[OT] Finding longest documents

Christopher Wright dhasenan at gmail.com
Tue Oct 14 17:19:56 PDT 2008


Christopher Wright wrote:
> Actually, I STRONGLY urge that nobody use this heap.
> 
> It's a struct. If you access it by value and append to it, then access 
> it from any other alias, you will erase a random element from the heap.
> 
> If it were a class, this would not be possible. As I implemented it, it 
> would not be possible.
> 
> Containers as value types is such an idiotic idea for precisely this 
> reason.

Correction: as partial value types. If they were completely value types, 
it'd be stupid for a much different reason -- namely, that they're very 
difficult to resize. But this class of bugs would not be an issue.

D's builtin arrays have the same problem. In their case, the only real 
way around the issue is setting the first sizeof(size_t) bytes to the 
length rather than putting that on the stack.

Any situation in which only part of your state is shared is a potential 
for getting data structures into an erroneous state.



More information about the Digitalmars-d mailing list