Newsgroups: comp.edu,comp.lang.ada,comp.lang.c++,comp.lang.modula2,comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!nntp.sei.cmu.edu!news.psc.edu!hudson.lm.com!godot.cc.duq.edu!news.duke.edu!zombie.ncsc.mil!news.mathworks.com!uunet!in1.uu.net!bcstec!bcsaic!rodney
From: rodney@bcsaic.boeing.com (Rodney M. Bates)
Subject: Re: Comparison of languages for CS1 and CS2
Message-ID: <DBI7rJ.F46@bcsaic.boeing.com>
Sender: bates@salsv6.boeing.com(Rodney Bates)
Organization: Boeing Computer Services
References: <3srsn5$q8d@galaxy.ucr.edu> <3tid5q$13a@bach.seattleu.edu> <3tje1h$t31@duke.cs.duke.edu> <3tkt5u$3vk@felix.seas.gwu.edu>
Date: Mon, 10 Jul 1995 14:18:55 GMT
Lines: 44
Xref: glinda.oz.cs.cmu.edu comp.edu:13145 comp.lang.ada:32353 comp.lang.c++:137573 comp.lang.modula2:11947 comp.lang.scheme:13065

Mike Feldman wrote (concerning Ada):

> Here is the punch line, though - because an IN parameter _cannot_
> be modified within the subprogram (this can be easily checked by the
> compiler), the passing mechanism need be of NO concern to the
> casual or student programmer. IN means IN, OUT means OUT, and both
> are independent of "value" vs. "reference" jargon. This separation of
> concerns in parameter passing is one of the "little" things I really
> like in Ada. It's elegant.:-)

Well, after you get a little deeper, it gets, IMHO, not so elegant. :-(

For records and arrays, the compiler is free to use either a copy
or reference mechanism.  If the subprogram assigns to a nonlocal
variable which happens to be the same as the actual parameter,
the results depend on what mechanism the compiler chose.  In the case
of an OUT parameter, all it has to do is reference the nonlocal
variable.  Furthermore, this can all happen deep inside a further
call chain, in supposedly independent subprograms, where it is
not obvious.

Ada addresses this by defining a program which does this to be
"erroneous".  This is further defined to mean:

1. The programmer screwed up, and

2. The compiler is under no obligation the detect this.
   (It's no doubt undecidable anyway.)

In my experience, this is a bit too subtle even for the average
industrial programmer.

In my experience with CS1/CS2 students, although it will not be the
norm, it is inevitable that eventually some CS2 student will do
this by accident.  

Of course, in both situations, nobody will notice until someone attempts
to port to a different compiler.  We should all sleep better knowing
that embedded systems in airplanes and missiles always stick with a
single compiler, at least I think they do.

Rodney Bates
bates@salsv6.boeing.com

