Lisp HUG Maillist Archive

Trying to understand the macroexpansion of an iterate clause

Dear List

I am reading the iterate manual and have come across this form:
  (iter (generating (key . item) in '((a . 1) (b . 2) (c . 2)))
	(collect (next key))
	(collect (next item)))
The manual says that the form returns (a 2 c).

I have pasted the result of (macroexpand-1  form), where form is the
above iter form, but I have removed all the `#:' prefixes of the
variables, to http://paste.lisp.org/+31RO (the O is the
upper-case letter oh).

I have dry run the expanded code 3 times and I still do not understand
how the variable result21 is bound to a list whose length is > 1. The
only places in the expanded code where result21 is bound to a new value
consists of a SETQ with the value bound to temp24. During my dry
running, it appears that temp24 is bound to, successively, (a) (2)
(c). Using the Stepper tool, I have discovered that the value result21
is bound to, changes when end-pointer23 is bound to "(a 2)", but the
value in end-pointer23 is never used to change another variable.

So what changes the value of result21? And where?

Your help would be appreciated.

Sincerely
-- 
Dr Sian Mountbatten
http://www.poenikatu.co.uk/
Associate member of the FSF no. 10888
Asocia membro de la Libera Programara Fonduso n-ro 10888

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Re: Trying to understand the macroexpansion of an iterate clause

On 04/23/14 10:44, Sian Mountbatten wrote:
> I am reading the iterate manual and have come across this form:
>   (iter (generating (key . item) in '((a . 1) (b . 2) (c . 2)))
> 	(collect (next key))
> 	(collect (next item)))
> The manual says that the form returns (a 2 c).
> 
> I have pasted the result of (macroexpand-1  form), where form is the
> above iter form, but I have removed all the `#:' prefixes of the
> variables, to http://paste.lisp.org/+31RO (the O is the
> upper-case letter oh).
> 
> So what changes the value of result21? And where?

The code updating RESULT21 is the following form:

 (SETQ END-POINTER23
       (IF RESULT21
           (SETF (CDR END-POINTER23) TEMP24)
         (SETQ RESULT21 TEMP24)))

TEMP24, RESULT21, and END-POINTER23 all have the same initial value: the
cons '(A . NIL).  During subsequent evaluations the above form adds
items to the RESULT21 list in-place by replacing the cdr of the last
cons with a list containing each new item.


Mike

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Re: Trying to understand the macroexpansion of an iterate clause

Sian Mountbatten <poenikatu@fastmail.co.uk> writes:

> On 2014-04-23 19:09, Miller, Bradford W (GE Global Research) wrote:
>> You need to find two friends. One to hit you on the back of the head
>> with a chine ual, and the other to reboot your lisp machine.
> What is a "chine ual"? 

A chine nual, is a book with a big title written on the cover like this:

             +--------------+
             |     |  | LISP|
             |     |  |     |
             |     |MA|CHINE|
             |     |  |     |
             |     |MA|NUAL |
             +--------------+

so when the book is folded, you can read CHINE NUAL:

             ------+
             | LISP|
             |     |
             |CHINE|
             |     |
             |NUAL |
             ------+

http://i.imgur.com/8s2fPJg.jpg


-- 
__Pascal Bourguignon__
http://www.informatimago.com/
"Le mercure monte ?  C'est le moment d'acheter !"

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


RE: Trying to understand the macroexpansion of an iterate clause

That is great! :)

My copy of David Moon's book looks quite different, as I recall. Must be the Symbolics reprinted edition ... I have to go find it and look! :)

Z

Syed Zaeem Hosain | Chief Technical Officer
Aeris Communications, Inc.
Syed.Hosain@aeris.net
o: +1 408 557-1905 | f: +1 408 557-1925 | twitter: @AerisCTO | blog: http://www.aeris.com/blog

The information in this message may be confidential and legally privileged. If you are not the intended recipient of this message, please inform the sender of the error immediately. The review, use, distribution or copying of any message not intended for you is prohibited, and we ask that you permanently delete the message along with any copies and attachments.

-----Original Message-----
From: owner-lisp-hug@lispworks.com [mailto:owner-lisp-hug@lispworks.com] On Behalf Of Pascal J. Bourguignon
Sent: Wednesday, April 23, 2014 12:41 PM
To: Sian Mountbatten
Cc: lisp-hug@lispworks.com; Miller, Bradford W (GE Global Research)
Subject: Re: Trying to understand the macroexpansion of an iterate clause


Sian Mountbatten <poenikatu@fastmail.co.uk> writes:

> On 2014-04-23 19:09, Miller, Bradford W (GE Global Research) wrote:
>> You need to find two friends. One to hit you on the back of the head 
>> with a chine ual, and the other to reboot your lisp machine.
> What is a "chine ual"? 

A chine nual, is a book with a big title written on the cover like this:

             +--------------+
             |     |  | LISP|
             |     |  |     |
             |     |MA|CHINE|
             |     |  |     |
             |     |MA|NUAL |
             +--------------+

so when the book is folded, you can read CHINE NUAL:

             ------+
             | LISP|
             |     |
             |CHINE|
             |     |
             |NUAL |
             ------+

http://i.imgur.com/8s2fPJg.jpg


--
__Pascal Bourguignon__
http://www.informatimago.com/
"Le mercure monte ?  C'est le moment d'acheter !"

_______________________________________________
Lisp Hug - the mailing list for LispWorks users lisp-hug@lispworks.com http://www.lispworks.com/support/lisp-hug.html



_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Updated at: 2020-12-10 08:34 UTC