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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,b87849933931bc93 X-Google-Attributes: gidfac41,public X-Google-Thread: 109fba,b87849933931bc93 X-Google-Attributes: gid109fba,public X-Google-Thread: 1108a1,b87849933931bc93 X-Google-Attributes: gid1108a1,public X-Google-Thread: 103376,b87849933931bc93 X-Google-Attributes: gid103376,public X-Google-Thread: 114809,b87849933931bc93 X-Google-Attributes: gid114809,public From: jhd@herold.franken.de (Joachim Durchholz) Subject: Re: OO, C++, and something much better! Date: 1997/01/29 Message-ID: <6PnYDRs-3RB@herold.franken.de>#1/1 X-Deja-AN: 213015725 references: <32ED02EE.22E2@netright.com> newsgroups: comp.lang.eiffel,comp.lang.ada,comp.lang.c++,comp.lang.smalltalk,comp.object Date: 1997-01-29T00:00:00+00:00 List-Id: James wrote: > Depends - are we including C and C++ here ? In either language, I have > static type checking, but I can use casting to defeat that type checking - > thus, I get NONE of the benefits of static typing, and also none of the > benefits of dynamic checks (as is done in Smalltalk). Well, this goes overboard. I do get advantages from static typing in C/ C++. There's even evidence for this - one of the worst sources of errors in C was that routine parameters were basically untyped. The first reaction was the introduction of lint (a tool that was designed to do those checks that the C compiler didn't do), the second was requiring types for parameters (with some compatibility kludges, but nobody uses old-style routines anymore). These are very C-specific problems though. In C, undeclared parameters were cast to the (rather machine-dependent) "int" type, often with heavy loss in information and behaviour if the programmer passed something different in. The situation is somewhat different in Smalltalk - if an object is passed to a point it wasn't expected to go to, it still keeps all information and behaviour. Given the completeness of the Smalltalk libraries, chances are that the object will still respond in a useful way to anything that is thrown at it. On a more general level, I really would like to have some benefits of static typing in Smalltalk. Static typing provides much information for optimizers. Static typing allows me to make sure my library will not crash if some idiot passes nonsense to them. ("Idiot" in the sense that I do idiotic things myself, sometimes.) Static typing allows me to explicitly specify contracts between caller and routine (this is a very Eiffelish idea that you won't find in most OO language, but it is one the C++ community would very much like to adopt). I found an interesting approach in Sather. You don't have to declare everything; the compiler assumes the most general type possible if a variable is introduced somewhere. Such an approach could, if done well, combine the advantages of static and dynamic typing. Regards, -Joachim -- Joachim Durchholz, Hans-Herold-Str. 25, D-91074 Herzogenaurach, GERMANY