Translating Modula2 into D: variant records, pointer
BLS
Killing_Zoe at web.de
Tue Jan 9 09:09:13 PST 2007
Hi Frits,
> I think you can mostly fake this in D using private (differently-named)
> union members and property methods that assert if 'terminal' has the
> wrong value.
> You can even make it so that the original names directly alias the
> private names in a non-debug build, and only use the checking version in
> a debug build[1].
Can you please offer an example based on ...
Modula
TYPE NodePtr = POINTER TO Node;
Node = RECORD suc, alt: NodePtr;
CASE terminal: BOOLEAN OF
TRUE: tsym: CHAR |
FALSE: nSym: HeadPtr
END
END;
----------------------------------
Do you mean something similar .... ?
Pascal
TYPE
r2_rec = RECORD CASE INTEGER OF
1:
(e1: INTEGER;
e2: INTEGER);
2:
(e3: REAL);
END;
C/C++
typedef union {
struct {
int e1;
int e2;
} v1;
float e3;
} R2Rec;
... or am I completely wrong?
Bjoern
More information about the Digitalmars-d-learn
mailing list