https://github.com/swadey/LispSyntax.jl Skip to content Sign up * Why GitHub? Features - + Code review + Project management + Integrations + Actions + Packages + Security + Team management + Hosting + Mobile + Customer stories - + Security - * Team * Enterprise * Explore + Explore GitHub - Learn & contribute + Topics + Collections + Trending + Learning Lab + Open source guides Connect with others + Events + Community forum + GitHub Education + GitHub Stars program * Marketplace * Pricing Plans - + Compare plans + Contact Sales + Nonprofit - + Education - [ ] [search-key] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} swadey / LispSyntax.jl * Watch 11 * Star 143 * Fork 21 lisp-like syntax in julia View license 143 stars 21 forks Star Watch * Code * Issues 6 * Pull requests 1 * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights master 3 branches 8 tags Go to file Code Clone HTTPS GitHub CLI [https://github.com/s] Use Git or checkout with SVN using the web URL. [gh repo clone swadey] Work fast with our official CLI. Learn more. * Open with GitHub Desktop * Download ZIP Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Go back Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Go back Launching Xcode If nothing happens, download Xcode and try again. Go back Launching Visual Studio If nothing happens, download the GitHub extension for Visual Studio and try again. Go back Latest commit @swadey swadey - version specs for new regristrator requirements ... d87c4e7 Feb 6, 2020 - version specs for new regristrator requirements d87c4e7 Git stats * 95 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time doc Typos Mar 3, 2017 docs Updated the REPL usage docs. Jun 13, 2019 src Addressed review feedback. Jun 16, 2019 test Cleanup: put tests in testsets Jun 11, 2019 .travis.yml Modernize travis CI script Jun 7, 2019 LICENSE.md - clean license/comments Jan 23, 2016 Project.toml - version specs for new regristrator requirements Feb 6, 2020 README.md Updated the REPL usage docs. Jun 13, 2019 mkdocs.yml - update yml Jan 24, 2016 View code README.md LispSyntax.jl: A clojure-like lisp syntax for julia Join the chat at https://gitter.im/swadey/LispSyntax.jl Build Status This package provides a lisp-to-julia 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. Special Forms * (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*) Notable Differences * Symbol names cannot have -, *, /, ? ... - Julia symbol naming is used for everything, as a result, Julia syntax restrictions are maintained in LispSyntax.jl. * Reference to global variables in function scopes - Julia requires declaration of global symbols that are referenced in function scope. Because of this functions need to declare which symbols are global. This is done via the special form (global symbol*). * Binding forms not implemented - Clojure has very awesome destructuring binds that can used in most special forms requiring bindings (e.g. let, fn parameter lists, etc.). This is not currently implemented. * Lack of loop/recur - Currently, this is not implemented. As with Clojure, julia does not currently support TCO, so something like this may be needed (but a macro-implementation of tail call rewriting may be more appropriate for julia). * Optional typing - Currently not implemented. * Named functions are julia methods - For efficiency, functions defined with defn are translated to normal julia function expressions. This means the act as named lambdas in local scope. * Method definition - Also not currently implemented. If implemented it will probably not be a full implementation of Clojure's sophisticated dispatch system. * Macros differences - Macros defined in 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)). Macro hygiene follows the Julia approach of hygenic-by-default with explicit escaping using esc. This is the opposite of Clojure's macros which use explicit hygiene with specially named variables. * Julia's string macro dispatch not supported (yet) - for macros like @r_str which in Julia can be called via r"", it is currently necessary to call these via standard macro syntax: (@r_str "string") REPL Mode LispSyntax.jl provides a convenience REPL, alleviating one from having to type lisp"( ... )" for each top level expression. In order to use REPL mode, simply initialize it: julia> using LispSyntax julia> LispSyntax.init_repl() REPL mode Lisp Mode initialized. Press ) to enter and backspace to exit. At this point, type ), and you're ready to Lisp: jl> (* 2 (reduce + (: 1 6))) 42 jl> (defn fib [a] (if (< a 2) a (+ (fib (- a 1)) (fib (- a 2))))) fib (generic function with 1 method) jl> (fib 10) 55 To return to the Julia prompt, simply type the backspace type or Ctrl-C. Once there, you'll still have access to the fuctions you defined: julia> fib fib (generic function with 1 method) julia> fib(10) 55 You may also create a customized REPL. TODO * Support for exceptions: this is straight forward but not currently implemented. * Optional typing to support method definition * Structs and aggregate types * Special dispatch for string macro forms * Modules * import vs. using vs. include -- only using is currently implemented and confusingly, it matches Clojure's import form. * varargs and named arguments About lisp-like syntax in julia Resources Readme License View license Releases 8 v0.2.0 Latest Jun 11, 2019 + 7 releases Packages 0 No packages published Contributors 10 * @swadey * @c42f * @oubiwann * @SalchiPapa * @MasonProtter * @o314 * @MichaelHatherly * @zlaus * @PallHaraldsson * @gitter-badger Languages * Julia 98.8% * Clojure 1.2% * (c) 2021 GitHub, Inc. * Terms * Privacy * Security * Status * Help * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.