Changes between Initial Version and Version 1 of Doc/panc/dml/variables


Ignore:
Timestamp:
Mar 4, 2007, 6:37:54 PM (17 years ago)
Author:
/O=GRID-FR/C=FR/O=CNRS/OU=LAL/CN=Charles Loomis
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Doc/panc/dml/variables

    v1 v1  
     1= Variables =
     2[[TracNav]]
     3
     4To ease data handling, you can use variables in any DML expression. They are by default lexically
     5scoped to the outermost enclosing DML expression.  They do not need to be declared before they are
     6used.  The local variables are destroyed once the outermost enclosing DML block terminates.
     7
     8As a first approximation, variables work the way you expect them to work. They can contain proper-
     9ties and resources and you can easily access resource children using square brackets:
     10{{{
     11# populate /table which is a nlist
     12’/table/red’ = ’rouge’;
     13’/table/green’ = ’vert’;
     14
     15’/test’ = {
     16  x = list(’a’, ’b’, ’c’); # x is a list
     17  y = value(’/table’);     # y is a nlist
     18  z = x[1] + y[’red’];     # z is a string
     19  return(length(z));       # this will be 6
     20};
     21}}} 
     22
     23Local variables are subject to primitive type checking.  So the primitive type of a local variable cannot be changed unless the variable is assigned a value of 'undef' or 'null' between the type-changing assignments.
     24
     25Global variables (defined with the 'variable' statement) can be read from the DML block.  Global variables may not be modified from within the block; attempting to do so will abort the execution.
     26
     27Global and local variables share the same namespace.  Consequently, there may be unintended naming conflicts between them.  The best practice to avoid this, is to name all local variables with all lowercase letters and all global variables with all uppercase letters. 
     28
     29