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
So the Squirrel language already has 'outers' which act like references:
local x =0; functionmod() { x =5; } mod(); print(x) // x is now 5
x is modified with _OP_SETOUTER; function main() local x gets modified when calling mod() here
Squirrel "Outers" are similar to true references, but Squirrel's outers are limited to locals in the _parent function.
With some modification, how could full references be added to the Quirrel language?
functionmod(&x) { x =5; } local x =0; mod(x); print(x);
5
Syntax: Maybe parsing & in CreateFunction could call MarkLocalAsOuter() or something similar?
Then for runtime
In SQVM::CLOSURE_OP() outers seem to get setup on creating the closure:
if((nouters = func->_noutervalues)) {
for(SQInteger i = 0; i<nouters; i++) {
SQOuterVar &v = func->_outervalues[i];
switch(v._type){
case otLOCAL: // outer local stack target, possible to use for general references??FindOuter(closure->_outervalues[i], &STK(_integer(v._src)));
break;
case otOUTER:
closure->_outervalues[i] = _closure(ci->_closure)->_outervalues[_integer(v._src)];
break;
}
}
}
To add 'references' to the Quirrel language, "references" would have to be setup right before the function gets called, in _OP_PREPCALL or something? using a modified FindOuter function...
I wish I could create a direct pull request.. I was hoping to first get more insight on how reference parameters would best be implemented
The text was updated successfully, but these errors were encountered:
So the Squirrel language already has 'outers' which act like references:
x
is modified with _OP_SETOUTER; functionmain()
localx
gets modified when callingmod()
hereSquirrel "Outers" are similar to true references, but Squirrel's outers are limited to locals in the
_parent
function.With some modification, how could full references be added to the Quirrel language?
Syntax: Maybe parsing
&
inCreateFunction
could call MarkLocalAsOuter() or something similar?Then for runtime
In
SQVM::CLOSURE_OP()
outers seem to get setup on creating the closure:To add 'references' to the Quirrel language, "references" would have to be setup right before the function gets called, in
_OP_PREPCALL
or something? using a modifiedFindOuter
function...I wish I could create a direct pull request.. I was hoping to first get more insight on how reference parameters would best be implemented
The text was updated successfully, but these errors were encountered: