Unpack primitive types by default in data
johan.tibell at gmail.com
Fri Feb 17 01:42:50 CET 2012
On Thu, Feb 16, 2012 at 4:25 PM, Johan Tibell <johan.tibell at gmail.com> wrote:
> The worry is that reboxing will cost us, but I realized today that at
> least one other language, Java, does this already today and even
> though it hurts performance in some cases, it seems to be a win on
> average. In Java all primitive fields get auto-boxed/unboxed when
> stored in polymorphic fields (e.g. in a HashMap which stores keys and
> fields as Object pointers.) This seems analogous to our case, except
> we might also unbox when calling lazy functions.
By the way, I'd like to keep the two sources of reboxing separate.
Users cannot do much about the reboxing that occurs due to using
polymorphic data structures , such as Data.Map. However, the user
can do something about reboxing due to lazy functions, namely making
those functions stricter .
1. In theory the user could create a cut-n-paste copy of the data
structure and specialize it to a particular type, but I think we all
agree that would be unfortunate (not to say that it cannot be
justified in extreme cases.)
2. Although there might be cases when this isn't possible either, as
in the case of non-specialized, non-inlined polymorphic functions.
More information about the Glasgow-haskell-users