/[guile]/guile/guile-core/libguile/eval.c
ViewVC logotype

Diff of /guile/guile-core/libguile/eval.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.345 by dirk, Sun Nov 16 10:47:45 2003 UTC revision 1.346 by dirk, Sun Nov 16 13:32:02 2003 UTC
# Line 1585  SCM Line 1585  SCM
1585  scm_m_letstar (SCM expr, SCM env SCM_UNUSED)  scm_m_letstar (SCM expr, SCM env SCM_UNUSED)
1586  {  {
1587    SCM binding_idx;    SCM binding_idx;
   SCM new_bindings = SCM_EOL;  
1588    SCM new_body;    SCM new_body;
1589    
1590    const SCM cdr_expr = SCM_CDR (expr);    const SCM cdr_expr = SCM_CDR (expr);
# Line 1595  scm_m_letstar (SCM expr, SCM env SCM_UNU Line 1594  scm_m_letstar (SCM expr, SCM env SCM_UNU
1594    binding_idx = SCM_CAR (cdr_expr);    binding_idx = SCM_CAR (cdr_expr);
1595    check_bindings (binding_idx, expr);    check_bindings (binding_idx, expr);
1596    
1597    for (; !SCM_NULLP (binding_idx); binding_idx = SCM_CDR (binding_idx))    /* Transform ((v1 i1) (v2 i2) ...) into (v1 i1 v2 i2 ...).  The
1598       * transformation is done in place.  At the beginning of one iteration of
1599       * the loop the variable binding_idx holds the form
1600       *   P1:( (vn . P2:(in . ())) . P3:( (vn+1 in+1) ... ) ),
1601       * where P1, P2 and P3 indicate the pairs, that are relevant for the
1602       * transformation.  P1 and P2 are modified in the loop, P3 remains
1603       * untouched.  After the execution of the loop, P1 will hold
1604       *   P1:( vn . P2:(in . P3:( (vn+1 in+1) ... )) )
1605       * and binding_idx will hold P3.  */
1606      while (!SCM_NULLP (binding_idx))
1607      {      {
1608          const SCM cdr_binding_idx = SCM_CDR (binding_idx);  /* remember P3 */
1609        const SCM binding = SCM_CAR (binding_idx);        const SCM binding = SCM_CAR (binding_idx);
1610        const SCM name = SCM_CAR (binding);        const SCM name = SCM_CAR (binding);
1611        const SCM init = SCM_CADR (binding);        const SCM cdr_binding = SCM_CDR (binding);
1612        new_bindings = scm_cons2 (init, name, new_bindings);  
1613          SCM_SETCDR (cdr_binding, cdr_binding_idx);        /* update P2 */
1614          SCM_SETCAR (binding_idx, name);                   /* update P1 */
1615          SCM_SETCDR (binding_idx, cdr_binding);            /* update P1 */
1616    
1617          binding_idx = cdr_binding_idx;                    /* continue with P3 */
1618      }      }
   new_bindings = scm_reverse_x (new_bindings, SCM_UNDEFINED);  
1619    
1620    new_body = m_body (SCM_IM_LETSTAR, SCM_CDR (cdr_expr));    new_body = m_body (SCM_IM_LETSTAR, SCM_CDR (cdr_expr));
1621    return scm_cons2 (SCM_IM_LETSTAR, new_bindings, new_body);    SCM_SETCAR (expr, SCM_IM_LETSTAR);
1622      /* the bindings have been changed in place */
1623      SCM_SETCDR (cdr_expr, new_body);
1624      return expr;
1625  }  }
1626    
1627    

Legend:
Removed from v.1.345  
changed lines
  Added in v.1.346

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26