Linker error
Anonymous via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jun 5 13:59:16 PDT 2016
On Sunday, 5 June 2016 at 20:16:54 UTC, Andrej Mitrovic wrote:
> On 6/5/16, Anonymous via Digitalmars-d-learn
> <digitalmars-d-learn at puremagic.com> wrote:
>> static Note[0] empty;
>>
>> Note[] getNotes(string id)
>> {
>> return (id in store) ? store[id] : empty;
>> }
>
> It's likely an accepts-invalid bug, meaning it should be a
> compiler error instead. I don't think it makes sense that the
> compiler tries to slice a fixed-length array of length zero..
> tho perhaps it should just equate that to returning null.
>
> In any case you can return `null` instead of "empty".
> Fixed-length arrays of length zero aren't really all that
> well-defined. Some would say they make no sense, but there is a
> weird benefit to them when used with the built-in hashmaps (a
> void[0] value type wouldn't allocate memory, AFAIR and if that
> is still true).
Should I report this as a dmd bug then? Not sure where / how to
do that.
I think I'll just let it go; I was able to work passed it anyway
using "static Note[] empty;", and `null` works too. Is either one
better?
By the way, this is from an example I found in "D Web
Development" by Kai Nacke.
More information about the Digitalmars-d-learn
mailing list