Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum IO_ERR
- is
- TIMEOUT,
- BAD_STATE
- end enum
- interface istream
- is
- proc read(in byte[] buffer, size count) returns size, excepts IO_ERR; /*Procedures are non-pure; they can modify state, and can access global variables*/
- func end_of_input() returns bool; /*functions are pure; they cannot modify state, and can only modify parameters that are passed to them (a reference to the class is passed as an input parameter)*/
- end interface
- interface ostream
- is
- proc write(out byte[] buffer, size count) returns size, excepts IO_ERR;
- func end_of_output() returns bool;
- end interface
- interface seekable
- is
- func get_position() returns position;
- proc seek(position x) excepts SEEK_ERR;
- end interface
- /*inerfaces can be compound*/
- type iostream is istream ostream;
- type ipond is istream seekable;
- type opond is ostream seekable;
- type iopond is ipond opond;
- /*The following two classes are identical*/
- class File1
- implements iopond /*compound interfaces are decomposed and duplicates are removed*/
- is
- /*...*/
- end class
- class File2
- implements istream ostream seekable
- is
- /*...*/
- end class
- /*interfaces can also inherit other interfaces*/
- interface ipondx
- implements istream seekable
- is
- /*...*/
- end interface
- interface opondx
- implements istream seekable
- is
- /*...*/
- end interface
- interface iopondx
- implements ipondx opondx
- is
- /*...*/
- end interface
- /*In the case of iopondx, the seek and get_position methods are assumed to have separate implementations for both ipondx and opondx. In the interface iopond, there can only be one implementation of the methods in the pond interface since it is only included once.*/
- /*you can also have functions with unaliased compound types as parameters*/
- func foo(in istream ostream pond a);
- /*You can then pass objects of type File1 or File2 to foo, however:*/
- class File3
- implements iopondx
- is
- /*...*/
- end class
- /*It is not possible to pass objects of type File3 to foo, even though it implements the three interfaces. You must pass objects of a type that implements all three of those interfaces directly and not inherited from other interfaces (except with a cast, and only if single base class or implemented interface directly implements those interfaces)*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement