[plt-scheme] Stack Object

From: Anton van Straaten (anton at appsolutions.com)
Date: Tue Oct 15 19:20:17 EDT 2002

> I'm not really aware with Java, but let me ask this: Why is print-name
> not in the interface of the stack example?

The point is that the interface may apply to objects other than "Stack".
Objects belonging to any class which implements the interface can be called
in the same way, without the caller necessarily knowing what kind of object
it has.  All the caller needs to know is that the object supports the
interface that the caller understands.

However, this doesn't stop the Stack object from defining public methods
which are not part of a particular interface.  A caller which knows about
Stack objects, and knows it has a reference to one, can call methods that
are not on the interface.  A caller that is only aware of the interface, can
only call methods on the interface.

If you want to write strict code that always uses interfaces to invoke
methods, you can do so, but this is your choice: MzScheme doesn't require
that you write code this way.

Anton



Posted on the users mailing list.