Send empty assoc array to function

Mike Parker aldacron at gmail.com
Fri Jul 10 04:04:52 UTC 2020


On Friday, 10 July 2020 at 03:59:37 UTC, Mike Parker wrote:
> On Thursday, 9 July 2020 at 21:13:49 UTC, JN wrote:
>
>>
>> Interesting. Often in D discussion, an argument pops up that 
>> the language should be protecting against hidden breakages 
>> from API changes. This would be an example of that happening.
>>
>> void foo(int[int] bar), someone calls it with a null, suddenly 
>> the signature changes to void foo(int* bar) and you will be 
>> sending a null pointer and possibly breaking the app.
>
> Meh. You could say the same about foo(int[]), or 
> foo(SomeClass). AAs are reference types. Reference type 
> instances can be null.

Besides, when it comes to breakage, the discussions I've seen are 
about breaking changes in the language/compiler. There are 
opportunities in most (if not all) programming languages to 
introduce silent breakage when a library maintainer changes a 
public-facing API. And when it happens, that's not the fault of 
the language, but the library maintainer.


More information about the Digitalmars-d-learn mailing list