Skip to content

HTTPS clone URL

Subversion checkout URL

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