compiling on solaris 9

skaller skaller at users.sourceforge.net
Mon Sep 17 12:14:04 EDT 2007


On Mon, 2007-09-17 at 13:03 +0100, Simon Marlow wrote:
> skaller wrote:

> > 1. Measure the size (and alignment, while at it) of all the
> > integer types. (trial execute and run).
> 
> We already do this.  Incedentally, the GHC RTS does provide a full 
> complement of explicitly-sized types: Stg{Int,Word}{8,16,32,64} which are 
> correct on all the platforms we currently support.  The header that defines 
> them currently makes some assumptions (e.g. char is 8 bits), but that's 
> only because we're a bit lazy; 

All good programmers are lazy -- the whole point of computers
is to automate things so we can be :)

The algorithm I presented (crudely) goes further. 
What you're doing is enough for a language that doesn't have to 
bind to C and/or C++.

Note that doesn't mean you can't generate C/C++, it means you don't
need to bind to existing libraries.

If you did, you need to do more work as described. For example
if there is a C lib requiring a 

	int*

argument .. there's no way to tell which one of your types,
if any, is aliased to it. Of course .. this only matters in
glue logic, i.e. when you're actually writing C/C++ code,
not if you're generating assembler/machine code and calling
the library directly using the platform ABI based on registers.

When writing glue logic the end user can fix this problem with
platform specific casts, but platform *independent* casts would
be better (e.g. you might cast StgInt32 pointer to long* on
Win64.. but that would make a corey mess if the glue logic 
were compiled on Linux where long is 64 bits).

In Felix, this is critical, because the compiler actually generates
C++ which has to run on all platforms. I actually preferred the
same model you're using: (u)int{8,16,32,64} but it just didn't fly
because of the almost complete dependence on source code based
binding (Felix is roughly a well typed souped up macro processor .. :)

BTW: .. any thoughts on 128 bit integers? I mean, registers are
now 64 bits on desktops. There really should be a double precision
integer type..


-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


More information about the Glasgow-haskell-users mailing list