Open main menu

CDOT Wiki β

Changes

GPU621/Chapel

909 bytes added, 22:57, 29 November 2022
Variables
param myParam = 3.14;
writeln("myConst = ", myConst, ", myParam = ", myParam);
 
At module scope, all three variable kinds can be qualified by the config keyword. This allows the initial value to be overridden on the command line. A config var or config const may be overridden when the program is executed; a config param may be overridden when the program is compiled. Similarly, type aliases maybe be qualified by the config keyword. The comment following each declaration shows how the value can be modified.
 
config var cfgVar = "hello"; // ./variables --cfgVar="world"
config const cfgConst: bool = false; // ./variables --cfgConst=true
config param cfgParam = 4; // chpl variables.chpl -s cfgParam=1
config type cfgType = complex; // chpl variables.chpl -s cfgType=imag
writeln("cfgVar = ", cfgVar,
", cfgConst = ", cfgConst,
", cfgParam = ", cfgParam,
", cfgType = ", cfgType:string);
= Reference =
73
edits