Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: AGC was: Re: inner classes not possible,(in objc) right?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AGC was: Re: inner classes not possible,(in objc) right?




On 4 Apr 2005, at 16:40, Dietmar Planitzer wrote:


Tracking the type is crucial for allocating the proper registers / values and running the proper operators.


This tracks the types you declared, not the types of the values actually used.



The artificial distinction you are making here between the declared and "actual" type doesn't make any sense as long as we talk about C based languages.

The distinction is not at all artificial.

C and its descendants are statically typed languages. They don't have the concept of a dynamic type.

While statically typed, they are not strongly typed but weakly typed (due to casts). You absolutely *can* have a value that does not agree with its static type, though you have no way of determining this type mismatch other than that the value will not work for you.


For example:

float a=3.14159;
float *b=&a;
int **c=(int**)b;
int d = **c;

This will probably segfault on you quite badly, because you are using the in-memory bit pattern of the float 3.14159 as a pointer.

Another example closer to home:

typedef struct {
    Class isa;
    int a;
} _MyObject;

typedef struct {
    Class isa;
    float a;
} _AnotherObject;

_MyObject a = { objc_getClass( "MyObject" ), 1 };
_AnotherObject b = {  objc_getClass( "AnotherObject" ), 2.0 };

_MyObject *c = &a;
_AnotherObject *d = &b;
d = (_AnotherObject)c;

Are you going to argue that this is NOT a case where the dynamic type of the "object" disagrees with the static type?

[snip]

Marcel



--
Marcel Weiher                Metaobject Software Technologies
email@hidden        www.metaobject.com
Metaprogramming for the Graphic Arts.   HOM, IDEAs, MetaAd etc.
        1d480c25f397c4786386135f8e8938e4


_______________________________________________ Do not post admin requests to the list. They will be ignored. Objc-language mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re: AGC was: Re: inner classes not possible,(in objc) right? (From: Dietmar Planitzer <email@hidden>)
 >Re: AGC was: Re: inner classes not possible,(in objc) right? (From: Marcel Weiher <email@hidden>)
 >Re: AGC was: Re: inner classes not possible,(in objc) right? (From: Dietmar Planitzer <email@hidden>)
 >Re: AGC was: Re: inner classes not possible,(in objc) right? (From: Marcel Weiher <email@hidden>)
 >Re: AGC was: Re: inner classes not possible,(in objc) right? (From: Dietmar Planitzer <email@hidden>)
 >Re: AGC was: Re: inner classes not possible,(in objc) right? (From: Prachi Gauriar <email@hidden>)
 >Re: AGC was: Re: inner classes not possible,(in objc) right? (From: Helge Hess <email@hidden>)
 >Re: AGC was: Re: inner classes not possible,(in objc) right? (From: Marcel Weiher <email@hidden>)
 >Re: AGC was: Re: inner classes not possible,(in objc) right? (From: Dietmar Planitzer <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.