Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: autoload -X inside an anonymous function



On Oct 5, 10:32pm, Peter Stephenson wrote:
}
} However, this opens a can of worms, or reveals an open can of worms, or
} at least perturbs the wave function of the universe sufficiently that
} measurement reveals the can of worms to be in the opened state.  (I can,
} however, understand that Schroedinger's Cat is likely to remain more
} popular than Stephenson's Wormcan.)  Sorry, it's Friday evening.

Apparently it's now possible to determine that there are in fact worms
in the can, even if you haven't opened it, which seems a much better
metaphor for what actually goes on in quantum superposition than does
a zombie cat.  It's evidently also possible for two events to be each
other's causes, which is something the zsh code base seems to be quite
suited to demonstrate.
 
}   emulate zsh -c 'autoload +X -z stuff'
} 
} does work, because the function is loaded while the emulation is still
} in effect.  More explicitly, the emulate in this case is only "sticky"
} for functions declared in it, not for functions marked for autoload in
} it.  Maybe this needs to change?

I hadn't followed before that you had to explicitly make this not be the
case:

} 	    /* No sticky emulation for autoloaded functions */
} 	    shf->emulation = 0;

I'm generally in favor of your patch from 30718.  I'm mildly concerned
about functions that, when executed, define or autoload other functions,
but even if that's a real issue it could be fixed by another emulate -c
scope.
 
} Beyond that, I'm not sure what the answer is; is making -z force zsh
} emulation reasonable?  I don't necessarily think making -k force ksh
} emulation is reasonable, the function might be a zsh function that just
} happens to be written using the ksh format for autoloads.

I think changing the semantics of autoload -z is probably going too far.
A new option to autoload that caused emulation to be in effect would be
OK, but as the effect can already be had with an emulate wrapper, that
might be unnecessary TMTOWTDI.

} This generalises in a natural way to other emulations in a way
} overloading the -z flag doesn't.

Agree.



Messages sorted by: Reverse Date, Date, Thread, Author