Parrot's internal data types
1.3
Maintainer: Dan Sugalski <dan@sidhe.org> Class: Internals PDD Number: 4 Version: 1.3 Status: Developing Last Modified: 02 July 2001 PDD Format: 1 Language: English
Fixed some silly typos and dropped phrases.
Took all the underscores out of the field names.
The string header format has changed some to allow for type tagging. The flags information for strings has changed as well.
INT and NUM are now concepts rather than data structures, as making them data structures was a Bad Idea.
None. First version
This PDD describes Parrot's internal data types.
This PDD details the primitive datatypes that the Parrot core knows how to deal with. These types may be at a lower-level than those used by high level languages running on top of Parrot.
Integer data types are generically referred to as INTs. INTs are conceptual things and there is no data structure that corresponds to them.
INT
These are whatever size native integer was chosen at Parrot configuration time. The C-level typedefs INTVAL and UINTVAL get you a platform-native signed and unsigned integer respectively.
INTVAL
UINTVAL
Big integers, or bigints, are arbitrary-length integer numbers. The only limit to the number of digits in a bigint is the lesser of the amount of memory available or the maximum value that can be represented by a UINTVAL. This will generally allow at least 4 billion digits, which ought to be far more than enough for anyone.
The C structure that represents a bigint is:
struct bigint { void *buffer; UINTVAL length; INTVAL exponent; UINTVAL flags; }
The buffer pointer points to the buffer holding the actual number, length is the length of the buffer, exponent is the base 10 exponent for the number (so 2e4532 doesn't take up much space), and flags are some flags for the bigint.
buffer
length
exponent
flags
Note:The flags and exponent fields may be generally unused, but are in to make the base structure identical in size and field types to other structures. They may be removed before the first release of perl 6.
TODO: bring this up to date
Floating point data types are generically referred to as NUMs. Like INTs, NUMs are conceptual things, not real data structures.
NUM
These are whatever size float was chosen when parrot was configured. The C level typedef FLOATVAL will get you one of these.
FLOATVAL
Arbitrary precision decimal numbers, or bignums, can have any number of digits before and after the decimal point. They are represented by the structure:
struct bignum { void *buffer; UINTVAL length; INTVAL exponent; UINTVAL flags; }
and yes, this looks identical to the bigint structure. This isn't accidental. Upgrading a bigint to a bignum should be quick.
Parrot has a single internal string form:
struct parrot_string_t { pobj_t obj; UINTVAL bufused; void *strstart; UINTVAL strlen; const ENCODING *encoding; const CHARTYPE *type; INTVAL language; }
The fields are:
A pointer to a Parrot object, Parrot's most general internal data type. In this case, it holds the buffer for the string data, the size of the buffer in bytes, and any applicable flags.
The amount of the buffer currently in use, in bytes.
A pointer to the beginning of the actual string (which may not be positioned at the start of the buffer).
The length of the string, in characters.
How the data is encoded, for example fixed 8-bit characters, UTF-8, or UTF-32. Note that this specifies encoding only -- it's valid to encode EBCDIC characters with the UTF-8 algorithm. Silly, but valid.
The ENCODING structure specifies the encoding (by index number and by name, for ease of lookup), the maximum number of bytes that a single character will occupy in that encoding, as well as functions for manipulating strings with that encoding.
What sort of string data is in the buffer, for example ASCII, EBCDIC, or Unicode.
The CHARTYPE structure specifies the character type (by index number and by name) and provides functions for transcoding to and from that character type.
TODO: explain what this is for.
TODO: Parrot's other internal datatypes
None
The perl modules Math::BigInt and Math::BigFloat. The Unicode standard at http://www.unicode.org.
Type refers to a low-level perl data type, such as a string or integer.
Class refers to a higher-level piece of perl data. Each class has its own vtable, which is a class' distinguishing mark. Classes live one step below the perl source level, and should not be confused with perl packages.
A package is a perl source level construct.
To install Make, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Make
CPAN shell
perl -MCPAN -e shell install Make
For more information on module installation, please visit the detailed CPAN module installation guide.