I'd much rather fix implicit storage of literals than incur both template bloat
and have to deal with type deduction. Besides the heap allocation issue, the
rewrite that Don put forth already uses the compiler to type deduce the array
types (and therefore the key and value types) without any excessive template
bloat. I'm assuming you meant something like:
SomeRecursiveTemplateToDeduceKeyAndValue!(T) AALiteral(T...)(T vals) if
(vals.length % 2 == 0 && SomeRecursiveTemplateToEnsureKeyAndValueExist!(T))
What I was thinking is making something like:
void foo(scope int[]) {}
not allocate the argument to foo on the heap if it's a literal.
-Steve
----- Original Message -----
> From: Andrei Alexandrescu <[email protected]>
> To: Steve Schveighoffer <[email protected]>; Discuss the internals of DMD
> <[email protected]>
> Cc:
> Sent: Friday, February 3, 2012 6:25 PM
> Subject: Re: [dmd-internals] AssociativeArray in druntime should go before
> the next release
>
> On 2/3/12 2:28 PM, Steve Schveighoffer wrote:
>> What I am saying is, if we go with the lowering of:
>>
>> [a:b, c:d] => AALiteral([a,c], [b,d]);
>>
>> I would like to have this not needlessly allocate the arrays [a, c] and [b,
> d] on the heap, since those arrays will be unused after that call. To use
> the
> heap would be a step backwards, since the current AA literal code does not
> use
> it.
>>
>> -Steve
>
> I think the language is powerful enough to afford us the rewrite:
>
> [a:b, c:d] => aaLiteral(a, b, c, d)
>
>
> Andrei
>
_______________________________________________
dmd-internals mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/dmd-internals