- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
What's wrong here? Expression issue in Formula()
Caution - JMP will crash!!!
Names Default To Here( 1 );
f = Function( {},
/* .... */
ID = Associative Array( {{Name Expr(), 1}, {Expr(), 2}, {Function(), 3}}, 0 );/* .... */
);
f();
removing the function() from the list fixes the error.
Taking the associative array out of the outer function fixes the error.
[edit] a motivation why this can be helpful:
as a lookup table for parts of expressions - identified via Head()and Type():
myID = ID[Expr(function())]; // expected: 3
code = Expr(g = function ({x},1));
Head(Arg(code,2)); // function()
myID = ID[Head(Arg(code,2))]; // expected: 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: What's wrong here?
It sure does blow JMP away. You just invented a new fast way to exit from a JMP session......
This needs to go to JMP Support! Things like this are not supposed to happen.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: What's wrong here?
I have another one:
Caution - JMP will crash!!!
x = Expr(Function());
Show(name Expr(x) == Expr(Function()));
Print("not dead");
f = function({arg},
name Expr(arg) == Expr(Function()))
outside of the function the comparison of x with Function () is OK.
Inside of the function, JMP will already crash when it sees the command - no need to call f.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: What's wrong here?
from JMP support (TS- 00166834):
There is a known issue where JMP crashes when using a malformed function in another function.
So, the root cause can be narrowed down to
Caution - JMP will crash!!!
f = Function( {}, Expr(Function()));
... looking so innocent.
malformed function definition - yes. But it's a "well formed" JSL expression according to
@joseph_morgan / Using JSL to Develop Efficient, Robust Applications (EU 2018 415) .
So, surprising that JMP cannot live with it.
Function inside Function reminds me of JMP Expr() weirdness, can anyone explain? / @ErraticAttack .
So, besides the users, even JMP has issues when an expression shows up on different levels. So, maybe Insert Into: Flatten(0|1) or @Substitute First Occurence could even help JMP?
The suggestions from JMP support:
There are a couple of other things you can do to prevent the crash. One is to put the curly braces ({}) as a required argument in the internal function. Another is to remove the parentheses after the word Function in the internal function.
unfortunately no help for the application case from above.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: What's wrong here?
A workaround :
f = Function( {},
/* .... */
ID = Associative Array( {{"Name Expr()", 1}, {"Expr()", 2}, {"Function()", 3}}, 0 );
/* .... */
);
f();
code = Expr(g = function ({x},1));
myID=ID[Char(Head(Arg(code,2)))]
but it "hurts" a bit ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: What's wrong here?
I like this one a lot more:
f = Function( {},
/* .... */
Eval (Eval Expr(ID = Associative Array( {{Name Expr(), 1}, {Expr(Parse("Expr()")), 2}, {Expr(Parse("Function()")), 3}}, 0 )));
/* .... */
);
f;
code = Expr(g = function ({x},1));
myID=ID[Head(Arg(code,2))];
It can't work, after the eval expr it will be more or less the same as before ...
... wow!
NB: Expr()won't survive the Eval Expr - so has to get protected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: What's wrong here?
-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: What's wrong here? Expression issue in Formula()
I actually just submitted this bug report a few days ago! I found that using Expr(Function()) inside a function causes a crash. I was using it in the context of
Substitute(my_expr, Expr(Function()), Expr(Method()))
But was able to get by using Expr(Function) instead.
For your issue, another possible solution if you don't want to parse strings is do something like this
y = Function({head_key},
ID = Associative Array( EvalList({{Name Expr(), 1}, {Expr(), 2}, EvalList({Head(Expr(Function({},1))), 3})}), 0 );
ID[NameExpr(head_key)]
);
Show(y(Expr(Function())));
Although still not exactly 'pretty.'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: What's wrong here? Expression issue in Formula()
Head(Expr(Function()))
nice!
much better than my Eval( ... Parse( ... especially after citing Joseph's