基于原型编程

面向对象编程的一种风格和方式。在原型编程中,行为重用(在基于类的语言通常称为继承),是通过复制已经存在的原型对象的过程实现的。这个模型一般被认为是无类的、面向原型、或者是基于实例的编程。

原型编程最初的(也是最经典的)例子是编程语言 Self,它是由 David Ungar 和 Randall Smith 开发的。但是无类编程方式最近变得越来越受欢迎,并且被 JavaScript、Cecil、NewtonScript、Io、REBOL,还有一些其他的程序语言所采纳。

prototypal, prototype-oriented, classless, or instance-based programming, a style of object-oriented programming in which behaviour reuse (known as inheritance) is performed via a process of reusing existing objects that serve as prototypes.

Support

  • ecmascript
    • ActionScript 1.0, used by Adobe Flash and Adobe Flex
    • E4X
    • javascript
    • JScript
    • TypeScript
  • Lua
  • Perl, with the Class:Prototyped module
  • Python with prototype.py.
  • Ruby (programming language)