--- nobuyoshi nakada said:
Hi,
=20
At Fri, 5 Aug 2005 00:29:55 +0900,
Eric Mahurin wrote in [ruby-talk:150730]:
Here is my proposal:
=20
{ args : code }
=20
Even if when you make the args : optional to preserve
compatibility, I think this would be parsable if you treat the
arg list (possibly with default expressions) like a normal
statment except that the delimiter is ":" instead of ";".=20 This
should work because an arg list is a syntactically valid
statement. i.e.
=20
a=3D1
other=3D[3,4]
a,b=3D2,*other
=20
When the lexer finds a ":" instead of a ";" or newline as the
statement delimiter of first statement, it would treat that as
the arg list.
=20
Default values can be very long beyond new lines, if it is a
block statement or is parenthesized. it seems very confusing
and I guess such parser is impossible. Leading sign would be
mandatory.
When I said ";" or newline, the newlines I'm talking about are
only those that delimit statements. So, you could have
newlines in your arglist as long as they don't look like a
statement terminator:
{ a,
b=3D
a*
a :
a*b
}
"->" has also been suggested instead of ":". And I suggested
;/newline if you can make the arg-list mandatory (possibly
empty).
Would you agree that any valid arg-list is also syntactically a
valid statement? Or am I wrong? Wouldn't this fact be useful
in parsing this optional arg-list?
You still have the problem of ambiguities with the hash though.
Here are a few potential options for that:
%h{ ... } # like another quoting operator
hash( ... ) # simply a Kernel method
h( ... )
{} seems too overloaded now:
{ key=3D>value, ... } # hash
{ code } # block/lambda without args
{ |args| code } # block/lambda with args
I think that the syntax should either be left alone or
backwards compatibility should be broken (where necessary) and
these ambiguities solved once and for all.
=09
____________________________________________________
Start your day with Yahoo! - make it your home page=20
http://www.yahoo.com/r/hs=20
=20