This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: SCM_SMOB_TAG smob abstraction


Mikael Djurfeldt <mdj@mdj-pc.nada.kth.se> writes:

> Dirk Herrmann <dirk@ida.ing.tu-bs.de> writes:
> 
> > * readability:  The semantics of SCM_SMOB_TAG is immediately clear to a
> >   reader of the corresponding code.
> 
> Really?
> 
> What does it mean?

I think the point is more that SCM_SMOB_TAG has one unambiguous use.
With SCM_TYP16, various uses are used to mean different things.

A *lot* of the guile source code seems unnecessarily obfuscated and
semantically in-lined.  By that, I mean that if the thought is, e.g., to 
access the "bang" component, the code has some crazy expression to
accessing the bang component instead of an abstraction of the notion of
accessing that component and a separate definition.

This is a pervasive problem in the guile source, and is related to my
other big concern which is that there are far too many un-enforced,
un-checked constraints on the source code to ensure correctness.  E.g.,

SCM_PROC (s_add_hook_x, "add-hook!", 2, 1, 0, scm_add_hook_x);

SCM
scm_add_hook_x (SCM hook, SCM proc, SCM append_p)
{
...


There are dependencies among the name s_add_hook_x, "add-hook!",
scm_add_hook_x and the function name in the declaration.  Also there is
a hateful dependence between the three numbers in the SCM_PROC macro
invocation and the argument list to the primitive. None of these are
checked, and they are easy to get wrong, especially when cutting and
pasting.  Perhaps guile should adopt some better macros more like what
we use for Scwm. We would write:

SCWM_PROC(add_hook_x,"add-hook!",2,1,0,
          (SCM hook, SCM proc, SCM append_p))
{
...

And our documentation extraction system also verifies the numbers match
the number of arguments, and the C primitive name and the Scheme name
match (using some simple conventions and heuristics).  We've caught
innumerable bugs using these techniques and I'm certain we'd find
lurking bugs in Guile code if we applied the Scwm software-engineering
tools to Guile.

Greg


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]