== Quote from Steven Schveighoffer ([email protected])'s article > superdan Wrote: > > == Quote from Steven Schveighoffer ([email protected])'s article > > > superdan Wrote: > > > > == Quote from Steven Schveighoffer ([email protected])'s article > > > > > Is there some other reason to use structs besides copy construction? > > > > > -Steve > > > > > > > > memory management n shit. with a struct u can use refcounting n malloc n realloc n > > > > shit. still stays a reference type. nothing gets fucked up. > > > This is not necessary with purely memory-based constructs -- the GC is > > > your > > friend. The custom allocator ability in dcollections should provide plenty > > of > > freedom for memory allocation schemes. > > > > how do u set up yer custom allocator to free memory? u cant tell when its > > ok. > > copying refs iz under da radar. dats my point. > It frees an element's memory when the element is removed from the container. The container itself is managed by the GC. > > > > > > den there's all that null ref shit. with a class u have > > > > > > > > void foo(container!shit poo) > > > > { > > > > poo.addElement(Shit(diarrhea)); > > > > } > > > > > > > > dat works with struct but don't work with motherfucking classes. u need > > > > to write. > > > > > > > > void foo(container!shit poo) > > > > { > > > > if (!poo) poo = new container!shit; // fuck dat shit > > > > poo.addElement(Shit(diarrhea)); > > > > } > > > > > > > > u feel me? > > > It doesn't work. > > > > wut? it don't work? whaddaya mean it dun work? is you crazy? what dun work? > > maybe > > therez sum misundercommunication. > void foo(int[int] x) > { > x[5] = 5; > } > void main() > { > int[int] x; > foo(x); > assert(x[5] == 5); // fails > } > -Steve
wrote a long post but it got lost. shit. bottom line dats a bug in dmd or phobos.
