* (load) Question
@ 2003-02-16 4:53 Robert Uhl <ruhl@4dv.net>
2003-02-16 5:11 ` dvanhorn
0 siblings, 1 reply; 9+ messages in thread
From: Robert Uhl <ruhl@4dv.net> @ 2003-02-16 4:53 UTC (permalink / raw)
I have a file which contains something like the following:
(let ((x 3))
(+ x 4))
I want to be able to load it in and retrieve the value 7 (this is really
a massive over-simplification--what I'm actually doing is building a
massive data structure up by hand...). The problem is that (load
"filename") returns nothing. Now, I can use define to define a value,
but this is a very clumsy way to pass data back out.
Does anyone have any idea how to do what I'm trying to do? Shouldn't
(load) return the result of evaluating that file?
Thanks v. much.
--
Robert Uhl <ruhl@4dv.net>
The girl who remembers her first kiss now has a daughter who can't even
remember her first husband.
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: (load) Question
2003-02-16 4:53 (load) Question Robert Uhl <ruhl@4dv.net>
@ 2003-02-16 5:11 ` dvanhorn
2003-02-16 5:55 ` Robert Uhl <ruhl@4dv.net>
0 siblings, 1 reply; 9+ messages in thread
From: dvanhorn @ 2003-02-16 5:11 UTC (permalink / raw)
Cc: guile-user
Quoting "Robert Uhl <ruhl@4dv.net>" <ruhl@4dv.net>:
> I have a file which contains something like the following:
>
> (let ((x 3))
> (+ x 4))
>
> I want to be able to load it in and retrieve the value 7 (this is
> really
> a massive over-simplification--what I'm actually doing is building a
> massive data structure up by hand...). The problem is that (load
> "filename") returns nothing. Now, I can use define to define a value,
> but this is a very clumsy way to pass data back out.
>
> Does anyone have any idea how to do what I'm trying to do? Shouldn't
> (load) return the result of evaluating that file?
load returns an unspecified value according to R5RS. Does (eval (read)) suit
your needs?
HTH
-d
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: (load) Question
2003-02-16 5:11 ` dvanhorn
@ 2003-02-16 5:55 ` Robert Uhl <ruhl@4dv.net>
2003-02-16 6:32 ` Keith Wright
0 siblings, 1 reply; 9+ messages in thread
From: Robert Uhl <ruhl@4dv.net> @ 2003-02-16 5:55 UTC (permalink / raw)
dvanhorn@emba.uvm.edu writes:
>
> load returns an unspecified value according to R5RS. Does (eval
> (read)) suit your needs?
Yup, that's it. Bit of a nuisance--now that I know what to look for, I
was able to spot it in the docs. Thanks much.
--
Robert Uhl <ruhl@4dv.net>
There is no female Mozart because there is no female Jack the Ripper.
--Camille Paglia
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: (load) Question
2003-02-16 5:55 ` Robert Uhl <ruhl@4dv.net>
@ 2003-02-16 6:32 ` Keith Wright
2003-02-17 0:47 ` Robert Uhl <ruhl@4dv.net>
2003-02-19 8:33 ` Egil Moeller
0 siblings, 2 replies; 9+ messages in thread
From: Keith Wright @ 2003-02-16 6:32 UTC (permalink / raw)
Cc: guile-user
> From: ruhl@4dv.net (Robert Uhl <ruhl@4dv.net>)
>
> dvanhorn@emba.uvm.edu writes:
> >
> > load returns an unspecified value according to R5RS. Does (eval
> > (read)) suit your needs?
>
> Yup, that's it. Bit of a nuisance--now that I know what to look for, I
> was able to spot it in the docs. Thanks much.
Why nuisance? Load reads a whole file which may contain zero
or more definitions and zero or more expression. Choseing
one that gets returned would be kind of arbitrary, and then
what do you do if there are no expression?
-- Keith
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: (load) Question
2003-02-16 6:32 ` Keith Wright
@ 2003-02-17 0:47 ` Robert Uhl <ruhl@4dv.net>
2003-02-19 8:33 ` Egil Moeller
1 sibling, 0 replies; 9+ messages in thread
From: Robert Uhl <ruhl@4dv.net> @ 2003-02-17 0:47 UTC (permalink / raw)
Keith Wright <kwright@gis.net> writes:
>
> > > load returns an unspecified value according to R5RS. Does (eval
> > > (read)) suit your needs?
> >
> > Yup, that's it. Bit of a nuisance--now that I know what to look
> > for, I was able to spot it in the docs. Thanks much.
>
> Why nuisance? Load reads a whole file which may contain zero or more
> definitions and zero or more expression. Choosing one that gets
> returned would be kind of arbitrary, and then what do you do if there
> are no expression?
I'd follow the example of let, begin & friends: the last expression's
result is returned. If there are no expressions, it's undefined. Seems
fairly straightforward to me--at least, I cannot think of any reason
_not_ to have it behave thus.
Perhaps there's a good reason; I don't know. But it seems to me that
returning the result of the last expression would make sense.
--
Robert Uhl <ruhl@4dv.net>
Every man, woman, and responsible child has a natural, fundamental,
and inalienable human, individual, civil, and Constitutional right
(within the limits of the Non-Aggression Principle) to obtain, own,
and carry, openly or concealed, any weapon--handgun, shotgun, rifle,
machinegun, anything--any time, anywhere, without asking anyone's
permission. --L. Neil Smith
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: (load) Question
2003-02-16 6:32 ` Keith Wright
2003-02-17 0:47 ` Robert Uhl <ruhl@4dv.net>
@ 2003-02-19 8:33 ` Egil Moeller
2003-02-19 13:13 ` Andreas Rottmann
2003-02-19 17:35 ` Mikael Djurfeldt
1 sibling, 2 replies; 9+ messages in thread
From: Egil Moeller @ 2003-02-19 8:33 UTC (permalink / raw)
Cc: ruhl
> Why nuisance? Load reads a whole file which may contain zero
> or more definitions and zero or more expression. Choseing
> one that gets returned would be kind of arbitrary, and then
> what do you do if there are no expression?
What is the retun-value of a function? A function might contain multiple
definitions and expressions, too. The value is the value of the last one.
Why not have the same deifinition for load? And if there are not
expressions, then, just let the value returned be undefined or whatever.
As (load) is defined in teh standard to return an undefined value, this
could very well be specified as an extenssion, without breaking the
standard. Perheaps as an SRFI?
--
http://redhog.org
GPG Public key: http://redhog.org/PGP%20Public%20key.asc
Hi! I'm a .signature virus! Copy me into your ~/.signature to help me spread!
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: (load) Question
2003-02-19 8:33 ` Egil Moeller
@ 2003-02-19 13:13 ` Andreas Rottmann
2003-02-19 14:21 ` Dale P. Smith
2003-02-19 17:35 ` Mikael Djurfeldt
1 sibling, 1 reply; 9+ messages in thread
From: Andreas Rottmann @ 2003-02-19 13:13 UTC (permalink / raw)
Cc: Keith Wright
Egil Moeller <redhog@redhog.org> writes:
>> Why nuisance? Load reads a whole file which may contain zero
>> or more definitions and zero or more expression. Choseing
>> one that gets returned would be kind of arbitrary, and then
>> what do you do if there are no expression?
>
> What is the retun-value of a function? A function might contain multiple
> definitions and expressions, too. The value is the value of the last one.
> Why not have the same deifinition for load? And if there are not
> expressions, then, just let the value returned be undefined or whatever.
> As (load) is defined in teh standard to return an undefined value, this
> could very well be specified as an extenssion, without breaking the
> standard. Perheaps as an SRFI?
>
I would second that, as I have hacked up a modified version of load
for use in my code (at the C level) that does exactly that.
Regards, Andy
--
Andreas Rottmann | Dru@ICQ | 118634484@ICQ | a.rottmann@gmx.at
http://www.8ung.at/rotty | GnuPG Key: http://www.8ung.at/rotty/gpg.asc
Fingerprint | DFB4 4EB4 78A4 5EEE 6219 F228 F92F CFC5 01FD 5B62
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: (load) Question
2003-02-19 13:13 ` Andreas Rottmann
@ 2003-02-19 14:21 ` Dale P. Smith
0 siblings, 0 replies; 9+ messages in thread
From: Dale P. Smith @ 2003-02-19 14:21 UTC (permalink / raw)
Cc: kwright
On Wed, 19 Feb 2003 14:13:33 +0100
Andreas Rottmann <a.rottmann@gmx.at> wrote:
> Egil Moeller <redhog@redhog.org> writes:
>
> >> Why nuisance? Load reads a whole file which may contain zero
> >> or more definitions and zero or more expression. Choseing
> >> one that gets returned would be kind of arbitrary, and then
> >> what do you do if there are no expression?
> >
> > What is the retun-value of a function? A function might contain multiple
> > definitions and expressions, too. The value is the value of the last one.
> > Why not have the same deifinition for load? And if there are not
> > expressions, then, just let the value returned be undefined or whatever.
> > As (load) is defined in teh standard to return an undefined value, this
> > could very well be specified as an extenssion, without breaking the
> > standard. Perheaps as an SRFI?
> >
> I would second that, as I have hacked up a modified version of load
> for use in my code (at the C level) that does exactly that.
How about a lower level routine that returns that last expression. You
would then have load call that and just return SCM_UNDEFINED.
-Dale
--
Dale P. Smith
Senior Systems Consultant, | Treasurer,
Altus Technologies Corporation | Cleveland Linux Users Group
dsmith@altustech.com | http://cleveland.lug.net
440-746-9000 x239 |
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: (load) Question
2003-02-19 8:33 ` Egil Moeller
2003-02-19 13:13 ` Andreas Rottmann
@ 2003-02-19 17:35 ` Mikael Djurfeldt
1 sibling, 0 replies; 9+ messages in thread
From: Mikael Djurfeldt @ 2003-02-19 17:35 UTC (permalink / raw)
Cc: Keith Wright
Egil Moeller <redhog@redhog.org> writes:
> What is the retun-value of a function? A function might contain multiple
> definitions and expressions, too. The value is the value of the last one.
> Why not have the same deifinition for load? And if there are not
> expressions, then, just let the value returned be undefined or whatever.
> As (load) is defined in teh standard to return an undefined value, this
> could very well be specified as an extenssion, without breaking the
> standard.
In Guile, we try to return #<unspecified> in cases where the standard
defines the result as unspecified. The reason is that Guile wants to
encourage people to write portable Scheme code.
> Perheaps as an SRFI?
You'd be most welcome to submit an SRFI. I'd guess you'd have a hard
time with this one, though...
If many application writers find this behaviour useful, I suggest
*some* function with this behaviour is supplied in a Guile module.
Best regards,
Mikael D.
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2003-02-19 17:35 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-16 4:53 (load) Question Robert Uhl <ruhl@4dv.net>
2003-02-16 5:11 ` dvanhorn
2003-02-16 5:55 ` Robert Uhl <ruhl@4dv.net>
2003-02-16 6:32 ` Keith Wright
2003-02-17 0:47 ` Robert Uhl <ruhl@4dv.net>
2003-02-19 8:33 ` Egil Moeller
2003-02-19 13:13 ` Andreas Rottmann
2003-02-19 14:21 ` Dale P. Smith
2003-02-19 17:35 ` Mikael Djurfeldt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).