-
Notifications
You must be signed in to change notification settings - Fork 68
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
Create eep-0063.md: Lightweight UTF-8 binary string literals and patterns #46
Conversation
Btw, have you considered using |
@TD5 It is possible to create a bytestring type as: -type nonempty_bytestring() :: nonempty_list(byte()).
-type bytestring() :: list(byte()). Adding a bytestring type into Erlang/OTP would be helpful, as part of this. If the compiler knew it was UTF-8, it could have a special type separate from a bytestring, but similar (like |
I hadn't considered it, but it sounds reasonable. I don't myself have a preference. Either could be fine in my view. Why might |
No particular reason in isolation but I think it matters when it comes to concepts like interpolation, because you need a stronger indicator to know if you are interpolating a list of bytes or a list of characters and I believe the |
Not sure how relevant Python is for Erlang here, but its UTF-8 string literals (when introduced) are written >>> type("foo")
<class 'str'>
>>> type(b"foo")
<class 'bytes'>
>>> type(u"foo")
<class 'str'> For Erlang in theory I think both would fit - it is UTF-8 and the binary type - but when I think "bytes", I think some binary data that goes over the wire - when I think "UTF-8", I think some user-facing string. So as a small outside voice I'd vote for |
For myself, So I'd prefer to have |
Has EEP 66 (now PR #55) obsoleted this PR? |
I believe so 🙂 |
Actually, I am now sure that covers patterns, only literals? |
Did you mean "not sure"? It isn't stated in EEP 66, but sigils are a syntactical sugar (transformation) that happens before the parser tries to figure out what is a pattern. In general the parser may transform a sigil into any expression, for instance for string interpolation call a formatter. Then subsequent compilation steps will see that it cannot be in a pattern. But for the suggested
|
Yep, I meant "not sure", but I glad to heard this is handled now 🙂 |
No description provided.