Repository navigation
Replies: 3 comments
|
It probably should handle argument reversal as well (even if that's not terribly likely). |
0 replies
|
Personally I disagree with overloading operators to do something different than their intention, especially as different as this would be. In this case additionally, it means |
0 replies
|
It's a neat idea and seems to work well as a role. Could also overload the concat operator. package Mojo::File::Role::Overload;
use Mojo::Base -role;
use overload "/" => \&_child, "." => \&_child, fallback => 1;
sub _child { shift->child(shift) }
1;$ perl -I. -Mojo -E '(f->with_roles("+Overload")->new(".")/"Mojo"/"File"/"Role"/"Overload.pm")->tap(sub{c($_->dirname, $_->basename(".pm"), $_->extname)->join(" | ")->say})'
Mojo/File/Role | Overload | pm
$ perl -I. -Mojo -E '(f->with_roles("+Overload")->new(".")."Mojo"."File"."Role"."Overload.pm")->tap(sub{c($_->dirname, $_->basename(".pm"), $_->extname)->join(" | ")->say})'
Mojo/File/Role | Overload | pm@Leont What's an example of handling argument reversal? |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi, I enjoy working with pythons
pathliband its overloading of the slash, and it would be nice if I could do that with Mojo::File as well.A quick & dirty proof of concept:
What do others think?
All reactions