# \[ANN\] Ruby/Interface

**URL:** https://rubytalk.org/t/ann-ruby-interface/11998
**Category:** ruby-talk
**Created:** [8 June 2004 18:46 UTC](https://rubytalk.org/t/ann-ruby-interface/11998 "2004-06-08T18:46:30Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![Sean\_O\_Dell1](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@Sean\_O\_Dell1](https://rubytalk.org/u/Sean_O_Dell1)
#### Post date: [8 June 2004 18:46 UTC](https://rubytalk.org/t/ann-ruby-interface/11998/1 "2004-06-08T18:46:30Z")

</div>

Ruby/Interface 0.1-1

Homepage/Documentation: [http://interface.rubyforge.org/](http://interface.rubyforge.org/)

=== PURPOSE

Ruby/Interface was designed to help developers understand the purpose of Ruby  
objects encountered at run-time. Ruby is very dynamic, and it is sometimes  
hard to determine what function any given object serves, and the methods to  
which it responds to fulfill that function.

Ruby/Interface tries to solve this problem by “tagging” objects as  
implementing an interface. The implementation is enforced by comparing an  
object’s methods against the methods expected by the interface. When an  
object is created from a class which claims to implement an interface, or  
which includes a module that does, the object is flagged as properly  
implementing that interface so long as its methods take the same number of  
parameters as the methods described by the interface.

&nbsp;&nbsp;Sean O'Dell

---

<div class="post-metadata">

### Author: ![Curt\_Hibbs3](https://avatars.discourse-cdn.com/v4/letter/c/2acd7d/32.png) [@Curt\_Hibbs3](https://rubytalk.org/u/Curt_Hibbs3)
#### Post date: [8 June 2004 18:59 UTC](https://rubytalk.org/t/ann-ruby-interface/11998/2 "2004-06-08T18:59:49Z")

</div>

Sean O'Dell wrote:

> Ruby/Interface 0.1-1
> 
> Homepage/Documentation: [http://interface.rubyforge.org/](http://interface.rubyforge.org/)
> 
> === PURPOSE
> 
> Ruby/Interface was designed to help developers understand the  
> purpose of Ruby  
> objects encountered at run-time. Ruby is very dynamic, and it is  
> sometimes  
> hard to determine what function any given object serves, and the  
> methods to  
> which it responds to fulfill that function.
> 
> Ruby/Interface tries to solve this problem by “tagging” objects as  
> implementing an interface. The implementation is enforced by comparing an  
> object’s methods against the methods expected by the interface. When an  
> object is created from a class which claims to implement an interface, or  
> which includes a module that does, the object is flagged as properly  
> implementing that interface so long as its methods take the same  
> number of  
> parameters as the methods described by the interface.

Very nice... I like it!

Curt

---

<div class="post-metadata">

### Author: ![Mauricio\_Fernndez](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@Mauricio\_Fernndez](https://rubytalk.org/u/Mauricio_Fernndez)
#### Post date: [8 June 2004 20:23 UTC](https://rubytalk.org/t/ann-ruby-interface/11998/3 "2004-06-08T20:23:20Z")

</div>

Some comments:

I see you're using per-class tagging, hence being unable to track  
changes in the singleton class. I'd point you again to the last sections  
of [http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/102555](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/102555)  
which I believe you didn't read.  
There's an inconsistency in the code: you're checking the methods of the  
object (including its singleton methods) with Object#method but storing  
the result in a per-class structure; that won't fly.

Also, using class variables instead of class instance variables ties the  
notion of interface to inheritance, which I believe you wanted to avoid.

I would consider storing the conformance information in  
ROBJECT(self)-\>klass directly; this will be either the real class or  
the singleton class. In the first case, the "conformity table" is  
shared by all objects of that class; in the second, it will be "owned"  
by the object. The advantage is that this new table would be created  
on demand, only when the object is extended/a singleton method is  
defined and has\_interface? is called. You wouldn't even need to capture  
singleton\_method\_added this way.

> **···**
>
> On Wed, Jun 09, 2004 at 03:46:30AM +0900, Sean O'Dell wrote:
> 
> > Ruby/Interface tries to solve this problem by ???tagging??? objects as  
> > implementing an interface. The implementation is enforced by comparing an  
> > object???s methods against the methods expected by the interface.
> 
> --  
> Running Debian GNU/Linux Sid (unstable)  
> batsman dot geo at yahoo dot com
> 
> \<miguel\> any new sendmail hole I have to fix before going on vacations?  
> &nbsp;&nbsp;-- Seen on #Linux

---

<div class="post-metadata">

### Author: ![Nospam5](https://avatars.discourse-cdn.com/v4/letter/n/d9b06d/32.png) [@Nospam5](https://rubytalk.org/u/Nospam5)
#### Post date: [8 June 2004 20:28 UTC](https://rubytalk.org/t/ann-ruby-interface/11998/4 "2004-06-08T20:28:52Z")

</div>

Sean O'Dell wrote:

> Ruby/Interface 0.1-1

Very nice!

But wouldn't implements\_interface(...) instead of declare\_interface(...) be better, e.g "implements" is the Java terminology for implementing an interface? And maybe also implements\_interface?(...) instead of has\_interface?(...). Of aliasses for both.

Regards,

Peter

---

<div class="post-metadata">

### Author: ![Gavin\_Sinclair](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@Gavin\_Sinclair](https://rubytalk.org/u/Gavin_Sinclair)
#### Post date: [8 June 2004 23:40 UTC](https://rubytalk.org/t/ann-ruby-interface/11998/5 "2004-06-08T23:40:24Z")

</div>

Nice. But the Hash example on the page should be more comprehensive.  
It's ironic that this was driven by wanting to tell an array from a  
hash, and you've defined a :hash interface with just and = !

Gavin

> **···**
>
> On Wednesday, June 9, 2004, 4:46:30 AM, Sean wrote:
> 
> > Ruby/Interface 0.1-1
> 
> > Homepage/Documentation: [http://interface.rubyforge.org/](http://interface.rubyforge.org/)

---

<div class="post-metadata">

### Author: ![Sean\_O\_Dell1](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@Sean\_O\_Dell1](https://rubytalk.org/u/Sean_O_Dell1)
#### Post date: [9 June 2004 01:00 UTC](https://rubytalk.org/t/ann-ruby-interface/11998/6 "2004-06-09T01:00:49Z")

</div>

Changed the name of the library to [celsoft.com/interface](http://celsoft.com/interface).

&nbsp;&nbsp;Sean O'Dell

---

<div class="post-metadata">

### Author: ![Sean\_O\_Dell1](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@Sean\_O\_Dell1](https://rubytalk.org/u/Sean_O_Dell1)
#### Post date: [9 June 2004 19:55 UTC](https://rubytalk.org/t/ann-ruby-interface/11998/7 "2004-06-09T19:55:34Z")

</div>

I decided the library wasn't "Ruby" enough and I got some ideas from Daniel  
Berger's interface library, so I made a lot of changes.

Homepage: [http://interface.rubyforge.org/](http://interface.rubyforge.org/)  
Rubyforge Project Homepage: [http://rubyforge.org/projects/interface/](http://rubyforge.org/projects/interface/)  
Download: [http://rubyforge.org/frs/?group\_id=266&release\_id=529](http://rubyforge.org/frs/?group_id=266&release_id=529)

Code Snippet:

&nbsp;&nbsp;require "[celsoft.com/interface](http://celsoft.com/interface)"

&nbsp;&nbsp;HashInterface = Interface.new

&nbsp;&nbsp;HashInterface.add\_class\_patterns(Hash, :[], :[]=)  
&nbsp;&nbsp;HashInterface.add\_pattern(:each\_pair, proc{||})

&nbsp;&nbsp;class Hash  
&nbsp;&nbsp;&nbsp;&nbsp;implements HashInterface  
&nbsp;&nbsp;end

&nbsp;&nbsp;class\<\<ENV  
&nbsp;&nbsp;&nbsp;&nbsp;implements HashInterface  
&nbsp;&nbsp;end

&nbsp;&nbsp;p Hash.new.implements?(HashInterface) == true  
&nbsp;&nbsp;p ENV.implements?(HashInterface) == true

&nbsp;&nbsp;HashInterface.add\_pattern(:each\_pair, proc{|a|}) # method param changed

&nbsp;&nbsp;p ENV.implements?(HashInterface) == false

How It Works

Method patterns are stored with each Interface object and are used to check  
against the methods of any given object. The name and number of parameters  
are important. If an object never claims to implement an interface, it will  
always report that it does not implement a given interface, even if it may be  
capable of it. When an object claims to implement an interface, a thorough  
check is performed to verify that it actually does. This check is only  
performed when necessary for efficiency, when implements? is called. The  
result of the check is cached and returned quickly on subsequent calls to  
implements?. If either the interface definition changes, or methods are  
changed in the class of the object, the cache is dumped and the thorough  
check is performed the next time implements? is called, and the answer is  
then again cached.

---

<div class="post-metadata">

### Author: ![Sean\_O\_Dell1](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@Sean\_O\_Dell1](https://rubytalk.org/u/Sean_O_Dell1)
#### Post date: [8 June 2004 20:50 UTC](https://rubytalk.org/t/ann-ruby-interface/11998/8 "2004-06-08T20:50:46Z")

</div>

I have to ponder this a bit. I admit I am not entirely clear how Ruby works  
internally, and singletons are something I don't quite get. Let me digest  
the suggestions.

&nbsp;&nbsp;Sean O'Dell

> **···**
>
> On Tuesday 08 June 2004 13:23, Mauricio Fernández wrote:
> 
> > On Wed, Jun 09, 2004 at 03:46:30AM +0900, Sean O'Dell wrote:  
> > \> Ruby/Interface tries to solve this problem by ???tagging??? objects as  
> > \> implementing an interface. The implementation is enforced by comparing an  
> > \> object???s methods against the methods expected by the interface.
> > 
> > Some comments:
> > 
> > I see you're using per-class tagging, hence being unable to track  
> > changes in the singleton class. I'd point you again to the last sections  
> > of [http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/102555](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/102555)  
> > which I believe you didn't read.  
> > There's an inconsistency in the code: you're checking the methods of the  
> > object (including its singleton methods) with Object#method but storing  
> > the result in a per-class structure; that won't fly.
> > 
> > Also, using class variables instead of class instance variables ties the  
> > notion of interface to inheritance, which I believe you wanted to avoid.
> > 
> > I would consider storing the conformance information in  
> > ROBJECT(self)-\>klass directly; this will be either the real class or  
> > the singleton class. In the first case, the "conformity table" is  
> > shared by all objects of that class; in the second, it will be "owned"  
> > by the object. The advantage is that this new table would be created  
> > on demand, only when the object is extended/a singleton method is  
> > defined and has\_interface? is called. You wouldn't even need to capture  
> > singleton\_method\_added this way.

---

<div class="post-metadata">

### Author: ![Sean\_O\_Dell1](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@Sean\_O\_Dell1](https://rubytalk.org/u/Sean_O_Dell1)
#### Post date: [8 June 2004 20:51 UTC](https://rubytalk.org/t/ann-ruby-interface/11998/9 "2004-06-08T20:51:33Z")

</div>

Probably right. I'll change it. Seems I'm going to be fiddling it with it  
some more today anyway, may as well take of that now!

&nbsp;&nbsp;Sean O'Dell

> **···**
>
> On Tuesday 08 June 2004 13:28, Peter C. Verhage wrote:
> 
> > Sean O'Dell wrote:  
> > \> Ruby/Interface 0.1-1
> > 
> > Very nice!
> > 
> > But wouldn't implements\_interface(...) instead of declare\_interface(...)  
> > be better, e.g "implements" is the Java terminology for implementing an  
> > interface? And maybe also implements\_interface?(...) instead of  
> > has\_interface?(...). Of aliasses for both.

---

<div class="post-metadata">

### Author: ![Sean\_O\_Dell1](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@Sean\_O\_Dell1](https://rubytalk.org/u/Sean_O_Dell1)
#### Post date: [8 June 2004 21:13 UTC](https://rubytalk.org/t/ann-ruby-interface/11998/10 "2004-06-08T21:13:29Z")

</div>

> \> Ruby/Interface tries to solve this problem by ???tagging??? objects as  
> \> implementing an interface. The implementation is enforced by comparing an  
> \> object???s methods against the methods expected by the interface.
> 
> Some comments:
> 
> I see you're using per-class tagging, hence being unable to track  
> changes in the singleton class. I'd point you again to the last sections  
> of [http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/102555](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/102555)  
> which I believe you didn't read.

Per-class tagging is what I intended. There are three tag states: not tagged,  
tagged but unverified, and tagged and verified. Tagging initially only means  
"objects of this class may implement this interface." A check of the object  
itself later will determine if the object really does implement the  
interface.

> There's an inconsistency in the code: you're checking the methods of the  
> object (including its singleton methods) with Object#method but storing  
> the result in a per-class structure; that won't fly.

I see what you mean. I need to move the storage of the checks themselves to  
the object, absolutely correct. I think what I was thinking when I did it  
this way was, since I get no "module\_added" messages when methods are added  
to objects with \<\<, there was no sense in storing the information with the  
objects themselves. But I see that there's an inconsistency that way. I'll  
change that.

> Also, using class variables instead of class instance variables ties the  
> notion of interface to inheritance, which I believe you wanted to avoid.

No, not necessarily. Classes derived from other classes should inherit the  
interface. The initial tag only means "may implement the interface" not  
"does implement it." The final test is a comparison of the methods of the  
individual object methods and their arity.

> I would consider storing the conformance information in  
> ROBJECT(self)-\>klass directly; this will be either the real class or  
> the singleton class. In the first case, the "conformity table" is  
> shared by all objects of that class; in the second, it will be "owned"  
> by the object. The advantage is that this new table would be created  
> on demand, only when the object is extended/a singleton method is  
> defined and has\_interface? is called. You wouldn't even need to capture  
> singleton\_method\_added this way.

Ah, I see...thanks for pointing me at this. I was never really aware of klass  
before. I just read about how it relates to Singleton's, and it gave a whole  
heap of ideas on how I could do this better.

&nbsp;&nbsp;Sean O'Dell

&nbsp;&nbsp;Sean O'Dell

> **···**
>
> On Tuesday 08 June 2004 13:23, Mauricio Fernández wrote:
> 
> > On Wed, Jun 09, 2004 at 03:46:30AM +0900, Sean O'Dell wrote:

---

<div class="post-metadata">

### Author: ![Sean\_O\_Dell1](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@Sean\_O\_Dell1](https://rubytalk.org/u/Sean_O_Dell1)
#### Post date: [8 June 2004 22:54 UTC](https://rubytalk.org/t/ann-ruby-interface/11998/11 "2004-06-08T22:54:39Z")

</div>

Moving things around to work out of klass helped a lot, Mauricio, thanks for  
the advice. Got a new version up and running already. It handles Singletons  
nicely now.

&nbsp;&nbsp;Sean O'Dell

> **···**
>
> On Tuesday 08 June 2004 13:23, Mauricio Fernández wrote:
> 
> > On Wed, Jun 09, 2004 at 03:46:30AM +0900, Sean O'Dell wrote:  
> > \> Ruby/Interface tries to solve this problem by ???tagging??? objects as  
> > \> implementing an interface. The implementation is enforced by comparing an  
> > \> object???s methods against the methods expected by the interface.
> > 
> > Some comments:
> > 
> > I see you're using per-class tagging, hence being unable to track  
> > changes in the singleton class. I'd point you again to the last sections  
> > of [http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/102555](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/102555)  
> > which I believe you didn't read.  
> > There's an inconsistency in the code: you're checking the methods of the  
> > object (including its singleton methods) with Object#method but storing  
> > the result in a per-class structure; that won't fly.
> > 
> > Also, using class variables instead of class instance variables ties the  
> > notion of interface to inheritance, which I believe you wanted to avoid.
> > 
> > I would consider storing the conformance information in  
> > ROBJECT(self)-\>klass directly; this will be either the real class or  
> > the singleton class. In the first case, the "conformity table" is  
> > shared by all objects of that class; in the second, it will be "owned"  
> > by the object. The advantage is that this new table would be created  
> > on demand, only when the object is extended/a singleton method is  
> > defined and has\_interface? is called. You wouldn't even need to capture  
> > singleton\_method\_added this way.

---

<div class="post-metadata">

### Author: ![Sean\_O\_Dell1](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@Sean\_O\_Dell1](https://rubytalk.org/u/Sean_O_Dell1)
#### Post date: [9 June 2004 00:11 UTC](https://rubytalk.org/t/ann-ruby-interface/11998/12 "2004-06-09T00:11:02Z")

</div>

The name :hash tells you the purpose of the interface, not the method list.  
The method list is just to aid enforcement (to ensure they exist for the  
interface, and to ensure they have the same parameters so you can always  
depend on them being there as you expect them).

.has\_interface?(:hash) =\> false

Make sense?

&nbsp;&nbsp;Sean O'Dell

> **···**
>
> On Tuesday 08 June 2004 16:40, Gavin Sinclair wrote:
> 
> > On Wednesday, June 9, 2004, 4:46:30 AM, Sean wrote:  
> > \> Ruby/Interface 0.1-1  
> > \>  
> > \> Homepage/Documentation: [http://interface.rubyforge.org/](http://interface.rubyforge.org/)
> > 
> > Nice. But the Hash example on the page should be more comprehensive.  
> > It's ironic that this was driven by wanting to tell an array from a  
> > hash, and you've defined a :hash interface with just and = !

---

<div class="post-metadata">

### Author: ![David\_A\_Black3](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@David\_A\_Black3](https://rubytalk.org/u/David_A_Black3)
#### Post date: [9 June 2004 01:06 UTC](https://rubytalk.org/t/ann-ruby-interface/11998/13 "2004-06-09T01:06:43Z")

</div>

Hi --

> **···**
>
> On Wed, 9 Jun 2004, Sean O'Dell wrote:
> 
> > Changed the name of the library to celsoft.com/interface.
> 
> Ignore previous message (similar idea in spirit though  
> flipped the other way) -- hadn't seen this one.
> 
> David
> 
> --  
> David A. Black  
> dblack@wobblini.net

---

<div class="post-metadata">

### Author: ![Mauricio\_Fernndez](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@Mauricio\_Fernndez](https://rubytalk.org/u/Mauricio_Fernndez)
#### Post date: [9 June 2004 20:23 UTC](https://rubytalk.org/t/ann-ruby-interface/11998/14 "2004-06-09T20:23:02Z")

</div>

You might want to capture Module#remove\_method and  
Module#undef\_method...

> **···**
>
> On Thu, Jun 10, 2004 at 04:55:34AM +0900, Sean O'Dell wrote:
> 
> > If either the interface definition changes, or methods are  
> > changed in the class of the object, the cache is dumped and the thorough  
> > check is performed the next time implements? is called, and the answer is  
> > then again cached.
> 
> --  
> Running Debian GNU/Linux Sid (unstable)  
> batsman dot geo at yahoo dot com
> 
> > Linux is not user-friendly.
> 
> It \_is\_ user-friendly. It is not ignorant-friendly and idiot-friendly.  
> &nbsp;&nbsp;-- Seen somewhere on the net

---

<div class="post-metadata">

### Author: ![Jean-Hugues\_ROBERT](https://avatars.discourse-cdn.com/v4/letter/j/e47c2d/32.png) [@Jean-Hugues\_ROBERT](https://rubytalk.org/u/Jean-Hugues_ROBERT)
#### Post date: [10 June 2004 08:28 UTC](https://rubytalk.org/t/ann-ruby-interface/11998/15 "2004-06-10T08:28:00Z")

</div>

> I decided the library wasn't "Ruby" enough and I got some ideas from Daniel  
> Berger's interface library, so I made a lot of changes.
> 
> Homepage: [http://interface.rubyforge.org/](http://interface.rubyforge.org/)  
> Rubyforge Project Homepage: [http://rubyforge.org/projects/interface/](http://rubyforge.org/projects/interface/)  
> Download: [http://rubyforge.org/frs/?group\_id=266&release\_id=529](http://rubyforge.org/frs/?group_id=266&release_id=529)
> 
> Code Snippet:
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;require "celsoft.com/interface"
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HashInterface = Interface.new
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HashInterface.add\_class\_patterns(Hash, :, :=)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HashInterface.add\_pattern(:each\_pair, proc{||})
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class Hash  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;implements HashInterface  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class\<\<ENV  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;implements HashInterface  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p Hash.new.implements?(HashInterface) == true  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p ENV.implements?(HashInterface) == true

Should be implement?() vs implements?() I believe.  
See include?() for example.  
That is a nice Ruby idiom.

Also: You are using both "declarative" (like "implements")  
and "imperative" styles (like "add\_pattern). I feel like  
"declarative" style would be appropriate in both cases.

OTOH that might be a matter of style/taste.

Yours,

JeanHuguesRobert  
EOM

> **···**
>
> At 04:55 10/06/2004 +0900, you wrote:
> 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HashInterface.add\_pattern(:each\_pair, proc{|a|}) # method param changed
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p ENV.implements?(HashInterface) == false
> > 
> > How It Works
> > 
> > Method patterns are stored with each Interface object and are used to check  
> > against the methods of any given object. The name and number of parameters  
> > are important. If an object never claims to implement an interface, it will  
> > always report that it does not implement a given interface, even if it may be  
> > capable of it. When an object claims to implement an interface, a thorough  
> > check is performed to verify that it actually does. This check is only  
> > performed when necessary for efficiency, when implements? is called. The  
> > result of the check is cached and returned quickly on subsequent calls to  
> > implements?. If either the interface definition changes, or methods are  
> > changed in the class of the object, the cache is dumped and the thorough  
> > check is performed the next time implements? is called, and the answer is  
> > then again cached.
> 
> -------------------------------------------------------------------------  
> Web: [@jhr is virteal, virtually real](http://hdl.handle.net/1030.37/1.1)  
> Phone: +33 (0) 4 92 27 74 17

---

<div class="post-metadata">

### Author: ![Sean\_O\_Dell1](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@Sean\_O\_Dell1](https://rubytalk.org/u/Sean_O_Dell1)
#### Post date: [10 June 2004 15:33 UTC](https://rubytalk.org/t/ann-ruby-interface/11998/16 "2004-06-10T15:33:17Z")

</div>

> Should be implement?() vs implements?() I believe.  
> See include?() for example.  
> That is a nice Ruby idiom.

It's not proper English, but perhaps implement? is more "Ruby."

> Also: You are using both "declarative" (like "implements")  
> and "imperative" styles (like "add\_pattern). I feel like  
> "declarative" style would be appropriate in both cases.

On this I totally agree, except for one thing. Since I can't do:

interface IHash  
&nbsp;&nbsp;&nbsp;&nbsp;pattern (key)  
end

...to create the interface (like class or module) I don't feel like  
declarative is the way to go. I have no choice but to build interface  
procedurally, so I felt that more action-oriented methods were better.

I think if Matz ever gives developers the ability to do what I did above  
there, I would switch to something more declarative.

&nbsp;&nbsp;Sean O'Dell

> **···**
>
> On Thursday 10 June 2004 01:28, Jean-Hugues ROBERT wrote:
> 
> > At 04:55 10/06/2004 +0900, you wrote:

---

<div class="post-metadata">

### Author: ![Mark\_Hubbart](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@Mark\_Hubbart](https://rubytalk.org/u/Mark_Hubbart)
#### Post date: [10 June 2004 17:57 UTC](https://rubytalk.org/t/ann-ruby-interface/11998/17 "2004-06-10T17:57:57Z")

</div>

After being annoyed with what looked like improper English in  
all those #foo? methods, I noticed that you could read them as, say, "does foo include?" or "does foo respond\_to?" etc... They make sense that way, and are proper English, inasmuch as any programming construct is proper English 🙂

cheers,  
Mark

> **···**
>
> On Jun 10, 2004, at 8:33 AM, Sean O'Dell wrote:
> 
> > On Thursday 10 June 2004 01:28, Jean-Hugues ROBERT wrote:
> > 
> > > At 04:55 10/06/2004 +0900, you wrote:
> > > 
> > > Should be implement?() vs implements?() I believe.  
> > > See include?() for example.  
> > > That is a nice Ruby idiom.
> > 
> > It's not proper English, but perhaps implement? is more "Ruby."

---

<div class="post-metadata">

### Author: ![Sean\_O\_Dell1](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@Sean\_O\_Dell1](https://rubytalk.org/u/Sean_O_Dell1)
#### Post date: [10 June 2004 18:57 UTC](https://rubytalk.org/t/ann-ruby-interface/11998/18 "2004-06-10T18:57:19Z")

</div>

Interesting way to look at it.

Running my eyes over a lot of Ruby methods, I can see that implement? is more  
correct. However, I noticed that some methods are has\_ or is\_ prepended to  
them. I guess when does\_ makes more sense, the rule is to eliminate it?  
Either way, I see the pattern and I prefer the library behave the way people  
"expect" so I'll change the method names.

Just a side-note: I've added pre-defined interfaces for IArray, IHash,  
IString, IDate and ITime so far. 0.6 will have ITime and IDate and whatever  
others I add. 0.5 already has those others.

&nbsp;&nbsp;Sean O'Dell

> **···**
>
> On Thursday 10 June 2004 10:57, Mark Hubbart wrote:
> 
> > On Jun 10, 2004, at 8:33 AM, Sean O'Dell wrote:  
> > \> On Thursday 10 June 2004 01:28, Jean-Hugues ROBERT wrote:  
> > \>\> At 04:55 10/06/2004 +0900, you wrote:  
> > \>\>  
> > \>\> Should be implement?() vs implements?() I believe.  
> > \>\> See include?() for example.  
> > \>\> That is a nice Ruby idiom.  
> > \>  
> > \> It's not proper English, but perhaps implement? is more "Ruby."
> > 
> > After being annoyed with what looked like improper English in  
> > all those #foo? methods, I noticed that you could read them as, say,  
> > "does foo include?" or "does foo respond\_to?" etc... They make sense  
> > that way, and are proper English, inasmuch as any programming construct  
> > is proper English 🙂
