keita / selfish

Selfish introduces a prototipical object environment based on Self into Ruby.

This URL has Read+Write access

name age message
file LICENSE Loading commit data...
file README.rdoc
directory example/
directory lib/
directory spec/
README.rdoc

Selfish

Author:Keita Yamaguchi(山口 慶太) <keita.yamaguchi@gmail.com>
Copyright:© Keita Yamaguchi, 2008. All rights reserved.
License:Ruby License

Selfish introduces a prototipical object environment based on Self into Ruby.

Usage

Selfish is influenced by Self and similar to it very mush.

Selfish object

empty object

  Self: ()
  Selfish: _()

data slot "x" with 1

  Self: (|x <- 1|)
  Selfish: _(:x => 1)

object with parent slot "parent"

  Self: (|parent* <- ()|)
  Selfish: _(:_parent => _())

method

unary method

  Self: (|x <- 1. call = (x)|) call
  Selfish: _(:x => 1, :call => method { x }).call

with arguments

  Self: (|next: = (|:x| x + 1)|) next: 1
  Selfish: _(:next => method(:x) { x + 1 }).next 1

Slot

slot read

  Self: (|x <- 1|) x
  Selfish: _(:x => 1).x

slot write

  Self: (|x <- 1|) x: 2
  Selfish: _(:x => 1).x 2

Delegation

inheritance

  Self: (|parent* <- (|sum = (x + y)|). x <- 1. y <- 1|) sum
  Selfish: _(:_parent => _(:sum => method { x + y }), :x => 1, :y => 2).sum

multiple inheritance

  Self: (| p1* <- (|a = (1)|). p2* <- (|b = (2)|) |)
  Selfish: _( :_p1 => _(:a => method {1}), :_p2 => _(:b => method {2}))

Links