-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
improvements to addInt
and $
for integer types
#18592
Conversation
e7aaa7c
to
e98b337
Compare
e98b337
to
24b94bf
Compare
PTAL |
@Araq ping on this before this bitrots |
Nim devel cannot compile Nim 1.4 or earlier because you removed the magics. This removes more magics and so the problem will be worse. Would be nice if we could think of a solution for this problem; apart from that, I like the changes. |
indeed, after #18531, nim devel can't compile 1.4.0:
note that even before #18531, nim devel can't compile 1.2.0:
requiring that nim devel can compile prior versions prevents much needed simplifications though; plenty of magics (eg And, because compilining 1.4 from devel is not tested in CI, other PRs further break this (eg #11955 which introduces a new compilerProc Note that you already have the means to programmatically find the right nim version with which to build any prior nim version >= #17815 by checking in the bootstrap url+commit hash, and, with nimdigger (#18119), we can build any nim version >= v0.12.0 In short, I'd rather keep simplifying the compiler than require that new nim versions be able to build older nim versions, which adds un-necessary complexity. |
the bare minimum standard here tends to be that each version of the compiler can be compiled by the previous version of the compiler - this allows people with a working compiler to upgrade it to the next version without leaving the language - applying that strategy recursively one can reach any released version from any earlier version. It's somewhat surprising that compiling older versions should be a problem if basic backwards compatibility strategies are adhered to (ie deprecating instead of removing being the most simple one), but it's of course easier to not think about this. |
nim 1.4 can compile nim devel, both before and after this PR.
this doesn't impact backward compatibility for user code |
ping @Araq |
Keep the magics, I enjoy being able to compile 1.4 with Nim devel. (This implies the other removed magics should be brought back too.) |
=> #18708 |
… identical with -d:danger or debug mode
24b94bf
to
171a0d2
Compare
@Araq done, PTAL |
* improvements to $(SomeInteger) and addInt * remove mIntToStr, mInt64ToStr * improvements * fix tests/pragmas/tinjectstmt.nim; the diff is harmless, cgen code is identical with -d:danger or debug mode * rm tests/system/tstrmantle.nim * revert compiler/jsgen.nim for -d:nimVersion140
$
andaddInt
for integer types: instead of hardcoding the logic in the compiler (spread over a whopping> 10
files, with magics, compilerProcs, etc), all the logic is now handled in 1 place for addInt (digitsutils
) and 1 place for$
: (dollars
)x + ""
in js backend (consistent with whatconsole.log
would return), instead of producing wildly inconsistent and non-sensical resultsaddInt
now supports unsigned integer types, avoiding the slowerfoo.add $x
which allocates (see 3x faster digits10 via binary search (speeds up $ for numbers) #18324 which has benchmarks showing, unsurprisingly, that those allocations are costly)toLocation
(avoid allocations, and avoidwhen declared
)addQuoted
for unsigned intsnote:
splitting these tasks in separate PRs would complicate things a lot in this case, due to a number of constraints (in particular some bugs in csources_v1 that prevent certain obvious things from working)