cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
hogi
Level XIII

variables, symbols and names

in JSL, what is the difference between a variable, a "symbol" and a "name"?

 

var=Expr(1+2);
Name Expr(var); // return the expression which is stored in the name "var" - so var is a name?
Clear Symbols(var); // how can I clear a "symbol" if it's actually a "name"
3 REPLIES 3
hogi
Level XIII

Re: variables, symbols and names

Hm, names are more than just variables.
e.g. If a name is followed by (), it's considered to be a function:
 https://www.jmp.com/support/help/en/19.0/#page/jmp/rules-for-resolving-names.shtml 

 

And to clear or delete it, again one has to consider it to be a symbol:

f = function({}, print(hello));
Delete Symbols(f);
is empty(f)
hogi
Level XIII

Re: variables, symbols and names

How to create a name:

Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );
	
x = Expr(sex);
Show(Type(Name Expr(x)),x);

x = Parse("sex");
Show(Type(Name Expr(x)),x);

x = Parse(":sex");
Show(Type(Name Expr(x)),x); x = As Name("sex"); Show(Type(Name Expr(x)),x); Show(x[5])
hogi
Level XIII

Re: variables, symbols and names

Maybe better:

names default to here(1);
x=1;
Clear Symbols(x);

Name Expr(x);
Name Expr(y);

 

x is a variable, better: a symbol 

(can be cleared via clear symbols())

 

In Name expr(x), JMP takes thy NAME "x" [how knows if it's a symbol!], applies the rules:  https://www.jmp.com/support/help/en/19.0/#page/jmp/rules-for-resolving-names.shtml , finds out that x is a symbol in the here namespace and returns the expression stored in this symbol.

 

In Name expr(y), JMP takes thy NAME "y", applies the rules:  https://www.jmp.com/support/help/en/19.0/#page/jmp/rules-for-resolving-names.shtml , doesn't find anything and returns the name.


Up to now, I thought, 

names default to here(1);

means:
store the names in the here namespace.

But actually, names cannot be stored, they are just names?
So it is:
Look up the names in the here namespace  - [and if you don't specify a namespace, I will store the symbols there].

Who cares? Maybe understanding the original logic helps to better follow the logic ...


and if name expr() gets an expression as an argument that is different from a simple name, it just returns the expression?
always?

Recommended Articles