bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: feature request: new builtin `defer`, scope delayed eval


From: Koichi Murase
Subject: Re: feature request: new builtin `defer`, scope delayed eval
Date: Sat, 8 Oct 2022 17:18:40 +0900

Hi Lawrence,

2022年10月8日(土) 16:04 Lawrence Velázquez <vq@larryv.me>:
> On Sat, Oct 8, 2022, at 2:11 AM, Koichi Murase wrote:
> > [...]. One thing to note is that the RETURN trap
> > should be cleaned up inside the RETURN trap itself by running `trap -
> > RETURN', or otherwise the RETURN trap is erroneously considered by
> > Bash to be set for the caller function.
>
> The latter behavior is why I didn't describe RETURN as function-local
> in my earlier message, but I forgot the workaround of unsetting
> the trap from within itself.  Nice.

Yeah, that is the tricky point.

> Another strategy is to construct the complete trap string before
> setting the trap, using whichever concatenation methods are preferred:

I think the original idea of ``defer'', RAII, or similar features in
other programming languages is to avoid that (i.e., requiring cleanup
codes in a separate position of the code).

--
Koichi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]