Hi, Today I''m playing with CLR delegates :) I''ve run into a strange behavior. Take a look at the next C# block: ----------- public class Printer { public delegate void PrintValue(string value); } ----------- Assuming the above is the content of assembly.dll, take a look at the next IR console output: ----------->>> require "assembly.dll"=> true>>> p = Printer::PrintValue.new { |x| puts x }=> Printer+PrintValue>>> p("dsfs")"dsfs" => nil>>> d = Printer::PrintValue.new { |x| puts x }=> Printer+PrintValue>>> d("dsfd"):0: undefined method `d'' for main:Object (NoMethodError) ------------ Why does p work and d doesn''t? BTW, I see that delegates are converted to something called LightLambda. What is that? Many thanks! Shay. ---------------------------- http://www.ironshay.com Follow me: http://twitter.com/ironshay -- Posted via http://www.ruby-forum.com/.
Looks like some odd caching or invalidation. Please file a bug on Codeplex. JD ...there is no try> -----Original Message----- > From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core- > bounces at rubyforge.org] On Behalf Of Shay Friedman > Sent: Tuesday, June 09, 2009 5:35 AM > To: ironruby-core at rubyforge.org > Subject: [Ironruby-core] An Issue with CLR Delegates > > Hi, > > Today I''m playing with CLR delegates :) > > I''ve run into a strange behavior. > > Take a look at the next C# block: > ----------- > public class Printer > { > public delegate void PrintValue(string value); } > ----------- > > Assuming the above is the content of assembly.dll, take a look at the next IR > console output: > > ----------- > >>> require "assembly.dll" > => true > >>> p = Printer::PrintValue.new { |x| puts x } > => Printer+PrintValue > >>> p("dsfs") > "dsfs" > => nil > >>> d = Printer::PrintValue.new { |x| puts x } > => Printer+PrintValue > >>> d("dsfd") > :0: undefined method `d'' for main:Object (NoMethodError) > ------------ > > Why does p work and d doesn''t? > > BTW, I see that delegates are converted to something called LightLambda. > What is that? > > Many thanks! > Shay. > ---------------------------- > http://www.ironshay.com > Follow me: http://twitter.com/ironshay > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core
This is actually correct behavior. p("dsfs") calls Kernel#p with parameter "dsfs" d("dsfs") attempts to call method "d", which doesn''t exist. You need to do p.invoke("dsfs") and d.invoke("dsfs") to invoke the delegates. Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Jim Deville Sent: Tuesday, June 09, 2009 10:32 AM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] An Issue with CLR Delegates Looks like some odd caching or invalidation. Please file a bug on Codeplex. JD ...there is no try> -----Original Message----- > From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core- > bounces at rubyforge.org] On Behalf Of Shay Friedman > Sent: Tuesday, June 09, 2009 5:35 AM > To: ironruby-core at rubyforge.org > Subject: [Ironruby-core] An Issue with CLR Delegates > > Hi, > > Today I''m playing with CLR delegates :) > > I''ve run into a strange behavior. > > Take a look at the next C# block: > ----------- > public class Printer > { > public delegate void PrintValue(string value); } > ----------- > > Assuming the above is the content of assembly.dll, take a look at the next IR > console output: > > ----------- > >>> require "assembly.dll" > => true > >>> p = Printer::PrintValue.new { |x| puts x } > => Printer+PrintValue > >>> p("dsfs") > "dsfs" > => nil > >>> d = Printer::PrintValue.new { |x| puts x } > => Printer+PrintValue > >>> d("dsfd") > :0: undefined method `d'' for main:Object (NoMethodError) > ------------ > > Why does p work and d doesn''t? > > BTW, I see that delegates are converted to something called LightLambda. > What is that? > > Many thanks! > Shay. > ---------------------------- > http://www.ironshay.com > Follow me: http://twitter.com/ironshay > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core_______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
lol! Brilliant discovery Tomas! Thanks! ---------------------------- http://www.ironshay.com Follow me: http://twitter.com/ironshay -- Posted via http://www.ruby-forum.com/.
Well, it doesn''t take much to see these things right away. Just to implement a Ruby VM :) Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Shay Friedman Sent: Tuesday, June 09, 2009 1:07 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] An Issue with CLR Delegates lol! Brilliant discovery Tomas! Thanks! ---------------------------- http://www.ironshay.com Follow me: http://twitter.com/ironshay -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core