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.72k stars 81 forks source link

Go API Wiki Site #44

Open Stazer opened 5 years ago

Stazer commented 5 years ago

Hey,

first of all thanks for your work. I really enjoy using zygomys!

I just wanted to mention that the hash examples on the Go API Wiki Site are not correct which might be confusing.

Thanks!

Best Regards

glycerine commented 5 years ago

what do you mean, specifically?

Stazer commented 5 years ago

The use of the HashSet, HashGet, HashGetDefault and HashDel methods.

var hash SexpHash HashSet(&SexpStr{S: "hello"}, &SexpStr{S: "world"}) expr, err := HashGet(hash, &SexpStr{S:"hello"}) expr, err := HashGetDefault(hash, &SexpStr{S:"bar"}, &SexpInt{}) err := HashDel(hash, &SexpStr{S:"foo"})

It should be:

var hash SexpHash{env: env} hash.HashSet(&SexpStr{S: "hello"}, &SexpStr{S: "world"}) expr, err := hash.HashGet(env, &SexpStr{S:"hello"}) expr, err := hash.HashGetDefault(env, &SexpStr{S:"bar"}, &SexpInt{}) err := hash.HashDelete(&SexpStr{S:"foo"})

Furthermore I saw that HashGet, HashGetDefault and HashDelete require the environment as argument. Shouldn't they use the environment of the hash passed as pointer receiver? HashSet is doing that already.