willett wrote:
In such cases our intuitions may differ. This is why we have standards.
Tony Heatherington's brief description of the Extended Pascal standard follows. Tony was on the EP committee, and he has implemented a very high-quality EP compiler. (from: http://www.prosperosoftware.com/EPIntro.html#7)
----------- Heatherington -------------------------------- There are also provisions for formal parameters which adjust themselves to the actual parameter at each call.
PROCEDURE p (VAR s: string)
The Extended Pascal Standard itself, unfortunately, is very hard to read in this regard because to understand parameter passing of "string" you have to understand a lot of terminology that exists elsehere in the document.
Unfortunately so, as always.
The section on value parameter passing is 6.7.3.2. I'll attach an image of the main part of that section (sorry my PDF is an image file; anyone who has a character-based PDF, please send me it!)
I'm not sure if everyone here likes getting a 200KB attachment for a few lines of text. :-( There are PS versions of the standards linked on our homepage under "Resources". I think Chuck Falconer once provided a text version.
It says that the formal parameter, when the procedure is activated, has the same TYPE as the actual parameter.
I can't see this. It says:
: If the parameterÂform of the valueÂparameterÂspecification contains a : schemaÂname that denotes the schema denoted by the required : schemaÂidentifier string, then each corresponding actualÂparameter contained : by the activationÂpoint of an activation shall possess a type having an : underlyingÂtype that is a stringÂtype or the charÂtype; it shall be an error : if the values of these underlyingÂtypes, associated with the values denoted : by the actualÂparameters, do not all have the same length. Within the : activation, each corresponding formalÂparameter shall possess the type : produced from the schema string with the tuple having that length as its : component.
I.e., its type is a string with a component [i.e., capacity] which is the length of the actual parameter.
Upshot: Maurice's intuition appears to match the Extended Pascal Standard (at least for variables), and is the same as Tony Heatherington's reading of the Standard.
This quote applies to var (reference) parameters, not to value parameters. Whether the actual parameter is a constant of variable doesn't matter.
Frank