The thing that is still missing in the Perl core for me is more flow control resp. non-linear flow:
- Generators in Perl, so I can use (say):
sub upto {
my $stop = $_[0];
my $start = 0;
for ($start..$stop) {
yield $_
};
};
for my $item (upto(5)) {
print "At $item\n";
};
__END__
At 1
At 2
At 3
At 4
At 5
So far, Coro implements that, but not for Win32/MSVC, and it is not that stable. Also, the libcoro that Coro uses is under the GPL, which prohibits its distribution with the Perl core.
- Lightweight threads that have the approach of "share everything" instead of the "share nothing" approach taken by Perl so far. There is Thread::Sociable, which implements that, but so far, the approach to Perl threads has been, different. All threading is problematic in Perl because of the semantics of the really global stuff, like the namespace - if you have a "share everything" approach, you need to protect %:: and everything hanging off there, or the following code will behave unpredictable:
sub frobnicate {
print "Frobnicating\n";
};
sub frobnitz {
print "Frobnitzing\n";
};
sub gargle {
local *frobnicate = \&frobnitz;
frobnicate();
};
my $thr1 = async { gargle() };
my $thr2 = async { gargle() };
my $thr3 = async { gargle() };
- Transparent asynchronous IO. When I use the following:
open my $fh, "<:async", $filename
or die "Couldn't open '$filename': $!";
my $line = <$fh>;
# ... do some busy work without touching $line ...
print $line;
$line should be returned as a tie'd variable and the read request
should be run in the background, allowing the foreground program to continue. Any access to $line will then wait until the background read operation has completed.
Update:Upon rereading, I don't need the :Generator syntax on my generators. Just using the yield keyword (similar to return but remember all state so we know where to continue when we get called again) is enough.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|