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

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



On Fri, Apr 23, 2021 at 3:47 PM Oliver Kiddle <opk@xxxxxxx> wrote:
>
> I can just about see the case for warning on typeset -i/-F inf or nan
> but not on use.

Warning on -i/-F but not on simple scalar nor on array/hash is not
very useful because math context doesn't limit expansions to just
numerics.

> If we're worrying about POSIX compliance, it'd be easy enough to disable
> Inf and NaN in POSIX mode but there are dozens of special variables

Inf and NaN are actually lexical tokens in context, so it's not quite
the same situation as special variables.

> Bart Schaefer wrote:
> > +            if (issetvar(p)) {
> > +                zwarn("%s: using constant NaN", p);
>
> I'm not sure that "constant" is even the correct term for what NaN
> or even Inf is?

Perhaps not.  The patch was more to show the cost of implementing the
warning than to attempt to get the warning text right.

> >    integer Inf
> >    print $(( Inf[0] ))
> >  1:Refer to Inf with an array subscript
>
> That could potentially be made to work as an array lookup because
> subscripts have no other meaning that would clash.

Here though you mean array lookup in math context generically, not
specifically for variables with these names?




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