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

Q: how to make examples work using the -demo flag #31

Open jkleiser opened 5 years ago

jkleiser commented 5 years ago

I just installed zygo v5.0.1 on my Mac (macOS 10.14.1), and when I try the example I found in the wiki

(def sn (snoopy asst: (hornet forecast: (weather desc:"sunny"))))

then I get

error in evalGeneratedFunction:4: Error calling 'infix': symbol `weather` not found
in infix:0
in __main:22

What may be the problem here?

glycerine commented 5 years ago

Yeah. Sorry this isn't clearer. It's perfectly natural to wonder why this would work at all. After all. Without a prior function definition, defmap, or registration of a Go struct, none of the snoopy, hornet, or weather calls should work. Nobody has defined those functions.

So what is going on. Well, there is a special flag for demo and testing purposes.

https://github.com/glycerine/zygomys/blob/master/zygo/cfg.go#L43

So the trick is, starting zygo with zygo -demo will register those functions, letting the example function.