Torsten Anders wrote:
However, if I want to create a class in a function with multiple
methods, how can I do that when I only have the 'macro' class..end?
fun {MakeClass Methods}
%% e.g., Methods = [MethodName1#MethodBody1 ..]
class $
meth init skip end
<put method defs here>
end
end
Ahem. In this specific case, it is possible to use inheritance, and add
one method at a time. But it is not really convenient... (Though it
works: intermediate classes will disappear with garbage collection.)
fun {MakeClass Methods}
fun {AddMethod C MethodName#MethodBody}
class $ from C
meth !MethodName(...)=M
{MethodBody M}
end
end
end
class Base
meth init skip end
end
in
{FoldL Methods AddMethod Base}
end
Cheers,
raph
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users