develooper Front page | perl.perl6.users | Postings from August 2020

Re: Combining multiple "is..." traits into one?

Thread Previous | Thread Next
From:
Stuart Hungerford
Date:
August 12, 2020 00:38
Subject:
Re: Combining multiple "is..." traits into one?
Message ID:
CAG+kMrF=gsmEPg9wbZiH=aeUfAhYcQOuqFPTCcFmxdDcaNEB1g@mail.gmail.com
On Wed, Aug 12, 2020 at 8:12 AM Tobias Boege <tobs@taboege.de> wrote:

> [...]
> > Would a custom version of the trait_mod:<is> routine do the trick?
>
> Yes:
>
>   multi trait_mod:<is> (Routine $r, :$equivalence!) {
>       trait_mod:<is>($r, :equiv(&infix:<==>));
>       trait_mod:<is>($r, :assoc<chain>);
>   }

As a supplementary question: is it possible to build up trait
modifications from simpler ones? Something like:

multi trait_mod:<is> (Routine \routine, :$equality!) {
  trait_mod:<is>(routine, :equiv(&infix:<==>));
}

multi trait_mod:<is> (Routine \routine, :$chainable!) {
  trait_mod:<is>(routine, :assoc<chain>);
}

multi trait_mod:<is> (Routine \routine, :$equivalence!) {
  {magic to ensure routine is equality and routine is chainable}
}

Although I'm not yet sure that's a good idea.

Thanks,

Stu

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