ETSI's Bug Tracker - Ext Pack: Object-oriented features (ES 203 790)
View Issue Details
0007871Ext Pack: Object-oriented features (ES 203 790)[All Projects] Generalpublic27-08-2019 15:1528-12-2020 13:44
Jacob Wieland - Spirent 
Jens Grabowski 
normalminorhave not tried
closedfixed 
V1.2.1 (published 2020-05) 
V1.3.1 (ongoing) 
0007871: Class templates to be added to the language?
It should be investigated whether there are use cases that are facilitated by some class template mechanisms (outside which those that are already possible with the ones that we already have).
No tags attached.
docx CR7871-1.docx (134,973) 11-12-2020 12:48
http://oldforge.etsi.org/mantis/file_download.php?file_id=3988&type=bug
docx CR7871-2.docx (136,182) 11-12-2020 13:21
http://oldforge.etsi.org/mantis/file_download.php?file_id=3990&type=bug
docx CR7871-3.docx (148,597) 11-12-2020 13:22
http://oldforge.etsi.org/mantis/file_download.php?file_id=3991&type=bug
docx CR7871-4.docx (148,246) 11-12-2020 13:30
http://oldforge.etsi.org/mantis/file_download.php?file_id=3992&type=bug
docx CR7871-5.docx (137,390) 11-12-2020 13:34
http://oldforge.etsi.org/mantis/file_download.php?file_id=3993&type=bug
Issue History
27-08-2019 15:15Jacob Wieland - SpirentNew Issue
27-08-2019 15:23Jacob Wieland - SpirentAssigned To => Jens Grabowski
27-08-2019 15:23Jacob Wieland - SpirentStatusnew => assigned
17-12-2019 08:34Jacob Wieland - SpirentNote Added: 0015534
10-12-2020 14:10Jacob Wieland - SpirentNote Added: 0015843
10-12-2020 15:30Jacob Wieland - SpirentNote Added: 0015844
10-12-2020 15:36Jacob Wieland - SpirentNote Edited: 0015844bug_revision_view_page.php?bugnote_id=15844#r532
11-12-2020 11:07Jens GrabowskiAssigned ToJens Grabowski => Jacob Wieland - Spirent
11-12-2020 12:48Jacob Wieland - SpirentFile Added: CR7871-1.docx
11-12-2020 12:49Jacob Wieland - SpirentNote Added: 0015850
11-12-2020 12:49Jacob Wieland - SpirentAssigned ToJacob Wieland - Spirent => Tomas Urban
11-12-2020 12:50Jacob Wieland - SpirentNote Added: 0015851
11-12-2020 13:05Jacob Wieland - SpirentNote Added: 0015852
11-12-2020 13:06Jacob Wieland - SpirentFile Added: CR7871-2.docx
11-12-2020 13:07Jacob Wieland - SpirentNote Added: 0015853
11-12-2020 13:21Jacob Wieland - SpirentFile Deleted: CR7871-2.docx
11-12-2020 13:21Jacob Wieland - SpirentFile Added: CR7871-2.docx
11-12-2020 13:22Tomas UrbanFile Added: CR7871-3.docx
11-12-2020 13:22Jacob Wieland - SpirentNote Added: 0015854
11-12-2020 13:23Tomas UrbanNote Added: 0015855
11-12-2020 13:23Tomas UrbanAssigned ToTomas Urban => Jacob Wieland - Spirent
11-12-2020 13:23Tomas UrbanStatusassigned => confirmed
11-12-2020 13:30Tomas UrbanFile Added: CR7871-4.docx
11-12-2020 13:34Jacob Wieland - SpirentFile Added: CR7871-5.docx
11-12-2020 13:35Jacob Wieland - SpirentAssigned ToJacob Wieland - Spirent => Tomas Urban
11-12-2020 13:35Jacob Wieland - SpirentStatusconfirmed => assigned
11-12-2020 13:35Jacob Wieland - SpirentNote Added: 0015856
11-12-2020 13:35Jacob Wieland - SpirentStatusassigned => confirmed
11-12-2020 13:40Tomas UrbanNote Added: 0015857
11-12-2020 13:40Tomas UrbanStatusconfirmed => resolved
11-12-2020 13:40Tomas UrbanResolutionopen => fixed
11-12-2020 13:40Tomas UrbanAssigned ToTomas Urban => Jens Grabowski
17-12-2020 16:17Gyorgy RethyProduct Version => V1.2.1 (published 2020-05)
17-12-2020 16:17Gyorgy RethyTarget Version => V1.3.1 (ongoing)
28-12-2020 13:44Jens GrabowskiStatusresolved => closed

