On Thu, Sep 4, 2014 at 10:17 AM, Raoul Duke <[email protected]> wrote:
> > Anybody understand this well enough to explain it to me? > > not i. > > what would it look like in regular ml/haskell/etc. style data > constructoring? would it just end up being insanely verbose? is it not > even doable? It's not doable. There are variants that have looked at so-called union type. Those languages typically use a syntax similar to 'a|'b. There are a bunch of complications with this, the biggest one being that the union type is not discriminated. Note that union type in this sense does not mean polymorphism. It means that a single piece of code is going to receive an argument that may be one type or the other, and needs to somehow figure out which one. If we can discriminate the union somehow, then all these complications go away. In the AST case, we actually *can* discriminate the union, because we know the parent node type and the index number that was used to fetch the child. That tells us that certain AST types are not allowed for this child, and we can do a CASE statement on the rest. The child discrimination, in that case, is used to justify why the non-exhaustive case statement is safe. The discrimination performed by the CASE then differentiates between the remaining cases. Discriminators don't inherently need to be union leg tags. All we really need is a statically computable constant expression that derives a unique value for each leg. Jonathan
_______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
