lisp-like syntax for julia
This package provides a julia-to-lisp syntax translator with convenience macros that let you do this:
lisp"(defn fib [a] (if (< a 2) a (+ (fib (- a 1)) (fib (- a 2)))))"
@test lisp"(fib 30)" == 832040
@test fib(30) == 832040 LispSyntax.jl is implemented as an expression translator between lisp/clojure-like syntax and julia's AST. Julia's compiler, JIT and multiple-dispatch infrastructure is used for code generation and execution. Because of this, LispSyntax.jl is not really clojure or lisp in most meaningful ways. The semantics are entirely julia-based (which are very similar to scheme/lisp in many ways). The net result is that LispSyntax.jl is really an alternative S-expression-like syntax for julia, not an implemention of clojure or lisp.
(def symbol init)(quote form)(defn symbol [param*] expr*)(defmacro symbol [param*] expr*)(lambda [param*] expr*)`(fn [param*] expr*)`(let [binding*] expr*)(global symbol*)(while test expr*)(for [binding*] expr*)(import package*)LispSyntax.jl.(global symbol*).let, fn parameter lists, etc.). This is not
currently implemented.LispSyntax.jl look like
standard Lisp macros but because expressions are special objects in
julia, S-expressions returned from macros require a special
translation step to generate julia expression trees. The result is
that LispSyntax.jl macros are directly translated into Julia macros and
must be called via special syntax (e.g. (@macro expr)).@r_str which in Julia can be called via r"", it is
currently necessary to call these via standard macro syntax:
(@r_str "string")
using is currently
implemented and confusingly, it matches Clojure's import form.