Jackalope - Javascript with Antlers

( actually, coffeescript... )

A short quiz

    
var n = 'foo' / 2
typeof n == ...
    
    

'number'

    
var n = ''
n % 2 = ...
    
    

0

    
var n = null
typeof n == ...
    
    

'object'

    
var a = []
typeof a == ...
    
    

'object'

...better use instanceof Array

Simple type checks

    
// check for integer
( typeof n == 'number' && n % 1 == 0 )

// is it a simple (anonymous) object?
!!(value && toString.call(value) == "[object Object]" && value.__proto__ == Object.prototype)
    
    

And what was that again with undefined or null and ===

We need constraints!

Jackalope is a set of mixins that add an API inspired by Moose, the object system for perl, to coffeescript classes and javascript objects.
( It borrows all the best features from Perl 6, CLOS (Lisp), Smalltalk, Java, BETA, OCaml, Ruby and more )

CoffeeScript invents some good ideas and steals many others. The number one source I could identify for the most useful ideas in CoffeeScript? Perl.

Yes, Perl. The language that's guaranteed to produce an audible gasp if mentioned in civilized programming circles today.

Yet for ten solid years, Perl was a petri dish of syntactic innovation.

-- Geoffrey Grosenbach (coffeescript-in-motion)

Declarative interface:

Non-native types:

Runtime typechecks in constructor

Lazy initialization, method generation, triggers:

Status

Code:
https://github.com/mvhenten/Jackalope
Wikipedia:
http://nl.wikipedia.org/wiki/Jackalope
The jackalope conspiracy:
http://www.sudftw.com/jackcon.htm
“Legend also has it that female jackalopes can be milked as they sleep belly up and that the milk can be used for a variety of medicinal purposes”