Revision 29624
- Date:
- 2010/02/03 01:09:04
- Files:
Legend:
- Added
- Removed
- Modified
-
docs/Perl6/Spec/S07-iterators.pod
222 222 No list should ever contain the C<EMPTY> exception, since iterational 223 223 control flow should always terminate when that value is returned. 224 224 225 Note: C<get> and C<getobj> must be atomic for any iterator shared 226 by more than one thread, since it is likely that message passing is 227 implemented in terms of them. 228 225 229 =head2 method batchobj ($max?) {...} 226 230 227 231 Returns a batch of parcels/objects in some appropriate C<Positional> type that … … 379 383 380 384 =head2 Generic Lazy Slice 381 385 382 The generic lazy slice consumes the C<Capture>s from an iterator but 386 The generic lazy slice consumes the C<Parcel>s from an iterator but 383 387 stores the results as a bi-dimensional list, where the first dimension 384 388 corresponds to an iteration, and the second contains the values in 385 389 the C<Parcel> returned for that iteration, but turned into a C<Seq> object. 386 390 Empty C<Parcel> objects are turned into empty C<Seq> objects. 391 Any other object is returned as itself. 387 392 388 To obtain a generic lazy slice, end a feed in a sliced C<Positional>. 393 To obtain a generic lazy slice, end a feed in a sliced binding. 389 394 390 my @@it <== map { ... }, 1,2,3; 395 my **@it <== map { ... }, 1,2,3; 391 396 392 (XXX TODO: 397 Note that in: 393 398 394 @@it <== (1,mysub(),2;1,2,3); 395 @@it[0]; 396 @@it[0;1]; 399 my **@it <== (1,mysub(),2; 1..*); 397 400 398 exactly when does mysub() get called?) 401 the slice lists are independently lazy. However, the call to 402 C<mysub()> is not particularly lazy; it occurs when the parcel is 403 constructed. Any laziness is in the function's return value, not in 404 the call. A call in the top level of any parcel is called eagerly. 405 To call a function lazily it is necessary to embed the call in some 406 other explicitly lazy operator: 399 407 408 1, (() ... { START mysub() }), 2 # harder way 409 1, lazy { mysub() }, 2 # easier way 400 410 411 [Note: the above text really belongs somewhere else, but I'm too lazy to 412 figure out where.] 413 401 414 =head1 Coroutines 402 415 403 416 Perl6 does not have a formally defined sub-style coroutine. Doubtless