Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: lvalue considered harmful...

by adrianh (Chancellor)
on Dec 14, 2002 at 20:58 UTC ( #219893=note: print w/ replies, xml ) Need Help??


in reply to Re: lvalue considered harmful...
in thread Tutorial: Introduction to Object-Oriented Programming

One of my favourite languages, Pop-11, does it in quite a nice way. You define a separate subroutine for the lvalue side - known as an updater.

For example, a function to access and update the second element of a linked list can be written in Pop-11 like this:

define second(list); hd(tl(list)) enddefine; define updaterof second(value, list); value -> hd(tl(list)) enddefine; vars list; [a b c d] -> list; second(list) => ** b 42 -> second(list); second(list) => ** 42 list => ** [a 42 c d]

All the advantages of writing separate setter/getter functions without the noise (as I see it) in the function names.

In Pop-11 lvalues are poorly named, since they appear on the right! Doing value -> something in Pop-11 is the same as something = value in perl.

I find it reads well (something goes into something else) and it also solves that whole "confusing = with ==" problem.


Comment on Re^2: lvalue considered harmful...
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (10)
As of 2015-07-28 09:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (254 votes), past polls