just a few small questions

Chris Nicholson-Sauls ibisbasenji at gmail.com
Tue Apr 18 17:09:15 PDT 2006


MM wrote:
>>I think you are best off using the heap for your large global array. 
>>Data placed on the heap stays there until you explicitly delete it, so 
>>you don't have to use a global. Heap is also what you use if you have 
>>any sort of dynamic memory needs, you can allocate what you need when 
>>you need it. If you use new/delete to much, the heap may become 
>>segmented and then the garbage collector will run (I think). The heap is 
>>unlimited for the most part, while you can only allocate so much data 
>>onto the stack. The heap might be slower to access, but not enough to be 
>>a significant problem.
>>
>>Maybe an expert can vindicate my post?
>>~ Clay
> 
> 
> Why is wrong with using a Global? When I need an array for the whole time and
> more than half of the subs need to access it, I just don't want to use those
> annoying pointers the whole time :).. how is this done in D?
> 

Pointers, schmointers.  You can pass an array as normal to a function without copying. 
(This is where the Copy-on-Write people might speak up.  I'll let them.)  Also, if you 
intend to replace the array during a function, just use an 'out' or 'inout' parameter.

Although personally I have no problem with using globals.  :)

-- Chris Nicholson-Sauls



More information about the Digitalmars-d-learn mailing list