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: 10a146,a03ae7f4e53958e1 X-Google-Attributes: gid10a146,public X-Google-Thread: fac41,a03ae7f4e53958e1 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,8775b19e3c68a5dc X-Google-Attributes: gid103376,public X-Google-Thread: fa0ae,a03ae7f4e53958e1 X-Google-Attributes: gidfa0ae,public X-Google-Thread: 1094ba,a03ae7f4e53958e1 X-Google-Attributes: gid1094ba,public X-Google-Thread: 114809,a03ae7f4e53958e1 X-Google-Attributes: gid114809,public X-Google-Thread: 109fba,a03ae7f4e53958e1 X-Google-Attributes: gid109fba,public X-Google-Thread: 1014db,a03ae7f4e53958e1 X-Google-Attributes: gid1014db,public From: watzka@stat.uni-muenchen.de (Kurt Watzka) Subject: Re: Which language pays most? Smalltalk, not C++ nor Java. Date: 1997/12/28 Message-ID: <685mee$5d4$1@sparcserver.lrz-muenchen.de>#1/1 X-Deja-AN: 310756467 Distribution: world References: <199712121931.LAA25389@sirius.infonex.com> <67iipp$ktj$1@darla.visi.com> <882756127snz@genesis.demon.co.uk> <34A14C27.57C0@min.net> <67rjb3$pfb$1@brie.direct.ca> <34A50CAA.54AA@netup.cl> Organization: Institut fuer Statistik der LMU Muenchen (Germany) Reply-To: watzka@stat.uni-muenchen.de Newsgroups: comp.lang.fortran,comp.lang.c,comp.lang.c++,comp.lang.eiffel,comp.lang.java.programmer,comp.lang.smalltalk,comp.lang.perl.misc,comp.lang.ada,comp.edu Date: 1997-12-28T00:00:00+00:00 List-Id: Guillermo Schwarz writes: >Kaz Kylheku wrote: >> Although 'memcpy' is not a reserved keyword by any means, >> it is a reserved 'external name'. >It is the first time I see reserved external. Well, looks as if there still is something to learn about C for you. The exact wording is "are reserved as identifiers with external linkage", but "reserved external name" looks close enough to me. >> A strictly conforming program may not define any external >> name that begins with 'mem' followed by any combination of letters, >> digits or underscores. >Ok. Define void memfoo() { } and see if it compiles. >It does. The behaviour of a program that declares or defines an identifier with the same name as an identifier reserved in that context is undefined. Undefined behaviour means: "No diagnostic required, and whatever the implementor chooses to do is correct behaviour as far as the definition of the C programming language is concerned". >> Define memcpy, if you write such a static function, you must not >> include the header in >> the same translation unit, else undefined behavior results. >Wrong. The compiler points out two different implementations. >The executable can't be generated. If memcpy is not defined as a function with external linkage, and if is not included, an implementation that does not sucessfully translate the program in question is at error. Did you actually _try_ it, and if yes, which implementation did "point out two different implementations"? --------8<--------8<--------8<--------8<--------8<--------8<-------- #include static void *memcpy(void *to, const void *from, size_t n) { char *cto = to; const char *cfrom = from; while (n--) *cto++ = *cfrom++; } struct foo { int fred; char wilma[32]; double barney; }; int main(void) { struct foo bar = { 0 }, baz = { 42, "Hello", 3.14159 }; memcpy(&bar, &baz, sizeof baz); printf("%d, %s, %f\n", bar.fred, bar.wilma, bar.barney); return 0; } --------8<--------8<--------8<--------8<--------8<--------8<-------- is a valid C program, because the header associated with the file scope identifier memcpy() is not included, and because memcpy() is not defined as a symbol with external linkage. >> There is no such thing as ``overriding'' in C. Each external name must >> have exactly one definition if it is used anywhere in the program. >That's true. C is not object oriented. C++ is just an Smalltalk >wannabe. The object model and design ideas behind C++ are completely different from Smalltalk. You could probably call C++ a Simula wannabe (If you are prepared to call a Mustang a Modell T wannabe), but calling it a Smalltalk wannabe indicates that you either don't know Smalltalk or you don't know C++. Kurt -- | Kurt Watzka Phone : +49-89-2178-2781 | watzka@stat.uni-muenchen.de