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

Re: Documenting $(( foo )) as similar to $(( ($foo) ))



On Thu, Feb 15, 2024 at 9:46 PM Lawrence Velázquez <larryv@xxxxxxx> wrote:
>
> I just noticed that Bart added the following text to zshmisc(1):
>
>         If the expansion of $val1 is text rather than a number,
>         then when val1 is referenced that text is itself evaluated
>         as a math expression as if surrounded by parentheses
>         `($val1)'.
>
> I assumed that Mikael's comparison of foo with ($foo) was meant to
> be an analogy, so I didn't nitpick it at the time, but I worry that
> this addition to the documentation could be misconstrued

It was my hope/expectation that "as if" would be adequate there.  Note
that in that paragraph we're talking about how val1 works WITHOUT a $
prefix whereas here here you have it WITH a $ prefix:

> ...just because this is valid (if ill-advised):
>
>         % print $((($foo)))
>         3

The latter is only "valid" because of order-of-operations effects, the
inner $foo is expanded before the outer $(( )).

If you can suggest a better way to express "expansion of $val1 is
text" please do.  I rejected "the value of val1" because prior
sentences already refer to "the value" as the result after arithmetic
occurs whereas here we want to refer to the string before arithmetic.




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