How to hide type internals



Hi,

I would like to write a package that exports functions using a special
type, without showing the details in the spec (even not in the private
part).
In Modula-2 one can declare opaque types (which mostly are pointers but
also can be any type of word size).

Like this:

package keys is
type key;
function GetKey return key;
procedure FetchElement (k : key);
-- implementation of key not visible here
end keys;

package body keys
...
type Data is record
...
end record;
type key is access Data;
....
end keys;

.



Relevant Pages