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't exactly the same as C++. In C++, a function does not have access to the calling function'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"><<a href="mailto:mhertling@online.de">mhertling@online.de</a>></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>
> I ran a quick test:<br>
><br>
><br>
> function( test )<br>
> message( "SOME_TEST: ${SOME_TEST}" )<br>
> endfunction()<br>
><br>
> function( start )<br>
> set( SOME_TEST "HELLO WORLD" )<br>
> test()<br>
> endfunction()<br>
><br>
> start()<br>
><br>
><br>
> Seems like a function has access to the calling scope's defined variables.<br>
> I thought because functions created a new scope, that excluded access to<br>
> variables defined in the outer scope (i.e. calling scope)<br>
><br>
> Can someone explain?<br>
<br>
</div></div>The line "SOME_TEST: HELLO WORLD" 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's quite the same as in C/C++<br>
with the { and } tokens; see also the C++ "::" 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>