gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gm2] ISO M2 CAST faulty behaviour and more about opaque types


From: Iztok
Subject: [Gm2] ISO M2 CAST faulty behaviour and more about opaque types
Date: Thu, 09 Oct 2003 15:04:54 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1

Gaius !

TYPE Foo = RECORD .... END;
         pFoo = POINTER TO Foo;

VAR a : SYSTEM.ADDRESS;
        pfoo : pFoo;

BEGIN
pfoo := SYSTEM.CAST(pFoo, a); (* fails with "arguments to CAST must be (Type, Variable or Constant)" *)
END


One more thing:

We have been discussing about opaque types recently and I have noticed the questionable implementation of the opaue types. Namely, you have said that you equaled them to SYSTEM.ADDRESS. I am concerned about the correct type checking now. Consider situation:

DEFINITION 1

TYPE Opaque1;

IMPLEMENTATION 1

TYPE OpaqueImpl1 = RECORD ..... END;
TYPE Opaque1 = POINTER TO OpaqueImpl1;

PROCEDURE p1 (arg1 : Opaque1);

DEFINITION 2

TYPE Opaque2;

IMPLEMENTATION 2

TYPE OpaqueImpl2 = RECORD ..... END;
TYPE Opaque2 = POINTER TO OpaqueImpl2;

PROCEDURE p2 (arg2 : Opaque2);


MODULE 3

VAR foo1 : 1.Opaque1;
        foo2 : 2.Opaque.2;


You allow: foo1 := foo2 which could be correct considering their primary behaviour - being references. Considering their referenced type it should issue at least warning because you could by this logic do also :

2.p2( foo1 )

which is dangerous.

I think that the variable of typed pointer could be mutually assignable with another of SYSTEM.ADDRESS but not with another of different typed pointer, except using SYSTEM.CAST which transfers the reponsibility for functional disasters from compiler to developer in charge.

It also means that opaque types can not be equalized to SYSTEM.ADDRESS but considered as typed pointers of different kinds


It is not fatal but needs consideration.

Anybody else with an opinion ?

Regards !

Iztok Kobal

(do not reply since the reply address is fake)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]