Thanks for pointing out these issues!

On Sat, Jun 22, 2013 at 9:26 AM, Ashish Myles <marci...@gmail.com> wrote:
> POSSIBLE ERRATA:
>
> Slide 40:
>   The notes say "Change [@Drawable] to [~@Drawable]". The latter should be
>   ~[@Drawable], or, to be consistent with the Slide 41, perhaps
>   &[@Drawable]? Both tested to work.
>

Typo, I'm about to upload a fixed copy.

> Slide 51:
>   The program seems to be missing a unique pointer sigil ~; and the types of
>   the array and the initializer ("quux") don't match. Here is a possible
>   correction? (Tested.)
>
>   fn h(b: ~[int]) { }
>   fn g(a: ~[int]) { }
>   fn f(n: uint) {
>       let v: ~[int] = vec::from_elem(n,1);
>       h(v);
>       g(v);
>   }

Ditto.

>
> Slide 53:
>   Perhaps the audio is needed for this slide, but I am confused. Before I
>   start with that, I checked
>     struct Cat {
>         a : int,
>     }
>     fn main() {
>         let v: Cat::new();
>     }
>   It seems that there is no default new() function, so I don't know the
>   type of the object returned by Cat::new(). Is it Cat or ~Cat here?
>
>   The comment about Cat not being copyable seems to imply that the type is
>   Cat (i.e. stack-allocated). But then send_cat_to_moon(cat) should not be
>   able to invalidate the reference, right? So there should not be a problem
>   with that code as webcam should get destructed before cat at the end of
>   the block.
>
>   If Cat::new() returns ~Cat and Webcam::new() returns ~Webcam, then I can
>   see this working out, but then there is the implicit assumption (that
>   could perhaps be clarified in the comments) that send_cat_to_moon(cat)
>   takes its argument as ~Cat rather than, say, &Cat.

Since this example was just meant to illustrate a potential problem,
there are several things about it that aren't valid Rust. I tried to
add more comments in the note beneath the slide explaining that. The
definitions of the constructors/static methods for WebCam and Cat are
omitted, and presumably Cat has some fields that I left out because
they're not needed for understanding the problem. In particular, Cat
could have fields that are non-copyable, even if its constructor
returns a Cat (and not a ~Cat).

Thanks for your interest!

Tim


-- 
Tim Chevalier * http://catamorphism.org/ * Often in error, never in doubt
"Not a riot, it's a rebellion." -- Boots Riley
"Attention Bros and Trolls: When I call out your spew, I'm not angry,
I'm defiant." -- Reg Braithwaite
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to