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

Re: [Vala] self-less delegates



On Mon, May 26, 2008 at 6:49 PM, Juerg Billeter <j bitron ch> wrote:
>
> Delegates are often declared outside classes but still used for instance
> methods, so we don't want to default to no context there. However, I agree
> that the `static' modifier can be misleading as it usually has a slightly
> different meaning. That's why I'd like to replace it by an attribute, see
> http://bugzilla.gnome.org/show_bug.cgi?id=526549
>

This change looks good to me, since it seems that non-static delegates
can still be used for methods outside instances, i.e.

using GLib;

delegate void MyDelegate(int a);

void blah(int a) {
        stdout.printf("%d\n", a);
}

int main(string[] args) {
        MyDelegate d = blah;
        d(5);
        return 0;
}


So the only real use case for static delegates is C bindings as you
write in the bug report.

I was just about to write a patch for you but it looks like it would
only be about 2 lines anyway. :)

Cheers,
Jared


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