Multiple-value-list with no values. 
Author Message
 Multiple-value-list with no values.

What is the supposed to be the result of multiple-value-list if it
acts on a value that has no elements.


Fri, 16 Jul 2004 10:20:43 GMT  
 Multiple-value-list with no values.

Quote:

> What is the supposed to be the result of multiple-value-list if it
> acts on a value that has no elements.

A look into the HyperSpec shows:
(multiple-value-list form) ==  (multiple-value-call #'list form)

So your question gets simplified to the question what is supposed
to be the result of (list) which is obviously the empty list.

ciao,
Jochen



Fri, 16 Jul 2004 11:43:49 GMT  
 Multiple-value-list with no values.
gOn Mon, 28 Jan 2002 04:43:49 +0100, Jochen Schmidt

Quote:


>> What is the supposed to be the result of multiple-value-list if it
>> acts on a value that has no elements.

>A look into the HyperSpec shows:
>(multiple-value-list form) ==  (multiple-value-call #'list form)

>So your question gets simplified to the question what is supposed
>to be the result of (list) which is obviously the empty list.

>ciao,
>Jochen

Welll Clisp returns (nil).


Fri, 16 Jul 2004 15:46:53 GMT  
 Multiple-value-list with no values.

Quote:

> gOn Mon, 28 Jan 2002 04:43:49 +0100, Jochen Schmidt


> >> What is the supposed to be the result of multiple-value-list if it
> >> acts on a value that has no elements.

> >A look into the HyperSpec shows:
> >(multiple-value-list form) ==  (multiple-value-call #'list form)

> >So your question gets simplified to the question what is supposed
> >to be the result of (list) which is obviously the empty list.

> >ciao,
> >Jochen
> Welll Clisp returns (nil).

That doesn't sound right.  Are you sure you aren't just seeing the
default nil value from binding to more variables than there are values
in the multiple-values?

e.g. (using Dylan syntax, sorry, it's more familiar, especiall the #rest
part at the end)

   let (a, b, c, d) = values(1, 2);

c and d get #f.  In CL they'll get nil.  For the same reason, x will get
#f/nil:

  let x = values();

But if you do...

  let (#rest z) = values();

... then z is an empty sequence.

-- Bruce



Fri, 16 Jul 2004 15:56:13 GMT  
 Multiple-value-list with no values.

Quote:



> > gOn Mon, 28 Jan 2002 04:43:49 +0100, Jochen Schmidt


> > >> What is the supposed to be the result of multiple-value-list if it
> > >> acts on a value that has no elements.

> > >A look into the HyperSpec shows:
> > >(multiple-value-list form) ==  (multiple-value-call #'list form)

> > >So your question gets simplified to the question what is supposed
> > >to be the result of (list) which is obviously the empty list.

> > >ciao,
> > >Jochen
> > Welll Clisp returns (nil).

> That doesn't sound right.

No, it doesn't.  And in the copy of CLISP I have handy (2000-03-06), I
get NIL.  If there are any versions of CLISP that return (NIL) here,
that's a bug and should be reported (unless they're really really old...)

--
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                              
   |     ) |                              
  (`-.  '--.)                              
   `. )----'                              



Fri, 16 Jul 2004 16:00:15 GMT  
 Multiple-value-list with no values.

Quote:




>> > gOn Mon, 28 Jan 2002 04:43:49 +0100, Jochen Schmidt


>> > >> What is the supposed to be the result of multiple-value-list if it
>> > >> acts on a value that has no elements.

>> > >A look into the HyperSpec shows:
>> > >(multiple-value-list form) ==  (multiple-value-call #'list form)

>> > >So your question gets simplified to the question what is supposed
>> > >to be the result of (list) which is obviously the empty list.

>> > >ciao,
>> > >Jochen
>> > Welll Clisp returns (nil).

>> That doesn't sound right.

>No, it doesn't.  And in the copy of CLISP I have handy (2000-03-06), I
>get NIL.  If there are any versions of CLISP that return (NIL) here,
>that's a bug and should be reported (unless they're really really old...)

I just tried:
(setf x (values-list nil))
(multiple-values-list x)
=>(nil)
version 2.27

Actually it came about because of something different I was doing:
(use-package "REGEXP")
(setf s "abcdef")
(setf reg-exp-match (multiple-value-list (match 'ghi" s)))
(if (not (nul reg-exp-match))
     (princ (subseq s (match-begin (car reg-exp-match))
                                (match-end   (car reg-exp-match)))))

where the princ crashes because (car reg-exp-match) is nil.
Actually it turns out that reg-exp-match is (nil).



Fri, 16 Jul 2004 16:33:49 GMT  
 Multiple-value-list with no values.

Quote:
> >No, it doesn't.  And in the copy of CLISP I have handy (2000-03-06), I
> >get NIL.  If there are any versions of CLISP that return (NIL) here,
> >that's a bug and should be reported (unless they're really really old...)
> I just tried:
> (setf x (values-list nil))
> (multiple-values-list x)
> =>(nil)
> version 2.27

[ I assume you meant multiple-value-list in the above, otherwise CLISP
  should have signalled an error. ]

That is completely correct behaviour:

- (values-list nil) produces 0 values, but since the right-hand side
  of the setf form will require exactly 1 value, that value is
  defaulted to nil, so x gets set to nil.
- (multiple-value-list nil) must return (nil), since evaluating nil
  yields exactly 1 value, namely nil, which is then returned.

To test what you wanted to test, you can do:

(multiple-value-list (values-list nil))

which yields nil, as expected.

You should be aware that multiple values deteriorate to 1 value in all
contexts other than those which are specified to handle
multiple-values specially, like e.g. m-v-bind, m-v-call, m-v-list, but
also progn, etc.

Quote:
> Actually it came about because of something different I was doing:
> (use-package "REGEXP")
> (setf s "abcdef")
> (setf reg-exp-match (multiple-value-list (match 'ghi" s)))
> (if (not (nul reg-exp-match))
>      (princ (subseq s (match-begin (car reg-exp-match))
>                                 (match-end   (car reg-exp-match)))))

> where the princ crashes because (car reg-exp-match) is nil.
> Actually it turns out that reg-exp-match is (nil).

That would indicate that match returns nil, and not 0 values.

Regs, Pierre.

--

 The most likely way for the world to be destroyed, most experts agree,
 is by accident. That's where we come in; we're computer professionals.
 We cause accidents.                           -- Nathaniel Borenstein



Fri, 16 Jul 2004 19:30:34 GMT  
 Multiple-value-list with no values.

Quote:
>[ I assume you meant multiple-value-list in the above, otherwise CLISP
>  should have signalled an error. ]

Yes. I always get confused whther the s goes with values-list or
multiple-value-list and once in a while make the typo.
I think it was a big mistake to name these two differently and they
should
have settled on values or value. The way it is now is just error
prone.


Fri, 16 Jul 2004 23:09:44 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. (values (multiple-value-form)) whats the point?

2. CGI getting multiple values with same name into a list

3. multiple values and lambda lists

4. lambda list in MULTIPLE-VALUE-BIND?

5. Turning a list value in a parameter into a list for eval without quasiquote/unquote

6. Removing the values from a list from another list

7. Generating a value from a VALUE ERROR

8. Comparing value in an input field to any value from another file

9. C4 - Autoincrementing default values for multi-valued template symbols

10. Copying one array value into subsequent array values

11. value dependent boolean to retain its sense when values would change boolean

12. how to set knobs to the dicreet values indicated and no values in between

 

 
Powered by phpBB® Forum Software