Parrot

=[|The Parrot Primer]: What is Parrot?=

Design goals
Parrot is designed with the needs of dynamically typed languages (such as Perl and Python) in mind, and should be able to run programs written in these languages more efficiently than VMs developed with static languages in mind (JVM, .NET). Parrot is also designed to provide interoperability between languages that compile to it. In theory, you will be able to write a class in Perl, subclass it in Python and then instantiate and use that subclass in a Tcl program.

A quick review of Parrot
Parrot is a register-based virtual machine with 4 register types: Integer, String, Number and PMC. PIR registers are referenced by a $ character, a capital letter signifying the register type followed by the register number ($S15 is String register number 15). Parrot programs consist of lines of text where each line contains one opcode and its arguments.

Each subroutine will have as many registers available of each basic type (int, num, string, and pmc) as necessary; a simple subroutine will only need a few whereas complex subroutines with many calculations will need a larger number of registers. This is a fundamental difference from hardware CPUs (and the original design of Parrot), in which there are a fixed number of registers.

PIR also provides for a more "natural" syntax for opcodes than the standard assembly language op arg, arg format. Rather than writing set $I1, 0 to assign a zero to the $I1 register, you may instead write $I1 = 0. PIR also provides easy syntax for creating named variables and constants, subroutines, passing parameters to subroutines, accessing parameters by name, etc. Now, on to business ...

Instruction formats
Parrot can currently accept instructions to execute in four forms.

1) PAST (Parrot Abstract Syntax Tree) enables Parrot to accept an abstract syntax tree style input - useful for those writing compilers. 2) PIR (Parrot Intermediate Representation) is designed to be written by people and generated by compilers. It hides away some low-level details, such as the way parameters are passed to functions. 3) PASM (Parrot Assembly) is a level below PIR - it is still human readable/writable and can be generated by a compiler, but the author has to take care of details such as calling conventions and register allocation. 4) All of the above forms of input are automatically converted inside Parrot to PBC (Parrot Bytecode). This is much like machine code, but understood by the Parrot interpreter. It is not intended to be human-readable or human-writable, but unlike the other forms execution can start immediately, without the need for an assembly phase. Parrot bytecode is platform independent.

Parrot Design Documents (PDDs)

Design Documents

 * [|PDD 0: Design Document Format]
 * [|[DRAFT PDD 1: Overview]]
 * [|Design Document Template]
 * [|PDD 3: Calling Conventions]
 * [|[DRAFT PDD 5: Opcodes]]
 * [|[DRAFT PDD 6: Parrot Assembly Language (PASM)]]
 * [|PDD 7: Conventions and Guidelines for Parrot Source Code]
 * [|[DRAFT PDD 8: PMC Keys]]
 * [|PDD 9: Garbage Collection Subsystem]
 * [|PDD 10: Embedding]
 * [|[DRAFT PDD 11: Extending]]
 * [|PDD 13: Bytecode]
 * [|[DRAFT PDD 14: Numbers]]
 * [|PDD 15: Objects and Classes]
 * [|[DRAFT PDD 16: Native Call Interface (NCI)]]
 * [|PDD 17: Polymorphic Containers]
 * [|PDD 18: Security Model]
 * [|PDD 19: Parrot Intermediate Representation (PIR)]
 * [|PDD 20: Lexical Variables]
 * [|PDD 21: Namespaces]
 * [|PDD 22: I/O]
 * [|PDD 23: Exceptions]
 * [|PDD 24: Events]
 * [|PDD 25: Concurrency]
 * [|PDD 26: Compiler Tools - Abstract Syntax Tree]
 * [|PDD 27: Multiple Dispatch]
 * [|PDD 28: Strings]
 * [|[DRAFT PDD 29: Compiler Tools]]
 * [|PDD 30: Installation]
 * [|[DRAFT PDD 31: HLL Compilers and Libraries]]