Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!pprg.unm.edu!hc!ames!zodiac!joyce!sri-unix!garth!phipps From: phipps@garth.UUCP (Clay Phipps) Newsgroups: comp.lang.misc Subject: Modula-2 Cast Syntax (was Re: What is B&D? (...)) Message-ID: <2493@garth.UUCP> Date: 31 Jan 89 07:29:32 GMT References: <8784@megaron.arizona.edu> <186@m2xenix.UUCP> Reply-To: phipps@garth.UUCP (Clay Phipps) Organization: INTERGRAPH (APD) -- Palo Alto, CA Lines: 38 In article <186@m2xenix.UUCP> randy@m2xenix.UUCP (Randy Bush) writes: >... The professor heard the pleas. Modula-2 has unchecked casts. I would prefer the current (existing) form (as I understand it), because it seems to require the least special-case compiling. > pointer := PointerTypeName ( ArbitraryValueOfSameNumberOfBits ) ^^^^^^^^^^^^^^^ In the first example, any apparent function reference whose function-id is the name of a type must be treated as a cast; however, the expression within the parentheses can be evaluated just as it would be as the actual-parameter for a function invocation. >Or the new form being suggested in recent ISO work > > pointer := SYSTEM.CAST ( PointerTypeName, ArbitraryValueOfSameNumberOfBits ) ^^^^^^ ^^^^ ^^^^^^^^^^^^^^^ In the second example, any apparent function reference with the special name "SYSTEM.CAST" (or more likely, first "SYSTEM", then "CAST") must be treated as a special case. Furthermore, the first actual parameter must be treated as a special-case, because it is the name of the target type, not an expression to be evaluated. Only the last actual parameter can be evaluated normally. I think of the first example as requiring only 1 special-case decision (trivially handled with semantic actions during parsing), and the second example as requiring 2 of them (still straightforward to handle with semantic actionsa, but not as simple). What does the decreased simplicity of handling the second example buy ISO ? Is the ISO proposal trying to make way for a distinction between casts and conversions (the latter changing the bit patterns, e.g., from that for floating 0.1e2 to string '10.0' or integer 10) ? -- [The foregoing may or may not represent the position, if any, of my employer] Clay Phipps {ingr,pyramid,sri-unix!hplabs}!garth!phipps Intergraph APD, 2400#4 Geng Road, Palo Alto, CA 93403 415/494-8800