Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 403 lines (255 sloc) 11.99 kb
fba2bc1 @coke PDD cleanup (TT #1536); Remove maintainer, changes sections.
coke authored
1 # Copyright (C) 2001-2010, Parrot Foundation.
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
2
740e774 @allisonrandal [cage] Cleaning up the PDD titles for better display and
allisonrandal authored
3 =head1 PDD 3: Calling Conventions
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
4
49bf7e6 @allisonrandal [doc] Abandoning daft Perl 5-style documentation headings.
allisonrandal authored
5 =head2 Abstract
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
6
0abc6ea @chipdude Bring pdd03 out of clip purgatory.
chipdude authored
7 Parrot's inter-routine calling conventions.
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
8
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
9
8682534 @leto [cage] Remove more svn-- remnants from our PDDs
leto authored
10
11
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
12
49bf7e6 @allisonrandal [doc] Abandoning daft Perl 5-style documentation headings.
allisonrandal authored
13 =head2 Synopsis
7d2f0b5 @jkeenan Make PPD conform to coding standard for PDDs (https://rt.perl.org/rt3/Ti...
jkeenan authored
14
15 Not applicable.
16
49bf7e6 @allisonrandal [doc] Abandoning daft Perl 5-style documentation headings.
allisonrandal authored
17 =head2 Description
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
18
8e58c2e @jhoblitt reformat all Pods under docs/pdds
jhoblitt authored
19 This document describes how to pass arguments from registers to subroutines,
20 and how subroutines can extract their parameters into registers for use.
b27d0f7 Fixed calling convention docs. Again
Dan Sugalski authored
21
8e58c2e @jhoblitt reformat all Pods under docs/pdds
jhoblitt authored
22 Since Parrot's calling conventions are continuation-based, there is arguably
23 very little difference between a call and a return. Because of this, the
24 conversion rules are the same regardless of whether code is invoking a
25 subroutine or a return continuation.
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
26
49bf7e6 @allisonrandal [doc] Abandoning daft Perl 5-style documentation headings.
allisonrandal authored
27 =head3 Common Features of Argument/Return Opcodes
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
28
8e58c2e @jhoblitt reformat all Pods under docs/pdds
jhoblitt authored
29 There are four opcodes involved in parameter and return value propagation:
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
30
31 =over 4
32
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
33 =item *
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
34
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
35 C<set_args>, for passing arguments;
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
36
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
37 =item *
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
38
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
39 C<set_returns>, for returning values;
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
40
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
41 =item *
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
42
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
43 C<get_params>, for accepting parameters; and
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
44
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
45 =item *
b27d0f7 Fixed calling convention docs. Again
Dan Sugalski authored
46
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
47 C<get_results>, for accepting return values.
b27d0f7 Fixed calling convention docs. Again
Dan Sugalski authored
48
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
49 =back
8f37cf5 tweak calling conventions
Dan Sugalski authored
50
0abc6ea @chipdude Bring pdd03 out of clip purgatory.
chipdude authored
51 FAQ: Given Parrot's internal use of continuation-passing style ["CPS"], it
52 would be possible to use one pair of opcodes for both call and return, since
53 under CPS returns I<are> calls. And perhaps someday we will have only two
2be4a28 * docs/pdds/draft/pdd06_pasm.pod:
Bob Rogers authored
54 opcodes. But for now, certain efficiency hacks are easier with four opcodes.
0abc6ea @chipdude Bring pdd03 out of clip purgatory.
chipdude authored
55
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
56 The common syntax of these opcodes is:
8f37cf5 tweak calling conventions
Dan Sugalski authored
57
3b2acaf @paultcochrane [pdd] Removed deprecated opcode syntax as recommended by Allison Randal....
paultcochrane authored
58 <set_opcode> "flags0, flags1, ..., flagsN", VAL0, VAL1, ... VALN
59 <get_opcode> "flags0, flags1, ..., flagsN", REG0, REG1, ... REGN
60 <get_opcode> "..., 0x200, flags0, ...", ..., "name", REG0, ...
8155c8a MMD 16 - builtin infix multis
Leopold Toetsch authored
61
8e58c2e @jhoblitt reformat all Pods under docs/pdds
jhoblitt authored
62 The flags string is a literal quoted string denoting a list of zero or more
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
63 comma-separated integers. Integers may be specified either in decimal, or if
64 prefixed with "0b"/"0x", in binary/hexadecimal. There must be exactly one
65 integer for each value or register given.
66
0abc6ea @chipdude Bring pdd03 out of clip purgatory.
chipdude authored
67 For documentation purposes we'll number the bits 0 (low) through 30 (high).
68 Bit 31 (and higher, where available) will not be used.
69
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
70 Some values and registers do not correspond directly to values passed or
71 received. (See the descriptions of the OPT_FLAG and NAMED bits, below.)
72
49bf7e6 @allisonrandal [doc] Abandoning daft Perl 5-style documentation headings.
allisonrandal authored
73 =head4 Flag Words; Common Flag Word Bits
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
74
8e58c2e @jhoblitt reformat all Pods under docs/pdds
jhoblitt authored
75 Each integer in the flag string controls the processing of the corresponding
76 value or register.
7dccda2 Changes to the calling conventions
Dan Sugalski authored
77
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
78 These bits of each flag word have common meanings for all argument/
79 return-value opcodes:
7dccda2 Changes to the calling conventions
Dan Sugalski authored
80
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
81 0-3 TYPE
82 0b0000 = I
83 0b0001 = S
84 0b0010 = P
85 0b0011 = N
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
86
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
87 Don't set these bits yourself; the assembler will do it.
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
88
49bf7e6 @allisonrandal [doc] Abandoning daft Perl 5-style documentation headings.
allisonrandal authored
89 =head3 Passing Arguments, Returning Values
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
90
8e58c2e @jhoblitt reformat all Pods under docs/pdds
jhoblitt authored
91 Just before calling a subroutine with C<invokecc> or calling a method with
85e077d @paultcochrane [pdds] Minor formatting and textual corrections.
paultcochrane authored
92 C<call_methodcc>, use the C<set_args> opcode to tell Parrot where the
8e58c2e @jhoblitt reformat all Pods under docs/pdds
jhoblitt authored
93 subroutine's or method's arguments will come from and how they should be
94 expanded by the target.
7ed080d Fixed the PMC parameter passing docs
Dan Sugalski authored
95
7d2f0b5 @jkeenan Make PPD conform to coding standard for PDDs (https://rt.perl.org/rt3/Ti...
jkeenan authored
96 Similarly, just before returning from such a subroutine or method, use
97 the C<set_returns> opcode to tell Parrot where the return values will
98 come from and how to expand them for the caller's use.
7ed080d Fixed the PMC parameter passing docs
Dan Sugalski authored
99
49bf7e6 @allisonrandal [doc] Abandoning daft Perl 5-style documentation headings.
allisonrandal authored
100 =head4 Flag Word Bits For 'Setting'
37a10ea Some precursor changes
Dan Sugalski authored
101
8e58c2e @jhoblitt reformat all Pods under docs/pdds
jhoblitt authored
102 These bits of each flag word have these meanings specific to C<set_args> and
103 C<set_returns>:
37a10ea Some precursor changes
Dan Sugalski authored
104
82bee68 @ambs Changed pre-formatted text to standard POD. Now we can LaTeX it
ambs authored
105 =over 4
106
f40e752 @ambs Some more POD issues for printer-friendly LaTeX version
ambs authored
107 =item 4 C<CONSTANT>
82bee68 @ambs Changed pre-formatted text to standard POD. Now we can LaTeX it
ambs authored
108
109 The value is a literal constant, not a register. (Don't set this bit
110 yourself; the assembler will do it.)
111
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
112 =item 5 C<FLAT> (P only)
113
114 If this bit is set on a PMC value, then the PMC must be an aggregate. The
115 contents of the aggregate, rather than the aggregate itself, will be passed.
82bee68 @ambs Changed pre-formatted text to standard POD. Now we can LaTeX it
ambs authored
116
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
117 If the C<NAMED> bit is also set, the aggregate will be used as a hash; its
589e643 @allisonrandal [cage] Some usage cleanup on "arguments" versus "parameters".
allisonrandal authored
118 contents, as key/value pairs, will be passed as named arguments. The PMC
bab0c32 @jkeenan Change RT reference to TT reference.
jkeenan authored
119 must implement the full hash interface. {{ TT #1288: Limit the required
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
120 interface. }}
82bee68 @ambs Changed pre-formatted text to standard POD. Now we can LaTeX it
ambs authored
121
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
122 If the C<NAMED> bit is not set, the aggregate will be used as an array; its
589e643 @allisonrandal [cage] Some usage cleanup on "arguments" versus "parameters".
allisonrandal authored
123 contents will be passed as positional arguments.
82bee68 @ambs Changed pre-formatted text to standard POD. Now we can LaTeX it
ambs authored
124
125 The meaning of this bit is undefined when applied to integer, number, and
126 string values.
127
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
128 =item 6 (unused)
82bee68 @ambs Changed pre-formatted text to standard POD. Now we can LaTeX it
ambs authored
129
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
130 =item 7 (unused)
82bee68 @ambs Changed pre-formatted text to standard POD. Now we can LaTeX it
ambs authored
131
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
132 =item 8 (unused)
f40e752 @ambs Some more POD issues for printer-friendly LaTeX version
ambs authored
133
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
134 =item 9 C<NAMED> (C<FLAT> or string constant only)
82bee68 @ambs Changed pre-formatted text to standard POD. Now we can LaTeX it
ambs authored
135
136 When the FLAT bit is also set, behavior is as described above in the "FLAT"
137 section. Otherwise, this bit may only be set on a unique string constant
138 specifying the name of the next argument (or returned value).
139
140 =back
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
141
49bf7e6 @allisonrandal [doc] Abandoning daft Perl 5-style documentation headings.
allisonrandal authored
142 =head3 Accepting Parameters, Accepting Return Values
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
143
7d2f0b5 @jkeenan Make PPD conform to coding standard for PDDs (https://rt.perl.org/rt3/Ti...
jkeenan authored
144 As the I<first opcode> in a subroutine that will be called with
145 C<invokecc> or a method that will be called with C<call_methodcc>, use
146 the C<get_params> opcode to tell Parrot where the subroutine's or
147 method's arguments should be stored and how they should be expanded.
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
148
7d2f0b5 @jkeenan Make PPD conform to coding standard for PDDs (https://rt.perl.org/rt3/Ti...
jkeenan authored
149 Similarly, just I<before> (yes, I<before>) calling such a subroutine or
150 method, use the C<get_results> opcode to tell Parrot where the return
151 values should be stored and how to expand them for your use.
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
152
8e58c2e @jhoblitt reformat all Pods under docs/pdds
jhoblitt authored
153 NOTE: It should be obvious, but in case it's not: You must name only registers
154 as targets of these opcodes, not constants. (You can't store anything into a
155 constant. That would make it a variable.)
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
156
49bf7e6 @allisonrandal [doc] Abandoning daft Perl 5-style documentation headings.
allisonrandal authored
157 =head4 Flag Word Bits For 'Getting'
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
158
8e58c2e @jhoblitt reformat all Pods under docs/pdds
jhoblitt authored
159 These bits of each flag word have these meanings specific to C<get_params> and
160 C<get_results>:
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
161
82bee68 @ambs Changed pre-formatted text to standard POD. Now we can LaTeX it
ambs authored
162 =over 4
163
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
164 =item 4 (unused)
82bee68 @ambs Changed pre-formatted text to standard POD. Now we can LaTeX it
ambs authored
165
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
166 =item 5 C<SLURPY> (P only)
82bee68 @ambs Changed pre-formatted text to standard POD. Now we can LaTeX it
ambs authored
167
168 If this bit is set on a P register, then it will be populated with an
169 aggregate that will contain all of the remaining values that have not already
170 been stored in other registers.
171
172 All such values will be converted to PMCs according to the detailed rules
173 below, and those PMCs will be stored into the new aggregate.
174
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
175 If the C<NAMED> bit is also set, the aggregate will be the HLL-specific hash
589e643 @allisonrandal [cage] Some usage cleanup on "arguments" versus "parameters".
allisonrandal authored
176 type and the contents will be all unassigned _named_ arguments.
82bee68 @ambs Changed pre-formatted text to standard POD. Now we can LaTeX it
ambs authored
177
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
178 If the C<NAMED> bit is not set, the aggregate will be the HLL-specific array
589e643 @allisonrandal [cage] Some usage cleanup on "arguments" versus "parameters".
allisonrandal authored
179 type and the contents will be all unassigned positional arguments.
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
180
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
181 =item 6 (unused)
82bee68 @ambs Changed pre-formatted text to standard POD. Now we can LaTeX it
ambs authored
182
f40e752 @ambs Some more POD issues for printer-friendly LaTeX version
ambs authored
183 =item 7 C<OPTIONAL>
82bee68 @ambs Changed pre-formatted text to standard POD. Now we can LaTeX it
ambs authored
184
185 If this bit is set on a register for which no value has been passed, no
186 exception will be raised; rather, the register will be set to a default value:
187 a Null PMC for P, an empty string for S, or zero for N or I.
188
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
189 =item 8 C<OPT_FLAG> (I only)
82bee68 @ambs Changed pre-formatted text to standard POD. Now we can LaTeX it
ambs authored
190
191 An I register with this bit set is set to one if the immediately preceding
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
192 B<OPTIONAL> register received a value; otherwise, it is set to zero. If the
193 preceding register was not marked B<OPTIONAL>, the behavior is undefined; but
194 we promise you won't like it.
82bee68 @ambs Changed pre-formatted text to standard POD. Now we can LaTeX it
ambs authored
195
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
196 =item 8 C<READONLY> (P only)
82bee68 @ambs Changed pre-formatted text to standard POD. Now we can LaTeX it
ambs authored
197
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
198 I<XXX - PROPOSED ONLY - XXX>
82bee68 @ambs Changed pre-formatted text to standard POD. Now we can LaTeX it
ambs authored
199
200 If this bit is set on a P register that receives a value, Parrot will ensure
201 that the final value in the P register is read-only (i.e. will not permit
202 modification). If the received value was a mutable PMC, then Parrot will
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
203 create and set the register to a {not yet invented} read-only PMC wrapper
204 around the original PMC.
82bee68 @ambs Changed pre-formatted text to standard POD. Now we can LaTeX it
ambs authored
205
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
206 Future Notes: Parrot's algorithm for deciding what is writable may be
207 simplistic. In initial implementations, it may assume that any PMC not of a
208 known read-only-wrapper type is mutable. Later it may allow the HLL to
209 provide the test. But we must beware overdesigning this; any HLL with a truly
210 complex notion of read-only probably needs to do this kind of wrapping itself.
82bee68 @ambs Changed pre-formatted text to standard POD. Now we can LaTeX it
ambs authored
211
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
212 =item 8 (unused for S and N)
213
214 =item 9 C<NAMED> (C<SLURPY> or string constant only)
82bee68 @ambs Changed pre-formatted text to standard POD. Now we can LaTeX it
ambs authored
215
216 When the SLURPY bit is also set, behavior is as described above in the
217 "SLURPY" section. Otherwise, this bit may only be set on a unique string
589e643 @allisonrandal [cage] Some usage cleanup on "arguments" versus "parameters".
allisonrandal authored
218 constant specifying the name of the next parameter (or returned value).
82bee68 @ambs Changed pre-formatted text to standard POD. Now we can LaTeX it
ambs authored
219
220 =back
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
221
49bf7e6 @allisonrandal [doc] Abandoning daft Perl 5-style documentation headings.
allisonrandal authored
222 =head4 Overflow and underflow
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
223
ca0d5e6 + Expand description of current overflow/underflow behavior, explain
Bob Rogers authored
224 If too many or too few values are provided for the given target registers,
225 Parrot by default will throw an exception for C<get_params>, but not for
226 C<get_results>. This error behavior can be controlled via the C<errorson> and
227 C<errorsoff> opcodes using C<PARROT_ERRORS_PARAM_COUNT_FLAG> for C<get_params>
228 and C<PARROT_ERRORS_RESULT_COUNT_FLAG> for C<get_results>. (It is not
229 possible to control underflow behavior separately from overflow.)
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
230
ca0d5e6 + Expand description of current overflow/underflow behavior, explain
Bob Rogers authored
231 Note that if the final target is a P register with FLAT set, then overflow can
232 never occur. Similarly, if all target registers are marked B<OPTIONAL>, then
233 underflow is impossible.
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
234
ca0d5e6 + Expand description of current overflow/underflow behavior, explain
Bob Rogers authored
235 Note also that when these errors are off, any excess destination registers in
236 the case of underflow are left untouched, rather than being reset to zero or
237 null. Excess registers explicitly marked B<OPTIONAL> are always reset,
238 regardless of the error flag settings.
a40f31b Added docs on Parrot's calling conventions.
Dan Sugalski authored
239
49bf7e6 @allisonrandal [doc] Abandoning daft Perl 5-style documentation headings.
allisonrandal authored
240 =head4 Ordering of named values (outgoing)
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
241
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
242 Named values (arguments, or values to return) must be listed textually after
243 all the positional values. C<FLAT> and non-C<FLAT> values may be mixed in any
244 order.
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
245
49bf7e6 @allisonrandal [doc] Abandoning daft Perl 5-style documentation headings.
allisonrandal authored
246 =head4 Ordering of named targets (incoming)
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
247
248 Named targets (parameters, or returned values) must appear I<after> all the
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
249 positional targets. A C<SLURPY> positional target, if present, must be the
250 last positional target; a C<SLURPY> named target, if present, must be the last
251 named target.
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
252
253 So the acceptable ordering of targets is:
254
255 =over 4
256
257 =item *
258
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
259 positional non-SLURPY (any number)
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
260
261 =item *
262
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
263 positional SLURPY array (optional)
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
264
265 =item *
266
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
267 NAMED non-SLURPY (any number)
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
268
269 =item *
270
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
271 NAMED SLURPY hash (optional)
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
272
273 =back
274
49bf7e6 @allisonrandal [doc] Abandoning daft Perl 5-style documentation headings.
allisonrandal authored
275 =head4 Mixing named and positional values
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
276
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
277 Positional targets can only be filled with positional values.
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
278
85e077d @paultcochrane [pdds] Minor formatting and textual corrections.
paultcochrane authored
279 Named targets can be filled with either positional or named values.
280 However, if a named target was already filled by a positional value, and
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
281 then a named value is also given, this is an overflow error.
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
282
49bf7e6 @allisonrandal [doc] Abandoning daft Perl 5-style documentation headings.
allisonrandal authored
283 =head4 Type Conversions
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
284
8e58c2e @jhoblitt reformat all Pods under docs/pdds
jhoblitt authored
285 Unlike the C<set_*> opcodes, the C<get_*> opcodes must perform conversion from
286 one register type to another. Here are the conversion rules:
898b4d2 Final release version of pdd03
Dan Sugalski authored
287
288 =over 4
289
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
290 =item *
898b4d2 Final release version of pdd03
Dan Sugalski authored
291
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
292 When the target is an I, N, or S register, storage will behave like an
293 C<assign> (standard conversion).
898b4d2 Final release version of pdd03
Dan Sugalski authored
294
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
295 =item *
898b4d2 Final release version of pdd03
Dan Sugalski authored
296
8e58c2e @jhoblitt reformat all Pods under docs/pdds
jhoblitt authored
297 When the target and source are both P registers, storage will behave like a
298 C<set> (pass by reference).
898b4d2 Final release version of pdd03
Dan Sugalski authored
299
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
300 =item *
898b4d2 Final release version of pdd03
Dan Sugalski authored
301
0abc6ea @chipdude Bring pdd03 out of clip purgatory.
chipdude authored
302 When the target is a P register and the source is an integer, the P will be
757c937 @chromatic [OO] Changed more PMC creation from constant syntax to string style.
chromatic authored
303 set to a new Integer[1] which has been C<assign>ed the given integer.
898b4d2 Final release version of pdd03
Dan Sugalski authored
304
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
305 =item *
898b4d2 Final release version of pdd03
Dan Sugalski authored
306
8e58c2e @jhoblitt reformat all Pods under docs/pdds
jhoblitt authored
307 When the target is a P register and the source is a number, the P will be set
757c937 @chromatic [OO] Changed more PMC creation from constant syntax to string style.
chromatic authored
308 to a new Float[1] which has been C<assign>ed the given number.
898b4d2 Final release version of pdd03
Dan Sugalski authored
309
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
310 =item *
898b4d2 Final release version of pdd03
Dan Sugalski authored
311
8e58c2e @jhoblitt reformat all Pods under docs/pdds
jhoblitt authored
312 When the target is a P register and the source is a string, the P will be set
757c937 @chromatic [OO] Changed more PMC creation from constant syntax to string style.
chromatic authored
313 to a new String[1] which has been C<assign>ed the given string.
898b4d2 Final release version of pdd03
Dan Sugalski authored
314
315 =back
316
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
317 [1] or some other type specified by the current HLL type map, which may
318 substitute an alternative type for each default low-level Parrot type (array,
319 hash, string, number, etc.).
5b3d0e6 update pdd03 to better reflect current state
Leopold Toetsch authored
320
49bf7e6 @allisonrandal [doc] Abandoning daft Perl 5-style documentation headings.
allisonrandal authored
321 =head2 Implementation
7d2f0b5 @jkeenan Make PPD conform to coding standard for PDDs (https://rt.perl.org/rt3/Ti...
jkeenan authored
322
323 Not applicable.
324
49bf7e6 @allisonrandal [doc] Abandoning daft Perl 5-style documentation headings.
allisonrandal authored
325 =head2 Bugs
898b4d2 Final release version of pdd03
Dan Sugalski authored
326
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
327 Required features are missing:
898b4d2 Final release version of pdd03
Dan Sugalski authored
328
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
329 =over 4
6ef5471 Added null ops to core.ops
Dan Sugalski authored
330
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
331 =item *
6ef5471 Added null ops to core.ops
Dan Sugalski authored
332
6d3f9cf @chipdude It's all new. All of it.
chipdude authored
333 Specific exceptions to throw for specific errors.
334
335 =back
336
49bf7e6 @allisonrandal [doc] Abandoning daft Perl 5-style documentation headings.
allisonrandal authored
337 =head2 PIR Syntax Examples
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
338
49bf7e6 @allisonrandal [doc] Abandoning daft Perl 5-style documentation headings.
allisonrandal authored
339 =head3 Function Calls
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
340
6e05a06 @coke [docs] Mark & test more pasm/pir.
coke authored
341 =begin PIR_FRAGMENT_INVALID
342
343 .local pmc foo, i, ar, y, p, value, kw, a, b, c, z
344 # ...
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
345 foo(1, i) # 2 positional arguments
346 foo(x, ar :flat, y) # flattening array
d5305a0 @particle [PDD03[: clarify examples for :named syntax
particle authored
347 foo(p, 'key' => value) # named argument
348 foo(p, value :named('key')) # the same
33fc8c5 pdd03 typo
Leopold Toetsch authored
349 foo(kw :named :flat) # a flattening hash
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
350
1aa4e60 @chipdude Remove the :maybe_flat "feature", which was intended to help Perl 6, but
chipdude authored
351 # all together now: three positional (one flat) with two named (one flat)
352 foo(a, b, c :flat, 'x' => 3, 'y' => 4, z :flat :named('z'))
353
6e05a06 @coke [docs] Mark & test more pasm/pir.
coke authored
354 =end PIR_FRAGMENT_INVALID
355
49bf7e6 @allisonrandal [doc] Abandoning daft Perl 5-style documentation headings.
allisonrandal authored
356 =head3 Parameters
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
357
6e05a06 @coke [docs] Mark & test more pasm/pir.
coke authored
358 =begin PIR
359
360 .sub foo
361 .param int i # positional parameter
362 .param pmc argv :slurpy # slurpy array
363 .param pmc value :named('key') # named parameter
364 .param int x :optional # optional parameter
365 .param int has_x :opt_flag # flag 0/1 x was passed
366 .param pmc kw :slurpy :named # slurpy hash
367 # ...
368 .end
369
370 =end PIR
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
371
49bf7e6 @allisonrandal [doc] Abandoning daft Perl 5-style documentation headings.
allisonrandal authored
372 =head3 Return Values
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
373
6e05a06 @coke [docs] Mark & test more pasm/pir.
coke authored
374 =begin PIR_INVALID
375
376 .sub foo
377 .local pmc i, ar, value
378 .return (i, ar: flat, value :named('key') )
379 .end
380
381 =end PIR_INVALID
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
382
49bf7e6 @allisonrandal [doc] Abandoning daft Perl 5-style documentation headings.
allisonrandal authored
383 =head3 Call Results
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
384
6e05a06 @coke [docs] Mark & test more pasm/pir.
coke authored
385 =begin PIR_FRAGMENT
386
387 .local pmc x, foo, i, j, ar, value
c410b60 @chipdude * Add two more TYPE, allowing for the unknown future.
chipdude authored
388 x = foo() # single result
d5305a0 @particle [PDD03[: clarify examples for :named syntax
particle authored
389 (i, j :optional, ar :slurpy, value :named('key') ) = foo()
6ef5471 Added null ops to core.ops
Dan Sugalski authored
390
6e05a06 @coke [docs] Mark & test more pasm/pir.
coke authored
391 =end PIR_FRAGMENT
392
49bf7e6 @allisonrandal [doc] Abandoning daft Perl 5-style documentation headings.
allisonrandal authored
393 =head2 References
ef9e57c tidy up pdds
Michael Scott authored
394
fba2bc1 @coke PDD cleanup (TT #1536); Remove maintainer, changes sections.
coke authored
395 F<pdd23_exceptions.pod>
ef9e57c tidy up pdds
Michael Scott authored
396
0abc6ea @chipdude Bring pdd03 out of clip purgatory.
chipdude authored
397 =cut
f140bda @chipdude Formatting: standardize word wrap at column 78.
chipdude authored
398
0abc6ea @chipdude Bring pdd03 out of clip purgatory.
chipdude authored
399 __END__
400 Local Variables:
401 fill-column:78
402 End:
Something went wrong with that request. Please try again.