<?xml version="1.0" encoding="windows-1252"?>
<node id="219893" title="Re^2: lvalue considered harmful..." created="2002-12-14 15:58:29" updated="2005-08-15 09:29:48">
<type id="11">
note</type>
<author id="186362">
adrianh</author>
<data>
<field name="doctext">
&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;For example, a function to access and update the second element of a linked list can be written in Pop-11 like this:&lt;/p&gt;

&lt;code&gt;
define second(list);
        hd(tl(list))
enddefine;

define updaterof second(value, list);
        value -&gt; hd(tl(list))
enddefine;

vars list;
[a b c d] -&gt; list;

second(list) =&gt;
** b

42 -&gt; second(list);

second(list) =&gt;
** 42

list =&gt;
** [a 42 c d]
&lt;/code&gt;

&lt;p&gt;All the advantages of writing separate setter/getter functions without the noise (as I see it) in the function names.&lt;/p&gt;

&lt;p&gt;In Pop-11 lvalues are poorly named, since they appear on the right! Doing &lt;code&gt;value -&gt; something&lt;/code&gt; in Pop-11 is the same as &lt;code&gt;something = value&lt;/code&gt; in perl.&lt;/p&gt;

&lt;p&gt;I find it reads well (something goes into something else) and it also solves that whole "confusing = with ==" problem.&lt;/p&gt;</field>
<field name="root_node">
218778</field>
<field name="parent_node">
219886</field>
</data>
</node>
