None taken.

You are not the first to suggest that I am looking for something different and incompatible. I say that I am not. I want everything that an lvalue sub or method has now in p5 (actually more as I would like for list context lvalue subs to work properly). The only difference is that I would like to be able to validate the assignment.

One of the reasons given for why the this is not possible without resorting to callbacks in the form of a tie, is that it would make localising (temporising) lvalue subs difficult or impossible.

The term "temporise", and all discussion relating to it, comes directly from Apocalypse 6.

But in particular, note that we want to be able to temporize object attributes, which is why there's a TEMP method in our proxy. In Perl 5 you could only temporize (localize) variables. But we want accessors to be usable exactly as if they were variables, which implies that temporization is part of the interface. When you use a temp or let context specifier:

temp $obj.foo = 42; let $obj.bar = 43;

the proxy attribute returned by the lvalue method needs to know how to temporize the value. More precisely, it needs to know how to restore the old value at the end of the dynamic scope.

All I did was fall in line with the terminology used there.

It was suggested that the ability to localise (temporise) an lvalue sub for a scoped duration was one reason why if any validation was allowed for lvalue subs, it would have to be done as a callback (via tie or similar).

The post to which you replied and it's predecessor describe my suggestion that it would be better to localise the sub itself and a temporary lvalue, rather than the actual lvalue returned by the sub.

In terms of the above snippet, the value assigned in temp $obj.foo = 42; would be "undone" at the end of the scope. In this case, by temporising the sub rather than fetching real lvalue, the end of scope would simply discard the temporary value assigned.

The only time the real sub would get called is if the temporary value is made real as in the let $obj.bar = 43;

Assuming I've understood the terminiology. FWIW: I now see the flaw in this suggestion.


Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.

In reply to Re^15: Experimenting with Lvalue Subs by BrowserUk
in thread Experimenting with Lvalue Subs by Limbic~Region

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.