Surely I understand it now with this whole business of dynamic memory
management by garbage collector.
Understand my logic: ALLOC is "dangerous" because it is not a
straightforward function as malloc. Because Data_Make_Struct also calls
ALLOC, then it is also dangerous. Not only Data_Make_Struct, but *all*
the seemingly innocent Ruby function that may allocate memory are, in some
sense, dangerous. All C programmers who never dealt with garbage
collector before have to know about this issue of double initialization,
because the bug may be difficult to trace. Therefore:
"If I can use malloc instead of ALLOC to accomplish the same purpose,
why should I ever need to use ALLOC?"
It seems the word "dangerous" has been taken beyond its intended
interpretation. Remember the phrase "Goto Considered Harmful" or "Java
new Considered Harmful"? I have changed it from "harmful" to "dangerous",
but it seems someone is realy upset about the word "dangerous". We are
not talking about technicals anymore, but just personal stuff. What a
waste...
Another example: If you responded to the statement "never use ALLOC; use
malloc instead" with "it is not a good idea, because of this, this,
....", you would have contributed to the body of knowledge; however, when
you just answer "it is stupid" without giving any reason, it is really a
waste... you accomplish nothing: it does not help me or anybody else.
Bill
===========================================================================
ts <decoux / moulon.inra.fr> wrote:
> Data_Make_Struct() is *not* dangerous. The goal of Data_Make_Struct() is
> to call ALLOC(), initialize all members of the struct to zero then call
> Data_Wrap_Struct()
> If you have not understood this : don't use it.
> Guy Decoux