Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 145 lines (99 sloc) 4.019 kb
0a9cc7d S16, IO.pod, springs forth from the quantum foam.
markstos authored
1
2 =encoding utf8
3
4 =head1 Title
5
ca45d7b Moved Signals and IPC from S16 to S17, which can now be processes and…
wayland authored
6 DRAFT: Synopsis 16: IO / User / Group
0a9cc7d S16, IO.pod, springs forth from the quantum foam.
markstos authored
7
8 =head1 Version
9
b9baa2d [IO.pod]
markstos authored
10 Author: Largely, the authors of the related Perl 5 docs.
0a9cc7d S16, IO.pod, springs forth from the quantum foam.
markstos authored
11 Maintainer: Larry Wall <larry@wall.org>
b9baa2d [IO.pod]
markstos authored
12 Contributions: Mark Stosberg <mark@summersault.com>
ee7470e S02: Moved comment about standard file handles to S16.
wayland authored
13 Tim Nelson <wayland@wayland.id.au>
7dd6f86 [spec/S16] move IFS/OFS/IRS/ORS to the more specific roles.
ruoso authored
14 Daniel Ruoso <daniel@ruoso.com>
0a9cc7d S16, IO.pod, springs forth from the quantum foam.
markstos authored
15 Date: 12 Sep 2006
62be922 kill DEF* variants
lwall authored
16 Last Modified: 23 Feb 2009
17 Version: 21
0a9cc7d S16, IO.pod, springs forth from the quantum foam.
markstos authored
18
a74e144 More IO and Functions whackage
lwall authored
19 This is a draft document. Many of these functions will work as in Perl
aba29c8 [spec/S16] proposed role-based api
ruoso authored
20 5, except we're trying to rationalize everything into roles. For
a74e144 More IO and Functions whackage
lwall authored
21 now you can assume most of the important functions will automatically
22 be in the * namespace. However, with IO operations in particular,
23 many of them are really methods on an IO handle, and if there is a
24 corresponding global function, it's merely an exported version of
25 the method.
0a9cc7d S16, IO.pod, springs forth from the quantum foam.
markstos authored
26
1bfbfe1 Did some work on users and groups
wayland authored
27 =head1 IO
28
29 =head2 Overridable IO handles
62be922 kill DEF* variants
lwall authored
30
31 In Perl 6, there are the I<standard> IO handles, and any number of overriding
32 inner filehandles for the same symbol.
33
34 The I<standard> handles are our old familiar friends (with new names).
35 Standard input changed from STDIN to C<$*IN>, standard output changed
36 from STDOUT to C<$*OUT>, and standard error changed from STDERR to
37 C<$*ERR>. In Perl 6 these symbols represent more of a concept than
38 a given filehandle, since the meaning is contextually determined.
39 The process's version of these handles live in the C<PROCESS::>
40 namespace, which is more global than the per-interpreter C<GLOBAL::>
41 namespace.
42
43 When no explicit filehandle is used, the standard IO operators are
44 defined in terms of the contextual variables. So the C<print> function
45 prints to C<$*OUT>, while C<warn> warns to C<$*ERR>. The C<< =<> >>
46 term inputs from C<$*IN>. So any given dynamic scope (interpreter,
47 thread, function or method call) may redefine the current meaning of
48 any of those filehandles within the dynamic scope of itself and of
49 its called routines.
50
51 So to put it another way, when you write something like
52
53 say "Howdy, world!"
54
55 the C<say> function looks for the current meaning of C<$*OUT>, and
56 takes the closest definition it can find in its callers. If none
57 of the callers have overridden the definition, it looks in the
58 interpreter's C<GLOBAL> namespace. If the interpreter hasn't overridden
59 the meaning, it takes the meaning from C<PROCESS>. In essence, any
60 dynamic scope in Perl 6 is allowed to do IO redirection much like
61 a Unix shell does with its subprocesses, albeit with a different
62 syntax:
63
64 {
65 temp $*OUT = open $newfile, :w;
66 foo() # all stdout goes to $newfile
67 }
68 # stdout reverts to outer scope's definition
ee7470e S02: Moved comment about standard file handles to S16.
wayland authored
69
1bfbfe1 Did some work on users and groups
wayland authored
70 =head2 Roles and Classes
e89ba9e S16: Referred to other documents
wayland authored
71
72 The roles and classes that define most of the functionality for IO are defined in
73 S32-setting-library/IO.pod. The main functions used are listed in S29 with references to
74 S32-setting-library/IO.pod.
75
1bfbfe1 Did some work on users and groups
wayland authored
76 =head1 Users and Groups
77
78 =head2 User role
79
80 role User {
81 has $username; # Username (some descendants(?) may want to implement a real $name)
82 has $id; # User ID
83 has $dir; # Home directory for files
84 }
85
86 =item new
87
88 method User new($Username?, $UID?) {...}
89
90 Creates a new User object, fetching the information either by username or user ID.
91
92 =item write
93
94 method write() {...}
95
96 Tries to write the current User object to the user database. This may well fail.
97
98 =item Str
99
100 When converted to a Str, returns $username.
101
102 =item Num
103
104 When converted to a Num, returns $uid.
105
106 =head2 OS::Unix::User role
107
108 role OS::Unix::User does User {
109 has $password;
110 has $gid;
111 has $gecos;
112 has $shell;
113 }
114
115 All the information is naturally fetched from the system via getpwuid, getpwnam, or the
116 like.
117
118 =head2 Group role
119
120 role Group {
121 has $name;
122 has $id;
123 has @members;
124 }
125
126 =item new
127
128 method Group new(:$Name, :$ID);
129
130 =item write
131
132 method write();
133
134 Tries to write the group entry into the system group database.
135
0a9cc7d S16, IO.pod, springs forth from the quantum foam.
markstos authored
136 =head1 Additions
137
138 Please post errors and feedback to perl6-language. If you are making
139 a general laundry list, please separate messages by topic.
1205952 [t\spec] smartlink issues
buchetc authored
140
141 =cut
1bfbfe1 Did some work on users and groups
wayland authored
142
143 =encoding utf8
144
Something went wrong with that request. Please try again.