[dmd-concurrency] draft 7

Michel Fortin michel.fortin at michelf.com
Mon Feb 1 14:05:24 PST 2010


Le 2010-02-01 à 16:49, Andrei Alexandrescu a écrit :

> I think swap could be typed as:
> 
> swap(scope ref int[], scope ref int[]);
> 
> The point of scope parameter typechecking is that swap does not save a reference surreptitiously; I think escaping to another scope parameter should be fine (if somewhat conservative).

It's not safe unless the compiler enforcse that all scoped parameters belong to the same owner object. Otherwise you could exchange them between too different objects and unless there is no aliasing they'd now each be owned by two locks!


> In fact I've had this idea for a while now that "ref" should imply "I won't escape it". That would make ref strictly pass-down. Walter is mildly favorable to that idea. I think it's worth giving it a closer look now.

This has some far-reaching consequences: since the 'this' of a struct is a 'ref', you wouldn't be able to take the address of a member.


-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/





More information about the dmd-concurrency mailing list