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

ID | Project | Category | View Status | Date Submitted | Last Update
0007774 | Part 01: TTCN-3 Core Language | Clarification | public | 04-06-2018 14:27 | 18-12-2018 11:49

Reporter | Thilo Lauer |
Assigned To | Tomas Urban |
Priority | normal | Severity | minor | Reproducibility | have not tried
Status | closed | Resolution | no change required |
Platform |  | OS |  | OS Version |
Product Version | v4.9.1 (published 2017-05) |
Target Version |  | Fixed in Version |  |
Clause Reference(s) | TTCN-3 Standard, Part 1 completely
Source (company - Author) | Devoteam - Thilo Lauer

Summary | 0007774: Is replace function applicable to variables/templates of string/record of types with values containing matching mechanisms

Description

Can the replace function be used for variables or templates assigned by a matching-mechanism/symbol (OmitValue, AnyValue, AnyValueOrNone, AnyElementOrNone, ValueList, Complement, Permutation, Superset, Subset)?
We would like to get a clarification as the standard is here too unspecific currently.
Please note:
we are NOT(!) voting for permitting replace for variables/templates of string/record of types with values containing matching mechanisms/symbols.
We simply want to get a clarification how to handle such cases if permitted.
For a number of examples, please see the uploaded file.

Steps To Reproduce | see the uploaded file
Additional Information |
Tags | No tags attached.
Relationships |
Attached Files | CR_replace AnyValueOrNone in strings, rec. of, etc. (clarification).docx (28,357) 04-06-2018 14:27 http://oldforge.etsi.org/mantis/file_download.php?file_id=3752&type=bug

Issue History
Date Modified | Username | Field | Change
04-06-2018 14:27 | Thilo Lauer | New Issue |
04-06-2018 14:27 | Thilo Lauer | File Added: CR_replace AnyValueOrNone in strings, rec. of, etc. (clarification).docx |
05-06-2018 14:45 | Jacob Wieland - Spirent | Note Added: 0015107 |
05-06-2018 14:50 | Jacob Wieland - Spirent | Note Edited: 0015107 | bug_revision_view_page.php?bugnote_id=15107#r481
16-07-2018 14:31 | Jens Grabowski | Assigned To | => Jens Grabowski
16-07-2018 14:31 | Jens Grabowski | Status | new => assigned
16-07-2018 14:32 | Jens Grabowski | Note Added: 0015135 |
16-07-2018 14:32 | Jens Grabowski | Status | assigned => feedback
18-07-2018 09:51 | Jens Grabowski | Note Added: 0015154 |
18-07-2018 09:52 | Jens Grabowski | Assigned To | Jens Grabowski => Jacob Wieland - Spirent
18-07-2018 09:52 | Jens Grabowski | Status | feedback => assigned
18-07-2018 10:33 | Jacob Wieland - Spirent | Note Added: 0015155 |
19-07-2018 10:04 | Jacob Wieland - Spirent | Assigned To | Jacob Wieland - Spirent => Jens Grabowski
19-07-2018 10:04 | Jacob Wieland - Spirent | Status | assigned => feedback
11-10-2018 14:37 | KristÃ³f Szabados | Assigned To | Jens Grabowski => Tomas Urban
11-10-2018 14:37 | KristÃ³f Szabados | Status | feedback => assigned
11-10-2018 16:26 | Tomas Urban | Note Added: 0015259 |
11-10-2018 16:27 | Tomas Urban | Note Edited: 0015259 | bug_revision_view_page.php?bugnote_id=15259#r489
11-10-2018 16:28 | Tomas Urban | Note Edited: 0015259 | bug_revision_view_page.php?bugnote_id=15259#r490
11-10-2018 16:29 | Tomas Urban | Note Edited: 0015259 | bug_revision_view_page.php?bugnote_id=15259#r491
18-12-2018 11:49 | Jens Grabowski | Note Added: 0015292 |
18-12-2018 11:49 | Jens Grabowski | Status | assigned => closed
18-12-2018 11:49 | Jens Grabowski | Resolution | open => no change required

Notes

(0015107)
Jacob Wieland - Spirent
05-06-2018 14:45 (edited on: 05-06-2018 14:50)

According to the standard, the first parameter of the replace function must be a value. Therefore, any list that contains a matching mechanism is not allowed.
This is apparent from the signature given in section C.4.3:
replace(
in any_string_or_sequence_type inpar,
in integer index,
in integer len,
in any_string_or_sequence_type repl
) return any_string_or_sequence_type
And also from the first sentence of the description:
"This function replaces the substring or subsequence of value inpar at index index of length len with the string or
sequence value repl and returns the resulting string or sequence."
If you compare that, for instance with the substr function:
substr(
in template (present) any_string_or_sequence_type inpar,
in integer index,
in integer count
) return input_string_or_sequence_type
the difference should become clear.
So, as far as I can see, the standard is already clear in that regard.

(0015135)
Jens Grabowski
16-07-2018 14:32

STF does not a see a need for further clarification. Devoteam should check comment from Jacob.

(0015154)
Jens Grabowski
18-07-2018 09:51

