Which language constructs could be done as a library if we accept some breaking changes?

Alexandru Ermicioi alexandru.ermicioi at gmail.com
Mon Nov 29 14:03:20 UTC 2021


On Monday, 29 November 2021 at 13:51:30 UTC, Paul Backus wrote:
> On Monday, 29 November 2021 at 13:11:47 UTC, Alexandru Ermicioi 
> wrote:
>> But isn't a slice basically a struct with pointer and length?
>> Therefore you can consider that a slice is never null, but 
>> rather internal ptr field is, while length is 0.
>> The assoc array could follow same logic, i.e. point to null 
>> node.
>>
>> any ops could then be implemented in terms of operator 
>> overloading.
>
> You can't overload operators for built-in types, like pointers. 
> So if you do it this way, you would no longer be able to write 
> `ptr[start .. end]`--instead, you'd have to write something 
> like `ptr.slice(start, end)`.

Sorry, kinda hard to remember that this is thread based 
conversation. I was talking in context where frontend does lower 
down built-in types to struct implementations of said builtin 
types.


More information about the Digitalmars-d mailing list