Safer exceptions #11721
Safer exceptions #11721
Conversation
Introduce a flexible scheme for declaring and checking exceptions that can be thrown. It relies on the _effects as implicit capabilities_ pattern. The scheme is not 100% safe yet since it does not track and prevent capability capture. Nevertheless, it's already useful for declaring thrown exceptions and finding mismatches between provided and required capabilities.
4c2ceb6
to
0cbaa03
0cbaa03
to
b65958f
0228129
to
fe446b4
Actually, no. The rules for context function types make them mutually compatible. I am not yet sure about unions, whether there is a way to obtain them. But since we do have commutativity, maybe they are not needed. |
648c880
to
c02fb16
c02fb16
to
1c353ab
| @@ -680,6 +680,8 @@ object Build { | |||
| "-sourcepath", (sourceDirectories in Compile).value.map(_.getAbsolutePath).distinct.mkString(File.pathSeparator), | |||
| // support declaration of scala.compiletime.erasedValue | |||
| "-Yerased-terms" | |||
| // TODO: drop after bootstrap with erasure language import | |||
| // scala.compile now contains the roght language import so no global setting is needed | |||
mr-git
Mar 15, 2021
maybe:
.. the right language ..
?
maybe:
.. the right language ..
?
| import language.experimental.erasedTerms | ||
| import annotation.implicitNotFound | ||
|
|
||
| /** A ability class that allows to throw exception `E`. When used with the |
mr-git
Mar 15, 2021
•
/** AN ability ..
though, in other places it is referenced as "A capability"..
/** AN ability ..
though, in other places it is referenced as "A capability"..
|
Would it be possible for a user to implement something like this, without needing casts or other hacks? object Try:
def apply[E, A](body: CanThrow[E] ?=> A): Try[A] =
try
Success(body)
catch
case NonFatal(ex) => Failure(ex) |
|
I would like to suggest, to consider rename |
Introduce a flexible scheme for declaring and checking which exceptions can be thrown.
It relies on the effects as implicit capabilities pattern.
The scheme is not 100% safe yet since it does not track and prevent capability capture.
Nevertheless, it's already useful for declaring thrown exceptions and finding mismatches
between provided and required capabilities.
Link to Doc page
Everything is enabled under
Based on #11695