[m-dev.] Commas considered optional

Ralph Becket rafe at cs.mu.OZ.AU
Thu Nov 29 15:50:48 AEDT 2001

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?

- 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

More information about the developers mailing list