emacs-devel
[Top][All Lists]
Advanced

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

Re: __attribute__ ((cleanup)) and emacs-module.c


From: Po Lu
Subject: Re: __attribute__ ((cleanup)) and emacs-module.c
Date: Sun, 12 Mar 2023 08:42:41 +0800
User-agent: Gnus/5.13 (Gnus v5.13)

Paul Eggert <eggert@cs.ucla.edu> writes:

> On 2023-03-10 17:37, Po Lu wrote:
>
>> +#define MODULE_INTERNAL_CLEANUP                     \
>> +  module_reset_handlerlist (&internal_cleanup)
>
> No need for the "&" here. Omit it, and change the type of
> module_reset_handlerlist to take 'struct handler *' instead of 'struct
> handler **'.
>
> Also, please make this macro a parameterless function-style macro
> called via 'MODULE_INTERNAL_CLEANUP ()' as it acts like a function.

OK, will do.

> Also, please define a macro MODULE_FUNCTION_END something like this:
>
>   #define MODULE_FUNCTION_END(retval) \
>      (MODULE_INTERNAL_CLEANUP (), retval)
>
> and use 'return MODULE_FUNCTION_END (<simple-expression>);' when the
> cleanup is immediately followed by a return of a value of a simple
> expression. For complex expressions that can throw exceptions, you can
> use something like:
>
>     <type> r = <complex-expression>;
>     return MODULE_FUNCTION_END (r);

I think this is likely to be confusing, because people won't realize the
situations in which it cannot be used, and we will end up with code
like:

  return MODULE_FUNCTION_END (Fthis_thing_that_calls_xmalloc ())


reply via email to

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