-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
Milestone
Description
While working on reducing the overhead of running for-loops, I stumbled upon one weird fact:
> function foo --on-variable foo; echo $argv $foo; end
> for foo in 1 2 3; end
VARIABLE SET FOO
VARIABLE SET FOO
VARIABLE SET FOO
VARIABLE SET FOOSee how that calls the event handler four times? That's because this called parser::set_var_and_fire to set the variable initially, which pins it to the outer scope.
That's probably useless.
However, I'm not sure the events here have a use in general. The reason is that for sets the variable as a local to the enclosing block, so no variable handler would ever be able to touch it?
Do we want to just remove the superfluous handler or the event firing here in general?
(or do we even want to abolish events for local variables entirely?)
Is there a use here I'm not seeing?