[Omake] allowing for lazy extends?

Erick Tryzelaar erickt at dslextreme.com
Sun Jan 28 16:59:31 PST 2007


I think I found an odd bug with lazy_extend with the word "name" inside 
the function. Consider this code, assuming that the lazy_extend from 
before is used:


% A. =
A>        A. =
A>           foo(a, b) =
foo>            echo foo $a $b
foo>            .
.
A>           .
.
- : class Object
       object-length = <fun 0>
       object-map = <fun 1>
       object-mem = <fun 1>
       foo = <fun 2>
       object-find = <fun 1>
       object-add = <fun 2>
       object-foreach = <fun 3>
% B. =
B>        B. =
B>           lazy_extend(A)
B>           .
.
- : class Object
       object-length = <fun 0>
       object-map = <fun 1>
       object-mem = <fun 1>
       name = "A" : Sequence
       foo = $(apply global.obj-find $(apply global.getvar "A" : 
Sequence) "foo" : Sequence)
       object-find = <fun 1>
       val = <fun 3>
       var = "object-foreach" : Sequence
       object-add = <fun 2>
       object-foreach = <fun 3>
% C. =
C>        C. =
C>           lazy_extend(B)
C>           .
.
- : class Object
       object-length = <fun 0>
       object-map = <fun 1>
       object-mem = <fun 1>
       name = $(apply global.obj-find $(apply global.getvar "B" : 
Sequence) "name" : Sequence)
       foo = $(apply global.obj-find
                $(apply global.getvar $(apply global.obj-find $(apply 
global.getvar "B" : Sequence) "name" : Sequence))
                "foo" : Sequence)
       object-find = <fun 1>
       val = <fun 3>
       var = "object-foreach" : Sequence
       object-add = <fun 2>
       object-foreach = <fun 3>
% B. +=
B>        B. +=
B>           foo(a, b) =
foo>            echo bbb $a $b
foo>            .
.
B>           .
.
- : class Object
       object-length = <fun 0>
       object-map = <fun 1>
       object-mem = <fun 1>
       name = "A" : Sequence
       foo = <fun 2>
       object-find = <fun 1>
       val = <fun 3>
       var = "object-foreach" : Sequence
       object-add = <fun 2>
       object-foreach = <fun 3>
% echo $(A.foo 1, 2)
foo 1 2

% echo $(B.foo 1, 2)
bbb 1 2

% echo $(C.foo 1, 2)
foo 1 2


It looks like the expression:

this = $(obj-add $(this), $(var), $`(obj-find $(getvar $,(name)), $,(var)))

Isn't having "name" eagerly evaluated, as shown in this output:

$(apply global.getvar $(apply global.obj-find $(apply global.getvar "B" 
: Sequence) "name" : Sequence))


(On a side note, shouldn't there be commas in this to make it more 
directly evaluatable?

$(apply $(global.getvar), $(apply $(global.obj-find), $(apply 
$(global.getvar), B), name))

Also, there doesn't seem to be the global namespace object. Would that 
be worth adding?)



Anyway, so if I replace "name" in "lazy_extend" with "name2", this bug 
goes away:

% A. =
A>        A. =
A>           foo(a, b) =
foo>            echo foo $a $b
foo>            .
.
A>           .
.
- : class Object
       object-length = <fun 0>
       object-map = <fun 1>
       object-mem = <fun 1>
       foo = <fun 2>
       object-find = <fun 1>
       object-add = <fun 2>
       object-foreach = <fun 3>
% B. =
B>        B. =
B>           lazy_extend(A)
B>           .
.
- : class Object
       object-length = <fun 0>
       object-map = <fun 1>
       object-mem = <fun 1>
       name2 = "A" : Sequence
       foo = $(apply global.obj-find $(apply global.getvar "A" : 
Sequence) "foo" : Sequence)
       object-find = <fun 1>
       val = <fun 3>
       var = "object-foreach" : Sequence
       object-add = <fun 2>
       object-foreach = <fun 3>
% C. =
C>        C. =
C>           lazy_extend(B)
C>           .
.
- : class Object
       object-length = <fun 0>
       object-map = <fun 1>
       object-mem = <fun 1>
       name = $(apply global.obj-find $(apply global.getvar "B" : 
Sequence) "name" : Sequence)
       name2 = "B" : Sequence
       foo = $(apply global.obj-find $(apply global.getvar "B" : 
Sequence) "foo" : Sequence)
       object-find = <fun 1>
       val = <fun 3>
       var = "object-foreach" : Sequence
       object-add = <fun 2>
       object-foreach = <fun 3>


Strangely, there's still this "name" floating around, even though I 
don't define "name" anywhere. This look like a bug?

-e



More information about the Omake mailing list