bug-guile
[Top][All Lists]
Advanced

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

Re: Vectors should not evaluate to themselves


From: Martin Grabmueller
Subject: Re: Vectors should not evaluate to themselves
Date: Fri, 06 Apr 2001 17:10:26 +0200

> From: Mikael Djurfeldt <address@hidden>
> Date: 05 Apr 2001 01:12:28 +0200
> 
> Martin Grabmueller <address@hidden> writes:
> 
> > according to R5RS, literally entered vectors do not evaluate to
> > themselves and must always be quoted.  Guile does not detect this
> > error:
> > 
> > guile> #(as)
> > #(as)
> > 
> > Should this be fixed, and can it be fixed easily?
> 
> It should be fixed and it is easy to fix.  We only need to remove a
> case in a switch at the top of the evaluator.

I have done that, but not committed yet.  As I have never touched the
evaluator before, I am not sure if the attached patch is sufficient.
Also, R5RS only defines ``Numerical constants, string constants,
character constants and boolean constants'' (R5RS 4.1.2) as
self-evaluating, so the following cases should be removed, too:

    case scm_tc7_smob:
    case scm_tcs_closures:
    case scm_tc7_cclo:
    case scm_tc7_pws:
    case scm_tcs_subrs:

and the `struct' part of the following:

    case scm_tcs_cons_gloc: {
      scm_bits_t vcell = SCM_STRUCT_VTABLE_DATA (x) [scm_vtable_index_vcell];
      if (vcell == 0) {
        /* This is a struct implanted in the code, not a gloc. */
        RETURN (x);
      } else {
        proc = SCM_PACK (vcell);
        SCM_ASRTGO (SCM_NIMP (proc), badfun);
#ifndef SCM_RECKLESS
#ifdef SCM_CAUTIOUS
        goto checkargs;
#endif
#endif
      }
      break;


===File ~/cvs/guile/guile-core/libguile/diff-eval===========
Index: eval.c
===================================================================
RCS file: /cvs/guile/guile-core/libguile/eval.c,v
retrieving revision 1.214
diff -r1.214 eval.c
2502,2516d2501
<     case scm_tc7_vector:
<     case scm_tc7_wvect:
< #ifdef HAVE_ARRAYS
<     case scm_tc7_bvect:
<     case scm_tc7_byvect:
<     case scm_tc7_svect:
<     case scm_tc7_ivect:
<     case scm_tc7_uvect:
<     case scm_tc7_fvect:
<     case scm_tc7_dvect:
<     case scm_tc7_cvect:
< #ifdef HAVE_LONG_LONGS
<     case scm_tc7_llvect:
< #endif
< #endif
============================================================



reply via email to

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