Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site opus.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!vax135!cornell!uw-beaver!tektronix!hplabs!hao!cires!nbires!opus!rcd From: rcd@opus.UUCP (Dick Dunn) Newsgroups: net.lang.pascal Subject: Re: X3J11 (PASCAL) parameters Message-ID: <765@opus.UUCP> Date: Fri, 7-Sep-84 02:34:55 EDT Article-I.D.: opus.765 Posted: Fri Sep 7 02:34:55 1984 Date-Received: Mon, 3-Sep-84 08:57:34 EDT References: <2356@dartvax.UUCP> Organization: NBI, Boulder Lines: 32 > Another feature that I try to avoid is assigning to value parame- > ters. It's often a good idea to leave the original (actual > parameter) value lying around, and make a local copy if you're > going to use it as a local variable. I guess that I wish that > assignment to value parameters were an error. I've been nailed a > few times by forgetting the "var" in a procedure header. It may be of interest that Pascal originally had "const" and "var" parameters. "Var" parameters worked as they do today. "Const" parameters behaved as if they'd been defined by a "const" declaration. The change to the current form happened in the "Revised Report" (which was fairly early on compared to the real evolution and popularization of the language). One could speculate on the reason for the change--my guess is that it is beneficial in the case where the value passed in requires some effort to copy. If the procedure needs scratch storage of the same type (size) as the value passed in, and if that storage had to be allocated anyway to hold the value, why not make the storage available? Moreover, there's a philosophical point here: I don't think that there's anything inherently "bad" in using value parameter storage--just think of it as an initialized local variable. If the language provides a mechanism, and it's a useful mechanism, and it's not "inherently evil" (big judgment call there), why not use it? I've been nailed once in a great while by forgetting the "var". I wonder if that isn't really more a problem with having a default? That is, suppose that the language had been designed so that you HAD to say either "value" or "var" - then you'd be forced to think which you wanted and wouldn't get caught by unexpected defaulting. -- Dick Dunn {hao,ucbvax,allegra}!nbires!rcd (303)444-5710 x3086 ...I'm not cynical - just experienced.