Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^10: Experimenting with Lvalue Subs

by demerphq (Chancellor)
on Jan 25, 2005 at 15:23 UTC ( #424892=note: print w/ replies, xml ) Need Help??


in reply to Re^9: Experimenting with Lvalue Subs
in thread Experimenting with Lvalue Subs

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


Comment on Re^10: Experimenting with Lvalue Subs
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://424892]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (16)
As of 2014-12-17 21:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (34 votes), past polls