http://d.puremagic.com/issues/show_bug.cgi?id=2753
------- Comment #3 from s...@iname.com 2009-03-22 16:50 ------- (In reply to comment #2) > judging from compiler error messages, ref is not a type modifier, it's a > function attribute, so brackets won't help. I'm a little confused - if that were the case, surely it would work? Moreover, what is there preventing ref from becoming a type modifier, if this would fix the problem? It should also be noted, that > others function attributes' grammar is also ambiguous. > --- > nothrow int function() foo(); > --- > What is nothrow here? So there's actually an advantage to the suffix notation for function attributes. > --- > const int foo(); > --- > What is const here? > > --- > int foo(ref int function() goo); > --- > This one would probably give no error. But that is a case that really is ambiguous. > Is it keyword saving issue? Semantically different things have the same > syntax. > If Walter wants context-dependent keywords, he should mark those contexts > better. > I would like to see function attributes at predictable, easy-to-spot > locations, > so it would be no chanse to mess storage class with function attributes. There > are already good places for function attributes (after function) and storage > class attributes (before type). If the attributes will be restricted to > corresponding places, there will be no ambiguity (except const). > --- > int foo(ref int function() goo); //ref parameter > int goo(int function() ref foo); //return byref function > --- I don't really like this. The ref essentially means the same thing, it's just whether it applies to the parameter or the return. In the latter, it's being moved further from what it applies to: the return type. IIRC, the equivalent C++ syntax is int foo(int (*&goo)()); // ref parameter int goo(int& (*foo)()); // ref return in parameter It isn't exactly clear, but at least it's unambiguous. If D got the & notation for reference, we would have int foo(int function()& goo); // ref parameter int goo(int& function() foo); // ref return in parameter Indeed, we could have ref take the place of & in this notation int foo(int function() ref goo); // ref parameter int goo(int ref function() foo); // ref return in parameter and so the syntax of ref/& would become consistent with that of *. We could do it like this, or we could make ref a type modifier along the lines of const. Take your pick. --