<div><div dir="auto">I learned some about scope by studying how LISP/Scheme implemented them.   It’s like a stack of maps,  when you enter a new scope, you get a new map, and push it on the stack,   When you exit a scope, you pop the map.   You can enter new fields into the map with their values.</div><div dir="auto"><br></div><div dir="auto">John</div></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jun 7, 2020 at 3:41 PM Andreas Plesch <<a href="mailto:andreasplesch@gmail.com">andreasplesch@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div dir="ltr">Let's see if I can explain this question clearly.<br><br>First the example:<br><br><div><a href="https://github.com/andreasplesch/x3dom/blob/gh-pages/test/functional/proto/castle/proto_nested.x3d" target="_blank">https://github.com/andreasplesch/x3dom/blob/gh-pages/test/functional/proto/castle/proto_nested.x3d</a> </div><div><br></div><div>The table2 ProtoBody uses an instance of the leg2 proto. The leg2 proto declaration is defined outside of the table2 proto declaration name scope.</div><div><br></div><div>The expected result is that the table2 proto declaration is able to use the name 'leg2' to find the leg2 proto definition.</div><div><br></div><div>This does not work in my x3dom proto exploration and it took me a while to realize that the reason is (too?) strict scoping. The leg2 proto definition occurs outside of the execution context and name scope of the table2 proto. Therefore it is not visible to the table2 proto.<br></div><div><br></div><div>At first glance this strictness seems not unreasonable, however, all tested browsers display the scene as expected.</div><div><br></div><div>So I am somewhat puzzled. I think what it means is that name scoping does not apply to the name of Protos given by the name attribute, since the name of Proto is the name of a node definition. Proto names are possibly global.</div><div><br></div><div>One consequence is that two Protos in a scene cannot have the same name. And I recall that this case is spec'ed to lead to undefined behaviour.</div><div><br></div><div>Would it be correct to treat Proto names as global ? To be clear, by Proto name I refer to the name given by the name attribute, not a DEF name of an instance.</div><div><br></div><div>Thanks for any insight, or pointers to relevant spec. sections, -Andreas</div></div><div dir="ltr"><div><br></div><div>-- <br>Andreas Plesch<br>Waltham, MA 02453</div></div>
_______________________________________________<br>
x3d-public mailing list<br>
<a href="mailto:x3d-public@web3d.org" target="_blank">x3d-public@web3d.org</a><br>
<a href="http://web3d.org/mailman/listinfo/x3d-public_web3d.org" rel="noreferrer" target="_blank">http://web3d.org/mailman/listinfo/x3d-public_web3d.org</a><br>
</blockquote></div></div>