This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: instance?
- From: Per Bothner <per at bothner dot com>
- To: Chris Dean <ctdean at sokitomi dot com>
- Cc: dominique dot boucher at nuecho dot com, "'T. Dampier'" <dampier at mercedsystems dot com>, "'Kawa List'" <kawa at sources dot redhat dot com>
- Date: Mon, 23 Feb 2004 15:09:10 -0800
- Subject: Re: instance?
- References: <000c01c3fa17$f7c6f970$6400a8c0@Forman> <27933.1077573367@mercedsystems.com>
Chris Dean wrote:
I like all of these ideas, even if I disagree with some of the syntax.
How about this syntax:
(define-namespace date <java.util.Date>) ; create the namespace
(date:new) ; (make <java.util.Date>)
(date:some-method x) ; (invoke x 'some-method)
(date:instance? x) ; (instance? x <java.util.Date>)
I have no objections to this.
I'm not saying I'd veto (date:? x) either, but it is a little strange
looking, and I think (date:instance? x) would be more readable.
> (date:class) ; <java.util.Date> equivalent
This should perhaps be (date:type) or date:type (a variable).
<java.util.Date> evaluates to gnu.bytecode.ClassType instance,
not a java.lang.Class instance.
We could even change the name of define-namespace to define-alias in
Kawa Scheme if we thought it was useful to separate the usage above with
the semantics of the namespace concept in XML.
Er... define-alias already exists, and can be used for "typedefs".
See kawa/lib/arrays.scm.
Dominique Boucher wrote:
> Also, it would be really nice to be able to use the namespace in the
> type declarations. Something along the line of
>
> (define-namespace foo "class:some.java.class")
>
> (define (a-function (arg :: foo))
> ...)
That would pollute name lookup. define-namespace defines a name
*prefix*, not name in the normal scope. It's implemented similar to:
(define-constant $Namespace$ "class:some.java.class")
--
--Per Bothner
per@bothner.com http://per.bothner.com/