std.signals2 proposal
eskimo
jfanatiker at gmx.at
Tue Nov 6 05:39:08 PST 2012
On Tue, 2012-11-06 at 14:13 +0100, Jacob Carlborg wrote:
> > obj.signal.connect(() { /* my very funny delegate. */ })
> > which would compile with the standard implementation but would fail
> > badly at runtime.
>
> And why would it be bad to pass a delegate literal like this?
>
>
Because the connect method in std.signal interprets the context pointer
of the delegate to be an Object. If it is not, your program crashes. To
quote the author of _d_toObject (which is used in the original
std.signal):
/******************************************
* Given a pointer:
* If it is an Object, return that Object.
* If it is an interface, return the Object implementing the
interface.
* If it is null, return null.
* Else, undefined crash
*/
Object _d_toObject(void* p);
Also check out the bugs section in the html documentation:
http://dlang.org/phobos/std_signals.html
More information about the Digitalmars-d
mailing list