Laurent Sansonetti
lsans****@apple*****
Mon Aug 27 03:32:58 JST 2007
Hi Satoshi-san, On Aug 26, 2007, at 7:13 PM, Satoshi Nakagawa wrote: > It seems a different situation as described above. > > If we introduced automatic definition of the missing method, > however we would need to call #to_s and #dup every time. > > The major point is the cost of #to_s and #dup. > We cannot bypass it because NSString has its own value, > different from Ruby String. > When we want to call a method of Ruby String, > we need to convert NSString into Ruby String. > > So I think we should port Ruby String methods to NSString > as much as possible. > It's good for performance because it doesn't need > method_missing and #to_s and #dup and #setString. > > Obviously it's also applicable to NSArray and NSDictionary. > But it's easier for these types, because we need to think > about character encodings for NSString and Ruby String. You're right, porting the methods would be the best idea. In the interim we have this solution based on method_missing, but ideally it would be great if all the String, Array, Hash methods were respectively ported to NSString, NSArray and NSDictionary (including their mutable types). I don't think it's a difficult job, but it's long. We could for example share this task amongst developers. Maybe some implementation will be common to all classes and could be mixed as a module. I would be happy to help anyway :) Laurent