On Wed, 20 Feb 2013 21:50:01 -0500, deadalnix <[email protected]> wrote:
On Wednesday, 20 February 2013 at 13:42:48 UTC, Steven Schveighoffer
wrote:
On Wed, 20 Feb 2013 01:00:00 -0500, deadalnix <[email protected]>
wrote:
As discussed previously, I really wonder hy a const and non const
version of a function can exists in a first place. What problem does
it solve that isn't better solved by inout ?
const(T) and T are different types. Saying you can overload on types,
unless they just vary by const is a special case that I don't think is
worth adding.
Explain me how the hell you overload on implicit parameter types ?
A method is simply a function that takes a hidden parameter of an object
or struct.
Really, a method with a signature Obj.foo() is a function with a signature
foo(Obj this)
A const method Obj.foo() const is a function with a signature
foo(const(Obj) this)
So it's equivalent to saying you can overload:
foo(int *x)
foo(const(int) *x)
To disallow this would be unnecessarily restrictive.
-STeve