[m-dev.] Commas considered optional

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Nov 29 19:40:22 AEDT 2001


On 29-Nov-2001, Michael Day <mikeday at bigpond.net.au> wrote:
> 
> > This proposal might be desirable for conjunctions where you
> > typically use a newline between conjuncts so the removal of the comma
> > wouldn't make a huge difference to the ``visual parsing'' of the program.
> > However, in the example you give above, eliminating the commas between
> > arguments makes the code harder to read, IMHO.  It is quite hard to
> > tell where one argument ends and the next one starts and also makes it
> > hard to quickly ascertain the arity of f.
> 
> So... make commas optional?

Yes, see subject line ;-)
That is needed for backwards compatibility, if nothing else.
It is also what I implemented.

> Seems to satisfy both cases. And and and...  
> they wouldn't be necessary in typeclass definitions??

Right.  The parentheses would still be needed, though.

> (What about current code that overloads ','/2, would that be equivalent to 
> overloading juxtaposition too?)

In my initial implementation, I made juxtaposition be parsed as ','/2.
But I think it might be nicer to make juxtaposition of terms
(other than in arguments or lists) be parsed as a special operator,
such as ' '/2, and then have ' '/2 be recognized by the compiler as an
alternative syntax for conjunction.  That way juxtaposition could be
used for conjunction, but it would be up to the user or library developer
to decide whether or not they want it to be used for pairs.

Another point is that in my initial implementation, I gave juxtaposition
the same operator predence and associativity as ',', but it would be
trivial to change that if desired.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list