foo!(bar) ==> foo{bar} ==> foo[bar] (just Brackets)

Jarrett Billingsley jarrett.billingsley at gmail.com
Fri Oct 17 18:53:30 PDT 2008


On Fri, Oct 17, 2008 at 7:45 PM, Benji Smith <dlanguage at benjismith.net> wrote:

> Actually, with Andrei's "Array" template introducing template syntax for
> arrays, I think there could be a convincing argument that all arrays
> (associative or otherwise) would benefit from a template-like declaration.
>
> After all, a standard garden-variety array is actually very much like a
> type-specialized "sequence" container.
>
> Templates like these could entirely replace the builtin array types, and I
> think everyone, from beginner to pro, would be comfortable with the syntax:
>
>  // Maybe make the names explicit...
>  auto a = DynamicArray[int];
>  auto b = StaticArray[int, 3];
>
>  // Or the name could be the same, with the template arguments
>  // determining the static/dynamic implementation...
>  auto c = Array[int];
>  auto d = Array[int, 3];
>
>  // Syntax between arrays, standard containers, and library
>  // containers would be syntactically similar. Very nice.
>  auto e = AssociativeArray[int, double];
>  auto f = HashMap[int, double];
>  auto g = PriorityQueue[double];
>
> I actually think it's a very nice, totally workable idea.

I hate to change sides, but the more I look at this template syntax
the more I like it...



More information about the Digitalmars-d mailing list