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
[stdlib] Add repr()
function and Representable
trait
#2361
[stdlib] Add repr()
function and Representable
trait
#2361
Conversation
0409719
to
09d667a
Compare
Is Upd: It seems |
Signed-off-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com>
09d667a
to
c195ede
Compare
Signed-off-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com>
Signed-off-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com>
Signed-off-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com>
✅🟣 This contribution has been merged 🟣✅ Hey @gabrieldemarmiesse, Thanks so much again for the contribution! 🎉 We're moving to a new infrastructure for merging contributions to Mojo (we're using a tool called Copybara), and your contribution has now been merged into our internal copy of the Mojo Standard Library. I've added the "merged-internally" label on this PR. The changes in this PR will appear here in the mojo repo nightly branch when we do our next outbound synchronization at the time that the next Mojo nightly is released. That should happen within the next 24 hours. Please let me know if you have any questions or concerns. |
Thanks for merging and fixing the conflicts. I made two follow-up issues: |
…#38803) [External] [stdlib] Add `repr()` function and `Representable` trait This PR is a follow up on the discussion there: #2207 There is no `RepresentableRaising` trait yet, this can come later on. We assume here that `42` is the Mojo representation of `Int(42)` because this is how it materializes. Same we assume that `"hello"` is the Mojo string representation of `String("hello")` because StringLiteral materializes into String. We could have used `Int(42)` and `String("hello")` as Mojo representations but that seems very cumbersome and not aligned with the evolution of the language. The discussion is still open for other types. The `__repr__` implementation for String is very simplistic and I believe it's enough as a start, we can push the complexity in other separate PRs (handling `\` and so on). I will open an issue when this PR is merged requesting contributor help to improve it. I will create another issue after this PR is merged to track the conformance of (all?) library types to the `Representable` trait. Co-authored-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com> Closes #2361 MODULAR_ORIG_COMMIT_REV_ID: 82c5e2b83582a61341b8e4a5bfa9d66f7c4f34ab
🎉 🔥 This landed in tonight's nightly release in #2480! Thanks again for the contribution! |
another thing about |
This PR is a follow up on the discussion there:
#2207
There is no
RepresentableRaising
trait yet, this can come later on.We assume here that
42
is the Mojo representation ofInt(42)
because this is how it materializes. Same we assume that"hello"
is the Mojo string representation ofString("hello")
because StringLiteral materializes into String.We could have used
Int(42)
andString("hello")
as Mojo representations but that seems very cumbersome and not aligned with the evolution of the language. The discussion is still open for other types.The
__repr__
implementation for String is very simplistic and I believe it's enough as a start, we can push the complexity in other separate PRs (handling\
and so on). I will open an issue when this PR is merged requesting contributor help to improve it.I will create another issue after this PR is merged to track the conformance of (all?) library types to the
Representable
trait.