guile-devel
[Top][All Lists]
Advanced

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

Re: stumped by scm_car/scm_cdr


From: Marius Vollmer
Subject: Re: stumped by scm_car/scm_cdr
Date: Fri, 08 Oct 2004 00:12:49 +0200
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Han-Wen Nienhuys <address@hidden> writes:

> I tried to remove all fishy looking places where SCM_C[AD]R were used,
> and now it seems to work OK. You might want to consider just doing
> abort() or a something similar as a standard.

That would not fit SCM_CAR, SCM_CDR etc well.  These macros are there
for code that knows what it does and wants to do it fast.  You can use
SCM_DEBUG_CELL_ACCESSES to have them do some checks, however.  These
checks will only assert that you access a cell, not whether that cell
represents a pair.

In general Guile only aborts when there is no other way, for example
when it has run out of memory or when the error reporting mechanism
itself fails.

> If the C code uses the API incorrectly, then (IMO) this is not
> something that should be signaled at Scheme level using scm_error(),
> because no amount of Scheme coding can fixup such errors.

It is not really clear to me what "incorrect use of the C API" would
mean; we can not really talk about it in general, only about specific
cases.

For example, when scm_error is called during GC that is a fatal error
since scm_error is not allowed to return but it can't do its usual
thing and throw to a handler in the middle of GC.  People are just not
supposed to do anything during GC that can signal an error, so Guile
just aborts in this case.

However, when scm_to_locale_string is asked to convert a string that
contains a #\nul character, it signals an error.  Why shouldn't it?

So, we might talk about whether SCM_CAR and SCM_CDR should abort when
passed a non-pair, or whether they should signal an error; or whether
they should check that they are passed a cell.

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405




reply via email to

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