digitalmars.D - Casting between delegates with qualified value type parameters
- Sean Eskapp (20/20) Jan 20 2011 Delegates cannot be cast from one type to another, even if the only diff...
- Daniel Murphy (5/6) Jan 23 2011 Sounds like it could be http://d.puremagic.com/issues/show_bug.cgi?id=37...
Delegates cannot be cast from one type to another, even if the only difference in type is the qualifiers on value type parameters. However, the same code works fine with functions instead of delegates, as such: import std.stdio; void foo(void function(int) bar) { bar(5); } void foobar(void delegate(int) bar) { bar(5); } void main() { foo (function(int i) { writeln(i); }); // OK foo (function(immutable int i) { writeln(i); }); // OK foobar(delegate(int i) { writeln(i); }); // OK foobar(delegate(immutable int i) { writeln(i); }); // error } Is there a reason for this, or is it a bug?
Jan 20 2011
"Sean Eskapp" <eatingstaples gmail.com> wrote in message news:ih9rhr$2c1k$1 digitalmars.com...Is there a reason for this, or is it a bug?Sounds like it could be http://d.puremagic.com/issues/show_bug.cgi?id=3797 All sorts of implicit conversions are currently allowed between function pointers that shouldn't be.
Jan 23 2011