Re: Semicolon wrangling (was Re: [friam] Minutes)

William ML Leslie <[email protected]> Sat, 20 Oct 2012 13:10:08 +1100
Newsgroups gmane.comp.lang.e.general
Message-ID <CAHgd1hGRzD7eokVux+8e8VDUof6f-q0faSBv7jZBC4wysEW97Q@mail.gmail.com>
On 20/10/2012, Kevin Reid <kpreid-M/[email protected]> wrote:
> On Oct 19, 2012, at 15:20, Norman Hardy wrote:
>> One question is whether semicolon is separator, or terminator.
>> I think that everyone agrees that commas are separators but Kevin noted
>> that some languages allow terminal commas.
>> Perhaps sqrt(x,) means the same as sqrt(x).
>> (I don’t like that.)
>
> For what it's worth, as a general rule in such languages, this is only
> permitted, or at least only used in practice, in uniform/variable-length
> things such as collection literals, not function arguments.

Some languages do support this in function arguments, I don't think it
is such a bad thing.  It means one less thing to have to worry about
when generating code from a language that doesn't have a sensible
reduce/join, or generating code from within emacs (it would be
/really/ useful in SQL).

If the meaning of the comma there can be confused with some other
usage of commas within the language, there's probably a deeper issue.

>> I grant the problem of accidental return values which must be addressed.
>> To me omitting semis is like omitting commas, or even plus signs.)

This point seems the most interesting to me.  If the target language
doesn't have implicit return (from functions/methods) the issue is
somewhat mitigated because you can see immediately if the value is
being discarded or used somehow.


Something I find unclear in the remaining discussion is the precedence
of the operations mentioned.  I took it that a newline was supposed to
be just like a semicolon, but then I wonder if

^def foo := makeFoo(); foo.setBar(baz)

binds foo to the result of makeFoo() or foo.setBar(baz).

I mean that, if this last-value feature of semicolon has any use, it
would be to allow the user to eventually bind the result to a name,
but this appears to be confused in the example.

I suppose you could make brackets or braces mandatory - it just looks
like binding has lower precedence to me.

-- 
William Leslie