<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Returning an expression from a function differs when namespace is used. in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/901939#M106108</link>
    <description>&lt;P&gt;wow!&lt;BR /&gt;&lt;BR /&gt;added to&amp;nbsp;&lt;LI-MESSAGE title="Tiny Traps in Jmp and JSL" uid="702685" url="https://community.jmp.com/t5/Discussions/Tiny-Traps-in-Jmp-and-JSL/m-p/702685#U702685" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 19 Sep 2025 11:04:40 GMT</pubDate>
    <dc:creator>hogi</dc:creator>
    <dc:date>2025-09-19T11:04:40Z</dc:date>
    <item>
      <title>Returning an expression from a function differs when namespace is used.</title>
      <link>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/658869#M84815</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ran into some strange behavior when returning an expression from a function, and could not find any discussions about this already. I am in the habit of using namespaces for pretty much everything. I found that when a function returns an expression, the expression is not evaluated for an unscoped function, but is evaluated if a namespace is used. Does anyone know what's going on here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This script should show that the variable x is not incremented when the first function is called, but is incremented on the second function call. I am using JMP v17.0.0, so this has possibly been fixed, but I am not able to update right now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NewNamespace("varNamespace");
varNamespace:x = 0;&lt;BR /&gt;
myFunc = Function({},
	{DEFAULTLOCAL},
	returnVal = Expr(varNamespace:x++);
	NameExpr(returnVal);
);

myFunc();
Show(varNamespace:x);

NewNamespace("functionTest");
functionTest:myFunc = Function({},
	{DEFAULTLOCAL},
	returnVal = Expr(varNamespace:x++);
	NameExpr(returnVal);
);

functionTest:myFunc();
show(varNamespace:x);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Jul 2023 01:34:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/658869#M84815</guid>
      <dc:creator>bculver</dc:creator>
      <dc:date>2023-07-17T01:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: Returning an expression from a function differs when namespace is used.</title>
      <link>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/680708#M86642</link>
      <description>&lt;P&gt;I have updated to 17.2.0, and can confirm this is still issue still occurs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a simplified example that should hopefully be easier to read&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;x = 0;
myFunc = Function({}, {DEFAULTLOCAL},
	Expr(::x++);
);

myFunc(); // Returns unevaluated expression: Expr(::x++)
Show(::x); // ::x=0;

NewNamespace("funcNS");
funcNS:myFunc = Function({},{DEFAULTLOCAL},
	Expr(::x++);
);

funcNS:myFunc(); // Returns evaluated expression;
show(::x); // ::x=1;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Sep 2023 20:47:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/680708#M86642</guid>
      <dc:creator>bculver</dc:creator>
      <dc:date>2023-09-22T20:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: Returning an expression from a function differs when namespace is used.</title>
      <link>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/680789#M86648</link>
      <description>&lt;P&gt;Pretty sure you've discovered a bug. Here's a even more simplified demo of two ways to use functions in namespaces:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;funcNS = New Namespace(
	"funcNS",
	f1 = Function( {}, 
		expr(1+2)
	)
);

funcNS:f2 = Function( {}, 
	expr(1+2)
);
	
Show( Type( funcNS:f1() ), Type( funcNS:f2() ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Type(funcNS:f1()) = "Expression";&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Type(funcNS:f2()) = "Number";&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;f1 is returning the correct answer; f2 is incorrectly evaluating the answer. I prefer the f2 way (except for this bug) because it is faster:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;
funcNS = New Namespace(
	"funcNS",
	f1 = Function( {}, 
		1
	)
);

funcNS:f2 = Function( {}, 
	1
);
	
nf1 = 0;
For( endtime = HP Time() + 1e6, endtime &amp;gt; HP Time(), nf1++,
	funcNS:f1()
);
Show( nf1 ); // 180K calls
nf2 = 0;
For( endtime = HP Time() + 1e6, endtime &amp;gt; HP Time(), nf2++,
	funcNS:f2()
);
Show( nf2 ); // 260K calls&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;nf1 = 182239;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;nf2 = 258929;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The two issues are probably related. Items specified inside the namespace function call are not constructed until they are used (they are kept as expressions.) That means f1 is not compiled when the namespace is created, but f1 is compiled each time it is used, thus slower.&amp;nbsp; So there is probably some specialized C++ code to recompile f1 and then evaluate it. My guess is that same code is triggered for f2, but doesn't recompile because f2 is already compiled, and then incorrectly evaluates the result of f2, which most of the time is a primitive value and no one notices. The expr() value that is returned does evaluate into a simpler value, causing you to notice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-SPOILER&gt;code I played with to check my understanding&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;c=1; d="hi"; e=["key1"=&amp;gt;"val1"];
a = New Namespace( "a",
	w = {c, d, e},
	x = Eval List( {c, d, e} ),
	 // the RHS expression is assigned to x
	y = 1 // this does what you expect because 1 == expr(1)
);
Show( a );
/* The namespace is holding the expressions...
a = New Namespace("a", {
w = {c, d, e},
x = Eval List( {c, d, e} ),
y = 1
});
*/
Show( a:x ); // a:x = {1, "hi", ["key1" =&amp;gt; "val1"]};
/////////// change some globals
c=2; d="there"; e["key2"]="newval";
Show( a:x ); // a:x = {2, "there", ["key1" =&amp;gt; "val1", "key2" =&amp;gt; "newval"]};

a:z = Eval List( {c, d, e} );
show(a);
/*
a = New Namespace("a", {
w = {c, d, e},
x = Eval List( {c, d, e} ),
y = 1,
z = {2, "there", ["key1" =&amp;gt; "val1", "key2" =&amp;gt; "newval"]}
});
*/
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2026"&gt;@jules&lt;/a&gt;&amp;nbsp; - pretty sure this is a bug. I don't think there will be many namespace users depending on the wrong behavior.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Sep 2023 16:08:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/680789#M86648</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-09-23T16:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: Returning an expression from a function differs when namespace is used.</title>
      <link>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/901483#M106072</link>
      <description>&lt;P&gt;Has there been any update to this?&lt;BR /&gt;As far as i can tell this behavior still exists in jmp 19.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It definitely seems like the return value gets evaluated twice in the ns:f2 definition:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;ns = New Namespace("fns",
	f1 = Function({},
		x = Expr(1+3);
		return(Name Expr(x));
	);
);

f1 = Function({},
	x = Expr(1+3);
	return(Name Expr(x));
);

ns:f2 = Function({},
	x = Expr(1+3);
	return(Name Expr(x));
);

ns:f3 = Function({},
	x = Expr(1+3);
	return(Name Expr(Name Expr(x)));
);

Show(f1(), ns:f1(), ns:f2(), ns:f3());&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRIKE&gt;&lt;STRONG&gt;f1() = 1 + 3;&lt;BR /&gt;ns:f1() = 1 + 3;&lt;BR /&gt;ns:f2() = 4;&lt;BR /&gt;ns:f3() = 1 + 3;&lt;/STRONG&gt;&lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;f1() = 1 + 3;&lt;BR /&gt;ns:f1() = 1 + 3;&lt;BR /&gt;ns:f2() = 4;&lt;BR /&gt;ns:f3() = x;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRIKE&gt;If anyone else encounters this problem the quick workaround is as the example suggest; Wrap the return value in "Name Expr" until the desired result&amp;nbsp;&lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;This does not work. I had a x defined in the global/here scope from previous runs. There seem to be no way to return an expression from a function defined like ns:f2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This definitely seem like a bug, i dont think anyone would expect a ns:f2 to return a different value compared to ns:f1 or f1; the function code is exactly the same.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Sep 2025 16:28:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/901483#M106072</guid>
      <dc:creator>KasperSchlosser</dc:creator>
      <dc:date>2025-09-17T16:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: Returning an expression from a function differs when namespace is used.</title>
      <link>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/901703#M106088</link>
      <description>&lt;P&gt;I'll make a report through the support team.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TS-00235798&lt;/P&gt;</description>
      <pubDate>Thu, 18 Sep 2025 14:11:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/901703#M106088</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2025-09-18T14:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: Returning an expression from a function differs when namespace is used.</title>
      <link>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/901731#M106090</link>
      <description>&lt;P&gt;I also made a report: TS-00235515&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The response from support was that this was not considered a bug, even if the behavior was unexpected.&lt;/P&gt;
&lt;P&gt;Root cause was as you described; Basically the ns:f2 function gets evaluated twice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This seem to also affect everything defined outside the initial namespace creation, As can be seen in the updated example below.&lt;/P&gt;
&lt;P&gt;The proposed solution is to wrap everything in an expression - ns:f2 = Expr(Function(....))&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);
delete symbols();

ns = New Namespace("fns",
	{
	f1 = Function({},{Default Local},
		x = Expr(1+3);
		return(Name Expr(x));
	),
	e1 = Name Expr(expr(1 + a))
	}
);

f1 = Function({},{Default Local},
	x = Expr(1+3);
	return(Name Expr(x));
);

ns:f2 = Function({},{Default Local},
	x = Expr(1+3);
	return(Name Expr(x));
);

ns:f3 = Expr(Function({},{Default Local},
	x = Expr(1+3);
	return(Name Expr(x));
));

ns:e2 = Name Expr(expr(1 + a));
ns:e3 = Expr(Name Expr(expr(1 + a)));

show(ns:e1);
show(try(ns:e2, exception_msg));
show(ns:e3);

Show(f1(), ns:f1(), ns:f2(), ns:f3());
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;ns:e1 = 1 + a;&lt;BR /&gt;Try(ns:e2, exception_msg) = {"Name Unresolved: a"(1, 2, "a", a /*###*/)};&lt;BR /&gt;ns:e3 = 1 + a;&lt;BR /&gt;f1() = 1 + 3;&lt;BR /&gt;ns:f1() = 1 + 3;&lt;BR /&gt;ns:f2() = 4;&lt;BR /&gt;ns:f3() = 1 + 3;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Sep 2025 14:39:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/901731#M106090</guid>
      <dc:creator>KasperSchlosser</dc:creator>
      <dc:date>2025-09-18T14:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: Returning an expression from a function differs when namespace is used.</title>
      <link>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/901770#M106093</link>
      <description>&lt;P&gt;That workaround is...unfortunate. Fortunately, most users are not trying to return expressions and don't need it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Sep 2025 16:03:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/901770#M106093</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2025-09-18T16:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Returning an expression from a function differs when namespace is used.</title>
      <link>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/901773#M106094</link>
      <description>&lt;P&gt;Also, most of the unfortunate aspect can be alleviated by returning&amp;nbsp;&lt;/P&gt;
&lt;P&gt;expr(expr(1+1))&lt;/P&gt;
&lt;P&gt;rather than making the entire function be&lt;/P&gt;
&lt;P&gt;expr(function(...&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;funcNS = New Namespace(
	"funcNS",
	f1 = Function( {}, 
		expr(1+2)
	)
);

funcNS:f2 = Function( {}, 
	expr(expr(1+2)) // &amp;lt;&amp;lt;&amp;lt;&amp;lt; extra expr wrapper
);
	
Show( Type( funcNS:f1() ), Type( funcNS:f2() ) ); // expr, expr&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Sep 2025 16:10:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/901773#M106094</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2025-09-18T16:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: Returning an expression from a function differs when namespace is used.</title>
      <link>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/901935#M106106</link>
      <description>&lt;P&gt;That solution is indeed more elegant, however it seem to only work when you can directly write the expression to return.&lt;/P&gt;
&lt;P&gt;If the expression is stored in a variable and we wrap that in an Expr() the value returned is an expression with the variable name&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case it seems the only solution seems to be to wrap the return value in a Name Expr() and the entire function in an expr&lt;/P&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;funcNS:f5 = Expr(Function( {}, {Default Local},
	x = Expr(1+2);
	Name Expr(x)
));

Show( funcNs:f5() ); // 1+2&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;P&gt;One big danger with this us that the second evaluation seem to happen outside the local scope of the function.&lt;/P&gt;
&lt;P&gt;A global variable might shadow the return value, which would not give an error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);
Delete Symbols(); // Only use if you dont have variables you need

funcNS = New Namespace("funcNS");

funcNS:f1 = Function( {}, {Default Local},
	x = Expr(1+2);
	Expr(x);
);

funcNS:f2 = Function( {}, {Default Local},
	x = Expr(1+2);
	Expr(Expr(x));
);

funcNS:f3 = Expr(Function( {}, {Default Local},
	x = Expr(1+2);
	x;
));

funcNS:f4 = Expr(Function( {}, {Default Local},
	x = Expr(1+2);
	Expr(x);
));

funcNS:f5 = Expr(Function( {}, {Default Local},
	x = Expr(1+2);
	Name Expr(x)
));
	
Show( Try(funcNs:f1(), exception_msg) ); // Name Unresolved
Show(funcNs:f2()); // X
Show(funcNs:f3()); // 3
Show(funcNs:f4()); // x
Show(funcNs:f5()); // 1+2

// Second Evaluation happens outside Function scope
x = Expr(Expr(1+10));
Show(funcNs:f1()); // 1+10&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Sep 2025 10:27:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/901935#M106106</guid>
      <dc:creator>KasperSchlosser</dc:creator>
      <dc:date>2025-09-19T10:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: Returning an expression from a function differs when namespace is used.</title>
      <link>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/901939#M106108</link>
      <description>&lt;P&gt;wow!&lt;BR /&gt;&lt;BR /&gt;added to&amp;nbsp;&lt;LI-MESSAGE title="Tiny Traps in Jmp and JSL" uid="702685" url="https://community.jmp.com/t5/Discussions/Tiny-Traps-in-Jmp-and-JSL/m-p/702685#U702685" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Sep 2025 11:04:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/901939#M106108</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-09-19T11:04:40Z</dc:date>
    </item>
    <item>
      <title>Re: Returning an expression from a function differs when namespace is used.</title>
      <link>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/901940#M106109</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);

x= Expr("Hello");

funcNS = New Namespace("funcNS");
funcNS:f = Function( {}, {Default Local},
	x = Expr(1+2);
	Substitute(Expr(Expr(ex)), Expr(ex), (Name Expr(x)))
);
	
Show( funcNS:f() , Type( funcNS:f() ) ); // expr, expr&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;UL&gt;
&lt;LI&gt;go give the function a chance to look up &lt;FONT face="courier new,courier"&gt;x&lt;/FONT&gt; inside the function:&amp;nbsp; &amp;nbsp;&lt;FONT face="courier new,courier"&gt;Name Expr()&lt;/FONT&gt; instead of &lt;FONT face="courier new,courier"&gt;Expr().&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;to prevent the namespace from evaluating the return value "twice", the return value has to be protected with &lt;FONT face="courier new,courier"&gt;Expr()&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;this makes the life difficult for the Name Expr()&amp;nbsp;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Expr(Name Expr())&lt;/FONT&gt; will stop &lt;FONT face="courier new,courier"&gt;Name Expr()&lt;/FONT&gt; from doing it's job&lt;/LI&gt;
&lt;LI&gt;In 99% of such cases, one can use &lt;FONT face="courier new,courier"&gt;Eval Expr().&lt;/FONT&gt;&lt;BR /&gt;But here it's difficult, because &lt;FONT face="courier new,courier"&gt;Expr()&lt;/FONT&gt; is used in JMP for 2 purposes:&lt;BR /&gt;-&amp;nbsp; &lt;FONT face="courier new,courier"&gt;"it is here()"&lt;/FONT&gt; inside of &lt;FONT face="courier new,courier"&gt;Eval Expr()&lt;/FONT&gt;&lt;BR /&gt;- &lt;FONT face="courier new,courier"&gt;I protect you()&amp;nbsp;&lt;/FONT&gt; - as a solution to the namespace issue&lt;BR /&gt;unfortunately, &lt;FONT face="courier new,courier"&gt;Eval Expr()&lt;/FONT&gt; will be happy with the first &lt;FONT face="courier new,courier"&gt;Expr()&lt;/FONT&gt; and evaluate it.&lt;BR /&gt;so, &lt;FONT face="courier new,courier"&gt;Eval Expr(Expr(Expr(Name Expr(x))))&lt;/FONT&gt;&amp;nbsp;will not work in the spirit of&amp;nbsp; &lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Eval Expr ( I protect you ( it is here(Name Expr(x))))&lt;BR /&gt;&lt;/FONT&gt;instead it&amp;nbsp; interpretes it as&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Eval Expr(&amp;nbsp;it is here(I protect you(Name Expr(x))))&lt;/FONT&gt; &lt;BR /&gt;and therefore it will return&amp;nbsp;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Expr(Name Expr(x))&lt;/FONT&gt; &lt;BR /&gt;... and then JMP will search for &lt;FONT face="courier new,courier"&gt;x&lt;/FONT&gt; outside of the scope of the function&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;The ultimate solution to all Expression issues is &lt;FONT face="courier new,courier"&gt;Substitute()&lt;BR /&gt;&lt;LI-MESSAGE title="Re: Expression Handling in JMP: Tipps and Trapdoors" uid="826252" url="https://community.jmp.com/t5/Discussions/Expression-Handling-in-JMP-Tips-and-Trapdoors/m-p/826252#U826252" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;BR /&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;is there an easier solution than&amp;nbsp;&lt;FONT face="courier new,courier"&gt;&lt;BR /&gt;&lt;CODE class=" language-jsl"&gt;Substitute(Expr(Expr(ex)), Expr(ex), (Name Expr(x)))&lt;/CODE&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Fri, 19 Sep 2025 11:26:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Returning-an-expression-from-a-function-differs-when-namespace/m-p/901940#M106109</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-09-19T11:26:18Z</dc:date>
    </item>
  </channel>
</rss>

