cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
] />

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
ih
Super User (Alumni) ih
Super User (Alumni)

defining function scope changes how result is returned

Why don't all three of these return their unevaluated argument like the first one does? Is there a way to make the last two work like the first? Inside the function, e is still unevaluated, this seems to happen when the result is returned.

names default to here(1);
ns = New Namespace("n");

   foo = function({e}, Name Expr(e) );
ns:bar = function({e}, Name Expr(e) );

show(      foo( expr( notavar     ) ) ); // expected    returns notavar, unevalauted
show( here:foo( expr( notavarhere ) ) ); // unexpected  tries to evaluate notavarhere
show(   ns:bar( expr( notavarns   ) ) ); // unexpected  tries to evaluate notavarns

Inside the function e is unevaluated, as expected:

ns:bart = function( {e}, Show( Name Expr(e) ) );
ns:bart( expr( notavar ) );              // expected, unevaluated

There is an uninspiring workaround by copying the function to the current default namespace, although it doesn't solve nested function calls.

localbar = name expr( ns:bar );
show( localbar( expr( notavar ) ) );     // expected, unevaluated

 

0 REPLIES 0

Recommended Articles