Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Dear fellow monks, I'm seeking comments on a new module I've written, including suggestions for improving its name before I release an initial version to CPAN. This module started as a thought exercise coming out of Abigail's talk at YAPC::NA on Lexical::Attributes and Ingy's talks about Spiffy. It's now reached the point where the basics are working and it might be of interest. The working name is "Object::Local". Here's a quick example of use:

package My::Object; use strict; use Object::Local; give_methods our $self; our $name : Prop; our $color : Prop; sub as_string : Method { return ref($self) . " named '$name' with color '$color'"; } 1; __ELSEWHERE__ use My::Object; my $o = My::Object->new; $o->set_name("xdg")->set_color("orange"); print $o->as_string; __RESULT__ My::Object: named 'xdg' with color 'orange'

At its core, this module helps create inside-out objects. It does some things like Lexical::Attributes and Spiffy, but in some different (better? worse?) ways. Like those modules, it's a bit unusual compared to other object/class generators out there and has some of its own unique approaches:

  • Provides $self automatically to methods -- without source filtering
  • Provides dynamic aliasing of properties within methods, eliminating accessor calls in methods -- again, without source filtering
  • Uses attributes to mark properties and methods, but only in the BEGIN phase so should be mod_perl friendly (though I haven't tested this yet)
  • Under the hood, uses local() and dynamic scoping of package variables ($self, et al.) while remaining 'strict' friendly

Suggestions for a better name are welcome. Some criteria I'd like to apply to the naming include:

  • evocative -- the name should convey some salient point about the module
  • relatively short -- the whole point of the module is less typing so a long name is counterproductive
  • catchy -- it would be nice to stand out from the zillions of Class:: modules since this actually is pretty wierd and different
  • not too frivolous -- e.g. "Spiffy" meets the above three but is a bit on the frivolous side (sorry, Ingy)

I've considered variations such as:

  • Object/Class::Less -- 'less' typing for the programmer, plus a bit of a pun
  • Class::Selfless -- more specific on the "less"
  • Object::Voodoo -- lots of under-the-hood namespace munging, function wrapping, etc. to make this work
  • Object::Dynamic -- dynamic scoping tricks heavily used throughout
  • Class::OutsideIn -- like InsideOut, but the global/local trick is another type of inversion

Your early feedback on functionality or names is appreciated. When I release the module, I'll have more detailed commentary on the internals, speed benchmarks, and pros/cons versus other approaches.

Thank you,


Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

In reply to RFC: an unusual inside-out object generator by xdg

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-04-17 06:27 GMT
Find Nodes?
    Voting Booth?

    No recent polls found