Skip to content

Unified call syntax#21

Open
erikvalkering wants to merge 46 commits intomasterfrom
unified_call_syntax
Open

Unified call syntax#21
erikvalkering wants to merge 46 commits intomasterfrom
unified_call_syntax

Conversation

@erikvalkering
Copy link
Owner

No description provided.

TODO: the actual implementation.

- Added project to CMakeLists.txt
- Added skeleton for example
- Added (unrelated) experiment for &auto::foo emulation.
In order to add helpers to the invokers to make them point to both the free- and member-function invoker, we need to hardcode the names of the classes. This makes it also a bit easier to follow with respect to debuggability.
- Removed repeatedly defined INVOKER.
- Removed MEMBER_FUNCTION-prefix from infix invoker: it is not a member function.
- Renamed the corresponding class for the above invoker to 'reflector_free_function'. This way, both the member-function exposer as well as the free-function exposer can use the same invoker.
They are already private inside of a class.
Later, this will be given helper function 'as_nonmember()' and 'as_member()', for supporting unified call syntax.
… syntax.

the problem is as follows:

using namespace algorithms;
$(v).sorted();
     \-> on_call() -> call() -> sorted(v)
}
the last sorted() function doesn't know which namespaces it should consider, because what has been inserted in the caller's scope (i.e. using namespace algorithms;) is lost there.

The idea is to register all the namespaces that need to be considered, by inserting a tag type into each of them. Then an additional smart reference is wrapped around the underlying object before calling the actual free-function (i.e. sorted(v)). This smart reference contains as a template argument the inserted tag type. As a result, adl will also consider the tag type's namespace, which is the namespace that contains the correct function. Because the smart reference type implicitly converts to the underlying type, everything works automagically.
This will be needed to make the unified call syntax work.
…llows for including the lookup to include additional namespaces.
- Unused variables.
- Mixing of struct/class for same definition.
Also put them into two separate namespaces, to test multi-namespace support.
- User-defined conversion functions should be defined for all value categories
- Added missing namespace qualifier
- Added several using directives to find the algorithms
Later, this macro will probably be renamed to REFLECTABLE_OPERATOR, because it is generally the default one that should be used.
This, because for REFLECTABLE_OPERATOR() there cannot be a reflector_free_function_invoker.
This is needed in case the member function or free function that is being called captures the parameter as a templatized type, in which case the underlying object will not be pulled out of the adl_finder. In that case, it is very likely that the called function uses the interface of the passed parameter (which is now a smart reference). Therefore, it needs to forward the entire interface, and not only the conversion to the underlying type. Hence, a full-fledged smart reference type is required.
Wrapping non-const lvalue-references is problematic at the moment, and requires a rather major refactoring. Therefore, disable support for those value categories for now, such that we can move forward.
This makes remembering the syntax a bit easier :')
Because of the adl_finder (i.e. the mechanism that enables lookup in registered namespaces), the call() function (the one called by the invoker) will also consider the originally called function, which in turn calls the on_call function, resulting in the infinite recursion.

- Added a mechanism that detects this recursion, and disables the on_call function overload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant