Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xbase] Rewriting an expression to conform to expected type
[Xbase] Rewriting an expression to conform to expected type [message #699429] Thu, 21 July 2011 14:04
Eclipse UserFriend
Originally posted by:

Hi,

I've mentioned before that I'm fond of Scala's shorthand notation for
unary functions, e.g. _.name instead of o | o.name or [o | o.name]. The
argument against supporting something like this is that it has the same
syntax as an ordinary expressions, hence, you cannot parse it into a
closure object.

However, since Xbase supports type inference, it should be able to
notice that the context requires a (unary) function and do the rewrite.
I.e. rewrite myList.find(_.name==null) to myList.find(_|_.name==null)
when type inference shows that the expression's type (boolean) does not
match the expected function type. I suppose this could be generalized to
supporting rewriting an expression when types don't match, e.g. parse a
string to an int, etc.

Hallvard
Previous Topic:Grammar w. hundreds of message types
Next Topic:Troubles with content assist
Goto Forum:
  


Current Time: Sat Sep 19 15:46:13 GMT 2020

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

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

Back to the top