NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Sub::Current for the Win! (Score:1)
See, this is exactly why I love Perl, cause there is always a something on CPAN that will make your life easier.
- Stevan
Re:Sub::Current for the Win! (Score:2)
That's great, but solve my 'yield' problem and I'll really love you :)
Reply to This
Parent
Re: (Score:1)
Well, all the "yield" and "block" stuff is just sugar around your basic continuation passing. So here is the translation of what the ruby is actually doing.
Re: (Score:1)
I took the dog for a walk and thought about this a bit and realized where my scoping issue was. Here is a sugared version, probably could be a little cleaner still, maybe even with some subroutine attributes (sub foo : continuation { ... } or something).
Re: (Score:2)
Damn. I am doing the bit with passing around the sub, but it really does read like what you've done is much cleaner and actually makes it read like Ruby.
Re: (Score:1)
Actually took a look into rubyisms, I think that is just another case of Cozens "egoware" (only one version ever released and not meant to actually be used, only for people to look at and go "wow"). All the DB:: fiddling means it is bound to be very fragile with things like eval, etc.
RE: reading like Ruby
I actually find the desugared perl one to be the most readable since it doesn't obscure what is actually being done.
- Stevan
yieldness (Score:1)
use strict;
use Coro::Generator;
{
package Foo;
sub new { bless { val => $_[1] } => $_[0] }
sub inc { $_[0]->{val} += $_[1] }
sub val { shift->{val} }
}
my $inner_testy = generator {
my $foo = pop;
foreach my $item (@_) {