guile-devel
[Top][All Lists]
Advanced

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

Re: Commercial development


From: Neil Jerram
Subject: Re: Commercial development
Date: Sun, 12 Jun 2005 10:38:53 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Debian/1.7.8-1

Neil Jerram wrote:
> 
> Yes, I'll have a go.

How about the attached?  The scm_reverse_x is annoying, but removing it
would require

- either modifying transform_bindings etc. so as not to reverse things
in the first place, or so as to reverse the init vars in the same way as
the init forms

- or constructing the list backwards in eval_letrec_inits - but I can't
see a way of doing that.

        Neil

Index: eval.c
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/eval.c,v
retrieving revision 1.397
diff -u -r1.397 eval.c
--- eval.c      6 Jun 2005 18:49:55 -0000       1.397
+++ eval.c      12 Jun 2005 09:30:14 -0000
@@ -96,6 +96,7 @@
 static SCM canonicalize_define (SCM expr);
 static SCM *scm_lookupcar1 (SCM vloc, SCM genv, int check);
 static SCM unmemoize_builtin_macro (SCM expr, SCM env);
+static SCM eval_letrec_inits (SCM env, SCM init_forms, SCM init_values);
 
 
 
@@ -3148,6 +3149,29 @@
   return *results;
 }
 
+static SCM
+eval_letrec_inits (SCM env, SCM init_forms, SCM init_values)
+{
+  SCM argv[10];
+  int i = 0, imax = sizeof (argv) / sizeof (SCM);
+
+  while (!scm_is_null (init_forms))
+    {
+      if (imax == i)
+       {
+         init_values = eval_letrec_inits (env, init_forms, init_values);
+         break;
+       }
+      argv[i++] = EVALCAR (init_forms, env);
+      init_forms = SCM_CDR (init_forms);
+    }
+
+  for (i--; i >= 0; i--)
+    init_values = scm_cons (argv[i], init_values);
+
+  return init_values;
+}
+
 #endif /* !DEVAL */
 
 
@@ -3563,21 +3587,9 @@
           x = SCM_CDR (x);
           {
             SCM init_forms = SCM_CAR (x);
-            SCM init_values = SCM_EOL;
-            do
-              {
-                init_values = scm_cons (EVALCAR (init_forms, env), 
init_values);
-                init_forms = SCM_CDR (init_forms);
-              }
-            while (!scm_is_null (init_forms));
-
-           /* In order to make case 1.1 of the R5RS pitfall testsuite
-              succeed, we would need to copy init_values here like
-              so:
-
-              init_values = scm_list_copy (init_values);
-           */
-            SCM_SETCDR (SCM_CAR (env), init_values);
+           SCM init_values = eval_letrec_inits (env, init_forms, SCM_EOL);
+            SCM_SETCDR (SCM_CAR (env),
+                       scm_reverse_x (init_values, SCM_UNDEFINED));
           }
           x = SCM_CDR (x);
           PREP_APPLY (SCM_UNDEFINED, SCM_EOL);

reply via email to

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