Paul Eggert <address@hidden
> schrieb am So., 22. Nov. 2015 um 00:10 Uhr:
Philipp Stephani wrote:
>> Many modules will have needs similar to Emacs itself in
>> >respect, and it would be better if they didn't have to reinvent this
> But what should the interface be? There are only three possibilities in C:
> return a sentinel value, crash, longjmp.
There's a fourth possibility: do what Emacs does. Emacs defines its own
throw-catch mechanism built atop C. C modules that need to cleanup when unwound
can do so by registering via the equivalent of record_unwind_protect, and Emacs
won't longjmp through them without cleaning up. This already works for xmalloc
memory-exhaustion failures, and modules can just use the already-existing mechanism.
We have already discussed longjmp at length in this thread, and Daniel, Aurélien and I are all strongly against it. Using longjmp makes it effectively impossible to write modules in any language but C, and even C code has to be very careful (e.g. it can't use __attribute__((cleanup))). longjmp is only possible within a monolithic system that is able to make closed-world assumptions such as the Emacs binary itself, it is impossible in generic and portable library code. We have worked hard to remove the possibility of longjmp leaking into module code, and I won't put that possibility back in.