Last active
August 29, 2015 14:00
-
-
Save ElectricCoffee/078940f5e0a3bcbde3d7 to your computer and use it in GitHub Desktop.
An idea I had to make a lisp dialect, less focused on historical accuracy, and more focused on feeling like a modern language, and also having classes and objects be a central part of the language, rather than being "glued on" as it seems to be in some Lisp dialects
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
; Scala inspired Lisp | |
; I call it "Stutter" :3 | |
; variable (mutable) definition: | |
(var a 5) | |
; value (immutable) definition: | |
(val b 4) | |
; function definition: | |
(def double (x) | |
(* 2 x)) | |
; class definition: | |
(class person% (nm ag) (object%) | |
(val name nm) | |
(var age ag) | |
(public/def birthday () (++ _age)) | |
(public/def get-name () name) | |
(public/def change-name (n) (set name n)) | |
(public/def get-age () age)) | |
; instances | |
(val john (new person% "John" 24)) | |
; method calls | |
(send john get-name) ; returns "John" | |
(send john change-name "bob") ; returns unit | |
(send john get-name) ; returns "bob" | |
(send john birthday) ; returns unit | |
(send john get-age) ; returns 25 | |
; lambdas (called "anon" because "lambda" is too long to write) | |
((anon (x y) (* y (+ x 2))) 2 5) ; returns 20 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment