Robert Hodge
17-06-2013, 04:35
The DIM statement allows for multiple declarations of variables, such as
DIM a, b, c AS LONG
However, in this example, a and b are not of type LONG but are variants. Thus, the AS LONG clause is not applied to the entire list of variable, but only to the last name (c).
This syntax can mislead the reader. It is desirable to have some way to declare all three variables with the same type, without having to respecify the AS clause each time. A few possible syntax options come to mind:
First, instead of a comma, some other punctuation would be used to connect a list of variables:
DIM a & b & c AS LONG
DIM a; b; c AS LONG
Second, the list could be put into parens, or maybe braces:
DIM (a, b, c) AS LONG
DIM {a, b, c} AS LONG
My personal vote, all things being equal, I'd would choose the parenthesized list.
DIM a, b, c AS LONG
However, in this example, a and b are not of type LONG but are variants. Thus, the AS LONG clause is not applied to the entire list of variable, but only to the last name (c).
This syntax can mislead the reader. It is desirable to have some way to declare all three variables with the same type, without having to respecify the AS clause each time. A few possible syntax options come to mind:
First, instead of a comma, some other punctuation would be used to connect a list of variables:
DIM a & b & c AS LONG
DIM a; b; c AS LONG
Second, the list could be put into parens, or maybe braces:
DIM (a, b, c) AS LONG
DIM {a, b, c} AS LONG
My personal vote, all things being equal, I'd would choose the parenthesized list.