# From Clojure to Janet ## How to convert files ### Comments `% s ; r # ` ### called keyword property access Use a macro: - Select `\ \( : ret ` - Record the macro: `Q n v e c get e e a p Q` - Then just `q` until you've changed everything ### Chars don't exist - \char -> "char", e.g. - \newline -> "\n", etc. - \a -> "a" ### Use mutable arrays and tables Where data structures are mutable, add `@`s. ### Sets & tables Sets don't exist in Janet. Use tables with values set to `true`. ### Strings -> number literals - Clj uses `edn/read-string`; Janet uses `parse-all` ### `loop` -> `defn recur` - Clj's `loop` is very different from Janet's `loop` - As a quick and dirty workaround, change it to an interior recursive function - Janet has tail calls, so this is nearly as efficient (paying the overhead for creating the function) - An optimization is to pull out these functions and declare them at the toplevel ### current-char ### Straight replacements: - nth -> get - assoc -> put - conj -> array/push - str -> string - substr -> slice