DMDScript now under Boost license

Adam Ruppe destructionator at gmail.com
Tue Mar 30 15:21:49 PDT 2010


On 3/29/10, Robert Clipsham <robert at octarineparrot.com> wrote:
> I seem to recall it is, and a fairly old D1 at that... You could always
> update it and send a patch Walter's way, see if he accepts it :)

Walter seems to have fixed it up the the new D1; it compiled there.

And I just spent the day making a port to D2. There's a few WTFs in
there though, which I hacked around.

Here it is:
http://arsdnet.net/dcode/dmdscript_d2.zip

First, once each in dobject.d and script.d, I casted away a const.
grep for FIXME.

Second, and this is the big one: the assocative array implementation
in there seems to have broken entirely with the switch to D2. Look for
"BIG HACK" in property.d - I had to do this two times:

	assert(key !is null);
	p = *key in table;

	// BIG HACK! in seems broken!
        if(p is null)
	foreach(k,ref v; table) {
		if(k.toString() == key.toString()) {
			p = &v; // WTF
			break;
		}
	}

Previously, it used a custom AA implementation, similar to the one in
Phobos, but not quite the same. It cached the hashes for boosted
speed.

In phobos2, the AA implementation is completely different. This first
manifested itself as linker errors on foreach statements (fix it by
compiling as:

dmd -oftest *.d

instead of using the makefile). Then, I noticed obvious things were failing.

After spending a few hours on it, I decided to just give up and use
the above hack. I still don't understand why it is happening that way.
(I thought const correctness would be the hard thing, but aside from
the two casts, it was fairly easy. The stupid AA has been the real
problem!)



But, anyway, it now works on some simple scripts, and the asserts in
there all work, so I think it is working correctly.

Now, with it compiling as D2, the next step will be making the wrapper
template I mentioned yesterday. I don't have time to do it today
though.

On the bright side, I know the code a bit better now than I ever did
before, so maybe I can make this template better than I thought! We'll
see.


More information about the Digitalmars-d-announce mailing list