Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Backward-compatible anonymous functions?
- X-seq: zsh-users 16089
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Backward-compatible anonymous functions?
- Date: Tue, 07 Jun 2011 10:07:37 -0700
- In-reply-to: <alpine.LNX.2.01.1106071126100.19088@hp.internal>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <alpine.LNX.2.01.1106071126100.19088@hp.internal>
On Jun 7, 11:39am, Benjamin R. Haskell wrote:
}
} () {
} # this stuff happily parsed, but not executed
} }
}
} But, I couldn't think of a similarly-simple transformation (akin to
} "change (A) to (+A)") that I could apply where I used anonymous scopes.
} Anyone here have a good one?
I used to use "repeat 1 { ... }" for this kind of thing but of course
that doesn't have local options/variables.
The trouble is that to implement a scope you have to first define it and
then call it. That requires a syntactic transformation that's probably
impossible in zsh because functions won't accept a block as an argument,
and aliases can only expand in place, they can't grab the command line
and append something at the end.
You might be able to write a scope push/pop module along the lines of
what I played with in workers/28271, but the popping part may still be
a problem. I suppose if you created a builtin "toggle_scope" that
returns true when pushing a new local scope and false when popping to
the previous scope, then you could write
while toggle_scope; { ... }
and then the loop would execute once and the loop body would be in a
new scope. Needs further thought to handle nested scopes, etc.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author