-
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
IO capability & compiler plugin #140
Conversation
…va methods throwing IOException
doc/io.md
Outdated
[application errors](basics/error-handling.md)) | ||
|
||
Quite importantly, the **absence** of `using IO` specifies that the method has **no** I/O side effects (however, it | ||
might still block the thread, e.g. when using a channel, or have other side effects, such as throwing exceptions). |
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.
or have other side effects, such as throwing exceptions
or interact with randomness and system time?
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.
yes, I don't think that would count as IO :)
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 was thinking if it's worth mentioning here as 'other side effects'.
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.
ah yes, good idea :)
application (e.g. in the `main` method), or when integrating with third-party libraries. Otherwise, the capability | ||
should be passed as an implicit parameter. Such an ideal scenario might not possible, but there's still value in `IO` | ||
tracking: by looking up the usages of `IO.unsafe` it's possible to quickly find the "roots" where the `IO` capability | ||
is introduced. For example: |
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.
Are there cases when it won't be in some kind of main method which puts together all the modules?
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 was thinking e.g. of callbacks when integrating with reactive-streams or such?
doc/io.md
Outdated
## The requireIO compiler plugin | ||
|
||
Ox provides a compiler plugin, which verifies at compile-time that the `IO` capability is present when invoking any | ||
methods from the JDK or Java libraries that specify to throw an `java.io.IOException`. |
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.
Did you consider including java.sql.SQLException
? JDBC methods throw it instead of IOException
for communication errors, and it's part of the JDK. On the other hand, users probably interact with libraries that, even if wrapping JDBC, don't necessarily throw raw SQLException
. I saw some signs of this happening here and there in ScalikeJDBC, but that may not be enough to justify the idea :)
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.
Yeah good idea, the list is already extensible, we could easily provide a good default.
# Conflicts: # core/src/main/scala/ox/channels/SourceCompanionIOOps.scala # core/src/test/scala/ox/channels/SourceCompanionIOOpsTest.scala # core/src/test/scala/ox/channels/SourceIOOpsTest.scala # doc/channels/io.md
No description provided.