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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Dec 3 05:29:55 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=481


Bruno Medeiros <bdom.pub+deebugz at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bdom.pub+deebugz at gmail.com


--- Comment #3 from Bruno Medeiros <bdom.pub+deebugz at gmail.com> 2010-12-03 05:28:18 PST ---
(In reply to comment #1)
> This enhancement's importance is raised by the fact that array literals have
> dynamic length by default, so simply writing
> 
> auto a = [1,2,3,4];
> 
> won't make a of type int[4].
> 
> I think using "[$]" is the most sensible option. 

I don't quite get this argument. If you have a syntax such as "[$]" (I assume
you are referring to Bill's example of "int[$] arr"), then obviously
  auto a = [1,2,3,4];
still won't make a of type int[4]... 

The only way to use auto (in it current form) to declare a static array would
be to have a syntax for a static array literal. Or to have a template and/or
function to create the static array value. Isn't this latter alternative
preferable? A bit more verbose, but no language changes should be necessary.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list