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

ID | Project | Category | View Status | Date Submitted | Last Update
0008104 | Part 01: TTCN-3 Core Language | New Feature | public | 09-08-2022 16:32 | 04-01-2023 12:25

Reporter | Matthias Simon |
Assigned To | Jens Grabowski |
Priority | normal | Severity | minor | Reproducibility | have not tried
Status | closed | Resolution | fixed |
Platform |  | OS |  | OS Version |
Product Version |  |
Target Version |  | Fixed in Version |  |
Clause Reference(s) | Core Language Spec
Source (company - Author) | Nokia - Matthias Simon

Summary | 0008104: Automatic type inference
Description | Automatic type inference is a powerful feature where you allow the compiler to infer the type of a declaration by using the special type `auto`. Example: var auto u := getUser("Foo"); Open question: Do we allow `auto` only in declarations or also in formal parameters, return types, nested types and templates?
Steps To Reproduce |
Additional Information |
Tags | No tags attached.
Relationships |
Attached Files | CR8104.docx (309,467) 14-11-2022 12:51 http://oldforge.etsi.org/mantis/file_download.php?file_id=4081&type=bug CR8104-2.docx (316,772) 07-12-2022 10:35 http://oldforge.etsi.org/mantis/file_download.php?file_id=4087&type=bug CR8104-3.docx (317,153) 20-12-2022 09:29 http://oldforge.etsi.org/mantis/file_download.php?file_id=4107&type=bug

Issue History
Date Modified | Username | Field | Change
09-08-2022 16:32 | Matthias Simon | New Issue |
16-08-2022 11:06 | Jens Grabowski | Note Added: 0016217 |
16-08-2022 11:06 | Jens Grabowski | Assigned To | => Tomas Urban
16-08-2022 11:06 | Jens Grabowski | Status | new => assigned
16-08-2022 14:14 | Jens Grabowski | Project | TTCN-3 Change Requests => Part 01: TTCN-3 Core Language
11-11-2022 12:30 | Jens Grabowski | Note Added: 0016311 |
14-11-2022 12:51 | Tomas Urban | File Added: CR8104.docx |
14-11-2022 12:53 | Tomas Urban | Note Added: 0016314 |
14-11-2022 12:53 | Tomas Urban | Assigned To | Tomas Urban => Jens Grabowski
14-11-2022 12:53 | Tomas Urban | Status | assigned => confirmed
14-11-2022 19:46 | Matthias Simon | Note Added: 0016315 |
06-12-2022 12:57 | Matthias Simon | Assigned To | Jens Grabowski => Tomas Urban
06-12-2022 12:57 | Matthias Simon | Status | confirmed => assigned
07-12-2022 10:35 | Tomas Urban | File Added: CR8104-2.docx |
07-12-2022 10:53 | Tomas Urban | Note Added: 0016369 |
07-12-2022 10:53 | Tomas Urban | Assigned To | Tomas Urban => Matthias Simon
07-12-2022 10:53 | Tomas Urban | Status | assigned => confirmed
12-12-2022 08:39 | Matthias Simon | Note Added: 0016381 |
12-12-2022 08:39 | Matthias Simon | Assigned To | Matthias Simon => Tomas Urban
12-12-2022 08:39 | Matthias Simon | Status | confirmed => assigned
20-12-2022 09:28 | Tomas Urban | File Added: CR-8105-3.docx |
20-12-2022 09:29 | Tomas Urban | File Deleted: CR-8105-3.docx |
20-12-2022 09:29 | Tomas Urban | File Added: CR8104-3.docx |
20-12-2022 09:36 | Tomas Urban | Note Added: 0016432 |
20-12-2022 09:36 | Tomas Urban | Assigned To | Tomas Urban => Matthias Simon
20-12-2022 09:36 | Tomas Urban | Status | assigned => confirmed
20-12-2022 11:02 | Matthias Simon | Status | confirmed => resolved
20-12-2022 11:02 | Matthias Simon | Resolution | open => fixed
20-12-2022 11:02 | Matthias Simon | Assigned To | Matthias Simon => Jens Grabowski
04-01-2023 12:25 | Jens Grabowski | Note Added: 0016465 |
04-01-2023 12:25 | Jens Grabowski | Status | resolved => closed

Notes

