Subject: [sv-ec] $cast
From: Kevin Cameron x3251 (Kevin.Cameron@nsc.com)
Date: Mon Jan 06 2003 - 15:01:41 PST
I'd like to split the $cast into methods that do assignment with checking
and the check:
Enum_type foo;
int i;
if (foo.valid(i + 1)) // check in range
foo = i + 1; // unchecked assignment
foo.assign(i + 1); // check and assign, fails fatally if out of range
And maybe add an optional severity argument to "assign" so that it can be
non-fatal. E.g.:
foo.assign(1+1,$warning); // Issue warning if out of range
The return value of the assign method is the new value of the object.
The other thing with enums was that they can be considered as an array of
constant values. The logical extension of that is to use indexing and add
the methods for arrays:
enum Colors { red, green, blue, yellow, white, black };
Colors bar = Colors[Colors.size -1]; // bar is black
Kev.
This archive was generated by hypermail 2b28 : Mon Jan 06 2003 - 15:02:34 PST