Implicit reboxing of unboxed tuple in let-patterns
rae at richarde.dev
Mon Aug 31 19:14:22 UTC 2020
> On Aug 31, 2020, at 10:34 AM, Spiwack, Arnaud <arnaud.spiwack at tweag.io> wrote:
> That being said, Richard seemed to feel rather strongly about this one. Richard, do you still agree with your then position that let (#x, y#) = … being a lazy pattern (hence implicitly boxes the pair) is the right semantics?
I admit I don't feel as strongly any more. My argument in that thread was from the standpoint of a language designer: there is really no reason, a priori, for an unboxed-tuple binding to be strict. What controls strictness is whether the bound variables are of unlifted type. However, I'm currently in more sympathy with language users, who (for whatever reason) seem to think that bindings with #s in them should be strict. (I have this intuition myself, even though it's not quite warranted on technical grounds.)
What do we think of
> pattern Unl x y = (# x, y #)
> ex1, ex2 :: ()
> ex1 = let Unl x y = Unl undefined undefined in ()
> ex2 = let Unl x y = undefined in ()
? Today, both ex1 and ex2 evaluate to (). If we were to change the specification here, would we consider any unlifted-type pattern (where the type of the pattern itself is unlifted, independent of the type of any of its bound variables) to be banged? Or would it be a super-special case for unboxed tuples?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ghc-devs