Evaluation of variables - HiStructClient/femcad-doc GitHub Wiki
Do you wonder why you should use := or = in FemCad scripting?
The difference is in type of evaluation. Sign := stands for lazy evaluation and = stands for eager evaluation.
The author of FemCad suggest the following:
- for definition of main variables in gclass please use := (we might not need all the variables in gclass)
- inside dynamic objects, prefered is shorter = (the variable is evaluated during creation of object anyway)
- inside updaters, the suggested is shorter = (the variable is evaluated during creation of the called class anyway)
- if you are using .Aggregate function which uses updater in each iteration, please prefer the eager (=) evaluation, this prevents stacking of gclasses
The reason behind is the following:
= ... right hand side is evaluated immediately after loading of gclass, regardless the variable is used or not (eager evaluation)
:= ... right hand side is evaluated only in case some variable need the identifier on the left hand side (lazy evaluation)