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: 109fba,df854b5838c3e14 X-Google-Attributes: gid109fba,public X-Google-Thread: 1014db,df854b5838c3e14 X-Google-Attributes: gid1014db,public X-Google-Thread: 10db24,fec75f150a0d78f5 X-Google-Attributes: gid10db24,public X-Google-Thread: 103376,df854b5838c3e14 X-Google-Attributes: gid103376,public From: dewar@cs.nyu.edu (Robert Dewar) Subject: Re: ANSI C and POSIX (was Re: C/C++ knocks the crap out of Ada) Date: 1996/04/08 Message-ID: #1/1 X-Deja-AN: 146464112 references: <4k9qhe$65r@solutions.solon.com> <828964950snz@genesis.demon.co.uk> <4kbfup$2vd@news1.mnsinc.com> <4kbl5i$p3@mordred.gatech.edu> <4kbr5q$j1l@mulga.cs.mu.OZ.AU> organization: Courant Institute of Mathematical Sciences newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++,comp.edu Date: 1996-04-08T00:00:00+00:00 List-Id: Fergus says "Nope, you've got cause and effect backwards. There's no way to make undefined behavior portable *because* it is undefined. If a language has constructs with undefined behaviour, this will lead to portability problems. But some languages have fewer areas of undefined behaviour than others. Some languages don't have any undefined behaviour at all." True enough, but this is only achievable by going to a fairly high level of abstraction. For example SNOBOL4 (or SPITBOL) programs are totally portable, with no undefined behavior at all. But if you have a language that can twiddle bits at a low level, it is hard to see how undefined behavior could be eliminated completely. It is definitely true that constructs with undefined (or non-deterministic) behavior, can lead to portability problems. Remember portable programs are portable by definition -- it's possible to write portable programs in any language. Portability problems are precisely caused by constructs that render progams non-portable. This is obvious, but worth saying, because for example Peter tends to say "What portability problems, your code is just wrong :-)" Back to non-determinism. A language can have totally defined semantics and still have non-deterministic semantics. For example in SETL, a language with no undefined semantics: x := arb {1,2,3,4}; selects an arbitrary element of the set, and puts any of 1,2,3,4 in X. The semantics of SETL is well defined (although as usual the presence of such non-determinism complicates the formal semantics). However, it is now possible to write non-portable SETL programs that incorrectly depend on "knowing" that in practice the compiler in use always implements arb by selecting the minimum element (a perfectly correct implementation, arb does not mean random!). A similar case arises in Ada with the select statement, which is free to select any open alternative non-determinisitically, or with the semantics of expression evaluation, where it is non-determinstic whether the right or left operand of an operator is evaluated first. The second case could be eliminated from the language, but anyting invollving timing is likely to lead to some non-eliminatable non-determinism. dp