<?xml version="1.0" encoding="windows-1252"?>
<node id="217287" title="Re: Re: Lexical scoping like a fox" created="2002-12-03 12:28:20" updated="2005-07-19 22:21:11">
<type id="11">
note</type>
<author id="87452">
broquaint</author>
<data>
<field name="doctext">
&lt;blockquote&gt;&lt;i&gt;
From this description and the examples it might not be clear that $foo is in scope from its declaration to the end of the enclosing block or file
&lt;/i&gt;&lt;/blockquote&gt;
Good point, but I do mention file-scoped lexicals later on in the tutorial and I don't like forward-referencing in learning material. Will see if I can clear it up somehow though.

&lt;blockquote&gt;&lt;i&gt;
I think that the point [Elian] makes about destruction is still valid. The lifetime of an item is a separate issue to its scope (lexical or otherwise).
&lt;/i&gt;&lt;/blockquote&gt;
This is true, but I didn't think it was necessary to go into the details of reference counting for something as simple as a lexical scoping tutorial. I was trying to keep it as straight forward as possible and adding memory management into the fray would almost certainly confuse the reader. Perhaps I should put a reference to [Matts]' [http://www.perl.com/pub/a/2002/08/07/proxyobject.html|Proxy Objects article] as further reading.

&lt;blockquote&gt;&lt;i&gt;
Another way you can demonstrate this nicely is with a BEGIN block.
&lt;/i&gt;&lt;/blockquote&gt;
Marvellous! That illustrates the compile time vs runtime concept beautifully.

&lt;blockquote&gt;&lt;i&gt;
Not entirely sure that this is quite clear enough - especially the phrase "length of a given lexical scope".
&lt;/i&gt;&lt;/blockquote&gt;
I do labour the meaning of the 'length' of a lexical scope shortly after, and I can't think of another way of clearing stating how a dynamic scope is defined (perhaps a more judicious use of commenting the code would do the trick) so it'll have to do for now :)

&lt;blockquote&gt;&lt;i&gt;
Might be worth mentioning the historical context
&lt;/i&gt;&lt;/blockquote&gt;
Indeed, think I'll stick a line in there to elaborate on why &lt;tt&gt;[perlfunc:local|local]&lt;/tt&gt; has such an ambiguous definition.

&lt;blockquote&gt;&lt;i&gt;
This is, of course, equally true of dynamic scoped variables
&lt;/i&gt;&lt;/blockquote&gt;
True, but I didn't want to mention the fact that localised dynamic variables are in fact *new* variables because I reckon it would add yet another layer of complexity that the tutorial could do without.

&lt;p/&gt;

Thanks again for the input, it is most insightful indeed! I think the whole tutorial will need get another revision and then posted to [Tutorials].

&lt;br/&gt;
HTH
&lt;p/&gt;
&lt;tt&gt;_________&lt;br&gt;&lt;u&gt;broquaint&lt;/u&gt;&lt;/tt&gt;</field>
<field name="root_node">
213855</field>
<field name="parent_node">
215546</field>
</data>
</node>
