3 ms·
I would love to see support for calling out into go functions. The go stdlib so often has good implementations of functionality in places where things like the
by vvern 8y ago
I would love to see support for calling out into go functions. The go stdlib so often has good implementations of functionality in places where things like the python stdlib doesn't.
There are some obvious questions around calling conventions and error handling, method invocation, etc. but nothing there seems totally insurmountable. Having a compliant implementation as a jumping off point is a great start.
Looking at the interp internals, the representation of function call expressions might need a little bit more structure to pull this off (rather than just a big switch for the awk builtins and user calls as just more awk instructions plopped inline). Furthermore there are questions about how exactly to represent go objects but I suspect with some boxing it could be made relatively ergonomic.
- benhoyt 8y agoThat's a neat idea! (Though not necessarily in the spirit of AWK as a simple text processing language. :-) I started playing with something like this in a previous language interpreter I made in Go (https://github.com/benhoyt/littlelang/blob/master/interpreter/native.go https://github.com/benhoyt/littlelang/blob/master/interprete...). It's definitely possible to do with the reflect package, though it wouldn't be trivial to do a full implementation.