in reply to Re: What if Perl had an OO standard library?
in thread What if Perl had an OO standard library?
:bow: @YourMother. Thanks for the kind words. Here's some cool stuff I haven't blogged about yet that you can do with Venus:
# throw exceptions easily# catch exceptions easilyVenus::Path->new('/path/to/nowhere')->throw->error({message => 'Missin +g file'}) "Missing file"
# determine and call methods on each item in an arrayVenus::Path->new('/path/to/nowhere')->catch('open')->message "Can't open /path/to/nowhere: No such file or directory"
# use indirect dispatching to nest calls (in this case, on each item in an array)Venus::Array->new(['a'..'d'])->call('map', 'uppercase'); [ 'A', 'B', 'C', 'D' ]
# use MORE POWER and force return an "autoboxing" object so you can continue chaining thingsVenus::Array->new(['a'..'d'])->call('map', 'box', 'uppercase'); [ bless({'value' => bless({'value' => 'A'}, 'Venus::String')}, 'Venus: +:Box'), bless({'value' => bless({'value' => 'B'}, 'Venus::String')}, 'Venus: +:Box'), bless({'value' => bless({'value' => 'C'}, 'Venus::String')}, 'Venus: +:Box'), bless({'value' => bless({'value' => 'D'}, 'Venus::String')}, 'Venus: +:Box ) ]
Venus::Array->new(['a'..'d'])->box('call', 'map', 'box', 'uppercase'); bless({'value' => bless({'value' => [ bless({'value' => bless({'value' => 'A'}, 'Venus::String')}, 'Venus: +:Box'), bless({'value' => bless({'value' => 'B'}, 'Venus::String')}, 'Venus: +:Box'), bless({'value' => bless({'value' => 'C'}, 'Venus::String')}, 'Venus: +:Box'), bless({'value' => bless({'value' => 'D'}, 'Venus::String')}, 'Venus: +:Box ) ]}, 'Venus::Array')}, 'Venus::Box'});
|
|---|