This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: symbol patch
- From: Per Bothner <per at bothner dot com>
- To: Chris Dean <Chris dot Dean at sokitomi dot com>
- Cc: Kawa List <kawa at sources dot redhat dot com>
- Date: Fri, 31 Oct 2003 05:34:59 -0800
- Subject: Re: symbol patch
- References: <24716.1067410543@mercedsystems.com>
Chris Dean wrote:
- A version of symbol? that checks that the symbol is interned.
I don't think this is very "scheme-y" (or "lisp-y"). There are other
Scheme implementations that support unintered symbols, and I believe in
them symbol? returns true for an uninterned symbol. Common Lisp's
symbolp returns t for an uninterfed symbol.
- A version of string->symbol that looks up the intern method at compile
time.
(define (string->symbol (str <string>))
- (invoke (invoke str 'toString) 'intern))
+ (invoke (as <java.lang.String> (invoke str 'toString)) 'intern))
This doesn't appear to be needed any more. The result of disassembling
misc.class seems optimal to me:
Method name:"string$To$Symbol" public static Signature:
225=(gnu.lists.FString)j
ava.lang.String
Attribute "Code", length:50, max_stack:1, max_locals:1, code_length:8
0: aload_0
1: invokevirtual #25=<Method gnu.lists.FString.toString
()java.lang.String>
4: invokevirtual #28=<Method java.lang.String.intern ()java.lang.String>
7: areturn
Attribute "LocalVariableTable", length:12, count: 1
slot#0: name: 387=str, type: 68=gnu.lists.FString (pc: 0 length: 8)
Attribute "LineNumberTable", length:6, count: 1
line: 19 at pc: 0
--
--Per Bothner
per@bothner.com http://per.bothner.com/