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
Stéphane Galland is currently offline Stéphane GallandFriend
Messages: 123
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.

[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: 762
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
Stéphane Galland is currently offline Stéphane GallandFriend
Messages: 123
Registered: July 2014
Location: Belfort, France
Senior Member
To follow up, the discussion on Github is: https://github.com/eclipse/xtext-extras/issues/236
Previous Topic:Resolve different parser rules dependency.
Next Topic:Unable to launch mwe2 workflow
Goto Forum:
  


Current Time: Fri Apr 19 11:16:05 GMT 2024

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

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

Back to the top