Hacker News new | past | comments | ask | show | jobs | submit login

Go makes composition less powerful than it could be by slicing structs, which means a lot of hoop jumping to get template methods (where blanks are filled in downstream).

I've been playing around with first class environments [0] lately in g-fu [1], which allow convenient and flexible composition of data and behavior using only what was already there.

I have a feeling Lua might be playing similar tricks with its tables, but I lack enough experience to judge.

[0] https://github.com/codr7/g-fu/blob/master/v1/lib/eos.gf

[1] https://github.com/codr7/g-fu




>slicing structs

Can you explain what this means? Still learning Go. Google didn't help.


I'll try :)

The issue is that you can't interface methods from pointers to a contained struct, since it has no idea where it is or how it got there. Instead a pointer to the full struct needs to be threaded all the way down to where the overridden function is called.

I sort of understand why, but this is a major missing piece that makes it very frustrating to add anything but trivial default implementations to interfaces in Go from my experience.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: