Skip to content

aoeu/zygomys

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image of Gopher flying

zygomys - embedded scripting language for Go.

quickly create a mini-language to configure 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).

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.

tell me more

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 easily 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 challenges and driving Go code.

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 Grandfather's Parentheses... features in zygomys 2.0.5 include

  • New in 2.0: dot-symbols! dot-symbols such as .plane or .plane.wing give OO-flavor and compact, expressive notation. See the wiki for discussion.
  • dot-symbols avoid the need for macros in many cases
  • readable assignment: (.a = 10) assigns value 10 to symbol a (NB use == for equality checks.)
  • 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).
  • 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.
  • 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 (req path) or (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.

Obligatory XKCD

Obligatory XKCD: "elegant weapons... for a more civilized age"

Additional features

  • 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 (bit-and, bit-or, bit-xor)
  • Comparison operations (<, >, <=, >=, ==, !=, and not=)
  • Short-circuit boolean operators (and and or)
  • Conditionals (cond)
  • Lambdas (fn)
  • Bindings (def, defn, and let)
  • Standalone and embedable REPL.
  • Tail-call optimization
  • Go API
  • Macro System with macexpand (macexpand (your-macro)) makes writing/debugging macros easy.
  • Syntax quoting -- with caret ^() instead of backtick.
  • Channel and goroutine support
  • Lexical scope.

See the wiki for lots of details and a full description of the zygomys language..

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

Java has Clojure, Go has zygomys. A 100% Golang, easy-to-use Lisp.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 88.7%
  • Emacs Lisp 10.8%
  • Other 0.5%