Changes (Dynamics 0.1, 25th of June 2002)
Dynamics are still under development. It is therefore important to note that dynamics are released for experiments only. Please re-read the last sentence.
At least the following restrictions apply:
However algebraic, record, function and array typed objects can be safely packed and/or unpacked.
The rest of this text is a practical guide on using dynamics and its supporting tools.
A dynamic (of static type Dynamic) consists of:
Basic operations on dynamics:
In addition there are type dependent functions i.e. the context determines the type of the packed object.
Please see the ‘Examples’-folder for concrete syntax and examples.
In addition to the normal procedure to create a new Clean project:
A dynamic is created using the following syntax:
dynamic <an arbitrarily Clean object> :: <external type>
Eventually most typed Clean objects can be injected into a dynamic. Only for some objects e.g. World, File, … natural restrictions will apply.
The external type of a dynamic is the static type of the object injected into the dynamic. The internal type of a dynamic are the types of all objects which help to create an object of the external type.
An example (Clean fragment):
dynamic (length [‘a’,’b’,’c’]) :: Int
The current implementation need not perform the rather costly internal type check because it is done at compile-time and the use of code repositories preserves the validity of the compile-time check.
After a dynamic project has been compiled and linked without errors, the static linker has created:
Only the batch-file is visible for the user and it replaces the executable that would normally be generated by the linker.
The code and type repositories for the dynamic project have been stored in the ‘libraries’-subfolder of the dynamic linker folder which has been set in the Clean IDE.
There are two ways to start a dynamic project:
The batch-file starts the dynamic linker by giving it the code repository for the dynamic application. The dynamic linker then starts the application at its normal entry point.
Each object in Clean conceptually is a graph rewriting system. The graph at run-time consists of:
In order to encode a dynamic e.g. write it to disk the above components of the run-time graph need to be encoded:
In addition lazy dynamics are supported. The dynamic version of the standard apply-function (see also Examples-folder) creates references to other dynamics. These references can be viewed using the dumpDynamic-tool. At run-time only those pieces of the dynamic are constructed which are actually needed. This improves efficiency.
An object packed into a dynamic on disk can be retrieved using the readDynamic-function. This function converts the disk representation of a dynamic to its run-time representation. The necessary functions are linked by a dynamic linker. As said the retrieval of dynamic happens in pieces to increase efficiency.
A dynamic pattern is transformed into the following actions that are performed in the order of enumeration:
Two type constructors are considered equal if their implementations are syntactically exactly the same modulo alpha-conversion. In case of an algebraic data-type the constructor order is insignificant.
The multiple occurrence of a type pattern variable on the left hand side of a function definition can be views as a means to do unification between different dynamics.
Garbage collection for dynamics and libraries
The garbage collector collects dynamics and libraries starting from some root mentioned on the first line of the ‘rootDir.txt’-file in your Dynamics 0.1-folder. Only a single root can be handled at the moment. You need to adapt the path for your machine. The garbage collector itself is in the utilities folder.
Some practical tips are given below:
From the paper-page (http://www.cs.kun.nl/st/Onderzoek/Publicaties/publicaties.html):
Papers about dynamics:
This paper describes the Input/Output of dynamics. This is called dynamic I/O. It illustrates the most interesting problems and their solutions to realize dynamic I/O.
This paper describes type dependent functions. A type dependent function can be use to enforce the static type context of the function upon a dynamic.
This paper introduces the notion of a dynamic and its two basic operations for the lazy functional programming language Clean.
Papers about the applications of dynamics:
This paper describes the combination of dynamics and generics. The combination allows writing pretty printers and parser for dynamic in an easy way.
This paper describes a first step towards an operating system written using Clean. It intensively uses dynamics.