This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: query type of an instance
- From: Yaroslav Kavenchuk <kavenchuk at gmail dot com>
- To: Luis Casillas <luis at casillas dot org>
- Cc: kawa at sourceware dot org
- Date: Fri, 14 Dec 2007 12:49:54 +0200
- Subject: Re: query type of an instance
- References: <A613CC9B-9010-4DF8-9212-3D9F9528B41E@casillas.org>
Luis Casillas wrote:
You can just call the class() method on objects. Somewhere near the
top of your source file:
(define-namespace Object <java.lang.Object>)
... and then, when you want the class of foo:
(Object:class foo)
How to make it in REPL?
#|kawa:6|# (define x (cons 1 2))
#|kawa:7|# (define-namespace Obj <java.lang.Object>)
#|kawa:8|# (Obj:class x)
/dev/stdin:8:1: warning - no possibly applicable method '<init>/valueOf'
in java.lang.Object
gnu.mapping.WrongArguments: call to 'java.lang.Object.<init>()' has too
many arguments (2; must be 1)
at gnu.mapping.MethodProc.matchFailAsException(MethodProc.java:96)
at gnu.kawa.reflect.Invoke.applyN(Invoke.java:234)
at gnu.kawa.reflect.Invoke.apply(Invoke.java:99)
at gnu.mapping.CallContext.runUntilDone(CallContext.java:251)
at gnu.expr.ModuleExp.evalModule(ModuleExp.java:313)
at kawa.Shell.run(Shell.java:275)
at kawa.Shell.run(Shell.java:186)
at kawa.Shell.run(Shell.java:167)
at kawa.repl.main(repl.java:870)
--
WBR, Yaroslav Kavenchuk.