[Issue 481] Letting compiler determine length for fixed-length arrays

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Oct 13 03:44:03 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=481

--- Comment #38 from Shriramana Sharma <samjnaa at gmail.com> ---
Hmmm. I read through the thread starting at
http://forum.dlang.org/post/mag5hp$105a$1@digitalmars.com. I think I sorta see
the point of the developers here.

While I still think [$] is a cool little tidbit, I also have to agree with the
comment which said "let's not add every little tidbit to the language". The
title of the request is "letting compiler determine length for fixed-length
arrays", not specifically to add [$]. Having the compiler determine the length
can be done in many ways, and given that I already have to go to the library
for a lot of commonly used stuff like writeln and to!, this one doesn't seem
too much more. Although it *does* seem like something you should have out of
the box, so do stuff like print()... :-)

The one thing the library solution probably cannot address would be the
convoluted examples like a fixed-size array of a dynamic array of fixed-size
arrays, but let's face it: those are really contrived examples and not worth
introducing a language feature for...

I'm leaving my votes in since I do want *something* to be done to address the
actual request, since any such library solution is ATM still sitting over at
http://dpaste.dzfl.pl/f49a97e35974 and not actually included in Phobos.

BTW I don't think it should be named just 's' in the std.array module, but
something more meaningful, like fixedLengthArray (yikes, yes I know, but I'm
open to suggestions) and one can always do something like:

import std.array: f = fixedLengthArray;

--


More information about the Digitalmars-d-bugs mailing list