Pointer to variables in D

EraScarecrow rtcvb32 at yahoo.com
Wed Apr 25 21:57:50 PDT 2012


On Thursday, 26 April 2012 at 03:54:25 UTC, Nathan M. Swan wrote:
> Yes. My rule: don't use pointers unless doing it otherwise is 
> really slow or really hard.

  Might be safe to use a pointer on an immutable struct (Say, 
globally accessible data?). I'm trying this; but it's only to get 
around the need to copy the variable when in fact since the data 
never changes why should I use more space by copying it?

  Not the best idea, but if the data never changes, memory isn't 
manually managed, don't do pointer arithmetic, then it should be 
safe (Long as it's not local variable data).

  That said, I agree, avoid pointers as much as you can.


More information about the Digitalmars-d-learn mailing list