Bug or unsupported usage?

I couldn't say whether this is a bug, a feature, or an unsupported usage of table parameters, but I was getting odd results until I realized what was going on.

Sample code to illustrate the behavior:

Table:Test
[@This with alpha]

Table: This
In This, $1 is initially {$1}.&
\n[@That with bravo]&
\nIn This, $1 is now {$1}.

Table: That
In That, $1 is {$1}.

The result shows that $1 in table This has changed. You've lost the initial value of the table parameter.

In This, $1 is initially alpha.
In That, $1 is bravo.
In This, $1 is now bravo.

$1 isn't restored upon returning to table This.

The workaround is to preserve $1 right away:

Table:Test
[@This with alpha]

Table: This
{this1==$1} In This, this1 is initially {this1}.&
\n[@That with bravo]&
\nIn This, this1 is now {this1}.

Table: That
In That, $1 is {$1}.

And that lets you keep the original value for This's parameter:

In This, this1 is initially alpha.
In That, $1 is bravo.
In This, this1 is now alpha.

Comments

  • This would be 'expected' behavior. All variables are considered globals, so once set, they are available everywhere.

Leave a Comment