Vala Tutorial有一个example about DBus using anonymous methods。
Bus.own_name (BusType.SESSION, "org.example.DemoService", /* name to register */
BusNameOwnerFlags.NONE, /* flags */
on_bus_aquired, /* callback function on registration succeeded */
() => {}, /* callback on name register succeeded */
() => stderr.printf ("Could not acquire name\n")); /* callback on name lost */我正在尝试用Genie重写这段代码,但无法成功转换最后两行。Genie Tutorial只有an example on how to use a closure to define an event handler。
f.my_event += def (t, a)
print "event was detected with value %d", a如何在Genie的方法调用中使用匿名方法定义?
发布于 2015-02-09 22:56:26
我认为这是不可能的。您必须使用"def“调用另一个进程。
Bus.own_name (BusType.SESSION, "org.example.DemoService",
BusNameOwnerFlags.NONE,
on_bus_aquired,
reg,
err);
def reg()
pass
def err()
print "error"发布于 2015-07-14 18:23:00
这在目前是不可能的:
https://bugzilla.gnome.org/show_bug.cgi?id=746704
目前只支持过时的lambda信号语法(+=)。这个补丁在大多数构造中提供了lambda支持,唯一的要求是大括号和括号需要在多个行构造上缩进平衡。
https://stackoverflow.com/questions/24352222
复制相似问题