From: Peter Seibel
Subject: Forms other than PROG1 and PROG2 that don't pass through multiple values?
Date: 
Message-ID: <m3zmza2q7f.fsf@javamonkey.com>
Are there any standard macros or special operators, other than PROG1
and PROG2, that return the value of a subform but don't pass through
any multiple values returned by that subform (i.e. return only the
primary value)? I can't think of any but, as always, may be spacing on
something obvious.

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp

From: M Jared Finder
Subject: Re: Forms other than PROG1 and PROG2 that don't pass through multiple   values?
Date: 
Message-ID: <34trehF4dmii4U1@individual.net>
Peter Seibel wrote:
> Are there any standard macros or special operators, other than PROG1
> and PROG2, that return the value of a subform but don't pass through
> any multiple values returned by that subform (i.e. return only the
> primary value)? I can't think of any but, as always, may be spacing on
> something obvious.

It's probably not what you want, but VALUES does that.

(VALUES (VALUES 1 2)) ==> 1

   -- MJF
From: Peter Seibel
Subject: Re: Forms other than PROG1 and PROG2 that don't pass through multiple values?
Date: 
Message-ID: <m3mzva2mee.fsf@javamonkey.com>
M Jared Finder <·······@digipen.edu> writes:

> Peter Seibel wrote:
>> Are there any standard macros or special operators, other than PROG1
>> and PROG2, that return the value of a subform but don't pass through
>> any multiple values returned by that subform (i.e. return only the
>> primary value)? I can't think of any but, as always, may be spacing on
>> something obvious.
>
> It's probably not what you want, but VALUES does that.
>
> (VALUES (VALUES 1 2)) ==> 1

That's true. But it's true of all functions because of the way forms
are evaluated:

  (identity (values 1 2)) ==> 1
  (+ (values 1 2))        ==> 1
  (* (values 1 2))        ==> 1

