Skip to content

HTTPS clone URL

Subversion checkout URL

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