This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: extended "colon notation" [feedback needed]
Per Bothner wrote:
In addition to the check-in features, I'm considering the following:
(1) To check that a value is an instance of a type:
(TYPE:instance? VALUE)
;; same as (instance? VALUE TYPE)
Alternative syntaxes considered:
(TYPE:instanceof? VALUE) ;; similar to Java instanceof
(TYPE:? VALUE) ;; short and sweet
I prefer each of the alternatives over the first even though it seems to
be the most sensible choice.
(2) To cast a value to a type:
(TYPE:<- VALUE)
;; same as (as VALUE TYPE)
The <- is meant to be like the arrows in say number->string, but
backwards, since the target TYPE is mentioned first. It's a bit ugly,
so alternative syntax would be welcome.
This is tough. The best (of many even worse) ideas I have are:
(TYPE:-cast VALUE)
(TYPE:@cast VALUE)
(TYPE:for VALUE)
I wanted to suggest something like this
(*:<TYPE> VALUE)
but it won't work (because of <class> constants).
Is any of the above better than (as ...)?
Hmmmm, is this possible:
((TYPE) VALUE)
(3) Accessing the java.lang.Class for a class type:
(TYPE:.class)
;; similar to (Class:forName "TYPE"), or Java's TYPE.class
I like that best (a teeny odd but consistent).
Is my recollection that constructors can be invoked with:
(TYPE:new ...)
correct?
Jim