a-la-Class::Struct, with exported functions that install accessors by means of eval
Perhaps, but Class::Struct may not be the best module to base your OO interface on since it's intent is to implement C structs in Perl. That and eval is evil ;)
using subroutine attributes, and perhaps variable attributes (still experimental in 5.8?)
It'd certainly look very nice syntatically, but I believe attributes are still somewhat of a grey area (esp. for variables).
installing methods on the fly using AUTOLOAD and *{$AUTOLOAD} = sub { do { this() and that() } } ;
This is certainly a nice way of generating accessor methods if somewhat heavy-handed (*anything* could be an accessor).

Unfortunately there is a fundamental flaw to this whole approach - it is *impossible* to have truly encapsulated classes in Perl without taking advantage of lexical scoping. So while closures may look like an abberation in your otherwise pristine code, it may be a necessity to achieve your goal of true encapsulation. I think I'll write a meditation on the whole subject of encapsulation in perl in the next week or so.
HTH

_________
broquaint


In reply to Re: Re: Re: Looking for exportable privacy and protection by broquaint
in thread Looking for exportable privacy and protection by bronto

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.