Re: Ver 4.0 allocate() question

new topic     » goto parent     » topic index » view thread      » older message » newer message
bernie said...

Is there any good reason that the interpreter returns non-initialize memory
from the allocate function?

Most of the code that I have seen using the allocate function in Euphoria
is closely followed by a mem_set() zero or poke() zero function.

Would'nt it be a good idea to zero out memory internally during the allocate()
This would prevent some user errors and remove the mem_set() over-head.
It would still allow a user to initialize to some other value with mem_set()
or poke() functions

I remember reading, long ago, that the rationale for this was that there is no point initialising a memory block if you are going to initialise it yourself. Waste of time.

From my own experience, the first instruction that follow an allocate() is a poke/2/4(), so I'm glad there is no implicit mem_set() I cannot disable. In other cases, I hand the block to some routine for it to fill the structure in, which again makes initialisation wasteful. The counterpart being that, if you want to do a mem_set(), then you do it yourself, but only whe needed.

CChris

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu