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

d coder dlang.coder at gmail.com
Thu Jan 31 04:27:08 PST 2013


On Thu, Jan 31, 2013 at 5:30 PM, monarch_dodra <monarchdodra at gmail.com> wrote:
> The pull is kind of stuck in limbo, specifically because of the problems
> associated with implementing reference semantics with structs :/


Thanks for the enlightening email.

I am of the considered view that reference semantics with structs in D
is tough (if not impossible) with default constructor and postblit
constructor (used when passing objects). This is because you can not
initialize any object (wrapped in the struct) in the default
constructor and if you are passing the struct as a function parameter,
it is not possible to initialize these internal objects (before
passing them) in the postblit constructor. I faced this in some of my
code. Do not know if you are facing the same scenario in the DList
implementation.

Are there any possible solutions in the pipe?

Regards
- Puneet


More information about the Digitalmars-d mailing list