From: glen mccready
To: Dead Beef <0xdeadbeef@substance.abuse.blackdown.org> Date: Thu, 13 Jul 1995 23:15:12 -0400
---------- Forwarded message ---------- Date: Thu, 13 Jul 1995 20:05:02 -0400 From: Keith Bostic <bostic@CS.Berkeley.EDU> To: /dev/null@python.bostic.com Subject: ... at least I think they do. Forwarded-by: guy@netapp.com (Guy Harris) From: rodney@bcsaic.boeing.com (Rodney M. Bates) Subject: Re: Comparison of languages for CS1 and CS2 Organization: Boeing Computer Services Date: Mon, 10 Jul 1995 14:18:55 GMT 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