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

Add a isiterable trait #23

Closed
davidanthoff opened this issue Feb 21, 2017 · 4 comments
Closed

Add a isiterable trait #23

davidanthoff opened this issue Feb 21, 2017 · 4 comments

Comments

@davidanthoff
Copy link
Contributor

I'm not sure this can be done, but I have a vague idea that with all the new work about world counters etc. it might be feasible to add a trait that checks whether all the functions required for iteration are implemented for a type? I remember we discussed this somewhere before, and back then this didn't work because of the infamous problem in julia that I think is now solved with the world counting stuff.

Having an iterable trait would allow me to go to a much more elegant design in Query.jl.

@mauro3
Copy link
Owner

mauro3 commented Feb 21, 2017

I'm not sure how the word-age stuff could help here, but I know next to nothing about it. The new type-system might. You could try to use method_exists inside a generated function, like described in https://github.com/mauro3/SimpleTraits.jl#advanced-features.

@davidanthoff
Copy link
Contributor Author

See #25.

Next step for me is to understand inheritance of traits, so that I can define a trait IsIterableTable, where I also check whether the element type of the iterator is a subtype of a specific type.

Thanks for the pointer to method_exists, one of those cases where I would have hunted forever, but that made it all really simple :)

@mauro3
Copy link
Owner

mauro3 commented Feb 22, 2017

Cool :-)

There is no inheritance built into SimpleTraits but you can do it by hand, again using generated functions. See the BeautyAndBeast example in the README.

Although the IsIterableTable may not be suitable for base-traits.jl, please post it here if you piece it together.

@mauro3
Copy link
Owner

mauro3 commented Feb 22, 2017

Fixed by #25.

@mauro3 mauro3 closed this as completed Feb 22, 2017
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

2 participants