comp.lang.ada
 help / color / mirror / Atom feed
From: pattis@beaver.cs.washington.edu  (Richard Pattis)
Subject: Re: Language pitfalls (was Re: FORTRAN bug)
Date: 15 Dec 92 18:08:21 GMT	[thread overview]
Message-ID: <1992Dec15.180821.17817@beaver.cs.washington.edu> (raw)

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."

             reply	other threads:[~1992-12-15 18:08 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-12-15 18:08 Richard Pattis [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-12-17 18:48 Language pitfalls (was Re: FORTRAN bug) John Halper
1992-12-17 14:18 Terry J. Westley
1992-12-17  1:31 Robert I. Eachus
1992-12-16 20:59 John Bollenbacher
1992-12-16 20:02 Julian C . Lander
1992-12-16 17:38 Bob Kitzberger
1992-12-16 17:27 Mark A Biggar
1992-12-16 16:32 olivea!spool.mu.edu!yale.edu!qt.cs.utexas.edu!cs.utexas.edu!asuvax!ennews
1992-12-16 14:38 crispen
1992-12-16  1:22 Robert I. Eachus
1992-12-15 20:35 news.centerline.com!noc.near.net!inmet!spock!stt
1992-12-15 15:47 Michael Feldman
1992-12-15 14:55 David Emery
1992-12-15 13:55 enterpoop.mit.edu!eru.mt.luth.se!lunic!sunic!news.lth.se!dag
1992-12-14 21:57 Bob Kitzberger
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox