Community
Participate
Working Groups
It should be possible to omit the dot and the name of a feature call if an expession's type provides a matching method with the name 'apply'. Such that the following could evaluates to true: [String s | s.toUpperCase]("foo") == "FOO" and would be the same as [String s | s.toUpperCase].apply("foo") == "FOO"
How would we handle these cases? ---- Java --- class Item { public Item apply(String foo) {} } ------------- ---- Xtend --- class Foo { def Item item() {} def Item item(String foo) {} def curious { item("x") // does this map to "item(String)" or "item().apply(String)" item("a")("b")("c") // does this map to "...apply(String).apply(String)"? } } --------------
The non-sugarred version should be preferred.
This won't work for various technical reasons and generally sugar for applying functions doesn't seem to be important (little usage).
Too bad. Taking this one step further could have enabled transparent currying a la Haskell.