Open plafer opened 1 week ago
Very interesting! One question: if I understood the above correctly, tag need to be defined at compile time - right? If so, how would we deal with MAST forests which need to be instantiated at runtime? For example, say we have a set of serialized MastForest
's (this set could be arbitrarily large) - how would we assign tags to them on deserialization?
The initial implementation of
MastForest
in #1217 made it the user's responsibility to use aMastNodeId
with its correspondingMastForest
; incorrect use would not be caught by the compiler.I believe this can be solved by using "type tags", as outlined below. A few derived considerations:
Tag
type to the deserializing functionAssembler::assemble_program()
method (and other similar ones) would take a genericTag
, used to tag the resultingMastForest
(andProgram
by extension).MastForest
s out of thin air such asfn f(m1: MastForest, m2: MastForest) -> MastForest
wouldn't be possible anymore (although it isn't clear to me at the moment whether these will ever be necessary)MastNodeId
s of one of their arguments would still be possible, e.g.fn f<T1, T2>(m1: MastForest<T1>, m2: MastForest<T2>) -> MastForest<T1>