Syntax "surprise"

Thu, 25 Jul 2002 01:15:23 +0900, David Alan Black dblack@candle.superlink.net pisze:

I suspect that a Ruby-like language without commas separating method
arguments would end up with an awful lot of parentheses instead.

Indeed it implies more parentheses. I was experimenting with two
approaches to mixing space-separated and comma-separates argument
lists:

  1. The basic syntax is “function arg1 arg2 arg3” and additionally
    “,” means “) (”. So you can write either of these:
    func x y (g 3)
    func(x, y, g 3)
    func x (y, g 3)

  2. The basic syntax is “function arg1 arg2 arg2”. Expressions may
    return any number of results and they are interpolated into argument
    lists. “expr1, expr2” means to concatenate results of expressions.
    So the above are valid as well and have the same meaning.

So you can’t write commas without parentheses, but you never need to
parenthesize atomic expressions, commas can be avoided completely if
you like, and you can also consistently use the syntax “f(x, y, z)”
with usual precedence.

···


__("< Marcin Kowalczyk
__/ qrczak@knm.org.pl
^^ Blog człowieka poczciwego.