ETSI's Bug Tracker - Part 01: TTCN-3 Core Language
View Issue Details

ID | Project | Category | View Status | Date Submitted | Last Update
0008155 | Part 01: TTCN-3 Core Language | Technical | public | 12-12-2022 14:20 | 15-01-2024 12:22

Reporter | Matthias Simon |
Assigned To | Jens Grabowski |
Priority | normal | Severity | minor | Reproducibility | have not tried
Status | closed | Resolution | won't fix |
Platform |  | OS |  | OS Version |
Product Version |  |
Target Version |  | Fixed in Version |  |
Clause Reference(s) | n/a
Source (company - Author) | Nokia - Matthias Simon

Summary | 0008155: Issue with the number of elements of templates

Description

How do I get the number of elements of a string or list?
For example of a hexstring template:
template hexstring s := '1*F'H
for (var integer i := 0; i<lengthof(s); i := i + 1) {
log(s[i]);
}
I would expect the number of elements in this template would be 3 (as suggested by clause 15.6.1). However lengthof produces a (justified) runtime error and sizeof is deprecated.
Is there a mechanism for retrieving the number of elements in a string or list in TTCN-3 or do we need a new predefined function?

Steps To Reproduce |
Additional Information |
Tags | No tags attached.
Relationships |
Attached Files |

Issue History
Date Modified | Username | Field | Change
12-12-2022 14:20 | Matthias Simon | New Issue |
20-12-2022 13:03 | Jens Grabowski | Note Added: 0016442 |
20-12-2022 13:03 | Jens Grabowski | Assigned To | => Jens Grabowski
20-12-2022 13:03 | Jens Grabowski | Status | new => assigned
20-12-2022 13:12 | Jens Grabowski | Note Added: 0016443 |
07-11-2023 16:25 | Jens Grabowski | Assigned To | Jens Grabowski => Matthias Simon
07-11-2023 16:26 | Jens Grabowski | Note Added: 0016541 |
08-11-2023 10:49 | Matthias Simon | Note Added: 0016544 |
08-11-2023 23:48 | Gusztáv Adamis | Note Added: 0016558 |
08-11-2023 23:49 | Gusztáv Adamis | Note Added: 0016559 |
08-11-2023 23:49 | Gusztáv Adamis | Note Deleted: 0016559 |
08-11-2023 23:50 | Gusztáv Adamis | Note Edited: 0016558 | bug_revision_view_page.php?bugnote_id=16558#r623
10-11-2023 08:25 | Matthias Simon | Note Added: 0016571 |
10-11-2023 08:25 | Matthias Simon | Assigned To | Matthias Simon => Jens Grabowski
10-11-2023 08:25 | Matthias Simon | Status | assigned => resolved
10-11-2023 08:25 | Matthias Simon | Resolution | open => won't fix
15-01-2024 12:22 | Jens Grabowski | Note Added: 0016591 |
15-01-2024 12:22 | Jens Grabowski | Status | resolved => closed

Notes

(0016442)
Jens Grabowski
20-12-2022 13:03

TTF discussion: Has to be studied. Cannot be resolved for the next version. To be shifted into 2023.

(0016443)
Jens Grabowski
20-12-2022 13:12

TTF discussion: lenghtof function needs to be revised.

(0016541)
Jens Grabowski
07-11-2023 16:26

TTF discussion: Resolution will be based on an optional parameter.

(0016544)
Matthias Simon
08-11-2023 10:49

We should reconsider our resolution, because a new proposal has come up (method-syntax).
Following options are available for discussion (only the first 3 are relevant in my opinion):
1. Optional Parameter
Example: lengthof({1,*,5}, true) // true uses new lengthof behaviour
+ Backwards compatible
- Surprising users can get surprising runtime errors, because behavior is aligned with length-constraint-assignment-rules
- Clumsy design (but seldom used, most users won't notice)
2. Just Change Behavior
Example: lengthof({1,*,5}) // returns 3
+ Expected behavior aligned with index-access-rules
+ easy to understand, good design
- Backwards incompatible (but only for rare corner cases, for fix an easy fix is available)
3. Method Syntax:
Example: {1,*,5}.lengthof()
+ Does not pollute existing namespaces
+ Easy to understand
- Method syntax is not very common in TTCN-3
- Grammar needs restructuring
- two different lengthof functionalities is confusing
4. New Syntax:
Random Example: lengthof @lastindex ({1,*,5})
+ Backwards compatible
+ Could be easy to understand,
+ New syntax could unlock other features (e.g. a[lengthof] := 23)
- New syntax increases language complexity
- We have no proposal how such syntax could look like
4. New Function:
Example: lastindex({1,*,3})
+ Easy to understand, no confusion about different lengthof behaviors
+ Could unlock other features by circumventing making lengthof issue
- Backwards incompatible, due to new keywords
5. Using length
Example: length({1,*,3})
+ Backwards compatible
+ Could reduce keywords by making lengthof superfluous
- Having two different length functions is confusing

(0016558)
Gusztáv Adamis
08-11-2023 23:48 (edited on: 08-11-2023 23:50)

Ericsson can accept backward incompability, so the lengthof() function can be extended (without adding an extra optional parameter) to reach the desired behaviour also for templates instead of resulting in a run-time error.

(0016571)
Matthias Simon
10-11-2023 08:25

Summary: A deeper investigation is required, because the situation is unclear. There seem to be contradictions between the lengthof-spec and its examples; also between binary-string values/templates and indexing rules, ... A new CR for this topic will be created.

(0016591)
Jens Grabowski
15-01-2024 12:22

No action required at the moment.