| Login | | Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name. | |
| Who's Online | There are currently, 36 guest(s) and 0 member(s) that are online.
You are Anonymous user. You can register for free by clicking here | |
 | |
|
Verification Guild: Forums |
|
| View previous topic :: View next topic |
| Author |
Message |
Newsletter Original Contribution

Joined: Dec 08, 2003 Posts: 1107
|
Posted: Fri Jan 21, 2000 12:00 am Post subject: Vera tip: emulating class-level enumerals |
|
|
(Originally from Issue 1.1, Item 4.0)
From: Janick Bergeron
In Vera, enumerals cannot be overloaded as in VHDL. This means that
if I use "RESET" in my enumerated type, you can't! Furthermode,
Vera predefines a bunch of them in the file
which cannot be used either (and they are popular ones that *I*
would like to use, e.g. "ALL", "ANY", etc...).
C++ as the concept of class-level enumerated type. e.g.:
class myClass {
enum {Symbol1, Symbol2, Symbol3};
}
As long as these enumerated types are in different classes, the
symbols used for the enumerals can be overloaded. Each symbols is
accessed using the syntax classname::enumaral (e.g.: myClass::Symbol2).
You can emulate the same thing using public static data members in Vera.
For example:
class myClass {
static integer ANY := 0;
static integer ALL := 1;
task myTask(integer arg = 0 /* ANY */);
}
Notice how I'm now able to use these symbols since they are in a different
scope than enumerals. Unfortunately, they can be accidentally changed
(there is no concept of a "constant" in Vera) and must be referenced
trough an object instance. That is why I cannot use "ANY" as the default
input value for the "arg" argument in myClass::myTask. Once I have
an instance, I can use the following:
myClass obj = new;
obj.myTask(obj.ANY);
Added to my wish-list for Vera:
- Class-level enumerals
- "const" objects
- class-level reference to static data members (e.g. classname::member)
Janick Bergeron
Qualis Design Corp. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
| |
|
|