Abstract type: Difference between revisions
Content added Content deleted
Line 112: | Line 112: | ||
<lang python>class Stack() |
<lang python>class Stack() |
||
def !valid?(object) nil |
def !valid?(object) nil |
||
tag Stack some-object ; always fails</lang> |
tag Stack some-object ; always fails</lang> |
||
However this is not much use if we want to use an abstract class to define an interface. Here is a quasi-abstract class which can be used to tag objects if they conform to the class's membership expectations: |
|||
<lang python>class AbstractStack() |
|||
def !valid?(object) |
|||
object |
|||
and |
|||
bound? !enstack |
|||
is-instance? !enstack Closure |
|||
bound? !destack |
|||
is-instance? !destack Closure</lang> |
|||
=={{header|Haskell}}== |
=={{header|Haskell}}== |