newbie question: type checking (guilaume bour)
8 Nov 2001 01:19:07 -0500

          From comp.compilers

Related articles
newbie question: type checking (2001-11-08)
Re: newbie question: type checking (Matthias Blume) (2001-11-08)
Re: newbie question: type checking (Christian Bau) (2001-11-08)
| List of all articles for this month |

From: (guilaume bour)
Newsgroups: comp.compilers
Date: 8 Nov 2001 01:19:07 -0500
Keywords: types, question
Posted-Date: 08 Nov 2001 01:19:07 EST

Hello. I have to invent a language and write its compiler(which must
generate c-shell) for a school project.

My idea is to made a language with no type declaration, and where a
could take different types during its "life".
But I want also to make a compiler with strong type checking
(the type of all variables must be known after compilation).

here is an exemple:
    a := 5
    b := a + 3

    b := "hello"

We can determine b type by using the context:
* line 2: b is an integer
                    (it result from the addition of a(an integer) and 3(an
integer too))
* line 4: b becomes a string

In the next example, we can't determine the type of the variable 'res'
after the instruction 'if' (it can be a string as well as a float):

    if(div = 0)
        res := "division by 0"
        res := 4/div

So I would like to know if there is a way to avoid(even suppress) such

Guillaume Bour.

Post a followup to this message

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