Hello,
I am trying to call explicitly implemented interface method, but get
such error
undefined method `bar'' for #<App::Cls:0x000005c>
C# code:
public interface IFoo
{
void Bar();
}
public class Cls : IFoo
{
void IFoo.Bar() { }
}
Ruby code:
x = App::Cls.new
x.bar
But this one works fine:
public class Cls : IFoo
{
public void Bar() { }
}
What is wrong?
- Alex
--
Posted via http://www.ruby-forum.com/.
Tomas Matousek
2009-Jan-08 15:56 UTC
[Ironruby-core] Problem calling explicit interface methods
Filed bug #23494.
Tomas
-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at
rubyforge.org] On Behalf Of Alex 2k8
Sent: Thursday, January 08, 2009 2:25 AM
To: ironruby-core at rubyforge.org
Subject: [Ironruby-core] Problem calling explicit interface methods
Hello,
I am trying to call explicitly implemented interface method, but get
such error
undefined method `bar'' for #<App::Cls:0x000005c>
C# code:
public interface IFoo
{
void Bar();
}
public class Cls : IFoo
{
void IFoo.Bar() { }
}
Ruby code:
x = App::Cls.new
x.bar
But this one works fine:
public class Cls : IFoo
{
public void Bar() { }
}
What is wrong?
- Alex
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ironruby-core mailing list
Ironruby-core at rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core
Curt Hagenlocher
2009-Jan-08 16:04 UTC
[Ironruby-core] Problem calling explicit interface methods
I''m not convinced this is exactly a bug. There is no public
''bar'' method on Cls after all. I think IronPython would
require you to say something like App::IFoo::bar(App::Cls.new()) in order to
make the interface call explicit.
-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at
rubyforge.org] On Behalf Of Tomas Matousek
Sent: Thursday, January 08, 2009 7:56 AM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Problem calling explicit interface methods
Filed bug #23494.
Tomas
-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at
rubyforge.org] On Behalf Of Alex 2k8
Sent: Thursday, January 08, 2009 2:25 AM
To: ironruby-core at rubyforge.org
Subject: [Ironruby-core] Problem calling explicit interface methods
Hello,
I am trying to call explicitly implemented interface method, but get
such error
undefined method `bar'' for #<App::Cls:0x000005c>
C# code:
public interface IFoo
{
void Bar();
}
public class Cls : IFoo
{
void IFoo.Bar() { }
}
Ruby code:
x = App::Cls.new
x.bar
But this one works fine:
public class Cls : IFoo
{
public void Bar() { }
}
What is wrong?
- Alex
--
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
Tomas Matousek
2009-Jan-08 16:50 UTC
[Ironruby-core] Problem calling explicit interface methods
Fair enough, it could be called a feature :) There needs to be some way how to
call the method.
Tomas
-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at
rubyforge.org] On Behalf Of Curt Hagenlocher
Sent: Thursday, January 08, 2009 8:05 AM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Problem calling explicit interface methods
I''m not convinced this is exactly a bug. There is no public
''bar'' method on Cls after all. I think IronPython would
require you to say something like App::IFoo::bar(App::Cls.new()) in order to
make the interface call explicit.
-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at
rubyforge.org] On Behalf Of Tomas Matousek
Sent: Thursday, January 08, 2009 7:56 AM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Problem calling explicit interface methods
Filed bug #23494.
Tomas
-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at
rubyforge.org] On Behalf Of Alex 2k8
Sent: Thursday, January 08, 2009 2:25 AM
To: ironruby-core at rubyforge.org
Subject: [Ironruby-core] Problem calling explicit interface methods
Hello,
I am trying to call explicitly implemented interface method, but get
such error
undefined method `bar'' for #<App::Cls:0x000005c>
C# code:
public interface IFoo
{
void Bar();
}
public class Cls : IFoo
{
void IFoo.Bar() { }
}
Ruby code:
x = App::Cls.new
x.bar
But this one works fine:
public class Cls : IFoo
{
public void Bar() { }
}
What is wrong?
- Alex
--
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
_______________________________________________
Ironruby-core mailing list
Ironruby-core at rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core
Curious, how it is expected to work (or nobody thinked it over yet?)
Example to consider:
- - - -
public interface IFoo1
{
void Bar();
}
public interface IFoo2
{
void Bar();
}
public class Cls : IFoo1, IFoo2
{
void IFoo1.Bar() {}
void IFoo2.Bar() {}
public void Bar() {}
}
- - - -
C# approach:
- - - -
Cls obj = new Cls();
obj.Bar();
((IFoo1)obj).Bar();
((IFoo2)obj).Bar();
- - - -
What is for IronRuby?
Thanks,
- Alex
--
Posted via http://www.ruby-forum.com/.
Tomas Matousek
2009-Jan-08 17:48 UTC
[Ironruby-core] Problem calling explicit interface methods
Not yet.
obj.as(IFoo1).Bar() might be one option.
Tomas
-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at
rubyforge.org] On Behalf Of Alex 2k8
Sent: Thursday, January 08, 2009 8:54 AM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Problem calling explicit interface methods
Curious, how it is expected to work (or nobody thinked it over yet?)
Example to consider:
- - - -
public interface IFoo1
{
void Bar();
}
public interface IFoo2
{
void Bar();
}
public class Cls : IFoo1, IFoo2
{
void IFoo1.Bar() {}
void IFoo2.Bar() {}
public void Bar() {}
}
- - - -
C# approach:
- - - -
Cls obj = new Cls();
obj.Bar();
((IFoo1)obj).Bar();
((IFoo2)obj).Bar();
- - - -
What is for IronRuby?
Thanks,
- Alex
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ironruby-core mailing list
Ironruby-core at rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core
Shri Borde
2009-Jan-08 17:57 UTC
[Ironruby-core] Problem calling explicit interface methods
In IronPython, we went back and forth over this. On the one hand, the API author
might have chosen to make it harder to access the method, requiring a cast like
this:
App::Cls cls = new App::Cls();
cls.bar(); // syntax error
IFoo ifoo = (IFoo)cls;
ifoo.bar(); // works
OTOH, dynamic languages have no type for variables, and so you don''t
know if it should be an error or not. ie. How would IronRuby know if the
programmer expects a variable to be of type App::Cls or of type IFoo.
IronPython ended up allowing it as long as there was no clash. If there is a
clash, you have to use App::IFoo(cls).bar().
Thanks,
Shri
-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at
rubyforge.org] On Behalf Of Tomas Matousek
Sent: Thursday, January 08, 2009 8:50 AM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Problem calling explicit interface methods
Fair enough, it could be called a feature :) There needs to be some way how to
call the method.
Tomas
-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at
rubyforge.org] On Behalf Of Curt Hagenlocher
Sent: Thursday, January 08, 2009 8:05 AM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Problem calling explicit interface methods
I''m not convinced this is exactly a bug. There is no public
''bar'' method on Cls after all. I think IronPython would
require you to say something like App::IFoo::bar(App::Cls.new()) in order to
make the interface call explicit.
-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at
rubyforge.org] On Behalf Of Tomas Matousek
Sent: Thursday, January 08, 2009 7:56 AM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Problem calling explicit interface methods
Filed bug #23494.
Tomas
-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at
rubyforge.org] On Behalf Of Alex 2k8
Sent: Thursday, January 08, 2009 2:25 AM
To: ironruby-core at rubyforge.org
Subject: [Ironruby-core] Problem calling explicit interface methods
Hello,
I am trying to call explicitly implemented interface method, but get
such error
undefined method `bar'' for #<App::Cls:0x000005c>
C# code:
public interface IFoo
{
void Bar();
}
public class Cls : IFoo
{
void IFoo.Bar() { }
}
Ruby code:
x = App::Cls.new
x.bar
But this one works fine:
public class Cls : IFoo
{
public void Bar() { }
}
What is wrong?
- Alex
--
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
_______________________________________________
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