----boundary-LibPST-iamunique-1985967187_-_-
Content-type: text/plain
Ok, I can answer my own question.
When dealing with complex data structures it is
unreasonable to expect the compiler to judge
whether two structures are identical hence
if two types T1 and T2 actually have the same
structure then the compiler doesn't know
(can't tell). It is left up to the user to give then
the same name.
Also if T1 is an extension of T then it is reasonable
to accept T1 as the argument to a procedure that
accepts T.
Ok, back to work...
-Doug
Douglas G. Danforth wrote:
Thanks Robert.
I also wonder why VectorA does not match VectorB.
I can understand it is easier for a compiler to just check
the identifier rather than the semantics underlying it BUT
the internal representations are identical.
So if John calls it a pig and Tom calls it a swine then
"it" is not the same in the two cases?
-Doug
Robert wrote:
Maybe it would (*look*) more likeable if you wrote
TYPE
Vector3 = ARRAY 3 OF REAL;
Matrix3 = ARRAY 3 OF Vector;
If you look at the language reference you require
formal parameters to 'match', which in this case requires them to be
'equal' types, which in this case requires them to be the 'same' type,
which in this case requires them to be the same identifier.
So
VectorA = ARRAY 3 OF REAL
does not 'match' with
VectorB = ARRAY 3 OF REAL.
I am guessing there is a good reason for this?
In your case you were passing an anonomous type which is not the 'same' as another type.
Regards
Robert
On 01/04/2010 07:22, Douglas G. Danforth wrote:
Thanks Aubrey.
Not sure I like it but thanks.
I have adopted the strategy that all procedures
that accept vectors or matrices specify their
arguments for general forms (i.e.
VDesc and MDesc) even when they only want
a restricted subset. I let the module context
enforce the preconditions.
-Doug
Aubrey McIntosh wrote:
Try this:
MODULE PrivTest2;
TYPE
VDesc = ARRAY OF REAL;
V3Desc = ARRAY 3 OF REAL;
MDesc = ARRAY OF ARRAY OF REAL;
M3Desc = ARRAY 3,3 OF REAL;
MTubeDesc = ARRAY 3 OF V3Desc;
PROCEDURE Q (IN v: VDesc); BEGIN END Q;
PROCEDURE Q3 (IN v: V3Desc); BEGIN END Q3;
PROCEDURE Test;
VAR
mt : MTubeDesc;
BEGIN
Q(mt[0]); (* works *)
Q3 (mt[0]) (*also works*)
END Test;
END PrivTest2.
On Wed, Mar 31, 2010 at 9:23 PM, Douglas G. Danforth
Received on Thu Apr 01 2010 - 22:27:39 UTC