On Fri, May 1, 2015 at 11:15 AM Jonathan S. Shapiro <[email protected]> wrote:
> There are three ways we can handle mutual recursion in BitC. One is to > declare (as a matter of design) that mutually recursive functions must be > co-defined within a common LETREC. The other is to take the view that all > top-level function definitions within a single unit of compilation are > understood to occur within a LETREC over the entire compilation unit (which > implies that functions may engage in forward-reference). The third option > is to allow forward declarations within a unit of compilation (as BitC v0 > did), which can be thought of as a compromise in which everything in a unit > of compilation is logically defined in a UoC-granularity LETREC but we add > an additional syntactic requirement (the declaration) both to ease the > problem for type inference and to avert *unintentional* forward reference. > > I am completely comfortable to disallow [static] mutual recursion across > module boundaries, because codependent modules aren't a good thing. I'm > less sanguine about requiring mutually recursive definitions to be defined > in a common [explicit] LETREC. > > Opinions? > It's straightforward to do the graph analysis that adds letrec's implicitly (with the finest possible granularity), so the only advantage of a letrec is explicitness. Thus, my vote would be against explicit letrec: if the compiler can do it for you without a significant increase in complexity (and no confusing runtime penalties), it's better to make it easy for the programmer.
_______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
