http://d.puremagic.com/issues/show_bug.cgi?id=7176
Nick Treleaven <ntrel-pub...@yahoo.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ntrel-pub...@yahoo.co.uk --- Comment #16 from Nick Treleaven <ntrel-pub...@yahoo.co.uk> 2013-03-20 07:15:30 PDT --- (In reply to comment #7) > I could really have a use for this. I have a lot of methods that just returns > a > single expression. I thought I'd add some hard data on this. There are quite a lot of these in Phobos (edited results to only show larger count items): $ git grep -Ec '\{\s*return\b' std/ std/algorithm.d:77 std/cpuid.d:27 std/format.d:35 std/functional.d:37 std/math.d:31 std/range.d:86 std/regex.d:44 std/traits.d:71 std/typecons.d:54 std/variant.d:23 std/xml.d:24 Admittedly, some of these may be false positives for e.g. lambdas, but a quick scan through the results shows they are almost all one line function/method definitions. I think this demonstrates a significant use case for the proposed syntax. > Another idea would be to allow optional braces for methods and functions, just > as for if-statements. That might not be ideal syntax with template constraints: void foo(T)(T v) if (isFoo!T) writeln(v); void foo(T)(T v) if (isFoo!T) => writeln(v); The second syntax is clearer in distinguishing the constraint from if statement syntax IMO. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------