Re: [heycam/webidl] Make [SameObject] beneficial (#212)

Yeah, so what Gecko has is:

* `[Cached]` to indicate that autogenerated caching should happen.  In addition to that, attributes marked `[Cached]` are allowed to have sequence, dictionary, and record types, because the reason for not allowing attributes with those types (creation of a new object on each get) does not apply in the `[Cached]` case.  Also, we check that `[NewObject]` and `[Cached]` are not used together, because that's nonsensical.
* `[SameObject]` as defined in the spec, but with the additional implication that there are no side-effects from the get.
* `[Constant]` which is just like `[SameObject]` but without type restrictions, so you can use it on any return type.  Again, implies no side-effects from the get.
* `[Pure]` which promises no side-effects but not constancy of return value.  That said, two consecutive calls to a `[Pure]` thing _will_ return the same value each time (because the first call can't affect the return value of the second call: see no side-effects), so `[Cached]` is allowed on `[Pure]` things, not just `[Constant]`/`[SameObject]` ones.  There's a way to invalidate the cache if something that does have side-effects changes the value involved.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/212#issuecomment-505215677

Received on Monday, 24 June 2019 23:14:58 UTC