[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Why not adopt "Python Style" indentation for Ruby?

Yukihiro Matsumoto

5/18/2007 2:24:00 PM

Hi,

In message "Re: Why not adopt "Python Style" indentation for Ruby?"
on Fri, 18 May 2007 23:15:05 +0900, "S.Volkov" <svolkov@comcast.net> writes:

|imho: indentation should not define semantic;

Agreed.

|suggestion: make 'end' optional if code block contains only one statement;

I'm not sure if we can define syntax for above suggestion.

while cond
puts a
puts b # delimit by indentation or else??

or maybe

while cond: puts a # should be in same line

matz.

1 Answer

S.Volkov

5/18/2007 6:02:00 PM

0

"Yukihiro Matsumoto" <matz@ruby-lang.org> wrote in message
news:1179498273.407463.1345.nullmailer@x31.netlab.jp...
> Hi,
>
> In message "Re: Why not adopt "Python Style" indentation for Ruby?"
> on Fri, 18 May 2007 23:15:05 +0900, "S.Volkov" <svolkov@comcast.net>
> writes:
>
...
>
> |suggestion: make 'end' optional if code block contains only one
> statement;
>
> I'm not sure if we can define syntax for above suggestion.
>
> while cond
> puts a
> puts b # delimit by indentation or else??
You are right, not feasible - rejected :)

> or maybe
>
> while cond: puts a # should be in same line
Thus we introduce new semantic for newline!
Following construct becomes invalid (and confusing):
while cond: puts a
puts b
end
=>my personal opinion - NO

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:
#--
while cond : puts a ; puts b ;;
# but
while cond do puts a ; puts b end
#-- until - same as while
#--
if cond : p a ;;
#--
if cond : p a else p b ;;
#-- unless - same as if
#--
for var in expr : p var ;;
# but
for var in expr do p var end
#-- case - sorry my lunch time ended, has to return back to my office..

BRs
Sergey Volkov