guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: when and unless


From: David Kastrup
Subject: Re: when and unless
Date: Wed, 07 Dec 2011 10:23:25 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (gnu/linux)

"Chris K. Jester-Young" <address@hidden> writes:

> On Tue, Dec 06, 2011 at 11:08:08PM +0100, David Kastrup wrote:
>> > Have you considered using `(values)' as your way of saying, "I'm not
>> > returning any values"?
>> 
>> Testing for that is not all that much fun.  It is also rather useless
>> since pretty much all of the call-for-effect functions of Guile return
>> *unspecified* rather than (values).
>
> You're not really supposed to test for it.

Lilypond is not Scheme but has a more complex syntax.  You can use
Scheme in a lot of places with different implications on the grammar
depending on the type of the expression.  It would not be feasible to
create a separate Scheme calling operator for every possible type of
expression.  And "called just for action" is one such type.

>> It is not clear to me why (values) can't just evaluate to a single
>> *unspecified* just like '() evaluates to null.  Outside of
>> call-with-values, I don't see much need to treat it special.
>
> Implementing that would pretty much either require CPS transforms all
> around (then you'd look at the arity of the continuation), or else
> you'd have to be keeping track of the arity of the current
> continuation some other way. Is it just me, or does that smell like
> Perl's wantarray?

Well, you'd need to have

(call-with-values (lambda () *unspecified*) (lambda x (length x))) => 0

That's the actual clincher I presume?  If one takes a look at the Scheme
language definition, one finds for one thing:

(define (values . things)
  (call-with-current-continuation 
    (lambda (cont) (apply cont things))))

And, more importantly:

    Except for continuations created by the call-with-values procedure,
    all continuations take exactly one value.

That means that one _only_ needs to consider the implications on
call-with-values continuations.

And it is not like Guile has a problem distinguishing content and
package itself (at least Guile 1.8):

guile> (write *unspecified*)
#<unspecified>guile> (write (values))
#<values ()>guile> 

So I still don't quite see the problem that would arise from making
(eq? *unspecified* (values)) => #t

-- 
David Kastrup




reply via email to

[Prev in Thread] Current Thread [Next in Thread]