(0016217)
Jens Grabowski
16-08-2022 11:06

TTF discussion: Interesting feature. Details need to be studied. Possible restriction: Auto-feature are restricted to var, const, (maybe) module parameter. Usage for templates may require further discussions.

(0016311)
Jens Grabowski
11-11-2022 12:30

TTF discussion: We introduce the feature for var, const and module parameter.

(0016314)
Tomas Urban
14-11-2022 12:53

The first version of the resolution uploaded. Please check and let me know what should be changed or added.

(0016315)
Matthias Simon
14-11-2022 19:46

Explaining this feature in the glossary is a great idea.
> 6.5. Automatic Type
> The expression or template body shall be one of the following...
> a) Reference to ...
Does this also include enumerated values?
> a) Reference to an [...] parameter
Probably timers should be excluded:
function f(timer t) {
var t2 := t;
}
How about ports?
> b) Function call returning a value.
Does this include macros, predefined functions and operations (`__LINE__`, `int2str`, `match`, `create`, ...)?
> d) Literal of ...
What about verdict literals and inline templates?
> g) Field assignment notation
Composite literals with field assignment notation create a anonymous records? Example:
module M {
type record Point { integer x, integer y }
control {
var p := { x := 23, y := 5 }; // Interred type is not "Point", but "record { integer x, integer y }"
}
}
Did I understand this correctly?
How do unions fit into this picture?
I found some examples where function argument type inference is be necessary:
var a := replace('00000110'B, 1, 3, '111'B), // type is bitstring
b := replace("My name is JJ", 13, 0, "xx") // type is charstring
How do we distinguish between list of templates and expressions?
Example:
var a := (1,2,3) // Okay: list of integer templates
var b := (1+2*3) // Okay: integer
var c := (1) // Error or integer?
> // automatic type: map from charst[r]ing to float
Typo in examples.
I noticed you replaced `Type` with `[TypeOrNestedTypeDef]`. Is the nested types on purpose?
> the ArrayDef part shall be missing as well
Why should be array part be omitted? Seems to me not necessary:
var a[] := {1,2,3} // a is an integer array of length 3

(0016369)
Tomas Urban
07-12-2022 10:53

New version uploaded, please check.
I addressed several issues: missing enumerated items, verdict literals, inline templates and TTCN-3 operators.
The following issues were not necessary to address in the draft:
1. As timer an port variables, constants and module parameters (with an explicitly specified type) are supported, there's no reason to restrict these type in automatic typing.
2. Preprocessor macros are conversted into charstring literals before compilation and then the rule f. is used
3. Composite literals create indeed anonymous records
4. (Anonymous) unions cannot be created by automatic typing as the notation is equal to a record with a single field
5. List of templates and an expression inside parenthesis are syntactically equal. The current proposal doesn't address this issue explicitly, but it is implicitly assumed the this kind of construction will be resolved as an expression.
6. The array notation [] (i.e. without dimensions) is definitely an interesting feature, but it would require more changes in the specification, because typed variables could also use automatic dimensions. I guess that is a topic for another CR.

(0016381)
Matthias Simon
12-12-2022 08:39

> p) Superset and subset [...] provide an [...] record of
I think the type of superset, subset, permutation, ... should be "template of set of {element type}".
> where all items are of the same type as the first item
We could phrase this requirement slightly different and allow cases where the first element has no concrete (or a misleading) type, such as:
1) {"Ilusat", "päeva!"} // record of universal charstring
2) {1, -, 3} // record of integer
3) {-, 2, 3} // record of integer
4) (*, 2, 3) // integer template
How about "where all items have a common type"?
I have some questions about template variables. Are these all template variables with integer type:
var template a := integer:?;
var template b := 1;
var value c := 1;
var d := integer:?;

(0016432)
Tomas Urban
20-12-2022 09:36

I fixed the issue with superset/subset and changed the text so that the expression "have a common type" is used wherever possible. That was an excellent suggestion and it makes the rules much simpler.
Regarding the last question, my opinion is that according to the proposed rules the keyword "template" is still mandatory, i.e. if you try to assign a matching symbol to a non-template automatic variable, you will get an error. Nevertheless, I am open to a discussion in this case, but I think such a change would require a different CR.

(0016465)
Jens Grabowski
04-01-2023 12:25

Implemented according to the resolution.