Hi, Is there a good reason why MacRuby would need to warn the user about the hazzards of removing methods? Removing methods is always a risky business, also in pure Ruby. But this is the power that a Ruby user gets and with it comes responsibility. And since Ruby doesn't warn for this, MacRuby shouldn't do so either IMO. Example: /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/ site_ruby/mocha/class_method.rb:50: warning: removing pure Objective-C method `__stubba__require__stubba__' may cause serious problem Eloy
Is there a good reason why MacRuby would need to warn the user about the hazzards of removing methods? Example: /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/ site_ruby/mocha/class_method.rb:50: warning: removing pure Objective- C method `__stubba__require__stubba__' may cause serious problem
If you read well the error message it warns for removing a *pure Objective-C* method. It does not warn for methods defined in normal Ruby. If my memory serves me right, removing a method is not supported by the Objective-C runtime. There is a work around to do it, by MacRuby is probably one of the rare applications to do it so it may cause problems.
Hey Vincent,
Is there a good reason why MacRuby would need to warn the user about the hazzards of removing methods? Example: /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/ site_ruby/mocha/class_method.rb:50: warning: removing pure Objective-C method `__stubba__require__stubba__' may cause serious problem
If you read well the error message it warns for removing a *pure Objective-C* method. It does not warn for methods defined in normal Ruby.
Sure. But first of all, it _isn't_ a pure objc method, it's a Ruby method, so not sure when/how this gets classified as a pure objc method…
If my memory serves me right, removing a method is not supported by the Objective-C runtime. There is a work around to do it, by MacRuby is probably one of the rare applications to do it so it may cause problems.
Second, the worst thing that can happen (afaik) is that the code breaks because you removed a method. And that _should_ break IMO, because that's how Ruby is crafted. So it's the developers responsibility to not introduce bugs in the application code, _not_ of the language/ bridge developer. - Eloy
I have discussed this with Laurent and will post the results here for completeness. The problem with the objc runtime is that if a method were to be removed and is called from the objc runtime, it would lead to seg faults. Therefor the warning is raised, so people don't have to look through stack traces. Fair enough. However, that's not what a Ruby user, like myself, would expect. So a solution we have discussed would be to change the behaviour of remove_method / undef_method on pure objc classes. It would remove the method and replace it with a stub which raises a NoMethodError. So the application would still crash, as expected, but with a sensible message. Some objc methods would probably still need the current warning, but only for methods like in Ruby Object#object_id and #__send__ etc. http://www.macruby.org/trac/ticket/197 Cheers, Eloy On Jan 5, 2009, at 1:09 PM, Vincent Isambart wrote:
Is there a good reason why MacRuby would need to warn the user about the hazzards of removing methods? Example: /Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/ site_ruby/mocha/class_method.rb:50: warning: removing pure Objective-C method `__stubba__require__stubba__' may cause serious problem
If you read well the error message it warns for removing a *pure Objective-C* method. It does not warn for methods defined in normal Ruby. If my memory serves me right, removing a method is not supported by the Objective-C runtime. There is a work around to do it, by MacRuby is probably one of the rare applications to do it so it may cause problems.
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
On Tue, Jan 6, 2009 at 9:55 AM, Eloy Duran <eloy.de.enige@gmail.com> wrote:
on pure objc classes. It would remove the method and replace it with a stub which raises a NoMethodError.
This may be a naive question but.. would it not be more appropriate to trigger the method_missing functionality? m/ -- Matt Mower :: http://matt.blogs.it/
Yes, that might be a better option. In my naivety, I mentioned this to Laurent as well, but it got lost in the discussion a bit. So Laurent, any input? Eloy On Jan 6, 2009, at 11:17 AM, Matt Mower wrote:
On Tue, Jan 6, 2009 at 9:55 AM, Eloy Duran <eloy.de.enige@gmail.com> wrote:
on pure objc classes. It would remove the method and replace it with a stub which raises a NoMethodError.
This may be a naive question but.. would it not be more appropriate to trigger the method_missing functionality?
m/
-- Matt Mower :: http://matt.blogs.it/ _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
participants (3)
-
Eloy Duran
-
Matt Mower
-
Vincent Isambart