> > fn f<'l>(x : & 'l int, y : & 'l int) -> & 'l int {
> > 
> >      x
> > 
> > }
> 
> This case would be written, with the same meaning, as:
> 
> fn f(x : &int, y : &int) -> &int {
>      x
> }
> ...
> > 
> > (This fails, but giving parameter y an independent lifetime makes it
> > succeed.)
> And would fail for the same reason. We would want to write, in the new
> proposal:
> 
> fn f(x : &int, y : &'int) -> &int {
>      x
> }

Yes, that's what I thought. Doesn't it make it too easy to write broken 
functions? On second thought, the broken functions are not dangerous and are 
easy to correct, so it might be worth the trade off.

Kind-of sucks that new developers have think about things like variable 
lifetime with your changes (actually, even when no reference is returned, in 
your proposal). With the current syntax it isn't necessary per-se (in some 
cases a copy could be made instead of returning a reference).

Best leave to Rust devs to comment further (I'm also new on the list).
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to