#ifdef considered harmful (was: DData)

Simon Marlow simonmar at microsoft.com
Fri Apr 16 12:06:02 EDT 2004


 
> "Simon Marlow" <simonmar at microsoft.com> writes:
> 
> > Most of the time it's unnecessary to use an explicit Int#.  
> If your Int
> > is in a data structure, you can use 
> > 
> >   {-# UNPACK #-} !Int
> > 
> > which is portable, and compiles to an unboxed Int in GHC >= 6.2.
> 
> Is this different from 
>         !Int
> and 
>         -funbox-strict
> ?
> 
> (I.e., should I change from this to UNPACK pragmas?)

They both have the same effect, but I prefer to put these hints in the
source code which is why I prefer to use {-# UNPACK #-} rather than the
command-line flag.  Also, sometimes it is necessary to have fine-grained
control over which fields are unpacked.

Cheers,
	Simon


More information about the Libraries mailing list