Working with Enumeration Datatypes

I'm using Enumeration Datatypes in my language. But I haven't found a good way to work with them.

If I define a property of an enumeration type, I just can access to it as a string. The is(< >) operation is just available if have direct access to that property. When I pass the property to a method it's just an ordinary string. And I haven't found a way to apply a switch case statement to the property.

I have found the type enummember<> and the operation enum/ /., which allow some enum handling but produces very much code for some primitive operations. Using these constructs lead to the confusing fact that enumerations  differ between values and presentation (named name outside the declaration). I have found out that the value of a property handled as string is (mostly but not always!) the presentation. So what are the values for??

At the moment I would really prefer standard java enumerations, but I haven't fond a way to use them in my language structure.
0
5 comments
One example how my way to set a enum property looks like:

node.enumproperty = enum/EnumDatatype/.<VAL>.name

So enum/EnumDatatype/.<VAL> produces a enummember, but I haven't found a way to assign this directly to the property. This is inconvenient and error-prone.
I guess there is a better way. So please feel free to show me one ;)
0
Perhaps you are looking for

node.enumproperty.set()
and
node.enumproperty.is() (for comparison)

Greets
0
Thanks, Micheal! I know about these operators. But they are just available, if the enumproperty is directly accessed as member of the node. Try to extract node.enumproperty as local variable... You even can't use the is() operator inside a property constraint for a enum property. This isn't very handy.
0
Sorry fabma for misunderstanding you.

Could you post a screenshot so I can understand how you use the enums?
Are you talking about enums in the baselang or the mps.lang(for language specification)?

Greets
0
Hmm, there is nothing to show on a screen shot. Just take your example node.enumproperty.is(<...>)  select just node.enumproperty and press Ctrl + Alt + V (extract variable). Then you will see what I mean.
0

Please sign in to leave a comment.