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


In reply to Re: Pretending to be lisp: macros by Anonymous Monk
in thread Pretending to be lisp: macros by anjiro

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.