Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 356585 - Init section of "for" blocks should be done at each iteration
Summary: Init section of "for" blocks should be done at each iteration
Status: CLOSED WONTFIX
Alias: None
Product: Acceleo
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows Vista
: P3 normal
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-02 09:05 EDT by Laurent Delaigue CLA
Modified: 2016-04-04 08:38 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Laurent Delaigue CLA 2011-09-02 09:05:24 EDT
Build Identifier: 

Currently in Acceleo, the initialization of variables declared in the init section of a "for" block is done once.
It would make much more sense to perform the init block once for each iteration of the block (where the iterator variable could be used).
And also, not to do this initialization at all if there is no iteration to be made! (iterating over an empty list I mean)

Reproducible: Always

Steps to Reproduce:
[for (s : String | Sequence{}) { len : Integer = s.size();}]
[len/]
[/for]
Comment 1 Laurent Goubet CLA 2016-04-04 08:38:15 EDT
init sections contain the definition of a set of variables that are meant to be used in the body of their owning block. For this purpose they are evaluated _before_ the block itself, and cannot use variables defined in said block (the "s" variable in your example). We do not plan on changing this behavior as the specification doesn't make it clear.