Chia-Network / clvm

[Contract Language|Chia Lisp] Virtual Machine
Apache License 2.0
86 stars 35 forks source link

add some type annotations #91

Closed arvidn closed 3 years ago

arvidn commented 3 years ago

This is in preparation for making SExp have a clearer API and not derive from CLVMObject

arvidn commented 3 years ago

is your opinion that SExp's API should be .atom and .pair properties instead of .as_atom() and .as_pair(), or that it should have both?

arvidn commented 3 years ago

I think the fact that CLVMObject and SExp share some part of their interfaces is problematic, and makes it more difficult to separate their responsibilities and uses.

richardkiss commented 3 years ago

Both. We can have SExp be a subclass of CLVMObject, but .as_pair() is subtly different from .pair in that it rewraps the pair of CLVMObject children as SExp objects.

SExp is basically so you can get convenience features like .as_iter and .as_int. It really shows how clever rust impl blocks are, since it'd be much nicer to just be able to add these methods right into CLVMObject.