Thank you for looking at this from another perspective.

The more I investigate this, the more I'm convinced that the source of the problem is my having bought into the monoculture of OO syntax, whilst not wanting to give up the convenience and flexibility of being able to tailor the syntax to the task.

Once that realisation dawned, it looked more closely at whether I was actually benefiting elsewhere from OO for this particular application, and I've pretty much concluded no.

Since then, I've made some progress. My ideal situation would be to use an lvalue accessor to the properties and that seemed ideal until I discovered that the actual assignment to the underlying value accessed via an lvalue sub is done outside of the scope of that sub.

That is, in the following:

my $x; sub x :lvalue { use somepragma; $x; } x() += 1;

The assignment of 1 to $x is not subject to somepragma. And that was the purpose of using an accessor in the first place.

Dropping the OO and using the anonymous block syntax seems to be my best bet at this time. Now I'm investigating appying the :shared attribute to an entire namespace.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^2: Passing an anonymous block to a method. by BrowserUk
in thread Passing an anonymous block to a method. by BrowserUk

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.