Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

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

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.


In reply to Re^2: lvalue considered harmful... by adrianh
in thread Tutorial: Introduction to Object-Oriented Programming by jreades

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 contemplating the Monastery: (4)
As of 2024-03-29 05:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found