RE: [Haskell] Re: Boxing (Day) Question
[Moving to haskell-café] You'd still need several versions of the code for a polymorphic function, one for pointer values, one for 4-byte non-pointers, one for 8-byte non-pointers etc. That's what .net does, I believe, but via runtime code generation. Simon | -----Original Message----- | From: haskell-bounces@haskell.org [mailto:haskell-bounces@haskell.org] On Behalf Of Ashley Yakeley | Sent: 29 December 2005 17:56 | To: haskell@haskell.org | Subject: [Haskell] Re: Boxing (Day) Question | | In article | <036EAC76E7F5EC4996A3B3C3657D411604105AB8@EUR-MSG-21.europe.corp.microso | ft.com>, | "Simon Peyton-Jones" <simonpj@microsoft.com> wrote: | | > The .NET CLR lifts the restriction by specialising code, so that it can | > adapt to whether it is moving Int# or Double# values around. In | > Haskell, though, it's not possible to statically generate all the | > instances you need, so you'd need run-time code generation to do this. | > | > It's a real restriction, and sometimes very tiresome, but I'm not | > planning to fix it soon, unless I have a brilliant idea for how to do it | > easily. | | So you don't think having a different kind for each kind of storage | (e.g. #4 for 4-byte values, etc.) would help you here? | | -- | Ashley Yakeley, Seattle WA | | _______________________________________________ | Haskell mailing list | Haskell@haskell.org | http://www.haskell.org/mailman/listinfo/haskell
In article <036EAC76E7F5EC4996A3B3C3657D41160416A761@EUR-MSG-21.europe.corp.microso ft.com>, "Simon Peyton-Jones" <simonpj@microsoft.com> wrote:
You'd still need several versions of the code for a polymorphic function, one for pointer values, one for 4-byte non-pointers, one for 8-byte non-pointers etc.
Yes, but that's up to the user. A type variable always has a particular kind, so for instance one might want an array over any 4-byte non-pointer value: data Array4 (a :: #4) Functions on Array4 only need one version of code. This makes polymorphism less useful, of course, but the goal here is to be closer to the machine. Trouble comes when you try to aggregate, however; one would need kinds that represent 8-byte values consisting of four bytes of data and four bytes of pointer, and so on. -- Ashley Yakeley, Seattle WA
participants (2)
-
Ashley Yakeley -
Simon Peyton-Jones