You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See _OP_SETOUTER_OP_GETOUTERMarkLocalAsOuter()GetOuterVariable() and FindOuter()
function mod()
-----OUTERS
0 x
-----Instructions
[000] _OP_LOADINT 5
[001] _OP_SETOUTER 255 0[x] // could be extended to support true references
[002] _OP_LOADNULLS 1 1
[003] _OP_RETURN 255 0
local x =123; functionmod() { x =5; } mod(); print(x)
5
With some modification, could real references be added to Squirrel / Squilu ?:
functionmod(&x) { x =5; } local x =123; mod(x); print(x);
5
The text was updated successfully, but these errors were encountered:
Everything is possible when one decides to take time and effort but maybe you'll be better served by something that already implements it like https://github.com/vovkos/jancy.
If you really need something easier is to pass the data as a table/array:
function mod(vx) { vx.x = 5; } local vx = {x=123]; mod(vx); print(vx.x);
Result desired:
We know existing-Squirrel cannot do this, but is it possible to implement this in Squirrel
sqvm.cpp
andsqcompiler.cpp
?How to modify integers by reference, like C++ can do
In Squirrel, the approximate thing is
_OP_SETOUTER
_OP_GETOUTER
. It is used by closure functionssquilu/SquiLu/squirrel/sqvm.cpp
Line 1934 in ef96bae
squilu/SquiLu/squirrel/sqvm.cpp
Line 687 in ef96bae
squilu/SquiLu/squirrel/sqfuncstate.cpp
Line 390 in ef96bae
squilu/SquiLu/squirrel/sqvm.cpp
Line 1162 in ef96bae
See
_OP_SETOUTER
_OP_GETOUTER
MarkLocalAsOuter()
GetOuterVariable()
andFindOuter()
With some modification, could real
references
be added to Squirrel / Squilu ?:The text was updated successfully, but these errors were encountered: