Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » What do you think about link cast operator to a "toX" function?
What do you think about link cast operator to a "toX" function? [message #1782935] Mon, 05 March 2018 12:52 Go to next message
Stephane Galland is currently offline Stephane GallandFriend
Messages: 120
Registered: July 2014
Location: Belfort, France
Senior Member
Dear all.

In Xbase DSL, we have the cast operator, e.g.
value as type
.
In Java, we have functions for converting an object to another type, e.g.
toString()
.

Now, I think about a mechanism that may automatically link the cast operator within a DSL to any "toX" function.

Let the DSL code
value as Type

The DSL compiler should try:

  • If the type of the value is a primitive type, use the standard cast operator;
  • If a single function "def toXYZ : Type" is defined within the type of value, call it;
  • If a single function "def toXYZ : T" where "T is a super type of Type" is defined, call it;O
  • Otherwise, use the standard cast operator.


Do you think this feature is practibable?

All the best.
Stéphane.


Prof. Stéphane Galland.
Belfort-Montbéliard University of Technologie, France.

http://www.multiagent.fr/People:Galland_stephane
http://www.sarl.io
http://www.arakhne.org

[Updated on: Mon, 05 March 2018 14:54]

Report message to a moderator

Re: What do you think about link cast operator to a "toX" function? [message #1782939 is a reply to message #1782935] Mon, 05 March 2018 13:41 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 602
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Hi Stéphane,

on first sight I like that idea. It is similar to the definition of operator methods. I think it makes sense to enter an issue for xtext-extras: https://github.com/eclipse/xtext-extras/issues and discuss it there.

~Karsten
Re: What do you think about link cast operator to a "toX" function? [message #1783384 is a reply to message #1782939] Mon, 12 March 2018 14:18 Go to previous message
Stephane Galland is currently offline Stephane GallandFriend
Messages: 120
Registered: July 2014
Location: Belfort, France
Senior Member
To follow up, the discussion on Github is: https://github.com/eclipse/xtext-extras/issues/236

Prof. Stéphane Galland.
Belfort-Montbéliard University of Technologie, France.

http://www.multiagent.fr/People:Galland_stephane
http://www.sarl.io
http://www.arakhne.org
Previous Topic:Resolve different parser rules dependency.
Next Topic:Unable to launch mwe2 workflow
Goto Forum:
  


Current Time: Sun Jun 24 13:21:40 GMT 2018

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

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

Back to the top