Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!decwrl!csus.edu!ucdavis!csusac!usenet From: brian@babbage.csus.edu (Brian Witt) Newsgroups: comp.sys.amiga.programmer Subject: Re: REVIEW: Comeau C++ compiler Summary: objC translation Keywords: programming, language, C++, compiler, objective-C Message-ID: <1991Apr23.163448.26011@csusac.csus.edu> Date: 23 Apr 91 16:34:48 GMT References: <36963@ditka.Chicago.COM> <1991Apr17.174759.16250@jato.jpl.nasa.gov> <20862@cbmvax.commodore.com> Sender: usenet@csusac.csus.edu (News account (alt)) Organization: California State University, Sacramento Lines: 52 In article <20862@cbmvax.commodore.com> daveh@cbmvax.commodore.com (Dave Haynie) writes: >In article <1991Apr17.174759.16250@jato.jpl.nasa.gov> jdickson@jato.Jpl.Nasa.Gov (Jeff Dickson) writes: > >> Since this C++ compiler rewrites your C++ into plain'ol C, does it >>do a good job? Say compared to if a human performed the translation manually. > >When a C++ compiler translates C++ code into C, it is doing much the same thing >that a C compiler does when it translates C into object code. There are a few oddities of coercien that go on, behind the scenes. For the objective-C (TM) like translator I built, for each message invokation, the "outter most" addition the translator does it put a typecast on the function call. Using a lead in Dr. Cox's book, I typecast the function _msg() to a function that returns the required type. This is NOT typecasting the return value (which can cause a conversion to take place, ie int --> float). Function _msg() by default returns a pointer type. with this define: extern void *_msg( void *, SEL, ... ); For instance, the line: char *name = [bytestring name]; turns into: char *name = (*((char * (*)()) _msg))( bytestring ,(/* name */_ocSAnoname[9])) ) ); (_ocSAnoname[] holds method selectors. it's long, but it works! ) > Given the extra complexities of >the C++ language, even if you wanted to do a hand translation, and felt you >could do better, it would take forever, and your head would eventually explode. In my OCT system, I've found that a line length doubles when converted from objective-C (TM) into plain old "C". Since OCT using dynamic binding throughout, you have to jump to a helper function. With static binding (like that in C++), your milage may vary... >-- >Dave Haynie Commodore-Amiga (Amiga 3000) "The Crew That Never Rests" > {uunet|pyramid|rutgers}!cbmvax!daveh PLINK: hazy BIX: hazy objective-C is a trademark of Stepstone, Inc. ---------------------------------------------------------------- brian witt | brian@babbage.ecs.csus.edu You are what you click | (and if you click it twice...) Not representing Cal State Sacramento, the ECS dept, or Iraq ---------------------------------------------------------------- -- ---------------------------------------------------------------- brian witt | brian@babbage.ecs.csus.edu You are what you click | (and if you click it twice...) Not representing Cal State Sacramento, the ECS dept, or Iraq