Re: problem with closure over &aux variable
Joshua,
Using 5.1.1personal edition under XP by copying your code into the listener..
CL-USER 1 > (defun test1 (n)
(labels ((up-from (low)
(let ((start (1- low)))
#'(lambda () (incf start)))))
(map-into (make-list n) (up-from 3))))
TEST1
CL-USER 2 >
(test1 5)
(3 4 5 6 7)
CL-USER 3 >
(defun test2 (n)
(labels ((up-from (low &aux (start (1- low)))
#'(lambda () (incf start))))
(map-into (make-list n) (up-from 3))))
TEST2
CL-USER 4 >
(test2 5)
(3 4 5 6 7)
CL-USER 5 >
(test1 10)
(3 4 5 6 7 8 9 10 11 12)
CL-USER 6 >
(test2 10)
(3 4 5 6 7 8 9 10 11 12)
The same test also passed on a mac.
Ian Whitlock
On Sat, Aug 8, 2009 at 12:27 AM, Joshua TAYLOR<tayloj@cs.rpi.edu> wrote:
>
> Yeah, this seems like a bug with &aux variables and labels and flet.
> I don't have the same problem if I define up-from as a separate
> function with either the let or &aux variable. I'll file a bug
> report.
>
> On Fri, Aug 7, 2009 at 7:08 PM, Joshua TAYLOR<tayloj@cs.rpi.edu> wrote:
>> Hi all, I think this is a bug, but before I report it, I'll ask. Am
>> I doing something wrong here?
>>
>>
>> (defun test1 (n)
>> (labels ((up-from (low)
>> (let ((start (1- low)))
>> #'(lambda () (incf start)))))
>> (map-into (make-list n) (up-from 3))))
>>
>> (defun test2 (n)
>> (labels ((up-from (low &aux (start (1- low)))
>> #'(lambda () (incf start))))
>> (map-into (make-list n) (up-from 3))))
>>
>>
>> Each should return a list of length n populated with the integers from
>> 3 to n+2. The only difference is that start is bound with let in
>> test1 and as an &aux variable in test2. Here's what happens on LWM
>> 5.1.2 OS X Intel.
>>
>>
>> CL-USER 1 > (test1 10)
>> (3 4 5 6 7 8 9 10 11 12)
>>
>> CL-USER 2 > (test2 10)
>>
>> Error: Bus error(10) [code 0] at 21E6B8F2
>> eax 56 ; ebx 56 ; ecx 0 ; edx FE26898E
>> esp 21E6B8CC ; ebp 21E6B8F8 ; esi 2 ; edi 21E6B8F2
>> 1 (abort) Return to level 0.
>> 2 Return to top loop level 0.
>>
>> Type :b for backtrace, :c <option number> to proceed, or :? for other options
>>
>> CL-USER 3 : 1 >
>>
>>
>> Is the bug with me or LispWorks (or both ^_^)?
>> Thanks, //JT
>>
>
>
>
> --
> =====================
> Joshua Taylor
> tayloj@cs.rpi.edu, jtaylor@alum.rpi.edu
>
> "A lot of good things went down one time,
> back in the goodle days."
> John Hartford
>
>
--
Ian Whitlock