Last active
January 1, 2017 00:59
-
-
Save arrdem/97c755f37170a8f312403c4b72ec2a4a to your computer and use it in GitHub Desktop.
Textual programs as views of ASTs.
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
;; I write | |
(ns foo) | |
(defn adds-one [x] | |
(+ x 1)) | |
(def another-adds-one | |
(partial + 1)) | |
;; SYMBOL TABLE (name -> UUID) | |
;; | |
;; These mappings come with the namespace/library clojure.core and are shared | |
;; | |
;; clojure.core/ns -> d7b971fa-d2a2-ecd4-c6c3-ffc6097fcd47 | |
;; clojure.core/def -> 575aedb3-b82e-2604-3aab-a1ebc592f2dc | |
;; clojure.core/defn -> b43c2c0d-50f1-f7f4-f503-9a1fb64726d8 | |
;; clojure.core/partial -> 1679597c-c7bd-c5a4-2de3-56eddfaa5fc4 | |
;; clojure.core/ns -> ff51ae7a-85c2-3b14-b1eb-e80b9624f8f9 | |
;; clojure.core/+ -> b91d5b29-295e-a204-efab-e1417fd72d5d | |
;; | |
;; These mappings are generated for the new symbols I've created | |
;; | |
;; foo/adds-one -> 86d975b5-c6f0-d1a4-389b-fb499b421587 | |
;; foo/another-adds-one -> 2e69905a-8e71-f5c4-bd53-d84f8663ff50 | |
;; x -> 9c5d94bd-bcd0-9484-b113-8ce229f49c5e | |
;; foo -> efd34525-ea47-f394-5133-dea55831a3d9 | |
;; editor serializes this in some non-textual binary encoding of lists / vectors / maps / sets / | |
;; symbols / numbers etc. | |
(#id "d7b971fa-d2a2-ecd4-c6c3-ffc6097fcd47" | |
#id "efd34525-ea47-f394-5133-dea55831a3d9") | |
(#id "b43c2c0d-50f1-f7f4-f503-9a1fb64726d8" | |
[#id "9c5d94bd-bcd0-9484-b113-8ce229f49c5e"] | |
(#id "b91d5b29-295e-a204-efab-e1417fd72d5d" | |
#id "9c5d94bd-bcd0-9484-b113-8ce229f49c5e" | |
1)) | |
(#id "575aedb3-b82e-2604-3aab-a1ebc592f2dc" | |
(#id "1679597c-c7bd-c5a4-2de3-56eddfaa5fc4" | |
#id "b91d5b29-295e-a204-efab-e1417fd72d5d" | |
1)) | |
;; A dictionary with the above mappings for the new foo namespace is also saved in parallel with the | |
;; file containing the ASTs in the foo namespace. When another editor loads this namespace, it loads | |
;; the ASTs, rendering them back to text using whatever dictionaries and formatting options the | |
;; rendering user may specify. For instance the user may have specified that single form function | |
;; definitions under some length should occur on the same line as the arguments. | |
... | |
(defn adds-one [x] (+ x 1)) | |
... | |
;; or that the argument list always gets its own line | |
... | |
(defn adds-one | |
[x] | |
(+ x 1)) | |
... | |
;; The idea is that while the user continues to read and write textual code, that code can be mapped | |
;; back to a binary form at the same level of abstraction which has legitimate alternate renderings | |
;; on which experts may disagree. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment