Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

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

My whole point here is that the term "lvalue subroutine" has been taken to mean "the same thing as VB/Java properties." But its not. Larry is solving a different problem to that which we care about: simple syntactic sugar so we can write things like

$obj->hashlikeproperty($key)=$value; $obj->scalarlikeproperty=$foo; $obj->flexibleproperty=(1..10); $obj->flexibleproperty=5;

and have them be some sensible equivelent method call. Id say that few of us care if we can use such a sub as a slot in a list assignment, or if we can take a ref to the "value" the property represents or if we can localize it (how the hell you localize a change that may have massive sideffects is beyond me). We dont care about weird stuff like that much, we dont even care much if $o->prop++ gets translated to two method calls. (If we were really concerned about such things we probably wouldnt be using Perl at all.)

We want the side effects, we want validation, it would be nice if we could handle list and scalar assignment in a single sub, but bottom line we just want the syntactic sugar and we really dont want to have to create ties for it every time. In fact it seems to me that ties arent even appropriate as there isnt any efficient way via a tied interface to do things like set a full array in a single go, instead it gets translated into zillions of STORE calls. Hmm, actually thinkign about it further i can imagine cases where a tied approach flat out wont work at all. How do you do something like

$obj->average=(1..10); #assign 5.5 as the average $obj->average=2.5; #assign 2.5 as the average

With a tied/lvalue interface?

---
demerphq


In reply to Re^10: Experimenting with Lvalue Subs by demerphq
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":



  • 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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-26 02:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found