Re: [BLACKBOX] Matrix slices - syntax

From: [at]} <Robert>
Date: Thu, 1 Apr 2010 18:53:33 +0100

----boundary-LibPST-iamunique-1708016268_-_-
Content-type: text/plain

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
>> <danforth{([at]})nowhere.xy
>>
>>> Folks,
>>>
>>> I don't understand this.
>>> If I define a procedure that takes an ARRAY OF REAL and
>>> pass it an row of a matrix then that works BUT if I specialize
>>> the procedure to take an ARRAY 3 OF REAL and pass it a
>>> row of a matrix ARRAY 3,3 OF REAL then the compiler complains.
>>>
>>> TYPE
>>> VDesc = ARRAY OF REAL;
>>> V3Desc = ARRAY 3 OF REAL;
>>> MDesc = ARRAY OF ARRAY OF REAL;
>>> M3Desc = ARRAY 3,3 OF REAL;
>>>
>>> PROCEDURE Q (IN v: VDesc); BEGIN END Q;
>>> PROCEDURE Q3 (IN v: V3Desc); BEGIN END Q3;
>>>
>>> PROCEDURE Test;
>>> VAR m3: M3Desc;
>>> BEGIN
>>> Q(m3[0]); (* works *)
>>> Q3(m3[0]) (* fails! incompatible assignment *)
>>> END Test;
>>>
>>> The "slice" m3[0], which is the first row of m3, is accepted by a routine
>>> that accepts general non specific vectors but that same slice which
>>> has length 3 is rejected by a routine that wants vectors of length 3.
>>> Why?
>>> I really don't understand the strong typing in this case.
>>>
>>> -Doug Danforth
>>>
>>>
>>> ---- To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to
>>> LISTSERV{([at]})nowhere.xy
>>>
>>
>>
>>
>>
>
> ---- To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to
> LISTSERV{([at]})nowhere.xy
>
>
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 9.0.800 / Virus Database: 271.1.1/2783 - Release Date: 04/01/10 07:35:00
>


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-1708016268_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFx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