This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: type declaration best practices?
* Per Bothner [2010-01-14 04:22+0100] writes:
> I like ML/Scala/Haskell-style pattern matching, and it would be nice
> to add that to Kawa. But coming up with a usable syntax that is
> flexible, readable, *and* generalizes syntax-rules-style patterns
> is not easy. And of course type-speciers are themselves a kind of
> pattern, which needs to be kept in mind when designing things.
Yes, or course.
> I had a cute idea for a a type specifier syntax: Change the old
> angle-backet syntax so it is no longer just a naming convention, but
> actually part of the syntax:
> (define x <int> 10)
> or
> (define x<int> 10)
> The difficulty is that the reader can't (I think) determine whether
> the '<' should a symbol "constituent" character, or part of a type
> specifier. It gets complicated because (in the future) we might
> want more complicated type-expressions. One could come up with
> some rules, losing some minor RnRS-compatibility in the default
> mode.
A single '<' might not work, but ":<" would probably be enough hint to
the reader. But that's about the same as "::" and the question is still
whether the reader produces a single form or spliced-in keywords.
An possible advantage of '<' would be that it could be used as opening
paren for type constructors. E.g. if we have type constructors union and
singleton, then something like this would work:
(define x:<union <int> <singleton #f>> 10)
still no better than
(define x::(union int (singleton #f)) 10)
Helmut