That's why I specified "macros or special operators".

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: Dirk Gerrits
Subject: CONSTANTLY [Was: Re: Forms other than PROG1 and PROG2 that don't pass through multiple values?]
Date: 
Message-ID: <87zmz9e76l.fsf_-_@dirkgerrits.com>
Peter Seibel <·····@javamonkey.com> writes:

> M Jared Finder <·······@digipen.edu> writes:
>
>> Peter Seibel wrote:
>>> Are there any standard macros or special operators, other than PROG1
>>> and PROG2, that return the value of a subform but don't pass through
>>> any multiple values returned by that subform (i.e. return only the
>>> primary value)? I can't think of any but, as always, may be spacing on
>>> something obvious.
>>
>> It's probably not what you want, but VALUES does that.
>>
>> (VALUES (VALUES 1 2)) ==> 1
>
> That's true. But it's true of all functions because of the way forms
> are evaluated

On a related note, was anyone besides me ever annoyed by the way
CONSTANTLY is defined?  It doesn't allow you to create functions
returning multiple values.  I would have preferred something like this:

(defun my-constantly (&rest values)
  #'(lambda () (values-list values)))
(define-compiler-macro my-constantly (&rest values)
  `#'(lambda () (values ,@values)))

So that:

CL-USER> (funcall (my-constantly))
; No value
CL-USER> (funcall (my-constantly 1))
1
CL-USER> (funcall (my-constantly 1 2))
1
2

Compare:

CL-USER> (funcall (constantly 1 2)) ; *ERROR*


Or perhaps something like this:

(defmacro my-constantly (values-form)
  `#'(lambda () ,values-form))

So that:

CL-USER> (funcall (my-constantly (values)))
; No value
CL-USER> (funcall (my-constantly 1))
1
CL-USER> (funcall (my-constantly (values 1)))
1
CL-USER> (funcall (my-constantly (values 1 2)))
1
2

Compare:

CL-USER> (funcall (constantly (values 1 2)))
1

Kind regards,

Dirk Gerrits
From: Kalle Olavi Niemitalo
Subject: Re: CONSTANTLY
Date: 
Message-ID: <87ekgli8np.fsf@Astalo.kon.iki.fi>
Dirk Gerrits <····@dirkgerrits.com> writes:

> On a related note, was anyone besides me ever annoyed by the way
> CONSTANTLY is defined?  It doesn't allow you to create functions
> returning multiple values.

In CMUCL, it does:

* (funcall (constantly 1 2))

1
2
* (describe 'constantly)

CONSTANTLY is an external symbol in the COMMON-LISP package.
Function: #<Function CONSTANTLY {103D5B81}>
Function arguments:
  (value &optional (val1 nil val1-p) (val2 nil val2-p) &rest more-values)
Function documentation:
  Builds a function that always returns VALUE, and posisbly MORE-VALUES.
Its declared argument types are:
  (T &OPTIONAL T T &REST T)
Its result type is:
  FUNCTION
On Thursday, 9/4/03 09:41:40 pm [-3] it was compiled from:
target:code/list.lisp
  Created: Friday, 5/23/03 12:20:25 am [-3]
  Comment: $Header: /home/anoncvs/CVS-cmucl/src/code/list.lisp,v 1.27 2002/11/20 16:14:33 toy Exp $
* 

There is also a proposal for standardising this in the CLiki:
http://www.cliki.net/Proposed%20ANSI%20Revisions%20and%20Clarifications
Shouldn't that one be moved to "Proposed Extensions To ANSI", though?

> (defun my-constantly (&rest values)
>   #'(lambda () (values-list values)))
> (define-compiler-macro my-constantly (&rest values)
>   `#'(lambda () (values ,@values)))

That compiler macro is wrong: it causes the value forms to be
evaluated each time the resulting function is called.
From: Dirk Gerrits
Subject: Re: CONSTANTLY
Date: 
Message-ID: <87mzv9gce7.fsf@dirkgerrits.com>
Kalle Olavi Niemitalo <···@iki.fi> writes:

> Dirk Gerrits <····@dirkgerrits.com> writes:
>
>> On a related note, was anyone besides me ever annoyed by the way
>> CONSTANTLY is defined?  It doesn't allow you to create functions
>> returning multiple values.
>
> In CMUCL, it does:
> [...]
> There is also a proposal for standardising this in the CLiki:
> http://www.cliki.net/Proposed%20ANSI%20Revisions%20and%20Clarifications

Ah good.  I'm not the only one. :)  Strange that SBCL hasn't got this
behaviour though.  Was it added to CMUCL after the SBCL fork, or has
SBCL removed it to be closer to the HyperSpec? 

> That compiler macro is wrong: it causes the value forms to be
> evaluated each time the resulting function is called.

Oops, you're right.  I thought it looked suspiciously short. :)  This
should be better:

(define-compiler-macro my-constantly (&rest values)
  (let ((vars (loop for val in values collect (gensym))))
    `(let ,(mapcar #'list vars values)
       #'(lambda () (values ,@vars)))))

Kind regards,

Dirk Gerrits
From: Raymond Toy
Subject: Re: CONSTANTLY
Date: 
Message-ID: <sxdzmyxfqbw.fsf@rtp.ericsson.se>
>>>>> "Dirk" == Dirk Gerrits <····@dirkgerrits.com> writes:

    Dirk> Kalle Olavi Niemitalo <···@iki.fi> writes:
    >> Dirk Gerrits <····@dirkgerrits.com> writes:
    >> 
    >>> On a related note, was anyone besides me ever annoyed by the way
    >>> CONSTANTLY is defined?  It doesn't allow you to create functions
    >>> returning multiple values.
    >> 
    >> In CMUCL, it does:
    >> [...]
    >> There is also a proposal for standardising this in the CLiki:
    >> http://www.cliki.net/Proposed%20ANSI%20Revisions%20and%20Clarifications

    Dirk> Ah good.  I'm not the only one. :)  Strange that SBCL hasn't got this
    Dirk> behaviour though.  Was it added to CMUCL after the SBCL fork, or has
    Dirk> SBCL removed it to be closer to the HyperSpec? 

It's been in CMUCL for as long as I can remember.  I think SBCL
removed that feature as being non-ANSI, but CMUCL left it in because
it's a useful extension.

Ray
From: Dirk Gerrits
Subject: Re: CONSTANTLY
Date: 
Message-ID: <87is5xgcbn.fsf@dirkgerrits.com>
Kalle Olavi Niemitalo <···@iki.fi> writes:

> That compiler macro is wrong: it causes the value forms to be
> evaluated each time the resulting function is called.

And of course the generated functions should take an ignored rest
parameter...

Kind regards,

Dirk Gerrits
From: Paul F. Dietz
Subject: Re: Forms other than PROG1 and PROG2 that don't pass through multiple values?
Date: 
Message-ID: <A5ydnbE7QNSZKHTcRVn-1g@dls.net>
Peter Seibel wrote:
> Are there any standard macros or special operators, other than PROG1
> and PROG2, that return the value of a subform but don't pass through
> any multiple values returned by that subform (i.e. return only the
> primary value)? I can't think of any but, as always, may be spacing on
> something obvious.

OR (except for the last value, if it is reached.)

	Paul
From: Peter Seibel
Subject: Re: Forms other than PROG1 and PROG2 that don't pass through multiple values?
Date: 
Message-ID: <m3zmza16ry.fsf@javamonkey.com>
"Paul F. Dietz" <·····@dls.net> writes:

> Peter Seibel wrote:
>> Are there any standard macros or special operators, other than PROG1
>> and PROG2, that return the value of a subform but don't pass through
>> any multiple values returned by that subform (i.e. return only the
>> primary value)? I can't think of any but, as always, may be spacing on
>> something obvious.
>
> OR (except for the last value, if it is reached.)

Interesting. I'd never noticed that. Anyone know why that is? Hmmm,
poking around with OR leads to COND which returns only the primary
value of the test form of the matching clause if there are no other
forms in the clause:

  CL-USER> (multiple-value-list (cond ((values 1 2))))
  (1)
  CL-USER> (multiple-value-list (cond (t (values 1 2))))
  (1 2)

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: Peter Seibel
Subject: Re: Forms other than PROG1 and PROG2 that don't pass through multiple values?
Date: 
Message-ID: <m3vf9y16fp.fsf@javamonkey.com>
Peter Seibel <·····@javamonkey.com> writes:

> "Paul F. Dietz" <·····@dls.net> writes:
>
>> Peter Seibel wrote:
>>> Are there any standard macros or special operators, other than PROG1
>>> and PROG2, that return the value of a subform but don't pass through
>>> any multiple values returned by that subform (i.e. return only the
>>> primary value)? I can't think of any but, as always, may be spacing on
>>> something obvious.
>>
>> OR (except for the last value, if it is reached.)
>
> Interesting. I'd never noticed that. Anyone know why that is? Hmmm,
> poking around with OR leads to COND which returns only the primary
> value of the test form of the matching clause if there are no other
> forms in the clause:
>
>   CL-USER> (multiple-value-list (cond ((values 1 2))))
>   (1)
>   CL-USER> (multiple-value-list (cond (t (values 1 2))))
>   (1 2)

To provide a possible answer to my own question, it seems that
requiring these macros to pass through multiple values all the time
would be pretty inefficient. At the moment (or a b) can be expanded into:

  (let ((#:g123 a))
    (if #:g123 #:g123 b))

But to make it return all the values from an arbitrary a it'd have to
be something like this:

  (let ((#:g123 (multiple-value-list a)))
    (if (first #:g123) (values-list #:g123) b))

which obviously requires some consing that wouldn't otherwise be
necessary. So basically--if my analysis is correct--this boils down to
the same reason we have PROG1 and MULTIPLE-VALUE-PROG1.

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: Paul Dietz
Subject: Re: Forms other than PROG1 and PROG2 that don't pass throughmultiple  values?
Date: 
Message-ID: <41EE8848.DA51D78C@motorola.com>
Peter Seibel wrote:

> To provide a possible answer to my own question, it seems that
> requiring these macros to pass through multiple values all the time
> would be pretty inefficient. At the moment (or a b) can be expanded into:
> 
>   (let ((#:g123 a))
>     (if #:g123 #:g123 b))
> 
> But to make it return all the values from an arbitrary a it'd have to
> be something like this:
> 
>   (let ((#:g123 (multiple-value-list a)))
>     (if (first #:g123) (values-list #:g123) b))
> 
> which obviously requires some consing that wouldn't otherwise be
> necessary. So basically--if my analysis is correct--this boils down to
> the same reason we have PROG1 and MULTIPLE-VALUE-PROG1.

But there's still the question... why aren't OR and COND special
operators?  If they were, they could be implemented to pass back
multiple values without consing.

I think the better reason is that this isn't needed very often.

	Paul
From: Christopher C. Stacy
Subject: Re: Forms other than PROG1 and PROG2 that don't pass throughmultiple  values?
Date: 
Message-ID: <uacr52xds.fsf@news.dtpq.com>
Paul Dietz <············@motorola.com> writes:

> Peter Seibel wrote:
> 
> > To provide a possible answer to my own question, it seems that
> > requiring these macros to pass through multiple values all the time
> > would be pretty inefficient. At the moment (or a b) can be expanded into:
> > 
> >   (let ((#:g123 a))
> >     (if #:g123 #:g123 b))
> > 
> > But to make it return all the values from an arbitrary a it'd have to
> > be something like this:
> > 
> >   (let ((#:g123 (multiple-value-list a)))
> >     (if (first #:g123) (values-list #:g123) b))
> > 
> > which obviously requires some consing that wouldn't otherwise be
> > necessary. So basically--if my analysis is correct--this boils down to
> > the same reason we have PROG1 and MULTIPLE-VALUE-PROG1.
> 
> But there's still the question... why aren't OR and COND special
> operators?  If they were, they could be implemented to pass back
> multiple values without consing.
> 
> I think the better reason is that this isn't needed very often.

Why can't OR be a macro that expands into something that doesn't
cons when it returns multiple values?
From: Paul Dietz
Subject: Re: Forms other than PROG1 and PROG2 that don't pass throughmultiple   values?
Date: 
Message-ID: <41EEC5FE.70BC6301@motorola.com>
"Christopher C. Stacy" wrote:

> Why can't OR be a macro that expands into something that doesn't
> cons when it returns multiple values?

How would you propose to do that?

	Paul
From: Christopher C. Stacy
Subject: Re: Forms other than PROG1 and PROG2 that don't pass throughmultiple   values?
Date: 
Message-ID: <u651t2ggj.fsf@news.dtpq.com>
Paul Dietz <············@motorola.com> writes:

> "Christopher C. Stacy" wrote:
> 
> > Why can't OR be a macro that expands into something that doesn't
> > cons when it returns multiple values?
> 
> How would you propose to do that?

By expanding into forms that are not defined in ANSI Common Lisp,
but which are further understood by the compiler?
From: Paul F. Dietz
Subject: Re: Forms other than PROG1 and PROG2 that don't pass throughmultiple   values?
Date: 
Message-ID: <P-idnSg_5sVha3PcRVn-qA@dls.net>
Christopher C. Stacy wrote:
> Paul Dietz <············@motorola.com> writes:
> 
> 
>>"Christopher C. Stacy" wrote:
>>
>>
>>>Why can't OR be a macro that expands into something that doesn't
>>>cons when it returns multiple values?
>>
>>How would you propose to do that?
> 
> 
> By expanding into forms that are not defined in ANSI Common Lisp,
> but which are further understood by the compiler?

Oh, like this:

   (OR f1 f2 ... fk) ==> (SOOPER-SEKRET-OR f1 f2 ... fk)

Ok. :)

	Paul
From: Christopher C. Stacy
Subject: Re: Forms other than PROG1 and PROG2 that don't pass throughmultiple values?
Date: 
Message-ID: <uacqz1k9t.fsf@news.dtpq.com>
"Paul F. Dietz" <·····@dls.net> writes:

> Christopher C. Stacy wrote:
> > Paul Dietz <············@motorola.com> writes:
> >
> >>"Christopher C. Stacy" wrote:
> >>
> >>
> >>>Why can't OR be a macro that expands into something that doesn't
> >>>cons when it returns multiple values?
> >>
> >>How would you propose to do that?
> > By expanding into forms that are not defined in ANSI Common Lisp,
> > but which are further understood by the compiler?
> 
> Oh, like this:
> 
>    (OR f1 f2 ... fk) ==> (SOOPER-SEKRET-OR f1 f2 ... fk)
> 
> Ok. :)

If a compiler can ever return multiple values without extra consing
(which indeed it can), then it doesn't matter what syntax is used;
the fact that a macro or special form may be involved is irrelevent.
From: Peter Seibel
Subject: Re: Forms other than PROG1 and PROG2 that don't pass throughmultiple  values?
Date: 
Message-ID: <m3is5tl2im.fsf@javamonkey.com>
······@news.dtpq.com (Christopher C. Stacy) writes:

> Paul Dietz <············@motorola.com> writes:
>
>> Peter Seibel wrote:
>> 
>> > To provide a possible answer to my own question, it seems that
>> > requiring these macros to pass through multiple values all the time
>> > would be pretty inefficient. At the moment (or a b) can be expanded into:
>> > 
>> >   (let ((#:g123 a))
>> >     (if #:g123 #:g123 b))
>> > 
>> > But to make it return all the values from an arbitrary a it'd have to
>> > be something like this:
>> > 
>> >   (let ((#:g123 (multiple-value-list a)))
>> >     (if (first #:g123) (values-list #:g123) b))
>> > 
>> > which obviously requires some consing that wouldn't otherwise be
>> > necessary. So basically--if my analysis is correct--this boils down to
>> > the same reason we have PROG1 and MULTIPLE-VALUE-PROG1.
>> 
>> But there's still the question... why aren't OR and COND special
>> operators?  If they were, they could be implemented to pass back
>> multiple values without consing.
>> 
>> I think the better reason is that this isn't needed very often.
>
> Why can't OR be a macro that expands into something that doesn't
> cons when it returns multiple values?

Maybe it can but I can't think of how. Seems the problem is you need
to capture a potentially arbitrary number of multiple values and hold
onto them while you figure out whether the primary value is non-NIL
and then return all the values if it is. Obviously you can do this as
I illustrated above but, at least in a naive implementation it's going
to cons up a list to hold the values. Perhaps a declare dynamic-extent
could let them be held on the stack?

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: Pascal Bourguignon
Subject: Re: Forms other than PROG1 and PROG2 that don't pass throughmultiple  values?
Date: 
Message-ID: <87r7khnu4h.fsf@thalassa.informatimago.com>
Paul Dietz <············@motorola.com> writes:

> Peter Seibel wrote:
> 
> > To provide a possible answer to my own question, it seems that
> > requiring these macros to pass through multiple values all the time
> > would be pretty inefficient. At the moment (or a b) can be expanded into:
> > 
> >   (let ((#:g123 a))
> >     (if #:g123 #:g123 b))
> > 
> > But to make it return all the values from an arbitrary a it'd have to
> > be something like this:
> > 
> >   (let ((#:g123 (multiple-value-list a)))
> >     (if (first #:g123) (values-list #:g123) b))
> > 
> > which obviously requires some consing that wouldn't otherwise be
> > necessary. So basically--if my analysis is correct--this boils down to
> > the same reason we have PROG1 and MULTIPLE-VALUE-PROG1.
> 
> But there's still the question... why aren't OR and COND special
> operators?  If they were, they could be implemented to pass back
> multiple values without consing.
> 
> I think the better reason is that this isn't needed very often.

Because we don't have quantum computers yet.

What would the outcome of be:

    (or (values nil nil t t) (values nil t nil t) (print :hi))

What about:

    (or (values nil nil t t) (values nil t nil t) (print (values 1 2 3 4)))

or:

    (or (values nil nil t t) (values nil t nil t)
        (values (print 1) (print 2) (print 3) (print 4)))


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

In a World without Walls and Fences, 
who needs Windows and Gates?
From: Paul Dietz
Subject: Re: Forms other than PROG1 and PROG2 that don't pass throughmultiple   values?
Date: 
Message-ID: <41EED06A.75721336@motorola.com>
Pascal Bourguignon wrote:

> What would the outcome of be:
> 
>     (or (values nil nil t t) (values nil t nil t) (print :hi))


The same as (print :hi).


> What about:
> 
>     (or (values nil nil t t) (values nil t nil t) (print (values 1 2 3 4)))

The same as (print (values 1 2 3 4)).

> or:
> 
>     (or (values nil nil t t) (values nil t nil t)
>         (values (print 1) (print 2) (print 3) (print 4)))

The same as (values (print 1) (print 2) (print 3) (print 4)).

None of these was the case being discussed.  That was, what would
this

   (or (values t 1 2) :not-reached)

be?  Currently it's T, but one could imagine a definition of OR
where it would be T, 1, 2.

	Paul
From: Peter Seibel
Subject: Re: Forms other than PROG1 and PROG2 that don't pass throughmultiple  values?
Date: 
Message-ID: <m3651tl0nc.fsf@javamonkey.com>
Pascal Bourguignon <····@mouse-potato.com> writes:

> Paul Dietz <············@motorola.com> writes:

>> But there's still the question... why aren't OR and COND special
>> operators? If they were, they could be implemented to pass back
>> multiple values without consing.
>> 
>> I think the better reason is that this isn't needed very often.
>
> Because we don't have quantum computers yet.
>
> What would the outcome of be:
>
>     (or (values nil nil t t) (values nil t nil t) (print :hi))

:hi

> What about:
>
>     (or (values nil nil t t) (values nil t nil t) (print (values 1 2 3 4)))

1

> or:
>
>     (or (values nil nil t t) (values nil t nil t)
>         (values (print 1) (print 2) (print 3) (print 4)))

1; 2; 3; 4

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: Pascal Bourguignon
Subject: Re: Forms other than PROG1 and PROG2 that don't pass throughmultiple  values?
Date: 
Message-ID: <87is5tnnj4.fsf@thalassa.informatimago.com>
Peter Seibel <·····@javamonkey.com> writes:

> Pascal Bourguignon <····@mouse-potato.com> writes:
> 
> > Paul Dietz <············@motorola.com> writes:
> 
> >> But there's still the question... why aren't OR and COND special
> >> operators? If they were, they could be implemented to pass back
> >> multiple values without consing.
> >> 
> >> I think the better reason is that this isn't needed very often.
> >
> > Because we don't have quantum computers yet.
> >
> > What would the outcome of be:
> >
> >     (or (values nil nil t t) (values nil t nil t) (print :hi))
> 
> :hi

Why not: (values :hi t t t) ?

> > What about:
> >
> >     (or (values nil nil t t) (values nil t nil t) (print (values 1 2 3 4)))
> 
> 1

Why not: (values 1 t t t) ?
 
> > or:
> >
> >     (or (values nil nil t t) (values nil t nil t)
> >         (values (print 1) (print 2) (print 3) (print 4)))
> 
> 1; 2; 3; 4

Why not: (values 1 t t t) ?


And obviously, I wanted to to ask the question with AND instead of OR.

Another tricky question, what about:

    (and (values t t t t) (values t t) (values 1 2 3 4 5))


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

In a World without Walls and Fences, 
who needs Windows and Gates?
From: Peter Seibel
Subject: Re: Forms other than PROG1 and PROG2 that don't pass throughmultiple  values?
Date: 
Message-ID: <m37jm9je5l.fsf@javamonkey.com>
Pascal Bourguignon <····@mouse-potato.com> writes:

> Peter Seibel <·····@javamonkey.com> writes:
>
>> Pascal Bourguignon <····@mouse-potato.com> writes:
>> 
>> > Paul Dietz <············@motorola.com> writes:
>> 
>> >> But there's still the question... why aren't OR and COND special
>> >> operators? If they were, they could be implemented to pass back
>> >> multiple values without consing.
>> >> 
>> >> I think the better reason is that this isn't needed very often.
>> >
>> > Because we don't have quantum computers yet.
>> >
>> > What would the outcome of be:
>> >
>> >     (or (values nil nil t t) (values nil t nil t) (print :hi))
>> 
>> :hi
>
> Why not: (values :hi t t t) ?

Because that's silly. ;-)

>> > What about:
>> >
>> >     (or (values nil nil t t) (values nil t nil t) (print (values 1 2 3 4)))
>> 
>> 1
>
> Why not: (values 1 t t t) ?

Likewise.


>> > or:
>> >
>> >     (or (values nil nil t t) (values nil t nil t)
>> >         (values (print 1) (print 2) (print 3) (print 4)))
>> 
>> 1; 2; 3; 4
>
> Why not: (values 1 t t t) ?

Because:

  (or nil nil (values (print 1) (print 2) (print 3) (print 4)))

already returns 1; 2; 3; 4.

>
> And obviously, I wanted to to ask the question with AND instead of OR.
>
> Another tricky question, what about:
>
>     (and (values t t t t) (values t t) (values 1 2 3 4 5))

I'd expect: 1; 2; 3; 4; 5.

These seem like the obvious extensions of OR and AND to pass through
multiple values--the primary value is always used to determine which
form (if any) provides the result; the only change is that multiple
values returned by that form are never discarded. Your version is
something just weird unless I'm missing something. If there was really
a use for such operators I'd call them MULITIPLE-VALUE-PARALLEL-OR and
MULITIPLE-VALUE-PARALLEL-AND or something equally grotesque to point
out that they're quite strange.

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: David Sletten
Subject: Re: Forms other than PROG1 and PROG2 that don't pass through multiple values?
Date: 
Message-ID: <IYiGd.69868$gd.17933@twister.socal.rr.com>
Peter Seibel wrote:

> Are there any standard macros or special operators, other than PROG1
> and PROG2, that return the value of a subform but don't pass through
> any multiple values returned by that subform (i.e. return only the
> primary value)? I can't think of any but, as always, may be spacing on
> something obvious.
> 
> -Peter
> 
MAPC and MAPL? They're functions not special ops/macros. And CLHS says 
first arg must be a proper list, so maybe this is undefined:
(mapl #'print (values '(a b c) '(1 2)))

David Sletten
From: Pascal Bourguignon
Subject: Re: Forms other than PROG1 and PROG2 that don't pass through multiple values?
Date: 
Message-ID: <87is5y6w9w.fsf@thalassa.informatimago.com>
Peter Seibel <·····@javamonkey.com> writes:

> Are there any standard macros or special operators, other than PROG1
> and PROG2, that return the value of a subform but don't pass through
> any multiple values returned by that subform (i.e. return only the
> primary value)? I can't think of any but, as always, may be spacing on
> something obvious.

PROG1                   (PROG1 (VALUES 1 2 3) :x)  --> 1

PROG2                   (PROG2 :x (VALUES 1 2 3))  --> 1

VALUES                  (VALUES (VALUES 1 2 3)) --> 1

MULTIPLE-VALUE-SETQ     (MULTIPLE-VALUE-SETQ (x y z) (VALUES 1 2 3)) --> 1

SETQ                    (SETQ x (VALUES 1 2 3)) --> 1

SETF                    (SETF x (VALUES 1 2 3)) --> 1
              but not:  (SETF (VALUES x y z) (VALUES 1 2 3)) --> 1 ; 2 ; 3


That's all I could identify with:

(defun grep-hyperspec (&optional string)
  (interactive "sString: ")
  (grep (format "find '%s' -type f -print|while read f ; do lynx -dump -nolist \"$f\" | grep -i '%s' && echo \"$f:1:-\" ; done #" (shell-quote-argument *hyperspec-path*) string))) 

M-x grep-hyperspec RET => result RET




-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS d? s++:++ a+ C+++ UL++++ P--- L+++ E+++ W++ N+++ o-- K- w--- 
O- M++ V PS PE++ Y++ PGP t+ 5+ X++ R !tv b+++ DI++++ D++ 
G e+++ h+ r-- z? 
------END GEEK CODE BLOCK------
From: Kalle Olavi Niemitalo
Subject: Re: Forms other than PROG1 and PROG2 that don't pass through multiple values?
Date: 
Message-ID: <87pt05iwfr.fsf@Astalo.kon.iki.fi>
Peter Seibel <·····@javamonkey.com> writes:

> Are there any standard macros or special operators, other than PROG1
> and PROG2, that return the value of a subform but don't pass through
> any multiple values returned by that subform (i.e. return only the
> primary value)?

This reminds me of DEFMACRO ("The value of the last form"...),
but it doesn't itself return the value.