Re: Prefix, not postfix (poll)
Per Bothner 15 Apr 2006 06:00 UTC
Marc Feeley wrote:
> My feeling is that the colon character does not belong in symbols anyway
> (either in the middle or at the end). It should be reserved as an infix
> operator to denote a qualified reference to a module (i.e. foo:bar
> should mean the thing called bar in the module foo). Many programming
> languages use such a notation, and in fact many Scheme programs use this
> notation for their own 90%-solution modules.
Kawa uses colon more generally as a "component-extraction" operator.
See http://www.gnu.org/software/kawa/PathExpressions.html
Basically the reader translates
expression:name
to:
($lookup$ expression 'name)
and then the $lookup$ operation does the appropriate thing depending on
the type of expression. This includes Java field and method lookup,
and namespace/package lookup. There are various compile-type
optimizations, plus some kludges for quoting, and for backwards
compatibility with code that uses colons in identifiers.
It's a more general and elegant solution (in my not-so-humble
opinion, of course) than the "JavaDot" notation used in some other
Java-based Scheme implementations.
--
--Per Bothner
xxxxxx@bothner.com http://per.bothner.com/