TYL PROGRAMMING LANGUAGE
▶ DYNAMIC SYSTEM MODULES
Overview
Dynamic System Modules are internal system modules that handle specialized tasks, such as database management, running processes and network TCP/IP communication. They come in two flavours: single and instance, and will be called single module and instance module respectively.

These modules are like classes in OOP languages. They have variables, functions and a construction or initialization mechanism, and they can be instantiated. But there are some differences in their behavior as Tyl modules, and also between themselves, because they are designed to work in a secure and optimal way to handle their tasks. Most of their variables can't be set a value, meaning they are read only variables, and they must be initialized with a minimum set of variables.

In this chapter we will work with an exemplary module called shaper, that has shape, data and location variables, and draw function. shaper draws a shape based on data in a location. Let's assume shaper must know its shape in order to function. In order to draw, it needs data and location, but without location it will draw in a location that's based on an internal algorithm.

All dynamic system modules are in caribbean green color, and properties or functions are in denim blue color.
Working with Single Modules
Each system module must be defined or initialized prior to using its functionalities:
shaper 'Circle'
shaper module is initialized in the same way a function is being called, its module name 'shaper', is written first and then comes arguments list. The arguments are in a predefined order, so if for shaper it is: shape, data and location, shape will be assigned the value 'Circle'. Note that since shape is crucial to shaper functionality, the only place that it can be set is in the initialization line.

Since the first token of this initialization line is the module name, it will be regarded as a single module, also known as static or singleton. All access to its variables and functions will be in the format module.variable and module.function respectively.

Once initialized, a single module will be available throughout the program and all merged modules.

So to print shaper shape:
print shaper.shape
Setting other variables is done as a regular variable assignment:
shaper.data 10
If a module has all its necessary variables to activate one of its functions, it can call the function:
shaper.draw
shaper will regard data as the circle radius, and will draw the shape.

There is no limit to modules initialization times, and whenever a new set of variables is needed, simply reinitialize the module:
pdata [ 5 100 ]
plocation [ 150 100 ]
shaper 'Rectangle' 10
shaper 'Poligon' pdata plocation
shaper.draw
data is a variable with non defined type, meaning it can handle different types, so in the case of the second initialization, it will have a list with the poligon data, and will draw it at plocation.
Attention: All variables in the initialization line must be either scalar values or variables. Other programmatic constructs such as string concatanations, functions and parentheses are not allowed!
Single modules are mainly good for preconfiguring them with a set of properties, and then using their functionalities. But if we need some modules with different properties, we better use instance modules.
PART 2