I'm working on Arrows in F# and I wanted to create a ***
operator. I note, however, that (***)
, the necessary way to express an operator in a function definition, overlaps with the F# block comment syntax. So how could you actually express this?
I thought of maybe .***.
but I think that will actually treat the dots as part of the operator, which I'd rather avoid.
You declare an operator function with the keyword operator preceding the operator. Overloaded operators are distinct from overloaded functions, but like overloaded functions, they are distinguished by the number and types of operands used with the operator. Consider the standard + (plus) operator.
An operator function is a user-defined function, such as plus() or equal(), that has a corresponding operator symbol. For an operator function to operate on the opaque data type, you must overload the routine for the opaque data type.
Operator Overloading in C++ This means C++ has the ability to provide the operators with a special meaning for a data type, this ability is known as operator overloading. For example, we can overload an operator '+' in a class like String so that we can concatenate two strings by just using +.
Operators that cannot be overloaded in C++ For an example the sizeof operator returns the size of the object or datatype as an operand. This is evaluated by the compiler. It cannot be evaluated during runtime. So we cannot overload it.
Yes, but you need to add spaces between the parentheses and the asterisks:
let ( *** ) x y = x * y
let z = 4 *** 5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With