You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
node: take context as argument to all ConstructNode constructors
In the new GhostCell paradigm it will be impossible for a Type (and
therefore a ConstructNode) to outlive its context. This means that
all the methods which currently return a disembodied ConstructNode
need to accept a context as a parameter.
In effect, this puts "direct constructors" and parsers/decoders of
ConstructNodes on even footing: people doing direct construction of
programs have always needed to create a context and keep track of it,
since the constructors iden(), unit(), witness() and jets all need
one. The other constructors simply copy the context Arc from the
objects.
This design had a couple goals:
* Minimizing pain for users by minimizing the number of places they had
to pass a context object
* Minimizing errors by using "the correct context object" automatically
by storing an Arc and cloning it behind the scenes
* Allowing users of decode_expression and ConstructNode::from_str to not
think about contexts at all.
However, I observe that the "minimizing pain" goal is not that valuable
since this only applies to ConstructNode (since CommitNode and RedeemNode
have complete types in them, and these are much more commonly used than
ConstructNode). Furthermore:
* The current logic actually makes it impossible to decode two expressions
and then combine them, since they'll have different associated type
contexts. (I guess nobody has tried this?? They would get a panic.)
* The "minimizing errors" goal we can achieve by GhostCell, at compile
time and much more thoroughly, and in a way that "feels Rustic" in
that it levers the existing borrowchecker.
0 commit comments