Last active
December 23, 2015 21:19
-
-
Save jeremyheiler/6695635 to your computer and use it in GitHub Desktop.
variable and function definitions for a javascript-based lisp?
This file contains 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
;; 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)) |
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
I prefer consistency so would prefer either def or define over var. I don't want to think too hard about JS when writing in another language.