<?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 Question about type() of variable declared with expr() in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Question-about-type-of-variable-declared-with-expr/m-p/485535#M72946</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using 'expr()' and I have a few questions.&lt;/P&gt;&lt;P&gt;I will ask questions according to the number written in the comments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1)&amp;nbsp;Can it be considered that eval() is applied when c is executed as it is?&lt;/P&gt;&lt;P&gt;2) -&amp;nbsp;&lt;/P&gt;&lt;P&gt;3)&amp;nbsp;Why does Number appear when the type of variable c declared as expr() is checked?&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;If type() executes the argument, recognizes the type and displays the result, I wonder why it is Expression in case of 4).&lt;/P&gt;&lt;P&gt;4) -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;a = 1;
b = 2;

c = expr(a + b);
c;                 // 1) Result : 3
print(c);          // 2) Result : a + b
type(c);           // 3) Result : Number
type(expr(a + b)); // 4) Result : Expression&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you :)&lt;/img&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 16:58:44 GMT</pubDate>
    <dc:creator>TaeJunRyu</dc:creator>
    <dc:date>2023-06-09T16:58:44Z</dc:date>
    <item>
      <title>Question about type() of variable declared with expr()</title>
      <link>https://community.jmp.com/t5/Discussions/Question-about-type-of-variable-declared-with-expr/m-p/485535#M72946</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using 'expr()' and I have a few questions.&lt;/P&gt;&lt;P&gt;I will ask questions according to the number written in the comments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1)&amp;nbsp;Can it be considered that eval() is applied when c is executed as it is?&lt;/P&gt;&lt;P&gt;2) -&amp;nbsp;&lt;/P&gt;&lt;P&gt;3)&amp;nbsp;Why does Number appear when the type of variable c declared as expr() is checked?&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;If type() executes the argument, recognizes the type and displays the result, I wonder why it is Expression in case of 4).&lt;/P&gt;&lt;P&gt;4) -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;a = 1;
b = 2;

c = expr(a + b);
c;                 // 1) Result : 3
print(c);          // 2) Result : a + b
type(c);           // 3) Result : Number
type(expr(a + b)); // 4) Result : Expression&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you :)&lt;/img&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 16:58:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Question-about-type-of-variable-declared-with-expr/m-p/485535#M72946</guid>
      <dc:creator>TaeJunRyu</dc:creator>
      <dc:date>2023-06-09T16:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: Question about type() of variable declared with expr()</title>
      <link>https://community.jmp.com/t5/Discussions/Question-about-type-of-variable-declared-with-expr/m-p/485593#M72948</link>
      <description>&lt;P&gt;The main thing to keep in mind is that &lt;CODE class=" language-jsl"&gt;Print()&lt;/CODE&gt;, &lt;CODE class=" language-jsl"&gt;Write()&lt;/CODE&gt; and &lt;CODE class=" language-jsl"&gt;Show()&lt;/CODE&gt; treat their arguments a bit differently than most functions -- they unpack but don't evaluate. Thus &lt;CODE class=" language-jsl"&gt;Print( c )&lt;/CODE&gt; will print the thing that &lt;CODE class=" language-jsl"&gt;c&lt;/CODE&gt; is -- it is an expression. &lt;CODE class=" language-jsl"&gt;Type()&lt;/CODE&gt; will unpack then evaluate its argument then return its type. If you want &lt;CODE class=" language-jsl"&gt;Type()&lt;/CODE&gt; to behave more like &lt;CODE class=" language-jsl"&gt;Print()&lt;/CODE&gt;, then use &lt;CODE class=" language-jsl"&gt;Name Expr()&lt;/CODE&gt;, as &lt;CODE class=" language-jsl"&gt;Type( Name Expr( c ) )&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 08:40:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Question-about-type-of-variable-declared-with-expr/m-p/485593#M72948</guid>
      <dc:creator>ErraticAttack</dc:creator>
      <dc:date>2022-05-10T08:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: Question about type() of variable declared with expr()</title>
      <link>https://community.jmp.com/t5/Discussions/Question-about-type-of-variable-declared-with-expr/m-p/485594#M72949</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/26363"&gt;@ErraticAttack&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand clearly what you are explaining.&lt;/P&gt;&lt;P&gt;However, I have a question for you.&lt;/P&gt;&lt;P&gt;If &lt;FONT color="#0000FF"&gt;Type&lt;/FONT&gt;() is unpacked and evaluated, then &lt;FONT color="#0000FF"&gt;Expr&lt;/FONT&gt;(a + b) is evaluated in case 4, shouldn't Number be returned as the return value of &lt;FONT color="#0000FF"&gt;Type&lt;/FONT&gt;() as in case 3?&amp;nbsp;In the process of evaluating the type after unpacking, does the processing differ depending on whether the argument is specified as a variable or a function?&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 10:05:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Question-about-type-of-variable-declared-with-expr/m-p/485594#M72949</guid>
      <dc:creator>TaeJunRyu</dc:creator>
      <dc:date>2022-05-10T10:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: Question about type() of variable declared with expr()</title>
      <link>https://community.jmp.com/t5/Discussions/Question-about-type-of-variable-declared-with-expr/m-p/485636#M72951</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;a = 1;
