Feature request: one-statement functions without brackets
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Mon Apr 2 02:37:14 PDT 2007
Downs wrote:
> Feature request: Allow functions of the form function-declaration
> statement;
> Example: int test() return 5;
>
> This would make the function syntax closer to the way if/else, while,
> for and similar
> statements' blocks are handled now, potentially making parsing easier.
> It would
> also help with internal consistency.
> Also, it would allow methods like void test() synchronized(this) { },
> which to me just
> looks cleaner than using brackets to contain a single statement.
> I couldn't immediately imagine a case where this syntax might lead to an
> ambiguity; if
> there is, I'm sorry.
>
> -- awaiting feedback, downs
Ambiguity:
---
void foo()(T);
---
No-implementation declaration of a no-template-argument template
function that takes a T, or no-argument function that evaluates "T"?
Of course, the practical use of a no-implementation template function
declaration may be limited enough (is there any at all?) that banning it
may not be much of a problem...
More information about the Digitalmars-d
mailing list