[ccan] [PATCH 2/4] order_functions: Scalar comparison functions

Rusty Russell rusty at rustcorp.com.au
Tue Jun 2 11:06:41 AEST 2015


David Gibson <david at gibson.dropbear.id.au> writes:
> Extend the order_functions module to provide simple, standard, comparison
> callbacks for scalar types (i.e. integer and floating point types).
>
> In addition to the usual variants comparing a plain scalar, this also
> provides helper macros to construct a suitably typed callback and context
> pointer to order structures by a specified scalar field.

This is *so awesome!*, I think many of my funcs can be
trivially replaced by these.

Two things:
1) Should we just expose the macro in the header, and be done?
   Hmm, I'd say not, since asort() won't be inlined anyway.
   But maybe s/SCALAR_ORDER/ORDER_SCALAR/ for namespace reasons
   and leave that in the header, with a /* You can build your own! */
   comment?

2) I'd prefer, despite the extra typing, to have the explicit
   declarations in the header anyway.  It's just far more readable.

Thanks,
Rusty.


More information about the ccan mailing list