I wonder whether we should have a special metamethod for pickle? The assumption that tostring (object) will generate a string that can be passed to functional.eval doesn't even hold true for the objects we provide in stdlib.
Two options:
- Objects that can be pickled have a
__pickle metamethod (analogous to Python's __repr) that outputs a constructor for the object being pickled (including a require "appropriate.module".constructor {args} rather than assuming "appropriate.module" is already loaded).
- We have to be careful that
__tostring does double duty with the above.
I'm leaning heavily towards (1) because, among others, it makes a cannot pickle error easy to determine and produce.
I wonder whether we should have a special metamethod for pickle? The assumption that
tostring (object)will generate a string that can be passed tofunctional.evaldoesn't even hold true for the objects we provide in stdlib.Two options:
__picklemetamethod (analogous to Python's__repr) that outputs a constructor for the object being pickled (including arequire "appropriate.module".constructor {args}rather than assuming"appropriate.module"is already loaded).__tostringdoes double duty with the above.I'm leaning heavily towards (1) because, among others, it makes a cannot pickle error easy to determine and produce.