[plt-scheme] About "interface" in MzScheme
For now, they are "stamps" on a class that "bless" it as "it implements
this interface." You can then test it with is-a and validate that nobody
has given you a bad thing. It's like predicates on numbers, booleans,
structures, and other things.
We may also add contracts to interfaces one day. Don't hold your breath
however.
-- Matthias
At Wed, 19 Jun 2002 15:01:51 +0800 (CST), =?big5?q?Oscar?= wrote:
> [Please handle PLT Scheme list administrative tasks through the Web:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme]
>
> Hi All,
> I'm new to MzScheme and feel exciting
> about the OO system =).
> However, I wonder what's the "interface"
> for? In Java/C++ interfaces or classes with
> pure abstract methods are used as place holder
> for real implementation of methods. However,
> in Scheme you do not even need to worry about
> types when you create variables to hold the
> object.
>
> e.g.
> In Java:
> public interface MyInterface {
> public void doIt();
> ...
> }
> public class MyClass implement MyInterface {
> public void doIt();
> ...
> }
>
> public class OtherClass {
> public void go(MyInterface mi) {
> // so we are sure "mi" have "doIt()"
> mi.doIt();
> }
> }
>
>
> In Scheme:
> // no need to declare type for "obj"
> (define obj (make-object MyClass%))
>
> So why do you need interfaces?
> Are there any more detailed tutorial to
> OO system of MzScheme besides the Manual?
>
> Regards,
> Oscar
>
> -----------------------------------------------------------------
> < ¨C¤Ñ³£ Yahoo!©_¼¯ > www.yahoo.com.tw