[plt-scheme] Why does (begin ((lambda () (values))) (display "k")) fail?

From: ifconfig nslookup (nslookupifconfig at hotmail.com)
Date: Wed May 19 16:52:58 EDT 2004

You can return no values, but that causes the errors you experienced.
There is another solution, though.
Return a void value
(define (foo bar)
  (display bar)
  (void))


> (foo "baz")
baz
>


ifconfig 

-----Original Message-----
From: plt-scheme-admin at list.cs.brown.edu
[mailto:plt-scheme-admin at list.cs.brown.edu] On Behalf Of Anders Conradi
Sent: Wednesday, May 19, 2004 9:22 PM
To: ifconfig
Cc: 'Noel Welsh'; plt-scheme at list.cs.brown.edu
Subject: Re: [plt-scheme] Why does (begin ((lambda () (values))) (display
"k")) fail?

  For list-related administrative tasks:
  http://list.cs.brown.edu/mailman/listinfo/plt-scheme


On onsdag, maj 19, 2004, at 14:45 Europe/Stockholm, ifconfig wrote:

>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> The problem is not that the call to values has no arguments, it is 
> that the
> expression that accepts (values) gets 0 values instead of 1.
> An example:
>
> Welcome to DrScheme, version 207.
> Language: Pretty Big (includes MrEd and Advanced).
>> (call-with-values (lambda () (values 1 2 3))
>                     list)
> (1 2 3)
>> (call-with-values (lambda () (values 1 2))
>                     list)
> (1 2)
>> (call-with-values (lambda () (values 1))
>                     list)
> (1)
>> (call-with-values (lambda () (values))
>                     list)
> ()
>>
>

Thanks. I was just in to much of a Common Lisp mode when I wanted to 
have a nil function that didn't return any values. Now I have found the 
void function that seems to be what I was after. By now I am well on my 
may to be terminally confused by continuations instead. :)

> Yours,
> ifconfig.
>
>
>> -----Original Message-----
>> From: plt-scheme-admin at list.cs.brown.edu [mailto:plt-scheme-
>> admin at list.cs.brown.edu] On Behalf Of Noel Welsh
>> Sent: Wednesday, May 19, 2004 1:02 PM
>> To: Anders Conradi; plt-scheme at list.cs.brown.edu
>> Subject: Re: [plt-scheme] Why does (begin ((lambda () (values))) 
>> (display
>> "k")) fail?
>>
>>   For list-related administrative tasks:
>>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>
>>
>> --- Anders Conradi <beque at telia.com> wrote:
>>
>>> Welcome to DrScheme, version 206p1.
>>> Language: Standard (R5RS).
>>>> (define l (lambda () (values)))
>>>> (begin (l) (display "k"))
>>> context expected 1 value, received 0 values
>>>> ((lambda () (begin (l) (display "k"))))
>>> k
>>
>> I can confirm this works in MzScheme but displays an
>> error in DrScheme (in the MzScheme language no less).
>> It is due to the call to values with no value
>> supplied.  Some smaller examples:
>>
>>> (values)
>>
>>> (begin (values) 1)
>> context expected 1 value, received 0 values
>>
>>> (display (values))
>> [bug icon] context expected 1 value, received 0 values
>>
>> I can't explain it, but it only seems to occur when
>> the value of (values) is used in another expression.
>>
>> Noel
>>
>>
>> =====
>> Email: noelwelsh <at> yahoo <dot> com
>> Jabber: noelw <at> jabber <dot> org
>>
>>
>>
>>
>> __________________________________
>> Do you Yahoo!?
>> SBC Yahoo! - Internet access at a great low price.
>> http://promo.yahoo.com/sbc/
>



Posted on the users mailing list.