This is the mail archive of the kawa@sourceware.cygnus.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]

Re: "foo" as string


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/

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