Re: What attributes of a programming language simplify its use?

Keith Thompson <Keith.S.Thompson+u@gmail.com>
Wed, 07 Dec 2022 17:53:19 -0800

          From comp.compilers

Related articles
[4 earlier articles]
Re: What attributes of a programming language simplify its use? christopher.f.clark@compiler-resources.com (Christopher F Clark) (2022-12-03)
Re: What attributes of a programming language simplify its use? gah4@u.washington.edu (gah4) (2022-12-03)
Re: What attributes of a programming language simplify its use? Keith.S.Thompson+u@gmail.com (Keith Thompson) (2022-12-06)
Re: What attributes of a programming language simplify its use? gah4@u.washington.edu (gah4) (2022-12-06)
Re: What attributes of a programming language simplify its use? anton@mips.complang.tuwien.ac.at (2022-12-07)
Re: What attributes of a programming language simplify its use? DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2022-12-07)
Re: What attributes of a programming language simplify its use? Keith.S.Thompson+u@gmail.com (Keith Thompson) (2022-12-07)
Re: What attributes of a programming language simplify its use? DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2022-12-08)
Re: What attributes of a programming language simplify its use? gah4@u.washington.edu (gah4) (2022-12-08)
Re: What attributes of a programming language simplify its use? gah4@u.washington.edu (gah4) (2022-12-12)
| List of all articles for this month |

From: Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups: comp.compilers
Date: Wed, 07 Dec 2022 17:53:19 -0800
Organization: None to speak of
References: 22-12-001 22-12-003 22-12-004 22-12-007 22-12-010
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="68388"; mail-complaints-to="abuse@iecc.com"
Keywords: C, types, history
Posted-Date: 08 Dec 2022 13:57:51 EST

Hans-Peter Diettrich <DrDiettrich1@netscape.net> writes:
> On 12/6/22 6:56 PM, Keith Thompson wrote:
[...]
>> "int int" is a syntax error.
>
> I could not find in the (older) C++ grammar why "int int" should be a
> *syntax* error. Aren't both "int" and "long" simple-type-specifier's
> which can occur multiple times in a decl-specifier-seq?


No, there are specific rules that specify the way they can be used.
In the 2011 ISO C standard standard (I use the draft from
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf), the valid
type specifiers are listed in section 6.7.2.


        At least one type specifier shall be given in the declaration
        specifiers in each declaration, and in the specifier-qualifier
        list in each struct declaration and type name. Each list of type
        specifiers shall be one of the following multisets (delimited
        by commas, when there is more than one multiset per item);
        the type specifiers may occur in any order, possibly intermixed
        with the other declaration specifiers.


The list includes entries:
- int, signed, or signed int
- long long, signed long long, long long int, or signed long long int
among others. There are no entries in which the keyword "int" appears
more than once.


(The C99 standard incorrectly referred to these as "sets" rather than
"multisets", which preserve the number of times each element occurs.
The word "sets" was correct in C90, which didn't have long long.)


[...]


> In former times it was much easier to decide with a single basic type id
> (int...) and type modifiers (long...).


int and long are both keywords that are type specifiers, but they differ
in how they can be used. It's tempting to think that the "long" in
"long int" qualifies the type name "int", and that's probably how it
originated, but that's now how the language standard specifies it.


C++ has equivalent rules, stated a bit differently. (C introduced
long long in 1999, C++ in 2011.)


--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for XCOM Labs
void Void(void) { Void(); } /* The recursive call of the void */


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.