From: timsuth@... (Tim Sutherland) Date: 2004-10-29T09:19:00+09:00 Subject: Re: Dereferencing PtrData in Ruby/DL In article <41816603.30703@email.byu.edu>, Jamis Buck wrote: >Jamis Buck wrote: >> Carl Youngblood wrote: >> >>> Thanks Jamis. Now I have another problem. How do I get a pointer to >>> a pointer? Let's say I've just allocated a pointer with: >>> >>> mypointer = DL.malloc(DL.sizeof('P')) >>> >>> How do I get a pointer to that pointer? mypointer.to_p doesn't seem >>> to work. >> >> >> Try "mypointer.ptr". >> >> Then "mypointer.ref" to dereference the pointer. > >Ack. Other way around. PtrData#ptr dereferences a pointer, while >PtrData#ref obtains a pointer to the pointer in question. What do you think of the following patch to dl/doc/dl.txt? The first time I used PtrData#ptr and PtrData#ref I had to look in the source code to see what they did. --- dl.txt Sun Jan 12 06:28:59 2003 +++ dl-new.txt Fri Oct 29 13:09:28 2004 @@ -198,10 +198,12 @@ string is '\0'. * ptr = PtrData#ptr,+@ - * returns the pointed value as a PtrData object ptr. + * returns the dereferenced value as a PtrData object ptr. + this is like `*ptr' in C. * ptr = PtrData#ref,-@ * returns the reference as a PtrData object ptr. + this is like `&ptr' in C. * ptr = PtrData#+ * returns the PtrData object