Commit 11bf0d4e authored by Eric Myhre's avatar Eric Myhre

Comments about future needs on nodebuilder.

In thinking about how to make a 'bind' (aka, reflect and atlases) Node
implementation, some interesting stuff comes up: despite being all
one concrete Node implementation, it needs specialization (for the
reflect.Value bound inside, specifically); and 'bind' nodes don't
*necessarily* have a schema and a typed.Node associated with them,
so the existing comments about specializing using Type info don't
actually apply.  So!  What do?

These comments are a tad hypothetical (and have been on my uncommitted
working tree for a while, so hopefully they're not *too* stale; I just
want to get them in history somewhere rather than keep dancing my
patches around them)... but there's almost certainly something to
address somewhere in this area.
parent 2fd79241
......@@ -64,6 +64,7 @@ func unmarshal(nb ipld.NodeBuilder, tokSrc shared.TokenSource, tk *tok.Token) (i
}
k = tk.Str
// FUTURE: check for typed.NodeBuilder; need to specialize before recursing if so.
// FUTURE: similar specialization needed for bind.Node as well -- perhaps this actually needs to live on NodeBuilder.
v, err = Unmarshal(nb, tokSrc)
if err != nil {
return nil, err
......
......@@ -76,6 +76,7 @@ func unmarshal(nb ipld.NodeBuilder, tokSrc shared.TokenSource, tk *tok.Token) (i
}
k = tk.Str
// FUTURE: check for typed.NodeBuilder; need to specialize before recursing if so.
// FUTURE: similar specialization needed for bind.Node as well -- perhaps this actually needs to live on NodeBuilder.
v, err = Unmarshal(nb, tokSrc)
if err != nil {
return nil, err
......
......@@ -75,6 +75,7 @@ func unmarshal(nb ipld.NodeBuilder, tokSrc shared.TokenSource, tk *tok.Token) (i
}
k = tk.Str
// FUTURE: check for typed.NodeBuilder; need to specialize before recursing if so.
// FUTURE: similar specialization needed for bind.Node as well -- perhaps this actually needs to live on NodeBuilder.
v, err = Unmarshal(nb, tokSrc)
if err != nil {
return nil, err
......
......@@ -54,6 +54,20 @@ type NodeBuilder interface {
CreateString(string) (Node, error)
CreateBytes([]byte) (Node, error)
CreateLink(Link) (Node, error)
//ForField(string) NodeBuilder // works on maps (degenerately) and structs and (overloaded name) unions
//ForValues() NodeBuilder // works on maps, lists, enums, *not* structs and *not* unions
//ForKeys() NodeBuilder // works on maps
// need an ChildrenAreDiscriminated bool for whether to use per-field or all-values on maps.
// unmarshalling will only ever know it has a NodeBuilder and it has map tokens coming in.
//
// ... what do structs of string repr do?
// nbd, must've already been picked.
//
// ... can we just assume everything is discriminated? what's the perf cost?
// one func call with a constant return, in the unhappy path.
// main question is whether the compiler can optimize that (and the boxing) out correctly.
}
// MapBuilder is an interface for creating new Node instances of kind map.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment