On Sat, Dec 27, 2014 at 1:14 PM, Jonathan S. Shapiro <[email protected]> wrote: > On Sat, Dec 27, 2014 at 9:50 AM, Matt Oliveri <[email protected]> wrote: >> >> On Fri, Dec 26, 2014 at 7:44 PM, David Jeske <[email protected]> wrote: >> > Personally, the pattern-like behavior I miss the most in >> > modular-compilation-land is the ability for the compiler to statically >> > validated that matching covers all cases. However, with modular >> > compilation >> > this requires all types used in the matching to be defined in the module >> > the >> > match exists in (so they can't later change after a dependent module >> > update). I suspect this is one of the reasons most languages with solid >> > matching are whole-program-compilers. >> >> I don't follow the reasoning here. Please explain? > > > Matt: > > I believe David is trying to say that a pattern match can be written in such > a way that it only works for certain types. In my opinion, it's stronger > than that. The moment you use a pattern at all, you are either going to > remove most of the genericity at the thing you are matching (e.g. if you > match x::y you're requiring a list 'a) or you are at least going to be > introducing a constraint of some form. (e.g. "those types 'a having member > "x").
That sounds completely expected and non-problematic. If you use a list pattern, you are matching against a list. If you wanted to access some generic sequence, then you should not be using pattern matching! > But I think David isn't entirely right that this is a separate compilation > issue. I think the real issue lies in the fact that the type system that > survives to the late binding stage doesn't admit all of the constraints you > might want. I still don't follow. Constructors in the patterns are not generic; why would we need fancy constraints? The types matched against can and should be heavily constrained to specific type constructors. > Well, that and there's probably a pretty severe boxing penalty in something > like CLI. Scala has a way of supporting pattern matches against OO interfaces. With something like that, and inlining, I figure boxing penalties should not be considered inherent to pattern matching. Well, I guess you aren't going to inline across modules. But I still don't see why you're pinning the blame on pattern matching, and not the data type itself. Hmm, I guess the Scala approach is rather at-odds with the idea that pattern matching can't be generic. But it doesn't have to be. _______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
