betaveros / noulith

*slaps roof of [programming language]* this bad boy can fit so much [syntax sugar] into it
1.13k stars 20 forks source link

Using `Rc::as_ptr` to hash `Obj::Func` and `Seq::Stream` #28

Closed timfennis closed 4 months ago

timfennis commented 4 months ago

Hi

You inspired me to read crafting interpreters and write my own programming language. Since rust is also my implementation language of choice I'm able to take plagiaristic amounts of inspiration from Noulith. Thanks I guess, hope you don't mind.

I was adding adding a Dictionary type myself and noticed that you wrap Obj in ObjKey to deal with instances of Obj that seemingly can't be hashed easily. I was doing something similar but ended up implementing Hash for Obj and used Rc::as_ptr to hash my function type. (I also implemented PartialEq using the same pointer)

Is this something you considered and rejected, if so, what was your reasoning? If not I would be down to create a PR that gets rid of ObjKey.

timfennis commented 4 months ago

Hmm I'm noticing now that your PartialEq for ObjKey behaves differently from ParitalEq for Obj which is probably another reason why ObjKey and Obj are different.

betaveros commented 4 months ago

Glad to hear about other people's languages!

Honestly I don't remember, I vaguely believe that I tried comparing and hashing pointers and was discouraged by some compiler warning, but I could be making this up. So I could be open to making functions hashable. But yeah I think Obj probably shouldn't have total Ord for example.

timfennis commented 4 months ago

Thanks for the insights, if I find the time I'll try and draft up a PR soon.