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

Generic typechecked interfaces #7232

Closed
Rageoholic opened this issue Nov 26, 2020 · 3 comments
Closed

Generic typechecked interfaces #7232

Rageoholic opened this issue Nov 26, 2020 · 3 comments
Milestone

Comments

@Rageoholic
Copy link
Contributor

So one thing we do a lot is pass in a type to specialize on. And thanks to std.meta.traits we can write functions that are arbitrarily complex and get a bool back that tells us if it fulfills some requirements. However right now you have to put checking for traits in the function and not as part of the signature. While this isn't the biggest deal I think it would be a good idea to be able to put in a set of boolean expressions evaluated at comptime and if any of them evaluates to false it will result in a compile error that tells you which expressions evaluated to false. This should let us put the compile error at the call site rather than in the function and it removes some code duplication.

@ghost
Copy link

ghost commented Nov 26, 2020

Related: #1669

@tauoverpi
Copy link
Contributor

It would be a bit nicer if it's always invoked @compileError with a human friendly error instead of a bool flag since after a few constraints it becomes difficult to generate meaningful error automatically. #6615 is related and could provide the same thing by @compileError in the function called on the type.

@andrewrk
Copy link
Member

Looks like everything in this proposal is covered by #1669

@andrewrk andrewrk added this to the 0.8.0 milestone Jan 3, 2021
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

No branches or pull requests

3 participants