skx / yal

Yet another lisp interpreter
GNU General Public License v2.0
16 stars 0 forks source link

Initial support for calling golang, via reflection. #143

Closed skx closed 7 months ago

skx commented 1 year ago

This is a proof of concept for calling golang functions from yal, via the use of reflection. There's a bit of overhead in massaging the types into suitable forms - both for arguments, and results, but the core idea seems reasonable.

With this built and installed you can run:

> (path.Glob "/etc/p*")
((/etc/pam.conf /etc/pam.d /etc/papersize /etc/passwd /etc/passwd- /etc/passwd.org /etc/perl /etc/pipewire /etc/pki /etc/plymouth /etc/pm /etc/pnm2ppa.conf /etc/polkit-1 /etc/ppp /etc/printcap /etc/profile /etc/profile.d /etc/protocols /etc/pulse /etc/puppet /etc/purple /etc/python /etc/python3 /etc/python3.5 /etc/python3.7 /etc/python3.9) nil)

Needs more work in deciding what to add, and better conversion routines. (c.f. evalfilter).

TODO:

But this updates #139.

skx commented 1 year ago

On reflection - pun intended - I'm not sold on this approach:

I think there's a middle-ground here:

TLDR:

However - major problem - you can't iterate over methods of a package. So I still have to hardcode options (such as "strings", "time", "os"). Meh. Maybe I should just abandon the whole idea?