Re: [Vala] Base class constructor
- From: Jürg Billeter <j bitron ch>
- To: Ondřej Jirman <megous megous com>
- Cc: vala paldo org
- Subject: Re: [Vala] Base class constructor
- Date: Fri, 25 Aug 2006 23:43:23 +0200
On Fre, 2006-08-25 at 22:59 +0200, Ondřej Jirman wrote:
Thank you for your reply. It helped. Distinction between construction
methods and constructors was nonobvious to me.
Understandable, I'm still open to ideas how it could be made more
intuitive while still obeying the GObject principles.
I will try to port my package selector for slackware that is written in
C++ (gtkmm) to vala and give some feedback if I found something
interesting that may be of any use to vala (bugs, feelings, etc.).
Sounds nice, porting real applications is certainly the right way to get
Vala ready.
I have question about use of lamda functions to handle signals thrown by
GTK+ objects. I can't get it to work. I don't know what I'm doing wrong.
I've tried to use it the same way as it is used in test-18.vala.
Instead of 'close_button.clicked += on_close_clicked' in the hello world
example I use:
close_button.clicked += (close_button) => {
hide();
};
And valac fails to compile it with error:
pkgsetup.vala:58.46-58.47: error: syntax error, unexpected =>,
expecting ;
pkgsetup.vala:60.8-60.8: error: syntax error, unexpected ;
pkgsetup.vala:71.1-71.1: error: syntax error, unexpected }
Compilation failed: 3 error(s), 0 warning(s)
Is this just not yet implemented or am I doing something wrong again?
The parser doesn't support the syntax
(param1) => expression
yet. You have to omit the parentheses if the handler expects exactly one
parameter, i.e.
param1 => expression
or
() => expression
or
(param1, param2, ...) => expression
should be fine. Note that the number of parameters in the signal handler
have to match exactly at the moment. Although the compiler already
accepts handlers with less parameters, IIRC, it will most likely crash
your application; this will be officially supported in a later version.
BTW, how is determined type of arguments passed to the lambda function?
Is it from the type of arguments I am passing to it or is it from the
context I am using it in? Like callback function type or signal
declaration.
It's determined from the context, i.e. the signal declaration in this
case.
Regards,
Jürg
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]