#1416: Unreasonably painful to add a method to all *Array PMCs
--------------------+-------------------------------------------------------
 Reporter:  japhb   |       Owner:              
     Type:  RFC     |      Status:  new         
 Priority:  normal  |   Milestone:              
Component:  core    |     Version:  2.0.0       
 Severity:  medium  |    Keywords:  Array method
     Lang:          |       Patch:              
 Platform:          |  
--------------------+-------------------------------------------------------
 Adding a method that works for all *Array PMCs (in either PIR or NQP)
 should be really easy, but it isn't.  If all *Array PMCs had a common
 ancestor (Array, say), you could do this:

 {{{
 module Array {
     method reverse () {
         my @reversed;
         for self { @reversed.unshift($_); }
         @reversed;
     }
 }
 }}}

 Unfortunately, there is no such common ancestor.  Likewise, they
 share no common role, so that's not an in either.

 One could copy and paste the above block for each *Array module, but
 that's just nuts.  Talk about a DRY violation.

 It's possible one might create one method code object, then iterate over
 all the known *Array types and use add_method to add that code to them as
 a method, but this will fail if the list of *Array types changes, which it
 reasonably might.  Plus it's just ugly for what should be a simple task.

-- 
Ticket URL: <https://trac.parrot.org/parrot/ticket/1416>
Parrot <https://trac.parrot.org/parrot/>
Parrot Development
_______________________________________________
parrot-tickets mailing list
[email protected]
http://lists.parrot.org/mailman/listinfo/parrot-tickets

Reply via email to