Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Supertype of enumeration

Supertype of enumeration

Hello,
Is it possible to declare a new enumeration as being a supertype of an existing enumeration ? So that when the base enumeration is modified, the second takes it into account.
I can't find a syntax that would work, nor any help on the subject.
Thanks,
JB.

For example:
type BaseEnumeration=enumeration(base1,base2,base3);
type CompletedEnumeration=enumeration(base1,base2,base3,comp1,comp2);  //as =BaseEnumeration added of comp1,comp2

Re: Supertype of enumeration

The only way I could think of was the following, but it won't work because you may only inherit from one class of type restriction.

Code:

class A

  type E1 = enumeration(a,b,c);
  type E2 = enumeration(d,e,f);
  type F
    extends E1;
    extends E2;
  end F;
  F f;
end A;

The following does flatten,  but won't produce correct code:

Code:

class A

  class E1 = enumeration(a,b,c);
  class E2 = enumeration(d,e,f);
  class F
    extends E1;
    extends E2;
  end F;
  F f;
end A;

There are 0 guests and 0 other users also viewing this topic