- 论坛徽章:
- 24
|
本帖最后由 zhujiang73 于 2011-09-08 19:09 编辑
回复 幻の上帝
... 委托?... 拜托,委托不就是函数指针么。C#因为没有函数指针这种东西才抽象出来 ...
captivated 发表于 2011-09-08 17:03
反射没用,看看我们的 GTK 做了什么,尽管代价大了点。
“It makes sense to build many kinds of applications using (at least) two different levels and languages. Those being C+GObject, and a managed (GC'd) runtime. C is good for graphics, multimedia, and lower level systems work. However, writing complex software is difficult and error-prone without garbage collection. A managed runtime such as Vala, JavaScript, Python, Java, Lua, .NET, Scheme etc. makes a lot of sense for non-fast-path application logic such as configuration, layout, dialogs, etc.
Thus, one of the major goals of the GObject introspection project is to be a convenient bridge between these two worlds, and allow you to choose the right tool for the job, rather than being limited inside one or the other. With the introspection project, you can write for example a ClutterActor or GtkWidget subclass in C, and then without any additional work use that class inside JavaScript.”
关于“委托”,话就更长了,参见:成员函数指针与高性能的C++委托 http://www.cnblogs.com/jans2002/archive/2006/10/13/528160.html
对了 int pthread_create(pthread_t *restrict tidp,
const pthread_attr_t *restrict attr,
void *(*start_rtn)(void),
void *restrict arg);
如果 void *(*start_rtn)(void) 是一个委托,C++ 的线程世界就清净了。 |
评分
-
查看全部评分
|