bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: unset does not act as expected on namerefs


From: Dan Douglas
Subject: Re: unset does not act as expected on namerefs
Date: Sat, 6 Jun 2015 03:59:24 -0500

On Tue, Jun 2, 2015 at 7:31 AM, Greg Wooledge <address@hidden> wrote:
> There's declare -i, but no sane person USES that, so we can ignore it.

While in bash `-i` likely either has no effect or slows things down
very slightly, in ksh93 and probably zsh it's a huge performance win
because it prevents integers and floats from being automatically
coerced to and from a string on every operation. It also guarantees
(after the attribute is set) that the value will never be anything
other than the right type unless the attribute is explicitly removed.
It's perfectly sane to use it for values that are always guaranteed
correct by construction or by validation. (Use the `integer' and
`float' aliases in ksh, which are preset to use the largest currently
available type).

So long as you always remember to initialize the variable you can't
really go wrong with it.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]