2025年9月4日(木) 20:57 Martin D Kealey <mar...@kurahaupo.gen.nz>:
> On Wed, 3 Sept 2025 at 07:17, Koichi Murase <myoga.mur...@gmail.com> wrote:
>> 2025年9月3日(水) 1:21 Martin D Kealey <mar...@kurahaupo.gen.nz>:
>> > Maybe « function foo -o compat=60 -o extglob -o nullglob … { …; } »?
>>
>> With that syntax, Zsh defines multiple functions of the same content,
>
> Aww sheesh. Zsh is a great idea, a fresh implementation devoid of
> historical baggage, but then it adds stuff like this in ways that
> clobber potential extension spaces. IMO some zsh extensions are NOT
> worth emulating.
>
>> I'm not sure if we want a similar feature in the future, but at least,
>> I think we want to avoid a confusing syntax as much as possible.
>
> I would strongly prefer a syntax that didn't comprise multiple
> statements that have to be executed in sequence.  Ideally the same
> syntax would work if/when we add lexically scoped functions.

I realized that Zsh implemented "function -T foo" in the latest
release 5.9. It is actually a breaking change.

>From https://zsh.sourceforge.io/releases.html
> # ZSH - Release Notes
>
> ## Changes between 5.8.1 and 5.9
>
> ### Incompatibilities
>
> The "function" reserved word, used to define functions, gained a new
> -T option. That affects syntaxes such as:
>
> 1. "function -T { ... }". It used to define a function named
>   "-T". It now defines and executes an anonymous function with
>   single-level tracing enabled --- same as "function f { ... };
>   functions -T f; f", but without naming the function.
>
> 2. "function -T foo { ... }". It used to define two functions, named
>   "-T" and "foo" (see the MULTI_FUNC_DEF option). It now defines a
>   function "foo" with tracing enabled.
>
> 3. "function -- { ... }". It used to define a function named
>   "--". It now defines and executes an anonymous function. The "--"
>   is taken to be an end-of-options guard (same as "ls --").

Then, we might introduce a similar syntax to specify attributes to the
function, such as « function -r read_only_function { ... } » or «
function -t trace_function { ... } », and even "language-level
options" like « function -o default -o parse_extglob myfunc { ... } »
(where "-o default" means to use the default parse options, ignoring
all non-default parse settings in the context).

--
Koichi

Reply via email to