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 bit_array.to_string_lossy #800

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

richard-viney
Copy link
Contributor

@richard-viney richard-viney commented Feb 6, 2025

Fixes #797.

The separate version of the function for the JavaScript target is a little bit of an eyesore, but can be removed at some future date once utf_codepoint pattern matching is supported on that target.

Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

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

Thank you!

// target due to not using the `utf8_codepoint` bit array segment type. Once
// the JavaScript target supports `utf8_codepoint` this function should be
// removed.
@target(javascript)
Copy link
Member

Choose a reason for hiding this comment

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

It's a shame so much is needed for JavaScript, and this introduces a new @target, which we have been working hard to remove.

How challenging would it be to have utf8_codepoint support in JavaScript? That seems like it would be a better solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bit array pattern matching in JS would need to be expanded to support dynamic sizes first, then utf_codepoint could be implemented on top of that.

I think it's reasonable to wait for that to happen, or alternatively a @target can be avoided by either using the longer JS-compatible version on both targets (it works fine on Erlang), or by implementing the JS version directly in JS as an external function.

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.

Suggestion: Add bit_array.to_lossy_string() or similar
2 participants