哪些语言提供对象文字的使用?
哪些语言提供对象文字的使用? (或者你可以用什么语言轻松模拟它们?)你能给出一个代码示例吗?
从明显的 javascript 片段开始:
var someObj = {
someProperty: 123,
someFunction: function() {
alert('hello!');
}
};
What languages provide the use of object literals? (Or in what languages could you easily emulate them?) Can you give a code example?
Starting with the obvious javascript snippet:
var someObj = {
someProperty: 123,
someFunction: function() {
alert('hello!');
}
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看 C# 匿名类型
Checkout C# anonymous types
如果用“term”替换 object,那么 Prolog 会自然地执行此操作(事实上,没有其他方法来构造对象)。这是一个以二叉树为特色的示例:
Lisp 和Scheme 在该领域也有一些相当先进的功能,特别是引用和半引用:
实际上所有函数式编程语言都以某种形式复制了这一点。
If you replace object by "term," then Prolog does this naturally (in fact, there's no other way to construct an object). Here's an example featuring binary trees:
Lisp and Scheme also have some pretty advances features in this area, particularly quoting and semiquoting:
Practically all functional programming languages have copied this in some form.