Re: New Cocoa Programmer
Re: New Cocoa Programmer
- Subject: Re: New Cocoa Programmer
- From: Ondra Cada <email@hidden>
- Date: Mon, 12 Nov 2001 10:52:50 +0100
Marcel,
>
>>>>> Marcel Weiher (MW) wrote at Mon, 12 Nov 2001 09:26:09 +0100:
MW> Actually, this could be compiled back when class-names by themselves
MW> could be used
MW>
MW> switch ( [myObject class] ) {
MW> case NSString:
MW> break;
MW> }
I'm not that sure: so far as I remember, Brad Cox always made point of that
a class name is always interpreted as a _type_ with the sole exception of
being a receiver of a message.
MW> I don't quite remember when class-names stopped being legal values, but
MW> I think the change was between NextStep and OpenStep.
At the very least, not in my NS3.3:
20 /Net/g4/tmp> cat q.m
#import <objc/Object.h>
void main() {
switch ([Object class]) {
case (int)Object: break; // would fail
}
}
21 /Net/g4/tmp> cc -Wall q.m
q.m: In function `main':
q.m:4: switch quantity not an integer
q.m:5: parse error before `Object'
22 /Net/g4/tmp>
From pure curiosity I've tried it with a "normal" type, and truly the error
reported is the same one:
27 /Net/g4/tmp> cat q.m
#import <objc/Object.h>
typedef int What;
void main() {
switch ([Object class]) {
case (int)What: break; // would fail
}
}
28 /Net/g4/tmp> cc -Wall q.m
q.m: In function `main':
q.m:6: switch quantity not an integer
q.m:7: parse error before `What'
29 /Net/g4/tmp>
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
2K Development: email@hidden
http://www.2kdevelopment.cz
private email@hidden
http://www.ocs.cz/oc