Skip to content

neverblued/js-clos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JS-CLOS

Javascript object system inspired by Common Lisp.

Example

Symbols, generics and methods:

new clos.symbol('hard');
new clos.symbol('brittle');

new clos.generic('bump');

new clos.method(clos.generics['bump'], [
	clos.symbols['brittle'],
	clos.symbols['hard']
], function(brittle, hard){
	return 'crash';
});

Inheritance:

new clos.symbol('floor', ['hard']);
new clos.symbol('glass', ['brittle']);

Types:

ok(clos.is(42, clos.number),
	'42 is ' + clos.number);

Classes:

var hard = clos.symbols['hard'];
var floor = clos.symbols['floor'];
var glass = clos.symbols['glass'];

ok(clos.is(floor, hard),
	floor + ' is ' + hard);

Action:

var bump = clos.generics['bump'].lambda();

equal(bump(glass, floor), 'crash',
	bump + ' ' + glass + ' and ' + floor + ' is crash');

Test

npm test

About

Common Lisp Object System on JavaScript (sketch)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published