Re:Scopes – Retargetable programming language and infrastruc...
by giornogiovanna on Monday May 06, 2019 @03:36AM
(#19837505)
But how would you distinguish between
struct A<'a, 'b>(&'a u8, &'b u8);
and
struct B<'a>(&'a u8, &'a u8);
without lifetime annotations?
Re:Scopes – Retargetable programming language and infrastruc...
by sanxiyn on Monday May 06, 2019 @08:03AM
(#19838590)
You can always assume the former(all lifetimes are different). It is strictly more general.
Re:Scopes – Retargetable programming language and infrastruc...
by giornogiovanna on Monday May 06, 2019 @11:33AM
(#19840333)
Thanks, so lifetimes can definitely be inferred for safe code (although just like type inference, they can lead to leaky abstractions). But aren't lifetime annotations necessary for unsafe code? How could you cast a pointer into a struct into a raw pointer and back, while preserving the lifetime, without them?
I couldn't find anything more about "view propagation" either but I strongly suspect it's no more powerful. Probably less and/or buggier at this point, given its relative maturity.