Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace overloading with template specializations. #147

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AnonymousProgrammerLandau
Copy link
Contributor

Define the interface for types in the new types.h. This includes functions like _get, _checked_get and _push as well as _get_n and _push_n. The notion of primitive types, to define types not being able to get a raw pointer to from Lua, is inverted and has changed to is_referenceable.

Split specializations of different kind of types from primitives.h into
separate header files: primitives.h, tuples.h and userdefined.h.

Split specializations of different kind of types from `primitives.h` into
separate header files: `primitives.h`, `tuples.h` and `userdefined.h`.
@AnonymousProgrammerLandau
Copy link
Contributor Author

To fulfill the two new test cases, I started out to correct the order of declarations and definitions for all overloads of _push[1] relative to the definition of _push_n[2]. (_push_n was defined prior to overloads of _push for sel::function.) I quickly found myself splitting headers into separate headers for declarations and definitions. In my opinion that turned out to be quite messy.

By switching to the proposed solution, the order of includes is no longer such a problem. Uses of _push_n within templates do not need the definitions for all specializations. It suffices to have them included by the point the call to _push_n is actually instantiated. In practice that is in code using Selene, which then already has all headers included.

[1] holds also for _get and _checked_get
[2] holds also for _get_n and make_Ref

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