News for hackers. Stuff that matters.
Re:Elvish – An experimental Unix shell in Go by zokier on Saturday July 26, 2014 @05:11PM (#8090812)
It would be nice if

    put 1 2 3 4 5 | filter {|x| > $x 2} | map {|x| * 2 $x}
could be written just as

    put 1 2 3 4 5 | filter > $_ 2 | map * 2 $_
Re:Elvish – An experimental Unix shell in Go by tinco on Saturday July 26, 2014 @05:29PM (#8090865)
can you express that grammar in ebnf? I think the parser would need to be at least ll(C) where C is bigger than 1.

Would the presence of $_ denote a lambda? how would nested lambda's work?

Why not:

    put 1 2 3 4 5 | filter -> > $1 2 | map -> * 2 $1
I think that would be easier to parse, and not much typing overhead, also $_ is a weird thing.
Re:Elvish – An experimental Unix shell in Go by e12e on Sunday July 27, 2014 @03:32AM (#8092217)
This is equivalent to the following bash incantation?:

    cat <<eof\
     | while read a;do if [[ $a -gt 2 ]];then echo $a;fi; done \
     |while read b;do echo $((b*2));done
    1
    2
    3
    4
    5
    eof
(Better expressed with seq):

    seq 5 \
    | while read a;do if [[ $a -gt 2 ]];then echo $a;fi; done \
    | while read b;do echo $((b*2));done
But we can do (a little) better:

    # Ok, this is a bit odd, the filter is actually inverse...
    filter()
    {
        while read it
        do
          #NOT SAFE!!
          if eval ${*}
          then
            echo "${it}"
          fi
        done
    }

    map()
    {
        while read it
        do
          #NOT SAFE!!
          eval ${*}
          echo "${it}"
        done
    }

    #Valid bash:
    seq 5 \
    | filter test '$it' -gt 2 \
    | map 'it=$((it*2))'
Sorry, didn't mean to turn this into stack overflow, the "simple" syntax just tickled me...
Re:Elvish – An experimental Unix shell in Go by Dewie on Saturday July 26, 2014 @05:34PM (#8090877)
Some languages have a sort-of default variable name for cases like this, namely "it":

> put 1 2 3 4 5 | filter > $it 2 | map * 2 $it

Re:Elvish – An experimental Unix shell in Go by JadeNB on Sunday July 27, 2014 @01:18PM (#8093318)
As zokier was presumably pointing out, other languages have a different sort-of-default variable name, namely `$_` (http://c2.com/cgi/wiki?DollarUnderscore). :-)