tfpt review "/shelveset:SymToProc;REDMOND\tomat" Comment : Implements Symbol#to_proc Tomas -------------- next part -------------- A non-text attachment was scrubbed... Name: SymToProc.diff Type: application/octet-stream Size: 17030 bytes Desc: SymToProc.diff URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100306/a66f4cac/attachment.obj>
So we''re going to have sym#to_proc available in the core 1.8 implementation? Other than that question, this looks good. Now I have to go remove some hacks ;) JD -----Original Message----- From: Tomas Matousek Sent: Friday, March 05, 2010 8:22 PM To: IronRuby External Code Reviewers Cc: ironruby-core at rubyforge.org Subject: Code Review: SymToProc tfpt review "/shelveset:SymToProc;REDMOND\tomat" Comment : Implements Symbol#to_proc Tomas
Yep, we already have other methods from 1.8.7, like instance_exec. The advantage of having these in 1.8.6 is that it will work in apps that check if to_proc method is present. I guess they might do some eval magic if the method is not implemented which slows things down. Tomas -----Original Message----- From: Jim Deville Sent: Friday, March 05, 2010 8:30 PM To: Tomas Matousek; IronRuby External Code Reviewers Cc: ironruby-core at rubyforge.org Subject: RE: Code Review: SymToProc So we''re going to have sym#to_proc available in the core 1.8 implementation? Other than that question, this looks good. Now I have to go remove some hacks ;) JD -----Original Message----- From: Tomas Matousek Sent: Friday, March 05, 2010 8:22 PM To: IronRuby External Code Reviewers Cc: ironruby-core at rubyforge.org Subject: Code Review: SymToProc tfpt review "/shelveset:SymToProc;REDMOND\tomat" Comment : Implements Symbol#to_proc Tomas
Probably no eval magic, unless you are thinking of a more advanced version of Sym#to_proc than I have been using. I define it with: Class Symbol Def to_proc Lambda {|x| x.send(self)} End End Sure, it doesn''t cover everything, but it hits the 90% cases. -----Original Message----- From: Tomas Matousek Sent: Friday, March 05, 2010 10:42 PM To: Jim Deville; IronRuby External Code Reviewers Cc: ironruby-core at rubyforge.org Subject: RE: Code Review: SymToProc Yep, we already have other methods from 1.8.7, like instance_exec. The advantage of having these in 1.8.6 is that it will work in apps that check if to_proc method is present. I guess they might do some eval magic if the method is not implemented which slows things down. Tomas -----Original Message----- From: Jim Deville Sent: Friday, March 05, 2010 8:30 PM To: Tomas Matousek; IronRuby External Code Reviewers Cc: ironruby-core at rubyforge.org Subject: RE: Code Review: SymToProc So we''re going to have sym#to_proc available in the core 1.8 implementation? Other than that question, this looks good. Now I have to go remove some hacks ;) JD -----Original Message----- From: Tomas Matousek Sent: Friday, March 05, 2010 8:22 PM To: IronRuby External Code Reviewers Cc: ironruby-core at rubyforge.org Subject: Code Review: SymToProc tfpt review "/shelveset:SymToProc;REDMOND\tomat" Comment : Implements Symbol#to_proc Tomas
Yes, something like this might be quite accurate: class Symbol def to_proc Proc.new do |*args| raise ArgumentError if args.size == 0 target = args.delete_at(0) target.send(self, *args) end end end instance_exec on the other hand is also 1.8.7 method and is usually emulated by string eval. Tomas -----Original Message----- From: Jim Deville Sent: Friday, March 05, 2010 10:58 PM To: Tomas Matousek; IronRuby External Code Reviewers Cc: ironruby-core at rubyforge.org Subject: RE: Code Review: SymToProc Probably no eval magic, unless you are thinking of a more advanced version of Sym#to_proc than I have been using. I define it with: Class Symbol Def to_proc Lambda {|x| x.send(self)} End End Sure, it doesn''t cover everything, but it hits the 90% cases. -----Original Message----- From: Tomas Matousek Sent: Friday, March 05, 2010 10:42 PM To: Jim Deville; IronRuby External Code Reviewers Cc: ironruby-core at rubyforge.org Subject: RE: Code Review: SymToProc Yep, we already have other methods from 1.8.7, like instance_exec. The advantage of having these in 1.8.6 is that it will work in apps that check if to_proc method is present. I guess they might do some eval magic if the method is not implemented which slows things down. Tomas -----Original Message----- From: Jim Deville Sent: Friday, March 05, 2010 8:30 PM To: Tomas Matousek; IronRuby External Code Reviewers Cc: ironruby-core at rubyforge.org Subject: RE: Code Review: SymToProc So we''re going to have sym#to_proc available in the core 1.8 implementation? Other than that question, this looks good. Now I have to go remove some hacks ;) JD -----Original Message----- From: Tomas Matousek Sent: Friday, March 05, 2010 8:22 PM To: IronRuby External Code Reviewers Cc: ironruby-core at rubyforge.org Subject: Code Review: SymToProc tfpt review "/shelveset:SymToProc;REDMOND\tomat" Comment : Implements Symbol#to_proc Tomas