Changes between Version 6 and Version 7 of Doc/panc/statements


Ignore:
Timestamp:
Mar 7, 2007, 1:33:52 PM (19 years ago)
Author:
/C=FR/O=CNRS/OU=UMR8607/CN=Michel Jouvin/emailAddress=jouvin@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Doc/panc/statements

    v6 v7  
    2020== assignment ==
    2121
    22 Assignment statements are used to modify a part of the configuration tree by replacing the subtree
    23 identified by its path by the result of the execution a DML block. This result can be a single property or a resource holding any number of elements.  There are conditional and unconditional assignments:
     22== delete ==
     23
     24This statement will delete the named path.
    2425{{{
    25 [ final ] path ?= dml;
    26 [ final ] path = dml;
     26delete path;
    2727}}}
    28 where the path is represented by a string literal.  Single-quoted strings are slightly more efficient, but double-quoted strings work as well.  The conditional form (`?=`) will only execute the DML block and assign a value if the named path does not exist or contains the undef value.
     28where the path is a string literal. 
    2929
    30 The assignment will create parents of the value that do not already exist.
     30Note that this statement is '''deprecated'''.  The assignment statement
     31{{{
     32path = null;
     33}}}
     34provides the same functionality.  This statement will disappear in a future release of the pan compiler.
    3135
    32 If a value already exists, the pan compiler will verify that the new value has a compatible type.  If not, it will terminate the processing with an error.
     36== type ==
     37
     38Type definitions are critical for the validation of the generated machine profiles.  Types can be built up from the primitive pan types and arbitrary validation functions.  New types can be defined with
     39{{{
     40type identifier = type-spec;
     41}}}
     42Types referenced in the type-spec must already be defined.  See the Type section for more details on the syntax of the type specification.
     43
     44Note that the compiler keeps the distinct function and type namespaces.  One can define a function and type with the same names.
     45
     46== function ==
     47
     48Functions can be defined by the user.  These are arbitrary DML blocks bound to an identifier.  Once defined, functions can be called from any subsequent DML block.  The function definition syntax is:
     49{{{
     50function identifier = dml;
     51}}}
     52See the Function section for more information on user-defined functions and a list of built-in functions.
     53
     54Note that the compiler keeps the distinct function and type namespaces.  One can define a function and type with the same names.
     55
     56== variable ==
     57
     58Global variables can be defined.  These may be referenced from any DML block after being defined.  They may not be modified from a DML block; they can only be modified from a variable statement.  Like the assignment statement there are conditional and unconditional forms:
     59{{{
     60[ final ] variable identifier ?= dml;
     61[ final ] variable identifier = dml;
     62}}}
     63For the conditional form, the DML block will only be evaluated and the assignment done if the variable does not exist or has the undef value.
     64
     65If the 'final' modifier is used, then the variable may not be subsequently modified.  Attempts to do so will result in a fatal error.
     66
     67Pan provides several automatic global variables: OBJECT, SELF, and LOADPATH (and their deprecated lowercase equivalents).  OBJECT contains the name of the object template being evaluated; it is a final variable.  SELF is the current value of a path referred to in an assignment or variable statement.  The SELF reference cannot be modified, but children of SELF may be.  LOADPATH can be used to modify the load path used to locate template for the include statement.
     68
     69Any valid identifier may be used to name a global variable.  To avoid conflicts with local variables, however, global variables are usually named in all uppercase; local variables in all lowercase.
     70
     71== bind ==
     72
     73The bind statement binds a type definition to a path.  Multiple types may be bound to a single path.  During the validation phase, the value corresponding to the named path will be checked against the bound types.  There are two variants:
     74{{{
     75bind path = type-spec;
     76type path = type-spec;
     77}}}
     78See the Type section for a complete description of the type-spec syntax.  Note that the second form is '''deprecated''' and will disappear in a future release.
     79
     80== valid ==
     81
     82The valid statement binds a validation DML block to a path.  It has the form:
     83{{{
     84valid path = DML;
     85}}}
     86This is a convenience statement and has exactly the same effect as the statement:
     87{{{
     88bind path = element with DML;
     89}}}
     90The pan compiler internally implements this statement as the bind statement above.
    3391
    3492
    35 == delete ==