I played with the "is" trait and I is puzzled. This example code multi trait_mod:<is> (Routine \routine, :$equality!) { trait_mod:<is>(routine, :equiv(&infix:<==>)); }
sub is-eq is equality { ... } say 'is-eq ', &is-eq.prec; multi trait_mod:<is> (Routine \routine, :$chainable!) { trait_mod:<is>(routine, :assoc<chain>); } sub chained is chainable { ... } say 'chained ', &chained.prec; multi trait_mod:<is> (Routine \routine, :$equivalence!) { trait_mod:<is>(routine,:equality); trait_mod:<is>(routine,:chainable); } # Uncomment these two lines # sub trait-er is equality is chainable { ... } # say 'trait-er ', &trait-er.prec; # or uncomment these two lines # sub jolly-trait is equivalence { ... } # say 'jolly-trait',&jolly-trait.prec; run it as-is, and the results make sense to me is-eq {iffy => 1, pasttype => chain, prec => m=} chained {assoc => chain} if I uncomment either of the two-line stanzas at the end, the output of is-eq also changes. is-eq {*assoc => chain*, iffy => 1, pasttype => chain, prec => m=} chained {assoc => chain} trait-er {assoc => chain, iffy => 1, pasttype => chain, prec => m=} is-eq {*assoc => chain*, iffy => 1, pasttype => chain, prec => m=} chained {assoc => chain} jolly-trait{assoc => chain, iffy => 1, pasttype => chain, prec => m=} What is going on, why are the traits changing for 'is-eq' in the uncommented examples? -y On Tue, Aug 11, 2020 at 5:38 PM Stuart Hungerford < stuart.hungerf...@gmail.com> wrote: > On Wed, Aug 12, 2020 at 8:12 AM Tobias Boege <t...@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 >