1. Separators of function parameters
Colon (:), comma (,) and semicolon (;) are used as separators of function parameters in esProc. Their priority decreases in turn.The most common method is to use commas to separate parameters, which is in line with function syntax in most programming languages. For example:
In this
example, parameters of if(), create() and T.insert() function in A3, A4 and A5 are separated from each
other by commas.
Some
functions have “coupled” parameters, which are closely related or work
together. In this case, a colon is often used to separate them.
For
example, for if() function in A3, each
condition corresponds to a returned result and colons are used to separate the
results. In the in() function used in one condition, 150 and 180
are also separated by a colon and together they form a numerical interval [150,180].
In A5's T.insert() function, field value and field name also come in
pairs with colons in between to separate them.
In some
functions, indicative parameters can be added to certain parameters to change
the computational method relating to them. In this case, colons are usually
used as separators. See below:
Both A2 and
A3 sort records of cities according to state ID first, then sort by name if
cities belong to the same state. Difference is that -1 is appended after NAME
in A3's function, meaning that sorting by name is in a descending order.
Sometimes,
parameters in function can be divided into different parts according to their
roles. Semicolons are usually used to separate these parts.
In A2's groups() function, the parameter before the semicolon is
used for grouping, and those after it are for summarizing computation, whose
parameters are separated by a colon to define name of the summarizing field. In
A3's top() function, the parameter after semicolon defines that
the top 5 records are fetched.
In some
functions, parameters are quite many. Usually these parameters are divided into
several groups which are separated by semicolons:
T.switch() function in A4 transforms
different fields into records of another table sequence, and a semicolon is used
here. Besides, comma, colon and semicolon are all used in A4 as separators.
This kind of code writing creates clear layers for function parameters.
2. Omission of function parameters
Some esProc parameter functions have default values and, therefore, can be omitted, making functions more concise.
In A5,
parameters after colon are used to designate field names corresponding to
certain values when inserting records. Parameters for designating field names
can be omitted in A6 because it uses default field names to set field values
one by one.
But colons
cannot be omitted when they are used to separate intervals:
In A3, in(B1+B2,180:)
and in(B1+B2,:120) represent respectively B1+B2>=180 and B1+B2<=120,
in which the colons cannot be omitted.
For
parameters separated by semicolons, the semicolon can be omitted if there is no
parameter after it. For example, if n is not set in A.top()
function and only the top one is needed; or when the transformation of a
certain field is not needed in T.switch() function.
When commas
are used as separators, they should generally be retained even if parameters
are set by default. For example:
Expression in A2
equals to =A1.to(4,A1.len()), expression in A3 equals to =A1.to(1,4).
没有评论:
发表评论