YASOS-like object system based on association lists
Jason K. MacDuffie 9b78889be5 add protocol and simplify-object | %!s(int64=6) %!d(string=hai) anos | |
---|---|---|
.gitignore | %!s(int64=6) %!d(string=hai) anos | |
LICENSE | %!s(int64=6) %!d(string=hai) anos | |
README.md | %!s(int64=6) %!d(string=hai) anos | |
alsos.body.scm | %!s(int64=6) %!d(string=hai) anos | |
alsos.sld | %!s(int64=6) %!d(string=hai) anos |
This is an object system based on YASOS using association lists instead of disjoint objects.
(define-operation (opname self arg ...) default-body)
(define-predicate opname)
(object ((name self arg ...) body) ... )
(object-with-ancestors ( (ancestor1 init1) ...) operation ...)
;; in an operation {a.k.a. send-to-super}
(operate-as component operation self arg ...)
> (import (macduffie alsos))
> (define-predicate instance?)
> (define-operation (instance-dispatcher obj)
0)
> (define (make-instance dispatcher)
(object
((instance? self) #t)
((instance-dispatcher self) dispatcher)))
> (define x (make-instance 100))
> (instance? x)
#t
> (instance-dispatcher x)
100
> (instance? "Not an instance")
#f
> (instance-dispatcher "Not an instance")
0
LICENSE: MIT (Expat) license. See LICENSE for details.