<?xml version="1.0" encoding="UTF-8"?>

<rss version="2.0" xmlns:blogChannel="http://backend.userland.com/blogChannelModule">

<channel>
<title><![CDATA[Perl 6: SMOP Autovivification]]></title>
<link>http://www.perlfoundation.org/perl6/index.cgi?smop_autovivification</link>
<description></description>
<pubDate>Fri, 18 Jan 2008 17:20:23 -0000</pubDate>
<webMaster>synedra@gmail.com</webMaster>
<generator>Socialtext Workspace v2.14.7.2</generator>

<item>
<title><![CDATA[SMOP Autovivification]]></title>
<link>http://www.perlfoundation.org/perl6/index.cgi?smop_autovivification</link>
<description><![CDATA[<div class="wiki">
<h1 id="how_should_autovivification_work">How should autovivification work?</h1>
<blockquote><blockquote><blockquote>
This document still references YAP6 before the refactoring that caused the rename to SMOP. The logic is still valid, but the way the code works is considerably different.</blockquote></blockquote></blockquote>
<br /><p>
here it would return a ProxyScalar that references %a and 'b'</p>
<pre>
__a_b = YAP6_HASH_LOOKP(%a, 'b'); // variable resolution not detailed here.
</pre>
<br /><p>
the same object with a coercion to hash, at this time,</p>
<pre>
_hash__a_b = YAP6_HASH(__a_b);
</pre>
<br /><p>
here it would return another ProxyScalar that references _hash__a_b and 'c'</p>
<pre>
__a_b_c = YAP6_HASH_LOOKP(_hash__a_b, 'c');
</pre>
<br /><p>
until now, nothing happened yet, just the proxy objects were created but no actual lookup was made yet. we have a lazy path to the container.</p>
<pre>
my $b := %a&lt;b&gt;&lt;c&gt;;
</pre>
<br /><p>
The bind case, is at first, a capture creation, just like when using it into an argument list. So we have a two phase thing which is.</p>
<pre>
capture = YAP6_CAPTURE(/*invocant*/ NULL, /*positional*/ YAP6_LIST_CREATE(__a_b_c), /*named*/ NULL);
YAP6_BIND(/* this should be a signature, not detailed here*/ $b, capture);
</pre>
<br /><p>
After TimToady's clarification (and actual spec change), we now know that the capture never autovivifies, but only the binding does it. And only if the bound container is a rw container, so.</p>
<pre>
my $a is readonly := %a&lt;b&gt;&lt;c&gt;; # doesn't autovivify
</pre>
<br /><p>
So, the capture is really just a way to defer the contextualization of the object and does nothing else.</p>
<p>
The binding code is responsible for, when doing the actual bind, checking if the container itself is defined. If not and in the presence of a WHENCE closure, the object should be autovivified. But this requires the bootstrap...</p>
<p>
for now, check <a href="http://www.perlfoundation.org/perl6/index.cgi?smop_oo_bootstrap" title="(61 months) At first, it s important to understand that all C typedef structs in [SMOP] are meant to support Per...">SMOP OO Bootstrap</a></p>
</div>
]]></description>
<author>Daniel Ruoso</author>
<guid isPermaLink="true">http://www.perlfoundation.org/perl6/index.cgi?smop_autovivification</guid>
<pubDate>Fri, 18 Jan 2008 17:20:23 -0000</pubDate>
</item>

</channel>
</rss>