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

Re: Does add-zle-hook-widget violate the contract of ZLE hook widgets?



On Fri, Jun 25, 2021 at 2:52 AM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>
> I think it's misleading to look at the "caller and callee" system.  They
> aren't coupled.  The caller is written to work with any callee that
> follows the standard return value semantics, and the callee is written
> to work with any caller that expects the standard return value
> semantics.
>
> Some callers have a list of callees; some don't.  Some callers who have
> a list of callees will call them all; some will call them until the
> first success; some will call them until the first failure.  The callee
> neither knows nor cares.  The callee simply takes care to return
> non-zero whenever it fails, and zero whenever it succeeds.  That's
> implied.
>
> What isn't implied is which semantics the caller follows.  The caller
> (e.g., add-zsh-hook, add-zle-hook-widget) should document that.
>
> My point was that drivers signal even when there's no one else on the
> road.  The analogy to that is that functions should return zero for
> success and non-zero otherwise even when they don't know what their
> caller would do with that.

It seems I misunderstood your point/metaphor. Yes, I agree with all of
the above.


> Perhaps.  The manual and NEWS/README have different purposes.

I'm reasonably sure that NEWS/README has much lower visibility than
the manual. If we actually want 3rd-party script devs to implement
things correctly, then it needs to be in the manual.


Here's a new version of the patch. I added a note about return values
under ZLE > Hook Widgets.




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