Skip to content

Commit a62d2ce

Browse files
committed
More GLR discussion, plans, and notes.
1 parent eb232c5 commit a62d2ce

File tree

1 file changed

+80
-3
lines changed

1 file changed

+80
-3
lines changed

S07-glr-draft.pod

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,95 @@ to definitively know if the sequence will be finite or infinite.
142142
to indicate that such sequences are to be treated as known finite
143143
or known infinite.)
144144

145-
=head1 DISCUSSION
145+
=head1 MAJOR CHANGES AND DISCUSSION
146146

147-
During the draft phases of this document, feel free to add questions
148-
and/or discussion points here. Links to #perl6 logs are acceptable.
147+
During the draft phases of this document, the major changes from pre-GLR
148+
are listed here, along with any side-conjectures and discussion. Feel
149+
free to add questions or comments below, including references to relevant
150+
#perl6 irclogs as appropriate.
149151

150152
=over 4
151153

152154
=item *
153155

156+
The C<Parcel> type is going away (yay!). C<< infix:<,> >> will
157+
directly produce C<List> objects. This changes the way that nested
158+
parenthesized comma lists react to things like C<.elems>> and C<.[]>.
159+
160+
(1, (2, 3)).elems # (pre-GLR) 3; (post-GLR) 2
161+
(1, 2, 3..7).elems # (pre-GLR) 7; (post-GLR) 3
162+
163+
=item *
164+
165+
The C<for> statement will no longer flatten the value provided to it.
166+
In fact, C<for> will now be exactly isomorphic to C<.map>:
167+
168+
foo VALUES { ... }
169+
VALUES.map( { ... } } # same thing
170+
171+
This even extends to the case where the thing being iterated is
172+
an itemizing container holding an C<Iterable>:
173+
174+
my $s = <apple banana cherry date eggplant>;
175+
for $s { .say } # five iterations
176+
$s.map: { .say } # five iterations
177+
178+
The end result is fewer requirements for C<.list> or C<@()>
179+
contextualizers on things being iterated that just happen to be
180+
in scalar containers.
181+
182+
=item *
183+
184+
The C<< circumfix:<[ ]> >> array constructor and C<< circumfix:<{ }> >>
185+
hash constructor are no longer itemized by default. Use C<$[ ]> and
186+
C<${ }> to explicitly itemize.
187+
188+
This results in several desirable outcomes:
189+
190+
my @a = [ 1, 2, 3 ]; # @a has three elements
191+
say @a.perl; # "[1, 2, 3]" (trailing "<>" not needed)
192+
193+
=item *
194+
154195
Pm thinks/remembers that people preferred C<Iterable> to be a role
155196
instead of a class.
156197

198+
=item *
199+
200+
Looping constructs ( C<while>, C<for>, C<until>, C<loop> ) will be able
201+
to lazily return lists, as described in C<S04>.
202+
203+
=item *
204+
205+
Because of the above, the GLR will need to improve sink context handling...
206+
in particular by providing caller context. (Jonathan and Pm have already
207+
had discussions about how this can be achieved.)
208+
209+
=item *
210+
211+
The C<gather/take> statement will become much more efficient.
212+
In particular, it will evolve so that some or all C<take> statements
213+
will be able to populate the list without requiring continuations
214+
and exceptions at every step. As a result, it's very possible that
215+
some or most of the underlying list-handling code will be based on
216+
the gather/take system.
217+
218+
=item *
219+
220+
Some miscellaneous notes on list-based methods:
221+
222+
@list.flat # never returns self
223+
@list.list # may return self
224+
@list.kv # returns (0, @list[0], 1, @list[1], ...)
225+
# not ( (0, @list[0]), (1, @list[1]), ...)
226+
227+
=item *
228+
229+
A new type is conjectured that immediately interpolates a list
230+
of values into its surrounding list when it is encountered.
231+
This new type would replace the pre-GLR meaning of C<Nil> and
232+
the temporary C<Empty> type.
233+
157234
=back
158235

159236
=head1 AUTHORS

0 commit comments

Comments
 (0)