-
Notifications
You must be signed in to change notification settings - Fork 316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Vector.build_multiple
and handle dataflow error and warning propagation in build
and build_multiple
#9766
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reconciling the very functional dataflow error and warning mechanisms with these rather-imperative builders is quite a challenge. I'm really really happy we are patching the holes and making the error/warning propagation more robust - that's really great!
I've got some minor comments. The biggest issue I see is the quadratic complexity explosion at warnings handling.
Maybe we should consider changing our underlying data structures, to make +
on vectors more efficient (we could use a similar Rope structure as we use on the Text
type). But that's a bigger effort. For now let's just (slightly ironically) use an imperative builder there.
distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Time/Format/Tokenizer.enso
Outdated
Show resolved
Hide resolved
self.warnings.put (self.warnings.get + (warnings.map .value)) | ||
Nothing | ||
warnings = Warning.get_all x . map .value | ||
append_result = self.warnings_java_builder.appendTo (warnings . slice 0 warnings.length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this slice
needed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously this was needed to prevent an error, but it's not happening now, so I've removed it.
Adds
Vector.build_multiple
to build multipleVector
s at the same time.Also handles uncaught dataflow errors being added to builders or returned from builder callbacks, as well as attached warning propagation.
This converts the remaining uses of
Vector.new_builder
toVector.build
inStandard.Base
.Following @Jaroslav’s suggestion, this PR implements the propagation of dataflow errors passed to
Builder.append
by wrapping them in a Panic.This is implemented as
Panic.throw_wrapped_if_error
andPanic.handle_wrapped_dataflow_error
, which I have modified to allow specifying the error type and a custom handler.Previously, we relied on the dataflow errors being propagated by
Builder.append
, which sometimes required thefold
pattern to ensure that error values were not added to theBuilder
as if they were regular values.Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
./run ide build
.