@@ -18,7 +18,7 @@ method open(IO::Handle:D:
18
18
Str :$mode,
19
19
:$r, :$w, :$a, :$x, :$update, :$rw, :$rx, :$ra,
20
20
:$create, :$append, :$truncate, :$exclusive,
21
- :$buffer
21
+ :$out-buffer, :$in- buffer
22
22
--> IO::Handle:D
23
23
)
24
24
@@ -84,24 +84,15 @@ modes in this case will result in exception being thrown.
84
84
85
85
In B < 6.d > language, path C < '-' > has no special meaning.
86
86
87
- Passing the C < :buffer > named argument enables output buffering for the handle,
88
- while C < :!buffer > disables it. The output buffer size is implementation defined.
89
- Passing an C < Int > allows the buffer size to be specified (the units are bytes);
90
- C < :0buffer > is equivalent to disabling output buffering. If a value other than
91
- an C < Int > or a C < Bool > is passed, it will be coerced into an C < Int > .
92
-
93
- When no output buffering options are specified, then the default will be
94
- C < :buffer > for non-TTY handles, and C < :!buffer > for TTY handles. A Perl 6
95
- implementation is required to flush the output buffers of C << PROCESS::<$OUT> >>
96
- and C << PROCESS::<$ERR> >> at program exit. All other handles should be
97
- explicitly closed to ensure that output buffers are flushed as part of the
98
- closing.
87
+ The C < :out-buffer > and C < :in-buffer > control input and output buffering
88
+ and by default behave as if values were C < Nil > .
89
+ See methods L < out-buffer > and L < in-buffer > for details.
99
90
100
91
B < Note: > unlike some other languages, Perl 6 does not use reference counting,
101
- and so B < the file handles are NOT flushed or closed when they go out of scope
102
- nor reliably at program exit > . While they I < will > get closed when garbage
103
- collected, garbage collection isn't guaranteed to get run. This means B < you must >
104
- use an explicit C < close > on handles opened for writing, to avoid data loss, and
92
+ and so B < the file handles are NOT flushed or closed when they go out of scope > .
93
+ While they I < will > get closed when garbage collected, garbage collection isn't
94
+ guaranteed to get run. This means I < you should > use an explicit C < close > on
95
+ handles opened for writing, to avoid data loss, and
105
96
an explicit C < close > is I < recommended > on handles opened for reading as well, so
106
97
that your program does not open too many files at the same time, triggering
107
98
exceptions on further C < open > calls.
@@ -488,6 +479,37 @@ my $fh = open 'path/to/file', :w;
488
479
$fh.printf: "The value is %d\n", 32;
489
480
$fh.close;
490
481
482
+ = head2 method out-buffer
483
+
484
+ Defined as:
485
+
486
+ method out-buffer(--> Int:D) is rw
487
+
488
+ Controls output buffering and can be set via an argument to L < open > . Takes
489
+ an C < int > as the size of the buffer to use (zero is acceptable). Can take
490
+ a L < Bool > : C < True > means to use default, implementation-defined buffer size;
491
+ C < False > means to disable buffering (equivalent to using C < 0 > as buffer size).
492
+
493
+ Lastly, can take a C < Nil > to enable TTY-based buffering control: if
494
+ the handle L < is a TTY|/routine/t > , the buffering is disabled, otherwise,
495
+ default, implementation-defined buffer size is used.
496
+
497
+ = head2 method in-buffer
498
+
499
+ Defined as:
500
+
501
+ method in-buffer(--> Int:D) is rw
502
+
503
+ Controls input buffering and can be set via an argument to L < open > .
504
+ Implementations may do partial or no input buffering on
505
+ L < binary|/routine/encoding > handles.
506
+
507
+ Takes an C < int > as the size of the buffer to use (zero is acceptable). Can
508
+ also take a L < Bool > : C < True > means to use default, implementation-defined buffer
509
+ size; C < False > means to disable buffering (equivalent to using C < 0 > as buffer
510
+ size). C < Nil > is also accepted and means to use default, implementation-defined
511
+ buffer size
512
+
491
513
= head2 method put
492
514
493
515
Defined as:
0 commit comments