<?xml version="1.0" encoding="windows-1252"?>
<node id="877292" title="Re: Moose and BUILD and 'ro' attributes" created="2010-12-15 10:44:01" updated="2010-12-15 10:44:01">
<type id="11">
note</type>
<author id="315586">
stvn</author>
<data>
<field name="doctext">
&lt;BLOCKQUOTE&gt;&lt;I&gt;
How do I set read-only variables in BUILD?
&lt;/I&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;
Why not just make a private writer, like this
&lt;CODE&gt;
has 'foo' =&gt; (
    is     =&gt; 'ro',
    isa    =&gt; 'Something',
    writer =&gt; '_set_foo',
    lazy   =&gt; 1,
    build  =&gt; '_build_foo',
);
&lt;/CODE&gt;
&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;I&gt;
Which is called first, BUILD or the attribute_builders?
&lt;/I&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;
The entire object instance is created and finalized before BUILD is called. When it gets to BUILD you can be sure you have a complete object (minus any non-initialized lazy attrs, etc). 
&lt;/P&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-315586"&gt;
-stvn
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
877225</field>
<field name="parent_node">
877225</field>
</data>
</node>
