File Inclusion


As is in C, file inclusion in ATS can be done by using the directive #include. For instance, the following line indicates that a file named foobar is included, that is, this line is to be replaced with the content of the file foobar:

#include "foobar.hats"
Note that the included file is parsed according to the syntax for statics or dynamics depending whether the file is included in a static or dynamic file. As a convention, the name of an included file often ends with the extension ".hats".

A common use of file inclusion is to keep some constants, flags or parameters being defined consistently across a set of files. For instance, the file prelude/params.hats serves such a purpose.

File inclusion can also be used to emulate (in a limited but rather useful manner) the feature of functors (a module-level language construct) as is supported in languages such as SML and Objective Caml. Examples illustrating such a use of file inclusion can be found elsewhere.