Przemyslaw Czerpak wrote:
I can do it in C, so I've wrote a EMPTYPTR() function with
   hb_retptr( NULL );
but I'm asking about compiler based 0p0 (just like 0d0 or 0t0 for empty date or timestamp) solution. Does such solution exist?
No. We can add literal pointer representation but I'd not like it.
Empty pointer is OK for me so functions like EMPTYPTR() are fine
but memory pointers are application instance dependent so I do not
want to introduce any way to explicitly set their value other then
null. If we add support for 0p0 then people will look for 0pDEADBEAF
Hi,


I understand your point of view. One of the reasons of my numeric to pointer change is to forbid "+" operation on memory addresses. So, I was looking for a way to initialize empty pointer only.
I wanted to use null pointer initialization in code:
  STATIC s_hWnd := EMPTYPTR()
that's way I wanted to have Compiler support for it. I moved initialization to init proc, so it's not critical, I can use EMPTYPTR(). But if Harbour has pointers, I must have a standard way to initialize variable to pointer (and probably compiler support for it), so we can discuss pseudo-function name anyway.

or other values and then for a way to store/retrieve pointers in
MEMOs or other data files. I do not know if I want to implement it.
At least as long as people will not use GC collectible pointers which
can be validated in C code such extensions seems to be too danger.
I'm using not collectible pointers for C structures, and I allow direct 
peek/poke of any field in structure using pointer and offset, but I 
always try to keep explicit peek/poke call in .ch file. For example,
to access C structure:
  typedef struct  {
     int    x, y;
  } POINT;
I use:
  #xtranslate POINT_x(<ptr>)   =>   PeekInt(<ptr>, 0)
  #xtranslate POINT_y(<ptr>)   =>   PeekInt(<ptr>, 4)

I'm very satisfied with this approach, it let's me have C level possibilities on Harbour. But I do not suggest this approach as solution for "the masses", because many programmers do not understand low level memory, and these possibilities will become a GPF.

Best regards,
Mindaugas
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to