"i guess it's ok to use the heap for global /set variables, but why not use registers or the stack for local variables?"Why did you assume that the fact that /var is an alias for /set -l means that local variables are made on the heap? Or did I misunderstand something here?
Btw, I don't think this little detail would matter in an already "slow" (compared to C++) environment like mirc. It sounds to me like saying that it would make a difference if you travelled the first 10 meters of a 100-kilometer distance by airplane and the rest 99990 meters by car, instead of using the car for all 100 kilometers.
"moreover, this hardcoded aliasing is a security leak that can easily be exploited. for instance, normally it isn't (and shouldn't!) be possible to use an evaluated expression to set local variables"It may be forbidden to modify a local var externally (or set a local var by an evaluated expression) in a programming language, but in scripting I don't consider this (and other similar things mirc does) bad. Inconsistency? Maybe, but I like it
But even if you disagree on the above, I still fail to see your point. How could this thing be exploited and by whom? Anything that has the permission to run aliases in mirc can do anything (including much worse things than setting local variables :P). In your example, if the scripter allows
b to run the
a alias, he should know what
a does. If by "security leak" you mean a discrepancy on a theoretical level then yes, it is a security leak; just let's make it clear that it's not a security leak in any dangerous way.
Anyway, I don't like the /var story either, but for other reasons.
1) It's buggy. Try setting a dynamic local var with /var (
//var %a $+ $me = 1): you'll find out that the "=" is included in the value. Generally, I don't trust /var as much as I trust /set -l (I've considered using /set -l in my scripts instead of /var but in most cases I don't, because it's undocumented and because /var allows you to set multiple vars at once).
2) It's an internal alias, which means that (according to what one would expect but also according to benchmarks) it is slower than /set -l.
Now, what do you make of that?
alias setstuff1 {
if 1 == 1 { !set -l %a 5 }
echo -s %a
}
alias setstuff2 {
if 1 == 1 {
!set -l %a 5 }
echo -s %a
}
alias setstuff3 {
if 1 == 1 { !set -l % $+ a 5 }
echo -s %a
}