You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucy.apache.org by Nick Wellnhofer <we...@aevum.de> on 2017/02/02 15:17:03 UTC

[lucy-dev] Wrappers for Obj functions

Lucifers,

When converting Obj_Is_A, Obj_Get_Class, and Obj_Get_Class_Name from methods 
to functions, I added autogenerated inline function wrappers for each class 
that make it possible to call these functions without casting the invocant to 
Obj. Now I moved Err_downcast and Err_certify to Obj, and these functions use 
a macro as wrapper. We should use the same approach for all these wrappers.

Inline functions provide more type safety but they pollute the function 
namespace of subclasses. Macros are generally shorter, at least when using 
"short names", but they're ALL CAPS.

We could also think about a more generic approach and make CFC create inline 
function wrappers for every function in a superclass that has a method-like 
invocant as first argument. Something like non-virtual methods in C++. This 
could also be triggered by a new function modifier. It should also be possible 
to autogenerate host language bindings for this type of function.

Nick

Re: [lucy-dev] Wrappers for Obj functions

Posted by Nick Wellnhofer <we...@aevum.de>.
On 02/02/2017 16:17, Nick Wellnhofer wrote:
> When converting Obj_Is_A, Obj_Get_Class, and Obj_Get_Class_Name from methods
> to functions, I added autogenerated inline function wrappers for each class
> that make it possible to call these functions without casting the invocant to
> Obj. Now I moved Err_downcast and Err_certify to Obj, and these functions use
> a macro as wrapper. We should use the same approach for all these wrappers.

I didn't realize that the reason why we have to use DOWNCAST and CERTIFY 
macros is that we want accurate line numbers in the reported exceptions. So 
let's leave everything as is for now.

Nick