• gex@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      6 months ago

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

      OpenFileOrDie()
      
          • frezik@midwest.social
            link
            fedilink
            arrow-up
            1
            ·
            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.

  • taanegl@beehaw.org
    link
    fedilink
    arrow-up
    0
    ·
    6 months ago

    I’m just hoping this paves the way to code with Southern dialect

    iffun is == true
    iffun ain't == false
    
      • frezik@midwest.social
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        6 months ago

        That reminds me of an old paper about how to create a compilable C program out of old game ROMs. Decompile to assembly. Implement a bunch of #define statements that implement all the ASM statements. Now compile it to a native binary on whatever platform.

        Won’t likely be faster or more accurate than regular emulation methods, but it’s a neat idea considering that the source code on all this stuff was lost a long time ago.

    • jtk@lemmy.sdf.org
      link
      fedilink
      English
      arrow-up
      1
      ·
      edit-2
      6 months ago

      I would have bought it if they said ifnot instead, it’s the same number of characters and wouldn’t require a major parser overhaul to support keywords with a ’ in the name.