develooper Front page | perl.perl5.porters | Postings from August 2012

Re: fixing smartmatch just hard enough (and when, too)

Thread Previous | Thread Next
From:
Jesse Luehrs
Date:
August 23, 2012 17:17
Subject:
Re: fixing smartmatch just hard enough (and when, too)
Message ID:
20120824001712.GZ11137@tozt.net
On Fri, Aug 24, 2012 at 09:40:35AM +1000, Damian Conway wrote:
> Leon Timmermans wrote:
> 
> > I suspect in practice junctions may be the only use-case for it. I
> > can't think of any other use-case.
> 
> Interesting. I can think of numerous other use-cases...
> 
>     1. In this very thread we've already seen Robert Sedlacek excellent
>        suggestion for type objects, for which I've already demonstrated
>        several possible ~~-overloadings.
> 
>     2. I'd also very much like to be able to overload ~~ for
>        Regexp::Grammar objects.
> 
>     3. And I can imagine that a similar overloading of ~~ for objects
>        encapsulating Marpa grammars would be of even greater value.
> 
>     4. The bioinformatics people might well like to be able to overload
>        ~~ to perform searches or alignments on objects representing DNA
>        and RNA sequences.
> 
>     5. I can also imagine ~~ overloaded to support Query objects:
> 
>             if ($db ~~ $query) {...}
> 
>     6. And I already have plans to allow InputConstraint objects, for
>        abstracting input filtering using my IO::Prompter module, by
>        being internally smartmatched:
> 
>             my $input = prompt 'Enter a number', must=>$constraint_obj;

None of these use cases are for overloaded objects on the lhs of the
smart match, which was the subject here. What other non-junction use
cases are there for that? (Note that equality operators (.=, etc)
already don't check overloading on their lhs, so this behavior isn't
unprecedented.)

-doy

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About