[Xbase] Rewriting an expression to conform to expected type [message #699429] |
Thu, 21 July 2011 14:04 |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03684 seconds