Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] OO-semantics of templates
[Acceleo] OO-semantics of templates [message #823543] Sun, 18 March 2012 13:31 Go to next message
Gregor Bonifer is currently offline Gregor BoniferFriend
Messages: 7
Registered: May 2011
Junior Member
Hi,

I stumbled upon the following behavior:
My idea was to seperate the traversal of a model from the creation of textual artifacts. The intention behind this is that a general strategy for walking a model may be used to create different kinds of textual representation that have a common structure.
First, I created a module walkInheritanceHierarchie with public templates walkPackage(pack : EPackage), walkRootClass(eClass : EClass, pack : EPackage) and walkSubClass(eClass : EClass, pack : EPackage):
- walkPackage calls walkRootClass for every EClass that doesn't have a superClass inside the package.
- walkRootClass calls walkSubClass for every direct subClass of the given class.
- walkSubClass calls itself for every direct subClass of the given class.

Now I wanted to create a simple xml-document reflecting the inheritance structure. So, I created a module renderHierarchieXML that extends walkInheritanceHierarchie.
I defined overriding templates for all three templates. Each template generates some text and calls [super/].

Now it seems that [super/]-call just delegates to the superTemplate which is then executed as if it was executed standalone. I would have expected that the template walkPackage calls the overriding version of walkRootClass, but instead it calls the overridden version from its own module. This means that the namespace used for the execution of super-calls does not respect the calling context. walkPackage seems to be unaware that it should not call walkRootClass from its own module, but the overriding template from the extending module.
Therefore the behavior does not resemble OO inheritance semantics.

What am I doing wrong? Did I misunderstand the concept behind the extending- and overriding-mechanism?

Regards,
Gregor Bonifer
Re: [Acceleo] OO-semantics of templates [message #824071 is a reply to message #823543] Mon, 19 March 2012 08:11 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Gregor

Acceleo is an implementation of most of the OMG MOFM2T 1.0
specification, which is a bit vague as to which module/template/query
concepts have namespace and which have class semantics. You are in good
company in observing a lack of reasonable polymorphism.

It is not entirely surprising that a 1.0 specification can be improved.
I hope that Obeo will start moving towards a 1.1 or 2.0 specifcation.

Regards

Ed Willink


On 18/03/2012 13:31, Gregor Bonifer wrote:
> Hi,
>
> I stumbled upon the following behavior: My idea was to seperate the
> traversal of a model from the creation of textual artifacts. The
> intention behind this is that a general strategy for walking a model
> may be used to create different kinds of textual representation that
> have a common structure.
> First, I created a module walkInheritanceHierarchie with public
> templates walkPackage(pack : EPackage), walkRootClass(eClass : EClass,
> pack : EPackage) and walkSubClass(eClass : EClass, pack : EPackage):
> - walkPackage calls walkRootClass for every EClass that doesn't have a
> superClass inside the package. - walkRootClass calls walkSubClass for
> every direct subClass of the given class.
> - walkSubClass calls itself for every direct subClass of the given class.
>
> Now I wanted to create a simple xml-document reflecting the
> inheritance structure. So, I created a module renderHierarchieXML that
> extends walkInheritanceHierarchie.
> I defined overriding templates for all three templates. Each template
> generates some text and calls [super/].
>
> Now it seems that [super/]-call just delegates to the superTemplate
> which is then executed as if it was executed standalone. I would have
> expected that the template walkPackage calls the overriding version of
> walkRootClass, but instead it calls the overridden version from its
> own module. This means that the namespace used for the execution of
> super-calls does not respect the calling context. walkPackage seems to
> be unaware that it should not call walkRootClass from its own module,
> but the overriding template from the extending module.
> Therefore the behavior does not resemble OO inheritance semantics.
> What am I doing wrong? Did I misunderstand the concept behind the
> extending- and overriding-mechanism?
>
> Regards,
> Gregor Bonifer
Re: [Acceleo] OO-semantics of templates [message #827357 is a reply to message #824071] Fri, 23 March 2012 08:04 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Gregor,

The fact that a call to "super" goes up to the overriding template ... and never goes back down (if "super" calls an overriden template) is a known limitation of Acceleo, though I could not locate the bug which I thought was open for this issue. Could you track your problem (your previous description would be enough) on the bugzilla? https://bugs.eclipse.org/bugs/enter_bug.cgi?product=M2T&component=Acceleo&hardware=All&os=All .

As Ed mentionned, the specification (you can find it there by the way : http://www.omg.org/spec/MOFM2T/1.0/ ) is quite vague as to the semantics of overriding, "super" calls, polymorphic dispatch... but as it stands, it is vague enough for us to think that the best implementation would be to be more "java-like" in the dispatching of template and query calls.

Laurent Goubet
Obeo
Previous Topic:MWE: Caching XML Schema to ECORE transformation
Next Topic:[ATL] The generate atl plugin works differently from atl configuration
Goto Forum:
  


Current Time: Fri Apr 26 11:41:35 GMT 2024

Powered by FUDForum. Page generated in 0.03197 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top