Re: address of variable
- Posted by "Boehme, Gabriel" <gboehme at POSTOFFICE.MUSICLAND.COM> Dec 16, 1999
- 510 views
Bernie Ryan wrote: >I think that a programmer should be able to store data in a >global variable inside a procedure or function. ( I don't need to >know the variables address ) Erm...you already *can* do this... global object var ... procedure or_function() ... var = some_value ... end procedure >I also think a programmer should be able to use the free function >to free memory that was allocated outside of a function or procedure >from within a procedure or function. atom addr ... procedure one_procedure() ... addr = allocate(number_of_bytes_needed) ... end procedure ... procedure another_procedure() ... if addr then ... free(addr) end if ... end procedure >An example for it's need is: > With in a procedure and I want to free a memory pointer's >allocated memory. Reallocate a larger memory block and then reassign >that memory block to that same memory pointer. This at present can not >be done in Euphoria. atom addr addr = 0 ... procedure resize_memory_block() ... free(addr) ... addr = allocate(new_length) ... end procedure >Correction, memory can be freed from within a function or procedure. >But, I want to be able to reassign a global pointer inside a procedure or >function. Okay, just put "global" in front of my "atom addr" in the example above. Hep yadda, Gabriel Boehme ---------- If we know what to look for, we may recognise it when it happens. Otherwise, we see what we expect to see. That is, what we know in ourselves. Robert Fripp ----------