Let me delve a little bit into the problem. According to the documentation:
The do keyword is used to call an expression (normally, a method call) just for its side-effect, and discards the result.
Now according to the list of possible expressions in the file I referred to before:
IntLit(value) StringLit(value) True() False() And(lhs, rhs) Or(lhs, rhs) Plus(lhs, rhs) Minus(lhs, rhs) Times(lhs, rhs) Div(lhs, rhs) LessThan(lhs, rhs) Not(expr) Equals(lhs, rhs) ArrayRead(arr, index) ArrayLength(arr) MethodCall(obj, meth, args) Variable(Identifier(name)) New(tpe) This() NewIntArray(size)
I want to figure out first in which cases should do act. Clearly, it should act with MethodCall as it provides a result but also with expressions that contain operators (And,Or,Plus,Minus,Times,Div,LessThan,Not,Equals,...). What would be the complete list of cases I should consider?
My second question is how can I implement Do behaviour for MethodCall, that is, not getting the result but getting the side effects.