项目作者: marcoonroad

项目描述 :
Concatenation-based prototypes implementation for Lua. :microscope: :crescent_moon: :family_man_woman_girl_boy: :house_with_garden:
高级语言: Lua
项目地址: git://github.com/marcoonroad/families.git
创建时间: 2017-08-04T04:56:41Z
项目社区:https://github.com/marcoonroad/families

开源协议:MIT License

下载


families

Concatenation-based prototypes implementation for Lua.

















Topics/Sections

  • Installation
  • Introduction
  • Usage
  • Why???
  • Further Information

Installation

Through Luarocks:

  1. $ luarocks --local install families

Through this project root directory:

  1. $ luarocks --local make

Introduction

This is a simple but somehow pure OO framework for the Lua language. Pure in the
sense cause it discards delegation entirely, but still preserving object inheritance
feel of Self/JavaScript. Such kind of delegation-less prototypes are known as
concatenative prototypes. They’re implemented on the Kevo language together with some
features called module operations, which are in some sense akin to the well-known trait
operators.

Concatenative Cloning

Because I already have implemented a library for software composition
here, I’m reserving myself to implement just
concatenation into this library. Besides, I
am free here to focus on concatenative object inheritance and also free to optimize that
fast as hell. The current state of this library is simple yet, however. Despite the removal
of delegation, it’s planned to provide it in fine-grained & specific ways through a concept
known as First-Class Delegation Links.

Usage

The API was designed to be simple and minimal. To create an object in this library, we’ll
use the function clone existing in the families module:

  1. local families = require "families"
  2. -- yadda yadda yadda --
  3. local object = families.clone (prototype, structure)

Where prototype is a previously created object and structure is where object differs
from its prototype. The prototype can be nil, and an alias is provided as well for such
cases:

  1. local prototype = families.prototype (structure)

So, the equivalent relations are:

  1. families.prototype (structure) <===> families.clone (nil, structure)

Where structure is the table which contains the whole definition for prototype.

Why???

I just want to Clone early and Clone often without the burden of Delegation in the middle of
path. Said that, I just want also to leverage the promising prototype-based programming with the whole
benefits from concatenative prototypes carried together. This library aims to provide a scalable,
fast/efficient and easy to reason prototype-based OO framework. Yet, it will be kept as simple as possible.
In the end, it will be easy to learn, to prototype, to debug and to extend (without the fear of breaking things
as it occurs on either delegative or class-based world).

Further Information

For more information, check out our wiki made with love!

Happy hacking!