Path: utzoo!utgpu!water!watmath!clyde!att!ihlpb!nevin1 From: nevin1@ihlpb.ATT.COM (Liber) Newsgroups: comp.arch Subject: Re: Semantics (was Software Distribution) Message-ID: <8916@ihlpb.ATT.COM> Date: 12 Oct 88 01:55:43 GMT References: <13889@mimsy.UUCP> <2472@uhccux.uhcc.hawaii.edu> Reply-To: nevin1@ihlpb.UUCP (55528-Liber,N.J.) Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 40 In article <2472@uhccux.uhcc.hawaii.edu> lee@uhccux.uhcc.hawaii.edu (Greg Lee) writes: >Why would programs run any faster in a language with some undefined >semantics? To make a comparison, the same programs would have to >run in both versions of the language, and so could not make any >use of the semantics undefined in one of the versions. So why >then would the definition of semantics cause a program which does >not use it to run slower? The things that usually (never make blanket all-encompassing statements; uh, I mean, *almost* never ... :-)) need defining are exceptions to a rule (eg: dereferencing NULL is an exception to the dereferencing operation). If exceptions are to be defined, they are usually defined so that they are consistent with the rest of the rules. In mathematics, for example, 1 is defined to not be prime, 0! is defined to be 1, x to the 0 power (x<>0) is defined to be 1, etc., because the rest of the rules need not make exceptions for these cases (the rules for what a prime is, what factorial means, what exponentiation means, etc., however, have these exceptions). So, given that *NULL is an exception to dereferencing, what would be a good way to define it? One way is to allow it to be dereferenced just like any other pointer. What does this definition give you? With this definition, you never (at the compiler level) have to check to see whether or not the value of a pointer is NULL. Now, what does this definition mean in terms of the semantics of the high-level language? Since pointers and memory locations are OS/machine/compiler dependent, the semantics of *NULL are implementation-dependent, and are considered undefined in terms of the semantics of the language. Most (if not all) of the other definitions of *NULL on the high-level (semantics of C) cause more exceptions (which translates into slower and larger code) to be required on the lower-level (implementation level). -- _ __ NEVIN J. LIBER ..!att!ihlpb!nevin1 (312) 979-4751 IH 4F-410 ' ) ) "I catch him with a left hook. He eels over. It was a fluke, but there / / _ , __o ____ he was, lying on the deck, flat as a mackerel - kelpless!" / (_