Dear Raphael,

Thank you, I might actually be using this in my code!

Just a related question: how is an inherited method etc. of a class looked up? I mean, do all these intermediate classes add a performance penalty when, say, this very first method in Methods is called?

Best,
Torsten

On 15.03.2006, at 17:03, Raphael Collet wrote:
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

--
Torsten Anders
Sonic Arts Research Centre
Queen's University Belfast (UK)
www.torsten-anders.de


_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to