https://github.com/glycerine/zygomys Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions For + Enterprise + Teams + Startups + Education By Solution + CI/CD & Automation + DevOps + DevSecOps Case Studies + Customer Stories + Resources * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Pricing [ ] * # 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 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. You switched accounts on another tab or window. Reload to refresh your session. {{ message }} glycerine / zygomys Public * Notifications * Fork 78 * Star 1.5k Zygo is a Lisp interpreter written in 100% Go. Central use case: dynamically compose Go struct trees in a zygo script, then invoke compiled Go functions on those trees. Makes Go reflection easy. github.com/glycerine/zygomys/wiki License BSD-2-Clause license 1.5k stars 78 forks Star Notifications * Code * Issues 9 * Pull requests 0 * Actions * Projects 0 * Wiki * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Wiki * Security * Insights glycerine/zygomys This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. master Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 3 branches 116 tags Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/g] Use Git or checkout with SVN using the web URL. [gh repo clone glycer] Work fast with our official CLI. Learn more about the CLI. * Open with GitHub Desktop * Download ZIP Sign In Required Please sign in to use Codespaces. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @glycerine glycerine repair test if v6 is in package path; restore make to install and test ... b824c98 Jan 12, 2023 repair test if v6 is in package path; restore make to install and test b824c98 Git stats * 976 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time benchmarks atg. modernize benchmarks/array-mult.zy. Fixes #32 November 15, 2018 12:19 cmd/zygo fix go.mod version to v6 according workflow https://go.dev/doc/ module... January 12, 2023 16:34 emacs atg. zygo.el debug off March 20, 2016 13:54 imaginarium backup notes March 13, 2016 13:17 media update media January 18, 2016 17:57 slides atg. fix Parser.Start() infparse_nocomment.go September 20, 2016 23:18 tests fix: perform a tail call on a varargs function would hang forever August 26, 2022 17:57 zygo repair test if v6 is in package path; restore make to install and test January 12, 2023 16:07 .gitignore atg. include left-out files. v5.0.1 January 1, 2018 15:37 LICENSE standardize on lower case: prefer zygomys January 10, 2016 15:12 Makefile repair test if v6 is in package path; restore make to install and test January 12, 2023 16:07 README.md atg. update README December 10, 2018 14:07 abstract.txt atg. fix abstract typos February 23, 2016 15:08 go.mod fix go.mod version to v6 according workflow https://go.dev/doc/ module... January 12, 2023 16:34 go.sum release v6.0.1 August 24, 2020 07:46 View code [ ] zygomys - an embedded scripting language for Go quickly create a mini-language to drive your project why use zygomys? installation not your average parentheses... features in zygomys 5.1.1 include obligatory XKCD additional features where did the name zygomys come from? users of note license author credits README.md Image of Gopher flying zygomys - an embedded scripting language for Go Quick examples... Note that parenthesis always mean a function call or native lisp form, and function calls always use outer-parentheses. Traditional lisp style: // tail recursion; tail-call optimization works, so this won't overflow the stack. zygo> (defn factTc [n accum] (cond (== n 0) accum (let [newn (- n 1) newaccum (* accum n)] (factTc newn newaccum)))) zygo> (factTc 11 1) // compute factorial of 11, aka 11! aka 11*10*9*8*7*6*5*4*3*2 (factTc 11 1) 39916800 zygo> An optional infix syntax is layered on top. The infix syntax is a subset of Go. Anything inside curly braces is infix. Outer parenthesis are still always used for function calls. The zygo REPL is in infix mode by default to facilitate math. // show off the infix parser zygo> x := 3; y := 5; if x + y == 8 { (println "we add up") } else { (println "wat?" ) } we add up zygo> quickly create a mini-language to drive your project zygomys is an embeddable scripting language. It is a modernized Lisp with an object-oriented flavor, and provides an interpreter and REPL (Read-Eval-Print-Loop; that is, it comes with a command line interactive interface). why use zygomys? zygomys allows you to create a Domain Specific Language to drive your program with minimal fuss and maximum convenience. It is written in Go and plays nicely with Go programs and Go structs, using reflection to instantiate trees of Go structs from the scripted configuration. These data structures are native Go, and Go methods will run on them at compiled-Go speed. Because it speaks JSON and Msgpack fluently, zygomys is ideally suited for driving complex configurations and providing projects with a domain specific language customized to your problem domain. The example snippets in the tests/*.zy provide many examples. The full documentation can be found in the Wiki. zygomys blends traditional and new. While the s-expression syntax defines a Lisp, zygomys borrows some syntax from Clojure, and some (notably the for-loop style) directly from the Go/C tradition. The standalone REPL is called simply zygo. zygo is also shorthand for the whole project when speaking aloud. In writing, the full zygomys is used to aid searchability. installation $ go get github.com/glycerine/zygomys/cmd/zygo not your average parentheses... features in zygomys 5.1.1 include * [*] package mechanism that supports modularity and isolation of scripts/packages/libraries from each other. See tests/package.zy for examples. * [*] NaN handing that matches typical expectations/Go's answers. * [*] struct defintion and type checking. See tests/declare.zy for examples. * [*] Readable nested method calls: (a.b.c.Fly) calls method Fly on object c that lives within objects a and b. * [*] Use zygo to configure trees of Go structs, and then run methods on them at natively-compiled speed (since you are calling into Go code). * [*] sandbox-able environment; try zygo -sandbox and see the NewGlispSandbox() function. * [*] emacs/zygo.el emacs mode provides one-keypress stepping through code. * [*] Command-line editing, with tab-complete for keywords (courtesy of https://github.com/peterh/liner) * [*] JSON and Msgpack interop: serialization and deserialization * [*] (range key value hash_or_array (body)) range loops act like Go for-range loops: iterate through hashes or arrays. * [*] (for [(initializer) (test) (advance)] (body)) for-loops match those in C and Go. Both (break) and (continue) are available for additional loop control, and can be labeled to break out of nested loops. * [*] Raw bytes type (raw string) lets you do zero-copy []byte manipulation. * [*] Record definitions (defmap) make configuration a breeze. * [*] Files can be recursively sourced with (source "path-string"). * [*] Go style raw string literals, using `backticks`, can contain newlines and " double quotes directly. Easy templating. * [*] Easy to extend. See the repl/random.go, repl/regexp.go, and repl/time.go files for examples. * [*] Clojure-like threading (-> hash field1: field2:) and (:field hash) selection. * [*] Lisp-style macros for your DSL. * [*] optional infix notation within {} curly braces. Expressions typed at the REPL are assumed to be infix (wrapped in {} implicitly), enhancing the REPL experience for dealing with math. obligatory XKCD Obligatory XKCD: "elegant weapons... for a more civilized age" additional features * [*] Go-style comments, both /*block*/ and //through end-of-line. * [*] zygomys is a small Go library, easy to integrate and use/ extend. * [*] Float (float64), Int (int64), Char, String, Symbol, List, Array, and Hash datatypes builtin. * [*] Arithmetic (+, -, *, /, mod, **) * [*] Shift Operators (sll, srl, sra) * [*] Bitwise operations (bitAnd, bitOr, bitXor) * [*] Comparison operations (<, >, <=, >=, ==, !=) * [*] Short-circuit boolean operators (and and or) * [*] Conditionals (cond) * [*] Lambdas (fn) * [*] Bindings (def, defn, let, letseq) * [*] Standalone and embedable REPL. * [*] Tail-call optimization * [*] Go API * [*] Macro System with macexpand (macexpand (yourMacro)) makes writing/debugging macros easier. * [*] Syntax quoting -- with caret ^() instead of backtick. * [*] Backticks used for raw multiline strings, as in Go. * [*] Lisp-expression quoting uses % (not '; which delimits runes as in Go). * [*] Channel and goroutine support * [*] Full closures with lexical scope. See the wiki for lots of details and a full description of the zygomys language.. where did the name zygomys come from? zygomys is a contraction of Zygogeomys, a genus of pocket gophers. The Michoacan pocket gopher (Zygogeomys trichopus) finds its natural habitat in high-altitude forests. The term is also descriptive. The stem zygo comes from the Greek for yoke, indicating a pair or a union of two things, and mys comes from the Greek for mouse. The union of Go and Lisp in a small cute package, that is zygomys. users of note https://github.com/metacurrency/holochain license Two-clause BSD, see LICENSE file. author Jason E. Aten, Ph.D. credits The ancestor dialect, Glisp, was designed and implemented by Howard Mao. The Go gopher was designed by Renee French. (http:// reneefrench.blogspot.com/) The design is licensed under the Creative Commons 3.0 Attributions license. Read this article for more details: https://blog.golang.org/gopher XKCD https://xkcd.com/297/ licensed under a Creative Commons Attribution-NonCommercial 2.5 License(https://xkcd.com/license.html). About Zygo is a Lisp interpreter written in 100% Go. Central use case: dynamically compose Go struct trees in a zygo script, then invoke compiled Go functions on those trees. Makes Go reflection easy. github.com/glycerine/zygomys/wiki Resources Readme License BSD-2-Clause license Stars 1.5k stars Watchers 53 watching Forks 78 forks Report repository Releases 116 tags Packages 0 No packages published Contributors 12 * @glycerine * @zhemao * @eliothedeman * @mattn * @chrhlnd * @tsenart * @DianeLooney * @qjpcpu * @sug0 * @XANi * @maxxant * @japanoise Languages * Go 93.6% * Emacs Lisp 6.2% * Other 0.2% Footer (c) 2023 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time.