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

Re: wrapper functions in modules



Bart Schaefer wrote:

> ... [ several serious problems with the wrapper functions ]

I stand corrected.

And damn, my first idea was to let modules register only one function
which would have to call back the execution code, i.e.:

doshfunc(...)
{
  ...
  runshfunc(list, wrappers);
  ...
}

runshfunc(List list, FuncWrap wrap)
{
  if (wrap)
    wrap->func(list, wrap->next);
  else {
    ...
    execlist(...);
    ...
  }
}

example_wrapper(List list, FuncWrap wrap)  // from module
{
  ... do something

  runshfunc(list, wrap);

  ... restore something
}

This would solve the call stack problems you mentioned. Also, writing
wrappers would be easier in modules since you can use local variables, 
static local variables for number-of-calls and so on...

About the problems with unloading: I would vote for completely
disallowing to unload a module if a wrapper is active for it.
This is relatively easy to keep track of and seems to be the savest,
the question is: how often does one want to unload modules in shell
functions?

Finally about the order in which installed wrappers are to be called:
looking at load_module() it should be enough to build the wrappers
list by appending new definitions to the end.

Ok. No patch for now, just the question: does this sound ok?

And, of course, if someone has ideas for a completely different
solution, I would like to hear about it.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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