2 ms·
This closure syntax, with the vertical bars around the parameter: peach {|h| ssh root@$h[name] $h[cmd] } $hosts Does it harken back to some popular langua
by __MatrixMan__ 2y ago
This closure syntax, with the vertical bars around the parameter:
peach {|h| ssh root@$h[name] $h[cmd] } $hosts
Does it harken back to some popular language? I first encountered it in nushell but now that I've seen it in elvish I'm wondering where it came from.
- svieira 2y agoRuby did it first, but it goes farther back at least to Smalltalk if not further.
- xiaq 2y agoIt wasn't directly borrowed from any other language (https://news.ycombinator.com/item?id=40317577 https://news.ycombinator.com/item?id=40317577) but there's definitely something nice about the syntax that causes multiple languages to use it. Elvish predates Nushell by quite a few years BTW :)
- __MatrixMan__ 2y agoI had that backwards, perhaps they took inspiration from you :)
- sestep 2y agoRust uses the same syntax: https://doc.rust-lang.org/book/ch13-01-closures.html https://doc.rust-lang.org/book/ch13-01-closures.html
- steveklabnik 2y agoWhich came from Ruby which came from Smalltalk.