Chapter 2. True YCP Modules

Table of Contents

2.1. Included Modules
2.2. True Modules (Imported Modules)
2.3. True Modules And Constructors

True modules are rather new in the YaST world and it is planned that they will replace the old method of including modules completely (with exception of some rare cases perhaps). The following sections will outline the differences between these concepts.

2.1. Included Modules

YCP, originally planned as a functional language, always did dynamic (i.e. runtime) binding of variables. Although useful in many cases, it's quite puzzling for someone used to “imperative” languages. So you could well program the following block and get an unexpected result.

{
   integer x = 42;

   define f() ``{ return x; }

   ... // lots of lines

   x = 55;

   return f();  // will return 55 because of runtime binding of x!
}
	

Another widely misused feature is to include global definitions. While there was no alternative as long as include was the only referencing instrument, this is certainly not a good programming practice in view of speed and memory considerations.