8.1 Functors as values

A functor is data-structure that describes a module. In the same way that proc {Foo... end constructs a procedure, functor Foo ... end constructs a functor. For example:

declare 
functor Foo 
export 
   greetings : Greetings
define 
   Greetings = 'hello world' 
end

Let's take a look at this value by invoking {Inspect Foo}:

What we see is that a functor is an Oz value known as a chunk. A chunk is like a record in that it has features, but unlike records which have structural equality, chunks have token equality; that is, each chunk is unique an distinct from any other chunk, even if they have the same features and values.



Denys Duchier, Claire Gardent and Joachim Niehren
Version 1.3.99 (20050412)