ETSI's Bug Tracker - Part 01: TTCN-3 Core Language
View Issue Details
0005518Part 01: TTCN-3 Core LanguageNew Featurepublic23-04-2010 10:3214-12-2010 13:20
Gyorgy Rethy 
Ina Schieferdecker 
normalminoralways
closedfixed 
v4.1.1 (published 2009-06) 
v4.3.1 (published 2011-06)v4.3.1 (published 2011-06) 
new
L.M.Ericsson
0005518: Add int2enum predefined function
Converting between the enumareted and integer type has been a pain in TTCN-3, required - in worth case - two external functions for each enumerated (OK, in real life less, but still...). Introducing enum2int solved half of the problem. users like it. But now users are requesting the "second half" of the solution, conversion from integer to enumerated. Reasons of - at least one of the users - are:
"I have some values which are (correctly) handled by test ports as integer types.
But, I'd like to internally handle them as enumerated, for several reasons:
  - there is a finite number of values for them.
  - enum values are more human readable in source code than integer.
  - ttcn log shows enum values with both: label and integer values
    (const values are only shown as integer, without its label value).

So, when receiving these values, I found the need to convert
them from integer to the internal enumerated value.

Is there an elegant way to solve this (better than a select/case function)?"
Proposed solution: introduce the int2enum predefined function with the signature:

int2enum (in integer int, out <any defined enumerated type> enum) returm integer;

i.e. the second parameter shall be a variable and the type of this variable defines the enumerated type to which the integer has to be mapped. The return value shall return 0 if the conversion is successful or non-zero if unsuccessful (it needs further discussion if we want to differentiate the erro cases - and how many of them). I think it is needed because in the case of an integer->enum conversion there is quite a high probability that the in integer value does not have an equivalent enum value. If not handling this type of error case via the return value, user who wants to write a robust code ends up with select case statements again and, in fact, the int2enum predefined function would become useless.
No tags attached.
zip CR5518-Resolution-Jens-100630.zip (39,856) 30-06-2010 18:34
http://oldforge.etsi.org/mantis/file_download.php?file_id=2390&type=bug
doc CR5518-Resolution-Gyorgy-100701.doc (212,480) 01-07-2010 09:07
http://oldforge.etsi.org/mantis/file_download.php?file_id=2391&type=bug
doc CR5518-Resolution-Jens-100830.doc (213,504) 31-08-2010 09:28
http://oldforge.etsi.org/mantis/file_download.php?file_id=2417&type=bug
doc CR5518-Resolution-101201.doc (213,504) 01-12-2010 09:26
http://oldforge.etsi.org/mantis/file_download.php?file_id=2447&type=bug
Issue History
23-04-2010 10:32Gyorgy RethyNew Issue
23-04-2010 10:32Gyorgy RethyClause Reference(s) => new
23-04-2010 10:32Gyorgy RethySource (company - Author) => L.M.Ericsson
28-06-2010 16:38Gyorgy RethyStatusnew => assigned
28-06-2010 16:38Gyorgy RethyAssigned To => Jens Grabowski
29-06-2010 10:48Gyorgy RethyNote Added: 0009397
29-06-2010 10:48Gyorgy RethyTarget Version => Edition 4.3.1 (not yet published)
30-06-2010 18:34Jens GrabowskiFile Added: CR5518-Resolution-Jens-100630.zip
30-06-2010 18:35Jens GrabowskiNote Added: 0009438
30-06-2010 18:35Jens GrabowskiAssigned ToJens Grabowski => Gyorgy Rethy
01-07-2010 09:07Gyorgy RethyNote Added: 0009440
01-07-2010 09:07Gyorgy RethyFile Added: CR5518-Resolution-Gyorgy-100701.doc
01-07-2010 09:08Gyorgy RethyAssigned ToGyorgy Rethy => Ina Schieferdecker
01-07-2010 09:08Gyorgy RethyStatusassigned => resolved
01-07-2010 09:08Gyorgy RethyResolutionopen => fixed
01-07-2010 09:08Gyorgy RethyFixed in Version => Edition 4.2.2 (not yet published)
05-07-2010 13:43Jacob Wieland - SpirentStatusresolved => feedback
05-07-2010 13:43Jacob Wieland - SpirentResolutionfixed => reopened
05-07-2010 13:43Jacob Wieland - SpirentNote Added: 0009479
13-07-2010 11:47Gyorgy RethyNote Added: 0009518
30-08-2010 12:22Gyorgy RethyStatusfeedback => assigned
30-08-2010 12:22Gyorgy RethyAssigned ToIna Schieferdecker => Jens Grabowski
31-08-2010 09:28Jens GrabowskiFile Added: CR5518-Resolution-Jens-100830.doc
31-08-2010 09:31Jens GrabowskiNote Added: 0009659
31-08-2010 09:31Jens GrabowskiAssigned ToJens Grabowski => Gyorgy Rethy
01-12-2010 09:26Gyorgy RethyFile Added: CR5518-Resolution-101201.doc
01-12-2010 09:28Gyorgy RethyNote Added: 0009873
01-12-2010 09:28Gyorgy RethyAssigned ToGyorgy Rethy => Ina Schieferdecker
01-12-2010 09:28Gyorgy RethyStatusassigned => resolved
01-12-2010 09:28Gyorgy RethyResolutionreopened => fixed
01-12-2010 09:28Gyorgy RethyFixed in VersionEdition 4.2.2 (not yet published) => Edition 4.3.1 (not yet published)
14-12-2010 12:52Ina SchieferdeckerNote Added: 0009963
14-12-2010 13:20Ina SchieferdeckerStatusresolved => closed

Notes
(0009397)
Gyorgy Rethy   
29-06-2010 10:48   
Agreed in principle, create proposed text.
(0009438)
Jens Grabowski   
30-06-2010 18:35   
Resolution Version 1 uploaded, assigned to György for proofreading.
(0009440)
Gyorgy Rethy   
01-07-2010 09:07   
Its OK, just some minor editorials. See CR5518-Resolution-Gyorgy-100701.doc.
(0009479)
Jacob Wieland - Spirent   
05-07-2010 13:43   
I would strongly vote for a void-function and treat the error cases as with all other conversion functions as a testcase error. The proposed approach seems inconsistent with the rest of the language in that regard. Error handling should not be necessary on the TTCN-3 language level.
(0009518)
Gyorgy Rethy   
13-07-2010 11:47   
This is also a possible approach, OK, don't include this CR to v4.2.2 but let leave the discussion for the next session.
(0009659)
Jens Grabowski   
31-08-2010 09:31   
Last note from Jacob was accepted and the resolution from 30.08.2010 resolves the CR accordingly. Assigned for proofreading to György.
(0009873)
Gyorgy Rethy   
01-12-2010 09:28   
One minor editorial in aneex C text, "converts and integer value" -> "converts an integer value". Final version is in CR5518-Resolution-101201.doc
(0009963)
Ina Schieferdecker   
14-12-2010 12:52   
Implemented as proposed.