-
Notifications
You must be signed in to change notification settings - Fork 28
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
Added err outport for Println. #860
base: main
Are you sure you want to change the base?
Conversation
Nice job 👍
Good catch. So this one is a bit tricky:
So you have choice here
BTW there's an issue related to this (but not about exactly this)
Default template must be changed because otherwise e2e tests will fail
Please check if Go's |
I believe (I didn't test it!)
|
Ok, I have more questions regarding this. So first of all, I just checked the Go documentation for their Print's. They throw errors, but they mention, that it is convention, not to worry about errors. There would be the question, how much do we want to follow Go for that? If we really are strict about it, this PR should be closed and we would need to remove the error from Printf. But independent of this, we have to think about how do deal with For. Because this raises even more questions. The For-handler can throw multiple errors. Therefore, wouldn't we need an error-stream for that? Alternative ideas I had would be a separate TryFor-component (although I don't really like this idea) or to include an error handler that handles the error seperately (but is against the idea of handling errors in the main component, but might be useful when implementing logging). |
Given these statements I would say that both
Not really. As soon as Please note that re-implementing stream processors so they follow this logic is a separate task #861 because it requires internal state
I would rather try to keep APIs minimal and composable instead. E.g. having only one version of
The problem with this solution is that optional dependencies are not supported - if component needs dependency, it always needs it. At least this is the current situation |
Alright, so we are on the same page, I also change the For-component, to return an error if the handler returns an error and in a later step, errors.Lift will be implemented, so components without an error outport will still be able to be used in For. |
By "stop" I mean omit/discard/delete rather than block |
…error. Adjusted testcases for changed For implementation.
New commit includes the changed For component with error handling. Open Todos:
|
…r new println syntax. Updated documentation with new println syntax.
@emil14 Can you check the documentation on the new commit? |
@@ -8,6 +8,7 @@ import ( | |||
) | |||
|
|||
func Test(t *testing.T) { | |||
t.Skip("Remove this skip, until errors.Lift has been implemented.") |
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.
actually there's no need for lifting here, because println sends err
@@ -3,9 +3,11 @@ import { lists, fmt } | |||
const lst list<bool> = [true, false] | |||
|
|||
def Main(start any) (stop any) { | |||
ListToStream<bool>, For<bool>{PrintAsNum}, Wait | |||
ListToStream<bool>, For<bool>{PrintAsNum}, Wait, Panic |
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.
I've found the reason of deadlock - here PrintAsNum
has outports sig, err
while For
expects res, err
. So println sends to :sig
but nobody reads from there. It's specific case of the #435
Here's the correct implementation:
import { lists, fmt }
const lst list<bool> = [true, false]
def Main(start any) (stop any) {
ListToStream<bool>, For<bool>{PrintAsNum}, Wait, Panic
---
:start -> $lst -> listToStream -> for
for:res -> wait -> :stop
for:err -> panic
}
def PrintAsNum(data bool) (res any, err error) {
println fmt.Println?
---
(:data ? 1 : 0) -> println -> :res
}
Also no need for t.Skip()
for this test
@MDH0 unfortunately you have to merge |
…rintln # Conflicts: # README.md # examples/file_write_all/main.neva # examples/image_png/main.neva
…th_range_and_if test to use errors.Lift. Changed errors_lift test to not print out a number anymore. Adjusted examples and other tests for new println implementation.
I was able to catch deadlock with
It looks very similar to #872 and probably not related to this PR @MDH0 FYI |
Why are the examples compiling now? This is the opposite of 'it works on my system'. |
This will resolve #859.
Added an
err
outport to Println and adjusted the go implementation and tests for that.There is still a problem regarding the For component, because that one doesn't support error handling yet. Should we deal with this yet and if yes, how should we deal with this? Because theoretically (unless I am missing something) we would need an implementation with error handling and an implementation without error handling.
Also another todo is changing the default template and docs for the new Println change.
Another question would be, if we should do the same for Print?