lambdak: multi-line lambda implementation in native Python
Jussi Piitulainen
jpiitula at ling.helsinki.fi
Sat Jan 17 11:49:50 CET 2015
Steven D'Aprano writes:
> Ah, wait, I forgot Ruby's brilliant "feature" that whitespace
> *between* expressions is significant:
>
> [steve at ando ~]$ cat ~/coding/ruby/ws-example.rb
> #!/usr/bin/ruby
>
> def a(x=4)
> x+2
> end
>
> b = 1
> print "a + b => ", (a + b), "\n"
> print "a+b => ", (a+b), "\n"
> print "a+ b => ", (a+ b), "\n"
> print "a +b => ", (a +b), "\n"
>
> [steve at ando ~]$ ruby ~/coding/ruby/ws-example.rb
> a + b => 7
> a+b => 7
> a+ b => 7
> a +b => 3
>
>
> A shiny new penny for any non-Ruby coder who can explain that!
I've only seen small amounts of Ruby code on the net. The only way I
can make some sense of that is if it gets analyzed as follows, using
parentheses for calls:
a + b => 7 # a() + b => a(4) + b => 4 + 2 + 1
a+b => 7 # a() + b
a+ b => 7 # a() + b
a +b => 3 # a(+b) => a(b) => a(1) = 1 + 2
I'm not quite fond of such surprise in programming language syntax.
More information about the Python-list
mailing list