glycerine / zygomys

Zygo is a Lisp interpreter written in 100% Go. Central use case: dynamically compose Go struct trees in a zygo script, then invoke compiled Go functions on those trees. Makes Go reflection easy.
https://github.com/glycerine/zygomys/wiki
BSD 2-Clause "Simplified" License
1.71k stars 81 forks source link

mux function call mismatch #55

Closed qjpcpu closed 2 years ago

qjpcpu commented 2 years ago

mux function: register a function for multiple name, forexample, the builtin function "+ - * /".

when pass a mux function to another function, the behavior would be unpredictable:

(defn sub [f a b] (f a b))
(sub - 2 1) ;; expect  1 but get 3

when execute function '-' , its name changes to 'f', so use '+' as its default operand.

well, this bug comes from glisp, too.

glycerine commented 2 years ago

thanks. if you figure out a fix, I'll be happy to incorporate it.

qjpcpu commented 2 years ago

thanks. if you figure out a fix, I'll be happy to incorporate it.

https://github.com/glycerine/zygomys/pull/56

glycerine commented 2 years ago

Merged. Thank you.