Hi Mats,
You should read sections 6.1.2.6 Mixing subtyping mechanisms of the Core
Notation (ES 201 873-1).
"Within integer and float (or derivations of these types) subtype
definitions it is allowed to mix lists and ranges. It is possible to mix
both value list and type list subtyping with each other and with range
subtyping. Overlapping of different constraints is not an error."
Within charstring and universal charstring subtype definitions it is not
allowed to mix pattern, value list, type list, or range constraints
type integer MyRange1 (0..255);
type MyRange1 MyIntegers1 (0, 10, 20, 30, 40, 50); // all MyIntegers1 are
valid MyRange1 values
MyIntegers1 is a valid subtype since all values in the value list are
members of the MyRange1 subtype definition.
type integer MyList1 (-10, 0, 10, 20, 30, 40, 50);
type MyList1 MyIntegers2 (0..20); // I am really not sure how to
interpret that range
MyIntegers2 is not a valid subtype since the values 1..9 and 11..19 are not
valid values of subtype MyList1 on which MyIntegers2 is defined.
NOTE: Subtype definitions based on basic types or other subtypes MAY only
consist of values specified in the containing/parent subtype.
type integer MyType (MyRange1, MyList1); // values are: ( -10, 0..255)
type MyType MyIntegers3(0, 10, 20); // values of only one subtype
used
type MyType MyIntegers4(-10, 0, 10, 100); // values from both subtypes
used
MyIntegers3 and MyIntegers4 are both legal subtype definitions since their
member values are proper subsets of the subtype they are based on. If you
added a value outside the MyType definitions, such as -1 or 256, then you
would have a type definition violation.
When I want to know whether a type definition is legal or not I use Venn
diagrams.
E.g. one large circle for the integer basic type ( -infinity ..
+infinity)
A smaller circle for the MyRange1 subtype ( drawn inside the large
integer basic type) ( 0..255)
A still smaller circle for the MyIntegers1 subtype ( drawn inside
the MyRange1 subtype) ( 0, 10, 20, 30, 40, 50)
A small circle which is the union of the MyRange1 and MyList1
representing MyType ( -10, 0..255)
A small circle for the MyIntegers3 subtype also contained in the
MyType (0, 10, 20)
A small circle for the MyIntegers3 subtype also contained in the
MyType subtype and intersecting with values of the MyIntegers3 subtype ,
values ( 0, 10)
If any of the values defined in the subtype I am defining find themselves
outside of the 'circle' defining the containing sub-type definition (as a
subtype might be derived from a long chain of subtypes), then you have
visual confirmation that you have a type violation. Think about using set
theory to determine whether you have type violations (at compilation time).
E.g. if MyIntegers4 included the value 256, which is not a valid value of
its parent type on which it is based, this would be a type violation and
should either cause a compile time type violation error.
Determining type compatibility at run-time can get a bit messy. Some
implementations, of TTCN-2, completely ignored sub-type
restrictions/constraints to optimize execution time and reduce boundary
checking analysis complexity during assignment.
To download a free copy of our latest version of the TTCN-3 Quick Reference
Card (QRC) visit: <
www.blukaktus.com/>
www.blukaktus.com (under
Reference Card)
The QRC is available in A4 or booklet format and is provided as a PDF.
Cheers,
Claude.
PS: Because TTCN-3 uses type compatibility instead of requiring the use of
STRONG typing, it makes life more difficult than necessary for tool
developers. Strong typing was something which I was pushing hard for when
TTCN-3 was initially being developed back in the late 90s.
NOTE: STRONG typing is only required for communications operations as
specified in section 6.3.4 of ES201 873-1.
NOTE2: For all rules on TTCN-3 type compatibility, read section 6.3 Type
compatibility of ES201 873-1
Blukaktus Communications phone: +49 (0)30 9606 7986
Edinburger Strasse 39 fax: +49 (0)30 9606 7987
13349 Berlin mobile: +49 (0)174 701 6792
email: <
This email address is being protected from spambots. You need JavaScript enabled to view it.>
This email address is being protected from spambots. You need JavaScript enabled to view it.