On 03/01/2012 01:38 AM, Robert Dailey wrote:
> I ran a quick test:
>
>
> function( test )
> message( "SOME_TEST: ${SOME_TEST}" )
> endfunction()
>
> function( start )
> set( SOME_TEST "HELLO WORLD" )
> test()
> endfunction()
>
> start()
>
>
> Seems like a function has access to the calling scope's defined variables.
> I thought because functions created a new scope, that excluded access to
> variables defined in the outer scope (i.e. calling scope)
>
> Can someone explain?
The line "SOME_TEST: HELLO WORLD" is missing, I guess?
As usual with scoping mechanisms, there is access to the outer scope
from within the inner scope: Read access via ordinary dereferencing
and write access via PARENT_SCOPE. It's quite the same as in C/C++
with the { and } tokens; see also the C++ "::" operator.
Regards,
Michael
--
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake