From: Macario Ortega Date: 2008-10-30T08:51:43+09:00 Subject: Re: Named arguments gem Daniel Berger wrote: > On Oct 29, 2:17�pm, Macario Ortega wrote: >> > Aha, thanks, that explains it. >> > � � [alpha, beta] >> >> alpha.instance_of?(Integer) >> � � ...do stuff with alpha and beta >> � end >> � named_args_for :test_method >> end > > Oh, I realize there are ways to get the same behavior. But, I'd like > that notation. > > What I'm ultimately hoping for is that, if you support that notation, > we could use RubyInline behind the scenes and do automatic > optimization: > > http://segment7.net/projects/ruby/inline_optimization.html > > What do you think? > > Regards, > > Dan I don't think that notation is actually posible, I guess that is not ruby anymore. You could write your method in a string in a ruby like syntax with the expected type, parse it and evaluate it to generate a method def like the one above but that would defy the purpouse of turning any ruby method into a method that accepts an options hash, another altenative is to have a method called #named_args_with_typing that would accept a hash with a Symbol key corresponding to the argument and as value the expected Object the arg should be instance of, and generate a code structure like the one above; or just stick to duck typing and be careful not to pass the wrong type. Anyway it will blow its just matter of the kind of error to expect. I've zero experience with inline ruby but what I understand from this post http://blog.zenspider.com/2005/02/rubytoruby.html is that you could programatically generate C from ruby code, I guess it should be super plain ruby code. This project seems to "compile" domain specific ruby code for the ATMEGA microprocessor: http://rad.rubyforge.org/ -- Posted via http://www.ruby-forum.com/.