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

Generify functions and userdata types #3

Merged
merged 5 commits into from
Jun 24, 2017
Merged

Conversation

kroepke
Copy link
Owner

@kroepke kroepke commented Jun 21, 2017

the rationale is that typically functions receive a well-defined list of argument types
and require either an ArgumentIterator to peel out the values or directly cast their
parameters to the specific type.

Not only is that error prone, it also required duplicate work all over the place.
By allowing to specify the argument types no such casting is required for the common case
as the simple type parameter allows IDEs to properly create method signatures.

The same applies to userdata, which is very often used to expose Java classes into Lua.
In those cases the types are well known to the programmer and no helper fields, type casts or
other checks are required, because the user data is already encapsulated.

Thus the boilerplate required is reduced and the user code becomes clearer.

the rationale is that typically functions receive a well-defined list of argument types
and require either an ArgumentIterator to peel out the values or directly cast their
parameters to the specific type.

Not only is that error prone, it also required duplicate work all over the place.
By allowing to specify the argument types no such casting is required for the common case
as the simple type parameter allows IDEs to properly create method signatures.

The same applies to userdata, which is very often used to expose Java classes into Lua.
In those cases the types are well known to the programmer and no helper fields, type casts or
other checks are required, because the user data is already encapsulated.

Thus the boilerplate required is reduced and the user code becomes clearer.
use them if the types of the parameters aren't known, or you don't want to use generics
this is syntactic sugar to avoid having to spell out the type parameters every time

migrate internal usage to untyped abstract functions where applicable
@kroepke kroepke changed the title initial work to generify functions and userdata types Generify functions and userdata types Jun 24, 2017
@kroepke kroepke merged commit 27d61e2 into master Jun 24, 2017
@kroepke kroepke deleted the generic-interfaces branch June 24, 2017 15:09
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