Chapter 3. More YCP types

Table of Contents

3.1. Data Type block

Section not written yet...

3.1. Data Type block

Basically a block is a sequence of YCP statements enclosed in curly brackets. It can be a whole YCP program as was the case with the outermost block in hello.ycp from Section 1.1, “YCP Source”. What is special about blocks in YCP is that they represent a value and therefore can be assigned to a variable. It is sometimes really useful to have those blocks as YCP values because this makes it possible to use them as parameters to function calls. Of course the syntactical structure of blocks can become rather complex which leads to a description of the whole language itself. Therefore we put this into a section of its own: Chapter 8, YCP Program Structure.

For now the following examples should suffice.

Example 3.1. Block constants

{ return 17; }
{ integer a = 5; return a + 8; }