This repository has been archived by the owner on Dec 31, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
proposal.html
99 lines (86 loc) · 3.85 KB
/
proposal.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!doctype html>
<meta charset="utf8">
<link rel="shortcut icon" href="https://tc39.github.io/ecma262/img/favicon.ico" />
<pre class=metadata>
title: Optional catch binding
status: proposal
stage: 4
contributors: Michael Ficarra
location: https://github.com/michaelficarra/optional-catch-binding-proposal
</pre>
<emu-intro id="sec-introduction">
<h1>Introduction</h1>
<h2>Goals</h2>
<ul>
<li>Allow developers to use try/catch without creating an unused binding
</ul>
</emu-intro>
<!-- es6num="13.15" -->
<emu-clause id="sec-try-statement">
<h1>The `try` Statement</h1>
<h2>Syntax</h2>
<del class="block">
<emu-grammar>
TryStatement[Yield, Await, Return] :
`try` Block[?Yield, ?Await, ?Return] Catch[?Yield, ?Await, ?Return]
`try` Block[?Yield, ?Await, ?Return] Finally[?Yield, ?Await, ?Return]
`try` Block[?Yield, ?Await, ?Return] Catch[?Yield, ?Await, ?Return] Finally[?Yield, ?Await, ?Return]
Catch[Yield, Await, Return] :
`catch` `(` CatchParameter[?Yield, ?Await] `)` Block[?Yield, ?Await, ?Return]
Finally[Yield, Await, Return] :
`finally` Block[?Yield, ?Await, ?Return]
CatchParameter[Yield, Await] :
BindingIdentifier[?Yield, ?Await]
BindingPattern[?Yield, ?Await]
</emu-grammar>
</del>
<ins class="block">
<emu-grammar>
TryStatement[Yield, Await, Return] :
`try` Block[?Yield, ?Await, ?Return] Catch[?Yield, ?Await, ?Return]
`try` Block[?Yield, ?Await, ?Return] Finally[?Yield, ?Await, ?Return]
`try` Block[?Yield, ?Await, ?Return] Catch[?Yield, ?Await, ?Return] Finally[?Yield, ?Await, ?Return]
Catch[Yield, Await, Return] :
`catch` `(` CatchParameter[?Yield, ?Await] `)` Block[?Yield, ?Await, ?Return]
`catch` Block[?Yield, ?Await, ?Return]
Finally[Yield, Await, Return] :
`finally` Block[?Yield, ?Await, ?Return]
CatchParameter[Yield, Await] :
BindingIdentifier[?Yield, ?Await]
BindingPattern[?Yield, ?Await]
</emu-grammar>
</ins>
<emu-note>
<p>The `try` statement encloses a block of code in which an exceptional condition can occur, such as a runtime error or a `throw` statement. The `catch` clause provides the exception-handling code. When a catch clause catches an exception, its |CatchParameter| is bound to that exception.</p>
</emu-note>
<!-- es6num="13.15.7" -->
<emu-clause id="sec-runtime-semantics-catchclauseevaluation">
<h1>Runtime Semantics: CatchClauseEvaluation</h1>
<p>With parameter _thrownValue_.</p>
<emu-grammar>Catch : `catch` `(` CatchParameter `)` Block</emu-grammar>
<emu-alg>
1. Let _oldEnv_ be the running execution context's LexicalEnvironment.
1. Let _catchEnv_ be NewDeclarativeEnvironment(_oldEnv_).
1. Let _catchEnvRec_ be _catchEnv_'s EnvironmentRecord.
1. For each element _argName_ of the BoundNames of |CatchParameter|, do
1. Perform ! _catchEnvRec_.CreateMutableBinding(_argName_, *false*).
1. Set the running execution context's LexicalEnvironment to _catchEnv_.
1. Let _status_ be the result of performing BindingInitialization for |CatchParameter| passing _thrownValue_ and _catchEnv_ as arguments.
1. If _status_ is an abrupt completion, then
1. Set the running execution context's LexicalEnvironment to _oldEnv_.
1. Return Completion(_status_).
1. Let _B_ be the result of evaluating |Block|.
1. Set the running execution context's LexicalEnvironment to _oldEnv_.
1. Return Completion(_B_).
</emu-alg>
<ins class="block">
<emu-grammar>Catch : `catch` Block</emu-grammar>
<emu-alg>
1. Return the result of evaluating |Block|.
</emu-alg>
</ins>
<emu-note>
<p>No matter how control leaves the |Block| the LexicalEnvironment is always restored to its former state.</p>
</emu-note>
</emu-clause>
</emu-clause>