in reply to Pretending to be lisp: macros

Slap me around and call me Susan (actually, my name's Jim, but that's another story), but I don't like this. From an OO tandpoint, this makes no sense. Methods are supposed to be attached to the object they're supposed to work upon. With this method, you may create multiple methods that do the same thing, but none of which are accessible directly from the object they work upon. For instance:

# yes, an associative array...but make it objectified my $pretend_object = bless({},"Pretend::Object"); # enter a block for whatever reason for (1..10) { # ok, since we decided to skip on creating methods accessible # from the object, let's create our accessor method here # note: it gets recreated every loop my $func = _setter_getter_maker($pretend_object,'attrib'); $func->($_); } # stupid accessor fell out of scope :-/ my $func = _setter_getter_maker($pretend_object,'attrib'); print $func->();

You're probably asking yourself, "who would code like that?" Trust me, more people do than you'd expect. Just have a class that generates these accessor methods. Of course, accessor methods are generally considered to be bad design in OO. But anywho, perhaps a module from which these methods are inherited would be more appropriate?

Anonymously yours,
Anonymous Monk