b = 2;
type( a + b );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;"Number"&lt;/P&gt;
&lt;P&gt;Internally, type received an expression tree that looks like add( a, b ). The tree is evaluated to a number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;a = 1;
b = 2;
type( expr( a + b ) );
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;"Expression"&lt;/P&gt;
&lt;P&gt;Internally, type received an expression tree that looks like expr( add( a, b ) ). Again, the tree is evaluated; the expr() node in the tree returns its argument as an expression.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;a = 1;
b = 2;
c = expr( a + b );
type( c );
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;"Number"&lt;/P&gt;
&lt;P&gt;Internally, type received an expression tree that looks like c. Again, it is evaluated. c is an expression, add(a,b), that will use the current values of a and b whenever c is evaluated.&amp;nbsp; c does NOT have an expr() node in its tree.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"unpacking" isn't a well defined idea in JSL. Every built in function initially sees its argument(s) as expression trees. Some functions evaluate their arguments without looking at them first. Other functions never evaluate them. Some functions look to see if the root node of the expression is eval() or expr() or send() and do something different. (send() is the &amp;lt;&amp;lt; operator. There is a unary usage in argument lists to identify special arguments, oftentimes actual messages being sent to a displaybox that is being created.) Adding a formula expression to a column is one example that trips me up sometimes; it assumes the argument should not be evaluated. Adding eval() around the formula causes it to eval, because formula(...) peeks at the argument. The alternative would have been to always evaluate the argument and then the normal use case would require expr() around the formula (because evaluating expr(...) just returns its argument.)&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 13:25:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Question-about-type-of-variable-declared-with-expr/m-p/485636#M72951</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2022-05-10T13:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: Question about type() of variable declared with expr()</title>
      <link>https://community.jmp.com/t5/Discussions/Question-about-type-of-variable-declared-with-expr/m-p/485694#M72952</link>
      <description>&lt;P&gt;Languages like C and C++ evaluate arguments to function calls before the call. C and C++ don't have an Expression data type because expressions are compiled into code at compile time. Faster execution, but limits some of the ways you can think about solving a problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;JSL has a parse() function that takes a string and turns it into an expression tree. The eval() function evaluates the tree. The tree evaluates automatically when accessed as a right-hand-side of an assignment, unless special care is taken to peek at it.&amp;nbsp; There is a nameExpr() function that should only be used if you need to peek at the expression stored in a variable without accidentally evaluating it. For some reason, lost in time, and maybe too late to fix now, print/show/write were written without the call to evaluate their arguments if the argument appears to be a simple variable. Ok, at the time it probably seemed like a speed up because there is some overhead to eval(c) vs just get c's value. But print(c+0) will evaluate the argument, as will print(eval(c)), because the argument is not a simple variable.&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 14:27:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Question-about-type-of-variable-declared-with-expr/m-p/485694#M72952</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2022-05-10T14:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: Question about type() of variable declared with expr()</title>
      <link>https://community.jmp.com/t5/Discussions/Question-about-type-of-variable-declared-with-expr/m-p/485770#M72959</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/982"&gt;@Craige_Hales&lt;/a&gt;&amp;nbsp;is certainly right -- unpacking is not a good term, sorry for any confusion!&amp;nbsp; The behavior I was trying to describe is documented though -- check this link:&amp;nbsp;&lt;A href="https://www.jmp.com/support/help/en/15.2/index.shtml#page/jmp/expressions.shtml" target="_blank"&gt;https://www.jmp.com/support/help/en/15.2/index.shtml#page/jmp/expressions.shtml&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the relevant bit:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ErraticAttach_0-1652199320967.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/42366i5FE4175D7F2A193B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ErraticAttach_0-1652199320967.png" alt="ErraticAttach_0-1652199320967.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 16:15:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Question-about-type-of-variable-declared-with-expr/m-p/485770#M72959</guid>
      <dc:creator>ErraticAttack</dc:creator>
      <dc:date>2022-05-10T16:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: Question about type() of variable declared with expr()</title>
      <link>https://community.jmp.com/t5/Discussions/Question-about-type-of-variable-declared-with-expr/m-p/485972#M72991</link>
      <description>&lt;P&gt;THANK YOU!! you have been extremely helpful! :)&lt;/img&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2022 09:37:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Question-about-type-of-variable-declared-with-expr/m-p/485972#M72991</guid>
      <dc:creator>TaeJunRyu</dc:creator>
      <dc:date>2022-05-11T09:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: Question about type() of variable declared with expr()</title>
      <link>https://community.jmp.com/t5/Discussions/Question-about-type-of-variable-declared-with-expr/m-p/485973#M72992</link>
      <description>&lt;P&gt;Thank you! Became very helpful.&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2022 09:39:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Question-about-type-of-variable-declared-with-expr/m-p/485973#M72992</guid>
      <dc:creator>TaeJunRyu</dc:creator>
      <dc:date>2022-05-11T09:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: Question about type() of variable declared with expr()</title>
      <link>https://community.jmp.com/t5/Discussions/Question-about-type-of-variable-declared-with-expr/m-p/801894#M97779</link>
      <description>&lt;P&gt;Interestin to see that write does different things depending on the type of argument.&lt;BR /&gt;There are some other functions which do the inverse: they look up a simple name, but do NOT evaluate a more complex expression.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anybody have a full list of &lt;EM&gt;which function does "look up", "unpack" , "evaluate" .... it's argument before using it&lt;/EM&gt;?&lt;BR /&gt;How many cases have to be considered?&lt;BR /&gt;&lt;BR /&gt;I noticed there are some special cases like &lt;FONT face="courier new,courier"&gt;for each&lt;/FONT&gt; - which checks if the first argument is a list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;x= Expr(Print(2));
y = "hello";


Write(x); // -&amp;gt;Print(2)
Write(y || " world"); // hello world
Head(x); // Print()
Type(x); //-&amp;gt; 2
...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 22:52:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Question-about-type-of-variable-declared-with-expr/m-p/801894#M97779</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-09-25T22:52:54Z</dc:date>
    </item>
  </channel>
</rss>

