No, the print statement is not missing. In fact it prints just fine (function test() is able to obtain the value for variable SOME_TEST).<div><br></div><div>This isn&#39;t exactly the same as C++. In C++, a function does not have access to the calling function&#39;s local declarations. In order for the function to get access to these, they must be passed in as parameters.<br clear="all">
<div><br></div><div>---------</div>Robert Dailey<br>
<br><br><div class="gmail_quote">On Wed, Feb 29, 2012 at 9:54 PM, Michael Hertling <span dir="ltr">&lt;<a href="mailto:mhertling@online.de">mhertling@online.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On 03/01/2012 01:38 AM, Robert Dailey wrote:<br>
&gt; I ran a quick test:<br>
&gt;<br>
&gt;<br>
&gt; function( test )<br>
&gt; message( &quot;SOME_TEST: ${SOME_TEST}&quot; )<br>
&gt; endfunction()<br>
&gt;<br>
&gt; function( start )<br>
&gt; set( SOME_TEST &quot;HELLO WORLD&quot; )<br>
&gt; test()<br>
&gt; endfunction()<br>
&gt;<br>
&gt; start()<br>
&gt;<br>
&gt;<br>
&gt; Seems like a function has access to the calling scope&#39;s defined variables.<br>
&gt; I thought because functions created a new scope, that excluded access to<br>
&gt; variables defined in the outer scope (i.e. calling scope)<br>
&gt;<br>
&gt; Can someone explain?<br>
<br>
</div></div>The line &quot;SOME_TEST: HELLO WORLD&quot; is missing, I guess?<br>
<br>
As usual with scoping mechanisms, there is access to the outer scope<br>
from within the inner scope: Read access via ordinary dereferencing<br>
and write access via PARENT_SCOPE. It&#39;s quite the same as in C/C++<br>
with the { and } tokens; see also the C++ &quot;::&quot; operator.<br>
<br>
Regards,<br>
<br>
Michael<br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br></div>