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

Order of bits within pattern syntax should be documented #661

Open
Ravenslofty opened this issue Dec 13, 2021 · 2 comments
Open

Order of bits within pattern syntax should be documented #661

Ravenslofty opened this issue Dec 13, 2021 · 2 comments

Comments

@Ravenslofty
Copy link
Contributor

Ravenslofty commented Dec 13, 2021

For "pattern syntax" in Case and Value.matches it's not obvious where the least significant bit is in the pattern (first or last character in the string).

It would be nice if the documentation for these functions mentioned the ordering for this.

It might be a silly idea, but I think the order would be more obvious if the string format had an 0b prefix, showing most significant bit first like a Python integer; I don't know how to demonstrate little-bit-endian first like that however.

@modwizcode
Copy link
Contributor

modwizcode commented Dec 14, 2021

I think this is a relatively straightforward documentation improvement? Just to confirm the desire is that the bit on the left of the pattern is MSB and the right is LSB of the value? I believe this matches the way it's implemented.

@Ravenslofty
Copy link
Contributor Author

Ravenslofty commented Dec 14, 2021

When matching against a Python integer, one would use something like m.Case(0bxy), where x is most significant first, so it seems most natural to me to have the leftmost bit be most significant in the pattern syntax too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants