Skip to main content



      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 07:52 Go to next message
Eclipse UserFriend
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 09:54] by 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 08:41 Go to previous messageGo to next message
Eclipse UserFriend
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 10:18 Go to previous message
Eclipse UserFriend
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 Jul 25 01:40:58 EDT 2025

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

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

Back to the top