Hello,

Once I finish up my latest pull request, the first non-backwards-compatible steps toward the new lifetime syntax will be in place. I'll try to send a mail for each change that requires modifying source code. Note: since the pull request hasn't landed yet, the changes I describe below are not yet mandatory, but they will still work even now.

In particular:

- you can now use the 'foo lifetime notation, though you don't have to (emacs users, if you update your emacs-mode the syntax highlighter will recognize 'foo. vi users, you're on your own). Once we do a snapshot, the 'foo notation will become mandatory. (Note: within the compiler, you should stick to &foo/Bar and Bar/&foo until we do a snapshot)

- the defaults are changing. First, you can no longer use anonymous lifetime references outside of functions. Second, a type like &'a Foo where Foo contains borrowed pointers used to default to &'a Foo<'a>. You must now write that explicitly, otherwise it defaults to &'a Foo<'b>. That is, the lifetime parameter to Foo used to default to the same lifetime as the enclosing borrowed pointer, if any, but now all omitted lifetimes default to fresh lifetimes.

So more concretely, a type definition like so:

    type MapUint = &fn(uint) -> uint;

should be changed to:

    type MapUint<'self> = &'self fn(uint) -> uint;

The `<'self>` declaration is currently inferred if you leave it off, but I have changes in place to disable that. For now, you *MUST* call the lifetime parameter `'self`. This too will change eventually.

Similarly, a struct definition like:

    struct MyStruct {
        map_fn: MapUint, // same as above
        slice: &[uint]
    }

should be changed to:

    struct MyStruct<'self> {
        map_fn: MapUint<'self>,
        slice: &'self [uint]
    }

As before, for the moment, the `<'self>` definition is currently optional and the lifetime parameter must be called 'self, but this will change.




Niko
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to