This is the mail archive of the
kawa@sourceware.cygnus.com
mailing list for the Kawa project.
Re: "foo" as string
- To: Luke Gorrie <luke at bluetail dot com>
- Subject: Re: "foo" as string
- From: Per Bothner <per at bothner dot com>
- Date: 10 Mar 2000 16:13:40 -0800
- Cc: kawa at sourceware dot cygnus dot com
- References: <lh4safjazt.fsf@cockatoo.bluetail.com>
Luke Gorrie <luke@bluetail.com> writes:
> Would it be a nice feature to have kawa.lang.FString coercable to
> java.lang.Sting for the purposes of invoke? At the moment I have a
> bunch of things like:
>
> (make <javax.swing.JLabel> (str "My label"))
> (define (str s) (invoke s 'to-string))
It might be convenient. However, it is not clear tht sloppier
use of types is a good idea. Though the confusion between Scheme
strings and Java Strings has certainly caused some problems.
> Or am I missing something?
One problem is performance. If we know at compile time that
the actual argument is a non-null FString, and the method needs a String,
then it is easy enough to insert a toString call - in fact that
is what the <String> pseudo-type does.
You can do:
(make <javax.swing.JLabel> (as <String> "My label"))
(see the Kawa manual)
However, if the actual argument is null, the calling toString
will fail, though a cast to <java.lang.String> would work.
--
--Per Bothner
per@bothner.com http://www.bothner.com/~per/