Issue 14438: Example ambiguity (mtt-rtf) Source: (, ) Nature: Clarification Severity: Minor Summary: Section 8.1.5 describes initSections and tells us that ----------8<---------- An InitSection contains a set of variable initializations to be used in the body of its owning block. ---------->8---------- Yet example A.3 sports something like this : ----------8<---------- [template public class_header(c : Class) { int count = -1; } ] [...] [for(a : Attribute) | c.attribute) { count = count + 1; }] #define [a.name/]_BIT [count/] [/for] ---------->8---------- First of all, "int count = -1" is syntactically wrong and should be "count : Integer = -1"; but I've raised this in a separate issue not accepted yet so I don't have its number). The real problem here is that this example initializes a variable "count" in the template's init section, then tries to -modify- this variable in the init section of a for. That just cannot be with the specification as it is now : the second init section should be "count : Integer = count +1" to be syntactically correct, and this doesn't mean "increment the value of 'count'" but "create variable 'count' with value 'count + 1' so we actually create a second variable that hides the first. Furthermore, as this second variable is declared on a for, and initSection's variables are only meant to be useable in the 'for' body, this second "count" variable will only last for an iteration. This means that every iteration, we create a new variable 'count' of value '0' (since the first 'count' variable is '-1'). There is nothing in MOFM2T that's been specified as something that allows for the *modification* of a variable. We can only initialize them. Modifying variables requires the introduction of a non-generating block. Side-effect free blocks where we could do things without generating text. The next version should revise the A.3 example so as not to be misleading about the signification of InitSections. It should also introduce a new block dedicated to logic. Resolution: Revised Text: Actions taken: September 28, 2009: received issue Discussion: End of Annotations:===== m: webmaster@omg.org Date: 28 Sep 2009 08:38:16 -0400 To: Subject: Issue/Bug Report ******************************************************************************* Name: Laurent Goubet Company: Obeo mailFrom: laurent.goubet@obeo.fr Notification: Yes Specification: MOF Model to Text Transformation Language (MOFM2T) Section: 8.1.5, A.3 FormalNumber: formal/2008-01-16 Version: 1.0 RevisionDate: 01/16/08 Page: 30, 16 Title: Example ambiguity Nature: Clarification Severity: Minor test: 3qw8 B1: Report Issue Description: Section 8.1.5 describes initSections and tells us that ----------8<---------- An InitSection contains a set of variable initializations to be used in the body of its owning block. ---------->8---------- Yet example A.3 sports something like this : ----------8<---------- [template public class_header(c : Class) { int count = -1; } ] [...] [for(a : Attribute) | c.attribute) { count = count + 1; }] #define [a.name/]_BIT [count/] [/for] ---------->8---------- First of all, "int count = -1" is syntactically wrong and should be "count : Integer = -1"; but I've raised this in a separate issue not accepted yet so I don't have its number). The real problem here is that this example initializes a variable "count" in the template's init section, then tries to -modify- this variable in the init section of a for. That just cannot be with the specification as it is now : the second init section should be "count : Integer = count +1" to be syntactically correct, and this doesn't mean "increment the value of 'count'" but "create variable 'count' with value 'count + 1' so we actually create a second variable that hides the first. Furthermore, as this second variable is declared on a for, and initSection's variables are only meant to be useable in the 'for' body, this second "count" variable will only last for an iteration. This means that every iteration, we create a new variable 'count' of value '0' (since the first 'count' variable is '-1'). There is nothing in MOFM2T that's been specified as something that allows for the *modification* of a variable. We can only initialize them. Modifying variables requires the introduction of a non-generating block. Side-effect free blocks where we could do things without generating text. The next version should revise the A.3 example so as not to be misleading about the signification of InitSections. It should also introduce a new block dedicated to logic.