Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: anonymous functions (no documentation yet)
- X-seq: zsh-workers 25252
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx (Zsh hackers list)
- Subject: Re: PATCH: anonymous functions (no documentation yet)
- Date: Thu, 26 Jun 2008 10:12:33 -0700
- In-reply-to: <18441.1214488302@xxxxxxx>
- In-reply-to: <200806261506.m5QF6aCd019139@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <18441.1214488302@xxxxxxx> <9646.1214491732@thecus> <200806261506.m5QF6aCd019139@xxxxxxxxxxxxxx>
On Jun 26, 2:51pm, Peter Stephenson wrote:
}
} I just spotted that it's very easy to add "anonymous" functions, which
} are defined using normal function syntax, but executed immediately.
I like this idea although I prefer the "function { ... }" syntax to the
empty parens with nothing before them.
With FUNCTION_ARGZERO set, what's the value of $0 inside an anonymous
function? What's the value of $functions[$0] ?
On Jun 26, 4:06pm, Peter Stephenson wrote:
} Subject: Re: PATCH: anonymous functions (no documentation yet)
}
} Oliver Kiddle wrote:
} > f ''() { ... }
} >
} > might have the effect of defining a function f and running it
} > immediately. And then you might write: f '' ''() { ... } and so on.
}
} That ought to be a relatively straightforward addition, I think, subject
} to the query above.
What would the form with multiple empty-string arguments mean? Call
the function multiple times? (Anyway I take it from later remarks
that ''() already defines a function with the empty name, so probably
this "name it but also call it" idea won't work.)
} > What effect does all this have on the positional parameters?
}
} 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author