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

Re: autoload variables

Am 30.08.21 um 18:57 schrieb Anthony Fletcher:
On Mon, 30 Aug 2021 at 12:40, René Neumann <lists@xxxxxxxxx> wrote:

Is there a reason you need this as a variable? Would a function

upif() { ip -4 r | ... }

not suffice?

- René

A function would work but then you need to run it every time to get the
same value..... and of course the variable is for other commands. Thus
        systemcommand $(upif)
In this particular case anything to do with the uplink interface (eg
dump_dhcp6). I guess the function could cache the result for speed.

As always: the tradeoff between having everything loaded "just in case" vs the "doing extra work when I need it".

In my eyes, it heavily depends on the use cases: When you write, "I need it (only) when debugging networks", I hear "once in a blue moon" and would argue that any discussion about speed is wasted time (i.e. well, let it recalc the value each of the four times a month one needs it). But you also might be someone for whom "debugging networks" is part of the job, which of course shifts the focus a lot...

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