符合这些标准的编程语言
我需要一种编程语言(最好是可编写脚本的并且具有 JIT 将是一个优点,但这两个不是必需的),这将允许这样的事情(示例):
object
{
id;
new();
destroy();
}
info
{
descr;
}
event inherit object, info
{
trigger; //has id, descr, trigger
}
anon_event inherit event
{
- decr; //removes descr property, therefore anon_event has id, trigger, but NO descr
}
这将是特别好的,它还可以:
- 在创建时自动生成 id( new()),
- 允许指定读取哪些属性(成员)公共、私有、const
- 自动生成公共属性的 getter/setter(const 的 getter),
- 为 getter/setter 提供日志记录/回调设施,
- 允许选择属性(selectallprop(descr) 将选择具有 descr 属性的所有实例),并且在类型上 selectalltype(event) 将选择所有事件和 anon_events,即使成员不相同,
- 也允许运行时继承、添加/删除属性;
我认为这足以让我大致了解我正在寻找什么类型的语言。基本上,它是基于组件(作为组件成员的属性列表)或从另一个角度看没有共同祖先的多重继承。
谢谢你的提示
I need a programming language (preferably scriptable and having JIT would be a plus, but these two are not necessary), which would allow something like this (example):
object
{
id;
new();
destroy();
}
info
{
descr;
}
event inherit object, info
{
trigger; //has id, descr, trigger
}
anon_event inherit event
{
- decr; //removes descr property, therefore anon_event has id, trigger, but NO descr
}
It would be especially nice, that it could also:
- autogenerate id's on creation(new()),
- allow specify which properties(members) are read public, private, const
- autogenerate getters/setters for public properties (getters for const),
- have logging/callback facilities for getters/setters,
- allow select on property (selectallprop(descr) would select all instances with descr property) and on type selectalltype(event) would select all events and anon_events even if the members are not the same,
- allow runtime inheritance, addition/removal of properties;
I think this is enough to give a general idea what type of language I am seeking. Basically, it's a component(list of properties as component members) based or looking from another point of view multiple inheritance without common ancestor.
Thank you for your tips
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您所要求的将(1)违反里氏替换原则,这是面向对象编程的重要原则,并且(2)在实践中几乎不可能使用,因为从类中删除任意成员通常会导致与同一类中的其他成员一样的非编译或非功能代码在很大程度上取决于那些已删除的成员。
所以我想说的是:这整件事是个坏主意。
What you're asking for would (1) violate the Liskov Substitution Principle, an important tenet of object-oriented programming, and (2) would be almost impossible to use in practice, as removing arbitrary members from a class will very often lead to non-compiling or non-functional code as other members in that same class would much of the time depend on those removed members.
So what I'm saying is: this whole thing is a Bad Idea.