note
toma
Chained mutators can
<UL>
<LI>Save typing</LI>
<LI>Create symmetry</LI>
<LI>Result in clearer code.</LI>
</UL>
Here's a snippet from my own code. This probes a
real-time audio application with a five channel
OpenGL oscilloscope:
<code>
my $s= Scope->new('probe' => $netlist)
->anatrace('in', 'System input', 'active', 1)
->anatrace('out_1', 'Lpf bank1', 'active', 1)
->anatrace('out_2', 'Lpf bank2', 'active', 1024)
->anatrace('out', 'System output', 'active', 1)
->anatrace('bank2', 'Switch pos', 'active', 1)
->generate();
</code>
Want to see another channel? Call anatrace again.<P>
I don't think that features with potential downsides
should be 'considered harmful'.<P>
It is possible to create a 'little language'
out of chained method calls. I avoid creating little
languages because I have seen a few of them grow into
voracious blood-sucking monsters.
I can enjoy chaining method calls without
fear of triggering a science-related memetic disorder.<P>
<div class="pmsig"><div class="pmsig-81749">
<div class="pmsig"><I>It should work perfectly the first time! - toma</I></div>
</div></div>
417872
417872