[Issue 12931] Make const, immutable, and inout illegal as funtion attributes on the left-hand side of a function
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Jun 23 20:35:10 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12931
Steven Schveighoffer <schveiguy at yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |schveiguy at yahoo.com
--- Comment #4 from Steven Schveighoffer <schveiguy at yahoo.com> ---
(In reply to Jonathan M Davis from comment #0)
> The reason that's usually given as to why const is legal on the left-hand
> side is because all function attributes can go on either side of the
> function, and it would be inconsistent to disallow const, immutable, or
> inout on the left. But that's not even true! As issue# 12930 shows, static,
> private, public, package, and protected are all illegal on the left.
You mean "illegal on the *right*"
Some questions:
these are currently also legal and equivalent to your example:
const: Bar foo() {...}
const{ Bar foo() {...} }
Those OK or not? I'd say yes, because the only really confusing one is where
the const seems to apply to Bar. In those cases, const looks more like a
class-level attribute, and don't appear to apply to the return type.
Come to think of it, this is also not ambiguous:
const void foo() {...}
But I think this should also be disallowed for consistency
Also, shared is in this category, as it is a type constructor.
9 votes in 7 days, must be some sort of record :) I'll add mine shortly. I
would guess that there would be zero
--
More information about the Digitalmars-d-bugs
mailing list