ETSI's Bug Tracker - Ext Pack: Object-oriented features (ES 203 790)
View Issue Details

ID | Project | Category | View Status | Date Submitted | Last Update
0007866 | Ext Pack: Object-oriented features (ES 203 790) | [All Projects] General | public | 26-08-2019 14:57 | 09-01-2020 16:03

Reporter | Jacob Wieland - Spirent |
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 |  |

Summary | 0007866: Allow nested classes

Description

As it is often more convenient for some implementations, TTCN-3 should allow the definition of nested classes.
A nested class is a class defined inside another class body with access to the containing class's protected and public members.
A nested class shall not define (neither directly nor through inheritance from superclasses) a member with the same name as one of the members of the outer class or its runs on type. If no runs on type is given to the inner class, it inherits it from the outer class. However, it may declare a runs on type which is runs-on compatible with the one from the outer class.
EXAMPLE:
type record of charstring Strings;
type class @abstract StringIterator {
function @abstract hasNext() return boolean;
function @abstract next() return charstring;
}
type class StringList {
var Strings v_strings;
type class Iterator extends StringIterator {
var integer v_pos := 0;
public function hasNext() return boolean {
return v_pos < lengthof(v_strings);
}
public function next() return charstring {
v_pos := v_pos + 1;
return v_strings[v_pos-1];
}
}
function iterator() return Iterator {
return Iterator.create();
}
}

Steps To Reproduce |
Additional Information |
Tags | No tags attached.
Relationships |
Attached Files | CR7866.docx (136,387) 17-12-2019 08:31 http://oldforge.etsi.org/mantis/file_download.php?file_id=3878&type=bug CR7866-2.docx (154,353) 17-12-2019 10:25 http://oldforge.etsi.org/mantis/file_download.php?file_id=3882&type=bug CR7866-3.docx (154,411) 17-12-2019 14:26 http://oldforge.etsi.org/mantis/file_download.php?file_id=3887&type=bug

Issue History
Date Modified | Username | Field | Change
26-08-2019 14:57 | Jacob Wieland - Spirent | New Issue |
27-08-2019 13:39 | Jacob Wieland - Spirent | Note Added: 0015474 |
27-08-2019 13:39 | Jacob Wieland - Spirent | Assigned To | => Jacob Wieland - Spirent
27-08-2019 13:39 | Jacob Wieland - Spirent | Status | new => assigned
17-12-2019 08:31 | Jacob Wieland - Spirent | File Added: CR7866.docx |
17-12-2019 08:32 | Jacob Wieland - Spirent | Note Added: 0015533 |
17-12-2019 08:32 | Jacob Wieland - Spirent | Assigned To | Jacob Wieland - Spirent => Tomas Urban
17-12-2019 08:32 | Jacob Wieland - Spirent | Status | assigned => confirmed
17-12-2019 10:25 | Tomas Urban | File Added: CR7866-2.docx |
17-12-2019 10:26 | Tomas Urban | Note Added: 0015544 |
17-12-2019 10:26 | Tomas Urban | Assigned To | Tomas Urban => Jacob Wieland - Spirent
17-12-2019 12:44 | KristÃ³f Szabados | Note Added: 0015553 |
17-12-2019 13:28 | Jacob Wieland - Spirent | Note Added: 0015554 |
17-12-2019 13:29 | Jacob Wieland - Spirent | Status | confirmed => assigned
17-12-2019 13:29 | Jacob Wieland - Spirent | Assigned To | Jacob Wieland - Spirent => KristÃ³f Szabados
17-12-2019 13:29 | Jacob Wieland - Spirent | Status | assigned => confirmed
17-12-2019 13:36 | Jacob Wieland - Spirent | Assigned To | KristÃ³f Szabados => Tomas Urban
17-12-2019 13:36 | Jacob Wieland - Spirent | Status | confirmed => assigned
17-12-2019 14:06 | KristÃ³f Szabados | Note Added: 0015557 |
17-12-2019 14:26 | Tomas Urban | File Added: CR7866-3.docx |
17-12-2019 14:28 | Tomas Urban | Note Added: 0015561 |
17-12-2019 14:28 | Tomas Urban | Assigned To | Tomas Urban => KristÃ³f Szabados
17-12-2019 14:28 | Tomas Urban | Status | assigned => confirmed
18-12-2019 07:10 | KristÃ³f Szabados | Assigned To | KristÃ³f Szabados => Jacob Wieland - Spirent
18-12-2019 07:10 | KristÃ³f Szabados | Status | confirmed => assigned
18-12-2019 07:10 | KristÃ³f Szabados | Note Added: 0015563 |
18-12-2019 07:58 | Jacob Wieland - Spirent | Note Added: 0015566 |
18-12-2019 07:58 | Jacob Wieland - Spirent | Status | assigned => resolved
18-12-2019 07:58 | Jacob Wieland - Spirent | Resolution | open => fixed
18-12-2019 07:58 | Jacob Wieland - Spirent | Assigned To | Jacob Wieland - Spirent => Jens Grabowski
09-01-2020 16:03 | Jens Grabowski | Status | resolved => closed

Notes

(0015474)
Jacob Wieland - Spirent
27-08-2019 13:39

Inner class type : StringList.Iterator instantiating inner class from outside: var StringList v_list := StringList.create(); ... var StringList.Iterator v_iterator := v_list.Iterator.create();

(0015533)
Jacob Wieland - Spirent
17-12-2019 08:32

please review proposal

(0015544)
Tomas Urban
17-12-2019 10:26

I made some minor corrections to the text. Please review the corrections and if you are fine with them, the CR can be marked as resolved.

(0015553)
KristÃ³f Szabados
17-12-2019 12:44

Do I understand correctly right now it is possible to instantiate an object of the nested class, with no object of the containing class? In which case using member fields of the containing class, does not have any meaning.

(0015554)
Jacob Wieland - Spirent
17-12-2019 13:28

No, there is restriction b) which disallows this: b) Referencing the name of a nested class in a null reference via dotted notation shall cause an error. How else would you instantiate the object from outside? And if you are inside, the object is 'this'

(0015557)
KristÃ³f Szabados
17-12-2019 14:06

Technically there is no object involved according to the current text, so there can be no null reference:
"The constructor of a nested class may be invoked on a reference composed of the containing and nested class identifier separated by a dot"
In my understanding this talks about class names, not object instances, and class names can not be null ... so the restriction in this setup is not sensible and it is only possible to instantiate a nested class without an object of the containing class.

(0015561)
Tomas Urban
17-12-2019 14:28

New resolution uploaded, please review.

(0015563)
KristÃ³f Szabados
18-12-2019 07:10

Looks fine for me, please review.

(0015566)
Jacob Wieland - Spirent
18-12-2019 07:58

resolved