preparing for const, final, and invariant

Walter Bright newshound1 at digitalmars.com
Fri May 18 14:15:40 PDT 2007


Manfred Nowak wrote:
> Walter Bright wrote
> 
>> Passing things through void* is a way of escaping the type
>> checking, and if you break the rules by doing so, your program
>> might break. 
> 
> The compiler seems to follow the specs which say
> 
> | A pointer T* can be implicitly converted to one of the following:
> |
> |    void*
> 
> There is no hint in the specs that this even _implicite_ possible 
> conversion is breaking the security of the type system.
> 
> But let me assume for now, that this implicite conversion is an 
> exception and that "breaks type system" will be included in the 
> specs.
> 
> Now how about using a circular list, i.e avoiding use of `void *'
> 
> struct T{
>   T* next;
> }
> T a;
> void main(){
>   T g;
>   g.next= &g;
>   void f( in T p){
>     a= *(p.next); // @*_
>   }
>   f( g); // breaking of scope rule?
> }

Yes, you're breaking it.



More information about the Digitalmars-d-announce mailing list