On 15.03.2012 21:22, H. S. Teoh wrote:
On Thu, Mar 15, 2012 at 05:02:06PM +0100, Don Clugston wrote:
On 15/03/12 00:16, H. S. Teoh wrote:
[...]
This is good, and very, very important. Do *not* make any attempt at
compiler integration until it is *completely* ready.
This includes AA literals. They need to be accepted somehow. The
compiler will give you syntax sugar and *nothing* more.
How does the compiler currently work with AA literals? I see two
functions in aaA.d for constructing AA's from literals. Which one is the
one actually being used?
One possibility might be to accept a pair of array literals,
representing keys and values.
OK. This shouldn't be hard to do. I'll take a stab at it.
Possibly it should call a CTFE function to convert them into some
other form?
This is one major area that I forgot to mention, and that is, making AA
literals work at compile-time. Currently things like this don't work:
enum myAA = ["abc":123, "def":456];
I'd like to make that work. That would require compile-time construction
of the AA and storing it in some form that the compiler can put into the
object file.
What's wrong with AA structure itself, it's link-pointer based?
At any rate, I stored complex structs as immutable, though links were
index-based.
I'm thinking of something along the lines of using mixins
to generate explicit instances of Slot structs, so the above would
translate to something like:
Impl __myAA_literal_impl = Impl(__myAA_literal_slots[0..$], 2);
Slot[4] __myAA_literal_slots = [
// The exact order in here will depend on precise hash
// values, which will need to be somehow computed by
// CTFE. Is that even remotely possible right now??
null,
&__myAA_literal_slot1,
null,
&__myAA_literal_slot2
];
Slot __myAA_literal_slot1 = Slot(null, /*hash value*/, "abc", 123);
Slot __myAA_literal_slot2 = Slot(null, /*hash value*/, "def", 456);
enum myAA = AssociativeArray!(string,int)(&__myAA_literal_impl);
Would something like this be workable? Is it even possible to compute
the necessary hashes at compile-time?
T
--
Dmitry Olshansky