"I have a mind like a steel... uh... thingy." Patrick Logan's weblog.

Search This Blog

Wednesday, March 16, 2011

Bouncing Back

Over the years whenever I've wanted to learn a new programming language, the first significant application I've tried is a Scheme interpreter. Many (most?) Scheme interpreters on the web don't implement call-with-current-continuation and often do not handle tail calls well (i.e. they blow the implementation language's stack).

It's not hard to implement these things using simple mechanisms, but the simple mechanisms are not widely known. And as it happens, implementing these two very mechanisms tell you a lot about the implementation language. (Primarily because most languages have neither, and most languages do not have closures, and so you have to go to widely varying lengths to implement these two things.)

I've wanted to try out Javascript on a "significant" application. So below is a link to NCONC, which uses "trampoline style" to trampoline a "continuation-passing style" interpreter written in Javascript. I have a reasonable start on docco-style comments which I will put up asap. I presented this at pdxfunc last Monday and will use my memory of that to write more. 8^D

Note since I have only put in (parts of) a couple of weekends, and my only interest has been illustrating trampolines and call-with-current-continuation, you will not yet find more than a handful of implemented standard procedures. (Enough to run some tests.) And you will not find display so no printing yet. Oh, and no macros yet! But you do have call/cc.

https://github.com/patrickdlogan/nconc

Suggestions for better Javascript style are welcome too. I have a few in mind already, but people wanted to see the code. So.

No comments:

Blog Archive

About Me

Portland, Oregon, United States
I'm usually writing from my favorite location on the planet, the pacific northwest of the u.s. I write for myself only and unless otherwise specified my posts here should not be taken as representing an official position of my employer. Contact me at my gee mail account, username patrickdlogan.