Re: [Vala] anonymous functions



On Tue, 2008-07-15 at 11:11 +0100, Sam Liddicott wrote:
* Ali Sabil wrote, On 15/07/08 10:47: 

Signal handler always have the "signal sender" as 1st parameter, in
this case it would be the AdvancedSample instance from which the
"foo" signal originated.

I proposed the "sender" keyword inside signal handler context (just
like the "this" keyword inside the object instance context) to
eliminate this confusing parameter a while ago, but it didn't seem
like a good idea for many people.

Hmmm... this makes me feel uncomfortable in the same way the glade
example callbacks make me feel uncomfortable, there seem to be
implicit parameters which are not defined in the prototypes, you just
have to "know", the s was not referenced in the foo signal declaration
either. 

The issue is that the sender parameter, that all signal handlers have,
is not a signal parameter, it's really just a signal handler parameter.
When emitting the signal (and soon also in virtual signal methods),
there is no sender parameter as `this` is the same as the sender.

I don't quite understand what exactly makes you feel uncomfortable, the
fact that you don't have to specify the sender when declaring the
signal, the proposed sender keyword, or something else?

Is this anonymous signal handler invoked as a flat function or method?
Does "this" have a value (I guess it does or the use of name would
fail) in which case, surely s must be declared somewhere else...

It's invoked as an instance method. The example is a bit special in that
the same instance emits and handles the signal. In general `this` and
the sender are two separate objects. `s.name`, `this.name`, and `name`

Juerg




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]