[Pdx-pm] File-Fu overloading: '*' replaces '.'
pagaltzis at gmx.de
Sat Feb 23 14:48:28 PST 2008
* Eric Wilhelm <scratchcomputing at gmail.com> [2008-02-23 21:25]:
> my $dir = File::Fu->dir("bar"); # "bar/"
> my $alsodir = $dir * 'bat'; # "barbat/"
> my $subdir = $alsodir / 'baz'; # "barbat/baz/"
> my $subdir2 = $dir * 'bat' / 'baz'; # "barbat/baz/"
> my $file = $subdir + 'file.txt'; # "barbat/baz/file.txt"
I find the basic File::Fu interface interesting… but operator
overloading always makes me just ever so slightly queasy, and
this example is no exception. I get the desire for syntactic
sugar, I really do… but looking at this, I think the sane way
to accommodate that desire is to attach overloaded semantics
to a specially denoted scope rather than hang them off the type
of an object.
Err, OK, I am going off on a trail that is no longer directly
relevant to your inquiry. Sorry. I shall muse about that by
myself for a while.
Aristotle Pagaltzis // <http://plasmasturm.org/>
More information about the Pdx-pm-list