4 ms·
Author here. It's still a young language and naive implementation focused on correctness, but I'm very happy with how its turning out. I'm especially fond of
by codr7 7y ago
Author here.
It's still a young language and naive implementation focused on correctness, but I'm very happy with how its turning out.
I'm especially fond of first class environments and qualified identifiers [0]; which allow composing, overriding and delegating data and behavior in a convenient yet remarkably flexible way. It's clearly a more fundamental mechanism than the usual suspects.
Note that this is the opposite of what Python is doing with __dict__ and Lua with tables. Rather than basing the implementation on a general purpose data structure, g-fu exposes the the implementation and allows hooking into it.
It reminds me of pcostanza's work on Context Oriented Programming and ContextL [1], but integrated rather than bolted on.
[0] https://github.com/codr7/g-fu/tree/master/v1#environments https://github.com/codr7/g-fu/tree/master/v1#environments
[1] https://github.com/pcostanza/contextl https://github.com/pcostanza/contextl
- azhenley 7y agoThanks for posting this! I made a toy Forth in Go recently [1] but didn’t really know what I was doing. I’m going to check G-Fu out to understand how I should have implemented mine. [1] https://github.com/AZHenley/goforth https://github.com/AZHenley/goforth
- codr7 7y agoCool. I've written my share of Forths, but none in Go. Lisp is definitely more involved, especially expanding macros and juggling environments. You're welcome :) Note that I'm still in the process of simplifying and refactoring quite heavily. Feel free to get in touch if you run into anything weird, and I'll do my best to help make sense of it.
- Scarbutt 7y agoIf Go can't load code at runtime, how do you plan to add a "real" lisp REPL?
- codr7 7y agoIt can using plugins from what I've seen. I'm not aiming for a regular Lisp though, g-fu is designed to be embedded in and complement Go first hand.
- irq-1 7y agoFYI, plugins in Go only work on linux and macos. Windows has the option to load dlls dynamically, but it is a different mechanism. If I remember right the Go devs were not planning on making plugins work on other platforms because of having to make the PE format work(?)
- codr7 7y agoYeah, so I heard. I have yet to try plugins myself, but I've implemented the same mechanism using dlopen in C. I'm almost hoping that big G is forced by greed to include Windows. Otherwise some kind of shim on top of DLL-loading might be an option.
- nudq 7y ago> first class environments Which are notorious for being unoptimizably slow > It reminds me of pcostanza's work on Context Oriented Programming and ContextL I'm not reminded at all. Can you expound?
- deleted 7y ago[deleted]
- codr7 7y agoHow so? I get that going the route of Python and Lua and using a general purpose data structure for the environment isn't optimal. But g-fu exposes the already existing environment as a separate type, the only thing it knows how to do is map symbols to values and access is restricted to a few special forms just like any regular Lisp enviroment. Well, context oriented programming is all about separating the system into layers of behavior that may be flexibly and conveniently composed to get the right mix of functionality. Which is exactly what g-fu is doing with first class environments.