Hi All!
I agree that this is clearly an issue. Hacking the name, or using a
not-so-perfect replacement identifier is a clumsy workaround around
certainly. Quoting gives me the creeps to, but I could live with an
operator, or yes, even a keyword escape mechanism. A prefix escape
token would be especially handy I suspect, for the lexer as well as the
programmer. A leading underscore is not permitted in identifiers and is
not used in visible keywords, but is, I recall used internally. It
strikes me as a reasonable candidate. The percent character is also a
possiblity as it has limited use and I don't think would introduce any
ambiguity.
Examples:
_attribute
%attribute
or perhaps better,
_ attribute
% attribute (my favorite)
The lone underscore certainly is not ambiguous but I'm not all that keen
on it. The percent appears in quotes as an escape char, so having act
as an escape when outside of quotes seems to me the best option. It's in
use, it's probably not ambiguous, and the semantics are similar to
current ones (being a escape mechanism).
Depending on the lexer of course, it might be that the intervening
whitespace is optional, as there might be no need for a separator. I
dislike anything "optional" in syntax.
R
==================================================
Roger F. Osmond
----------------------------------------
Amalasoft Corporation
273 Harwood Avenue
Littleton, MA 01460
> -------- Original Message --------
> Subject: Re: [eiffel_software] Re: Using keywords as identifiers
> From: Peter Gummer <
[hidden email]>
> Date: Mon, May 11, 2009 7:53 pm
> To:
[hidden email]
> colinlema wrote:
> > I'm not aware of any keywords usable as identifiers in C#.
> >
> >
> All C# keywords are usable as identifiers, Colin, simply by prefixing
> the keyword with "@".
> I'm requesting similar functionality in Eiffel, except that I think a
> more Eiffelesque approach would be to surround the identifier with `'.
> Adding an underscore suffix is a hack. Although "attribute_" would
> impair the readability of the class text only mildly, the main problem
> is when this propagates through to other tools -- diagrams,
> documentation, XMI, etc. -- where "attribute_" would be the wrong name
> for publication to external parties.
> - Peter Gummer