For the record: I really like the chaining idea. I don't know if it would work, but I like it.
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Orion Edwards Sent: Wednesday, November 26, 2008 4:10 PM To: ironruby-core@rubyforge.org Subject: Re: [Ironruby-core] IronRuby and XNA. Super and Generics Ah I see. Completely agree with the reasoning behind 'stuff appears when you require mscorlib' too. Possible idea - make 'of' a proc rather than a method, so it uses square brackets instead of round ones. d = Dictionary.of[String, String] t = Load of[Texture2d], "sometexture" # awesome, but only because 'Load' is a conveniently nice name IMHO the [] "looks more like templates" than if it used () - but I'm biased on account of having never written a line of VB.net in my life. The VB coders will probably have the exact opposite reaction to me :-) Even so, I'm not entirely sure that copying VB is neccessarily the right thing... Examples for thought: data = [1,2,3,4] Array.convert_all of[Fixnum, String], data, lambda{ |x| x.to_s } Array.convert_all of(Fixnum, String), data, lambda{ |x| x.to_s } Array.convert_all T[Fixnum, String], data, lambda{ |x| x.to_s } Array.convert_all T(Fixnum, String), data, lambda{ |x| x.to_s } I guess that any of these will be fine once one becomes used to them... Here's one from left-field which probably won't work, but how about using a proxy like andand does Array.with(Fixnum, String).convert_all data, lambda{ |x| x.to_s } Array.T(Fixnum, String).convert_all data, lambda{ |x| x.to_s } T(Texture2d).load "sometexture" Tomas Matousek wrote: It's like: Sub Foo(Of T)(ByVal a As T) End Sub Sub Main() Foo(Of Integer)(1) End Sub Tomas From: [EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]> [mailto:[EMAIL PROTECTED] On Behalf Of Orion Edwards Sent: Wednesday, November 26, 2008 3:27 PM To: ironruby-core@rubyforge.org<mailto:ironruby-core@rubyforge.org> Subject: Re: [Ironruby-core] IronRuby and XNA. Super and Generics That makes sense. Dictionary.of(T1, T2) looks good, but how do they handle invoking generic methods? I don't have VB.net installed, and all the samples I can find all rely on type inference rather than explicitly specifying the type Do they do Load( of(Texture2d), "blah" ) ?? Thanks. Tomas Matousek wrote: VB.NET has (Of T) syntax for generic parameters, so it would be familiar to VB programmers :) I don't see a strong connection between "of" and "typeof". "T" is interesting, though we already use "of" for generic types (e.g. Dictionary.of(String, String)) so it might be better to stick with one concept for all generic parameters. We don't want to extend Ruby syntax. Adding new methods is safe since it could always be implemented as monkey patching and could be done conditionally, for example after you require 'mscorlib' the new methods appear. If you don't use CLR no IronRuby/CLR specific methods should be available (it currently doesn't work that way, but that's the plan). Tomas From: [EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]> [mailto:[EMAIL PROTECTED] On Behalf Of Orion Edwards Sent: Wednesday, November 26, 2008 12:38 PM To: ironruby-core@rubyforge.org<mailto:ironruby-core@rubyforge.org> Subject: Re: [Ironruby-core] IronRuby and XNA. Super and Generics While I can certainly see the elegance of the 'of' suggestion, it can't help but to trip my "code smell" warning, because 'of' implies 'typeof', and it treats the types as method arguments. I can't help but think that every new programmer, seeing this: myTexture = content.load( of(Texture2D), "mytexture" ) is going to wrongly infer that it's calling this CLR method content.Load( typeof(Texture2D), "mytexture" ) The relative lack of such counter-intuitive assumptions is IMHO one of the best things about ruby. I'd really like to see IronRuby keep this up Perhaps it would be more clear if 'of' was 'T' ?? - eg: myTexture = content.load( T(Texture2D), "mytexture" ) But that doesn't really solve the 'types aren't method arguments' problem How about this: myTexture = content.load[Texture2D]( "mytexture" ) myTexture = content.load[Texture2D] "mytexture" Both of these produce a syntax error in MRI, which IMHO is a good thing as it means IronRuby is not breaking any existing functionality. MRI is never going to have to call generics, and as far as I can tell there won't be any overlaps with existing ruby syntax (eg Proc#[], etc), so it seems safe. It also is consistent with the existing syntax for instantiating generic classes. The deal-breaker I guess would be how hard (or possible) this syntax is to implement with the IronRuby parser, etc. Tomas Matousek wrote: I'm thinking of something like: myTexture = content.load of(Texture2D), "mytexture" I.e. we would add Kernel#of method that takes a list of classes/modules and returns a special object representing generic parameters that binder would use for selecting the right method. We are open for more ideas. Tomas -----Original Message----- From: [EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]> [mailto:[EMAIL PROTECTED] On Behalf Of Dudu Baião Sent: Wednesday, November 26, 2008 10:49 AM To: ironruby-core@rubyforge.org<mailto:ironruby-core@rubyforge.org> Subject: Re: [Ironruby-core] IronRuby and XNA. Super and Generics Thanks John! I will do that. Just for curiosity, what will be the syntax to call generic methods? :) 2008/11/26 John Lam (IRONRUBY) <[EMAIL PROTECTED]><mailto:[EMAIL PROTECTED]>: We can't consume generic methods today. It's on the list of things to do though. You can work around this by defining a concrete method in C# that calls the appropriate generic method and call the concrete method from IronRuby. Thanks, -John -----Original Message----- From: [EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]> [mailto:[EMAIL PROTECTED] On Behalf Of Dudu Baião Sent: Tuesday, November 25, 2008 6:26 PM To: ironruby-core@rubyforge.org<mailto:ironruby-core@rubyforge.org> Subject: [Ironruby-core] IronRuby and XNA. Super and Generics Hi guys! Im playing with XNA trying to run the simplest xna example: To show a SpriteBatch on screen. After some tests I found some problems: 1- The "Microsoft::Xna::Framework::Game" expects that we implement some methods like "Update", "Drawn" etc, and inside the method we have to call the base class (super) actual method passing some parameters. If I try to do this: def update(game_time) super(game_time) end I get this error: my_game.rb:23:in `update': wrong number or type of arguments for `update' (ArgumentError) from Snippets.scripting:0:in `Update' from Microsoft.Xna.Framework.Game:0:in `Run' from program.rb:23:in `main' from :0 2- XNA uses generic functions to load the game contents. How can I convert the code above to IronRuby? // This is a texture we can render. Texture2D myTexture; protected override void LoadContent() { myTexture = Content.Load<Texture2D>("mytexture"); } Can IronRuby consume generics? Thanks! _______________________________________________ Ironruby-core mailing list Ironruby-core@rubyforge.org<mailto:Ironruby-core@rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core _______________________________________________ Ironruby-core mailing list Ironruby-core@rubyforge.org<mailto:Ironruby-core@rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core _______________________________________________ Ironruby-core mailing list Ironruby-core@rubyforge.org<mailto:Ironruby-core@rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core _______________________________________________ Ironruby-core mailing list Ironruby-core@rubyforge.org<mailto:Ironruby-core@rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core -- Orion Edwards Web Application Developer T: +64 7 859 2120 F: +64 7 859 2320 E: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> Open2view.com The Real Estate Website [cid:image001.jpg@01C94FE1.C5C6B620] ________________________________ _______________________________________________ Ironruby-core mailing list Ironruby-core@rubyforge.org<mailto:Ironruby-core@rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core -- Orion Edwards Web Application Developer T: +64 7 859 2120 F: +64 7 859 2320 E: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> Open2view.com The Real Estate Website [cid:image001.jpg@01C94FE1.C5C6B620] ________________________________ _______________________________________________ Ironruby-core mailing list Ironruby-core@rubyforge.org<mailto:Ironruby-core@rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core -- Orion Edwards Web Application Developer T: +64 7 859 2120 F: +64 7 859 2320 E: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> Open2view.com The Real Estate Website [cid:image001.jpg@01C94FE1.C5C6B620]
<<inline: image001.jpg>>
_______________________________________________ Ironruby-core mailing list Ironruby-core@rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core