The access rights (as private, protected and public) of the overload iterating operators (For, Next and Step) are not taken into account by the For...Loop statement.
By cons (for example), that works well for the overload operators New([]) and Delete([]) when called from New([]) expression and Delete([]) statement.
Example:
Type UDT Public: Declare Constructor (Byval i As Integer) Dim As Integer I Private: Declare Operator For (Byref iterateStep As UDT) Declare Operator Next (Byref iterateCondition As UDT, Byref iterateStep As UDT) As Integer Declare Operator Step (Byref step_var As UDT) End Type Constructor UDT (Byval i As Integer) This.I = i End Constructor Operator UDT.For (Byref iterateStep As UDT) End Operator Operator UDT.Next (Byref iterateCondition As UDT, Byref iterateStep As UDT) As Integer If iterateStep.I >= 0 Then Return This.I <= iterateCondition.I Else Return This.I >= iterateCondition.I End If End Operator Operator UDT.Step (Byref step_var As UDT) This.I += step_var.I End Operator For iterator As UDT = UDT(5) To UDT(10) Step UDT(1) ' expected: error 202: Illegal member access Print iterator.I Next iterator Sleep
fixed in fbc-1.08.0
[982a4f92862f3264a07f182d30bdfbd15d729e67]
Related
Commit: [982a4f]