Skip to content
\n

Following code prints as expected:

\n
my_option: \n    default: some_string\n    actual: test\n\nmy_option2: \n    default: $my_option/${2+3}\n    actual: test/5\n
\n

But inside docs I saw following https://scons.org/doc/production/HTML/scons-user.html#b-Substfile that Substfile can be nondeterministic in some cases. So are there similar limitations for this feature and is it published? I couldn't find it in the docs so... But looks like very intended beahavior so maybe it is published?

","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"

Sorry, never commented on this... I think the Substfile wording in the User Guide you point to is a remnant of when Python dicts were not order-preserving.

\n

In the case of Variables, ones that come from a file are processed by doing an exec on the script as if it were Python code, so that behavior should be well-known; nothing particular is done up front for values that come from the command line. Then, once a declared variable has a value, if it has a converter it is substituted before the converter is called; if it has a validator it may be substituted, depending on the type of the value - both also controlled by a flag which can be set to not do substitution (that's because of a specific request to cover a case where a value needed to hold something starting with a $ which was intended for the external tool, not as an SCons variable reference).

\n

So there seem to be plenty of ways for substitution not to happen on the value/default of a variable...

","upvoteCount":1,"url":"https://github.com/SCons/scons/discussions/4651#discussioncomment-11486778"}}}

Is variable default value expansion is published and reliable #4651

Answered by mwichmann
dustdfg asked this question in Q&A
Discussion options

You must be logged in to vote

Sorry, never commented on this... I think the Substfile wording in the User Guide you point to is a remnant of when Python dicts were not order-preserving.

In the case of Variables, ones that come from a file are processed by doing an exec on the script as if it were Python code, so that behavior should be well-known; nothing particular is done up front for values that come from the command line. Then, once a declared variable has a value, if it has a converter it is substituted before the converter is called; if it has a validator it may be substituted, depending on the type of the value - both also controlled by a flag which can be set to not do substitution (that's because of a specifi…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dustdfg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants