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

gah4 <gah4@u.washington.edu>
Thu, 8 Dec 2022 14:44:08 -0800 (PST)

          From comp.compilers

Related articles
[6 earlier articles]
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: gah4 <gah4@u.washington.edu>
Newsgroups: comp.compilers
Date: Thu, 8 Dec 2022 14:44:08 -0800 (PST)
Organization: Compilers Central
References: 22-12-001 22-12-003 22-12-004 22-12-007 22-12-010 22-12-011 22-12-012
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="72005"; mail-complaints-to="abuse@iecc.com"
Keywords: types, history
Posted-Date: 08 Dec 2022 17:53:43 EST
In-Reply-To: 22-12-012

On Thursday, December 8, 2022 at 12:45:04 PM UTC-8, Hans-Peter Diettrich wrote:


(snip)


> So let me repeat my questions:


> - Why is "int int" a syntax error? "At least one..." allows for more
> than one type-specifier in declaration-specifiers (6.7).


> - What's "long int long"? My current (Arduino) C++ compiler doesn't flag
> it as an error.


> DoDi
> [This is getting close to comp.lang.c but I'm OK with a little more
> discussion of the design decisions in C's very messy declarations. -John]


Now we can get closer to compilers.


I suspect that it isn't a syntax error, though it will depend on how the
compiler is written.


The compiler (parser) can accept any combination of the specifiers,
and even more than one of them, and then later the compiler decides
that the ones give are not valid.


There was a story many years ago, about a compiler with only one error
message: "SYNTAX ERROR". (Likely in the days of upper case only.)


In any case, it is often easier to write the parser more general than
the actual language, and then flag them later.


But also, the same can be done for the language standard.


As well as I know it, in early C variables default to int. Later, it
was required that they be declared, but the default type was still
int. You could declare:


auto i;


which declares i as automatic, and (by default) int.


It gets more interesting in Fortran, where you can give variables
attributes in separate statements:


            INTEGER I
            DIMENSION I(10,10)
            PUBLIC I
            ALLOCATABLE I
            ASYNCHRONOUS I
            CONTIGUOUS I
            INTENT(IN) I
            OPTIONAL I
            POINTER I
            PROTECTED I
            SAVE I
            TARGET I
            VOLATILE I


All might be legal syntax separately, but not legal in all combinations.


Post a followup to this message

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