Skip to content

Commit f7ab575

Browse files
committed
Introducing nl-reading/nl-saying, comments welcome
Earlier versions of the spec and the implementation used only the rather verbose "input-line-separator". This was later shortened to "nl", but we lost the inputness of the separator. Since we only use the new line separator on "say", I thought it would be approriate to name that case "nl-saying". Consequently, extending "nl" to "nl-reading" seemed appropriate.
1 parent 738c5b3 commit f7ab575

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

S16-io.pod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,8 @@ These are the methods provided by the PIO role (an alphabetical order):
440440
get get next line
441441
getc get next character
442442
ins number of lines read
443+
nl-reading new line separator when reading
444+
nl-saying new line to be used when saying
443445
lines return rest of contents as lines
444446
opened is it not closed?
445447
p the handle is a pipe

S32-setting-library/IO.pod

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,10 @@ X<note()>
143143

144144
sub note(*@text --> Bool)
145145

146-
Print the given text, followed by a new line C<"\n"> on C<$*ERR>. Before
147-
printing, call the C<.gist> method on any non-C<Str> objects. Return whether
148-
successful. It really just is like L</say()>, but on C<$*ERR>.
146+
Print the given text, followed by a new line (as determined by the
147+
C<"nl-saying"> attribute on C<$*ERR>. Before printing, call the C<.gist>
148+
method on any non-C<Str> objects. Return whether successful. It really just
149+
is like L</say()>, but on C<$*ERR>, except that a bare call will say "Noted".
149150

150151
=head2 open()
151152
X<open()>
@@ -160,8 +161,9 @@ X<open()>
160161
Bool :$bin = False,
161162
Str :$enc = "Unicode", # utf-8 unless otherwise
162163
# newlines
163-
Any :$nl = "EOL",
164-
Bool :$chomp = True,
164+
Any :$nl-reading = "EOL",
165+
Any :$nl-saying = "\n",
166+
Bool :$chomp = True,
165167
--> IO::Handle )
166168

167169
A convenience function for opening normal files as text (by default) as
@@ -204,13 +206,18 @@ figuring out which actual UTF is in use, either from a BOM or other heuristics.
204206
If heuristics are inconclusive, UTF-8 will be assumed. (No 8-bit encoding will
205207
ever be picked implicitly.)
206208

207-
=item :nl
209+
=item :nl-reading
208210

209211
The marker used to indicate the end of a line of text. Only used in text
210212
mode. Defaults to "EOL", which implies accepting any combination of C<"\n">,
211213
C<"\r\n"> or C<"\r"> or any other Unicode character that has the C<Zl>
212214
(Separator, Line) property.
213215

216+
=item :nl-saying
217+
218+
The end of a line of text marker used when C<say>ing on this handle. Defaults
219+
to C<"\n">.
220+
214221
=item :chomp
215222

216223
Whether or not to remove new line characters from text obtained with
@@ -238,9 +245,9 @@ X<say()>
238245

239246
sub say(*@text --> Bool)
240247

241-
Print the given text, followed by a new line C<"\n"> on C<$*OUT>. Before
242-
printing, call the C<.gist> method on any non-C<Str> objects. Return whether
243-
successful.
248+
Print the given text, followed by a new line (as determined by the
249+
C<"nl-saying"> attribute on C<$*OUT>. Before printing, call the C<.gist>
250+
method on any non-C<Str> objects. Return whether successful.
244251

245252
=head2 slurp()
246253
X<slurp()>
@@ -1205,8 +1212,8 @@ X<.get>
12051212
method get(--> Str)
12061213

12071214
Reads the next line and returns it. Uses the (implicit) specification of
1208-
C<:nl> with L</open> to determine where a line ends. Returns a C<Str> type
1209-
object if no more lines to be read.
1215+
C<:nl-reading> with L</open> to determine where a line ends. Returns a C<Str>
1216+
type object if no more lines to be read.
12101217

12111218
=head3 .getc
12121219
X<.getc>

0 commit comments

Comments
 (0)