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:

> To me it doesn't seem sloppy, it actually seems more intuitive/natural
> than the scheme symbol -> java string mapping. But that's me - I'd
> quite like to have them both coerce.

The quetsion is:  Do you want to handle null?  If so, calling toString
will not work, though you could call String.valueOf.  That produces
"null" given a null pointer, which is not always what you want:
Sometimes you want "null", sometimes a null pointer, sometimes an
exception.  That is one reason it may be best to leave it to the
programmer.

Kawa does it make it possible to define new coercions and use them as
type specifiers.  It already has <String> (calls toString),
<java.lang.String> (casts to String), <string> (casts to FString).
You could define a new coercion that calls String.valueOf.
-- 
	--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]