Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!sun!pitstop!sundc!seismo!uunet!pdn!alan From: alan@pdn.nm.paradyne.com (Alan Lovejoy) Newsgroups: comp.lang.modula2 Subject: Re: Is this a compiler bug? Message-ID: <5736@pdn.nm.paradyne.com> Date: 7 Mar 89 20:02:46 GMT References: <8903032139.AA00466@gilroy.pa.dec.com> Reply-To: alan@pdn.nm.paradyne.com (0000-Alan Lovejoy) Organization: AT&T Paradyne, Largo, Florida Lines: 43 In article <8903032139.AA00466@gilroy.pa.dec.com> Modula2 List writes: > >INC(CARDINAL(code), 1); > >is not accepted by most Modula-2 compilers, because ``CARDINAL(code)'' is an >expression (an r-value, for those conversant with C's description) rather than >a variable (an l-value). INC effectively takes a VAR parameter, so insists >upon having a variable. > >I don't consider the cast to really be an expression. I see it as a type >conversion which is more properly seen as a viewpoint change rather than a >computation. I therefore consider this a silly restriction, and done >something about it in the Modula-2 compiler I maintain. But it certainly >isn't standard. > > Joel McCormack *Syntactically*, "CARDINAL(BITSET{2,5})" is an expression. The only way to differentiate between this and any other expression is by means of the semantics. If the parser permits expressions everywhere that "idents" and/or "qualidents" are allowed, then it must rely on the semantic analyzer to distinguish between legal and illegal expression usage. But Wirth published a grammar for Modula-2 that explicitly outlawed the usage of what are syntactically expressions in cases like the one above. So any compiler that relaxes this restriction is not standard. The fact that the resulting language may be an improvement over the one defined by Wirth has not been enough to motivate most compiler writers, whose work so far is largely a labor of love. The international standardization effort is the last great hope for addressing this issue. From what I have heard, I wouldn't expect any changes that would allow "INC(CARDINAL(x), 1)" anytime soon, unfortunately. If you want to complain about the shortcomings of M2, start with the fact that modules are not classes, and don't forget to mention the lack of an inheritance mechanism and parametric types/modules. -- Alan Lovejoy; alan@pdn; 813-530-2211; ATT-Paradyne: 8550 Ulmerton, Largo, FL. Disclaimer: I do not speak for ATT-Paradyne. They do not speak for me. ___________ This Month's Slogan: Reach out and BUY someone (tm). ___________ Motto: If nanomachines will be able to reconstruct you, YOU AREN'T DEAD YET.