glycerine / zygomys

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.
https://github.com/glycerine/zygomys/wiki
BSD 2-Clause "Simplified" License
1.71k stars 81 forks source link

POC of limited function Glisp factories #9

Closed eliothedeman closed 8 years ago

eliothedeman commented 8 years ago

Not sure about the grouping of functions I used. Name-spacing/library support is probably the best way to do this in the long term, but this seems like a decent solution for now.

glycerine commented 8 years ago

Please be sure to run "make" to check the test suite against your changes. When I build your branch it looks like the raw2str function was lost; tests/raw.zy fails.

$ make
...
tests/range.zy passed
error in __main:32: symbol `raw2str` not found
tests/raw.zy failed
make: *** [test] Error 1
jaten@jatens-MacBook-Pro ~/src/github.com/glycerine/zygomys ((HEAD detached at 3a57040)) $ grep raw2str repl/*.go
jaten@jatens-MacBook-Pro ~/src/github.com/glycerine/zygomys ((HEAD detached at 3a57040)) $ git checkout master
M       repl/gitcommit.go
Previous HEAD position was 3a57040... POC of limited function Glisp factories
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
jaten@jatens-MacBook-Pro ~/src/github.com/glycerine/zygomys (master) $ grep raw2str repl/*.go
repl/functions.go:      "raw2str":    RawToStringFunction,
jaten@jatens-MacBook-Pro ~/src/github.com/glycerine/zygomys (master) $ 
glycerine commented 8 years ago

I really like the idea of some kind of library or namespace support. I'm thinking of Go's unsafe package, and how the playground doesn't run unsafe and therefore it is sandboxed.

But this simpler approach suffices for now.

glycerine commented 8 years ago

@eliothedeman thanks again for this; I've polished and merged. Try it out! see the new -sandbox flag to the repl which makes experimenting with it easy.