Bracketed comments

From Successor ML

Jump to: navigation, search


PL/I, in the days of 029 keypunches and hence a limited character set, began the tradition of /**/ for comment delimiters. Both c and Java continue this tradition. ML switched to the superior (**) and introduced nested comments. However, students may stumble across (op *) and take a dislike to SML. The following RFC is intended to remedy this small language design error.


1. Introduction --- The change is straightforward. Replace (* with (. and *) with .)

2. Motivation and examples ---- The motivation is mainly the fact that op * cannot be parenthesized in a pleasant manner. While such parentheses are never required, code such as op * (,prices))

is harder to read than (op *) (ListPair,zip(quantities,prices))

especially for beginners. A secondary motivation is that some find (..) to be esthetically superior.

3. Assumptions --- None.

4. Formal syntax --- In the Definition of Standard Ml (revised), (the Defintion), replace (* by (. and *) by .) in all occurances. These occur on pages 4, 91 and the first page of the Index. (The index incorrectly states that page 5 has (* or *).)

5. Formal static semantics --- There does not appear to be any mention in the Definition of the effect of comments in tokenizing code. Specifically then, each full comment is to be treated, in forming tokens, as whitespace, equivalently, as replacable by the single character #" ".

6. Formal dynamic semantics --- None.

7. Interactions with previous proposals and other language features --- None.

8. Porting issues --- This change breaks almost all existing SML code. There is a trivial translation required, easily automated.

9. Implementation issues --- Lexers will require a simple modification.


From the Definition, the wildcard pattern row '...' cannot be parenthesized, so '(...)' is unambiguously a comment. Making the proposed change commits all future generations of sML to avoid allowing the wildcard pattern row to be parenthesized, including beginning or ending any parenthesizable entity.

Personal tools