Some middle-aged guy on the Internet. Seen a lot of it, occasionally regurgitating it, trying to be amusing and informative.

Lurked Digg until v4. Commented on Reddit (same username) until it went full Musk.

Was on kbin.social (dying/dead) and kbin.run (mysteriously vanished). Now here on fedia.io.

Really hoping he hasn’t brought the jinx with him.

Other Adjectives: Neurodivergent; Nerd; Broken; British; Ally; Leftish

  • 0 Posts
  • 117 Comments
Joined 1 year ago
cake
Cake day: August 13th, 2024

help-circle

  • Pretty sure druckef should be drucked. printf means print (to) file. “File” is valid German, but it is non-standard and “Datei” seems to be the preferred form.

    I could also argue that that d should be capitalised, but I’m already overstepping my bounds considering I know very little German.

    I wouldn’t want to say which should take precedence between C’s preference for all-lowercase keywords and functions and German’s Rule to capitalise all Nouns.











  • Now that you mention it, I do remember the backticks and symbols thing for infix, so yeah that’d be something extra that Haskell did. One of the few things about Haskell that wasn’t on the fringes of my capability and understanding as I recall.

    I remember thinking that it would be cool if other, more procedural, languages allowed it, but then most other languages also don’t have the capability of setting the precedence of new operators relative to old ones on the fly. A lot of that stuff is hard-coded into those languages’ compilers.




  • Yes. Most early BASICs even required that any reference to a function name, in definition or calling, be preceded by an FN keyword as well as the parentheses.

    QBASIC, Visual BASIC and the related dialects of BASIC found in MS Office and LibreOffice all have slightly better syntax for defining and calling functions than the older BASICs, but they all still require parentheses on their subroutine parameter lists too.

    At best, you might be able to call a subroutine by name with no empty parentheses after it, but as soon as you need parameters, you’ll need parentheses around them.

    But like I say, there was at least one rare BASIC that didn’t need them, so I’m assuming there might have been others that I’m not aware of.


  • (f x) works this way in Lisp - as in the joke - and Lisp descendants like Scheme. And then there’s Haskell which takes the whole thing a step further still.

    Also Perl, because Larry thought it would be fun(ctional). The external parentheses are technically optional in this case, but won’t break anything if included. Regular f(x) syntax is also supported there. (You could probably remake this meme with Python and Perl in first and second panels tbh.)

    And I know of at least one dialect of BASIC that allowed subroutine calls to lack their parentheses, so the same external parentheses thing would apply if that subroutine was a function.


  • Guido undoubtedly had a strong, strong hatred of the number of ways braces are overloaded in Perl.

    Do you really want an example?

    sub doHref { { do { ${someglobal{Href}} = {} }; last }; }

    Every single pairing there serves a different syntactic purpose. Some are related purposes, and I’ve crowbarred a few in unnecessarily for the sake of an example, but different nonetheless.

    The outer pair declares the sub, and the next pair is a free block that works as a once-through unlabelled loop, which is exited with the last. (Most other languages use break for this purpose.)

    The next pair are for the do which doesn’t act as a loop like the free block does. The next innermost pairing wrap a variable and the inner, innermost pairing indicate that the variable is a member of a hash (associative array) and we’re accessing the record named Href.

    The lone {} indicates a hash reference, so we’re assigning a reference to an empty, anonymous hash to that hash record.

    This example is ridiculous of course. There’s no need for most of those braces and syntax to do what it actually does. Also assigning to global variables is generally frowned upon.

    sub doHref { $someglobal{Href} = {} }

    … is equivalent and cuts out most of the guff. Still three different uses though.


  • Perl time:

    sub AUTOLOAD {
        our $AUTOLOAD=~s/.*:://;
        no strict;
        local $_=$_[0] and *STDOUT->$_($AUTOLOAD)
    }
    
    HelloWorld("print");
    

    Pro: You can Give HelloWorld any (syntactically valid) name you like and (as long as the parameter is "print", anyway) its name will be printed, no pre-declaration required.

    Con: The specified function inside the quotes has to be a method associated with a file descriptor.