Skip to content

meta_context and skip documentation #1853

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

Merged
merged 5 commits into from
Jul 11, 2025
Merged

meta_context and skip documentation #1853

merged 5 commits into from
Jul 11, 2025

Conversation

stephenberry
Copy link
Owner

@stephenberry stephenberry commented Jul 10, 2025

@Yaraslaut, when creating documentation for this new skip functionality, I realized that what we implemented only currently affects writing.

Skipping can also apply to reading. And, I think in some cases we want to only skip writing or only skip reading.

Here are the two approaches I'm thinking of taking.

First option is to simply name the function skip_write and a skip_read could be added later.

static constexpr bool skip_write(const std::string_view key) {
    return key == "internal_member";
}

The downside of this approach is that if we wanted to skip both reading and writing then we'd need to implement both functions or have a third function just called skip, but having three separate functions complicates the internals of Glaze.

The second option is to make the skip function templated on whether it is a read or write:

template <bool IsRead>
static constexpr bool skip(const std::string_view key) {
    if (not IsRead) {
       return key == "internal_member";
    }
    return false;
}

I'm leaning towards this second option. What are your thoughts?

@Yaraslaut
Copy link
Contributor

I think having one function is better, but the issue with the template arguments that I see is that user has to see it all the time, I personally would try to add an additional argument to the function aka "context" which the user can use it to figure out if this is a read/write or something else, furthermore the context can be easily extendable

@stephenberry stephenberry changed the title skip documentation meta_context and skip documentation Jul 11, 2025
@stephenberry
Copy link
Owner Author

@Yaraslaut, I implemented a new meta_context that is passed to the skip function. Right now it just provides information about whether the operation is parsing or serializing, but more meta information could be added in the future, as per your suggestion. Thanks for recommending this, I think it's a great approach! I also implemented support for skipping when reading.

@stephenberry stephenberry merged commit df05b35 into main Jul 11, 2025
25 checks passed
@stephenberry stephenberry deleted the skip branch July 11, 2025 13:43
@Yaraslaut
Copy link
Contributor

Thanks for the documentation, i also think that this is a great approach :)

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.

2 participants