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

isleaf is isempty #54

Closed
wants to merge 4 commits into from
Closed

isleaf is isempty #54

wants to merge 4 commits into from

Conversation

CarloLucibello
Copy link
Member

implement the suggestion in #52 (comment)

Fix #52

test/basics.jl Outdated Show resolved Hide resolved
test/basics.jl Outdated Show resolved Hide resolved
src/Functors.jl Outdated Show resolved Hide resolved
@CarloLucibello
Copy link
Member Author

CarloLucibello commented Nov 28, 2022

I don't see why we shouldn't do this. I think that [], (), (;) and Dict() can be safely considered as leafs

@ToucheSir
Copy link
Member

It would be pretty breaking, because we use exclude = isleaf to decide what to pass to map function callbacks. Code that never expected to encounter an empty (non-numeric) array or dict before is now going to have to deal with them. At a higher level, making two possible paths for particular types based on their contents over just types blows up any chance of us making traversals type stable and introduces additional overhead for users (who will now have to detect and guard against random empty arrays/dicts which they're not interested in. Distinguishing those from parameters would not be fun!)

As I mentioned in #52 (comment), the safer path seems to be limiting and not broadening the scope of isleaf so that we have fewer priveleged types.

@CarloLucibello
Copy link
Member Author

right, I clearly didn't think it through.

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.

empty namedtuple is not a leaf
2 participants