title: Why is adding methods to a type different than adding a sub or an operator in perl6?
body: <p>Making subs/procedures available for reuse is one core function of modules, and I would argue that it is the fundamental way how a language can be composable and therefore efficient with programmer time: </p>
  
  <p>if you create a type in your module, I can create my own module that adds a sub that operates on your type. I do not have to extend your module to do that.</p>
  
  <pre><code># your module
  class Foo {
      has $.id;
      has $.name;
  }
  
  # my module
  sub foo-str(Foo:D $f) is export {
      return "[{$f.id}-{$f.name}]"
  }
  
  # someone else using yours and mine together for profit
  my $f = Foo.new(:id(1234), :name("brclge"));
  say foo-str($f);
  
  </code></pre>
  
  <p>As seen in <a href="https://stackoverflow.com/questions/55814075/overloading-operators-for-a-class">Overloading operators for a class</a> this composability of modules works equally well for operators, which to me makes sense since operators are just some kinda syntactic sugar for subs anyway (in my head at least). Note that the definition of such an operator does not cause any surprising change of behavior of existing code, you need to import it into your code explicitly to get access to it, just like the sub above.</p>
  
  <p>Given this, I find it very odd that we do not have a similar mechanism for methods, see e.g. the discussion at <a href="https://stackoverflow.com/questions/34504849/how-do-you-add-a-method-to-an-existing-class-in-perl-6">How do you add a method to an existing class in Perl 6?</a>, especially since perl6 is such a method-happy language. If I want to extend the usage of an existing type, I would want to do that in the same style as the original module was written in. If there is a .is-prime on Int, it must be possible for me to add a .is-semi-prime as well, right?</p>
  
  <p>I read the discussion at the link above, but don't quite buy the "action at a distance" argument: how is that different from me exporting another multi sub from a module? for example the rust way of making this a lexical change (Trait + impl ... for) seems quite hygienic to me, and would be very much in line with the operator approach above.</p>
  
  <p>More interesting (to me at least) than the technicalities is the question if language design: isn't the ability to provide new verbs (subs, operators, methods) for existing nouns (types) a core design goal for a language like perl6? If it is, why would it treat methods differently? And if it does treat them differently for a good reason, does that not mean we are using way to many non-composable methods as nouns where we should be using subs instead?</p>