Functional syntax (Was: RE: [mercury-users] Hi, and determini sm)

Ralph Becket rbeck at microsoft.com
Mon Feb 5 21:51:04 AEDT 2001


>From Fergus Henderson on 03/02/2001 13:18:11
> 
> Bit fields are handy for when you have a data type with several fields
> that are each less than one word in size, which you want to optimize
> for space rather than speed, by packing multiple fields into a single
> word.  In ML and Mercury you can achieve that by using integer fields
> and manually writing access routines that get and set particular
> groups of bits within a word.  But in C you can use bit fields, which
> means you don't have to write the bit twiddling access routines.

This idea has come up before on the Mercury mailing list.  In fact, the
concept was somewhat more transparent than bitfields: if the compiler
could work out that a given type's values only occupied n bits (either 
by observation or a promise from the programmer) then it could do
bit-packing.

I suspect this would net a tidy performance improvement in many programs.
Moreover, there are many situations where performance requires you to
play the bit-packing game and to have this happen automatically would
remove a key source of bugs in code of this style.

--
Ralph Becket      |      MSR Cambridge      |      rbeck at microsoft.com 

--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list