FlexSignal updated too (Re: sslot version 0.2)
Lutger
lutger.blijdestijn at gmail.com
Sat Nov 18 06:26:58 PST 2006
Bill Baxter wrote:
> In the mean time, I've also updated FlexSignal to support connecting a
> function like:
> bool foo_slot(char[] s) { ... }
>
> to the signal:
> FlexSignal!(int, char[], float);
>
> I.e. the foo_slot can be connected to only get the char[] argument if
> that's all it's interested in. Unfortunately the syntax for this is a
> little cumbersome right now due to bug #540:
>
> thesignal.fconnect!(typeof(&foo_slot),1)(&foo_slot);
>
> When/if #540 is fixed this can become:
>
> thesignal.fconnect!(1)(&foo_slot);
>
> The '1' indicates foo_slot wants to skip the 1st argument emitted by the
> signal.
It's sort of a reverse bind? Would it be possible to write a seperate
adapter so it could be used with std.signals and allow for garbage
collection / deletion before disconnection?
Boost::signals works nicely with boost bind like this but it's a little
less flexible iirc.
Something like this perhaps:
thesignal.connect(adapt(thesignal, &foo_slot, 1));
and / or more concise:
connect(thesignal, &foo_slot, 1);
btw. there is a way to get the type of the .ptr property of a delegate
but I was reluctant to use it as it seemed a little too hackish:
http://www.digitalmars.com/d/archives/digitalmars/D/learn/delegate_type_info_5001.html
More information about the Digitalmars-d-announce
mailing list