Answer from Mr. Lauer regarding feedback (received via Email on 17.07.18):
Dear Mr. Grabowski,
Thanks for your request regarding our CR.
Recently we had a request from one of our customers, who wants to compile the following code:
function f_Check_UE_NetworkCap_CIOT(UE_NetworkCap p_UE_NetworkCap,
UE_NetworkCap_ToBeTested p_ToBeTested) return Boolean
{
var template (present) B8_Type v_Expected := ?; // seems not to be allowed, see examples 1 and 2 below
...
v_Expected := replace (v_Expected, 1, 1, f_ConvertBoolToBit (pc_HCCPCIoT));
...
}
}
The substr() statement allows AnyElementOrNone and AnyElement but no example is given in the standard. Here are some of our examples:
Example 1: substr(?,1,2); // What is the result? Seems to be not allowed as ? (=any value) is not used as matching symbol inside a string
Example 2: substr(*,1,2); // What is the result? Seems to be not allowed as ? (=any value) is not used as matching symbol inside a string
Example 3: substr(pattern "?*A",1,2); // What is the result? Seems to be allowed, result = "*A"; "*" = literal char, acc. to C.4.2
Example 4: substr(pattern "*?*A",1,2); // What is the result? Seems to be allowed, result = "?*" = literal chars , acc. to C.4.2
If examples 3 and 4 are allowed, it is possible to define:
a:=substr(pattern "*?*",1,2); // result is a characterstring of length 2 (not a template): result = "?*"
b:=replace(a,0,2,"asdf"); // result: b = "asdf"
c:=substr(pattern "*?*",0,1) & b; // result: c = "*asdf"
But using replace as a shortcut for the statements above - to our standard interpretation - is not allowed:
d:=replace(pattern"*?*",1,2,"asdf"); // result: should be: d = "*asdf", but this is currently not allowed.
There are a number of combinations between substring, replace, stringop (&) operating on values and/or (matching) templates
that are not yet described clearly enough in the current standard.
Especially stringop (&) allows much with templates:
Let us point to another example in the current standard:
Section 15.11: Concatenating templates of string and list types
EXAMPLE 1: Composing templates of binary string types
template bitstring mw_mybit := '010'B & ? & '1'B & ? length(1) & '1'B;
// results in the template '010*1?1'B
// note that & ? & turns to * within the resulting bitstring as the original ?
// stands for a bitstring of any length
"? (any value) stands for a bitstring of any length"
is a bit imprecise: ? (any value) stands here for a bitstring of length 1 .. infinite.
Replacing it by an * (any value or none) modifies the original pattern part to: a bitstring of length 0 .. infinite - which is slightly different.
Of course one can declare this to be the meaning of bitstring template concatenation ...
... and in case of stringop (&) it was made obvious by an example.
Our point here is, that there are a number of combinations of substring, replace, stringop (&) operating on values and/or (matching) templates ...
... that are not specified clearly enough - but they should be. Especially such "subtle" stringop details (as shown above) do not become obvious as long as there is no explicit example.
We can live with such imprecisions, but they rise the probability that compilers work differently - and users have different interpretations of the same TTCN-3 code.
General statements only helps, if they are valid in any case.
If general statements only describe the general direction, you have to deal with a lot of exceptions, that are often not or poorly defined ...
Hope this helps.
Regards,
Thilo Lauer
Principal Consultant
Solution Architect

(0015155)
Jacob Wieland - Spirent
18-07-2018 10:33

I don't concur with that analysis.
? stands for any value, that means also bitstrings of length 0, not only with length > 0. The equivalent on the pattern level for that is *, so example 1 is fully correct and there is nothing imprecise in (that part of) the text.
One could argue that the replace function could have the same strange allowance for dealing with occurrences of only the metacharacters ? and *, but in my opinion already the usage of substr on pattern is questionable as you change the semantics of the metacharacters to normal characters.
Thus, if at all, the standard should be changed that substr on a pattern again yields a pattern so that the semantics of the characters are retained. But, of course, that would be a backward incompatible change, so that will not happen.

(0015259)
Tomas Urban
11-10-2018 16:26 (edited on: 11-10-2018 16:29)

1. replace (v_Expected, 1, 1, f_ConvertBoolToBit (pc_HCCPCIoT))
This is an invalid code and shall not be compiled as the first formal parameter of the replace function is a value parameter. Because the declaration of the inpar is not completely standard, this is explicitly stated in the section C.4.3. The section 5.4.2 of the core language specification clearly states what actual parameters can be passed to in formal value parameters:
Actual parameters that are passed by value to in formal value parameters shall be variables, literal values, module parameters, constants, value variables, invocations of value returning (external) functions, formal value parameters (of in, inout or out parameterization) of the current scope or expressions composed of the above.
2. The substr function examples:
Example 1 and 2 are invalid, as the type context of the matching symbol is not set. If the AnyValue template was typed, then the error would occur because of other restriction mentioned in C.4.2 (AnyValue is not listed as a valid content of inpar)
Example 3 and 4 work as described and the following code as well. The replace function indeed doesn't work, but the original CR didn't request the change of its functionality! The question was if the rules were clear enough. If it is necessary to change the replace function functionality, a new CR should be submitted.
3. String concatenation
As Jacob pointed out, the following statement is absolutely wrong: "? (any value) stands here for a bitstring of length 1 .. infinite". There's no reason why "match(''B, ?)" should yield false as empty bitstring is not the same thing as an omitted bitstring. Naturally, all subsequent conclusions are incorrect as well, including the statement that different interpretations are possible. This is simply not the case.
My conclusion is that the presented examples failed to demonstrate any ambiguity or imprecision in the TTCN-3 core language standard.

(0015292)
Jens Grabowski
18-12-2018 11:49

STF decision: The presented examples failed to demonstrate any ambiguity or imprecision in the TTCN-3 core language standard. No change seems to be necessary.