[Top][All Lists]

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

Re: [Gcl-devel] Dotted lists

From: Camm Maguire
Subject: Re: [Gcl-devel] Dotted lists
Date: 21 Sep 2002 19:38:26 -0400

Greetings!  I've still not checked this in, so the dotted list issues
in ldiff et. al. you raised are still live.  I'd appreciate some
meaningful comments on how to approach this before committing what I
have, as its more radical than normal.  

In sum, we have a bunch of loops over list elements which use endp,
and which currently only work for proper lists.  On reaching the last
atom of a dotted list, these loops will throw an error.  I'd like a
solution which avoids having to edit each loop by hand.  The solution
I have, 2) below, does this, but has some drawbacks.  For example, it
assumes one endp check per loop iteration, which appears to be the
case in code generated and used by gcl.  And it won't work for
the few loops using endp(cdr(x), etc.  Keep in mind that this whole
discussion is at the C level -- lisp (endp ... will work as before,
throwing an error when passed the last atom of a dotted list.

Of course, if someone can show me that only a few loops need to be
addressed, then I'll happily adjust by hand, as its safer.

Perhaps you can file your dotted list bugs to the web site in the

Take care,

EXTER struct cons my_dot,my_dot_pit;

#define endp(x) ({\
    object _x=(x);\
    bool _b=FALSE;\
    if (type_of(_x)==t_cons) {\
       if (type_of(_x->c.c_cdr)!=t_cons && _x->c.c_cdr!=Cnil)\
       else \
    } else {\
       if (_x==my_dot.c_car)\
       else {\
         if (_x==Cnil || _x==(object)&my_dot_pit)\
             FEwrong_type_argument(sLlist, _x);\

#define endp_prop(a) (type_of(a)==t_cons ? FALSE : ((a)==Cnil ? TRUE : 
(FEwrong_type_argument(sLlist, (a)),FALSE)))

Camm Maguire <address@hidden> writes:

> Greetings!  
> Gcl has apparently been designed to only handle proper lists.  I have a
> working tree which can compile itself and maxima, and which extends
> functionality to dotted lists in general, but may yet have a few loose
> ends.  Before I commit, I'd like to consult with the list.
> 1) One solution of course is to modify the reader to store dotted
>    lists in proper form.  This of course would eliminate the
>    distinction between the two forms of list.  I take it one wants the
>    ability to distinguish between the two, but I can't see why.  Is
>    the standard just written to included dotted lists because some
>    original implementations tried to save the space of the final cons?
>    Or are they useful as distinct from proper lists?
> 2) The solution I have preserves the distinction, but alters the endp
>    macro to redirect the list to a special cons pointing to the final
>    cdr atom when passed an argument of this atom.  In this way, all
>    bodies of loops over lists will handle all elements properly
>    including the last.  At loop end, the list variable holds Cnil for
>    a proper list, or a special symbol indicating the end of a dotted
>    list.  This allows certain functions which return their answers as
>    lists to either dot the last element or cons it as usual.  Such end
>    loop processing has to be done function by function, but I made the
>    determination that such functions which care about the form of the
>    end of a list, apart from the fact that the list is at end, are
>    few, and preserving uniform treatment of loop body code is more
>    important.  The compiler actually wrote calls to endp with
>    arguments which could not be redirected in certain places, so these
>    have been adjusted as well.  There are only two places in the
>    compiler where it still seems necessary to use the old endp
>    behavior (i.e. for proper lists only), but this may actually be
>    used only for compiler internals, and in any case might be worked
>    around n the future.  On the other hand, if there are certain
>    definable areas where dotted lists should not be allowed, it would
>    be better to preserve the old endp in such places.  In any case,
>    the behavior for proper lists should be completely unchanged.  All
>    of Paul's related bug reports are fixed in this tree, to my
>    understanding. 
> Is this the right strategy here?  
> a) Do we need to support dotted lists as separate objects from proper lists?
> b) Is the idea that all elements of both should be
>    handled the same in most places, with exceptions treated by hand,
>    valid?
> c) Does anyone know if inferences can be made regarding the type lists the
>    compiler uses at various points?  I can give specifics on request.
> Take care,
> -- 
> Camm Maguire                                          address@hidden
> ==========================================================================
> "The earth is but one country, and mankind its citizens."  --  Baha'u'llah
> _______________________________________________
> Gcl-devel mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/gcl-devel

Camm Maguire                                            address@hidden
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah

reply via email to

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