目前有哪些语言支持 mixins?

发布于 2024-08-27 23:36:23 字数 34 浏览 6 评论 0原文

显然是 Ruby 和 Sass,但是还有哪些其他的呢?

Well obviously Ruby and Sass, but what are some other ones?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

奢望 2024-09-03 23:36:23

Wiki 有一个列表

http://en.wikipedia.org/wiki/Mixin#Programming_languages_that_use_mixins

引用:

使用 mixin 的编程语言

除了口味和 CLOS(一部分
Common Lisp),一些使用的语言
mixin 是:

* ColdFusion (Class based using includes and Object based 
  by assigning methods from one object to another at runtime)
* Curl(with Curl RTE)
* D (called "template mixins")
* Factor[citation needed]
* Fantom
* Ioke
* JavaFX Script
* JavaScript
* Object REXX
* OpenLaszlo
* Perl[3]
* PLT Scheme (mixins documentation)
* Python
* Ruby
* Scala
* Smalltalk
* Strongtalk
* Vala
* Visual Dataflex
* XOTcl/TclOO (object systems for Tcl)[4]

一些语言,例如 ECMAScript
(通常称为JavaScript)
不支持该语言的 mixin
水平,但可以很容易地模仿它们
将方法从一个对象复制到
另一个在运行时,从而
“借用”mixin 的方法。笔记
这是不可能的
静态类型语言,其中
对象的签名在编译时固定
时间。

Wiki has a list

http://en.wikipedia.org/wiki/Mixin#Programming_languages_that_use_mixins

To quote:

Programming languages that use mixins

Other than Flavors and CLOS (a part of
Common Lisp), some languages that use
mixins are:

* ColdFusion (Class based using includes and Object based 
  by assigning methods from one object to another at runtime)
* Curl(with Curl RTE)
* D (called "template mixins")
* Factor[citation needed]
* Fantom
* Ioke
* JavaFX Script
* JavaScript
* Object REXX
* OpenLaszlo
* Perl[3]
* PLT Scheme (mixins documentation)
* Python
* Ruby
* Scala
* Smalltalk
* Strongtalk
* Vala
* Visual Dataflex
* XOTcl/TclOO (object systems for Tcl)[4]

Some languages like ECMAScript
(commonly referred to as JavaScript)
do not support mixins on the language
level, but can easily mimic them by
copying methods from one object to
another at runtime, thereby
"borrowing" the mixin's methods. Note
that this is not possible with
statically typed languages, where an
object's signature is fixed at compile
time.

失而复得 2024-09-03 23:36:23

Perl 的 角色 可以称为 mixins。

Perl's Roles could be called mixins.

岁月如刀 2024-09-03 23:36:23

_why 的 potion 语言跃入脑海。这个想法是对象有状态和方法。在大多数语言中,状态发生在对象中,方法发生在类中。在 Potion 中,对象只有状态,方法完全由 mixin 处理。

引用自述文件

一切都是对象。甚至
Mixin 是对象。当然,
闭包是对象。

但是,对象并不是一切。
如果没有 mixins,它们就毫无用处。

顺便说一句,我想念为什么。我们需要更多的人做这样的疯狂事情

_why's potion language leaps to mind. The idea is that objects have state, and methods. In most languages, state happens in the object, methods happen on the class. In potion, objects have only state, methods are completely handled with mixins.

To quote from the readme

EVERYTHING IS AN OBJECT. EVEN
MIXINS ARE OBJECTS. AND, OF COURSE,
CLOSURES ARE OBJECTS.

However, OBJECTS AREN'T EVERYTHING.
THEY ARE USELESS WITHOUT MIXINS.

on a side note, I miss why. we need more people doing wild stuff like this

几味少女 2024-09-03 23:36:23

好吧,当然是风味。这演变成了CLOS

Well, Flavors of course. This morphed into CLOS.

沙与沫 2024-09-03 23:36:23

JavaScript 支持它们。您可以随时向对象的原型添加函数/字段。

JavaScript supports them. You can add functions/fields to an object's prototype anytime.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文