Index: 06_feature/query/lang.html =================================================================== --- 06_feature/query/lang.html (revision 33025) +++ 06_feature/query/lang.html (revision 33026) @@ -201,6 +201,35 @@ A void value is never equal to anything. A void value is not equal even to another void value. +
+User functions are defined with the function keyword, followed +by the function name and a comma separated list of argument names in +parenthesis. The argument list may be empty. Each argument passed must be +an object or a list (i.e. numbers can not be passed). +
+The body of the function may contain the same constructs as the body of a rule. +
+A function definition ends with a return keyword followed by an expression. +The experession is evaluated and the resulting value is returned. If the +expression iterates, the last evaluated value is returned. +
+Example (counts the number of non-terminal, holed padstacks on a net object +called LNET): +
+function count_vias(LNET) +let OBJS netobjs(LNET) +let VIAS (OBJS.type == PSTK) && (OBJS.hole > 0) && (OBJS.a."term" == "") +return llen(list(VIAS)) ++
+On the calling side user functions are the same as built-in functions, e.g. +the above functions can be called as: +
+let ALLNETS netlist() +assert (count_vias(ALLNETS) != 4) ++
Comments are lines starting with #