On Friday 05 October 2007 11:55:21 Patrick R. Michaud wrote: > In the case of dynamically generated code, using add_method is > somewhat more challenging because we can't perform the add_method > until after the PIR source has been compiled and loaded into the > namespace. That means that in addition to runtime-compiling > the source, we have to keep around a list of any methods contained > within that source so that we can then look them up and do individual > add_method calls for each. Either that or the source itself has to > have a :load/:init routine to do the add_method calls. > > Either way, tagging subs with :method is far cleaner. Anything else > feels like a serious kludge. :-)
The real problem is that :method acts at compile time, while newclass/subclass act at run time (even if that's :init or :load time). If there were PIR directives to create a class at compile time, this problem might be solvable in IMCC. (It's solvable in IMCC right now with a solution much like Patrick suggests.) -- c