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

Re: sh emulation POSIX non-conformances ("inf"/"Inf" in arithmetic expressions)



On Thu, Apr 22, 2021 at 1:46 PM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>
> Warn only when the variable is created, e.g., upon «typeset -F inf» or
> «(( nan = 3.14 ))», but not subsequent assignments?

The latter is already an error.  The former warns spuriously if the
user has no intention of ever mentioning the variable in math context
(or of ever using math at all).  And the problem exists in math
context whether or not the variable is declared to be of a numeric
type.

> Predefine $inf and $nan as readonly float variables initialized to the
> respective values?  (Not saying this is a good idea; just mentioning it
> for completeness)

The constants are case-insensitive, so we'd have to predefine twelve
names.  And we couldn't do this in POSIX (sh) context, which sort of
defeats the purpose.

I'm waiting for Vincent to tell us when/where he thinks the warning
should come from, but I don't think there's any sensible place for it.

The only good solution would have been to pick
otherwise-syntactically-impossible tokens in the first place (as
Vincent also mentioned), but it may be too late.




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