Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Collection Type Specification(There doesn't seem to be any definitive information what the semantics of these are and whether and to what extent these are supported)
Collection Type Specification [message #1282474] Wed, 02 April 2014 07:05 Go to next message
Philip Makedonski is currently offline Philip Makedonski
Messages: 10
Registered: May 2013
Junior Member
Hi,

I've been trying to grasp whether and to what extent collection types are supported in EOL/ETL. Consider the following example:


var a = new Set(String); //desired
var b = new Set(String); //intentionally "wrong", shall be Set(Integer)
var c = new Set(String); //intentionally "wrong", shall be Set(Real)
var d = new Set;
a.addValue("S");
a.addValue("P");
b.addValue(1);
b.addValue(2);
c.addValue(1.0);
c.addValue(2.0);
d.addValue(a);
d.addValue(b);
d.addValue(c);
(a).println();
(b).println();
(c).println();
(d).println();


operation Set(String) addValue(p : String) {
	(p + " (string)").println();
	self.add(p);
}

operation Set(String) addValue(p : Integer) { //intentionally "wrong", the context should be Set(Integer)
	(p + " (integer)").println();
	self.add(p);
}

operation Any addValue(p : Real) {
	(p + " (real)").println();
	self.add(p);
}

operation Any addValue(p : Collection(Real)) {
	(p + " (collection(real))").println();
	self.add(p);
}

operation Any addValue(p : Collection(String)) {
	(p + " (collection(string))").println();
	self.add(p);
}

operation Any addValue(p : Collection(Integer)) {
	(p + " (collection(integer))").println();
	self.add(p);
}



There doesn't seem to be any difference what type is specified in the Set definition. In addition, while parameter overloading for addValue() works for primitive types in the example above, it doesn't seem to work for typed collections - i.e. executing the above shows that
addValue(p : Collection(Real))
is always executed, regardless of what the type and contents of the collection supplied as parameter (or of the context for that matter).

In the example above, it is not really an issue, but in the actual usage scenario the operation bodies vary for the different types of collections.

Thus, my question is: Is there a way to get this to work with parameter overloading in the example above? Or shall I resort to a different solution (different operation names, additional parameter indicating the type, or changing the meta-model).

Thanks in advance!

Cheers,

Philip
Re: Collection Type Specification [message #1282481 is a reply to message #1282474] Wed, 02 April 2014 07:18 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris Kolovos
Messages: 795
Registered: July 2009
Senior Member
Hi Philip,

I'm afraid that support for overloading collection types isn't great in EOL at the moment so I'd suggest using one of the alternative solutions you mentioned.

Cheers,
Dimitris

[Updated on: Wed, 02 April 2014 07:18]

Report message to a moderator

Re: Collection Type Specification [message #1282502 is a reply to message #1282481] Wed, 02 April 2014 07:51 Go to previous message
Philip Makedonski is currently offline Philip Makedonski
Messages: 10
Registered: May 2013
Junior Member
Thanks for the clarification!

Cheers,

Philip
Previous Topic:[EGL] Append output to existing file
Next Topic:[URGENT] Help Me Please
Goto Forum:
  


Current Time: Mon Jul 28 00:33:46 EDT 2014

Powered by FUDForum. Page generated in 0.01413 seconds