lout-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Lout Internals Anyone?


From: Salman Khilji
Subject: Lout Internals Anyone?
Date: Sat, 26 Jul 2003 18:09:14 -0700
User-agent: KMail/1.5.1

I am trying to make any sense out of the Lout source-code.  Having a 
background in engineering and not in computer science, I am facing tremendous 
difficulty understanding the Directed Acyclic Graph that is used everywhere 
in Lout.

I really don't know what is meant by PARENT and CHILD direction.  Further each 
direction has a pred and succ.  Can someone please direct me to a link that 
explains how such a graph works?  Are there any alternative implementations 
wirtten in C++ templates that would help me understand the concept.  Some 
link that has pictures of how DAG's work would be good. 

Suppose B is a child of A.  According to the documentation there must exist a 
LNK node between A and B.

I would expect that the CHILD end of A would be connected to the PARENT of LNK 
and the CHILD end of LNK would be connected to PARENT of B.  But that is not 
the case.

It turns out that CHILD end of A is connected to CHILD of LNK and the PARENT 
of LNK is connected to PARENT of B.

I have spent around 20 hours looking at just this definition:

#define Append(x, y, dir)                                               \
( zz_res = (x), zz_hold = (y),                                          \
  zz_hold == nilobj ? zz_res  :                                         \
  zz_res  == nilobj ? zz_hold :                                         \
  ( zz_tmp = pred(zz_hold, dir),                                        \
    pred(zz_hold, dir) = pred(zz_res, dir),                             \
    succ(pred(zz_res, dir), dir) = zz_hold,                             \
    pred(zz_res, dir) = zz_tmp,                                         \
    succ(zz_tmp, dir) = zz_res                                          \
  )                                                                     \
)


I tried to change it to a function as follows so that I could step thru this 
and see whats going on.

OBJECT Append(OBJECT x, OBJECT y, int dir)
{
  zz_res = x;
  zz_hold = y;

  if (zz_hold == nilobj) return zz_res;
  if (zz_res  == nilobj) return zz_hold;

  zz_tmp = pred(zz_hold, dir);
  pred(zz_hold, dir) = pred(zz_res, dir);
  succ(pred(zz_res, dir), dir) = zz_hold;
  pred(zz_res, dir) = zz_tmp;
  succ(zz_tmp, dir) = zz_res;

  return zz_tmp;
}


But this does not work.  I have fairly advanced C/C++ skills, but I really 
have trouble reading these macros.

What is frustrating me is that I have spent a tremendous amount of time 
staring at only 10 lines of code, yet I cannot make sense out of it.

I was under the impression that every vertex would have a LNK node in between.  
But again that is not the case.  If you step thru the CopyTokenList function 
you realize that there are OBJECTs in there that are linked directly to each 
other instead of having a LNK node in between.  I have read the design 
documentation again and again but still can't decide as to why we need a LINK 
node among vertices.

Salman


reply via email to

[Prev in Thread] Current Thread [Next in Thread]