From HaskellWiki
< Yhc‎ | RTS
Jump to: navigation, search
Part of Yhc


Because Yhc is ported to several platforms with different word sizes the meaning of the various primitive integer types is non-trivial. This appears both in the descriptions in this document and also in the runtime source code.

Yhc uses both hardware dependent and hardware independent integer types.

Hardware Dependent

The basis of the hardware dependent type is the Word which is always the size of a native pointer (generally either 32 or 64 bits). There are then names for various subdivisions of the Word.

 Word or UInt       - unsigned integer, same size as native pointer
 HWord or HUInt     - unsigned integer, half the size of a Word
 QWord or QUInt     - unsigned integer, quarter the size of a Word
 Int                - signed integer, same size as Word
 HInt               - signed integer, same size as HWord
 QInt               - signed integer, same size as QWord

The distinction between Word and UInt (HWord and HUInt, etc) is whether the item in question is being used as a generic piece of space the same size as a pointer (Word) or whether it is used as an unsigned integer (UInt).

Hardware Independent

The hardware independent types are always exactly the same size on all platforms.

  UByte or UInt8    - unsigned 8 bit integer
  UInt16            - unsigned 16 bit integer
  UInt32            - unsigned 32 bit integer
  Char or Int8      - signed 8 bit integer
  Int16             - signed 16 bit integer
  Int32             - signed 32 bit integer

The different between Char and Int8 is whether it is being used as character or simply as a small integer. The difference between UByte and UInt8 is the same difference as between Word and UInt.