NAME ^

docs/pdds/pdd17_basic_types.pod - Document parrot's basic PMC types

ABSTRACT ^

This PDD documents the base Parrot PMC types and their behaviours.

DESCRIPTION ^

Parrot has a number of basic PMC types that all programs can guarantee will be available to them. (With the possible exception of parrot programs executing on an embedded device or other restricted environment)

Scalar types ^

Undef

This is the generic no-value type. It has a numeric value of zero, a string value of empty string, and a boolean value of false. It will, on assignment, turn itself into a PMC of the source type, or if assigned a basic type will turn itself into one of the wrapper PMC types (detailed below) for the basic types.

Integer

The PMC wrapper for Parrot's low-level integer type. Always an integer, with other types auto-converted to an integer when stored into this PMC. The range and behaviour of the Integer PMC is identical to the platform low-level integer.

The boolean value for an Integer is false if zero, otherwise true.

Floating point, string, and bignum values assigned to an Integer PMC round to the nearest integer. Floats, or strings which resolve to numbers, cap at the platform maximum or minimum integer value.

Integer PMCs take on a value of 1 if a boolean true is assigned, and a value of 0 if a boolean false is assigned.

If an out-of-range value is assigned to an Integer PMC, the PMC will throw an exception if exact math is enabled.

Float

The PMC wrapper for Parrot's low-level floating point type. Always a float, with other types autoconverted to a float when stored into this PMC.

The boolean value for a Float is false if exactly zero, otherwise true.

When converted to an integer, floats round to the closest integer, capping at the platform maximum or minimum integer value.

When converting to a string, floats use the platform default snprintf format.

String

The PMC wrapper for Parrot's low-level string type. Always a simple string, with other types autoconverted to a string when stored into this PMC.

The boolean value for a String is false if empty or the string '0' (a one character string holding a zero) otherwise true. This PMC autoconverts to an integer or float when its integer or float value is fetched.

Boolean

The PMC wrapper for Parrot's low-level true/false value. Returns 0 for false, 1 for true when fetched as an integer or float, empty string for false and '1' for true when fetched as a string.

BigNum

The PMC wrapper for Parrot's low-level BigNum type.

ParrotClass

The PMC for Parrot's class. (Note that this may go away if we ultimately make all classes just objects)

ParrotObject

The PMC for Parrot's base object type.

Reference

The PMC that represents a reference to another PMC. Delegates all functions to the referred-to PMC.

Array types ^

Note that for the following types you can set the size of the array by using the VTABLE_set_integer_native() method. Assigning an integer to the array as a whole sets the array to that size.

Note that size-changing operations, such as push, pop, shift, unshift, and splice, on fixed arrays will result in an exception.

FixedBooleanArray

A statically sized array which holds only Boolean values.

ResizeableBooleanArray

A dynamically sized array which holds only Boolean values.

FixedIntegerArray

A statically sized array which holds only Integer values.

ResizeableIntegerArray

A dynamically sized array which holds only Integer values.

FixedFloatArray

A statically sized array which holds only Float values.

ResizeableFloatArray

A dynamically sized array which holds only Float values.

FixedPMCArray

A statically sized array which holds only PMC values.

ResizeablePMCArray

A dynamically sized array which holds only PMC values.

FixedStringArray

A statically sized array which holds only String values.

ResizeableStringArray

A dynamically sized array which holds only String values.

Hash types ^

Hash

A container with key-value semantics. The values are PMCs.

Env

Env is a singleton PMC class, that is there is only one Env PMC in any interpreter. This PMC gives access to the process' environment variables--reading from it returns the value of the named process environment variable, while writing to it sets the value of a process environment variable. For example, to retrieve the current value of TERM (the terminal type on most Unix systems):

   new P1, .Env
   set S1, P1['TERM']
Note that an embedding system may override this behaviour.

Binary Math operations ^

The following is a list of what should happen with the basic types when used in a binary math operation:

Integer x Integer

The operation is an integer.

IMPLEMENTATION ^

FOOTNOTES ^

List of footnotes to the text.

REFERENCES ^

VERSION ^

CURRENT ^

    Maintainer: Dan Sugalski
    Class: Internals
    PDD Number: 17
    Version: 1.0
    Status: Developing
    Last Modified: 2004/06/11
    PDD Format: 1
    Language: English

HISTORY ^

version 1

None. First version

CHANGES ^

Version 1.0

None. First version


parrot