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

Hook Syntax #3

Closed ejemba closed 8 years ago

ejemba commented 8 years ago

Can you just give a sample for the hook (Pre and Post) in the wiki ?

PS Thank you for this amazing lib !

glycerine commented 8 years ago

Thanks @ejemba :)

The hooks allow Go functions to monitor Lisp functions. For example, see CountPreHook and CountPostHook

https://github.com/glycerine/zygomys/blob/01562f6161e20b70040704f1c805e3e64af4ede7/repl/repl.go#L16

and

https://github.com/glycerine/zygomys/blob/01562f6161e20b70040704f1c805e3e64af4ede7/repl/repl.go#L392

I'll leave this open as a reminder to add a description to the wiki in the near future.

glycerine commented 8 years ago

Thinking on this a little more, the hooks are mostly a means of internal profiling, left over from the Glisp days. I removed them from the feature list just now. They are still there internally, but not really meant to support anything vis-a-vis the language itself. So I'm closing this out as an (intentionally undocumented and unsupported feature); any user of the library can do similar or even simpler profiling trivially.

ejemba commented 8 years ago

@glycerine thank you for your answer :) I was thinking of them like the advice in emacs-lisp defadvice or hook that are very usefull.

Thanks anyway :)

glycerine commented 8 years ago

@ejemba wow I had no idea emacs lisp had all that. It's so built out. Kind of amazing. Glad you mentioned it(!)