Re:Zygomys: Embedded Scripting Language for Go
by ilyt on Thursday June 29, 2023 @05:13AM
(#36518137)
My phone's power level. Got task sent via tasker to some code that turns that into mqtt messages. Then they go to the metrics gatherer on my NAS (it also has gps position and few other things), and my computer.
I had more but mpower pro I was using (power strip with 6 sockets, power measuring and control) died on me ;/
Re:Zygomys: Embedded Scripting Language for Go
by thefounder on Wednesday June 28, 2023 @10:40PM
(#36515696)
Yes, I did that extensively and ended up using reflection only. The code generation/generated is just hard to maintain and the tools that generate the code (and read the code) are hard to maintain as well. Currently I'm using code "reading" only to extract documentation so no more code generation.
I do wish there was a nice library to aid in parsing Go, there may be one I'm not aware of - I used the standard AST library but it is very verbose. Actually generating the code is very easy and go format helps a lot.
Custom kubernetes operators in Go use code generation via comments extensively, perhaps worth looking at.
Re:Zygomys: Embedded Scripting Language for Go
by jaten on Thursday June 29, 2023 @06:45AM
(#36518732)
Zygo does have infix available in addition to traditional lisp parentheses. Just put the math (or whatever) inside curly braces. I much prefer math in infix, so I put in a Pratt parser for that.
Another related language that is embedded in Go is golisp by SteelSeries: https://github.com/SteelSeries/golisp
I had more but mpower pro I was using (power strip with 6 sockets, power measuring and control) died on me ;/
I do wish there was a nice library to aid in parsing Go, there may be one I'm not aware of - I used the standard AST library but it is very verbose. Actually generating the code is very easy and go format helps a lot.
Custom kubernetes operators in Go use code generation via comments extensively, perhaps worth looking at.
If you're not in love with the lisp syntax, you might want to take a look at Risor as well.
https://github.com/risor-io/risor#quick-example
Then I realized with maturin, that was Python :)