Related articles |
---|
[33 earlier articles] |
Re: Pointers to "why C behaves like that ?" joachim_d@gmx.de (Joachim Durchholz) (2002-11-24) |
Re: Pointers to "why C behaves like that ?" joachim_d@gmx.de (Joachim Durchholz) (2002-11-24) |
Re: Pointers to "why C behaves like that ?" jacob@jacob.remcomp.fr (jacob navia) (2002-11-26) |
Re: Pointers to "why C behaves like that ?" jacob@jacob.remcomp.fr (jacob navia) (2002-11-26) |
Re: Pointers to "why C behaves like that ?" jacob@jacob.remcomp.fr (jacob navia) (2002-11-26) |
Re: Pointers to "why C behaves like that ?" david.thompson1@worldnet.att.net (David Thompson) (2002-11-26) |
Re: Pointers to "why C behaves like that ?" ajo@andrew.cmu.edu (Arthur J. O'Dwyer) (2002-11-26) |
Re: Pointers to "why C behaves like that ?" thp@cs.ucr.edu (2002-11-26) |
Re: Pointers to "why C behaves like that ?" thp@cs.ucr.edu (2002-11-26) |
Re: Pointers to "why C behaves like that ?" Nicola.Musatti@ObjectWay.it (Nicola Musatti) (2002-11-26) |
Re: Pointers to "why C behaves like that ?" nmm1@cus.cam.ac.uk (Nick Maclaren) (2002-11-26) |
Re: Pointers to "why C behaves like that ?" peter_flass@yahoo.com (Peter Flass) (2002-11-26) |
Re: Pointers to "why C behaves like that ?" fjh@students.cs.mu.OZ.AU (Fergus Henderson) (2002-11-26) |
[27 later articles] |
From: | "Arthur J. O'Dwyer" <ajo@andrew.cmu.edu> |
Newsgroups: | comp.compilers |
Date: | 26 Nov 2002 21:50:38 -0500 |
Organization: | Carnegie Mellon, Pittsburgh, PA |
Keywords: | C, types, design |
Posted-Date: | 26 Nov 2002 21:50:38 EST |
On 24 Nov 2002 thp@cs.ucr.edu wrote:
>
> There is still the argument that a typo might create a new variable
> instead of a syntax error, e.g.:
>
[examples snipped]
>
> the typo will produce an unused-variable warning.
Yes. In fact, I've bootstrapped my own simple language (C-like,
untyped, 16-bit, medium-level) which contains no keywords for data
types at all, and thus no declaration syntax. To guard against typos,
I say that if we see
hellowrold;
that is a "declaration", not an error; and if we see
hellowrold = 42;
that is an "initialization", not an error; but if we see
printf(hellowrold);
or
helloworld = hellowrold;
they are most likely errors and cause compile-time warnings when a
certain DEBUG flag is set (which it is, by default).
> To insure against such repeated typos, the language can require a
> keyword to accompany the introduction of a new variable, e.g.:
>
> let profit = income - expenditures;
>
> In such a case the first typo above would produce a syntax error.
In fact, instead of "let", why don't we use "var" to indicate a new
VARiable, or "my", to indicate that the variable is MY program's?
For example,
my $programs
use perl;
We could even go further to insure against more insidious logic errors
by specializing; say,
let int profit = income - expenditures;
let float cost = labor - price;
Then we could even lose the "let", and just use "int" and "float" to
represent the "let" keyword!
Hmm... sounds familiar, don't it?
:-)
-Arthur
Return to the
comp.compilers page.
Search the
comp.compilers archives again.