diff --git a/clj_to_janet.md b/clj_to_janet.md new file mode 100644 index 0000000..191dba6 --- /dev/null +++ b/clj_to_janet.md @@ -0,0 +1,42 @@ +# 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