home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.ada
- Path: sparky!uunet!gatech!destroyer!cs.ubc.ca!uw-beaver!pattis
- From: pattis@cs.washington.edu (Richard Pattis)
- Subject: Re: Language pitfalls (was Re: FORTRAN bug)
- Message-ID: <1992Dec15.180821.17817@beaver.cs.washington.edu>
- Summary: Here is one in Ada
- Sender: news@beaver.cs.washington.edu (USENET News System)
- Organization: Computer Science & Engineering, U. of Washington, Seattle
- References: <1992Dec14.165537.18275@mks <1992Dec15.135539.7245@lth.se> <EMERY.92Dec15095542@dr_no.mitre.org>
- Date: Tue, 15 Dec 92 18:08:21 GMT
- Lines: 32
-
- Since Dave has volunteered to keep track....
-
- When I introduce recursion in my CS1/CS2 class, this one never fails to show
- up. It is truly a C-like error (excuse the pejorative term) in that the
- distinction between a statement and value is clouded to reduce the number of
- reserved words.
-
- Often the base case of a recursive function to manipulate a list looks like:
-
- IF mumble = NULL THEN
- RETURN NULL;
- ELSE ...
-
- What my students sometimes write is
-
- IF mumble = NULL THEN
- NULL;
- ELSE ...
-
- Here the statement NULL replaces the returning of a NULL value (which might be
- better to denote as NIL, at the expense of another reserved word). Of course,
- this is all syntactically legal and the error shows up only at execution time:
- often as a PROGRAM_ERROR (so at least Ada catches it at some time) if there
- are no other statements after the IF in the function. Of course, some compilers
- will give a warning based on the functions data flow information.
-
- Rich Pattis
- --
- ------------------------------------------------------------------------------
- Richard E. Pattis "Programming languages are like
- Department of Computer Science pizzas - they come in only "too"
- and Engineering sizes: too big and too small."
-