[Issue 7176] Lambda => syntax for function and methods too

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Mar 20 06:13:25 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=7176



--- Comment #15 from bearophile_hugs at eml.cc 2013-03-20 06:13:22 PDT ---
After having used Scala a little, I now have changed my mind a little again.

In Scala you write:

def f3(x: Int, y: Int): Int = if (x == 0) x else x * y


This is current valid D code:

int f1(int x, int y) { return (x == 0) ? x : x ^^ 2; }

const f2 = (int x, int y) => (x == 0) ? x : x ^^ 2;



Allowing this in D is nice to reduce some syntax noise. So I now like this
idea:

int f4(int x, int y) => (x == 0) ? x : x ^^ 2;


In functional-style programming very short functions are common.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list