[PDD] Add docs for the Parrot_PMC_push_* and Parrot_PMC_pop_* functions
[parrot.git] / examples / tutorial / 60_subroutines.pir
blob1e2c5eeff268d87971178002f3d748360a2bbb00
1 # Copyright (C) 2007-2009, Parrot Foundation.
2 # $Id$
4 =head1 Subroutines
6 PIR is a subroutine-based or "procedural" programming language.
7 Subroutines are used to break large tasks into smaller chunks. These
8 chunks can be used and reused throughout the program. Subroutines
9 are defined with the C<.sub> directive and continue until the C<.end>
10 directive.
12 Subroutines can take any number of input parameters, and can return
13 any number of output parameters. In practice, we recommend you don't
14 go overboard with creating huge argument lists because it gets very
15 messy and difficult to deal with very quickly.
17 =cut
19 .sub main :main
21    $S0 = foo("Zaphod")
22    say $S0
24 .end
26 .sub foo
27     .param string name
29     .local string greeting
30     greeting = "Hello, " . name
32     .return (greeting)
33 .end
35 # Local Variables:
36 #   mode: pir
37 #   fill-column: 100
38 # End:
39 # vim: expandtab shiftwidth=4 ft=pir: