Declares or defines an overloaded operator.
typename
assignment_op
let += -= *= /= \= mod= shl= shr= and= or= xor= imp= eqv= ^=
unary_op
- not @ * -> abs sgn fix frac int exp log sin asin cos acos tan atn
binary_op
+ - * / \ mod shl shr and or xor imp eqv ^ = <> < > <= >= andalso orelse
The built in operators like
=,
+, and
cast have predefined behaviors when used in expressions. These operators can be overloaded to do something other than predefined operations when at least one of the arguments to the operator is a
Type,
Class,
Enum, or
Union data type.
Operators are just functions. The operator '+' has functionality like
Function Plus( A as DataType, B as DataType ) as DataType. See
Operator Overloading for more information. Operators can be overloaded to accept different data types as parameters. Only the
Cast Operator can be overloaded to return different types.
Non-static operator members are declared inside the
Type or
Class. Global operators are declared outside. All operator definitions (procedure bodies) must appear outside.
Let,
Cast, and other assignment operators must be declared inside the
Type or
Class. They are passed a hidden
This parameter and have a return data type same as the
Type or
Class they are declared in.
Unary operators must be declared outside the
Type,
Class, or
Enum and have a return data type explicitly declared. Unary operators can be overloaded to return any valid data type, except for
Operator -> (Pointer To Member Access) which must return a
Type or
Class data type.
Binary operators must be declared outside the
Type,
Class, or
Enum and have a return data type explicitly declared. Binary operators can be overloaded with valid data types, except for relational operators, which must return
Integer.
Let refers to the assignment operator, as in
LET a=b. The
Let keyword is omitted in common practice, and is not allowed in the
-lang fb dialect. However,
Let() can be used to assign the fields of a UDT to multiple variables.
See
For,
Step, and
Next for more information on overloading the
For..Next statement for use with user defined types.