[lucy-dev] Wrappers for Obj functions

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[lucy-dev] Wrappers for Obj functions

Nick Wellnhofer
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
Reply | Threaded
Open this post in threaded view
|

Re: [lucy-dev] Wrappers for Obj functions

Nick Wellnhofer
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