From: Augustin Chan
Subject: accessing second return value off of read-from-string
Date: 
Message-ID: <4ok5au$rpq@sdcc12.ucsd.edu>
	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

From: Michael Wein
Subject: Re: accessing second return value off of read-from-string
Date: 
Message-ID: <31ADBD3B.41C67EA6@dfki.uni-sb.de>
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.  Should we use
>         funcall?

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
From: Erik Naggum
Subject: Re: accessing second return value off of read-from-string
Date: 
Message-ID: <3042464163910489@arcana.naggum.no>
[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
From: Michael Wein
Subject: Re: accessing second return value off of read-from-string
Date: 
Message-ID: <31AED85C.167EB0E7@dfki.uni-sb.de>
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.

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
From: Erik Naggum
Subject: Re: accessing second return value off of read-from-string
Date: 
Message-ID: <3042613720912308@arcana.naggum.no>
[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'.

-- 
sometimes a .sig is just a .sig
From: Michael Wein
Subject: Re: accessing second return value off of read-from-string
Date: 
Message-ID: <31B2B441.59E2B600@dfki.uni-sb.de>
Erik Naggum wrote:

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

You are right, I am sorry for the mistake.

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
From: ········@wat.hookup.net
Subject: Re: accessing second return value off of read-from-string
Date: 
Message-ID: <4oq1u3$gqc@nic.wat.hookup.net>
try multiple-value-setq or multiple-value-bind.  They are described in Steeles.
                                 Hartmann Schaffer
From: Donald H. Mitchell
Subject: Re: accessing second return value off of read-from-string
Date: 
Message-ID: <31B257D7.209E@pgh.net>
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              ···@pgh.net
Proactive Solutions, Inc.       412.835.2410
5858 Horseshoe Dr.              412.835.2411 (fax)
Bethel Park, PA 15102
From: Stefan K. Bamberger
Subject: Re: accessing second return value off of read-from-string
Date: 
Message-ID: <bambi-0306961301500001@wi6a66.informatik.uni-wuerzburg.de>
In article <·············@pgh.net>, "Donald H. Mitchell" <···@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

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