Repeat from the sign
See the code#Dal Segno
Write games, see your changes immediately: every time you change your code, Dal Segno rewinds your game back to the last time that piece of code was run.
#Language
It's sort of like Scheme.
;semicolons make the rest of a line a comment
(define x 10) ;var x = 10
(defn recur () ;named function definitions are global
(color 100 200 100) ;sets the color to be used
;for future draw operations
(fillRect 0 0 width height) ;this is the canvas
;context drawing operation
(color 0 0 230)
(drawArc x 100 111) ;queues a circle to be drawn
(render) ;actually paints queued drawings
(set! x (+ x .1)) ;change var wherever it was defined
(if (> x 300) ;you've got if, set!, define, defn,
(set! x 0)) ;and lambda - that's it for special forms
(recur)) ;no loop constructs - you have to recur!
(recur)
###Keywords
defn expressions update a global table of named functions in addition to evaluating to a function. Use do to put multiple expressions in the body of an if, set, or define
Identifier lookup checks the local scope, outer scopes, then the standard library and builtin functions:
console.log(args))(+ 2 2))If an identifier is not found in the above scopes lookup proceeds to
JavaScript objects. If the found value is a function, a version of
it bound to the object it was looked up on is returned.
e.g. log -> console.log.bind(console)
render is called. This is where
drawing functions like (fillRect x y width height) come from.To run the code locally you'll need webpack and some loaders.
npm install
npm install -g webpack
Once those are installed, run the following:
make
python3 -m http.server 8000 # or any other static file server
and open localhost:8000 in a webbrowser.
To run the tests, install mocha and chai and run mocha on the tests:
npm install -g mocha
npm install chai
mocha src/test*
The ES5/6 features in the code are limited to those implemented in Node without requiring any flags so the tests can be run without compiling.
There are a lot of directions this could be taken in, I capped it off pretty arbitrarily because I wanted to be able to show it to people. Some particularly relevant things to do:
I have a lot of smaller fixes I'd like to make, if you'd like to contribute let me know and I can advise on your PR. Here are a few simple fixes:
There's lots more, if there's interest I can throw a lot of things up on an issue tracker.
I wrote this to play with interpreters and so I could be informed as I talked to Mary Rose Cook about her Code Lauren project.
451 commits
JavaScript
86.9%
HTML
9.3%
CSS
3.1%
Repeat from the sign
See the code#Dal Segno
Write games, see your changes immediately: every time you change your code, Dal Segno rewinds your game back to the last time that piece of code was run.
#Language
It's sort of like Scheme.
;semicolons make the rest of a line a comment
(define x 10) ;var x = 10
(defn recur () ;named function definitions are global
(color 100 200 100) ;sets the color to be used
;for future draw operations
(fillRect 0 0 width height) ;this is the canvas
;context drawing operation
(color 0 0 230)
(drawArc x 100 111) ;queues a circle to be drawn
(render) ;actually paints queued drawings
(set! x (+ x .1)) ;change var wherever it was defined
(if (> x 300) ;you've got if, set!, define, defn,
(set! x 0)) ;and lambda - that's it for special forms
(recur)) ;no loop constructs - you have to recur!
(recur)
###Keywords
defn expressions update a global table of named functions in addition to evaluating to a function. Use do to put multiple expressions in the body of an if, set, or define
Identifier lookup checks the local scope, outer scopes, then the standard library and builtin functions:
console.log(args))(+ 2 2))If an identifier is not found in the above scopes lookup proceeds to
JavaScript objects. If the found value is a function, a version of
it bound to the object it was looked up on is returned.
e.g. log -> console.log.bind(console)
render is called. This is where
drawing functions like (fillRect x y width height) come from.To run the code locally you'll need webpack and some loaders.
npm install
npm install -g webpack
Once those are installed, run the following:
make
python3 -m http.server 8000 # or any other static file server
and open localhost:8000 in a webbrowser.
To run the tests, install mocha and chai and run mocha on the tests:
npm install -g mocha
npm install chai
mocha src/test*
The ES5/6 features in the code are limited to those implemented in Node without requiring any flags so the tests can be run without compiling.
There are a lot of directions this could be taken in, I capped it off pretty arbitrarily because I wanted to be able to show it to people. Some particularly relevant things to do:
I have a lot of smaller fixes I'd like to make, if you'd like to contribute let me know and I can advise on your PR. Here are a few simple fixes:
There's lots more, if there's interest I can throw a lot of things up on an issue tracker.
I wrote this to play with interpreters and so I could be informed as I talked to Mary Rose Cook about her Code Lauren project.
451 commits
JavaScript
86.9%
HTML
9.3%
CSS
3.1%