[R6RS] Enumerations proposal pre-draft
William D Clinger
will at ccs.neu.edu
Mon Apr 24 10:04:37 EDT 2006
After considering Mike's arguments for adding enumerated
values as a new feature to Scheme, I still prefer to use
symbols. My reasons for preferring symbols are:
1. Historically, symbols have served as enumerated values.
This usage is cited in the first paragraph of R5RS 6.3.3.
2. Symbols have hardly any other purpose in Scheme. In
the R5RS, symbols represent identifiers only when eval is
called.
3. Case dispatch on symbols can be quite fast. There is
little if any efficiency to be gained by introducing a new
feature.
4. It is easier for implementors to make case dispatch
on symbols fast than to add a new feature for enumerated
values, to modify the semantics of case expressions in
some way that would allow the new enumerated values, and
to make case dispatch on those new enumerated values as
fast as case dispatch on symbols should be.
5. Even if enumerated values were added as a new feature,
symbols would continue to be used as enumerated values,
both in legacy code and in code written by programmers
who understand that the new feature is redundant with
symbols.
6. A compiler's responsibility to generate fast code for
case dispatch on symbols would therefore continue even if
the new feature were added.
7. Programming languages should be designed not by piling
feature on top of feature, but by removing the weaknesses
and restrictions that make additional features appear
necessary. In this case, the weaknesses are mostly in
current implementations of case expressions, but the
general principle still applies: the solution is to fix
the weaknesses in those implementations, not to add new
features to the language.
Will
More information about the R6RS
mailing list