[MacRuby] #999: Handle Obj-C protocols better in MacRuby

MacRuby ruby-noreply at macosforge.org
Mon Nov 22 01:29:51 PST 2010


#999: Handle Obj-C protocols better in MacRuby
----------------------------------------+-----------------------------------
 Reporter:  martinlagardette@…          |       Owner:  lsansonetti@…        
     Type:  enhancement                 |      Status:  new                  
 Priority:  major                       |   Milestone:                       
Component:  MacRuby                     |    Keywords:                       
----------------------------------------+-----------------------------------

Comment(by martijn@…):

 Replying to [comment:4 lsansonetti@…]:
 > Looks like the class_addProtocol() runtime function could be used. I
 wonder if we can call it automatically, once all methods of a known
 protocol are defined.

 To me, it feels there might be too much 'magic' in automatically adding
 protocols a class conforms to. Plus, there are plenty of protocols with no
 required but only optional methods. Would all MacRuby classes then
 automatically conform to these protocols? I don't mind manually indicating
 what protocols a class supports, as this helps make explicit what its
 responsibilities are.

 So what about just adding a class macro that calls class_addProtocol()
 during class definition?

 {{{
 #!ruby
 class SourceListController
   add_protocol :NSOutlineViewDelegate

   def outlineView(outlineView, child:index, ofItem:item) ... end
   ...
 end
 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/999#comment:6>
MacRuby <http://macruby.org/>



More information about the macruby-tickets mailing list