The new, new phobos sneak preview

bearophile bearophileHUGS at lycos.com
Wed Apr 8 14:46:59 PDT 2009


Jarrett Billingsley:
> Wow, talk about inefficient.  Consider you have to write out a 100,000
> element array.  What a waste of memory.

There are three parameters to consider here: flexibility, speed, and complexity.

In most situations you don't need speed and flexibility (because you have to print few data and a comma is OK for most printing situations), so I think it's better to minimize complexity.

If you need flexibility but speed isn't necessary, use a generator or list comprehension or a map, plus a join. So the "complexity" is low still because you don't need to learn more syntax.

Then there is the large data case. Often you need to print it with commas, so the default printing is fine.

For the uncommon situation you talk about, where you have both large data and you need flexibility, then write a small for loop with many write() inside.

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

Andrei:
>How about parsing?<

How about using a module of the standard library designed for such simple parsing purposes?

Anyway, do as you like. I'm just thinking aloud here. I'll probably rewrite my dlibs for 2.0 anyway.

Later,
bearophile



More information about the Digitalmars-d mailing list