Notes
(0015534)
Jacob Wieland - Spirent   
17-12-2019 08:34   
Interesting in this regard would be to look at Class patterns introduced by Java or Scala.
(0015843)
Jacob Wieland - Spirent   
10-12-2020 14:10   
The only idea that I can come up with so far that is in sync with the design principles of TTCN-3 is to allow compound-assignment-notation as class templates.

Only those fields that are to be constrained should have to be mentioned, all unmentioned fields should implicitly be 'don't care'. That way, a template for class A can also be used for all subclasses of A that add additional fields. Otherwise, you would always have to use the mofifies contruct like A:modifies ? := { ... } instead of simply A:{ ... }

Only field members should be referenced on the left sides of the field assignments inside the compound assignment.

Example:

type class Pair { var integer a, b }

template Pair t := { a := (1 .. 20) }

type class Triple extends Pair { var integer c }

match(Triple.create(1,2,3), t) // returns true

Additionally, method calls of non-void methods of the class could also be allowed on the left hand side of the assignment notation.

For example:

type class @abstract Shape { function @abstract area() return float; }

template Shape smallShape := { area() := (0 .. 20.0) }

smallShape would match for all objects whose class is derived from Shape and where the result of the method call to area() fulfills the constraint.

For this extension, of course, multiple "assignments" for the same method shall be allowed in the compound assignment. As always, the semantics would be that for all assignments the constraint needs to be fulfilled so that the template matches.

Drawback here is that empty templates that do not match anything can be declared, as in

template Shape empty := {
  area() := (0.0 .. infinity),
  area() := {-infinity .. !0.0)
}

A similar such conflict can occur between an assignment of a field member and a method-call constraint.

So, maybe this advanced assignment notation with method calls should only be added to the advanced matching package.
(0015844)
Jacob Wieland - Spirent   
10-12-2020 15:30   
(edited on: 10-12-2020 15:36)
Probably only non-private fields should be possible to be used in class templates, as otherwise, private fields could be implicitly accessed.

Maybe this should even only be allowed for public property fields (and public methods), i.e. those things that you can access from outside.

(0015850)
Jacob Wieland - Spirent   
11-12-2020 12:49   
Please review first draft.
(0015851)
Jacob Wieland - Spirent   
11-12-2020 12:50   
TODO: BNF rules
(0015852)
Jacob Wieland - Spirent   
11-12-2020 13:05   
TODO: Delete the sentence that there are no object/class templates.
(0015853)
Jacob Wieland - Spirent   
11-12-2020 13:07   
Added second draft with additional restriction about object templates not being allowed to be used as values or converted into values.

Also added BNF rules (draft)
(0015854)
Jacob Wieland - Spirent   
11-12-2020 13:22   
Replaced draft 2 with version with simpler BNF change that also does not introduce BNF ambiguity by changing only the rule for FieldSpec
(0015855)
Tomas Urban   
11-12-2020 13:23   
It seems fine to me. I only made two small changes, please check.
(0015856)
Jacob Wieland - Spirent   
11-12-2020 13:35   
ok, also added the deletion of the restriction that there are no class templates to the draft, please check and resolve, if ok
(0015857)
Tomas Urban   
11-12-2020 13:40   
Reviewed, no issues found. The proposal is ready to be added to the next version of the specification.