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 updaterof second(value, list);
value -> hd(tl(list))
[a b c d] -> list;
42 -> second(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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||