ETSI's Bug Tracker - Ext Pack: Object-oriented features (ES 203 790) | |||||
View Issue Details | |||||
ID | Project | Category | View Status | Date Submitted | Last Update |
0007870 | Ext Pack: Object-oriented features (ES 203 790) | [All Projects] General | public | 27-08-2019 11:48 | 28-12-2020 12:21 |
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 | V1.2.1 (published 2020-05) | ||||
Target Version | V1.3.1 (ongoing) | Fixed in Version | |||
Summary | 0007870: Allow definition of class properties | ||||
Description | A class property is a class member which is referenced like a record field for reading and writing with the dotted notation, but implemented via getter and setter functions that are provided in the definition of the property (allowing value checking/normalization/conversion when setting a value and on-the-fly computation when getting the value). In C#, this looks like this: [<visibility>] <type> <identifier> { [<getter>] [<setter>] } [= <initial_value>]; <getter> and <setter> have different possible syntaxes: - [<visibility>] get { <body_returning value> } - [<visibility>] set { <body assigning value> } - [<visibility>] get => <result_value>; - [<visibility>] set => <value_assignment>; - [<visibility>] get; - [<visibility>] set; In the case that there is only a getter there is also a short version <visibility> <type> <identifier> => <result_value>; Thus, I propose the following syntaxes for TTCN-3 to define properties. var <template_modifier> <type> @property <modifiers> {<identifier> [<property_body>] [= <initial_value>] [","]}+ [";"] <property_body> has the following structure: "=>" <expression> | "{" (<getter> [<setter>] | <setter> [<getter>) "}" <getter> has the following structure: <modifiers> @get ("=>" <expression> [";"] | "{" { <statement> }+ "}") <setter> has the following structure: <modifiers> @set ("=>" <assignment> [";"] | "{" { <statement> } "}") We don't allow the { get; set; } syntax for automatic properties (without backing extra fields), instead, a @property variable without a <property_body> is treated as an automatic read/write property. When a property variable with a given <setter> is accessed on the left hand side of an assignment, the setter statements will be evaluated with the formal parameter 'value' being bound to the actual parameter of the right-hand-side. Accessing a non-automatic property value without a given <setter> on the left-hand side shall result in an error. When a property variable with a given <getter> is evaluated on the right hand side, the getter statements or expression will be evaluated and the resulting value will be the result of the evaluation. Accessing a non-automatic property value without a given <getter> on the right-hand side shall result in an error. Properties can be declared public and can be overridden by subclasses with the same visibility restrictions as for methods. Properties as well as their getters and setters can also be declared @abstract inside @abstract classes. If a property is declared abstract, the getter and/or setter does not need a body. A property, as well as getters and setters can also be declared @final. If a property is declared @final then neither the getter nor the setter can be overridden, otherwise, if a getter or setter itself is declared @final, then it shall not be overridden. Properties can be overridden by subclasses if they are not declared @final. EXAMPLE: type class MyPropertyClass { private var charstring v_color; // read-write property with backing variable public var charstring @property color { // getter in short form @get => v_color; @set { if (isColor(value)) { v_color := value } else { raise v_color&" is not a color" } } } // read-only property with computed value public var RGB @property rgb { // getter in long form @get { return computeRGB(v_color) } } // automatic property with initial value public var float @property size := 0.0; // read-only property with derived result in short form public var float @property square => size*size; // write-only property with short form public var float @property half_size { @set => size := half_size*2.0; } } | ||||
Steps To Reproduce | |||||
Additional Information | |||||
Tags | No tags attached. | ||||
Relationships | |||||
Attached Files | CR7870-1.docx (153,433) 12-10-2020 13:39 http://oldforge.etsi.org/mantis/file_download.php?file_id=3964&type=bug CR7870-2.docx (139,957) 07-12-2020 10:59 http://oldforge.etsi.org/mantis/file_download.php?file_id=3965&type=bug CR7870-3.docx (156,726) 08-12-2020 13:30 http://oldforge.etsi.org/mantis/file_download.php?file_id=3974&type=bug CR7870-4.docx (204,111) 09-12-2020 08:37 http://oldforge.etsi.org/mantis/file_download.php?file_id=3978&type=bug CR7870-5.docx (186,391) 09-12-2020 14:41 http://oldforge.etsi.org/mantis/file_download.php?file_id=3981&type=bug | ||||
Issue History | |||||
Date Modified | Username | Field | Change | ||
27-08-2019 11:48 | Jacob Wieland - Spirent | New Issue | |||
27-08-2019 13:04 | Jacob Wieland - Spirent | Description Updated | bug_revision_view_page.php?rev_id=499#r499 | ||
27-08-2019 14:23 | Jacob Wieland - Spirent | Note Added: 0015475 | |||
27-08-2019 15:06 | Jacob Wieland - Spirent | Assigned To | => Jens Grabowski | ||
27-08-2019 15:06 | Jacob Wieland - Spirent | Status | new => assigned | ||
14-08-2020 11:20 | Jens Grabowski | Assigned To | Jens Grabowski => Tomas Urban | ||
12-10-2020 13:39 | Tomas Urban | File Added: CR7870-1.docx | |||
12-10-2020 13:42 | Tomas Urban | Note Added: 0015791 | |||
12-10-2020 13:42 | Tomas Urban | Assigned To | Tomas Urban => Jacob Wieland - Spirent | ||
07-12-2020 10:32 | Jacob Wieland - Spirent | Note Added: 0015793 | |||
07-12-2020 10:38 | Jacob Wieland - Spirent | Note Added: 0015794 | |||
07-12-2020 10:59 | Jacob Wieland - Spirent | File Added: CR7870-2.docx | |||
07-12-2020 11:00 | Jacob Wieland - Spirent | Note Added: 0015795 | |||
07-12-2020 11:00 | Jacob Wieland - Spirent | Assigned To | Jacob Wieland - Spirent => Tomas Urban | ||
07-12-2020 11:03 | Jacob Wieland - Spirent | Note Added: 0015796 | |||
08-12-2020 09:19 | Jens Grabowski | Note Added: 0015807 | |||
08-12-2020 09:39 | Jens Grabowski | Note Added: 0015808 | |||
08-12-2020 09:49 | Jens Grabowski | Note Added: 0015809 | |||
08-12-2020 13:30 | Tomas Urban | File Added: CR7870-3.docx | |||
08-12-2020 13:39 | Tomas Urban | Note Added: 0015813 | |||
08-12-2020 13:39 | Tomas Urban | Assigned To | Tomas Urban => Jacob Wieland - Spirent | ||
09-12-2020 08:37 | Tomas Urban | File Added: CR7870-4.docx | |||
09-12-2020 08:38 | Tomas Urban | Note Added: 0015820 | |||
09-12-2020 09:16 | Jens Grabowski | Note Added: 0015823 | |||
09-12-2020 14:37 | Jacob Wieland - Spirent | File Added: CR7870-5.docx | |||
09-12-2020 14:38 | Jacob Wieland - Spirent | Note Added: 0015825 | |||
09-12-2020 14:38 | Jacob Wieland - Spirent | Assigned To | Jacob Wieland - Spirent => Tomas Urban | ||
09-12-2020 14:38 | Jacob Wieland - Spirent | Status | assigned => confirmed | ||
09-12-2020 14:41 | Jacob Wieland - Spirent | File Deleted: CR7870-5.docx | |||
09-12-2020 14:41 | Jacob Wieland - Spirent | File Added: CR7870-5.docx | |||
09-12-2020 15:10 | Tomas Urban | Note Added: 0015826 | |||
09-12-2020 15:10 | Tomas Urban | Assigned To | Tomas Urban => Jacob Wieland - Spirent | ||
10-12-2020 13:31 | Jacob Wieland - Spirent | Note Added: 0015841 | |||
10-12-2020 13:31 | Jacob Wieland - Spirent | Status | confirmed => resolved | ||
10-12-2020 13:31 | Jacob Wieland - Spirent | Resolution | open => fixed | ||
10-12-2020 13:31 | Jacob Wieland - Spirent | Assigned To | Jacob Wieland - Spirent => Jens Grabowski | ||
17-12-2020 16:17 | Gyorgy Rethy | Product Version | => V1.2.1 (published 2020-05) | ||
17-12-2020 16:17 | Gyorgy Rethy | Target Version | => V1.3.1 (ongoing) | ||
28-12-2020 12:21 | Jens Grabowski | Status | resolved => closed |
Notes | |||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|