Comment

Comment by lifthrasiir

Raku [1] deserves a honorable mention where it has named anonymous parameters, written as `$^x` and ordered lexicographically.

In my taste as a PL enthusiast, the biggest problem with this kind of anonymous parameters is a conflict with nested blocks. Suppose that our fictitious language is expression-oriented, `{ |x| ... }` denotes an explicit closure, `{ ... }` denotes an implicit closure and `$1`..`$n` are anonymous parameters in them. Consider the following examples:

    { $1 + $2 }             // Yeah, that would be `{ |x, y| x + y }`
    {}                      // Is this a zero argument function?
    { $100 }                // Does this have 100 arguments???
    { |x| $1 + $2 }         // Maybe this should be invalid...
    { { |x| $1 + $2 } }     // But maybe this should be okay??
    { { |x| $1 + x }($2) }  // And same to this???
    { { |x| $1 }($2) }      // Uh...
    { { $1 }($2) }          // Should be same to above, but...
    { { $2 }($1) }          // Not this (and will fail)!
The problem is much worse when you don't even have an explicit boundary like `{ ... }`. A limited form of automatic function, say `_ + _` without no parentheses, might work, but anything beyond that quickly devolves into a mess.

[1] https://docs.raku.org/language/variables#Variables

parent lifthrasiir 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton