Path: utzoo!attcan!uunet!mcvax!cernvax!ethz!forty2!claudio
From: claudio@forty2.UUCP (Claudio Nieder)
Newsgroups: comp.lang.modula2
Subject: Re: more about ORD and VAL
Message-ID: <352@forty2.UUCP>
Date: 7 Jul 88 19:44:56 GMT
References: <3638@pdn.UUCP> <8807051419.AA05623@banzai-inst.sw.mcc.com>
Reply-To: claudio@forty2.UUCP (Claudio Nieder)
Organization: Exp. Physics University Zuerich
Lines: 23

In article <8807051419.AA05623@banzai-inst.sw.mcc.com> Info-Modula2 Distribution List  writes:
>> The proposed (and ISO accepted) syntax for bit-preserving transfers is
|> CAST(CARDINAL, -1).  CAST must be imported from SYSTEM.
|
|This still leaves me wondering what a "meaning-preserving" conversion is for
|    CAST(CARDINAL, -1)
|
|What value would you expect to get back?

     First let me assume that by meaning-preserving "CAST" you mean the
conversion done with either CONVERT(CARDINAL,-1) or simply CARDINAL(-1)
presented in an earlier posting. The M2Amiga compiler treats this as an
error, similar as if you would write:

   MODULE t; VAR c:CARDINAL; BEGIN c:=-1; END t.

It is not possible to transform -1 into a CARDINAL number and preserv its
meaning/value. That's only possible if the target type contains that number.
E.g. it is possible to write in M2Amiga:

  MODULE t; VAR c:CARDINAL; r:REAL; BEGIN c:=1; r:=REAL(c); END t.

and r will get the value 1.0 .