Path: utzoo!utgpu!attcan!uunet!lll-winken!ames!pasteur!ucbvax!decwrl!decvax!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.misc Subject: Re: Expression Based Language Message-ID: <11398@haddock.ima.isc.com> Date: 12 Jan 89 06:21:32 GMT References: <3300001@uxg.cso.uiuc.edu> <3290002@hpctdls.HP.COM> <11359@haddock.ima.isc.com> <2659@ficc.uu.net> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 34 In article <2659@ficc.uu.net> you write: >Three comments: First, > > a = for(s1;e;s2) > > Is this legal? If e fails, is the value s1? I hadn't thought about that, but it's a reasonable definition -- provided the type of s1 matches the type of the body of the for statement. It does require saving the value of s1 before executing e, which is somewhat couterintuitive. > For expressions like if-without-else, the value if no statement > was executed was zero, NULL, whatever. This was in analogy to > short-circuit AND (which wasn't in the language). This would be self-consistent, but I'm not sure how useful it would be. In a while-statement, for example, if the value at the bottom of the loop is some useful value, the default (zero-execution) value would probably be some sort of error indication. Zero is not always an out-of-band value. On the other hand, a void value is even less useful, and the existence of else (for if-statements), default (for switch-statements), and the above trick of using `for' instead of `while' means that the user has complete control over the default value in any case. Given this, it seems acceptable to use zero as the `default default', when no explicit default is specified. It's also within the spirit of C, I think. >I think the value of a statement with varying types is soluble by looking >at the coercion needed to use it in context. Context outside of the expression itself? I think that's dangerous ground. Can you give an example of how one might use this? Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint