Re: [MacRuby-devel] book idea - "making it look like Ruby"
Magically converting a snake_case method call to a CamelCase method dispatch is bad for peformance and documentation. I believe that Laurent addressed that topic a few times already but I might be wrong. There is currently no plan to support that approach in MacRuby. - Matt On Fri, Feb 4, 2011 at 1:32 PM, Rich Morin <rdm@cfcl.com> wrote:
At 6:57 PM -0200 2/4/11, Caio Chassot wrote:
On 2011-02-04, at 01:26 , Rich Morin wrote: I'm sure the situation in JRuby land is worse, but generally, using Cocoa stuff from MacRuby feels enough like ruby, save for the HorridCamelCase, but I've gotten used to that.
Interestingly, JRuby does quite a bit of work to let folks use snake_case, instead of CamelCase.
-r -- http://www.cfcl.com/rdm Rich Morin http://www.cfcl.com/rdm/resume rdm@cfcl.com http://www.cfcl.com/rdm/weblog +1 650-873-7841
Software system design, development, and documentation _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
On 2011-02-11, at 15:25 , Matt Aimonetti wrote:
Magically converting a snake_case method call to a CamelCase method dispatch is bad for peformance and documentation.
I'm not suggesting that this be done as part of MacRuby, but should one want to go ahead on their on… Wouldn't it be possible to, strictly in Objective-C, go over the headers for each framework and generate equivalent snake_case entries directly in the method tables pointing to the same method addresses as the original CamelCase selectors? With that approach there would be no runtime performance impact, correct? (Disclaimer: I don't know much at all about Objective-C internals, pretty much nil about method dispatch in particular.)
At 6:09 PM -0200 2/11/11, Caio Chassot wrote:
On 2011-02-11, at 15:25 , Matt Aimonetti wrote:
Magically converting a snake_case method call to a CamelCase method dispatch is bad for peformance and documentation.
It's not clear to me that there would be a significant performance impact. It might be possible to do (most of) the translations at start-up time, avoiding much impact during execution. The question of documentation is also somewhat iffy. There is already a difference in appearance between the ObjC and MacRuby calling syntaxes. Would merely allowing (ie, not requiring) the use of snake_case make this much problem much worse? At 6:09 PM -0200 2/11/11, Caio Chassot wrote:
I'm not suggesting that this be done as part of MacRuby, but should one want to go ahead on their on
Ruby is extremely flexible. I'm quite sure that some metaprogramming could be used to prototype something for experimentation. If the results were interesting, but inefficient or awkward, it might be possible to do something better in MacRuby itself. Note that I'm not suggesting that Laurent would do this, just relying on the fact that MacRuby is an Open Source project... -r -- http://www.cfcl.com/rdm Rich Morin http://www.cfcl.com/rdm/resume rdm@cfcl.com http://www.cfcl.com/rdm/weblog +1 650-873-7841 Software system design, development, and documentation
On Feb 11, 2011, at 2:08 PM, Rich Morin wrote:
The question of documentation is also somewhat iffy. There is already a difference in appearance between the ObjC and MacRuby calling syntaxes. Would merely allowing (ie, not requiring) the use of snake_case make this much problem much worse?
I think this is a terrible idea. Language consistency is important, and just because you can do something doesn't necessarily mean you should. - Jordan
Hey All, Do MacRuby classes completely overwrite Objective-C classes if you load one in with the same class name? I'm just testing the best way to communicate to a MacRuby class from an Objective-C class and wanted to make sure. Robert Payne Interactive Developer
Hi Robert, Classes in ruby are open, which means that if you define it in multiple places, you get one class with things from all the definitions definitions. However, if you define the same methods, then which ever method you define last is the one that will exist. There are also techniques for concatenating methods. If you want two classes with the same name two remain separate, consider using a module to create a namespace. Sent from my iDevice On 2011-02-11, at 17:54, Robert Payne <robertpayne@me.com> wrote:
Hey All,
Do MacRuby classes completely overwrite Objective-C classes if you load one in with the same class name? I'm just testing the best way to communicate to a MacRuby class from an Objective-C class and wanted to make sure.
Robert Payne Interactive Developer _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Do MacRuby classes completely overwrite Objective-C classes if you load one in with the same class name? Just to be clear, the answer is no ;) - Matt Sent from my iPhone On Feb 11, 2011, at 17:00, Mark Rada <mrada@marketcircle.com> wrote:
Hi Robert,
Classes in ruby are open, which means that if you define it in multiple places, you get one class with things from all the definitions definitions.
However, if you define the same methods, then which ever method you define last is the one that will exist. There are also techniques for concatenating methods.
If you want two classes with the same name two remain separate, consider using a module to create a namespace.
Sent from my iDevice
On 2011-02-11, at 17:54, Robert Payne <robertpayne@me.com> wrote:
Hey All,
Do MacRuby classes completely overwrite Objective-C classes if you load one in with the same class name? I'm just testing the best way to communicate to a MacRuby class from an Objective-C class and wanted to make sure.
Robert Payne Interactive Developer _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
One day I'll get this question answering thing done correctly. Sent from my iDevice On 2011-02-11, at 20:05, Matt Aimonetti <mattaimonetti@gmail.com> wrote:
Do MacRuby classes completely overwrite Objective-C classes if you load one in with the same class name?
Just to be clear, the answer is no ;)
- Matt
Sent from my iPhone
On Feb 11, 2011, at 17:00, Mark Rada <mrada@marketcircle.com> wrote:
Hi Robert,
Classes in ruby are open, which means that if you define it in multiple places, you get one class with things from all the definitions definitions.
However, if you define the same methods, then which ever method you define last is the one that will exist. There are also techniques for concatenating methods.
If you want two classes with the same name two remain separate, consider using a module to create a namespace.
Sent from my iDevice
On 2011-02-11, at 17:54, Robert Payne <robertpayne@me.com> wrote:
Hey All,
Do MacRuby classes completely overwrite Objective-C classes if you load one in with the same class name? I'm just testing the best way to communicate to a MacRuby class from an Objective-C class and wanted to make sure.
Robert Payne Interactive Developer _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Mark, your answer was great, I just wanted to make sure people reading the thread in the future get a simple answer. You did a great job explaining why the answer was no and I'm sure it will be valuable to many. - Matt On Fri, Feb 11, 2011 at 5:35 PM, Mark Rada <mrada@marketcircle.com> wrote:
One day I'll get this question answering thing done correctly.
Sent from my iDevice
On 2011-02-11, at 20:05, Matt Aimonetti <mattaimonetti@gmail.com> wrote:
Do MacRuby classes completely overwrite Objective-C classes if you load one in with the same class name?
Just to be clear, the answer is no ;)
- Matt
Sent from my iPhone
On Feb 11, 2011, at 17:00, Mark Rada < <mrada@marketcircle.com> mrada@marketcircle.com> wrote:
Hi Robert,
Classes in ruby are open, which means that if you define it in multiple places, you get one class with things from all the definitions definitions.
However, if you define the same methods, then which ever method you define last is the one that will exist. There are also techniques for concatenating methods.
If you want two classes with the same name two remain separate, consider using a module to create a namespace.
Sent from my iDevice
On 2011-02-11, at 17:54, Robert Payne < <robertpayne@me.com><robertpayne@me.com> robertpayne@me.com> wrote:
Hey All,
Do MacRuby classes completely overwrite Objective-C classes if you load one in with the same class name? I'm just testing the best way to communicate to a MacRuby class from an Objective-C class and wanted to make sure.
Robert Payne Interactive Developer <http://robertjpayne.com/>
_______________________________________________ MacRuby-devel mailing list <MacRuby-devel@lists.macosforge.org> <MacRuby-devel@lists.macosforge.org> MacRuby-devel@lists.macosforge.org <http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel><http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list <MacRuby-devel@lists.macosforge.org>MacRuby-devel@lists.macosforge.org <http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Hey Guys, I'm a bit unclear on this situation then.. If you create an Objective-C class "MyController" with methods and then a Ruby class "MyController" the class should combine all the methods between both correct? For instance: Objective-C Class: #import "MyController.h" @implementation MyController - (void)helloWorld { NSLog(@"hello world!"); } @end Ruby Class: class MyController end Objective-C App Delegate Class: #import "AppDelegate.h" #import "MyController.h" @implementation AppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)notification { MyController *c = [[MyController alloc] init]; [c helloWorld]; } @end The behavior I'm expecting is to see "Hello world" in the console but it seems as if the entire Objective-C method was deleted. I don't have a method in the Ruby class called helloWorld. Cheers, Robert On 12/02/2011, at 2:43 PM, Matt Aimonetti wrote:
Mark, your answer was great, I just wanted to make sure people reading the thread in the future get a simple answer. You did a great job explaining why the answer was no and I'm sure it will be valuable to many.
- Matt
On Fri, Feb 11, 2011 at 5:35 PM, Mark Rada <mrada@marketcircle.com> wrote: One day I'll get this question answering thing done correctly.
Sent from my iDevice
On 2011-02-11, at 20:05, Matt Aimonetti <mattaimonetti@gmail.com> wrote:
Do MacRuby classes completely overwrite Objective-C classes if you load one in with the same class name?
Just to be clear, the answer is no ;)
- Matt
Sent from my iPhone
On Feb 11, 2011, at 17:00, Mark Rada <mrada@marketcircle.com> wrote:
Hi Robert,
Classes in ruby are open, which means that if you define it in multiple places, you get one class with things from all the definitions definitions.
However, if you define the same methods, then which ever method you define last is the one that will exist. There are also techniques for concatenating methods.
If you want two classes with the same name two remain separate, consider using a module to create a namespace.
Sent from my iDevice
On 2011-02-11, at 17:54, Robert Payne <robertpayne@me.com> wrote:
Hey All,
Do MacRuby classes completely overwrite Objective-C classes if you load one in with the same class name? I'm just testing the best way to communicate to a MacRuby class from an Objective-C class and wanted to make sure.
Robert Payne Interactive Developer _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
On 2011-02-12, at 01:59 , Robert Payne wrote:
The behavior I'm expecting is to see "Hello world" in the console but it seems as if the entire Objective-C method was deleted. I don't have a method in the Ruby class called helloWorld.
There's likely something wrong somewhere else in your project. If you post the whole compilable thing to github maybe we can take a look. This works: $ cat foo.m #import <MacRuby/MacRuby.h> @interface Foo : NSObject {} -(NSString*) helloWorld; @end @implementation Foo -(NSString*) helloWorld { return @"hello"; } @end int main (int argc, const char * argv[]) { [[MacRuby sharedRuntime] evaluateFileAtPath:@"foo.rb"]; Foo* foo = [Foo new]; NSLog(@"IM IN UR OBJC %@", [foo helloWorld]); NSLog(@"IM IN UR OBJC %@", [foo performRubySelector:@selector(helloRuby)]); // you could use the following too but it would generate a compile warning: // NSLog(@"IM IN UR OBJC %@", [foo helloRuby]); return 0; } $ cat foo.rb class Foo def helloRuby "hello ruby" end end NSLog("IM IN UR RUBY: %@", Foo.new.helloWorld) NSLog("IM IN UR RUBY: %@", Foo.new.helloRuby) $ clang -o foo foo.m -fobjc-gc-only -framework MacRuby -framework Foundation $ ./foo 2011-02-12 04:36:21.709 foo[26994:903] IM IN UR RUBY: hello 2011-02-12 04:36:21.713 foo[26994:903] IM IN UR RUBY: hello ruby 2011-02-12 04:36:21.714 foo[26994:903] IM IN UR OBJC hello 2011-02-12 04:36:21.714 foo[26994:903] IM IN UR OBJC hello ruby
On 2011-02-12, at 04:40 , Caio Chassot wrote:
On 2011-02-12, at 01:59 , Robert Payne wrote:
The behavior I'm expecting is to see "Hello world" in the console but it seems as if the entire Objective-C method was deleted. I don't have a method in the Ruby class called helloWorld.
Here's a terser, simpler example: $ cat foo.m #import <Foundation/Foundation.h> @interface Foo : NSObject {} -(NSString*) helloWorld; @end @implementation Foo -(NSString*) helloWorld { return @"hello"; } @end void Init_foo(void) {} $ clang -o foo.bundle foo.m -fobjc-gc-only -bundle -framework Foundation $ macruby -rfoo -e 'class Foo; end; puts Foo.new.helloWorld' hello
participants (6)
-
Caio Chassot
-
Jordan K. Hubbard
-
Mark Rada
-
Matt Aimonetti
-
Rich Morin
-
Robert Payne