August 05, 2003

autobox.pm

nntp.perl.org - perl.perl5.porters (79450)

I've just uploaded autobox.pm to CPAN:

http://www.cpan.org/authors/id/C/CH/CHOCOLATE/autobox-0.01.tar.gz

It contains a new lexically scoped pragma which enables
Perl's builtin datatypes to be autoboxed. This allows
methods to be invoked on unblessed references and on
scalars. Thus:

use autobox;

my $schwartzian = [ @_ ]->map(...)->sort(...)->map(...);
my $greet = "Hello, World!"->upper();
my $add_five = sub { $_[0] $_[1] }->curry()->(5);
my $sd = [ 1, 2, 6, 9, 9, 1, 4, 1 ]->standard_deviation();
my $range = 10->to(1);
my $hash_iterator = sub { my ($key, $value) = @_; ... };

{ alpha => beta, gamma => vlissides }->for_each($hash_iterator);

$greet->for_each(\&character_handler);

うぉー、ruby 風です。

Posted by miyagawa at August 5, 2003 12:58 PM | Permalink | Comments (0) | TrackBack(0)
Comments
Trackbacks
TrackBack URL for this entry: http://blog.bulknews.net/mt3/mt-tb.cgi/222
Post a comment