www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - UFCS-style invocation of lambdas

reply "Peter Alexander" <peter.alexander.au gmail.com> writes:
Would this be possible without breaking the grammar?

bool isPalindrome = getRange().(r => equal(r, retro(r)));


I find this way of writing that expression more natural and 
efficient than the alternatives:

auto r = getRange();
bool isPalindrome = equal(r, retro(r));

or

bool isPalindrome = (r => equal(r, retro(r)))(getRange());
Jan 25 2013
parent Timon Gehr <timon.gehr gmx.ch> writes:
On 01/25/2013 10:37 PM, Peter Alexander wrote:
 Would this be possible without breaking the grammar?

 bool isPalindrome = getRange().(r => equal(r, retro(r)));

Yes.
 I find this way of writing that expression more natural and efficient
 than the alternatives:

 auto r = getRange();
 bool isPalindrome = equal(r, retro(r));

 or

 bool isPalindrome = (r => equal(r, retro(r)))(getRange());

bool isPalindrome = getRange().ap!(r => equal(r, retro(r))); where auto ap(alias a,T...)(T b)=>a(b);
Jan 25 2013