Changes between Version 1 and Version 2 of Doc/panc/stdtpl/functions


Ignore:
Timestamp:
Nov 30, 2007, 11:34:41 AM (17 years ago)
Author:
/O=GRID-FR/C=FR/O=CNRS/OU=LAL/CN=Charles Loomis
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Doc/panc/stdtpl/functions

    v1 v2  
    22[[TracNav]]
    33
     4Several pan programming patterns or idioms occur frequently in machine configurations.  The functions defined in the "pan/functions" template provide shortcuts to using those idioms.  To access the functions, the template must be included in the machine configuration:
     5{{{
     6  include { 'pan/functions' };
     7}}}
     8After this is included, any of the defined functions can be used from within DML blocks.
     9
     10== 'self' Utility Functions ==
     11
     12Often one want to add elements to a resource (list or hash) incrementally with a sequence of assignment statements.  Those assignment statements usually being in different templates.  The following functions provide simple mechanisms to do so.
     13
     14"""push(element...) """
     15This function will return a copy of self with the given value(s) appended to the end.  If self is undefined, the function will create a new list with the arguments and return that.  An example is
     16{{{
     17  '/mylist' = push('a');
     18  '/mylist' = push('b');
     19}}}
     20The final value for '/mylist' will be a two-element list containing 'a' and 'b'. 
     21
     22Be careful, however, because the value of self is not directly modified by the push() function.  This means that the following:
     23{{{
     24  '/mylist' = {
     25    push('a');
     26    push('b');
     27  };
     28}}}
     29will leave '/mylist' with the one-element list 'b'.
     30
     31   
     32
     33== 'object' Utility Functions ==
     34
     35