Structs are Not Plain: A call for empty struct constructors

FeepingCreature feepingcreature at gmail.com
Fri Sep 20 06:33:09 UTC 2019


On Friday, 20 September 2019 at 06:01:00 UTC, Jonathan M Davis 
wrote:
> My point was that you can get the same behavior as
>
> with(Fixture())
> {
> }
>
> right now by using a factory function. The syntax just ends up 
> being a bit more verbose. It was the OP who wanted to actually 
> use with in this manner, and if
>
> with(Fixture.cons())
> {
> }
>
> didn't work, then they could just do something like
>
> auto f = Fixture.cons();
> with(f)
> {
> }
>

For the record, the solution we've settled on as the "best 
compromise" is an external factory function feeding into a 
(generated) constructor. That *seems* to work, since the mocker 
at least is init/copy-safe, and usually none of the fields need 
to *reference* the other fields. But it's still a workaround that 
should not be necessary.


More information about the Digitalmars-d mailing list