In both LW and ACL:
(loop for x in '(1 2 3)
and y = x
collecting (list x y))
-> ((1 NIL) (2 1) (3 2))
(loop for x in '(1 2 3)
and y = x
for z = (mod x 2)
collecting (list x y))
-> ((1 NIL) (2 1) (3 2))
(loop for x in '(1 2 3)
for z = (mod x 2)
and y = x
collecting (list x y))
-> ((1 1) (2 2) (3 3))
WTF? Oh, I get it. That is sick. Live by the loop, die by the loop.
kenny
--
http://www.theoryyalgebra.com/
"In the morning, hear the Way;
in the evening, die content!"
-- Confucius
On Feb 6, 4:27 pm, Ken Tilton <···········@optonline.net> wrote:
> In both LW and ACL:
>
> (loop for x in '(1 2 3)
> and y = x
> collecting (list x y))
> -> ((1 NIL) (2 1) (3 2))
(iter (for x in '(1 2 3))
(for y first x then x)
(collecting (list x y)))
((1 1) (2 2) (3 3))
>
> (loop for x in '(1 2 3)
> and y = x
> for z = (mod x 2)
> collecting (list x y))
> -> ((1 NIL) (2 1) (3 2))
(iter (for x in '(1 2 3))
(for y first x then x)
(for z first (mod x 2) then (mod x 2))
(collecting (list x y z)))
((1 1 1) (2 2 0) (3 3 1))
>
> (loop for x in '(1 2 3)
> for z = (mod x 2)
> and y = x
> collecting (list x y))
> -> ((1 1) (2 2) (3 3))
>
> WTF? Oh, I get it. That is sick. Live by the loop, die by the loop.
>
> kenny
>
> --http://www.theoryyalgebra.com/
>
> "In the morning, hear the Way;
> in the evening, die content!"
> -- Confucius
In article
<····································@k39g2000hsf.googlegroups.com>,
Slobodan Blazeski <·················@gmail.com> wrote:
> On Feb 6, 4:27 pm, Ken Tilton <···········@optonline.net> wrote:
> > In both LW and ACL:
> >
> > (loop for x in '(1 2 3)
> > and y = x
> > collecting (list x y))
> > -> ((1 NIL) (2 1) (3 2))
> (iter (for x in '(1 2 3))
> (for y first x then x)
> (collecting (list x y)))
> ((1 1) (2 2) (3 3))
? (loop for x in '(1 2 3)
for y = x
collecting (list x y))
((1 1) (2 2) (3 3))
> >
> > (loop for x in '(1 2 3)
> > and y = x
> > for z = (mod x 2)
> > collecting (list x y))
> > -> ((1 NIL) (2 1) (3 2))
> (iter (for x in '(1 2 3))
> (for y first x then x)
> (for z first (mod x 2) then (mod x 2))
> (collecting (list x y z)))
> ((1 1 1) (2 2 0) (3 3 1))
? (loop for x in '(1 2 3)
for y = x
for z = (mod x 2)
collecting (list x y z))
((1 1 1) (2 2 0) (3 3 1))
> >
> > (loop for x in '(1 2 3)
> > for z = (mod x 2)
> > and y = x
> > collecting (list x y))
> > -> ((1 1) (2 2) (3 3))
> >
> > WTF? Oh, I get it. That is sick. Live by the loop, die by the loop.
> >
> > kenny
> >
> > --http://www.theoryyalgebra.com/
> >
> > "In the morning, hear the Way;
> > in the evening, die content!"
> > -- Confucius
On Feb 6, 4:56 pm, Rainer Joswig <······@lisp.de> wrote:
> In article
> <····································@k39g2000hsf.googlegroups.com>,
> Slobodan Blazeski <·················@gmail.com> wrote:
>
> > On Feb 6, 4:27 pm, Ken Tilton <···········@optonline.net> wrote:
> > > In both LW and ACL:
>
> > > (loop for x in '(1 2 3)
> > > and y = x
> > > collecting (list x y))
> > > -> ((1 NIL) (2 1) (3 2))
> > (iter (for x in '(1 2 3))
> > (for y first x then x)
> > (collecting (list x y)))
> > ((1 1) (2 2) (3 3))
>
> ? (loop for x in '(1 2 3)
> for y = x
> collecting (list x y))
>
> ((1 1) (2 2) (3 3))
>
>
>
> > > (loop for x in '(1 2 3)
> > > and y = x
> > > for z = (mod x 2)
> > > collecting (list x y))
> > > -> ((1 NIL) (2 1) (3 2))
> > (iter (for x in '(1 2 3))
> > (for y first x then x)
> > (for z first (mod x 2) then (mod x 2))
> > (collecting (list x y z)))
> > ((1 1 1) (2 2 0) (3 3 1))
>
> ? (loop for x in '(1 2 3)
> for y = x
> for z = (mod x 2)
> collecting (list x y z))
> ((1 1 1) (2 2 0) (3 3 1))
>
>
>
> > > (loop for x in '(1 2 3)
> > > for z = (mod x 2)
> > > and y = x
> > > collecting (list x y))
> > > -> ((1 1) (2 2) (3 3))
What does and keyword means in Kenny's loop?
Slobodan
Slobodan Blazeski <·················@gmail.com> writes:
> [...]
> What does and keyword means in Kenny's loop?
Ask your favorite REPL!
(macroexpand-1 '(loop for x in '(1 2 3)
for z = (mod x 2)
and y = x
collecting (list x y)))
(macroexpand-1 '(loop for x in '(1 2 3)
and y = x
for z = (mod x 2)
collecting (list x y)))
--
__Pascal Bourguignon__
In article
<····································@h11g2000prf.googlegroups.com>,
Slobodan Blazeski <·················@gmail.com> wrote:
> On Feb 6, 4:56 pm, Rainer Joswig <······@lisp.de> wrote:
> > In article
> > <····································@k39g2000hsf.googlegroups.com>,
> > Slobodan Blazeski <·················@gmail.com> wrote:
> >
> > > On Feb 6, 4:27 pm, Ken Tilton <···········@optonline.net> wrote:
> > > > In both LW and ACL:
> >
> > > > (loop for x in '(1 2 3)
> > > > and y = x
> > > > collecting (list x y))
> > > > -> ((1 NIL) (2 1) (3 2))
> > > (iter (for x in '(1 2 3))
> > > (for y first x then x)
> > > (collecting (list x y)))
> > > ((1 1) (2 2) (3 3))
> >
> > ? (loop for x in '(1 2 3)
> > for y = x
> > collecting (list x y))
> >
> > ((1 1) (2 2) (3 3))
> >
> >
> >
> > > > (loop for x in '(1 2 3)
> > > > and y = x
> > > > for z = (mod x 2)
> > > > collecting (list x y))
> > > > -> ((1 NIL) (2 1) (3 2))
> > > (iter (for x in '(1 2 3))
> > > (for y first x then x)
> > > (for z first (mod x 2) then (mod x 2))
> > > (collecting (list x y z)))
> > > ((1 1 1) (2 2 0) (3 3 1))
> >
> > ? (loop for x in '(1 2 3)
> > for y = x
> > for z = (mod x 2)
> > collecting (list x y z))
> > ((1 1 1) (2 2 0) (3 3 1))
> >
> >
> >
> > > > (loop for x in '(1 2 3)
> > > > for z = (mod x 2)
> > > > and y = x
> > > > collecting (list x y))
> > > > -> ((1 1) (2 2) (3 3))
>
> What does and keyword means in Kenny's loop?
>
> Slobodan
http://www.lispworks.com/documentation/HyperSpec/Body/06_aaea.htm
for and as clauses can be combined with the loop keyword
and to get parallel initialization and stepping[1]. Otherwise,
the initialization and stepping[1] are sequential.
Rainer Joswig wrote:
> http://www.lispworks.com/documentation/HyperSpec/Body/06_aaea.htm
>
> for and as clauses can be combined with the loop keyword
> and to get parallel initialization and stepping[1]. Otherwise,
> the initialization and stepping[1] are sequential.
It's like the difference between let* (without and) and let (with and).
Pascal
--
1st European Lisp Symposium (ELS'08)
http://prog.vub.ac.be/~pcostanza/els08/
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
In article <···············@mid.individual.net>,
Pascal Costanza <··@p-cos.net> wrote:
> Rainer Joswig wrote:
>
> > http://www.lispworks.com/documentation/HyperSpec/Body/06_aaea.htm
> >
> > for and as clauses can be combined with the loop keyword
> > and to get parallel initialization and stepping[1]. Otherwise,
> > the initialization and stepping[1] are sequential.
>
> It's like the difference between let* (without and) and let (with and).
>
>
> Pascal
Almost.
(let ((a 10) (b a))
(list a b))
Above is an error. Binding b to the value of a does not work,
since a is unbound.
But this works:
? (loop for a = 10 then 20
and b = a then 30
repeat 3
collect (list a b))
((10 NIL) (20 30) (20 30))
So, it is more like SETF and PSETF
http://www.lispworks.com/documentation/HyperSpec/Body/m_setf_.htm
(let ((a nil) (b nil))
(setf a 10 b a)
(list a b))
-> (10 10)
(let ((a nil) (b nil))
(psetf a 10 b a)
(list a b))
-> (10 NIL)
Rainer Joswig wrote:
> In article
> <····································@h11g2000prf.googlegroups.com>,
> Slobodan Blazeski <·················@gmail.com> wrote:
>
>> On Feb 6, 4:56 pm, Rainer Joswig <······@lisp.de> wrote:
>>> In article
>>> <····································@k39g2000hsf.googlegroups.com>,
>>> Slobodan Blazeski <·················@gmail.com> wrote:
>>>
>>>> On Feb 6, 4:27 pm, Ken Tilton <···········@optonline.net> wrote:
>>>>> In both LW and ACL:
>>>
>>>>> (loop for x in '(1 2 3)
>>>>> and y = x
>>>>> collecting (list x y))
>>>>> -> ((1 NIL) (2 1) (3 2))
>>>> (iter (for x in '(1 2 3))
>>>> (for y first x then x)
>>>> (collecting (list x y)))
>>>> ((1 1) (2 2) (3 3))
>>>
>>> ? (loop for x in '(1 2 3)
>>> for y = x
>>> collecting (list x y))
>>>
>>> ((1 1) (2 2) (3 3))
>>>
>>>
>>>
>>>>> (loop for x in '(1 2 3)
>>>>> and y = x
>>>>> for z = (mod x 2)
>>>>> collecting (list x y))
>>>>> -> ((1 NIL) (2 1) (3 2))
>>>> (iter (for x in '(1 2 3))
>>>> (for y first x then x)
>>>> (for z first (mod x 2) then (mod x 2))
>>>> (collecting (list x y z)))
>>>> ((1 1 1) (2 2 0) (3 3 1))
>>>
>>> ? (loop for x in '(1 2 3)
>>> for y = x
>>> for z = (mod x 2)
>>> collecting (list x y z))
>>> ((1 1 1) (2 2 0) (3 3 1))
>>>
>>>
>>>
>>>>> (loop for x in '(1 2 3)
>>>>> for z = (mod x 2)
>>>>> and y = x
>>>>> collecting (list x y))
>>>>> -> ((1 1) (2 2) (3 3))
>>
>> What does and keyword means in Kenny's loop?
>>
>> Slobodan
>
> http://www.lispworks.com/documentation/HyperSpec/Body/06_aaea.htm
>
> for and as clauses can be combined with the loop keyword
> and to get parallel initialization and stepping[1]. Otherwise,
> the initialization and stepping[1] are sequential.
Ah, I see, didn't know yet - so what is Kenny's point?
Andreas
Andreas Thiele wrote:
> Rainer Joswig wrote:
>
>>In article
>><····································@h11g2000prf.googlegroups.com>,
>>Slobodan Blazeski <·················@gmail.com> wrote:
>>
>>
>>>On Feb 6, 4:56 pm, Rainer Joswig <······@lisp.de> wrote:
>>>
>>>>In article
>>>><····································@k39g2000hsf.googlegroups.com>,
>>>> Slobodan Blazeski <·················@gmail.com> wrote:
>>>>
>>>>
>>>>>On Feb 6, 4:27 pm, Ken Tilton <···········@optonline.net> wrote:
>>>>>
>>>>>>In both LW and ACL:
>>>>
>>>>>>(loop for x in '(1 2 3)
>>>>>> and y = x
>>>>>> collecting (list x y))
>>>>>>-> ((1 NIL) (2 1) (3 2))
>>>>>
>>>>> (iter (for x in '(1 2 3))
>>>>> (for y first x then x)
>>>>> (collecting (list x y)))
>>>>>((1 1) (2 2) (3 3))
>>>>
>>>>? (loop for x in '(1 2 3)
>>>> for y = x
>>>> collecting (list x y))
>>>>
>>>>((1 1) (2 2) (3 3))
>>>>
>>>>
>>>>
>>>>
>>>>>>(loop for x in '(1 2 3)
>>>>>> and y = x
>>>>>> for z = (mod x 2)
>>>>>> collecting (list x y))
>>>>>>-> ((1 NIL) (2 1) (3 2))
>>>>>
>>>>> (iter (for x in '(1 2 3))
>>>>> (for y first x then x)
>>>>> (for z first (mod x 2) then (mod x 2))
>>>>> (collecting (list x y z)))
>>>>>((1 1 1) (2 2 0) (3 3 1))
>>>>
>>>>? (loop for x in '(1 2 3)
>>>> for y = x
>>>> for z = (mod x 2)
>>>> collecting (list x y z))
>>>>((1 1 1) (2 2 0) (3 3 1))
>>>>
>>>>
>>>>
>>>>
>>>>>>(loop for x in '(1 2 3)
>>>>>> for z = (mod x 2)
>>>>>> and y = x
>>>>>> collecting (list x y))
>>>>>>-> ((1 1) (2 2) (3 3))
>>>
>>>What does and keyword means in Kenny's loop?
>>>
>>>Slobodan
>>
>>http://www.lispworks.com/documentation/HyperSpec/Body/06_aaea.htm
>>
>> for and as clauses can be combined with the loop keyword
>> and to get parallel initialization and stepping[1]. Otherwise,
>> the initialization and stepping[1] are sequential.
>
>
> Ah, I see, didn't know yet - so what is Kenny's point?
A list of let clauses all happen as if in parallel, and in a list of
let* clauses each happens after the other -- that is nice and
unsurprising -- but with a list of loop for and and clauses we get
nested sequentiality without any apparent grouping of for or and. The
and is relative to the nearest for, so by introducing an intermediate
for, an and that was serial to a for ends up parallel with it!
I feel an obfuscated code contest submission coming on.
kenny
--
http://www.theoryyalgebra.com/
"In the morning, hear the Way;
in the evening, die content!"
-- Confucius
Ken Tilton <···········@optonline.net> writes:
> A list of let clauses all happen as if in parallel, and in a list of
> let* clauses each happens after the other -- that is nice and
> unsurprising -- but with a list of loop for and and clauses we get
> nested sequentiality without any apparent grouping of for or and. The
> and is relative to the nearest for, so by introducing an intermediate
> for, an and that was serial to a for ends up parallel with it!
>
> I feel an obfuscated code contest submission coming on.
There's nothing obfuscated in it, but bad indentation.
Please, teach your non-yobbo IDE to indent as:
(loop for x in '(1 2 3)
for z = (mod x 2)
and y = x
collecting (list x y))
or write it as:
(loop for x in '(1 2 3)
for z = (mod x 2) and y = x
collecting (list x y))
--
__Pascal Bourguignon__ http://www.informatimago.com/
You never feed me.
Perhaps I'll sleep on your face.
That will sure show you.
Oh, look: http://halogen.note.amherst.edu/~jdtang/arclite/
I wonder why he never did that for Common Lisp.
<sigh>
kenny
--
http://www.theoryyalgebra.com/
"In the morning, hear the Way;
in the evening, die content!"
-- Confucius
On Feb 6, 2:52 pm, Ken Tilton <···········@optonline.net> wrote:
> I feel an obfuscated code contest submission coming on.
(loop for and in '(collect finally into if finally (return if)) for =
= and for finally = and collect finally into if finally (return if))
In article <···············@news.t-online.com>,
"Andreas Thiele" <······@nospam.com> wrote:
> Rainer Joswig wrote:
> > In article
> > <····································@h11g2000prf.googlegroups.com>,
> > Slobodan Blazeski <·················@gmail.com> wrote:
> >
> >> On Feb 6, 4:56 pm, Rainer Joswig <······@lisp.de> wrote:
> >>> In article
> >>> <····································@k39g2000hsf.googlegroups.com>,
> >>> Slobodan Blazeski <·················@gmail.com> wrote:
> >>>
> >>>> On Feb 6, 4:27 pm, Ken Tilton <···········@optonline.net> wrote:
> >>>>> In both LW and ACL:
> >>>
> >>>>> (loop for x in '(1 2 3)
> >>>>> and y = x
> >>>>> collecting (list x y))
> >>>>> -> ((1 NIL) (2 1) (3 2))
> >>>> (iter (for x in '(1 2 3))
> >>>> (for y first x then x)
> >>>> (collecting (list x y)))
> >>>> ((1 1) (2 2) (3 3))
> >>>
> >>> ? (loop for x in '(1 2 3)
> >>> for y = x
> >>> collecting (list x y))
> >>>
> >>> ((1 1) (2 2) (3 3))
> >>>
> >>>
> >>>
> >>>>> (loop for x in '(1 2 3)
> >>>>> and y = x
> >>>>> for z = (mod x 2)
> >>>>> collecting (list x y))
> >>>>> -> ((1 NIL) (2 1) (3 2))
> >>>> (iter (for x in '(1 2 3))
> >>>> (for y first x then x)
> >>>> (for z first (mod x 2) then (mod x 2))
> >>>> (collecting (list x y z)))
> >>>> ((1 1 1) (2 2 0) (3 3 1))
> >>>
> >>> ? (loop for x in '(1 2 3)
> >>> for y = x
> >>> for z = (mod x 2)
> >>> collecting (list x y z))
> >>> ((1 1 1) (2 2 0) (3 3 1))
> >>>
> >>>
> >>>
> >>>>> (loop for x in '(1 2 3)
> >>>>> for z = (mod x 2)
> >>>>> and y = x
> >>>>> collecting (list x y))
> >>>>> -> ((1 1) (2 2) (3 3))
> >>
> >> What does and keyword means in Kenny's loop?
> >>
> >> Slobodan
> >
> > http://www.lispworks.com/documentation/HyperSpec/Body/06_aaea.htm
> >
> > for and as clauses can be combined with the loop keyword
> > and to get parallel initialization and stepping[1]. Otherwise,
> > the initialization and stepping[1] are sequential.
>
> Ah, I see, didn't know yet - so what is Kenny's point?
>
> Andreas
I guess he was just confused by all the Arc code he was writing.
Slobodan Blazeski <·················@gmail.com> wrote:
> What does and keyword means in Kenny's loop?
Lazy evaluation :-) (in fact, parallel stepping).
--
Resistance is futile. You will be jazzimilated.
Didier Verna, ······@lrde.epita.fr, http://www.lrde.epita.fr/~didier
EPITA / LRDE, 14-16 rue Voltaire Tel.+33 (0)1 44 08 01 85
94276 Le Kremlin-Bic�tre, France Fax.+33 (0)1 53 14 59 22 ······@xemacs.org
On Feb 6, 7:27 am, Ken Tilton <···········@optonline.net> wrote:
> In both LW and ACL:
>
> (loop for x in '(1 2 3)
> and y = x
> collecting (list x y))
> -> ((1 NIL) (2 1) (3 2))
Loosely speaking, AND is used as a conjunction between subclauses that
belong to one clause. If a keyword other than AND is seen, it starts a
new clause. So the AND means that the y = x goes into the preceding
FOR. And the meaning of multiple initializations and assignments in a
single FOR is that they are done in parallel.
AND is also used in conditional constructs to combine subclauses:
(loop for x in '(1 2 3) if (oddp x) collect 'odd and collect x)
-> (odd 1 odd 3)
The AND means that the two COLLECT clauses are both under the IF.
Without the AND, the second COLLECT would be by itself,
unconditionally collecting all values of X.
So AND is just a jig to guide the parser; it has no intrinsic meaning
regarding sequential or parallel actions. The apparently different
uses in FOR and IF are really the same.
Den Wed, 06 Feb 2008 10:27:34 -0500 skrev Ken Tilton:
> In both LW and ACL:
>
> (loop for x in '(1 2 3)
> and y = x
> collecting (list x y))
> -> ((1 NIL) (2 1) (3 2))
>
> (loop for x in '(1 2 3)
> and y = x
> for z = (mod x 2)
> collecting (list x y))
> -> ((1 NIL) (2 1) (3 2))
>
> (loop for x in '(1 2 3)
> for z = (mod x 2)
> and y = x
> collecting (list x y))
> -> ((1 1) (2 2) (3 3))
>
> WTF? Oh, I get it. That is sick. Live by the loop, die by the loop.
>
> kenny
(iter (for x in '(1 2 3))
(for y = x)
(collecting (list x y)))
==> ((1 1) (2 2) (3 3))
(loop for x in '(1 2 3)
for y = x
collecting (list x y))
==> ((1 1) (2 2) (3 3))
That's one of the upsides of using ITERATE, it doesn't have the AND
clause (because it doesn't need it with more its more sex(p)y syntax),
and generally the interaction between its clauses and their results in
terms of code shuffling and binding time are specified much more
explicitly. In particular, it explicitly disclaims supporting parallel
binding, precisely because of cases such as yours.
Cheers,
Maciej
Den Thu, 07 Feb 2008 06:08:24 +0530 skrev Madhu:
> * Maciej Katafiasz <············@news.net.uni-c.dk> :
> Wrote on Wed, 6 Feb 2008 16:20:25 +0000 (UTC):
> | That's one of the upsides of using ITERATE, it doesn't have the AND
> | clause (because it doesn't need it with more its more sex(p)y syntax),
> | and generally the interaction between its clauses and their results
> | in terms of code shuffling and binding time are specified much more
> | explicitly. In particular, it explicitly disclaims supporting
> | parallel binding, precisely because of cases such as yours.
>
> Worse is better
Not at all, more like The Right Thing. Instead of pretending it's doing
something with unclear semantics and ridden with gotchas, it gives you a
very explicit contract and tools to do _what you actually want_, rather
than what happens to sort of give you the desired results (unless it
breaks and doesn't work at all). Namely, binding previous values in
ITERATE is explicit and has a well-defined meaning.
Cheers,
Maciej
* Maciej Katafiasz <············@news.net.uni-c.dk> :
Wrote on Thu, 7 Feb 2008 01:14:14 +0000 (UTC):
| Den Thu, 07 Feb 2008 06:08:24 +0530 skrev Madhu:
|> * Maciej Katafiasz <············@news.net.uni-c.dk> :
|> Wrote on Wed, 6 Feb 2008 16:20:25 +0000 (UTC):
|> | That's one of the upsides of using ITERATE, it doesn't have the AND
|> | clause (because it doesn't need it with more its more sex(p)y syntax),
|> | and generally the interaction between its clauses and their results
|> | in terms of code shuffling and binding time are specified much more
|> | explicitly. In particular, it explicitly disclaims supporting
|> | parallel binding, precisely because of cases such as yours.
|>
|> Worse is better
|
| Not at all, more like The Right Thing. Instead of pretending it's doing
| something with unclear semantics and ridden with gotchas, it gives you a
| very explicit contract and tools to do _what you actually want_, rather
| than what happens to sort of give you the desired results (unless it
| breaks and doesn't work at all). Namely, binding previous values in
| ITERATE is explicit and has a well-defined meaning.
isnt that a good reason to eliminate LET with its parallel bindings from
Lisp and keep only LET* ?
[I think the real reason is they couldnt come up with decent syntax for
the parallel bindings case, but i may just be trolling there]
--
Madhu
Den Thu, 07 Feb 2008 08:54:05 +0530 skrev Madhu:
> |> Worse is better
> |
> | Not at all, more like The Right Thing. Instead of pretending it's doing
> | something with unclear semantics and ridden with gotchas, it gives you a
> | very explicit contract and tools to do _what you actually want_, rather
> | than what happens to sort of give you the desired results (unless it
> | breaks and doesn't work at all). Namely, binding previous values in
> | ITERATE is explicit and has a well-defined meaning.
>
> isnt that a good reason to eliminate LET with its parallel bindings from
> Lisp and keep only LET* ?
I don't think so, since you can get perfectly good and consistent
semantics in LET without any gotchas. Not so much in LOOP, in no small
part because LOOP is so huge and has a lot less explicit syntax than
sexps.
> [I think the real reason is they couldnt come up with decent syntax for
> the parallel bindings case, but i may just be trolling there]
That might well be the reason, if you rephrase it as "we didn't want to
do what LOOP did, because we found its syntax confusing and prone to
gotchas". And because, as the tao of programming says, explicit is better
than implicit, the only real use for parallel binding has its own clause,
PREVIOUS, which says right on the tin what you're going to use it for.
Cheers,
Maciej
[I am not going to follow up anymore on this thread, but there is enough
misinformation here that I felt compelled to reply]
* Maciej Katafiasz <············@news.net.uni-c.dk> :
Wrote on Thu, 7 Feb 2008 11:34:11 +0000 (UTC):
| Den Thu, 07 Feb 2008 08:54:05 +0530 skrev Madhu:
|
|> |> Worse is better
|> |
|> | Not at all, more like The Right Thing. Instead of pretending it's doing
|> | something with unclear semantics and ridden with gotchas, it gives you a
|> | very explicit contract and tools to do _what you actually want_, rather
|> | than what happens to sort of give you the desired results (unless it
|> | breaks and doesn't work at all). Namely, binding previous values in
|> | ITERATE is explicit and has a well-defined meaning.
|>
|> isnt that a good reason to eliminate LET with its parallel bindings from
|> Lisp and keep only LET* ?
|
| I don't think so, since you can get perfectly good and consistent
| semantics in LET without any gotchas. Not so much in LOOP, in no small
| part because LOOP is so huge and has a lot less explicit syntax than
| sexps.
No, I reread it and it still sounds like exactly the same argument, You
are arguing against parallel binding.
LOOP gives you the facility to do parallel bindings IF YOU WANT THEM .
Other looping constructs in CL DO/DO* also give you the facility. No
one is forcing you to use the facility. But it is available for the
programmer to use. ITERATE removes this facility.
If you aren't arguing against parallel binding, all you are really
saying is ``Since I can't grok LOOP syntax, "it must be bad"''
So while CL gives you the ability to bind loop variables in parallel,
ITERATE removes this facility, because it cannot provide it with its
syntax. I think this is a change for the worse, because it takes away
an option which makes sense wherever parallel binding makes sense.
You are arguing that this change is better, by positing `worse is
better' style arguments, which is what I wanted to draw attention to in
my post.
|> [I think the real reason is they couldnt come up with decent syntax for
|> the parallel bindings case, but i may just be trolling there]
|
| That might well be the reason, if you rephrase it as "we didn't want to
| do what LOOP did, because we found its syntax confusing and prone to
| gotchas". And because, as the tao of programming says, explicit is better
| than implicit, the only real use for parallel binding has its own clause,
| PREVIOUS, which says right on the tin what you're going to use it for.
Since when did PREVIOUS perspicuously mean `bind these in `PARALLEL'' ?
It is not clear what you mean by `explicit/implicit' but let that pass.
An intelligent programmer with an independent aesthetic is a better
judge of what the useful cases are for parallel binding. No need for the
ITERATE authors to decide this for them
--
Madhu
Den Thu, 07 Feb 2008 17:50:55 +0530 skrev Madhu:
> [I am not going to follow up anymore on this thread, but there is enough
> misinformation here that I felt compelled to reply]
I'm not a fan of dragging it any further either, but your comments twist
mine enough that I don't want to leave it at that.
> |> [I think the real reason is they couldnt come up with decent syntax for
> |> the parallel bindings case, but i may just be trolling there]
> |
> | That might well be the reason, if you rephrase it as "we didn't want to
> | do what LOOP did, because we found its syntax confusing and prone to
> | gotchas". And because, as the tao of programming says, explicit is better
> | than implicit, the only real use for parallel binding has its own clause,
> | PREVIOUS, which says right on the tin what you're going to use it for.
>
> Since when did PREVIOUS perspicuously mean `bind these in `PARALLEL'' ?
Since never? The entire point is that it does NOT mean "bind in
parallel", ITERATE simply gives you the tool to do what you actually
wanted when you asked for parallel binding. Your argument reminds me of
people coming to #nihongo, asking how to construct gerund form in
Japanese, and then getting offended when they are told the question is
invalid and they are better off stating their intent instead of the
perceived solution.
> It is not clear what you mean by `explicit/implicit' but let that pass.
> An intelligent programmer with an independent aesthetic is a better
> judge of what the useful cases are for parallel binding. No need for the
> ITERATE authors to decide this for them
Except that "not deciding" means implementing a substandard construct
with no good or clear semantics that's used to emulate what's better
expressed with a different tool. So intelligent programmers writing
ITERATE opted for that different tool, is all.
Cheers,
Maciej
Madhu <·······@meer.net> wrote:
+---------------
| isnt that a good reason to eliminate LET with its
| parallel bindings from Lisp and keep only LET* ?
+---------------
Uh... No. Not unless you're going to remove multiple arguments
from functions entirely!! [...as classic Lambda Caculus did and
some current "pure" functional programming languages do (I think).]
Remember:
(defmacro let (bindings &body body)
`((lambda ,(mapcar #'car bindings)
,@body)
,@(mapcar #'cadr bindings)))
-Rob
-----
Rob Warnock <····@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607
P� Wed, 06 Feb 2008 16:27:34 +0100, skrev Ken Tilton
<···········@optonline.net>:
> In both LW and ACL:
>
> (loop for x in '(1 2 3)
> and y = x
> collecting (list x y))
> -> ((1 NIL) (2 1) (3 2))
>
> (loop for x in '(1 2 3)
> and y = x
> for z = (mod x 2)
> collecting (list x y))
> -> ((1 NIL) (2 1) (3 2))
>
> (loop for x in '(1 2 3)
> for z = (mod x 2)
> and y = x
> collecting (list x y))
> -> ((1 1) (2 2) (3 3))
>
> WTF? Oh, I get it. That is sick. Live by the loop, die by the loop.
>
> kenny
>
Don't reuse variables.. Look into iterate for a portable version using
previous value.
--------------
John Thingstad
Ken Tilton <···········@optonline.net> writes:
> In both LW and ACL:
>
> (loop for x in '(1 2 3)
> and y = x
> collecting (list x y))
> -> ((1 NIL) (2 1) (3 2))
>
> (loop for x in '(1 2 3)
> and y = x
> for z = (mod x 2)
> collecting (list x y))
> -> ((1 NIL) (2 1) (3 2))
>
> (loop for x in '(1 2 3)
> for z = (mod x 2)
> and y = x
> collecting (list x y))
> -> ((1 1) (2 2) (3 3))
>
> WTF? Oh, I get it. That is sick. Live by the loop, die by the loop.
I'm not clear precisely which detail you're WTFing, but I think the
passage you're looking for is this:
| If multiple iteration clauses are used to control iteration,
| variable initialization and stepping occur sequentially by default.
| The AND construct can be used to connect two or more iteration
| clauses when sequential binding and stepping are not necessary.
| The iteration behavior of clauses joined by AND is analogous to
| the behavior of the macro DO with respect to DO*.
So your first LOOP steps Y in parallel with X, your second LOOP steps
Y in parallel with X but Z sequentially after X and Y, and your last
LOOP steps X, then Z and Y sequentially after X.
--
RmK
Richard M Kreuter <·······@progn.net> wrote:
> Ken Tilton <···········@optonline.net> writes:
>
>> In both LW and ACL:
>>
>> (loop for x in '(1 2 3)
>> and y = x
>> collecting (list x y))
>> -> ((1 NIL) (2 1) (3 2))
>>
>> (loop for x in '(1 2 3)
>> and y = x
>> for z = (mod x 2)
>> collecting (list x y))
>> -> ((1 NIL) (2 1) (3 2))
>>
>> (loop for x in '(1 2 3)
>> for z = (mod x 2)
>> and y = x
>> collecting (list x y))
>> -> ((1 1) (2 2) (3 3))
>>
>> WTF? Oh, I get it. That is sick. Live by the loop, die by the loop.
>
> I'm not clear precisely which detail you're WTFing, but I think the
> passage you're looking for is this:
I think what's confusing is that there is no apparent information on
"operator precedence" (you know, 3 * - 4 + 5 / 8 etc). In the last loop
instance, does the and clause execute in parallel with the for before,
with the two for's before ? It's not explicit.
--
Resistance is futile. You will be jazzimilated.
Didier Verna, ······@lrde.epita.fr, http://www.lrde.epita.fr/~didier
EPITA / LRDE, 14-16 rue Voltaire Tel.+33 (0)1 44 08 01 85
94276 Le Kremlin-Bic�tre, France Fax.+33 (0)1 53 14 59 22 ······@xemacs.org
On Feb 7, 3:10 am, Didier Verna <······@lrde.epita.fr> wrote:
> Richard M Kreuter <·······@progn.net> wrote:
>
>
>
>
>
> > Ken Tilton <···········@optonline.net> writes:
>
> >> In both LW and ACL:
>
> >> (loop for x in '(1 2 3)
> >> and y = x
> >> collecting (list x y))
> >> -> ((1 NIL) (2 1) (3 2))
>
> >> (loop for x in '(1 2 3)
> >> and y = x
> >> for z = (mod x 2)
> >> collecting (list x y))
> >> -> ((1 NIL) (2 1) (3 2))
>
> >> (loop for x in '(1 2 3)
> >> for z = (mod x 2)
> >> and y = x
> >> collecting (list x y))
> >> -> ((1 1) (2 2) (3 3))
>
> >> WTF? Oh, I get it. That is sick. Live by the loop, die by the loop.
>
> > I'm not clear precisely which detail you're WTFing, but I think the
> > passage you're looking for is this:
>
> I think what's confusing is that there is no apparent information on
> "operator precedence" (you know, 3 * - 4 + 5 / 8 etc). In the last loop
> instance, does the and clause execute in parallel with the for before,
> with the two for's before ? It's not explicit.
What's confusing is that AND has a higher precedence (tighter binding)
than mere juxtaposition (conceptually an operator consisting of
nothingness).
In ordinary Lisp syntax, nothing binds more tightly than juxtaposition
in a list, and this is consistent everywhere (except where some silly
macro breaks it).
Given some A B from within a list, A B are both children of the same
node, in that order, and that's that.
The only tokens with relationships that work at varying distances are
the parentheses, and they are visually distinct. We don't have to see
them at all if the code is split into lines and indented, and whenever
they do appear in one line, their visual shape guides the brain into
seeing the grouping.
But LOOP syntax, the binding strength of juxtaposition is inconsistent
(like in other syntaxes, which is what parsing is all about: working
out these bindings to recover the tree shape based on hidden rules).
Given
K1 A B C K2 D E K3 F
you have to know that K1, K2 and K3 are keywords that begin clauses.
And so the binding between C K2 and E K3 is very weak, i.e. the syntax
is like:
(K1 A B C) (K2 D E) (K3 F)
The binding between K1 and A or B and C is tight, though; as tight as
ordinary juxtaposition.
Now this AND hack is used to tighten up the binding.
It goes against conventional algebra too. Multiplication is written
without any operator, and it is tighter than addition:
ax + yb
does not mean a * (x + y) * b. In a visually obvious way, the
conjunction + (not unlike AND) has a weaker coupling than
juxtaposition.
And exponentiation is tighter still. That is why it's indicated as a
superscript: in other words, an even /closer/ juxtaposition. The
superscripted element appears to be a bud growing on its host, which
is a closer relationship than two elements side by side.
So, bottom line, conjunctive connectives must bind less tightly than
juxtaposition in a sanely designed syntax (to the extent that syntax
can be sanely designed).
Didier Verna <······@lrde.epita.fr> writes:
> I think what's confusing is that there is no apparent information on
> "operator precedence" (you know, 3 * - 4 + 5 / 8 etc). In the last loop
> instance, does the and clause execute in parallel with the for before,
> with the two for's before ? It's not explicit.
Hm. I guess I don't see the ambiguity: the AND keyword connects the
following clause to the preceding clause.
for A and B ; Clauses A and B are connected.
for A and B and C ; A connects to B, and B connects to C, so they're
;all connected.
for A for B and C ; Clauses B and C are connected. A is not
;connected. Therefore, since sequential stepping is
;the default, A steps, then (B and C) step.
--
RmK