Possible bug when instantiating template function with nested struct

Alexandru Ermicioi alexandru.ermicioi at gmail.com
Sun Nov 7 13:59:11 UTC 2021


On Sunday, 7 November 2021 at 13:28:16 UTC, Stanislav Blinov 
wrote:
> On Sunday, 7 November 2021 at 12:55:15 UTC, Alexandru Ermicioi 
> wrote:
>> On Sunday, 7 November 2021 at 12:32:17 UTC, Stanislav Blinov 
>> wrote:
>>> On Sunday, 7 November 2021 at 12:02:49 UTC, Alexandru 
>>> Ermicioi wrote:
>>>
>>>> Then compiler would just lower down all T[] expressions to 
>>>> Array!T, and then let druntime implement semantics of the 
>>>> array.
>>>
>>> BetterC?..
>>
>> Are they working properly today though?
>>
>
> No, they don't. And won't until people stop trying to take the 
> compiler's responsibilities away from it.
>
>> Per my understanding these funcs mentioned in this thread are 
>> also in druntime.
>
> Arrays, ostensibly, are first class citizens in D, therefore 
> should be implemented in the language, not a library.

But why does it matter where you put it?

Array operations would still get lowered to some code 
implementing the desired behavior. In the case I've suggested to 
a struct.

This struct could be hard-coded in compiler itself, or put in a 
separate file (not necessarily druntime). It's just more 
flexible, and modular, if it is in some file rather hard-coded in 
compiler itself.

As such I don't think the placement of array behavior, does 
matter to how this behavior is being implemented, be it a couple 
of funcs, or a struct.

The question, is more what are downsides and things preventing at 
doing it as struct, since imho, a struct would perfectly 
represent what array is in d: A grouping of pointer and length, 
with couple of methods to operate upon them.


More information about the Digitalmars-d mailing list