It compiles a major subset of Apple's Dylan (http://lispm.dyndns.org/documentation/prefix-dylan/book.anno...) to JavaScript, both for use on a CommonJS implementation and in the browser. A bootstrapping compiler is implemented in JS, but the same compiler is also available in Ralph itself and features define-macro (Cl-like). The whole runtime is defined in Ralph as well and provides a single-inheritance object system (including next-method): https://github.com/turbolent/ralph/blob/master/src/runtime/c...
Almost all of the features are shown in https://github.com/turbolent/ralph/blob/master/src/tests/run... and I'm using it a project now. To build HTML5 apps, there's a small toolbox: https://github.com/turbolent/toolbox
Maybe it's useful to someone else. Cheers
The current one is single-inheritance, because it uses the prototype chain. It's a compromise between speed and usefulness. I'd prefer having multimethods (and maybe also multiple inheritance), but speed is a bit more important, as JavaScript is already quite slow.
So far I'm quite pleased with the single-inheritance and single dispatch solution, which basically works like that: https://gist.github.com/866506
As I needed a name, I just chose "Ralph" as that was the original code-name of Dylan (see http://en.wikipedia.org/wiki/History_of_the_Dylan_programmin...). I'm currently implementing a web-based IDE for the OpenDylan compiler (http://www.opendylan.org/), called "Hula" (original code-name of Apple's IDE, see http://wiki.opendylan.org/wiki/view.dsp?title=AppleDylanScre...). The work-in-progress is at https://github.com/turbolent/hula.
If you're interested in a demo, let me know.
> (+ 1 1 1 1)
=> 2
> (* 3 4 5 6)
=> 12
Does it only consider the first and second items in a list?https://github.com/jcoglan/fargo/blob/master/source/fargo/li...
Other than being obviously new, this is pretty cool.
Edit: Would there be a better way to fix it than to add functions like this?
function adder() {
var args = Array.prototype.slice.call(arguments);
return args.reduce(function(a, b){return a + b})
}
function subtractor() {
var args = Array.prototype.slice.call(arguments);
return args.reduce(function(a, b){return a - b})
}
function multiplier() {
var args = Array.prototype.slice.call(arguments);
return args.reduce(function(a, b){return a * b})
}
function divider() {
var args = Array.prototype.slice.call(arguments);
return args.reduce(function(a, b){return a / b})
}
(I haven't really put too much thought into this, but would love to hear of stronger approaches or obvious bad ideas in this one) (define (count x)
(let loop ((x x) (sum 0))
(if (zero ? x)
sum
(loop (- x 1) (+ sum x)))))
(count 100000) ; ==> 5000050000 (doesn't blow up)
I'm very tempted to help out however I can. I've been dreaming of using Scheme instead of JS in a Node.js setting.(cdr ()) makes it explode. What's nil? null nil don't exist
I do really like this. I was hoping for something like this where it would allow me to write lisp instead of javascript.
They also require the user to explicitly start a fiber. This means when you're not in a fiber you can use a faster stackless engine because you don't need to track the state of the current continuation.
Fair point.
BTW what's interesting about yield based versus lazy evaluation (functional stream) based sequence generation? Advantages of the latter are that they can easily be understood as sequences and thus further processed by lazy versions of the known sequence processing functions (map etc.), also they can be re-read multiple times, which you just made impossible for yield by not basing it on call/cc :).
It is expected to be released very soon for Javascript (and Scheme).
[1]: http://news.ycombinator.com/item?id=1921347
[2]: https://groups.google.com/group/qilang/msg/bd474d815479b50a?...
Although, I don't know that those things make it more practical than Scheme. Just more desirable to a subset of people who like that sort of thing.