Re: Why put type information into syntax?

lex@cc.gatech.edu
28 Mar 2000 01:03:46 -0500

          From comp.compilers

Related articles
Why put type information into syntax? across@vega.co.uk (Allister Cross) (2000-03-25)
Re: Why put type information into syntax? michael.prqa@indigo.ie (Michael Spencer) (2000-03-28)
Re: Why put type information into syntax? lex@cc.gatech.edu (2000-03-28)
Re: Why put type information into syntax? RobertADuffbobduff@world.std.com> (2000-03-28)
Re: Re: Why put type information into syntax? srineet@email.com (Srineet) (2000-04-01)
Re: Why put type information into syntax? tlh20@cam.ac.uk (Tim Harris) (2000-04-01)
Re: Why put type information into syntax? kst@cts.com (Keith Thompson) (2000-04-01)
Re: Re: Why put type information into syntax? kst@cts.com (Keith Thompson) (2000-04-03)
Re: Why put type information into syntax? michael.prqa@indigo.ie (Michael Spencer) (2000-04-05)
[6 later articles]
| List of all articles for this month |

From: lex@cc.gatech.edu
Newsgroups: comp.compilers
Date: 28 Mar 2000 01:03:46 -0500
Organization: Georgia Institute of Technology, Atlanta GA, USA
References: 00-03-133
Keywords: parse

"Allister Cross" <across@vega.co.uk> writes:


> Does anyone know of any reasons why built-in type names should be
> incorporated in the syntax of a language. I have been looking at the
> Java yacc grammar produced by Dmitri Bronnikov. This grammar contains
> a 'PrimitiveType' production containing the built-in types of
> 'BOOLEAN', 'CHAR' and so on. What is the advantage off treating
> built-in types differently from user-defined types?? Would it not be
> better to treat all types uniformly, by not putting primitive types in
> the grammar, and resolving such typing issues during semantic
> analysis.




Well, in Java, the "primitive" types really are different from regular
class or interface types. For example:


                1. There is probably some automatic coersion between primitive
                      types.


                2. Primitive types compile to different bytecodes.


                3. Primitive values are assigned and passed by value instead
                      of by reference.




Okay, that's enough to show that many kinds of analysis (whether by a
tool or by a human) are going to be interested in primitive types
vs. other kinds of types. Furthermore, it's easy to specify this in
the grammar, so why not?


Lex


Post a followup to this message

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