Taking address of properties

Robert jfanatiker at gmx.at
Thu Feb 7 11:28:16 PST 2013


Good point, but I think that this is pretty much a corner case where it
occasionally might be useful, but it does not rectify the consequences:
The moment you are allowed to take the address, you are stuck with the
ref returning accessor and can not change it later to a get/set pair. 

An easy solution:

	auto a=myrange.front;
	someCFunc(&a);
	myrange.front=a;

It is a little more to write, and maybe a tad slower (depending on the
smartness of the compiler), but we maintain the property guarantees,
which seems to me to be a very valuable goal.


Best regards,

Robert

On Thu, 2013-02-07 at 19:43 +0100, FG wrote:
> Once again. Ref returns are commonly used in ranges.
> I'd say that being able to take address of someRange.front is good for
> example for interoperability with external C libraries.
> Temporarily using a pointer here should be fine.
> 




More information about the Digitalmars-d mailing list