comp.lang.ada
 help / color / mirror / Atom feed
From: pattis@cs.washington.edu (Richard Pattis)
Subject: NULL statements, NULL values, and teaching
Date: 14 Dec 89 20:09:57 GMT	[thread overview]
Message-ID: <10188@june.cs.washington.edu> (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

                 reply	other threads:[~1989-12-14 20:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
replies disabled

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