A little of coordination for Rosettacode
bearophile
bearophileHUGS at lycos.com
Mon Feb 11 17:07:34 PST 2013
Jos van Uden:
> I have the rcrpg working, but I want to test it some more.
Good. Adding a bit of unittesting is acceptable, I think.
> I'm not very happy
> with the alias function, it accepts just about any input, it
> can put the program in an invalid state.
I presume this is a design bug shared with the original Python
code.
You have also fixed a translation bug of mine with remove(). I
don't like that function. In past I did another mistake (in
another program), forgetting to assign its result back to the
array.
> There was a bug by the way in the Python code, that slowed me
> down a bit.
D static type system asks for more coding work, but it has caught
very quickly that bug of this line of Python code:
tokens[0] = aliases[tokens[0]]
Dynamic typing has some advantages and in some cases it's handy,
but it has some disadvantages too. On the other hand I think that
Python code was not well tested; Python unittesting is able to
catch most of similar bugs.
I think we should fix the Python entry too (or at least add a
note in the Talk page).
> As for the "getattr", I've hacked a CTFE loop together that
> writes out if statements. I'm not sure how robust it is.
I think in normal D code you don't catch Throwable, but maybe in
this case it's OK.
> http://dpaste.dzfl.pl/5e6b824e
The D code has lot of imports because Python has a ton of
built-in things.
I have shortened the lines to about 72 chars max, and reformatted
the code a bit. If you like it and you have a Rosettacode
account, you can put it there yourself (otherwise I'll do it
myself). If later you find bugs or you want to change something,
there's always the possibility to modify it on the site.
http://dpaste.dzfl.pl/6778053f
In practice at the moment I am maintaining all the D entries of
Rosettacode. I keep the coding style uniform, but sometimes I
change some parts of such style on purpose to show different ways
to use D, or specific things. Several Rosettacode solutions have
more than one D entry, like when there is a very short and
high-level entry and a longer and low level entry that's faster.
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list