Bill Allombert on Tue, 07 Feb 2012 00:21:05 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

variable creation


Dear PARI developers,

Jeroen and Henri have asked why doing 
foo(x) when foo is not defined create x.

? variable()
%1 = [x]
? foo(2)
  ***   at top-level: foo(2)
  ***                 ^------
  ***   not a function in function call
? variable()
%2 = [x, foo]

The answer is that the evaluator does as follow:
? disassemble(()->foo(2))
00001   pushdyn         foo \\ $1  = the value of the global variable foo which is 'foo
00002   pushstoi        2   \\ $2  = 2
00003   calluser        1   \\ evaluate $1($2) which fails if $1 is not a t_CLOSURE

So actually, when calluser detect that function foo does not exist the variable is already
created.

Cheers,
Bill.