comp.lang.ada
 help / color / mirror / Atom feed
* NULL statements, NULL values, and teaching
@ 1989-12-14 20:09 Richard Pattis
  0 siblings, 0 replies; only message in thread
From: Richard Pattis @ 1989-12-14 20:09 UTC (permalink / raw)


Is there a good reason why the reserved word NULL is both a legal statement
and value (apart from the reason that Ada saves one reserved word by using
this one for double duty)?

From a teacher's persepective, after going out of my way to differentiate
expressions from statements (students often try to write function calls as
statements, assuming Ada implicitly does the right thing with the returned
value), I choke a bit when having to explain NULL the expression
interpretation of NULL.

A common NULL mistake that I see (which is difficult to debug) is students
writing functions (often recursive) that return access objects.  They write

.....

IF ...			-- base case
  THEN NULL;		-- the answer is NULL
  ELSE
    .....
    RETURN ....
END IF;
.....

Of course, they have omitted RETURN in the THEN clause, but the result is
still a statically legal Ada function.  By using NULL and NIL (for example)
this problem could be recognized as an error by the compiler.  Are there
other compelling reasons for using NULL to mean both?

Rich Pattis

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1989-12-14 20:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1989-12-14 20:09 NULL statements, NULL values, and teaching Richard Pattis

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