From 3938100069802365299
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,13ce76b24fcf616c
X-Google-Attributes: gidf78e5,public
From: Darin Adler <darin@bentspoon.com>
Subject: Re: Operator precedence
Date: 1999/12/29
Message-ID: <B48E2C60.E899%darin@bentspoon.com>#1/1
X-Deja-AN: 565911515
Content-Transfer-Encoding: 7bit
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <3868B1A1.D47627B4@kobasoft.nl>
X-Original-Date: Tue, 28 Dec 1999 08:59:12 -0800
Content-Type: text/plain; charset="US-ASCII"
X-Complaints-To: news@news.unimelb.edu.au
X-Trace: ariel.ucs.unimelb.edu.au 946439403 2734 128.250.37.153 (29 Dec 1999 03:50:03 GMT)
Organization: http://extra.newsguy.com
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUAOGmFEOEDnX0m9pzZAQEt5AGAlPgX58hnWmJD9on7uvehMxTk1zG/cg2I J9jaMoM4rrY/9+eQfjNXnFAgzkQGycJI =HldR
Mime-Version: 1.0
User-Agent: Microsoft Outlook Express Macintosh Edition - 5.0 (1513)
NNTP-Posting-Date: 29 Dec 1999 03:50:03 GMT
Newsgroups: comp.std.c++

Pieter van Beek <vanbeek@kobasoft.nl> wrote:

> There seems to be no operator precedence table in de ansi C++ standard.
> I always used the one from Stroustrup, and only found out yesterday this
> topic is not covered by the standard.

The reason for this is that you can't precisely define the relationships
between the C++ operators in terms of a precedence table. Stroustrup writes
in his book, right below the operator summary chart, "A few [of the C++]
grammar rules cannot be expressed in terms of precedence (also known as
binding strength) and associativity."

In the standard, where it's important to be precise, a chart would do harm,
because it would be redundant and would necessarily conflict with the
information already present in the grammar in the cases where the rules
can't be expressed in terms of precedence. Thus the standard doesn't define
the syntax in terms of "precedence", "binding strength", or "associativity";
instead it presents the grammar.

The standard also addresses this issue explicitly. A footnote in section 5/4
says, "The precedence of operators is not directly specified, but it can be
derived from the syntax."

    -- Darin
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



