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

support encoding core booleans #62

Merged
merged 1 commit into from Apr 3, 2022
Merged

Conversation

haarg
Copy link
Contributor

@haarg haarg commented Apr 1, 2022

Perl now has support for tracking boolean values. Use this to encode
perl booleans as json booleans.

Perl now has support for tracking boolean values. Use this to encode
perl booleans as json booleans.
@haarg
Copy link
Contributor Author

haarg commented Apr 1, 2022

This replaces #55, only including encoding of core boolean values.

return builtin::is_bool($_[0]);
}
return !!0;
}

sub true { $JSON::PP::true }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It there a reason for not making these two functions return native bools?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #63. It would be unwise to use native bools unless the application is equipped to deal with them everywhere.

Isn't !!0 a native bool (in perl versions where they exist)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!!0 is a native bool, and both is_bool and isa should be returning native bools.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, if you were referring to the true and false functions, that is because many things expect the bools coming from JSON::PP to be JSON::PP::Boolean objects. For now, I've left those unchanged for backwards compatibility. Also, this PR is only meant to deal with encoding. #63 exists to start dealing with decoding.

@charsbar charsbar merged commit d35f6d7 into makamaka:master Apr 3, 2022
charsbar added a commit that referenced this pull request May 21, 2022
This reverts #69, #63, and #62 that are based on builtin features for now, not to surprise people when Perl 5.36 is out.
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.

None yet

4 participants