[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gm2] question about variant records in ISO M2
From: |
Gaius Mulley |
Subject: |
Re: [Gm2] question about variant records in ISO M2 |
Date: |
Fri, 31 Jul 2009 13:44:14 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) |
> I'm implementing compile time range checking of variant records and
> I was wondering whether ISO M2 allows multiple variants in a record.
>
> For example is the following legal?
>
> TYPE
> foo = RECORD
> CASE c: CARDINAL OF
>
> 1..2: x: INTEGER |
>
> ELSE
> END ;
> CASE b: BOOLEAN OF
>
> TRUE: y: CARDINAL |
> FALSE: z: BOOLEAN
>
> END
> END ;
>
>
> if it is legal then what result should the compiler return if asked:
>
> VAR
> r: FOO ;
>
> TSIZE(r, TRUE)
>
> ?
also consider:
TYPE
foo = RECORD
CASE c: CARDINAL OF
1..2: x: INTEGER |
ELSE
g: CARDINAL
END ;
CASE b: INTEGER OF
3: y: CARDINAL |
4: z: BOOLEAN
ELSE
h: CHAR
END
END ;
TSIZE(foo, 5)
:-) ?
I'm guessing it returns SIZE(CARDINAL) + SIZE(CHAR). All fun stuff -
and it is interesting to see the explosion of issues that occurs when
one extends a small (ish) language pim[234] into ISO M2 ..
regards,
Gaius