[Issue 3075] void delegate(const(void)[]) should be implicitly convertable to void delegate(void[])
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jul 3 01:09:33 PDT 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3075
Walter Bright <bugzilla at digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #4 from Walter Bright <bugzilla at digitalmars.com> 2009-07-03 01:09:32 PDT ---
The actual rule for matching a delegate against a type is that the delegate is
covariant with the type. The return type is checked for covariance, and things
like a pure function is considered covariant with an impure one. This works
exactly the same as overriding a virtual function with a covariant one.
What you're asking for with the const parameters is contravariance.
Contravariant parameters are a good idea until overloading is considered. If
you have two functions, one with a const parameter and the other mutable, which
one overrides the base virtual function? You could say overriding is based on a
'best match', but things are complex enough without throwing that into the mix.
So, it is by design that the parameter lists must match exactly for covariant
functions. I also think it is not a good idea to have one covariant matching
rule for overriding, and another for implicit conversions. Better to have one
covariant rule.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list