Closed tdakkota closed 3 years ago
While the proposed change would not cause any existing program not to compile, it is a semantically breaking change to the contract of an existing interface. That is, every place that currently calls Iterator.Done would become responsible for checking whether the iterator implements ErrIterator and handling the result of the Err method if so; failure to do so would cause errors to be silently ignored.
Current iterator API https://github.com/google/starlark-go/blob/74c10e2c17dcdb1cd5ff8044e33d9338820db233/starlark/value.go#L238-L244 does not allow to return error, which got during iteration.
As I understand, Java implementation uses exception to pass errors. https://github.com/bazelbuild/bazel/blob/f78ffb5fb2f37d20acd1320ed37080c26b32e607/src/main/java/net/starlark/java/eval/Eval.java#L118-L119
I think Go implementation can provide a special interface like
Example usage: