On Sat, May 30, 2015 at 1:46 PM, Matt Oliveri <atma...@gmail.com> wrote:

> Sounds like we have a misunderstanding alright. I'm gonna get dinner,
> then think of a way to get to the bottom of this.
>

Sounds like. :-)

Let me show the part I don't know how to do in any current language.

Assume we have a templated structure ASTNode<T>. It has a children field.
The intent is that the child field will be some structured type (a record
or a product). Depending on the type T, we want the type of the "child"
field to be different.

I suppose we could do this with a family of AST structures, e.g. where T is
the record type itself. So we might have

struct Expr {
  ASTNode<Expr> * e1;
  ASTNode<Expr> *e2;
}

struct ASTNode<T> {
  ... common fields ...
  T children;
}

though this doesn't seem to handle any of the "subunion" cases in a way I
can obviously see. Except I'm not sure that we can forward-reference a
template in this way.

Even if we can, it begs the question of how to specialize the member
functions of ASTNode, which need to do different things depending on how T
was instantiated. We really don't want do this by using a distinct function
for each type T. The problem is purely practical: it's an unmaintainable
hairball.


shap
_______________________________________________
bitc-dev mailing list
bitc-dev@coyotos.org
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to