[Top][All Lists]

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

[Gcl-devel] Re: hi

From: Camm Maguire
Subject: [Gcl-devel] Re: hi
Date: 06 Oct 2005 13:27:04 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2


Robert Boyer <address@hidden> writes:

> Here are some miscellaneous thoughts.
> > I have a likely silly idea I'd like to float in this regard.
> I think it sounds silly too.  It would seem to bias things too much toward
> conses.  This is nothing except an emotional reaction.  In a 64 bit world,
> where throwing away half of one's address space a few times is ok, maybe its
> not such a bad idea.

OK, lets leave well enough alone.  We obviously showed some bias
toward fixnums by giving them their own address space -- just was
pondering whether that was the right priority over cons given our
original consultations on the two types.

> I would appreciate it if you could write a brief English version of the
> current version of type_of.  Which of the subtests are order dependent?
> E.g., must the NIL test come first, the imm test before the cons?

Well, in the dotnil removed version I'm testing now:

#define type_of(x)       ({register object _z=(object)(x);\
                           _z==Cnil ? t_symbol : \
                           (is_imm_fixnum(_z) ? t_fixnum : \
                           (is_cons(_z) ?  t_cons  : _z->d.t));})

First we assert NIL is a symbol.  I thought originally we could do
something clever by aligning the nil address so that it returned
t_symbol with the conventional logic, but then it surely would ot be 8
byte aligned and cons could no longer be detected by having an 8 byte
aligned address in the cdr position.  We do this first as it is likely
the most common -- it need only be done before the final ->d.t.

Next we check for immediate fixnums.  This must be done before
indirecting the pointer (as in checking for cons or other types) if we
don't want to abort on a segfault :-).

Then we check for cons as an address which points to an address
(corresonding to the cdr of the cons) that is either even or an
immediate fixnum.  We check the former first as it is likely the most
common.  It is possible to interchange this with the other type (d.t)
checking, but it appears that one would have to check the final bit
(d.e) twice in this case.

Finally, we know the escape bit (d.e) is set in the word pointed to by
the object, so we know it is a type word and we read the type code.

> The most frequent test is probably a test for atom/consp.  However, the code
> for DEFUNO_NEW("ATOM",object,fLatom is a little dumb, in view of the current
> type_of.  One should not do the full type_of computation to test if something
> is an atom; instead, one should skip at least the last _z->d.t because it is
> not going to be "cons" whatever it is.  (Unless I'm asleep again.)

This might not be a bad idea -- a C macro that just checks for cons:

#define consp(x)         ({register object _z=(object)(x);\
                           (!is_imm_fixnum(_z) && is_cons(_z));})

I'll try this out -- thanks!

> > is there a complete set of functions listed anywhere that
> > need be able to handle an improper list, so that I might dispense with
> > the old DOTNIL trick?
> I'm not sure that I understand this question quite yet.  If you'll try to
> rephrase it, or otherwise tell me what problem you're trying to solve, I'll
> try to work on answering it by looking at the ANSI spec.
> As I understand it, the object
>   (let ((x (cons nil nil)))
>      (rplaca x x) 
>      (rplacd x x))
> is an improper list.  But CAR, CDR and friends handle it just fine.  Do you
> want someone to give you a list that includes CAR, CDR, and friends?  It will
> be long.

Your other list has sufficed quite fine -- the dotnil removed version
fails 15 more ansi tests, which I will fix and then upload.

Take care,

> Bob

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]