help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Always using let*


From: Pascal J. Bourguignon
Subject: Re: Always using let*
Date: Mon, 15 Sep 2014 04:59:46 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>> Lisps such as Common Lisp were specifically designed with this
>> parallel evaluation in mind.  The spec (and CLTL(2)) specifically
>> emphasizes the inherent parallelism (independence) here that
>> implies the *possibility* of parallel evaluation.
>
> I simply claim that this is bogus.  Only the var-binding is "parallel", not
> the computation of each value.  So it's a "parallel binding" semantics,
> but it has nothing to do with efficient execution on multiple
> execution units.

The claim is not bogus.  It's just that in general, in presence of side
effects, since the expressions must be evaluated from left to right,
indeed, only the assignments can be performed in parallel.

But if you have side-effect free expressions, (or at least, provably
independent ones), then they could be evaluated in parallel despite the
left-to-right rule.  On the other hand, with setf, this could not be
the case.


    (let ((a 100) (b 200))
      (psetf a (loop repeat b finally (return 1))
             b (loop repeat a finally (return 2))))

could evaluate both loops in parallel, and therefore finishing by
assinging 1 to a and 2 to be after only 200 iterations instead of 300.


On the other hand:

    (let ((a 100) (b 200))
      (setf a (loop repeat b finally (return 1))
            b (loop repeat a finally (return 2))))

must perform 101 iterations, sequentially 100 followed by 1.

-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk


reply via email to

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