|[12 earlier articles]|
|Re: The semicolon habit (was: Q: Definition email@example.com (1995-06-24)|
|Re: The semicolon habit (was: Q: Definition tim@handel.Princeton.EDU (1995-06-24)|
|Re: The semicolon habit (was: Q: Definition firstname.lastname@example.org (1995-06-30)|
|Re: The semicolon habit (was: Q: Definition email@example.com (1995-07-01)|
|Re: The semicolon habit (was: Q: Definition firstname.lastname@example.org (Paul Long) (1995-07-05)|
|Re: The semicolon habit (was: Q: Definition tim@debusy.Princeton.EDU (1995-07-05)|
|Re: The semicolon habit (was: Q: Definition email@example.com (Bertrand Meyer) (1995-07-10)|
|Re: The semicolon habit (was: Q: Definition firstname.lastname@example.org (1995-07-13)|
|From:||Bertrand Meyer <email@example.com>|
|Keywords:||Eiffel, syntax, design|
|Organization:||Interactive Software Engineering Inc.|
|Date:||Mon, 10 Jul 1995 20:58:05 GMT|
In Eiffel semicolons between instructions are optional.
[In a few rare cases the semicolon is required.
For example if an instruction starts with an opening
parenthesis - rare but possible - and the previous
one ends with an identifier, then the semicolon
is required to disambiguate between e.g.
x := f;
(a + b).send_to_moon
x := f (a+b);
... (no valid parsing of the remainder of the preceding
extract, but enough to confuse a simple parser)
Because in the Algol tradition extra semicolons are harmless,
everyone can use his favorite style: semicolon-as-terminator
(a la C, PL/I, Ada); semicolon-as-separator (Algol, Pascal);
The recommended style is to include the semicolons. Under
some pressure from academic colleagues who had told me that the
possibility of omitting semicolons was a great attraction
to their students, I recently toyed the idea of removing
this rule and proposing ``no semicolons unless between separate
instructions on the same line (if you accept this style),
or if required to avoid ambiguity'' as the recommended style.
But applying this tentative rule to a number of library classes
produced a result that I couldn't fathom. It just did not
look right. So I think the recommended style rule will remain
what it is, although every programmer can apply a different style
if he so prefers.
I think that relying on indentation or other forms of layout for
separating instructions or other language constructs with semantic
values is a bad idea. The concept of free-form syntax is widely
spread and widely appreciated. We should use layout to express
structure, and may enforce style rules on layout; but layout is too
weak a mark to allow us to entrust it with any effect whatsoever on
our programs' semantics. In particular, a line feed should not be
treated differently from a space, except for special cases such as
comments. I accept, however, that this is a topic on which the
differences between people's views are at least as much a result of
taste, habit and intuition as of completely rational arguments.
Bertrand Meyer, ISE Inc., Santa Barbara
805-685-1006, fax 805-685-6869, <firstname.lastname@example.org>
Web home page: http://www.eiffel.com
Return to the
Search the comp.compilers archives again.