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

Re: PATCH: anonymous functions, full patch



2008/6/30 Peter Stephenson <pws@xxxxxxx>:
> On Thu, 26 Jun 2008 18:28:53 +0100
> Peter Stephenson <pws@xxxxxxx> wrote:
>> > } Positional parameters from the surrounding area would be hidden and the
>> > } local parameter list empty.  I could easily copy them in so that they
>> > } could be used and modified without affecting the calling environment.
>> >
>> > I'm of two minds on that score.  On the one hand it'd be nice to be able
>> > to get at the surrounding $@.  On the other it may often be a needless
>> > expense.
>>
>> Indeed, though unless your parameter list is humongous it won't be a big
>> effect.  On the other hand. humongous parameter lists are not unknown
>> with things like zargs.
>
> The way the internals work we would have to copy the list to pass down, but
> we wouldn't have to copy the strings.  Anything cleverer (that makes a
> significant difference) is quite a lot of work.  I've left this out for
> now.
>
> Here is a slightly more optimised patch with documentation and tests.
> In principle I think it can be optimised more, but I don't think it's worth
> it.

I played a bit with this to see what works and what doesn't, and I
came across this non-working syntax (which is also obviously useless,
but still):

() a=b
zsh: parse error near `\n'

while these work:

() { a=b }
setopt shortloops; for a in a; a=b

-- 
Mikael Magnusson



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