Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 347370

Summary: [EGL] Is @template now redundant?
Product: [Modeling] Epsilon Reporter: Louis Rose <louis>
Component: CoreAssignee: Louis Rose <louis>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=347016
Whiteboard:

Description Louis Rose CLA 2011-05-26 16:32:34 EDT
Given that operations now have access to the out variable (see 347016) and hence can use dynamic output sections, it's not clear whether we need the @template operation as well.

Either way, we need to update the Epsilon documentation as there is a less obvious distinction between annotated and unannotated operations now.
Comment 1 Louis Rose CLA 2011-07-14 10:54:35 EDT
Thinking about this, "standard" (unannotated) operations and @template operations are indeed different, and both seem to have their own use cases. I will update the book to reflect this, and will include the example below.

Consider the following code. @template operations return a string that can be postprocessed before being emitted (e.g. the call to firstToLowerCase below). Standard operations, by contrast, return no useful value and instead emit text as soon as they generate it.

[* The following returns no value, and immediately outputs "1" *]
[% "Foo".unannotated(); %]
[* The following returns a String, and hence permits postprocessing *]
[%="Foo".annotated()%]
[%="Foo".annotated().firstToLowerCase()%]

[% operation Any unannotated() {%]
[%=self%] (from standard operation)
[% } %]
[% @template
operation Any annotated() {%]
[%=self%] (from template operation)
[% } %]
Comment 2 Louis Rose CLA 2011-07-19 04:25:49 EDT
This bug now relates only to the Epsilon Book.

I've added a section on "user-defined operations in EGL" to the Epsilon Book, and committed it to SVN.