Skip to content

Instantly share code, notes, and snippets.

@jeremyheiler
Last active December 23, 2015 21:19
Show Gist options
  • Save jeremyheiler/6695635 to your computer and use it in GitHub Desktop.
Save jeremyheiler/6695635 to your computer and use it in GitHub Desktop.
variable and function definitions for a javascript-based lisp?
;; javascripty
(var foo 42)
(var inc (function (x) (+ x 1)))
(function dec (x) (- x 1))
;; clojurey
(def foo 42)
(def inc (fn [x] (x + 1)))
(defn dec [x] (- x 1))
;; schemey
(define foo 42)
(define inc (lambda (x) (+ x 1)))
(define (dec x) (- x 1))
@jeremyheiler
Copy link
Author

I think the only ways the javascripty solution could work is if it always create a function by assigning it to a var, or if I am able to determine if the function being created is in the statement or expression position. I don't want to do the former because the goal is to be bi-directional. "Familiarity" asside, I like the schemey approach here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment