This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'multi-term) | |
(setq multi-term-program "/bin/zsh") | |
(global-set-key (kbd "<f8>") 'multi-term) | |
(setq term-bind-key-alist | |
`(("M-d" . term-send-forward-kill-word) | |
("M-DEL" . term-send-backward-kill-word) | |
("C-c" . term-interrupt-subjob) | |
("M-v" . term-send-raw) | |
("C-y" . term-paste) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (foo arr) | |
(js "console.log(arr.length);")) | |
-> | |
var foo = function(arr){ | |
return console.log(arr.length);} | |
; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; AST style: | |
((equal? term "cond") | |
(define (transform i) | |
(if (or (> i node.children.length) | |
(eq? i node.children.length)) | |
null | |
(let ((n (vector-ref node.children i))) | |
(let ((condition (vector-ref n.children 0)) | |
(res (ast.node ast.LIST |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; outlet code for implementing traditional macro expansion | |
;; macros | |
(define (expand form) | |
(cond | |
((variable? form) form) | |
((literal? form) form) | |
((macro? (car form)) | |
(expand ((macro-function (car form)) form))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; outlet code for implementing EPS macros (http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.50.4332) | |
;; expanders | |
(define _expanders_ {}) | |
(define (expander-function name) | |
(ref _expanders_ (symbol->string name))) | |
(define (install-expander name func) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(trace-source (let ((i (+ 4 5))) | |
(+ i (* 2 (/ 3 4))))) | |
;; Output | |
(let ((i (+ 4 5))) | |
(+ i (* 2 (/ 3 4)))) | |
-- (+ 4 5) | |
>> RESULT: 9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var x = 1; | |
function foo() { | |
var x = x + 2; | |
console.log(x); // prints NaN | |
} | |
function bar() { | |
var x = x; | |
console.log(x); // prints undefined |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Requires Outlet to run: https://github.com/jlongster/outlet | |
;; | |
;; Run with: `ol main.ol <input-file>` | |
;; | |
;; This is a meta-circular evaluator for a basic Lisp. It is | |
;; mostly taken from SICP 4.1*. I wanted to see if I could write a | |
;; debugger with it. Turns out if I want control over control flow I | |
;; need a register-based interpreter. | |
;; | |
;; * http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-26.html#%_sec_4.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
((goto (label eval-exp)) | |
eval-dispatch | |
(test (op self-evaluating?) (reg exp)) | |
(branch (label ev-self-eval)) | |
(test (op variable?) (reg exp)) | |
(branch (label ev-variable)) | |
(test (op quoted?) (reg exp)) | |
(branch (label ev-quoted)) | |
(test (op assignment?) (reg exp)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; outlet: https://github.com/jlongster/outlet | |
(define-macro (case c . variants) | |
`(cond | |
,@(map (lambda (exp) | |
(if (== (car exp) 'else) | |
exp | |
`((list-find ',(car exp) ,c) | |
,@(cdr exp)))) | |
variants))) |