You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The RFC to this point uses the keywords `try`..`catch`, but there are a number of other possibilities, each with different advantages and drawbacks:
279
+
280
+
*`try { ... } catch { ... }`
281
+
282
+
*`try { ... } match { ... }`
283
+
284
+
*`try { ... } handle { ... }`
285
+
286
+
*`catch { ... } match { ... }`
287
+
288
+
*`catch { ... } handle { ... }`
289
+
290
+
*`catch ...` (without braces or a second clause)
291
+
292
+
Among the considerations:
293
+
294
+
* Simplicity. Brevity.
295
+
296
+
* Following precedent from existing, popular languages, and familiarity with respect to analogous constructs in them.
297
+
298
+
* Fidelity to the constructs' actual behavior. For instance, the first clause always catches the "exception"; the second only branches on it.
299
+
300
+
* Consistency with the existing `try!()` macro. If the first clause is called `try`, then `try { }` and `try!()` would have essentially inverse meanings.
301
+
302
+
* Language-level backwards compatibility when adding new keywords. I'm not sure how this could or should be handled.
303
+
304
+
274
305
# Drawbacks
275
306
276
307
* Increases the syntactic surface area of the language.
@@ -291,7 +322,9 @@ Without any attempt at completeness, here are some things which should be true:
291
322
292
323
* Don't.
293
324
294
-
* Only add the `?` operator, but not `try`..`catch`.
325
+
* Only add the `?` operator, but not `try` and `try`..`catch`.
326
+
327
+
* Only add `?` and `try`, but not `try`..`catch`.
295
328
296
329
* Instead of a built-in `try`..`catch` construct, attempt to define one using
297
330
macros. However, this is likely to be awkward because, at least, macros may
@@ -312,10 +345,10 @@ Without any attempt at completeness, here are some things which should be true:
312
345
serious an issue this would actually be in practice, I don't know - there's
313
346
reason to believe that it would be much less of one than in C++.
0 commit comments