lucy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Wellnhofer <wellnho...@aevum.de>
Subject Re: [lucy-dev] Method access macros, Clownfish capitalization conventions
Date Wed, 18 Apr 2012 17:24:37 GMT
On 18/04/2012 00:03, Marvin Humphrey wrote:
> Howdy,
>
> Seeing Nick generalize METHOD, SUPER_METHOD and OVERRIDDEN, I wonder if we
> can't improve on them.  For example, here's a version of METHOD which allows you
> to type the exact method name:
>
>    /* Usage:
>     *
>     *   Obj_equals_t equals
>     *      = (Obj_equals_t)METHOD(vtable, Lucy_Obj_Equals);
>     */
>    #define CFISH_METHOD(vtable, full_name) \
>       cfish_method(vtable, full_name ## _OFFSET)

+1 for that change.

> Or, perhaps even better, if we change the capitalization convention for the
> "inside-out vtable" offset variables, we can autogenerate the cast:
>
>    /* Usage:
>     *
>     *   Obj_equals_t equals = METHOD(vtable, lucy_Obj_equals);
>     */
>    #define CFISH_METHOD(vtable, full_name) \
>       ((full_name ## _t)cfish_method(vtable, full_name ## _OFFSET))
>
> I'm partial to that latter version.  The capitalization of the second argument
> is currently misleading, but we can clear that up...
>
> Right now, we differentiate between method invocation and implementing
> function using capitalization.
>
>      Lucy_Obj_Equals<---- method invocation
>      lucy_Obj_equals<---- implementing function
>
> This has proven confusing to developers; it would likely be clearer if we
> spelled those differently instead.
>
>                    | Current                | Proposed
>     ===============|========================|=======================
>     implementation | lucy_Obj_equals        | S_Obj_equals # static
>     method         | Lucy_Obj_Equals        | lucy_Obj_equals
>     typedef        | lucy_Obj_equals_t      | lucy_Obj_equals_t
>     offset         | Lucy_Obj_Equals_OFFSET | lucy_Obj_equals_OFFSET

+0

Note that the current naming scheme is consistent in so far that 
implementations and typedefs only exist for fresh methods while methods 
and offsets are defined for every method. I think it makes sense to have 
a typedef for every method and to use the same naming conventions for 
typedefs and methods. This would make it possible to autogenerate the 
typecast regardless of letter case.

Nick

Mime
View raw message