Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: inf and nan in arithmetic expansions
- X-seq: zsh-workers 42370
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: inf and nan in arithmetic expansions
- Date: Sat, 17 Feb 2018 00:38:52 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=5LxIyK 8a4cZVQwVPV67E/BJfFHFXRGPRhyYZb5oXhx8=; b=e1TARpmRp+NmINc4pwpYl/ K4o22WVLcqY03sSSHd0RmesRjffCfdlmb30wq9It2pM/hyDEThIA3Cjhlh2CgDhx kr8Cw5i5AlsI+Z2h7TmNZPbuPPxOWMTT7Qc02aQdTZwL6CfmYlXZajs0O8ZPQlxr FQSVaG7WHYF5eFoVV5U3Ru88+x1+bv7lhnULLDHe0J1uoZnqN+fl05IQfDkFfQwz ly9bmRIeTgfQAXOYw3no5O9LxiBsWDKtUIwRqOt64TMp4ONkAUFYwc8jKuuaCLXk zdbYoHRPpkZ1FhUtmkoKe/a1T3UHGQZhQ7j7VllQbSvGfrljMXwse/rcSAgs/BHQ ==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=5LxIyK 8a4cZVQwVPV67E/BJfFHFXRGPRhyYZb5oXhx8=; b=DqPFQuYtnUSYwwAi4J6wVZ 8Qwqo7ig+FB90zHoOOt3of7Xd2YEZpFYQuRXPf5TWwvCsSagaZ4ok4L2/ZrjvolW AGdEOlLHmydevvfKDwo42HxET41P//hxzdy75kD94mZ1qL8rQp+yEbyiiowtMA1y V3zz56biceOihykAlHIcSt61zy+jHX2JTVQ4ft7C2OE29d3pQbjGama2Yyy1G2s/ brm4XMYJ3YuxCt0mIK41Lx5jSTba5B7AWCCzrpkWl34Q82ynUuos7siCxJhAwA5+ k6UsVKR1aurGee9SjWHOLPXhiHAc8ks2a3QYXhedZPiRYZNSIPS9CBqim4rRAHCA ==
- In-reply-to: <17756.1518799875@thecus.kiddle.eu>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20180207223051.GA30393@chaz.gmail.com> <4253.1518045946@thecus.kiddle.eu> <1518093995.645366.1263935336.265ED7BF@webmail.messagingengine.com> <17756.1518799875@thecus.kiddle.eu>
Oliver Kiddle wrote on Fri, 16 Feb 2018 17:51 +0100:
> > And then we could add 'inf' and 'nan' as readonly variables initialised to
> > those respective values (as Oliver also suggests in the 19597 thread). There
> > are compatibility implications for scripts that use these variable names, but
> > there is no way around them if we want to allow explicitly doing (( x = inf ))
> > in user code...
>
> I'm not sure about making them readonly simply because not doing so is
> less likely to break an existing script.
After 42356 I am not sure whether I would prefer predefined variables
(readonly or not) or recognising 'inf' and 'nan' (putting aside the
question of case for a moment) as special constants in math contexts
as 42356 suggests.
> @@ -791,6 +822,21 @@ zzlex(void)
> break;
> /* Fall through! */
Unrelated to the patch: that comment is incorrect.
> default:
> + if (strcmp(ptr-1, "NaN") == 0) {
> + yyval.type = MN_FLOAT;
> + yyval.u.d = 0.0;
> + yyval.u.d /= yyval.u.d;
> + ptr += 2;
> + return NUM;
> + }
> + else if (strcmp(ptr-1, "Inf") == 0) {
> + yyval.type = MN_FLOAT;
> + yyval.u.d = 0.0;
> + yyval.u.d = 1.0 / yyval.u.d;
> + ptr += 2;
> + return NUM;
> + }
> +
> if (idigit(*--ptr) || *ptr == '.')
> return lexconstant();
> if (*ptr == '#') {
Messages sorted by:
Reverse Date,
Date,
Thread,
Author