<?xml version="1.0" encoding="windows-1252"?>
<node id="954497" title="Re^2: annotation, derivation" created="2012-02-17 05:31:53" updated="2012-02-17 05:31:53">
<type id="11">
note</type>
<author id="757127">
tobyink</author>
<data>
<field name="doctext">
&lt;p&gt;PS: by playing around with [mod://Devel::Declare] is ought to also be possible to replace code like this:&lt;/p&gt;
&lt;code&gt;
my $foo = an(5, '$foo');
&lt;/code&gt;
&lt;p&gt;With something more like:&lt;/p&gt;
&lt;code&gt;
annotated $foo = 5;
&lt;/code&gt;
&lt;p&gt;Devel::Declare allows you to hook into the Perl parser to catch keywords and add custom parsing for them. In this case, you'd catch the keyword &lt;c&gt;annotated&lt;/c&gt; and rewrite it to something like:&lt;/p&gt;
&lt;code&gt;
annotated(); my $foo = Scalar::Annotated-&gt;new(0, '$foo'); $$foo = 5;
&lt;/code&gt;
&lt;p&gt;Thus people could use &lt;c&gt;annotated&lt;/c&gt; in much the same way as they currently use &lt;c&gt;my&lt;/c&gt;, &lt;c&gt;local&lt;/c&gt; or &lt;c&gt;our&lt;/c&gt;.&lt;/p&gt;</field>
<field name="root_node">
954455</field>
<field name="parent_node">
954495</field>
</data>
</node>
