[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Pika-dev] alists, list issues
From: |
Tom Lord |
Subject: |
Re: [Pika-dev] alists, list issues |
Date: |
Fri, 6 Feb 2004 07:42:53 -0800 (PST) |
> From: Andreas Rottmann <address@hidden>
> I just found out that there are more issues in my list code, except
> for SCM_LSET: I sometimes set the result storage and later referenced
> one of the parameters. This is of course wrong, since it means
> scm_func (x, arena, x) won't reliably work. I'll fix those along with
> the LSET issue.
Oh good. I'd started reviewing and fixing things like that but I'll
hold off till your done.
Right:
~ return parameters are permitted to be the same as input
parameters.
~ never dereference a `t_scm_word *' return or input parameter as
either lvalue or rvalue.
~ never reference a local `t_scm_word' variable except with a & in
front of it (never use its value, only its address).
So, not `*result = l.tail' but `SCM_LSET (result, &l.tail)'
~ always use scm_values_eq, not == or !=
So, not `if (l.fast == l.slow)' but
`if (scm_values_eq (arena, &l.fast, &l.slow))'
~ generally speaking, don't include system headers directly
So, not `#include <stdarg.h>' but `#include "hackerlab/os/stdarg.h"'
The other thing I've found is non-critical coding issues (i.e.,
perfection about this kind of thing is not critical):
~ use parentheses, not precedence
Not `if (tail && n > 0)' but `if (tail && (n > 0))'
> Meanwhile, I've started implementing some alist functions, reaping the
> code from systas and unfinished-code. Again, I've an API question;
> scm_acons and scm_ass{q,v,oc} are clear to me, but should the C names
> for ass{q,v,oc}-ref and del{q,v,ete} (not really alist function, but
> needed by alist code) be?
Just what you'd think:
scm_ass{q,v,oc}_ref
scm_del{q,v,ete}
-t