Should we remove int[$] before 2.067?
Kapps via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jan 30 21:07:33 PST 2015
On Friday, 30 January 2015 at 19:07:53 UTC, Andrei Alexandrescu
wrote:
>
> The interesting thing is because of the tight overloading
> rules, "s" will only match statically-sized arrays. So it's
> okay to simply expose it as std.array.s without fear it might
> clash with other uses of the "s" symbol. Awesome. -- Andrei
With a library method of [1, 2, 3].s, or syntax of [1, 2, 3]s,
would this proposed $ syntax really provide any benefit? Since
you could already use 'auto a = [1, 2, 3]' for size inference, I
don't really see a strong benefit over 'int[$] a = [1, 2, 3]'
with the exception that you could specify the type in the latter.
More so, I think having .s is a much better alternative if
there's no substantial advantage to $, because it can also be
used as an expression for purposes such as making function calls
with a static array.
Example:
auto foo = Variant([1, 2, 3].s)
rather than
auto foo = Variant(cast(int[$])[1, 2, 3])
More information about the Digitalmars-d
mailing list