Hashing and imports

bearophile bearophileHUGS at lycos.com
Wed Mar 19 15:12:07 PDT 2008


While creating an AA with a static char array as key, I have seen that to make it work I have to put it inside a struct, because static arrays don't seem to have an hash function defined. I think this is a hole that deserves to be filled.

---------------

Time ago I have read that the computer language of the future may be what today we write in the code comments. In my code I often write:

import std.conv: toInt; // for foobar()

It means that toInt() will be used only inside the foobar function of the current module. Generally it's positive to put a name into the most tight enclosing scope, to avoid name clashes, cluttering the namespace. And it's positive to use a name, like toInt, as closer as possible where you define/import it. So I think it may be positive to put imports inside functions too (the only difference is that the imported names are visibile only in that function/method). A possible problem: I don't know where/when to execute the static this {} of a module imported into a function. If this becomes a problem, then a solution is just to allow importing modules without static this {} inside functions.

Bye,
bearophile



More information about the Digitalmars-d mailing list