1 # Copyright (C) 2007-2009, Parrot Foundation.
6 The other kind of variables in PIR are named variables.
7 You declare these with the .local directive, with the type
8 of the variable, followed by the name. The types of named
9 variables are the same set as the types of register
10 variables, int for integer, num for numbers (floats), string
11 for strings, and pmc for PMCs (objects).
13 A simple rule of thumb is to use register variables for
14 variables that are used on 3 or fewer lines of code, and
15 named variables for any longer-lived variables. This is
16 just a suggestion, but we think it really helps improve code
24 answer = 42 # set local integer var to the integer value 42
29 pi = 3.14159 # set local float var to an approximation of pi
33 .local string greeting
34 greeting = "Hello" # set temp string var to "Hello"
39 player = new ['String']
40 player = "Ford" # set temp PMC var to "Ford"
50 # vim: expandtab shiftwidth=4 ft=pir: