i have a problem with class operators (Delphi XE).
i have a problem with class operators (Delphi XE).
Lets say i have a Generic Record
and Enum TFoo = (a, b).
i have an operator for Add looking like this:
Add(Left: Record; Right: array of T)
I thought this way i could work like Sets if declared as Record:
MyRec := MyRec + [a]
The second parameter is treated as set (which is formal correct) but will give an "operator not applicable" error. How can i solve this? I'd like to keep the [] syntax.
Lets say i have a Generic Record
and Enum TFoo = (a, b).
i have an operator for Add looking like this:
Add(Left: Record
I thought this way i could work like Sets if declared as Record
MyRec := MyRec + [a]
The second parameter is treated as set (which is formal correct) but will give an "operator not applicable" error. How can i solve this? I'd like to keep the [] syntax.
You are right, in XE [] is open array constructor or a set, period.
ReplyDeleteThis seems ambiguous. What resolves the ambiguity?
ReplyDelete(I guess "everything that is in [] and is NOT in an openarray parameter" isn't clear to me.)
what would make this be regarded as an open array constructor? Different types of things inside of [ . . . ]? Or things declared elsewhere?
It's an open array parameter when the parser encounters it as actual parameters, otherwise the parser regards it to be a set.
ReplyDelete