Reading this in Apoc 4
sub mywhile ($keyword, &condition, &block) {
my $l = $keyword.label;
while (&condition()) {
&block();
CATCH {
my $t = $!.tag;
when X::Control::next { die if $t && $t ne $l); next }
when X::Control::last { die if $t && $t ne $l); last }
when X::Control::redo { die if $t && $t ne $l); redo }
}
}
}
Implies to me:
A &foo prototype means you can have a bare block anywhere in the
arg list (unlike the perl5 syntax).
Calling &foo() does *not* effect the callstack, otherwise the
above would not properly emulate a while loop.
If that's true, can pull off my custom iterators?
http:[EMAIL PROTECTED]/msg08343.html
Will this:
class File;
sub foreach ($file, &block) {
# yeah, I know. The RFC was all about exceptions and I'm
# not using them in this example.
open(FILE, $file) || die $!;
while(<FILE>) {
&block();
}
close FILE;
}
allow this:
File.foreach('/usr/dict/words') { print }
or would the prototype be (&file, &block)?
And would this:
my $caller = caller;
File.foreach('/usr/dict/words') {
print $caller eq caller ? "ok" : "not ok"
}
be ok or not ok? It has to be ok if mywhile is going to emulate a
while loop.
--
Michael G. Schwern <[EMAIL PROTECTED]> http://www.pobox.com/~schwern/
Perl Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One
navy ritual:
first caulk the boards of the deck,
then plug up my ass.
-- japhy