Re: Pointers to "why C behaves like that ?"

thp@cs.ucr.edu
24 Nov 2002 01:19:48 -0500

          From comp.compilers

Related articles
[15 earlier articles]
Re: Pointers to "why C behaves like that ?" peter_flass@yahoo.com (Peter Flass) (2002-11-20)
Re: Pointers to "why C behaves like that ?" er+cc@cs.brown.edu (Manos Renieris) (2002-11-20)
Re: Pointers to "why C behaves like that ?" md9slj@mdstud.chalmers.se (Stefan Ljungstrand) (2002-11-20)
Re: Pointers to "why C behaves like that ?" torbenm@diku.dk (Torben Ægidius Mogensen) (2002-11-24)
Re: Pointers to "why C behaves like that ?" torbenm@diku.dk (Torben Ægidius Mogensen) (2002-11-24)
Re: Pointers to "why C behaves like that ?" nmm1@cus.cam.ac.uk (Nick Maclaren) (2002-11-24)
Re: Pointers to "why C behaves like that ?" thp@cs.ucr.edu (2002-11-24)
Re: Pointers to "why C behaves like that ?" jacob@jacob.remcomp.fr (jacob navia) (2002-11-24)
Re: Pointers to "why C behaves like that ?" nicola.musatti@objectway.it (Nicola Musatti) (2002-11-24)
Re: Pointers to "why C behaves like that ?" fjh@cs.mu.OZ.AU (Fergus Henderson) (2002-11-24)
Re: Pointers to "why C behaves like that ?" anw@merlot.uucp (Dr A. N. Walker) (2002-11-24)
Re: Pointers to "why C behaves like that ?" whopkins@alpha2.csd.uwm.edu (Mark) (2002-11-24)
Re: Pointers to "why C behaves like that ?" whopkins@alpha2.csd.uwm.edu (Mark) (2002-11-24)
[45 later articles]
| List of all articles for this month |
From: thp@cs.ucr.edu
Newsgroups: comp.compilers
Date: 24 Nov 2002 01:19:48 -0500
Organization: University of California, Riverside
References: 02-11-059 02-11-087 02-11-089 02-11-111
Keywords: types, design
Posted-Date: 24 Nov 2002 01:19:48 EST

Peter Flass <peter_flass@yahoo.com> wrote:
+ Christian Bau wrote:
+> > A typo in the spelling of the variable "CurrentAmunt" in line 2
+> > creates a new variable "CurrentAmunt" that receives the result of the
+> > addition. Since the CurrentAmount variable is stored, the account
+> > receives a wrong value, and there is NO WAY to spot this bug until
+> > runtime!
+
+ Not true. To use a PL/I example again the compiler would simply have
+ to somehow flag usage of an undeclared variable and the programmer
+ could easily spot the typo. Of course this assumes you declare all
+ your variables even when you don't have to...
+ [I don't see a useful difference between a system that requires that you
+ declare everything, vs. one that doesn't but producesundeclared variable
+ warnings that the programmer treats like error messages. -John]


Some of my students are Pythonistas. They insist that the lack of
such assistance from the compiler in detecting typos has never been an
issue. (I wouldn't know.)


In the case at hand, the typo would (in most cases) yield an
unused-variable warning, even if the undeclared variable were accepted
by the language.


IIRC, some implicitly typed languages use the keyword "let" to
introduce a new variable. In which case, the absence of "let" just
before the typo would yield an error.


Tom Payne


Post a followup to this message

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