Logo etsi

ETSI's Bug Tracker

Notice: information submitted on the ETSI issue Tracker may be incorporated in ETSI publication(s) and therefore subject to the ETSI IPR policy.

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007866Ext Pack: Object-oriented features (ES 203 790)[All Projects] Generalpublic26-08-2019 14:5709-01-2020 16:03
ReporterJacob Wieland - Spirent 
Assigned ToJens Grabowski 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusclosedResolutionfixed 
PlatformOSOS Version
Summary0007866: Allow nested classes
DescriptionAs 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();
  }
}
TagsNo tags attached.
Attached Filesdocx file icon CR7866.docx [^] (136,387 bytes) 17-12-2019 08:31
docx file icon CR7866-2.docx [^] (154,353 bytes) 17-12-2019 10:25
docx file icon CR7866-3.docx [^] (154,411 bytes) 17-12-2019 14:26

- Relationships

-  Notes
(0015474)
Jacob Wieland - Spirent (developer)
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 (developer)
17-12-2019 08:32

please review proposal
(0015544)
Tomas Urban (developer)
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 (manager)
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 (developer)
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 (manager)
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 (developer)
17-12-2019 14:28

New resolution uploaded, please review.
(0015563)
Kristóf Szabados (manager)
18-12-2019 07:10

Looks fine for me, please review.
(0015566)
Jacob Wieland - Spirent (developer)
18-12-2019 07:58

resolved

- 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


MantisBT 1.2.14 [^]
Copyright © 2000 - 2020 MantisBT Team
Powered by Mantis Bugtracker