Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 356772

Summary: [Xbase] add shortcut feature call for 'apply'
Product: [Modeling] TMF Reporter: Sven Efftinge <sven.efftinge>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: enhancement    
Priority: P3 CC: knut.wannheden, moritz.eysholdt
Version: 2.0.0   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Sven Efftinge CLA 2011-09-06 03:56:08 EDT
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"
Comment 1 Moritz Eysholdt CLA 2011-09-12 08:48:39 EDT
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)"?
  }
}
--------------
Comment 2 Sven Efftinge CLA 2011-09-12 09:05:06 EDT
The non-sugarred version should be preferred.
Comment 3 Sven Efftinge CLA 2011-11-21 06:40:58 EST
This won't work for various technical reasons and generally sugar for applying functions doesn't seem to be important (little usage).
Comment 4 Knut Wannheden CLA 2011-11-21 06:48:21 EST
Too bad. Taking this one step further could have enabled transparent currying a la Haskell.