Anonymous user
Abstract type: Difference between revisions
→{{header|Genyris}}
Line 108:
=={{header|Genyris}}==
In Genyris by default there are no constructors. In effect all classes are Abstract until they are used to tag an object.
<lang python>class
There is no constructor for this class. To prevent the class ever being associated with an instance it suffices to force the validator to fail.
<lang python>class
def !valid?(object) nil
tag Stack some-object ; always fails
*** Error: class
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. In this case it wants two methods, !enstack and !destack:
<lang python>class
def !valid?(object)
object
Line 137:
tmp</lang>
Now we instantate a concrete object and validate that it conforms to the Abstract type:
<lang python>(XYZstack(!new)) :
=={{header|Haskell}}==
|