Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/17/84; site opus.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!hao!cires!nbires!opus!rcd From: rcd@opus.UUCP (Dick Dunn) Newsgroups: net.lang.c Subject: casts and puns (and digressions...) Message-ID: <940@opus.UUCP> Date: Wed, 7-Nov-84 05:39:39 EST Article-I.D.: opus.940 Posted: Wed Nov 7 05:39:39 1984 Date-Received: Thu, 8-Nov-84 20:07:04 EST References: <110@ISM780B.UUCP> Organization: NBI,Inc, Boulder CO Lines: 30 > ... Do not be misled by the fact that some casts on some machines > generate no code. A cast is a *conversion*, not a type pun... Unfortunately, not entirely true. What C calls "casts" covers both true casts (in, say, the ALGOL 68 sense) and puns, at least in practice. The operation is a cast when conversion "makes sense" (in semantic terms); otherwise it's a pun. For example, if i is an integer, (float)i is clearly a cast; it generates instructions on most machines and produces a different internal datum which is the float corresponding most closely to the integral value of i. However, (long*)i is a pun; you just have to stretch too far to make any sensible semantics which makes it a true cast. > >example 'struct foo {struct foo *ref;};'... > struct foo is not a recursive type. At best you might call it an > iterative type. What would you think of struct foo {struct foo bar;}; ? Please be careful when attacking other folks' terminology. Structured types which contain references to themselves are quite commonly called "recursive". (See, for example, Hoare's seminal paper "Notes on Data Structuring".) > >Also, Pascal, which is doubtlessly a strongly typed language, does > >permit a type definition like 'type ref= ^ref;' and handles it > >correctly... Perhaps true, but marginally relevant to reality, since the only value assignable to an object of type ref is NIL. -- Dick Dunn {hao,ucbvax,allegra}!nbires!rcd (303)444-5710 x3086 ...Never attribute to malice what can be adequately explained by stupidity.