Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!mit-eddie!bloom-beacon!deccrl!news.crl.dec.com!pa.dec.com!src.dec.com!moss%ibis@cs.umass.edu From: moss%ibis@cs.umass.edu (Eliot Moss) Newsgroups: comp.lang.modula3 Subject: Modula-3 syntax and semantics for constants Message-ID: <9012201408.AA02050@ibis.cs.umass.edu> Date: 20 Dec 90 14:08:50 GMT Reply-To: moss@cs.umass.edu Lines: 40 To: buschman@tubsibr.cs.umass.edu Cc: m3 >>>>> On Sun, 16 Dec 90 17:17:34 +0100, buschman@tubsibr said: buschman> In the report (21.10.89) it is said: "Expressions whose values can be buschman> determined statically are called constant expressions; ..." (p.2). buschman> But what is really allowed in constant expressions? In the report at buschman> least procedural operators are used in examples. What else would be buschman> ok? I don't know what you mean by "procedural operators", but certain built-in functions and infix/prefix operators are allowed if their values can be determined at compile time. User defined procedures are not. buschman> VAR a : INTEGER := 10; buschman> CONST b : INTEGER = a; buschman> is rejected by the compiler, but the value of b could be determined buschman> statically to be 10. It is always hard to be precise, but perhaps it would help to say "Expressions whose values can be determined statically without applying optimization techniques (such as data flow analysis or inline expansion) are called constant expressions." You are quite right that with advancing compiler technology it is harder ot make these definitions precise, though I suspect most language implementors would interpret the report the same way. It's roughly: it's a constant expression if we can determine its value statically by constant folding, i.e., it is an expression built from literals, constant definitions, and applications of certain functions and operators. (Some operators give a constant expression even when the expression they're applied to is not constant; again, that could all be handled.) It could be, and has been, done; it is just tedious. Hope this helps; I would tend to agree that Report wording should be reconsidered if it is not clear ..... J. Eliot B. Moss, Assistant Professor Department of Computer and Information Science Lederle Graduate Research Center University of Massachusetts Amherst, MA 01003 (413) 545-4206; Moss@cs.umass.edu