For the sake of maintainability, ease of reading and best practices, do you think this kind of interface is a good design?fetch("google.com") > my $content; # also: fetch("google.com") | _print; # and even: url("google.com")->() >> _self | _save_as_tree("./root"); $_->() | _save_as_tree("./root") while $_;
Isn't it misleading to use the ">" operator to write contents of something into a variable? Isn't it much cleaner to have something like this:
And what about this:my $content = fetch("google.com");
Aren't any of these options better:url("google.com")->() >> _self | _save_as_tree("./root");
I've never written a Perl module that used overload and I believe I've used only a few modules that had it. So is it just me because I'm not used to it, or is this an example of overload abuse?# hmmm, looks confusing: save_as_tree("./root", fetch( url("google.com") ) ); # chained calls, but still confusing: url("google.com")->fetch()->save_as_tree("./root"); # full OO: my $url = Some::Module::Name->new( url => "google.com" ); $url->fetch; $url->save_as_tree("./root");
Shouldn't the ">" operator be used only to compare things, where that "thing" could be an object and its class could implement a specific comparision method?
For example, a class called Person could overload ">" when comparing two Person instances, and the comparision would be based on the age of each person.
Please let me know what your thoughts about this subject are.
PS: I have not read PBP completely yet, there must be something about this over there...
In reply to Overload abuse or is it just me? by salvix
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |