-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Move typetraits.$ to system. Fixes #5827.
#7100
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
Conversation
|
I don't want it in system.nim. Nor do I want people to |
|
Why is that so bad? Imho easily converting types to strings comes in handy
My most basic use case looks like this: import typetraits
type
Generic[T] = object
a, b: T
proc `$`*[T](g: Generic[T]): string =
# A meaningful string representation should encode T in some way.
# I often want something like this for clarity:
"Generic[" & $T & "](" & $g.a & ", " & $g.b & ")"
let g = Generic[int](a: 1, b: 2)
echo g # Generic[int](1, 2)I just went through a bunch of my typetraits imports and they all where because of this. |
|
I also wondered why the basic For folks like me who like introspection of the code while developing (habit from Emacs lisp), this is a must have. Knowing the type of any variable is a requirement for me to help understand Nim better. I now end up importing typetraits everywhere in my notes: https://scripter.co/notes/nim/. |
|
@kaushalmodi why do you use "intToStr" instead of "parseInt" in your notes? |
|
@Yardanico I use both.. as they are for opposite use cases.. Though I don't know if |
|
@kaushalmodi yes, sorry, I've meant |
|
@kaushalmodi I think intToStr is needed when you need to add leading zeroes to your number |
|
@Araq can you elaborate on what is so bad for this to be in system.nim? I would vote to have this in system.nim. Often when I debug things, I do echo debugging, and it is just nice when it just works on types, too. Currently I always have to look up for that package that I have to import so that echo on the type just works, and that is bothering me. |
Let's continue this off-topic discussion here: https://forum.nim-lang.org/t/3874. |
8966e8b to
9625be1
Compare
|
Based on the reactions: everybody is for this practical change, Araq is against it. What is it gonna be? Merge (after fixing the version number in the comments) or |
I surrender, can be added to system. Once/if the CIs are green, of course. |
9625be1 to
01f2061
Compare
|
Rebased, let's see if that helps. |
|
Fails because of: |
| proc name*(t: typedesc): string = | ||
| ## Returns the name of the given type. | ||
| ## | ||
| ## As of Nim v0.18.0 this is just an alias for `$` which is defined in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before merging, change it to 0.19.2 or 0.20, depending on when this will be introduced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The correct version is 0.20 for this.
|
Makes |
|
fixed test failures, addressed comments and revived in #10071 |

No description provided.