Paste: generating lambdas with [let* inside

Author: ex_rzr
Mode: factor
Date: Tue, 22 Sep 2009 17:01:37
Plain Text |
(a)

USING: arrays kernel locals locals.parser locals.types
locals.rewrite.closures math prettyprint sequences quotations ;
IN: checks

<<

[let* | x [ "x" make-local ]
        x' [ "x" make-local ]
        b [ x [ 10 + ] x' prefix 2array 1array ]
        le [ b x 1quotation <let*> dup .  ]
        la [ x' 1array le 1quotation <lambda> dup . ] |
    la rewrite-closures first . ]

>>

(a) output:

[let* | x [ x 10 + ] | x ]
[| x | [let* | x [ x 10 + ] | x ] ]
[
    1 load-locals 0 get-local 10 + load-local
    0 get-local 2 drop-locals
]

Annotation: (b)

Author: ex_rzr
Mode: factor
Date: Tue, 22 Sep 2009 17:08:36
Plain Text |
(b)

USING: arrays kernel locals locals.parser locals.types
locals.rewrite.closures math prettyprint sequences quotations ;
IN: checks

<<

[let* | x [ "x" make-local ]
        b [ x [ 10 + ] x prefix 2array 1array ]
        le [ b x 1quotation <let*> dup . ]
        la [ x 1array le 1quotation <lambda> dup . ] |
    la rewrite-closures first . ]

>>

! i use the same local for lambda and [let

(b) output

[let* | x [ x 10 + ] | x ]
[| x | [let* | x [ x 10 + ] | x ] ]
[
    1 load-locals 0 get-local 10 + load-local
    0 get-local 2 drop-locals
]


Annotation: (c) = (b) + quotation

Author: ex_rzr
Mode: factor
Date: Tue, 22 Sep 2009 17:15:09
Plain Text |
(c)

USING: arrays kernel locals locals.parser locals.types
locals.rewrite.closures math prettyprint sequences quotations ;
IN: checks

<<

[let* | x [ "x" make-local ]
        b [ x [ 10 + ] x prefix 2array 1array ]
        le [ b x 1quotation <let*> dup . 1quotation ]
        la [ x 1array le 1quotation <lambda> dup . ] |
    la rewrite-closures first . ]

>>

! 'le [ b x 1quotation <let*> dup . ____1quotation____ ]'

(c) output

[let* | x [ x 10 + ] | x ]
[| x | [ [let* | x [ x 10 + ] | x ] ] ]

error:
...
You have found a bug in locals. Please report.
args [ ]
obj  x

so, my questions: 
1. (c) works fine, but (c) doesn't, why? where is a difference?

2. is (b) correct? if it is, why (c) doesn't work?

Annotation: *

Author: ex_rzr
Mode: factor
Date: Tue, 22 Sep 2009 17:16:09
Plain Text |
*1. (b) works fine, but (c) doesn't, why? where is a difference?

New Annotation

Summary:
Author:
Mode:
Body: