I'm not sure that I would agree here. Do you have a simple example?
foo.DoSomething()
... // remember not to return
// without foo.Done() called
// (EDITed for clarity:
// foo is the state, that changes,
// so you have to keep track of
// its changes)
foo.Done()
vs DoSomething (func(){
... // don't have to remember
// a thing, no side-effects,
// equivalent of .Done() is
// called afterwards for you
})
EDIT2: exact behavior is not the point, keeping track of things is. DoSomething(func() { ... })
becomes DoSomething(new Runnable() {
public void run() { ... }
});
or the longer form class MyAction implements Runnable {
public void run() { ... }
}
DoSomething(new MyAction());If you're considering a language deficient of functions then we can take advantage exactly of the idea that objects can embed functions by having a "callable" thing.
foo#doSomething (object
method call : unit -> unit =
...
end)