Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 1011 lines (658 sloc) 28.892 kB
7c79cd8 Removed some of the ugly bits and constants from Math::Basic, to the …
ajs authored
1
741e884 Added cat and the infix form of zip (Unicode and ASCII). For this, I …
ajs authored
2 =encoding utf8
3
04840a3 [Spec] treat all authors equally
lwall authored
4 =head1 TITLE
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
5
5223afc [docs/Perl6/Spec/Functions.pod]
agentz authored
6 Synopsis 29: Builtin Functions
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
7
04840a3 [Spec] treat all authors equally
lwall authored
8 =head1 AUTHORS
9
10 Rod Adams <rod@rodadams.net>
11 Larry Wall <larry@wall.org>
12 Aaron Sherman <ajs@ajs.com>
13 Mark Stosberg <mark@summersault.com>
14 Carl Mäsak <cmasak@gmail.com>
15 Moritz Lenz <moritz@faui2k3.org>
16 Tim Nelson <wayland@wayland.id.au>
b3ec3ab [Spec/S29-functions.pod] Added some details about die and fail
carlin authored
17 Carlin Bingham <carlin@theintersect.org>
04840a3 [Spec] treat all authors equally
lwall authored
18
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
19 =head1 Version
20
04840a3 [Spec] treat all authors equally
lwall authored
21 Created: 12 Mar 2005
22
3d430cb [S29] restrict Matcher from taking Bool
lwall authored
23 Last Modified: 24 Feb 2010
24 Version: 46
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
25
f185747 [S29] changed outdated notice about document location, noticed by Coke++
moritz authored
26 The document is a draft.
27
9d5a38d P6 Synopsis : ws changes - remove trailing spaces
Darren_Duncan authored
28 If you read the HTML version, it is generated from the pod in the pugs
d2b65db [S29] document Junction.eigenstates, which has been discussed on IRC …
moritz authored
29 repository under /docs/Perl6/Spec/S29-functions.pod so edit it there in
30 the SVN repository if you would like to make changes.
d9840d9 Added blurb about where to find and edit S29 at.
eric256 authored
31
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
32 =head1 Notes
33
b22582e 1st whack at exporting methods.
lwall authored
34 In Perl 6, all builtin functions belong to a named package (generally a
35 class or role). Not all
ddbf48d name whackage of various sorts
lwall authored
36 functions are guaranteed to be imported into the CORE scope.
37 In addition, the list of functions imported into C<CORE> will be
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
38 subject to change with each release of Perl. Authors wishing to
39 "Future Proof" their code should either specifically import the
40 functions they will be using, or always refer to the functions by their
41 full name.
42
43 After 6.0.0 comes out, global aliases will not be removed lightly,
44 and will never be removed at all without having gone through a
45 deprecation cycle of at least a year. In any event, you can specify
46 that you want the interface for a particular version of Perl, and
47 that can be emulated by later versions of Perl to the extent that
48 security updates allow.
49
50 Where code is given here, it is intended to define semantics, not to
51 dictate implementation.
52
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
53 =head2 Operators vs. Functions
54
55 There is no particular difference between an operator and a function,
56 but for the sake of documentation, only functions declared without
57 specifying a grammatical category or with a category of C<term:>
81d7a89 [docs/Perl6/Spec]
agentz authored
58 (see L<S02/"Bits and Pieces">) will be described as "functions",
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
59 and everything else as "operators" which are outside of the scope
ddbf48d name whackage of various sorts
lwall authored
60 of this document. (See S03 for operators.)
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
61
b22582e 1st whack at exporting methods.
lwall authored
62 =head2 Multis vs. Functions
63
d426c8b Note that multies aren't automatically global but are imported by Pre…
lwall authored
64 In actual fact, most of the "functions" defined here are multi
65 subs, or are multi methods that are also exported as multi subs.
ddbf48d name whackage of various sorts
lwall authored
66 The Setting is responsible for importing all the standard multi subs
67 from their various packages into the CORE lexical scope. See S02.
b22582e 1st whack at exporting methods.
lwall authored
68
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
69 =head1 Type Declarations
70
71 The following type declarations are assumed:
72
73 =over
74
75 =item AnyChar
76
77 The root class of all "character" types, regardless of level.
78
22c73b2 [S29] syntaxos (grammaros?) (spellos?) (typos?)
diakopter authored
79 This is a subtype of C<Str>, limited to a length of 1 at its highest
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
80 supported Unicode level.
81
82 The type name C<Char> is aliased to the maximum supported Unicode level
83 in the current lexical scope (where "current" is taken to mean the
84 eventual lexical scope for generic code (roles and macros), not the
85 scope in which the generic code is defined). In other words, use C<Char>
86 when you don't care which level you're writing for.
87
88 Subclasses (things that are C<isa AnyChar>):
89
90 =over
91
23d760e Tweaks to character types. Ling and Graf are dead.
lwall authored
92 =item CharLingua (language-defined characters)
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
93
23d760e Tweaks to character types. Ling and Graf are dead.
lwall authored
94 =item Grapheme (language-independent graphemes)
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
95
ccfe539 [Functions] did away with the Uni type
lwall authored
96 =item Codepoint
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
97
98 =item Byte
99
100 Yes, Byte is both a string and a number.
101
102 =back
103
23d760e Tweaks to character types. Ling and Graf are dead.
lwall authored
104 The short name for C<Grapheme> is typically C<Char> since that's the
ccfe539 [Functions] did away with the Uni type
lwall authored
105 default Unicode level. A grapheme is defined as a base codepoint plus
106 any subsequent "combining" codepoints that apply to that base codepoint.
107 Graphemes are always assigned a unique integer id which, in the case of
108 a grapheme that has a precomposed codepoint, happens to be the same as
109 that codepoint.
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
110
23d760e Tweaks to character types. Ling and Graf are dead.
lwall authored
111 There is no short name for C<CharLingua> because the type is meaningless
112 outside the scope of a particular language declaration. In fact,
113 C<CharLingua> is itself an abstract type that cannot be instantiated.
114 Instead you have names like C<CharFrench>, C<CharJapanese>,
115 C<CharTurkish>, etc. for instantiated C<CharLingua> types.
116 (Plus the corresponding C<StrLingua> types, presumably.)
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
117
b22582e 1st whack at exporting methods.
lwall authored
118 =item Matcher
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
119
3d430cb [S29] restrict Matcher from taking Bool
lwall authored
120 subset Matcher of Mu where none(Bool)
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
121
122 Used to supply a test to match against. Assume C<~~> will be used against it.
3d430cb [S29] restrict Matcher from taking Bool
lwall authored
123 Booleans are forbidden because they almost always indicate a programming
124 error where the argument has been evaluated too soon against the wrong C<$_>.
125 For instance:
126
127 grep $_ == 1, 1,2,3; # evaluating wrong $_, so forbidden
128 grep { $_ == 1 }, 1,2,3; # okay
129 grep * == 1, 1,2,3; # okay
130
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
131
f556581 [docs/Perl6/Spec/Functions.pod]
lanny authored
132 =item Ordering
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
133
0d55ac5 - Standardised on .signature vs. .sig
wayland authored
134 subset KeyExtractor of Code where { .signature === :(Any --> Any) };
135 subset Comparator of Code where { .signature === :(Any, Any --> Int ) };
f556581 [docs/Perl6/Spec/Functions.pod]
lanny authored
136 subset OrderingPair of Pair where { .left ~~ KeyExtractor && .right ~~ Comparator };
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
137
f4dbd60 [S29] expand on use of * in orderings
lwall authored
138 subset Ordering where Signature | KeyExtractor | Comparator | OrderingPair | Whatever;
f556581 [docs/Perl6/Spec/Functions.pod]
lanny authored
139
140 Used to handle comparisons between things. Generally this
aa215cb [S29, S32] removed eqv() and cmp() functions
masak authored
141 ends up in functions like C<sort()>,
f556581 [docs/Perl6/Spec/Functions.pod]
lanny authored
142 C<min()>, C<max()>, etc., as a $by parameter which provides
143 the information on how two things compare relative to each other.
144
145 =over
146
147 =item Comparator
148
149 A closure with arity of 2, which for ordering returns
150 negative/zero/positive, signaling the first argument should
151 be before/tied with/after the second. aka "The Perl 5 way".
152
153 For equivalence the closure returns either not 0 or 0 indicating
154 if the first argument is equivalent or not to the second.
155
156 =item KeyExtractor
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
157
f556581 [docs/Perl6/Spec/Functions.pod]
lanny authored
158 A closure with arity of 1, which returns the "key" by which
159 to compare. Values are compared using C<cmp> for orderings
160 and C<eqv> for equivalences, which in Perl 6 do different
161 comparisons depending on the types. (To get a Perl 5 string
162 ordering you must compare with C<leg> instead.)
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
163
f556581 [docs/Perl6/Spec/Functions.pod]
lanny authored
164 Internally the result of the KeyExtractor on a value should
165 be cached.
166
f4dbd60 [S29] expand on use of * in orderings
lwall authored
167 Note that it is very easy to generate a simple C<KeyExtractor>
168 using C<~*> for strings and C<+*> for numbers, since with most
169 simple operators C<*> returns a closure of one argument.
170
171 @sorted = sort +*, @unsorted; #ascending numeric
172 @sorted = sort -*, @unsorted; #descending numeric
173
f556581 [docs/Perl6/Spec/Functions.pod]
lanny authored
174 =item OrderingPair
175
176 A combination of the two methods above, for when one wishes
177 to take advantage of the internal caching of keys that is
178 expected to happen, but wishes to compare them with something
179 other than C<eqv> or C<cmp>, such as C<E<lt>=E<gt>> or C<leg>.
180
181 =item Signature
182
183 If a signature is specified as a criterion, the signature is
184 bound to each value and then each parameter does comparisons
185 in positional order according to its type, as modified by
186 its traits. Basically, the system will write the body of
187 the key extraction and comparison subroutine for you based on
188 the signature.
189
190 For ordering the list of positional parameter comparisons is
191 reduced as if using [||] but all comparisons do not need to be
192 performed if an early one determines an increasing or decreasing
193 order. For equivalence the list is reduced as if using [&&].
194
f4dbd60 [S29] expand on use of * in orderings
lwall authored
195 =item Whatever
196
197 An ordering of C<*> does the default comparison for the operator:
198
199 @sorted = sort *, @unsorted;
200
f556581 [docs/Perl6/Spec/Functions.pod]
lanny authored
201 =back
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
202
e672426 [docs/Perl6/Spec/Functions.pod]
agentz authored
203 =back
204
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
205 =head1 Function Packages
206
9b4ea89 Carry over @ vs @@ contextualization to zip and Z and map.
lwall authored
207 =head2 Context
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
208
209 =over
210
7c79cd8 Removed some of the ugly bits and constants from Math::Basic, to the …
ajs authored
211 =item caller
212
dff2364 [Spec] slaughter various confusing overloadings of the term 'context'
lwall authored
213 See L<S06/"The C<callframe> and C<caller> functions">.
7c79cd8 Removed some of the ugly bits and constants from Math::Basic, to the …
ajs authored
214
dff2364 [Spec] slaughter various confusing overloadings of the term 'context'
lwall authored
215 =item callframe
bd2bd5e More masak-inspired changes.
wayland authored
216
dff2364 [Spec] slaughter various confusing overloadings of the term 'context'
lwall authored
217 See L<S06/"The C<callframe> and C<caller> functions">.
bd2bd5e More masak-inspired changes.
wayland authored
218
81d7a89 [docs/Perl6/Spec]
agentz authored
219 =item eval
220
f55b3f9 [S29] document eval(Buf)
moritz authored
221 multi eval ( Str|Buf $code, Grammar :$lang = CALLER::<$?PARSER>)
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
222
f55b3f9 [S29] document eval(Buf)
moritz authored
223 Execute C<$code> as if it were code written in C<$lang>. If C<$code>
224 is of type C<Buf>, the same decoding techniques are applied as a compiler
225 for C<$lang> would usually do to input files.
226
227 The default for C<$lang> is the language in effect at the exact
228 location of the eval call.
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
229
9b4ea89 Carry over @ vs @@ contextualization to zip and Z and map.
lwall authored
230 Returns whatever C<$code> returns, or fails.
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
231
232 =item evalfile
233
9b4ea89 Carry over @ vs @@ contextualization to zip and Z and map.
lwall authored
234 multi evalfile (Str $filename ; Grammar :$lang = Perl6)
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
235
236 Behaves like, and replaces Perl 5 C<do EXPR>, with optional C<$lang>
237 support.
238
239
81d7a89 [docs/Perl6/Spec]
agentz authored
240 =item exit
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
241
9b4ea89 Carry over @ vs @@ contextualization to zip and Z and map.
lwall authored
242 multi exit (Int $status = 0)
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
243
244 Stops all program execution, and returns C<$status> to the calling environment.
245
246
247 =item sleep
248
9b4ea89 Carry over @ vs @@ contextualization to zip and Z and map.
lwall authored
249 our Num multi sleep ( Num $for = Inf )
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
250
251 Attempt to sleep for up to C<$for> seconds. Implementations are obligated
a40e8a1 Spellcheck pass on Functions
ajs authored
252 to support sub-second resolutions if that is at all possible.
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
253
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
254 See C<Synopsis 17: Concurrency> for more details.
255
256 =item die
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
257
b3ec3ab [Spec/S29-functions.pod] Added some details about die and fail
carlin authored
258 multi die (@LIST)
259
3767644 [Spec/S29-functions.pod] Fixed mistake with 'die'. carlin--, masak++
carlin authored
260 Throws a fatal Exception. The default exception handler prints each element of
261 the list to $*ERR (STDERR).
b3ec3ab [Spec/S29-functions.pod] Added some details about die and fail
carlin authored
262
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
263 =item fail
264
b3ec3ab [Spec/S29-functions.pod] Added some details about die and fail
carlin authored
265 multi fail (Str $message)
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
266
b3ec3ab [Spec/S29-functions.pod] Added some details about die and fail
carlin authored
267 Can only be called inside a routine and causes the routine to C<return> an
268 unthrown exception; a C<Failure> object which stringifies to C<$message>.
269 If C<use fatal> is in effect where the routine was called from, it throws
270 the exception.
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
271
272 =back
273
274
275 =head2 Conversions
276
277 =over
278
81d7a89 [docs/Perl6/Spec]
agentz authored
279 =item bless
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
280
b4c6aab [S29-functions] chasing spec changes to C<bless>
masak authored
281 our Object method bless(Object::RepCandidate $candidate, *@protos, *%init_args)
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
282
b4c6aab [S29-functions] chasing spec changes to C<bless>
masak authored
283 Calling C<bless> on any invocant (but typically a type object) to create a new
284 object with the same class as the invocant.
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
285
b4c6aab [S29-functions] chasing spec changes to C<bless>
masak authored
286 C<$candidate> is used to provide the underlying representation of the object.
287 The default is C<P6opaque>, but various other representations might be
288 desired, especially when interoperating with other languages. C<@protos> and
289 C<%init_args> both provide ways for values to be provided to the new
290 object, just like in the default C<new> method.
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
291
b4c6aab [S29-functions] chasing spec changes to C<bless>
masak authored
292 C<bless> automatically calls all appropriate C<BUILD> routines by calling the
9b4ea89 Carry over @ vs @@ contextualization to zip and Z and map.
lwall authored
293 C<BUILDALL> routine for the current class, which initializes the object in
81d7a89 [docs/Perl6/Spec]
agentz authored
294 least-derived to most-derived order. See L<S12/Objects>
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
295 for more detailed information on object creation.
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
296
297 =item chr
298
299 =item ord
300
15242ee [S29-functions] fix some misplaced types
lwall authored
301 multi method chr( Int $grid: --> Char ) is export
302 multi sub chr( Int *@grid --> Char )
303 multi method ord( Str $string: --> Int ) is export
ccfe539 [Functions] did away with the Uni type
lwall authored
304
305 C<chr> takes zero or more integer grapheme ids and returns the
306 corresponding characters as a string. If any grapheme id is used
307 that represents a higher abstraction level than the current
308 lexical scope supports, that grapheme is converted to the
309 corresponding lower-level string of codepoints/bytes that would
dff2364 [Spec] slaughter various confusing overloadings of the term 'context'
lwall authored
310 be appropriate to the current pragmatic context, just as any other Str
ccfe539 [Functions] did away with the Uni type
lwall authored
311 would be downgraded in context.
312
313 C<ord> goes the other direction; it takes a string value and returns
a9c37a9 changed "scalar context" into "item context" as per S02
vamped authored
314 character values as integers. In item context, the return value
ccfe539 [Functions] did away with the Uni type
lwall authored
315 is the just the integer value of the first character in the string. In
a9c37a9 changed "scalar context" into "item context" as per S02
vamped authored
316 list context, the return value is the list of integers representing
dff2364 [Spec] slaughter various confusing overloadings of the term 'context'
lwall authored
317 the entire string. The definition of character is pragma dependent.
ccfe539 [Functions] did away with the Uni type
lwall authored
318 Normally it's a grapheme id, but under codepoints or bytes scopes,
319 the string is coerced to the appropriate low-level view and interpreted
320 as codepoints or bytes. Hence, under "use bytes" you will never see a
321 value larger than 256, and under "use codepoints" you will never see a
322 value larger than 0x10ffff. The only guarantee under "use graphemes"
323 (the default) is that the number returned will correspond to the
324 codepoint of the precomposed codepoint representing the grapheme, if
325 there is such a codepoint. Otherwise, the implementation is free to
326 return any unique id that larger than 0x10ffff. (The C<chr> function
327 will know how to backtranslate such ids properly to codepoints or
dff2364 [Spec] slaughter various confusing overloadings of the term 'context'
lwall authored
328 bytes in any context. Note that we are assuming that every codepoint's
329 context knows its normalization preferences, and every byte's context
ccfe539 [Functions] did away with the Uni type
lwall authored
330 also knows its encoding preferences. (These are knowable in the
331 lexical scope via the $?NF and $?ENC compile-time constants).)
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
332
1b62953 [S29] added slice and hash contextualizers, reordered item and list
masak authored
333 =item item
334
335 our Item multi item ( $item )
336
337 Forces generic Item context on its argument, and returns it.
338
912d5a4 [S29] more @@ and iterator patchups
lwall authored
339 =item flat
340
341 our List multi flat ( *@list )
342
22c73b2 [S29] syntaxos (grammaros?) (spellos?) (typos?)
diakopter authored
343 Forces flat context on its arguments, and returns them.
912d5a4 [S29] more @@ and iterator patchups
lwall authored
344 The heavy work is done by the C<*@> binding.
345
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
346 =item list
347
912d5a4 [S29] more @@ and iterator patchups
lwall authored
348 our List multi list ( Iterable $item ) { $item.iterator.list }
349 our List multi list ( List \$iter ) { $iter }
350
351 Almost a no-op; just makes sure that $item can be iterated.
352
353 =item flat
354
355 our List multi flat ( *@list )
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
356
22c73b2 [S29] syntaxos (grammaros?) (spellos?) (typos?)
diakopter authored
357 Forces flat context on its arguments, and returns them.
912d5a4 [S29] more @@ and iterator patchups
lwall authored
358 The heavy work is done by the C<*@> binding.
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
359
1b62953 [S29] added slice and hash contextualizers, reordered item and list
masak authored
360 =item slice
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
361
912d5a4 [S29] more @@ and iterator patchups
lwall authored
362 our List multi slice ( **@list )
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
363
1b62953 [S29] added slice and hash contextualizers, reordered item and list
masak authored
364 Forces the argument list to be evaluated in slice context.
ea2a000 [Spec]reverted \x20 to \xC2A0. "Perl 6" and "Perl 5" are words, so we…
jimmy authored
365 (Slices are considered to be potentially multidimensional in Perl 6.)
912d5a4 [S29] more @@ and iterator patchups
lwall authored
366 Any C<Parcel> within the list will be transformed into a C<Seq>.
367 The work is actually done by the binding to the C<**@> parameter.
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
368
1b62953 [S29] added slice and hash contextualizers, reordered item and list
masak authored
369 =item hash
370
371 The C<hash> contextualizer
372
373 our Hash multi hash ( *@list )
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
374
1b62953 [S29] added slice and hash contextualizers, reordered item and list
masak authored
375 Forces the argument list to be evaluated in hash context.
376 The expression is evaluated in list context (flattening any C<Capture>s),
377 then a hash will be created from the list, taken as a list of C<Pair>s.
378 (Any element in the list that is not a C<Pair> will pretend to be a key
379 and grab the next value in the list as its value.) Equivalent to
380 C<%()> (except that empty C<%()> means C<%($/)>, while
381 empty C<hash()> means an empty hash).
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
382
383 =item :16, :8, :2, :10
81d7a89 [docs/Perl6/Spec]
agentz authored
384
6bd89b1 Whacked a lot of the =$+_ defaults.
lwall authored
385 our Num multi prefix:<:16> ( Str $hexstr )
386 our Num multi prefix:<:8> ( Str $octstr )
387 our Num multi prefix:<:2> ( Str $binstr )
388 our Num multi prefix:<:10> ( Str $decstr )
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
389 etc.
390
391 Interprets string as a number, with a default
392 hexadecimal/octal/binary/decimal radix. Any radix prefix (0b, 0d, 0x, 0o)
6bd89b1 Whacked a lot of the =$+_ defaults.
lwall authored
393 mentioned inside the string will override this operator (this statement is true: 10 == :8("0d10")), except 0b and 0d will be interpreted
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
394 as hex digits by :16 (C<hex("0d10") == :16 "0d10">). C<fail>s on failure.
395
396 These aren't really functions, syntactically, but adverbial forms that
397 just happen to allow a parenthesize argument. But more typically you'll
398 see
399
6bd89b1 Whacked a lot of the =$+_ defaults.
lwall authored
400 :4<222>
401 :16<deadbeef>
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
402
403 and such.
404
405 Replaces Perl 5 C<hex> and C<oct>.
406
407
81d7a89 [docs/Perl6/Spec]
agentz authored
408 =back
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
409
410
5e3f183 Took a stab at run and runinstead as proposed by Larry. Suggested :bg…
ajs authored
411 =head2 OS
412
413 =over
414
6631cff gethost function / methods added
ajs authored
415 =item gethost
416
9b4ea89 Carry over @ vs @@ contextualization to zip and Z and map.
lwall authored
417 our OS::Name multi gethost()
418 our OS::Name multi gethost( Str $name, OS::Addfamily :$type )
6631cff gethost function / methods added
ajs authored
419 our OS::Name multi method gethost( OS::Addr $addr: ) is export
420 our OS::Name multi method gethost( URI $uri: ) is export
421
422 The C<gethost> function operates on host naming or address information
423 and returns an C<OS::Name>. An C<OS::Name> is, minimally:
424
425 class OS::Name {
426 has Str $.name;
427 has OS::Addr $.addr;
428 has Array of Str @.aliases;
429 has Array of OS::Addr @.addrs;
430 }
431
432 Such names can apply to anything which has a name that maps
433 to an address, however, in this case the name is a hostname
434 and the address is some sort of network identifier (e.g.
435 an IPV4 address when resolving hosts that have IPV4 addresses).
436
437 When stringified, an C<OS::Name> yields its name. When
b876595 [Spec/Functions.pod] fixed minor typos, added missing arguments to .fmt
masak authored
438 stringified, an C<OS::Addr> yields its address in an
6631cff gethost function / methods added
ajs authored
439 appropriate text format (e.g. "10.1.2.3" for an IPV4 address).
440
441 The optional C<type> adverb can be passed when resolving a hostname,
442 and will filter the result to only those addresses that are of
443 the appropriate address family. This feature may be supported by
444 the underlying operating system, or Perl may emulate it.
445
446 Examples:
447
448 say "Connection from {$socket.peer.gethost}";
449 my $address = gethost("foo.example.com").addr;
450 my $hostname = gethost(:addr<"10.1.2.3">);
451
54d7c1f Fleshed out OS section with chroot, getlogin and kill -- kill suggest…
ajs authored
452 =item chroot
5e3f183 Took a stab at run and runinstead as proposed by Larry. Suggested :bg…
ajs authored
453
9b4ea89 Carry over @ vs @@ contextualization to zip and Z and map.
lwall authored
454 our Bool multi chroot ( Str $path = CALLER::<$_> )
5e3f183 Took a stab at run and runinstead as proposed by Larry. Suggested :bg…
ajs authored
455
dff2364 [Spec] slaughter various confusing overloadings of the term 'context'
lwall authored
456 On POSIX systems, changes the process context of the current process such
54d7c1f Fleshed out OS section with chroot, getlogin and kill -- kill suggest…
ajs authored
457 that the "root" directory becomes C<$path> and all rooted paths
458 (those that begin with a leading path separator) are relative to
459 that path. For security reasons, many operating systems limit
460 this functionality to the superuser. The return value will be
461 true on success.
462
463 =item getlogin
464
9b4ea89 Carry over @ vs @@ contextualization to zip and Z and map.
lwall authored
465 our Str multi getlogin ()
54d7c1f Fleshed out OS section with chroot, getlogin and kill -- kill suggest…
ajs authored
466
467 Returns the username of the account running the program. This may
468 not be as secure as using C<getpwuid> on some platforms.
469
470 =item kill
471
9b4ea89 Carry over @ vs @@ contextualization to zip and Z and map.
lwall authored
472 our Bool multi kill ( OS::Signal $signal, Bool :$group, *@pids )
473 our Bool multi method kill ( Proc::PID $pid: OS::Signal $signal?, Bool :$group )
54d7c1f Fleshed out OS section with chroot, getlogin and kill -- kill suggest…
ajs authored
474
475 Sends the given C<$signal> to the process(es) given and returns a boolean
476 value indicating success (true) if all of the processes existed and were
477 sent the signal and failure (false) if any of the processes did not exist
478 or the signal could not be delivered to them.
479
480 The C<$signal> can be initialized from an integer signal number or a
481 string. Common signals are:
482
483 KILL - stop the process, do not allow it to exit gracefully
484 TERM - stop the process, allow it to exit gracefully
485 HUP - Hangup, often used as a request to re-run from scratch
486 STOP - Pause execution
487 CONT - Continue after a STOP
488
489 Consult your operating system documentation for the full list
490 of signal names and numbers. For compatibility, a signal name
491 may be prefixed with "SIG".
492
3ece885 Concurrency.pod suggests a zero-argument method variant of kill. Docu…
ajs authored
493 The method form may omit the signal. In this case, the default signal is
494 C<'TERM'>.
495
54d7c1f Fleshed out OS section with chroot, getlogin and kill -- kill suggest…
ajs authored
496 If the C<:group> named parameter is passed, C<kill> will attempt to
497 send the signal to a process I<group> rather than a single process.
498 This functionality is platform-specific.
499
500 The special signal C<0> can be sent which does not actually deliver a
a40e8a1 Spellcheck pass on Functions
ajs authored
501 signal at all, and is used to determine if processes are still running:
54d7c1f Fleshed out OS section with chroot, getlogin and kill -- kill suggest…
ajs authored
502
503 say "Still running" if $proc.kill(0);
504
5e3f183 Took a stab at run and runinstead as proposed by Larry. Suggested :bg…
ajs authored
505 =item run
506
27c19bb History as written by the winners:
lwall authored
507 our Proc::Status multi run ( ; Str $command, :%env = %*ENV )
508 our Proc::Status multi run ( ; Str $path, *@args, :%env = %*ENV )
509 our Proc::Status multi run ( Str @path_and_args, :%env = %*ENV )
5e3f183 Took a stab at run and runinstead as proposed by Larry. Suggested :bg…
ajs authored
510
27c19bb History as written by the winners:
lwall authored
511 our Proc multi run ( ; Str $command, Bool :$bg!, :%env = %*ENV )
512 our Proc multi run ( ; Str $path, Bool :$bg!, *@args, :%env = %*ENV )
513 our Proc multi run ( Str @path_and_args, Bool :$bg!, :%env = %*ENV )
5e3f183 Took a stab at run and runinstead as proposed by Larry. Suggested :bg…
ajs authored
514
515 C<run> executes an external program, and returns control to the caller
516 once the program has exited.
517
518 The default form expects a single string argument which contains the
519 full command-line. This command-line will be scanned for special
520 characters that the operating system's shell might interpret such as
521 C<;> or embedded quotes. If any are found, the command will be run
522 through a sub-shell in an operating system specific fashion (on
523 POSIX systems, this means C<sh -c>).
524
525 If called like this:
526
527 run( :path<'/some/path'>, 'arg1', 'arg2', ... )
528
529 or with a single array (containing both the path and arguments), then the
530 path given is executed directly with no shell interpretation.
531
532 The return value is the exit status
533 of the program, and can be evaluated in the following contexts:
534
535 Bool - True = success; False = failure
536 Int - Exit status (per the .exit method)
537
9b4ea89 Carry over @ vs @@ contextualization to zip and Z and map.
lwall authored
538 See C<wait> for more detail on how the C<Proc::Status> object
5e3f183 Took a stab at run and runinstead as proposed by Larry. Suggested :bg…
ajs authored
539 is used.
540
541 On failure to execute, an undefined value is returned.
542
543 If the C<:bg> named parameter is passed, the program will be executed
544 in the background, and the run command will return as soon as the
545 child process is created. This means that the object returned is
9b4ea89 Carry over @ vs @@ contextualization to zip and Z and map.
lwall authored
546 actually a C<Proc>, which represents the created process.
5e3f183 Took a stab at run and runinstead as proposed by Larry. Suggested :bg…
ajs authored
547
548 [ Note: should the :bg form take rw filehandles or is that over-overloading
549 the functionality of run? Should run be the new open with
550 respect to executing external code? -ajs ]
551
552 [ Note: system() should be renamed to sys() or sh() or run() or
553 some such to avoid P5-induced boolean inversion confusion, plus
a40e8a1 Spellcheck pass on Functions
ajs authored
554 Huffmanize it a little better. I'm thinking run() might be best
5e3f183 Took a stab at run and runinstead as proposed by Larry. Suggested :bg…
ajs authored
555 for MMD reasons. --law
556
557 Note: exec should also be renamed to something clearer and "final"
558 and huffmanly longer. I'm thinking runinstead(). And maybe the
559 function behind qq:x should be rungather() rather than readpipe(). -law
560 ]
561
54d7c1f Fleshed out OS section with chroot, getlogin and kill -- kill suggest…
ajs authored
562 =item runinstead
563
9b4ea89 Carry over @ vs @@ contextualization to zip and Z and map.
lwall authored
564 multi runinstead ( ; Str $path, *@args )
565 multi runinstead ( ; Str $command )
54d7c1f Fleshed out OS section with chroot, getlogin and kill -- kill suggest…
ajs authored
566
567 Identical to C<run> except that it never returns. The executed program
568 replaces the currently running program in memory.
569
fa6452a Moved "syscall" from S16 to S29, as per discussion on mailing list.
wayland authored
570 =item syscall
571
5e3f183 Took a stab at run and runinstead as proposed by Larry. Suggested :bg…
ajs authored
572 =back
573
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
574 =head2 Concurrency
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
575
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
576 There are higher-level models of concurrency management in Perl (see
81d7a89 [docs/Perl6/Spec]
agentz authored
577 L<S17/Concurrency>). These functions are simply the lowest level
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
578 tools
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
579
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
580 =over
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
581
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
582 =item fork
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
583
9b4ea89 Carry over @ vs @@ contextualization to zip and Z and map.
lwall authored
584 our Proc sub Processes::fork()
212b018 Various builtin clarifications such as s/undef/undefine/.
lwall authored
585
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
586 Creates a copy of the current process. Both processes return from
587 C<fork>. The original process returns
9b4ea89 Carry over @ vs @@ contextualization to zip and Z and map.
lwall authored
588 the I<child> process as a C<Proc> object. The newly created process
589 returns the I<parent> process as a C<Proc> object. As with
590 any Proc object, the child process object numifies to the
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
591 process ID (OS dependent integer). However, the parent process object
592 numifies to C<0> so that the child and parent can distinguish each other.
212b018 Various builtin clarifications such as s/undef/undefine/.
lwall authored
593
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
594 Typical usage would be:
212b018 Various builtin clarifications such as s/undef/undefine/.
lwall authored
595
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
596 if !defined(my $pid = fork) {
597 die "Error calling fork: $!";
598 } elsif $pid == 0 {
599 say "I am the new child!";
600 exit 0;
601 } else {
602 say "I am the parent of {+$pid}";
603 wait();
604 }
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
605
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
606 =item wait
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
607
9b4ea89 Carry over @ vs @@ contextualization to zip and Z and map.
lwall authored
608 our Proc::Status multi method wait( Proc $process: *%options )
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
609
9b4ea89 Carry over @ vs @@ contextualization to zip and Z and map.
lwall authored
610 our Proc::Status multi wait ( Proc $process = -1, *%options )
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
611
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
612 Waits for a child process to terminate and returns the status
a2091db Make it clear that wait needs a numifyable return value
ajs authored
613 object for the child. This status object will numify to the process
614 ID of the child that exited.
615
9b4ea89 Carry over @ vs @@ contextualization to zip and Z and map.
lwall authored
616 Important Proc::Status methods:
212b018 Various builtin clarifications such as s/undef/undefine/.
lwall authored
617
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
618 .exit - Numeric exit value
619 .pid - Process ID
620 .signal - Signal number if any, otherwise 0
212b018 Various builtin clarifications such as s/undef/undefine/.
lwall authored
621
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
622 For historical reasons there is a C<.status> method which is equal to:
212b018 Various builtin clarifications such as s/undef/undefine/.
lwall authored
623
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
624 ($status.exit +< 8) +| $status.signal
212b018 Various builtin clarifications such as s/undef/undefine/.
lwall authored
625
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
626 If C<$process> is supplied, then wait will only return when the given process
9b4ea89 Carry over @ vs @@ contextualization to zip and Z and map.
lwall authored
627 has exited. Either a full C<Proc> object can be passed, or just a
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
628 numeric process ID. A C<-1> explicitly indicates that wait should return
629 immediately if any child process exits.
630
9b4ea89 Carry over @ vs @@ contextualization to zip and Z and map.
lwall authored
631 When called in this way, the returned C<Proc::Status> object
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
632 will have a C<.pid> of C<-1> (which is also what it numifies to) if
633 there was no such process to wait for.
634
635 The named options include:
636
637 =over
638
639 =item blocking
640
641 Defaults to true. If set to false, this forces wait to return immediately.
642
643 =item WNOHANG
644
645 Exists for historical compatibility. C<WNOHANG => 1> is identical to
646 C<blocking => False>.
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
647
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
648 =back
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
649
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
650 =back
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
651
d27427e S16: Added a few attributes to trees
wayland authored
652 =head2 Pending Apocalypse
653
654 The following functions are classified by Apocalypse/Synopsis numbers.
655
656 =over 4
657
658 =item A/S??: OS Interaction
659
660 chroot crypt getlogin /[get|set][pw|gr].*/ kill setpgrp setpriority
661 times
662
663 ... These are probably going to be part of POSIX, automatically imported to GLOBAL B<if> the platform is the right one
664
665 =back
666
667 =head2 Default Functions
668
669 These functions are exported into the default namespace
670
855c007 [S29] fix Pod errors
hinrik authored
671 =over
672
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
673 =item all -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
674
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
675 =item any -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
676
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
677 =item cat -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
678
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
679 =item classify -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
680
681 =item defined -- see S32-setting-library/Scalars.pod
682
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
683 =item grep -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
684
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
685 =item first -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
686
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
687 =item keys -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
688
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
689 =item kv -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
690
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
691 =item join -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
692
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
693 =item map -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
694
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
695 =item max -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
696
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
697 =item min -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
698
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
699 =item none -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
700
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
701 =item one -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
702
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
703 =item pairs -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
704
705 =item print -- see S32-setting-library/IO.pod
706
707 =item printf -- see S32-setting-library/IO.pod
708
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
709 =item roundrobin -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
710
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
711 =item pick -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
712
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
713 =item reduce -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
714
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
715 =item reverse -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
716
717 =item say -- see S32-setting-library/IO.pod
718
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
719 =item shape -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
720
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
721 =item sort -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
722
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
723 =item srand -- see S32-setting-library/Numeric.pod
d27427e S16: Added a few attributes to trees
wayland authored
724
5286e00 minor typo
duff authored
725 =item undefine -- see S32-setting-library/Scalars.pod
d27427e S16: Added a few attributes to trees
wayland authored
726
727 =item uri -- see S32-setting-library/IO.pod
728
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
729 =item values -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
730
731 =item warn -- see S32-setting-library/Any.pod
732
328c62a S29: s/Container.pod/Containers.pod/
wayland authored
733 =item zip -- see S32-setting-library/Containers.pod
d27427e S16: Added a few attributes to trees
wayland authored
734
855c007 [S29] fix Pod errors
hinrik authored
735 =back
736
d27427e S16: Added a few attributes to trees
wayland authored
737 =head2 Non-default Functions
738
9d5a38d P6 Synopsis : ws changes - remove trailing spaces
Darren_Duncan authored
739 These functions which existed in perl5 still exist, but are not part of the default
740 namespace any more.
d27427e S16: Added a few attributes to trees
wayland authored
741
742 =head3 Container
743
744 The following functions can now be found in or replaced by something in the Container
9d5a38d P6 Synopsis : ws changes - remove trailing spaces
Darren_Duncan authored
745 modules.
d27427e S16: Added a few attributes to trees
wayland authored
746
747 delete, exists, pop, push, shift, splice, unshift
748
749 =head3 Numeric
750
751 The following functions can now be found in or replaced by something in the Numeric
9d5a38d P6 Synopsis : ws changes - remove trailing spaces
Darren_Duncan authored
752 modules.
d27427e S16: Added a few attributes to trees
wayland authored
753
754 abs, atan2, cos, exp, log, rand, sqrt, sin
755
756 =head3 IO
757
9d5a38d P6 Synopsis : ws changes - remove trailing spaces
Darren_Duncan authored
758 The following functions can now be found in or replaced by something in the IO
759 modules.
d27427e S16: Added a few attributes to trees
wayland authored
760
761 accept, bind, binmode, chdir, chmod, chown, close, closedir, connect
762 eof, fcntl, fileno, flock, getc, getsockname, getsockopt, glob, ioctl, link, listen
763 lstat, mkdir, open, opendir, pipe, print, printf, read, readdir, readline, readlink
764 readpipe, recv, rename, rewinddir, rmdir, say, seek, seekdir, select, send, setsockopt
765 shutdown, socket, socketpair, stat, symlink, sysopen, sysread, sysseek
766 syswrite, tell, telldir, truncate, umask, unlink
767
768 =head3 Temporal
769
9d5a38d P6 Synopsis : ws changes - remove trailing spaces
Darren_Duncan authored
770 The following functions can now be found in or replaced by something in the Temporal
771 modules.
d27427e S16: Added a few attributes to trees
wayland authored
772
773 gmtime, localtime, time
774
775 =head3 String
776
9d5a38d P6 Synopsis : ws changes - remove trailing spaces
Darren_Duncan authored
777 The following functions can now be found in or replaced by something in the String
778 module.
d27427e S16: Added a few attributes to trees
wayland authored
779
9d5a38d P6 Synopsis : ws changes - remove trailing spaces
Darren_Duncan authored
780 chop, chomp, index, lc, lcfirst, pack, quotemeta, rindex, split, sprintf, substr, uc,
d27427e S16: Added a few attributes to trees
wayland authored
781 ucfirst, unpack
782
783 =head2 Obsolete Functions
784
9d5a38d P6 Synopsis : ws changes - remove trailing spaces
Darren_Duncan authored
785 Some of these are obsoleted only as general functions, and are still available by using
786 the right packages. Others are obsoleted in that they're keywords, rather than functions
787 (these are in their own section, below).
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
788
789 =over 4
790
d27427e S16: Added a few attributes to trees
wayland authored
791 =item %
792
793 $num1 % $num2
794
a6df0a3 the '%','mod' are the 'modulo' op; 'modulus' is either what you call …
Darren_Duncan authored
795 Does a floating point modulo operation, i.e. 5.5 % 1 == 0.5 and 5 % 2.5 == 0.
d27427e S16: Added a few attributes to trees
wayland authored
796
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
797 =item dbmopen, dbmclose
798
799 use DB_File;
800
801 =item dump
802
b876595 [Spec/Functions.pod] fixed minor typos, added missing arguments to .fmt
masak authored
803 Dumped. The C<.perl> method fills this role in Perl 6.
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
804
d27427e S16: Added a few attributes to trees
wayland authored
805 =item each
806
9d5a38d P6 Synopsis : ws changes - remove trailing spaces
Darren_Duncan authored
807 See .pairs() method, above.
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
808
affd391 Replaced iterators with NameServices role, based on an idea of ruoso+…
wayland authored
809 =item endpwent, endgrent, endservent, endprotoent, endnetent, endhostent
d98390b Created UserIterator and GroupIterator, and grouped some S29 function…
wayland authored
810
9d5a38d P6 Synopsis : ws changes - remove trailing spaces
Darren_Duncan authored
811 The NameServices role in S16 covers most of these.
d98390b Created UserIterator and GroupIterator, and grouped some S29 function…
wayland authored
812
d27427e S16: Added a few attributes to trees
wayland authored
813 =item format, formline
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
814
815 See Exegesis 7.
816
1bfbfe1 Did some work on users and groups
wayland authored
817 =item getgrgid, getgrnam, getpwnam, getpwuid
818
9d5a38d P6 Synopsis : ws changes - remove trailing spaces
Darren_Duncan authored
819 The User and Group roles in S16 cover most of these.
1bfbfe1 Did some work on users and groups
wayland authored
820
affd391 Replaced iterators with NameServices role, based on an idea of ruoso+…
wayland authored
821 =item getpwent, getgrent, getservent, getnetent, gethostent
d98390b Created UserIterator and GroupIterator, and grouped some S29 function…
wayland authored
822
9d5a38d P6 Synopsis : ws changes - remove trailing spaces
Darren_Duncan authored
823 The NameServices role in S16 covers most of these.
d98390b Created UserIterator and GroupIterator, and grouped some S29 function…
wayland authored
824
d27427e S16: Added a few attributes to trees
wayland authored
825 =item length()
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
826
9d5a38d P6 Synopsis : ws changes - remove trailing spaces
Darren_Duncan authored
827 This word is banned in Perl 6. You must specify units. In practise, this probably means
828 you want Str.chars(), although it could be Str.bytes(), or even something else. See
829 S32-setting-library/String for details.
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
830
d27427e S16: Added a few attributes to trees
wayland authored
831 =item msgctl, msgget, msgrcv, msgsnd
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
832
d27427e S16: Added a few attributes to trees
wayland authored
833 See IPC::SysV
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
834
212b018 Various builtin clarifications such as s/undef/undefine/.
lwall authored
835 =item local
836
837 Replaced by C<temp> which, unlike C<local>, defaults to not changing the value.
838
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
839 =item lock
840
81d7a89 [docs/Perl6/Spec]
agentz authored
841 See L<S17/Concurrency>. C<lock> has been replaced by
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
842 C<is atomic>.
843
d27427e S16: Added a few attributes to trees
wayland authored
844 =item pos
845
846 There is no C<pos> function in Perl 6 because that would not allow a string
847 to be shared among threads. Generally you want to use C<$/.to> for that now,
848 or keep your own position variable as a lexical.
849
850 =item prototype
851
852 &func.meta.signature;
853 &func.^signature;
854
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
855 =item ref
856
857 There is no ref() any more, since it was almost always used to get
858 the type name in Perl 5. If you really want the type name, you can
3cdfd90 [Spec] redefine WHAT to stringify to typename plus '()'
lwall authored
859 use C<$var.WHAT.perl>. If you really want P5 ref
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
860 semantics, use C<Perl5::p5ref>.
861
862 But if you're just wanting to test against a type, you're likely better off
863 performing an C<isa> or C<does> or C<can>, or just C<$var ~~ TYPE>.
864
865 =item reset
866
867 Was there a I<good> use for this?
868
d27427e S16: Added a few attributes to trees
wayland authored
869 =item semctl, semget, semop
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
870
d27427e S16: Added a few attributes to trees
wayland authored
871 See IPC::SysV;
872
affd391 Replaced iterators with NameServices role, based on an idea of ruoso+…
wayland authored
873 =item setpwent, setgrent, setservent, setprotoent, setnetent, sethostent
d98390b Created UserIterator and GroupIterator, and grouped some S29 function…
wayland authored
874
9d5a38d P6 Synopsis : ws changes - remove trailing spaces
Darren_Duncan authored
875 The NameServices role in S16 covers most of these.
d98390b Created UserIterator and GroupIterator, and grouped some S29 function…
wayland authored
876
d27427e S16: Added a few attributes to trees
wayland authored
877 =item shmctl, shmget, shmread, shmwrite
878
879 See IPC::SysV;
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
880
212b018 Various builtin clarifications such as s/undef/undefine/.
lwall authored
881 =item study
882
a40e8a1 Spellcheck pass on Functions
ajs authored
883 Algorithm was too Anglo-centric. Could be brought back if generalized somehow.
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
884
d27427e S16: Added a few attributes to trees
wayland authored
885 =item tie, tied
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
886
d27427e S16: Added a few attributes to trees
wayland authored
887 These are replaced by container types. The compiler is free to assume
888 that any lexical variable is never going to change its container type
889 unless some representation is made to that effect in the declaration.
890 Note: P5's tied() is roughly replaced by P6's variable().
2395ca6 Updates to S29 / Functions based on p6l disucssions and some general …
ajs authored
891
9d5a38d P6 Synopsis : ws changes - remove trailing spaces
Darren_Duncan authored
892 XXX Examples?
8747d5e %
juerd authored
893
9d5a38d P6 Synopsis : ws changes - remove trailing spaces
Darren_Duncan authored
894 my $foo is ....? is tie
895 the meta operation on the container type for 'rebless' -
d27427e S16: Added a few attributes to trees
wayland authored
896 macro tie ( $var, $class, *@args ) { CODE { variable($var).meta.rebless( $class, *@args ) } } )
8747d5e %
juerd authored
897
d27427e S16: Added a few attributes to trees
wayland authored
898 endXXX
8747d5e %
juerd authored
899
d27427e S16: Added a few attributes to trees
wayland authored
900 =item untie
8747d5e %
juerd authored
901
9d5a38d P6 Synopsis : ws changes - remove trailing spaces
Darren_Duncan authored
902 See notes on "tie", above, but basically these are replaced with container classes.
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
903
d27427e S16: Added a few attributes to trees
wayland authored
904 =item vec
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
905
d27427e S16: Added a few attributes to trees
wayland authored
906 Should replace C<vec> with declared buffer/array of C<bit>, C<uint2>,
907 C<uint4>, etc.
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
908
d27427e S16: Added a few attributes to trees
wayland authored
909 =item waitpid
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
910
d27427e S16: Added a few attributes to trees
wayland authored
911 C<wait> can now be called with or without an optional process/pid.
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
912
d27427e S16: Added a few attributes to trees
wayland authored
913 =item write
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
914
d27427e S16: Added a few attributes to trees
wayland authored
915 See Exegesis 7.
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
916
d27427e S16: Added a few attributes to trees
wayland authored
917 =back
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
918
d27427e S16: Added a few attributes to trees
wayland authored
919 =head3 Keywords
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
920
9d5a38d P6 Synopsis : ws changes - remove trailing spaces
Darren_Duncan authored
921 The following were listed in Perl 5's perlfunc, but should now be considered keywords
922 rather than functions.
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
923
d27427e S16: Added a few attributes to trees
wayland authored
924 last, my, next, no, our, package, return, sub, use
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
925
d27427e S16: Added a few attributes to trees
wayland authored
926 =head1 Default Export Questions
927
9d5a38d P6 Synopsis : ws changes - remove trailing spaces
Darren_Duncan authored
928 Not sure whether these are exported by default or not. Also, many may no longer exist; if
929 so, they should be entered in the "Obsolete" section.
d27427e S16: Added a few attributes to trees
wayland authored
930
855c007 [S29] fix Pod errors
hinrik authored
931 =over
932
d27427e S16: Added a few attributes to trees
wayland authored
933 =item Signal-related
934
935 alarm
936 kill
937
938 =item OS or library related
939
d98390b Created UserIterator and GroupIterator, and grouped some S29 function…
wayland authored
940 chroot
941 crypt
942 getlogin
943 getpeername -- should this go on Pipe?
944
945 OS objects:
946
947 --Process
948 getpgrp
949 getppid
950 getpriority
951 setpgrp
952 setpriority
953
954 --Service
955 getservbyname
956 getservbyport
957
958 --Protocol
959 getprotobyname
960 getprotobynumber
961
962 --Network
963 getnetbyaddr
964 getnetbyname
965
966 --Host
967 gethostbyaddr
968 gethostbyname
969
d27427e S16: Added a few attributes to trees
wayland authored
970 =item Flow control
6cac900 S29: Fix formatting
wayland authored
971
f8bc519 [S04] rename break/nobreak to succeed/proceed
lwall authored
972 succeed
973 proceed
d27427e S16: Added a few attributes to trees
wayland authored
974 redo
975
976 =item Other
6cac900 S29: Fix formatting
wayland authored
977
b6cc77c Moved Junctions from S29 to Containers.pod
wayland authored
978 bless
d27427e S16: Added a few attributes to trees
wayland authored
979 caller
980 chr
981 die
982 do
983 eval
984 exec
985 exit
986 fork
987 goto
988 hex
989 import
990 int
991 oct
992 ord
993 require
994 scalar
995 sleep
996 state
997 syscall
998 system
999 times
1000 utime
1001 wait
1002
855c007 [S29] fix Pod errors
hinrik authored
1003 =back
1004
a630d8c * repo-copy S26.pod and S29.pod into docs/Perl6/Spec/.
audreyt authored
1005 =head1 Additions
1006
1007 Please post errors and feedback to perl6-language. If you are making
1008 a general laundry list, please separate messages by topic.
192b028 Renamed .words to .comb
lwall authored
1009
3d430cb [S29] restrict Matcher from taking Bool
lwall authored
1010 =for vim:set expandtab sw=4:
Something went wrong with that request. Please try again.