@@ -103,18 +103,17 @@ relying on this behaviour in new programs is not recommended.
103
103
The C < :out-buffer > controls output buffering and by default behaves as if
104
104
it were C < Nil > . See method L < out-buffer > for details.
105
105
106
- B < Note (Rakudo versions before 2017.09): >
107
- B < Filehandles are NOT flushed or closed when they go out of scope > .
108
- While they I < will > get closed when garbage collected, garbage collection isn't
109
- guaranteed to get run. This means I < you should > use an explicit C < close > on
110
- handles opened for writing, to avoid data loss, and
111
- an explicit C < close > is I < recommended > on handles opened for reading as well, so
112
- that your program does not open too many files at the same time, triggering
113
- exceptions on further C < open > calls.
114
-
115
- B < Note (Rakudo versions 2017.09 and after): > Open filehandles are
116
- automatically closed on program exit, but it is still highly
117
- recommended that you C < close > opened handles explicitly.
106
+ B < Note (Rakudo versions before 2017.09): Filehandles are NOT flushed or closed
107
+ when they go out of scope > . While they I < will > get closed when garbage
108
+ collected, garbage collection isn't guaranteed to get run. This means I < you
109
+ should > use an explicit C < close > on handles opened for writing, to avoid data
110
+ loss, and an explicit C < close > is I < recommended > on handles opened for reading
111
+ as well, so that your program does not open too many files at the same time,
112
+ triggering exceptions on further C < open > calls.
113
+
114
+ B < Note (Rakudo versions 2017.09 and after): > Open filehandles are automatically
115
+ closed on program exit, but it is still highly recommended that you C < close >
116
+ opened handles explicitly.
118
117
119
118
= head2 method comb
120
119
@@ -141,10 +140,10 @@ Defined as:
141
140
142
141
has $.chomp is rw = True
143
142
144
- One of the attributes that can be set via C < .new > or L < open > .
145
- Defaults to C < True > . Takes a L < Bool > specifying whether the line separators
146
- (as defined by L « C < .nl-in > |/type/IO::Handle#method_nl-in» ) should be removed
147
- from content when using L « C < .get > |/type/IO::Handle#method_get» or
143
+ One of the attributes that can be set via C < .new > or L < open > . Defaults to
144
+ C < True > . Takes a L < Bool > specifying whether the line separators (as defined by
145
+ L « C < .nl-in > |/type/IO::Handle#method_nl-in» ) should be removed from content when
146
+ using L « C < .get > |/type/IO::Handle#method_get» or
148
147
L « C < .lines > |/type/IO::Handle#routine_lines» methods.
149
148
150
149
= head2 routine get
@@ -155,11 +154,11 @@ Defined as:
155
154
multi sub get (IO::Handle $fh = $*ARGFILES --> Str:D)
156
155
157
156
Reads a single line of input from the handle, removing the trailing newline
158
- characters (as set by L « C < .nl-in > |/routine/nl-in» )
159
- if the handle's C < .chomp > attribute is set to C < True > . Returns
160
- C < Nil > , if no more input is available. The subroutine form defaults to
161
- L « C < $*ARGFILES > |/language/variables#index-entry-%24%2AARGFILES» if no handle
162
- is given.
157
+ characters (as set by L « C < .nl-in > |/routine/nl-in» ) if the handle's C < .chomp >
158
+ attribute is set to C < True > . Returns C < Nil > , if no more input is available. The
159
+ subroutine form defaults to
160
+ L « C < $*ARGFILES > |/language/variables#index-entry-%24%2AARGFILES» if no handle is
161
+ given.
163
162
164
163
Attempting to call this method when the handle is
165
164
L < in binary mode|/type/IO::Handle#method_encoding > will result in
@@ -216,12 +215,12 @@ Defined as:
216
215
Closes the filehandle, unless its L < native-descriptor > is C < 2 > or lower. This
217
216
ensures the standard filehandles do not get inadvertently closed.
218
217
219
- Note that garbage collection is not guaranteed to
220
- happen, so you must NOT rely on C < DESTROY > for closing the handles you
221
- I < write to > and instead close them yourself. Programs that open a lot of files
222
- should close the handles explicitly as well, regardless of whether they were
223
- open for writing, since too many files might get opened before garbage
224
- collection happens and the no longer used handles get closed.
218
+ Note that garbage collection is not guaranteed to happen, so you must NOT rely
219
+ on C < DESTROY > for closing the handles you I < write to > and instead close them
220
+ yourself. Programs that open a lot of files should close the handles explicitly
221
+ as well, regardless of whether they were open for writing, since too many files
222
+ might get opened before garbage collection happens and the no longer used
223
+ handles get closed.
225
224
226
225
= head2 method gist
227
226
@@ -558,19 +557,19 @@ Defined as:
558
557
multi method put(**@text --> True)
559
558
multi method put(Junction:D --> True)
560
559
561
- Writes the given C < @text > to the handle, coercing any non-L < Str > objects
562
- to L < Str > by calling L « C < .Str > |/routine/Str» method on them, and appending the
563
- value of L « C < .nl-out > |/type/IO::Handle#method_nl-out» at the end. L < Junction > arguments
564
- L < autothread|/language/glossary#index-entry-Autothreading > and the order of printed strings
565
- is not guaranteed.
560
+ Writes the given C < @text > to the handle, coercing any non-L < Str > objects to
561
+ L < Str > by calling L « C < .Str > |/routine/Str» method on them, and appending the
562
+ value of L « C < .nl-out > |/type/IO::Handle#method_nl-out» at the end. L < Junction >
563
+ arguments L < autothread|/language/glossary#index-entry-Autothreading > and the
564
+ order of printed strings is not guaranteed.
566
565
567
566
Attempting to call this method when the handle is
568
567
L < in binary mode|/type/IO::Handle#method_encoding > will result in
569
568
C < X::IO::BinaryMode > exception being thrown.
570
569
571
570
= for code
572
571
my $fh = 'path/to/file'.IO.open: :w;
573
- $fh.print : 'some text';
572
+ $fh.put : 'some text';
574
573
$fh.close;
575
574
576
575
= head2 method say
0 commit comments