Skip to content

Commit cf66dbe

Browse files
committed
Minor tweaks
1 parent 71ffeb7 commit cf66dbe

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

text/000-structural-and-deref.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ rules:
9696
`Deref<Target=JsValue>`.
9797
* Otherwise, the *first* `extends` attribute is used to implement
9898
`Deref<Target=ListedType>`.
99+
* (long term, currently require a breaking change) reject multiple `extends`
100+
attributes, requiring there's only one.
99101

100102
This means that `web-sys` may need to be updated to ensure that the immediate
101103
superclass is listed first in `extends`. Manual bindings will continue to work
@@ -236,9 +238,9 @@ classes are passed child classes which override methods**.
236238

237239
An easy solution to this problem is to simply use `structural` everywhere, so...
238240
let's propose that! Consequently, this RFC proposes changing `#[wasm_bindgen]`
239-
to act as if all bindings are labeled as `structural`. This will not be a
240-
breaking change because the generated bindings will still have the same behavior
241-
as before, they'll just handle subclassing correctly!
241+
to act as if all bindings are labeled as `structural`. While technically a
242+
breaking change it's believed that we don't have any usage which would actually
243+
run into the breakage here.
242244

243245
### Adding `#[wasm_bindgen(final)]`
244246

@@ -276,7 +278,7 @@ As an example, today for `#[wasm_bindgen(method)] fn parent(this: &Parent);` we
276278
generate JS that looks like:
277279

278280
```rust
279-
#[wasm_bindgen(method, structural)]
281+
#[wasm_bindgen(method)]
280282
fn method(this: &Parent);
281283
```
282284

@@ -309,17 +311,17 @@ first parameter as `this`, meaning we can transform this to:
309311
export const __wasm_bindgen_Parent_method = Parent.prototype.method;
310312
```
311313

312-
and *voila*, no JS shims necessary! With `structural` we'll still need a shim in
313-
this future world:
314+
and *voila*, no JS function shims necessary! With `structural` we'll still need
315+
a function shim in this future world:
314316

315317
```js
316318
export const __wasm_bindgen_Parent_method = function() { this.method(); };
317319
```
318320

319321
Alright, with some of those basics out of the way, let's get back to
320322
why-`final`-by-default. The promise of [host bindings] is that by eliminating
321-
all these JS shims necessary we can be faster than we would otherwise be,
322-
providing a feeling that `final` is faster than `structural`. This future,
323+
all these JS function shims necessary we can be faster than we would otherwise
324+
be, providing a feeling that `final` is faster than `structural`. This future,
323325
however, relies on a number of unimplemented features in wasm engines today.
324326
Let's consequently get an idea of what the performance looks like today!
325327

0 commit comments

Comments
 (0)