in reply to Re: Smartmatch alternatives
in thread Smartmatch alternatives

I agree with:

"My problem with smartmatch is that it tries to replace several more explicit constructs. I prefer to just use the more explicit one, leaving less to heuristics."

... in most cases. Don't use ~~ when ==, eq or =~ would do a better job.

However, there is one place I really miss smartmatch. Let's take for example RDF::RDB2RDF; you don't need to know all the details of what it does; suffice to say that it's got user-configurable objects which process a database. One of the options that can be configured is which tables (if any) should be skipped. I liked being able to say "set the ignore_tables option to anything that can be used as the right hand side of a smart match".

So if they wanted to skip one particular table, they could do ignore_tables => "foo", if they had a list of tables to skip, then ignore_tables => \@private, or they could use a regexp ignore_tables => qr{^priv}, or if they had more complex requirements, ignore_tables => sub {...}.

Smartmatch made implementing that really easy. And it's that aspect of smart match that made me want to write a stable replacement for it.

use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name