From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,b87849933931bc93 X-Google-Attributes: gid109fba,public X-Google-Thread: fac41,b87849933931bc93 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,b87849933931bc93 X-Google-Attributes: gid103376,public X-Google-Thread: 114809,b87849933931bc93 X-Google-Attributes: gid114809,public X-Google-Thread: 1108a1,b87849933931bc93 X-Google-Attributes: gid1108a1,public X-Google-Thread: 1111a3,5ee869da42505971 X-Google-Attributes: gid1111a3,public From: nurban@csugrad.cs.vt.edu (Nathan M. Urban) Subject: Re: Combining dynamic and static typing Date: 1997/01/25 Message-ID: <5celpp$n3r@csugrad.cs.vt.edu>#1/1 X-Deja-AN: 212259221 references: <32E6797A.6E21@parcplace.com> <5c8u2j$jvo@castor.cca.rockwell.com> <01bc0b21$6a8293e0$7df2ad80@wkst01.milagro.austin.tx.us> organization: Virginia Polytechnic Institute and State University reply-to: nurban@vt.edu newsgroups: comp.lang.eiffel,comp.lang.ada,comp.lang.c++,comp.lang.smalltalk,comp.lang.objective-c,comp.object Date: 1997-01-25T00:00:00+00:00 List-Id: In article <01bc0b21$6a8293e0$7df2ad80@wkst01.milagro.austin.tx.us>, =?ISO-8859-1?Q?=22Jes=FAs_Eugenio_S=E1nchez=22_=3Cjesp@milagro.austin.?= =?ISO-8859-1?Q?tx.xx=3E?= wrote: > Erik M. Buck wrote in article = > <5c8u2j$jvo@castor.cca.rockwell.com>... > > In Don Harrison wrote: > > > What I'm wondering is whether it would be useful to have a development > > > environment in which you had the option of using either. > > Objective-C enables either! > Where can we find a specific example? Or where is it documented? For examples, look at NeXT's OpenStep libraries, among other things. Objective-C will let you statically type objects in your code. For example, instead of creating a string with id str = [NSString alloc]; you can do NSString* str = [NSString alloc]; Then, if you have a line of code to send a message like [str notAStringMessage]; where "notAStringMessage" is a method which the NSString class does not respond to, there will be a compile-time error. HOWEVER, it is actually the case that the object is still dynamic, since messages still go through the runtime system. For example, you could read in the name of a method, turn that into a selector, and send a message with that name to 'str', even if NSString doesn't respond to that message. That would generate a runtime exception, unless you had 'str's "forward:" method handle it. Which you might want to be able to do, and which C++ would not let you do. Thus, Objective-C gives you all the safety of C++'s static type checking, while retaining all the advantages of a dynamic language. -- Nathan Urban | nurban@vt.edu | Undergrad {CS,Physics,Math} | Virginia Tech