Why Strings as Classes?

bearophile bearophileHUGS at lycos.com
Wed Aug 27 11:30:48 PDT 2008


Michiel Helvensteijn:
> In the future it may be possible to do such analysis. If the indexing is in
> a deeper loop, it may weigh more than the insertions you are doing. But
> failing that, the programmer might give the compiler 'hints' on which
> functions he/she wants faster.

For example you can write Deque data structure made with a double linked list of small arrays. During run time it is able to collect few simple statistics of its usage, and it can grow or shrink the length of the arrays according to the cache line length and the patterns of its usage at runtime. There's a boolean constant that at compile time can switch off such collection of statistics, to make the data structure a bit faster but not adaptive. You may want the data structure not adaptive if you know very well what its future usage will be in the program, or in programs that run for few minutes/seconds. In programs that run for hours or days you may prefer a more adaptive data structure.

You can create similar data structures with languages that compile statically, but those operations look fitter when there's a virtual machine (HotSpot for example compiles and uncompiles code dynamically). LLMV looks like being able to be used in both situations :-)

Bye,
bearophile



More information about the Digitalmars-d mailing list