#!/usr/local/bin/rune # # Demonstrate an interface (multiple inheritance) import "sys" as self; import "stdio"; alias stdio.File *stdout = stdio.stdout; # sample class # class HashableListNode { interface ListNode lnode; interface HashNode hnode; } class HashableList { int a; int b; # An 'interface' combines a named declaration with an unnamed subclass # definition and also allows a pointer to our class (HashableList) # to be cast to a pointer to the subclass (list in this case). # interface List list { refine method void addTail(HashableListNode @node) { super.addTail(node); hash.super.addHash(node); } ... } interface Hash hash { refine method void addHash(HashableListNode @node) { super.addHash(node); list.super.addTail(node); } } }