Email or username:

Password:

Forgot your password?
Top-level
Tristam

@Mara I find it kind of weird that the extended lifetime annotation (i.e. `super`) ends up on the let binding, and not on the temporary whose lifetime will be extended

3 comments
Mara

@swiftcoder Huh? The let binding is for the value that will be lifetime-extended. (It's no longer a "temporary" because it now has a name.)

Tristam

@Mara in that case seems I misunderstood. Super let only extends its own lifetime, not the lifetime of any temporaries nested within expressions?

Mara

@swiftcoder Ah. Well, both?

`super let a = Thing;` makes `a` live as long as the surrounding block. The lifetime that allows the block's final expression to be `&a`, basically.

On top of that, we still have temporary lifetime extension, just like we have in a regular `let`:

`let a = &temp();` makes the temporary life as long as `a`.

Same for `super let a = &temp();`: the temporary will live as long as `a` (which might live longer than it would have in a regular `let`).

Go Up