[m-dev.] Commas considered optional

David Overton dmo at cs.mu.OZ.AU
Thu Nov 29 16:35:08 AEDT 2001


On Thu, Nov 29, 2001 at 03:50:48PM +1100, Ralph Becket wrote:
> A common topic for debate is how to improve the syntax of Mercury.
> Possibly for the first time ever in the history of such discussions, we
> suggest taking something out: the commas.
> 
> We've just conducted an experiment on the parser making the use of
> commas optional, interpreting simple juxtaposition as indicating an
> implicit intervening comma.  We've used this change to successfully
> compile some test programs (including non-trivial programs such as
> samples/calculator.m) written without commas.
> 
> This takes us a step closer towards the syntactic style of languages
> like ML and Haskell.
> 
> The effect of the change is visually subtle, but rather pleasing IMHO.
> Conjunctions are just sequences of goals, argument lists are somewhat
> shorter and so forth.  The only thing you have to watch out for is that
> binary operators take precedence in the usual way, so
> 
> 	f(A - B  X + Y) = f((A - B) (X + Y)) = f(A - B, X + Y)
> 
> Are there any strong feelings out there on the subject?  In particular,
> can anybody think of a better use for juxtaposition than as a
> replacement for the comma?

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.

> 
> - Ralph
> 
> p.s. The source code for the compiler includes some 270,000 commas.  If
> you assume it takes 0.2s to type a comma (the real figure is probably
> higher) then in excess of 15 working hours have been spent typing commas
> in the compiler alone!
> --------------------------------------------------------------------------
> 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
> --------------------------------------------------------------------------

-- 
David Overton      Department of Computer Science & Software Engineering
PhD Student        The University of Melbourne, Victoria 3010, Australia
+61 3 8344 9159    http://www.cs.mu.oz.au/~dmo
--------------------------------------------------------------------------
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