pass-by-ref semantics for structs (was Deque impl.)

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Jan 31 07:21:04 PST 2013


On 1/31/13 10:18 AM, Steven Schveighoffer wrote:
> On Thu, 31 Jan 2013 10:12:53 -0500, Andrei Alexandrescu
>> As far as I can tell classes have the same problem.
>
> Nope.
>
> void foo(someclass aa, int x, int y)
> {
> aa[x] = y;
> }
>
> void main()
> {
> someclass aa;
> foo(aa, 1, 2); // segfault
> ...
> }

We could easily arrange things to segfault just the same with a 
struct-based implementation.

Andrei




More information about the Digitalmars-d mailing list