gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gm2] CAST Woes


From: john o goyo
Subject: [Gm2] CAST Woes
Date: Sat, 18 Jun 2005 19:19:24 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040616

Itzok:

Thank you for your comment. I shall first report my findings and
then explain what I was trying to do.

Izo wrote:


john o goyo wrote:



------------------------------------------------------------
2. CASTing woes:

Is the following not valid?

===[cast.mod]===
MODULE cast;

FROM (*ISO*) SYSTEM IMPORT CAST, LOC;

VAR
    x :LOC;
    n :CARDINAL;

BEGIN (*cast*)
    n := 2;
    x := CAST(LOC, n)  (* Reported as error by GM2 of 2005-06-03 *)
END cast.
===[cast.mod ends]===

------------------------------------------------------------


John, have you checked the LOC with the ISO M2 standard ? I think that I remember (still, I might be badly wrong ...) that the LOC has some restrictions at being used as container. I think that the LOC was meant to be special and used only as the input (especcially as the open array) parameter in procedure definitions since it could be interpreted afterwards in the procedure implementation as any given type. If I am correct, already the "x : LOC" line is incorrect and not only "x := CAST(LOC, n);"

I think that you (and Gaius) should really check this with the standard.

================================================================
1. ISO/IEC 10514-1:1996(E)

I could find not find any such restriction (but I cannot claim to know
the entire standard #6-).  However, type FilePos in RndFile.def is
defined as an array of LOC and all the *Pos() procedures act on or
return something of this type.  I would say that restricting the use
of LOC would make it very difficult to use these procedures.


================================================================
2. Why LOC?

I was trying to compile some code that marshalled CARDINAL values
into bytes for storage and transport.  I cannot use CHAR to hold
them because the standard makes no assertion on the size of CHARs.
Other compilers accept BYTE and some even allowed something such
as "byte := cardinal MOD 256".


================================================================


Regards, Iztok


Sincerely,
john



reply via email to

[Prev in Thread] Current Thread [Next in Thread]