cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

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