This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Auto type conversion in target languages
- To: "Marisha Ray & Neil Jerram" <mpriz at dircon dot co dot uk>
- Subject: Re: Auto type conversion in target languages
- From: Jorgen `forcer' Schaefer <forcer at mindless dot com>
- Date: 22 Dec 1999 16:22:41 +0100
- Cc: <guile at sourceware dot cygnus dot com>
- References: <00a301bf4c56$8e0bce20$443670c2@mpriz.dircon.co.uk>
"Marisha Ray & Neil Jerram" <mpriz@dircon.co.uk> writes:
> From: Jorgen `forcer' Schaefer <forcer@mindless.com>
> >If in the tcl world someone says
> > double "100"
> >then foo can quite plausibly return 200, but the tcl reader for
> >Guile has no idea that double wants a number not a string.
> >
> >Has anyone any thoughts about this?
>
> Yes. I don't understand why the Guile/tcl reader needs to know that double
> expects a number. It is double that needs to know this: its implementation
> should convert its argument to a number. As far as the reader is concerned,
> it looks like a string, so it should be read as a string.
>
> But I suspect I may have misunderstood how you envisage the implementation
> of Tcl procedures like double.
It's not a problem for Tcl procedures to do this conversion, but
for already existing Guile procedures. You do want to use Guile
procedures from other languages guile can read, but currently you
have to predeclare them.
The double example was badly-chosen, sorry for that.
Better example: the inet-ntoa procedure of Guile (or any other
guile procedure that doesn't want a string)
In tcl you just want to be able to write
inet-ntoa "388639255"
because Tcl doesn't differenciate between numbers and strings -
they're converted as needed. For that above to work, the Tcl
reader needs to know that inet-ntoa wants a number and not a
string. Currently it requires the Tcl user to predeclare this in
the source file, which i think isn't the best solution.
Thus i was asking wether anyone has any thoughts about how to
improve this situation :)
-- forcer
--
((email . "forcer@mindless.com") (www . "http://forcix.cx/")
(irc . "forcer@#StarWars (IRCnet)") (gpg . "/other/forcer.gpg"))