On Sun, May 31, 2015 at 11:23 AM, Matt Oliveri <[email protected]> wrote:

> On Sun, May 31, 2015 at 10:51 AM, Jonathan S. Shapiro <[email protected]>
> wrote:
>


> > So first, many of these languages actually don't have a way to define
> > mutually recursive types.
>
> I don't believe you. :) The only popular language I know of that
> doesn't effectively have mutually recursive types is SQL, which of
> course doesn't have recursion at all.
>

So first, I mis-wrote that. I meant to write "co-recursive" as opposed to
"mutually recursive". But I stand by what I said. There are, for example,
no mutually recursive types in Java, C, C#, or (so far as I know) Haskell
or OCaml.

In all of these languages, it is possible to forward-declare a type in some
fashion and then use *references* to the forward-declared type before the
type itself is declared/defined.

That's not a mutually recursive type.


> > Second, merely factoring out the common fields isn't the goal here. The
> goal
> > is to do that in such a way that we end up with a type that can describe
> the
> > kind of AST that is typically associated with a context-free grammar.
>
> Right. I think that context-free-ness is what makes it possible, even
> if it turns out to be too bulky or messy. With context-sensitive,
> you'd need dependent types. (Or just GADTs, if you're lucky.)
>

Perhaps. And I think there's a point at which you say "I've encoded enough
in types to get most of the value I'm going to get out of checking, and
it's time to stop".

But I don't even see a good solution for CFGs, because of the "subunion"
issue. I know how to deal with that using dynamic checks, but not
statically.


shap
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to