diff options
-rw-r--r-- | libguile/ChangeLog | 8 | ||||
-rw-r--r-- | libguile/eval.c | 28 |
2 files changed, 26 insertions, 10 deletions
diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 36f09edf3..87e3ac868 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,11 @@ +2004-03-24 Dirk Herrmann <dirk@dirk-herrmanns-seiten.de> + + * eval.c (is_self_quoting_p): New static function. + + (scm_m_quote): Use is_self_quoting_p. + + (copy_tree): Corrected typo in comment. + 2004-03-28 Han-Wen Nienhuys <hanwen@xs4all.nl> * eval.c (s_scm_copy_tree): idem. diff --git a/libguile/eval.c b/libguile/eval.c index 97db5eb48..fddc50c58 100644 --- a/libguile/eval.c +++ b/libguile/eval.c @@ -451,6 +451,22 @@ literal_p (const SCM symbol, const SCM env) return 0; } + +/* Return true if the expression is self-quoting in the memoized code. Thus, + * some other objects (like e. g. vectors) are reported as self-quoting, which + * according to R5RS would need to be quoted. */ +static int +is_self_quoting_p (const SCM expr) +{ + if (SCM_CONSP (expr)) + return 0; + else if (SCM_SYMBOLP (expr)) + return 0; + else if (SCM_NULLP (expr)) + return 0; + else return 1; +} + /* Lookup a given local variable in an environment. The local variable is @@ -1697,16 +1713,8 @@ scm_m_quote (SCM expr, SCM env SCM_UNUSED) ASSERT_SYNTAX (scm_ilength (cdr_expr) >= 0, s_bad_expression, expr); ASSERT_SYNTAX (scm_ilength (cdr_expr) == 1, s_expression, expr); quotee = SCM_CAR (cdr_expr); - if (SCM_IMP (quotee) && !SCM_NULLP (quotee)) - return quotee; - else if (SCM_VECTORP (quotee)) + if (is_self_quoting_p (quotee)) return quotee; -#if 0 - /* The following optimization would be possible if all variable references - * were resolved during memoization: */ - else if (SCM_SYMBOLP (quotee)) - return quotee; -#endif SCM_SETCAR (expr, SCM_IM_QUOTE); return expr; } @@ -5373,7 +5381,7 @@ copy_tree ( * that in contrast to the typical hare-and-tortoise pattern, the step * of the tortoise happens before the hare takes its steps. This is, in * principle, no problem, except for the start of the algorithm: Then, - * it has to be made sure that the hare actually gets its advantage by + * it has to be made sure that the hare actually gets its advantage of * two steps. */ if (tortoise_delay == 0) { |