Re: The semicolon habit (was: Q: Definition

Bertrand Meyer <bertrand@eiffel.com>
Mon, 10 Jul 1995 20:58:05 GMT

          From comp.compilers

Related articles
[12 earlier articles]
Re: The semicolon habit (was: Q: Definition jan@neuroinformatik.ruhr-uni-bochum.de (1995-06-24)
Re: The semicolon habit (was: Q: Definition tim@handel.Princeton.EDU (1995-06-24)
Re: The semicolon habit (was: Q: Definition bevan@cs.man.ac.uk (1995-06-30)
Re: The semicolon habit (was: Q: Definition cbloom@utxvms.cc.utexas.edu (1995-07-01)
Re: The semicolon habit (was: Q: Definition plong@perf.com (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 bertrand@eiffel.com (Bertrand Meyer) (1995-07-10)
Re: The semicolon habit (was: Q: Definition jan@neuroinformatik.ruhr-uni-bochum.de (1995-07-13)
| List of all articles for this month |

Newsgroups: comp.compilers
From: Bertrand Meyer <bertrand@eiffel.com>
Keywords: Eiffel, syntax, design
Organization: Interactive Software Engineering Inc.
References: 95-04-193 95-07-042
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


and
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);
no semicolons.


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, <bertrand@eiffel.com>
Web home page: http://www.eiffel.com
ftp://eiffel.com
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.