Instantiation of nested structs should be allowed outside their parent scope

Stanislav Blinov stanislav.blinov at gmail.com
Tue Nov 9 16:19:04 UTC 2021


On Tuesday, 9 November 2021 at 16:06:02 UTC, Timon Gehr wrote:
> On 09.11.21 17:04, Stanislav Blinov wrote:
>> On Tuesday, 9 November 2021 at 15:55:14 UTC, Timon Gehr wrote:
>> 
>>> I don't think calling it with `null` is a great idea.
>> 
>> Oh and, of course, this type of compile-time tests aren't 
>> actually calling anything at all anyway.
>
> Presumably you are testing because you want to actually do it 
> later.

No, I am testing because I want to copy things :) Or have ranges 
of them. The NestedThatFails from before. Array of that is not an 
input range, according to Phobos. Because it fails one of the 
checks. Because the compiler is being overly cautious.

Which, again, makes NO sense. Nested struct is, effectively, just 
a family of delegates packed together in one type. There's zero 
reason not to let it be instantiated in some specific cases. Or 
then we have to forbid instantiation of ALL delegates unless 
we're providing context. Thus making delegates at least 50% 
useless.


More information about the Digitalmars-d mailing list