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

Re: Refering to overlaid variable from within a function



On Fri, 10 Sep 2010 02:13:20 -0400
Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx> wrote:
> The problem I have is that I just noticed that I can't use sets named
> "a", "b", "c", "name" because those are variables local in the suite
> of set manipulation functions.
> 
> Is there a way to refer to variables as they exist in the context of
> the caller of a function, so that you can use a name but not have to
> worry about the caller's names?
> 
> Otherwise, my options are to not name the sets inside the functions,
> which gets even harder to read, or to use __setmanip_<varname>s and
> just rely on that not conflicting, but I'm wondering if there's a
> cleaner way of doing this?

I don't think there is a clean way of doing this.  The variable code is one
of the parts that could do with a complete overhaul to make it maintainable
but without breaking its current functionality, which is a bit like
completely replacing the jam layer in a sponge cake with marmalade without
breaking the cake.

In the past I've used _-names and sometimes (yuk) positional parameters.

I'm not sure how hard it is to add a parameter flag to ensure any parameter
retrieved has a local level less than that of the current function.
Without looking I think it's one of those things where it's easy to do the
basic cases and very hard to do completely consistently.

pws

P.S. except of course the cake is a lie.


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom



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