• Trailblazing Braille Taser
    link
    fedilink
    2076 months ago

    I propose a new, more threatening kind of control flow.

    do {
      /* something */
    } or else {
      /* you don't want to find out */
    }
    
    • @[email protected]
      link
      fedilink
      586 months ago

      Some C++ style guides suggest the following naming convention for functions that crash on any error

      OpenFileOrDie()
      
          • @[email protected]
            link
            fedilink
            10
            edit-2
            6 months ago

            Perl also has unless() for the very purpose in OP, which is a more sensible choice.

            Oh, and if you need to reinforce your belief that Perl is a mess, the single-quote character can be used as a package separator instead of “::”. This was set in the 90s when nobody was quite sure of the right syntax for package separators, so it borrowed “::” from C++ and the single quote from Ada (I think).

            That means the ifn't() in OP can be interpreted as calling the t() function on the ifn package.

            The “::” separator is vastly preferred, though. Single quotes run havoc on syntax highlighting text editors (since they can also be used for strings). About the only time I’ve seen it used is a joke module, Acme::don't.

      • @[email protected]
        link
        fedilink
        English
        106 months ago

        Personally, I like to call catched exception variables up, so for a rethrow I can throw up;.

        • @[email protected]
          link
          fedilink
          25 months ago

          Except rethrowing an exception in C# is just throw;, anything else is a crime against the person who reads your stacktraces.

      • @[email protected]
        link
        fedilink
        46 months ago

        One of the modules in a project I’m working on is called VulkanOrDie which always makes me crack up when I see it in the compilation messages.

      • @[email protected]
        link
        fedilink
        English
        36 months ago

        It’s funnier when you try to SysCallAndDie() :-P

        (that’s a real thing in perl btw - I guess that function didn’t get the memo)

    • @[email protected]
      link
      fedilink
      86 months ago

      It exists, kind of. Python has this construct

      for item in iterable:
          ...
      else:
           ...
      

      which always puzzles me, since it depends on a break statement execution. I always have to look it up when the else block is executed.