in reply to Re^2: Class::InsideOut 1.01 now with added sugar
in thread Class::InsideOut 1.01 now with added sugar

I think you can reduce public name => my %name; to public \my %name; with the aid of PadWalker’s var_name function. Not sure if you want to depend on that module, though… although OTOH it’s probably better than writing the XS for the purpose yourself.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re^4: Class::InsideOut 1.01 now with added sugar
by xdg (Monsignor) on Jul 28, 2006 at 04:23 UTC

    I'm having an offline chat with someone about that. I probably would release a separate module that wraps Class::InsideOut for that. Padwalker requires 5.8 and I don't want to put that limitation on Class::InsideOut itself.

    If it works, I'd prefer this syntax:

    public my %name;

    I'm assuming that I can do var_name on \$_[0]. Anyone who's done that for some other evil purpose and can point me at sample/CPAN code, please do. Or if it's impossible, that would be good to know.

    -xdg

    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.

      That should work, although I haven’t tested it. And yeah, it’s probably better off in a separate wrapper module. At which point I’d probably switch to a Class:Stdish attribute interface, making it my %name : public; instead.

      Makeshifts last the longest.

        Attributes create more complexity again (e.g. extra steps for mod_perl compatibility) -- exactly the kind of thing I'm trying to avoid. If you want that kind of interface, I'd go with Class::Std or Object::InsideOut.

        As a side note for anyone following this thread, one advantage of the separate property label is that you can have your lexical hashes follow PBP style guides without affecting the accessor name:

        public name => my %name_of;

        -xdg

        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.