This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: instance?


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]