Waldek Hebisch wrote:
I then get:
actual schema discriminants do not match
in this line:
valueparam(fval,ls2);
Though the text of the message is somewhat misleading, the error (according to strict EP rules) is correct (i.e., the test is not EP compliant), as Length (fval) = 14 and Length (ls2) = 7:
: 6.7.3.2 Value parameters : : 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.
I think that GPC is wrong here. Namely, we have:
TYPE ... s20 = string(20);
so s20 does _not_ denote the `string' schema, it is merely a type produced from that schema with a tuple.
6.7.3.2 applies only for declarations of form:
PROCEDURE valueparam(fst1, fst2: string);
That is clear if you think about intended implementation: for discriminated schema you pass just the data. For undiscriminated schema you pass the data and a descriptor. If multiple parameters have the same type you can pass a single (common) descriptor. IMHO possibility of such optimization is the only justification for 6.7.3.2. Of course, our implementation is quite different...
Oh yes, I had misread this case (that's why GPC's error message appeared strange to me, should have looked closer ...)
This patch fixes this bug, and also a similar one with string var-parameters, if I understand this case right now (the statement `p (w^)' in fjf1098b.pas is correct, isn't it?).
{$extended-pascal}
program fjf1098a (Output);
type s = String (20);
procedure p (a, b: s); begin WriteLn (a, b) end;
begin p ('OK', '') end.
{$extended-pascal}
program fjf1098b (Output);
type s = String (20);
procedure p (var a: s); begin Write (a) end;
var v: ^s; w: ^String;
begin New (v); v^ := 'O'; p (v^); New (w, 20); w^ := 'K'; p (w^); WriteLn end.
Frank