Austin Hastings asked:
By extension, if it is NOT given an iterator object, will it appear to
create one?
Yep.
That is, can I say
for (@squares)
{
...
if $special.instructions eq 'Advance three spaces'
{
$_.next.next.next;
}
...
}
or some other suchlike thing that will enable me to consistently
perform iterator-like things within a loop, regardless of origin?
If, by C<$_.next.next.next;> you mean "skip the next three elements
of @squares", then no. $_ isn't an alias to the implicit iterator
over @squares; it's an alias for the element of @squares currently
being iterated.
You want (in my formulation):
my $dance = Iterator.new(@squares);
for $dance {
...
if $special.instructions eq 'Advance three spaces' {
$dance.next.next.next;
}
...
}
(Oh please! Let there be one, and for love of humanity, let it be
called "bork". Pleasepleaseplease!!! It's a shorthand form of "bind or
kontinue", really it is. :-) :-) :-))
"Brain on raw krack" more like it ;-)
So in general, diamonded-function-call implies coroutine/continuation?
That's the problem. I can't see how that works syntactically.
To disagree, vile Aussie! To be looking at perl5's adornmentless
diamond:
>
If I say: while (<>) {print;} I'm asking for file-scan behavior.
Yes. Special case.
If I say: for (@ARGV) { print; } I'm asking for array-scan behavior.
Yes.
If I say: for (<@ARGV>) { print; } I'm asking for trouble?
<grin> Under my proposal, you're saying:
* Grab next element of @ARGV
* Iterate that element.
*Unless* the elements of @ARGV in Perl 6 are actually special Iterator-ish,
filehandle-ish objects that happen to also stringify to the command-line
strings. Hmmmmm.
Proposal:
Seemed very complex to me.
That's "elify", to wit:
"Z'at elify the code?"
"Elify - no."
<GROAN>
Damian