On Tue, Jun 2, 2015 at 10:50 AM, Jonathan S. Shapiro <[email protected]> wrote:
> On Mon, Jun 1, 2015 at 10:58 AM, Matt Oliveri <[email protected]> wrote:
>>
>> I don't see forward references as fundamentally different from
>> recursive definitions, since that's exactly what they let you do....
>
>
> Yeah. Never mind. Don't know what I was thinking when I started in on
> co-recursive types. Chalk it up to a brain fart.
>
> The question from a language design perspective is whether we want to
> consider getting rid of forward declarations altogether in favor of using
> LETREC and TYPEREC (placeholder name) for that purpose.
I don't have a preference.
> For types, I don't think we even need TYPEREC, because everything you can do
> with TYPEREC is subsumed by parameterization. E.g. you can simply use a type
> variable as a placeholder. So e.g:
>
> struct S 'a {
> ... other fields ..
> recursive : 'a
> }
>
> struct corecurse {
> corecurses : S corecurse
> }
>
> or some such. If that suffices, then there is no real semantic gain to
> forward declarations, but I still think there is some expressive
> simplification to be had from them.
I agree. I don't think you technically need mutually recursive types
as long as you have recursive types and type parameters. But it's
often clearer and more convenient to use mutually recursive types.
Oh wait, what about mutually recursive type constructos? You'd need
higher order type constructors to do that. Perfectly possible,
semantically speaking, but without mutually recursive type-level
definitions, you're committing yourself to sufficiently-expressive
parameterized types.
> The other question, I suppose, is whether we really need LETREC at all given
> the existence of forward declarations. I'm not inclined to remove it, but
> it's still helpful to know which constructs are adding power to the language
> and which ones aren't.
Well actually, it seems slightly ugly to me to have both. Whereas I
doubt anyone would avoid mutually recursive definitions by using
parameters just because they can, there doesn't seem to be any good
reason to prefer forward references over LETREC, or vice versa, aside
from personal taste. Code would end up using both, and people would
say "Huh?".
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev