Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

accessing second return value off of read-from-string

7 views
Skip to first unread message

Augustin Chan

unread,
May 30, 1996, 3:00:00 AM5/30/96
to

read-from-string returns 2 values, how do you access the
second one? We tried passing the read-from-string with
parameters to another function in order to access the 2
values, but that didn't seem to work. Should we use
funcall?

Aug

Michael Wein

unread,
May 30, 1996, 3:00:00 AM5/30/96
to Augustin Chan

No, you need multiple-value-bind (or a similar function like multiple-
value-let that is capable of accepting multiple values).

Michael Wein German Research Center phone:
++49(0)681/3025303
Research assistant for Artificial Intelligence fax:
++49(0)681/3025341
http://www.dfki.uni-sb.de

Erik Naggum

unread,
May 30, 1996, 3:00:00 AM5/30/96
to

[Augustin Chan]

| read-from-string returns 2 values, how do you access the second one?
| We tried passing the read-from-string with parameters to another
| function in order to access the 2 values, but that didn't seem to work.

see `nth-value' if you only want the second value.

--
sometimes a .sig is just a .sig

Michael Wein

unread,
May 31, 1996, 3:00:00 AM5/31/96
to

Erik Naggum wrote:
>
> > read-from-string returns 2 values, how do you access the second one?
> > We tried passing the read-from-string with parameters to another
> > function in order to access the 2 values, but that didn't seem to work.
>
> see `nth-value' if you only want the second value.

This is possible, however nth-value is intended as a universal accessor function for
sequences and not for retrieving multiple values.

Erik Naggum

unread,
Jun 1, 1996, 3:00:00 AM6/1/96
to

[Erik Naggum]

| see `nth-value' if you only want the second value.

[Michael Wein]

| This is possible, however nth-value is intended as a universal accessor
| function for sequences and not for retrieving multiple values.

reading the fine manual is highly recommended.

http://www.harlequin.com/books/HyperSpec/Body/mac_nth-value.html

you're confusing `nth' and `nth-value'.

scha...@wat.hookup.net

unread,
Jun 1, 1996, 3:00:00 AM6/1/96
to

try multiple-value-setq or multiple-value-bind. They are described in Steeles.
Hartmann Schaffer

Donald H. Mitchell

unread,
Jun 2, 1996, 3:00:00 AM6/2/96
to Augustin Chan

Augustin Chan wrote:
>
> read-from-string returns 2 values, how do you access the
> second one? We tried passing the read-from-string with
> parameters to another function in order to access the 2
> values, but that didn't seem to work.

CLtL2: p 181ff

The functions you may want to look at include
nth-value [already mentioned and only pertaining to multiple-vals]
multiple-value-bind [no such thing as multiple-value-let]
multiple-value-call
multiple-value-setq

If you really only want the second value [final stream position], use
(nth-value 1 (read-from-string ...))
Note, use 1 because it's a zero based index.

If you want to pass both values to a function (which I think you were
merely trying as a means of accessing the second val, but what the heck):
(multiple-value-call #'receiving-function (read-from-string ...))

If you want to create local vars (ala let) to hold the vals:
(multiple-value-bind (read-result stream-posit)
(read-from-string ...)
..forms..)

If you want to capture both values into existing vars:
(multiple-value-setq (read-result stream-posit)
(read-from-string ...))
..forms..

--
Donald H. Mitchell d...@pgh.net
Proactive Solutions, Inc. 412.835.2410
5858 Horseshoe Dr. 412.835.2411 (fax)
Bethel Park, PA 15102

Michael Wein

unread,
Jun 3, 1996, 3:00:00 AM6/3/96
to

Erik Naggum wrote:

> you're confusing `nth' and `nth-value'.

You are right, I am sorry for the mistake.

Stefan K. Bamberger

unread,
Jun 3, 1996, 3:00:00 AM6/3/96
to

In article <31B257...@pgh.net>, "Donald H. Mitchell" <d...@pgh.net> wrote:

And last but not least:
multiple-value-list

This function collects all multiple-values in a list. Than you only have
one value and can work with it as used to. (i.e. with nth :-) )

? (multiple-value-list (floor 5 2))
(2 1)

- stefan

_____________________________________________________________________
*** Support bacteria -- it's the only culture some people have! ****
_____________________________________________________________________
Stefan K. Bamberger email: ba...@informatik.uni-wuerzburg.de
Lehrstuhl f"ur Informatik VI voice : ++49 931 7056118
Universit"at W"urzburg / Germany Fax : ++49 931 7056120
_____________________________________________________________________

0 new messages