Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.pascal.borland    |    Borland Pascal was actually pretty neat    |    2,978 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 1,181 of 2,978    |
|    Jason Burgon to victor75040@yahoo.com    |
|    Re: What does the Double caret (^^) mean    |
|    15 Dec 04 02:32:15    |
   
   From: gvision@ntlworld.com   
      
    wrote in message   
   news:ogvur0t6iidgaf3ipeb1rnu5vje5beh6h5@4ax.com...   
   > Hi,   
   >   
   > I understand the use of the ^ in pointers and how pointers work in   
   > TP7. I recently came accross soem code where they haev for example:   
   >   
   > T^^.next   
   >   
   > I have used it in the form of T^.next when traversing a linked list.   
   > Am just not sure how the double carets are to be used.   
      
   It simply means that T is a pointer to pointer, and double-dereferencing is   
   indeed often used by linked-list code. For example:   
      
   type   
    PDirectory = ^TDirectory;   
    TDirectory = object   
    Next: PDirectory;   
    Children: PDirectory;   
    ....;   
    end;   
      
    function TDirectory.AddChild(D: PDirectory): Boolean;   
    var   
    PCur: ^PDirectory;   
    begin   
    if D = nil then   
    begin   
    AddChild := False;   
    Exit;   
    end;   
    PCur := @Children;   
    while (PCur^ <> nil) and (DosCompare(D^.Name^, PCur^^.Name^) = 1) do   
    PCur := @PCur^^.Next;   
    D^.Next := PCur^;   
    PCur^ := D;   
    AddChild := True;   
    end;   
      
   Note that the intial value for PCur is set to the address of the pointer   
   that contains the address of the first in the linked-list of Children. The   
   use of double-dereferencing here ellimitates the need to handle the   
   otherwise special case of dealing with the first element of the list.   
      
   > Also I have seen @ being used instead of NEW,   
      
   No you haven't. New allocates heap memory to an object and returns a pointer   
   to it. @ returns the address of an existing object.   
      
   --   
   Jay   
      
   Author of Graphic Vision   
   http://homepage.ntlworld.com/gvision/   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca