Chapter 2. Filename Extensions

In ATS, the filename extensions .sats and .dats are reserved to indicate static and dynamic files, respectively. As these two extensions have some special meaning attached to them, which can be interpreted by the command atscc, they should not be replaced arbitrarily.

A static file may contain sort definitions, datasort declarations, static definitions, abstract type declarations, exception declarations, datatype declarations, macro definitions, interfaces for dynamic values and functions, etc. In terms of functionality, a static file in ATS is somewhat similar to a header file (with the extension .h) in C or an interface file (with the extension .mli) in OCaml.

A dynamic file may contain everything in a static file. In addition, it may also contain definitions for dynamic values and functions. However, interfaces for functions and values in a dynamic file should follow the keyword extern, which on the other hand should not be present when such interfaces are declared in a static file. For instance, the following syntax declares interfaces (or types) in a static file for a value named pi and a function named area_of_circle:

val pi : double fun area_of_circle (radius: double): double

When the same interfaces are declared in a dynamic file, the following slightly different syntax should be used:

extern val pi : double extern fun area_of_circle (radius: double): double

Please note that a static file is essentially a special case of a dynamic file. It is entirely possible to replace a static file with a dynamic one.

As a convention, we often use the filename extension .cats to indicate that a file contains some C code that is supposed to be combined with ATS code in certain manner. There is also the filename extension .hats, which we occassionally use for a file that should be included in ATS code stored in another file. However, the use of these two filename extensions are not mandatory, that is, they can be replaced if needed or wanted.