S.Volkov
5/19/2007 8:29:00 AM
"Yukihiro Matsumoto" <matz@ruby-lang.org> wrote in message
news:1179512451.328481.6736.nullmailer@x31.netlab.jp...
> Hi,
>
> In message "Re: Why not adopt "Python Style" indentation for Ruby?"
> on Sat, 19 May 2007 03:15:17 +0900, "S.Volkov" <svolkov@comcast.net>
> writes:
>
> |imho: we need special terminator anyway, now it is 'end', could be
> another;
> |suggestion: introduce ';;' terminator for 'implicit blocks (not started
> with
> |class/module/def/do/begin), ie:
>
> For your information, 1.9 once had exact same syntax you've proposed
> for a short while. I have a time machine. The idea was abandoned
> since it caused serious unreadability.
always? may be real cause was abuse of this syntax?
well, if suffix did not work,
can we try prefix syntax for 'end'-less constructs?
(if not has been tried before)
suggestion:
:& - prefixes 'single statement body' code block in
class/module/def/unless/then/else/while/until
#- samples
if cond :& puts a
if cond : puts a else :& puts b
while cond :& puts a
for var in expr :& puts var
# also valid:
if cond :& (puts a; puts b)
while cond :& begin puts a end
#- single statements 'chain'
unless cond_a
:& for ea in expr
:& for eb in ezpr
:& if cond(ea, eb)
:& do_smthng
#- simple functor with local state
class<<fib=Object.new
:& def get(m)
:& (@fh||=Hash.new{|h,n|h[n]=n<2?n:h[n-1]+h[n-2]})[m]
fib.get 10
#-> 55
BRs
Sergey