bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: ambigious ++ expression silently accepted


From: Aharon Robbins
Subject: Re: ambigious ++ expression silently accepted
Date: Tue, 13 Dec 2005 06:37:30 +0200

Thanks for the note.

> Date: Mon, 12 Dec 2005 19:23:20 +0100
> From: Ronny Akkersdijk <address@hidden>
> Subject: ambigious ++ expression silently accepted
> To: address@hidden
>
> I found something which may have to be classified as a bug.

It's not, see below.

> gawk version 3.1.4 (Fedora 4 distro on intel x86)
> Sorry, the 3.1.5 rpm for FC doesn't seem to exist yet.
>
> Some of my students wrote "{ foo++bar }" which is ambigious;
> Either: post-increment foo and concatenate with bar
> or: concatenate foo with pre-increment bar.

It's not ambiguous. The unary operators have higher precedence
than the binary ones, and concatenation is a binary operator.

> I would expect gawk to complain, but it does not 8-)
> If you change it into "{ print foo++bar }"
> you can see version 3.1.4 uses the first interpretation
> but whether by accident or by intention is unclear ;-)

By intention, as just described.

> address@hidden

I'll admit that concatenation in awk is possibly the single biggest source
of precedence confusion and strange behavior, and it would have been
better all around had the Bell Labs guys given it an explicit operator.
But they didn't, so we're stuck with awk as it is.

There's not much to do except use whitespace more carefully.

Thanks,

Arnold




reply via email to

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