Skip to content

Commit 8ad3e20

Browse files
committed
Replace 'event' with 'tag' in explainer
It was suggested to change the term 'event' to 'tag' to reference the section name and the entries within the section. The suggested reasons were they can be used something other than events in future, and the term event can be confusing with other concepts on the web. Closes WebAssembly#159.
1 parent f489a73 commit 8ad3e20

File tree

1 file changed

+28
-36
lines changed

1 file changed

+28
-36
lines changed

proposals/exception-handling/Exceptions.md

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ instruction. Thrown exceptions are handled as follows:
4545
1. If the call stack is exhausted without any enclosing try blocks, the embedder
4646
defines how to handle the uncaught exception.
4747

48-
### Event handling
48+
### Exception handling
4949

5050
This proposal adds exception handling to WebAssembly. Part of this proposal is
5151
to define a new section to declare exceptions. However, rather than limiting
5252
this new section to just defining exceptions, it defines a more general format
53-
that allows the declaration of other forms of events.
53+
that allows the declaration of other forms of events in future.
5454

5555
In general, an event handler allows one to process an event generated by a block
5656
of code. Events suspend the current execution and look for a corresponding event
@@ -62,22 +62,21 @@ Exceptions are a special case of an event in that they never resume. Similarly,
6262
a `throw` instruction is the suspending event of an exception. The catch block
6363
associated with a try block defines how to handle the throw.
6464

65-
WebAssembly events (i.e. exceptions) are defined by a new `event` section of a
66-
WebAssembly module. The event section is a list of declared events associated
67-
with the module.
65+
WebAssembly exceptions tags are defined in a new `tag` section of a WebAssembly
66+
module. The tag section is a list of declared tags associated with the module.
6867

69-
Each event has an `attribute` and a `type`. Currently, the attribute can only
70-
specify that the event is an exception. In the future, additional attribute
68+
Each tag has an `attribute` and a `type`. Currently, the attribute can only
69+
specify that the tag is for an exception. In the future, additional attribute
7170
values may be added when other events are added to WebAssembly.
7271

7372
To allow for such a future extension possibility, we reserve a byte in the
7473
binary format of an exception definition, set to 0 to denote an exception
75-
attribute, but for the moment we won't use the term event in the formal spec.
74+
attribute.
7675

7776
### Exceptions
7877

7978
An `exception` is an internal construct in WebAssembly. WebAssembly exceptions
80-
are defined in the event and import sections of a module.
79+
are defined in the tag and import sections of a module.
8180

8281
The type of an exception is denoted by an index to a function signature defined
8382
in the `type` section. The parameters of the function signature define the list
@@ -418,28 +417,21 @@ Each exception type has the fields:
418417
A single-byte unsigned integer indicating the kind of definition being imported
419418
or defined:
420419

421-
* `0` indicating a `Function` [import](Modules.md#imports) or
422-
[definition](Modules.md#function-and-code-sections)
423-
* `1` indicating a `Table` [import](Modules.md#imports) or
424-
[definition](Modules.md#table-section)
425-
* `2` indicating a `Memory` [import](Modules.md#imports) or
426-
[definition](Modules.md#linear-memory-section)
427-
* `3` indicating a `Global` [import](Modules.md#imports) or
428-
[definition](Modules.md#global-section)
429-
* `4` indicating an `Event` [import](#import-section) or
430-
[definition](#event-section)
420+
* `4` indicating a `Tag`
421+
[import](https://github.com/WebAssembly/design/blob/main/BinaryEncoding.md#import-section) or
422+
[definition](#tag-section)
431423

432424
### Module structure
433425

434426
#### High-level structure
435427

436-
A new `event` section is introduced and is named `event`. If included, it must
437-
appear immediately after the memory section.
428+
A new `tag` section is introduced. If included, it must appear immediately after
429+
the memory section.
438430

439-
##### Exception section
431+
##### Tag section
440432

441-
The `event` section is the named section 'exception'. For ease of validation,
442-
this section comes after the [memory
433+
The `tag` section is the named section 'tag'. For ease of validation, this
434+
section comes after the [memory
443435
section](https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#memory-section)
444436
and before the [global
445437
section](https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#global-section).
@@ -452,42 +444,42 @@ So the list of all sections will be:
452444
| Function | `3` | Function declarations |
453445
| Table | `4` | Indirect function table and other tables |
454446
| Memory | `5` | Memory attributes |
455-
| Event | `13` | Event declarations |
447+
| Tag | `13` | Tag declarations |
456448
| Global | `6` | Global declarations |
457449
| Export | `7` | Exports |
458450
| Start | `8` | Start function declaration |
459451
| Element | `9` | Elements section |
460452
| Code | `10` | Function bodies (code) |
461453
| Data | `11` | Data segments |
462454

463-
The event section declares a list of event types as follows:
455+
The tag section declares a list of tag types as follows:
464456

465457
| Field | Type | Description |
466458
|-------|------|-------------|
467-
| count | `varuint32` | count of the number of event to follow |
468-
| type | `event_type*` | The definitions of the event types |
459+
| count | `varuint32` | count of the number of tags to follow |
460+
| type | `tag_type*` | The definitions of the tag types |
469461

470462
##### Import section
471463

472464
The import section is extended to include exception definitions by extending an
473465
`import_entry` as follows:
474466

475-
If the `kind` is `Event`:
467+
If the `kind` is `Tag`:
476468

477469
| Field | Type | Description |
478470
|-------|------|-------------|
479-
| `type` | `event_type` | the event being imported |
471+
| `type` | `tag_type` | the tag being imported |
480472

481473
##### Export section
482474

483475
The export section is extended to reference exception types by extending an
484476
`export_entry` as follows:
485477

486-
If the `kind` is `Event`:
478+
If the `kind` is `Tag`:
487479

488480
| Field | Type | Description |
489481
|-------|------|-------------|
490-
| `index` | `varuint32` | the index into the corresponding event index space |
482+
| `index` | `varuint32` | the index into the corresponding exception index space |
491483

492484
##### Name section
493485

@@ -498,12 +490,12 @@ follows:
498490
| --------- | ---- | ----------- |
499491
| [Function](#function-names) | `1` | Assigns names to functions |
500492
| [Local](#local-names) | `2` | Assigns names to locals in functions |
501-
| [Event](#event-names) | `3` | Assigns names to event types |
493+
| [Tag](#tag-names) | `3` | Assigns names to tag types |
502494

503-
###### Event names
495+
###### Tag names
504496

505-
The event names subsection is a `name_map` which assigns names to a subset of
506-
the exception indices (Used for both imports and module-defined).
497+
The tag names subsection is a `name_map` which assigns names to a subset of
498+
the tag indices (Used for both imports and module-defined).
507499

508500
### Control flow operators
509501

0 commit comments

Comments
 (0)