This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Dirk Herrmann <dirk@ida.ing.tu-bs.de> writes: > SCM > scm_cons (x, y) > SCM x; > SCM y; > { > register SCM z; > SCM_NEWCELL (z); > SCM_SETCAR (z, x); > SCM_SETCDR (z, y); > return z; > } > > You see, no DEFER/ALLOW. Maybe this is an omission? No, this is OK. scm_cons is a constructor of pairs. It is supposed to receive valid scheme objects in x and y. The DEFER/ALLOW protect us from interruptions which could lead to GC. But if we can accept GC at any point in our code, we won't need DEFER/ALLOW. In the above case, the new cell will be OK regardless of where we get interrupted. (It is even OK if SCM_NEWCELL gets interrupted during its unlinking of the cell from the free list, since the interrupting code will skip the first pair on the free list.) But when we try to make a smob we'll get in trouble if we initialize the CAR first since the GC could be led to believe that the CDR points to an initialized malloc block corresponding to the smob type... /mdj