Nim 1.6 is out!!

2021-10-19 Thread timothee
Nice to see that hackernews, reddit posts generate discussions that go beyond the usual suspects of syntax and GC :) * * / *

using readFile at compile time break exceptions

2021-08-26 Thread timothee
This is precisely what would fix.

Print why assert failed?

2021-08-14 Thread timothee
The main difficulty in supporting `assert` to behave like `unittest.require` is how to avoid cyclic dependencies. assert is used in low-level modules, but implementing it to dump variables on failure would require either importing std/macros (causing cyclic deps) or using a few select magics fro

compiling and running nim progam via wine on osx: almost works, help welcome

2021-08-11 Thread timothee
=> see PR

complaining about nim popularity.

2021-08-10 Thread timothee
> the main thing is no direct android/ ios support as people use language which > have direct support for mobile development. please help with CI on those platforms, refs > Bad documentation not true anymore, but things can always be improved; plea

codegendecl on a const

2021-07-31 Thread timothee
Run du -sh /Users/timothee/git_clone/nim/timn/build/nimcache/@mt12666b.nim.c 14M /Users/timothee/git_clone/nim/timn/build/nimcache/@mt12666b.nim.c the object file and binary will be 5MB du -sh /Users/timothee/git_clone/nim/timn/build/nimcache/@mt12666b.nim.c.o 4.9M /Users/timoth

Which macOS installation method for Nim?

2021-07-17 Thread timothee
> git clone -q --depth 1 csources this step is un-necessary (and not even used, since we now use csources_v1). instead, follow docs (: git clone https://github.com/nim-lang/Nim cd Nim sh build_al

Why do `del` and `pop` procedures of TableRef not guarantee operations in one attempt?

2021-07-07 Thread timothee
note that `add` was deprecated, which was IIRC the only way to get dups proc add[A, B](t: TableRef[A, B]; key: A; val: sink B) {.deprecated: "Deprecated since v1.4; it was more confusing than useful, use `[]=`".} Run

Fedora packages

2021-07-07 Thread timothee
> How did you deal with nim doc? That is, where did you put dochack.js and > nimdoc.css? PR welcome to proceed as described here:

Nested string format error:

2021-07-03 Thread timothee
syntax highlight should've hinted you at your mistake, you need to escape `"` or use `"""`

Help for Sending Input Data To REPL

2021-07-02 Thread timothee
try compiling nim to wasm and let us know how far you get

Help for Sending Input Data To REPL

2021-07-02 Thread timothee
not yet, I intend to when I find time though

Help for Sending Input Data To REPL

2021-07-01 Thread timothee
I've developed a similar tool to implement a CAAS (compiler as a service) to implement a REPL (unlike inim, it doesn't recompile everything on each cmd; unlike nim secret, it can use c backend), it uses a client server architecture with a cmdline frontend for the REPL that talks to a backend in

compile with -d:useNimRtl --app:lib cause ambiguous identifier: 'nimrtl'

2021-06-30 Thread timothee
bung, next time please try to make your bug reports more helpful, eg: * show relevant context (nim version used, compilation command, as you now added) * try to minimize as much as you can on your end to minimize dependencies, ideally single module with no imports, or at least only stdlib de

compile with -d:useNimRtl --app:lib cause ambiguous identifier: 'nimrtl'

2021-06-30 Thread timothee
=>

compile with -d:useNimRtl --app:lib cause ambiguous identifier: 'nimrtl'

2021-06-30 Thread timothee
commands to reproduce?

Improving the documentation: Roadmap, community engagement.

2021-06-29 Thread timothee
> I remember when the "Edit" button on our documentation was considered to be > so essential that poor Araq went ahead and implemented it. For years now we > have this nice Edit button on everything. I think we got about 5 PRs in total > more thanks to this button. @araq the main use case (at l

How to get Name and Value from Variable for macro/template

2021-06-29 Thread timothee
see * `tests/compilerapi/tcompilerapi.nim` which might be what you want * `nim secret` seems relevant * `moduleSymbols` () which allows getting all symbols (private or not) from a module, including variables

How to get Name and Value from Variable for macro/template

2021-06-29 Thread timothee
# module1: var name* = "Leon" name = "Blane" # module2: from moduel1 import nil var name = moduel1.name Run

Formatting a float to currency

2021-06-29 Thread timothee
> But the code is pretty bad, both slow and hard to understand.. it can be improved during code review; at least it seems more correct than which I kept breaking during code review

Formatting a float to currency

2021-06-28 Thread timothee
> I was referring to the output of the function, once the float number is > converted to string. still, the sign is useful to have in output (but ok to have option to omit it for 0) > very remote case, not sure if it's really necessary... if this impacts performance, it's not worth it, but it

Sandboxing untrusted Nimscript code

2021-06-28 Thread timothee
> Do not define the nimcore conditional symbol and then the VM does not offer > staticExec/staticRead anymore. @araq this requires recompiling nim, which shouldn't be required for the OP's request. instead, we should have: * `--experimental:vmopsDanger`: allows un-restricted access to APIs (m

Formatting a float to currency

2021-06-28 Thread timothee
> Maybe it could be a good idea never include the sign when the value is 0 (?). the sign is useful, eg: 1/-0.0 = -Inf 1/0.0 = Inf

Formatting a float to currency

2021-06-27 Thread timothee
I like it; would you consider writing a PR? there's a few things I would change in the API but it could be addressed in code review. also, this case fails: doAssert fmtFloat(-0.0, 1, "t") == "-0.0" Run you can use math.signbit, or better, factor out the 1st part wi

Formatting a float to currency

2021-06-27 Thread timothee
see previous attempt here: I still think this would be a useful API, but a new proposal should use the discussions in that PR into account.

Is there a way to write tests & benchmarks for functions operating on NimNode?

2021-06-26 Thread timothee
besides -d:nimHasLibFFI (which currently requires recompiling nim), you also have: * `--benchmarkVM` enables cpuTime at CT * `--experimental:vmopsDanger` enables cpuTime at CT + other procs via vmops * `--profileVM`: a VM profiler showing time spent in user code at CT * vmutils.vmTrace: a

slim - fork version of nimble , handle task level dependency

2021-06-24 Thread timothee
> Maybe we should take this as a sign that the current state of Nimble isn't up > to the community's standard ? maybe this is a sign that nimble needs people to write PRs so we can improve what we have instead of splitting ecosystem.

Nim's float issue?

2021-06-21 Thread timothee
this is now fixed now that we have dragonbox (refs , for results on this, )

Is there a reliable way to round?

2021-06-21 Thread timothee
this is now fixed now that we have dragonbox when true: # D20210513T184615 from math import round let a = round(9.779, 2) doAssert a == 9.78 echo a # before dragonbox: 9.779, after dragonbox: 9.78, like in python3 Run

Binary unicode operators

2021-06-17 Thread timothee
> parsed with the same precedence as +: who's gonna remember that when reading code though? in practice, that'll mean you'll end up adding parens to disambiguate, eg: (a ⊞ (b ∤ c) ⩕ d) Run not only that, but precedence rules are much more complex than just considerin

Binary unicode operators

2021-06-17 Thread timothee
no proc `±`(x, y: int): auto = (x, y) let a1 = `±`(2, 3) # ok let a2 = 2 ± 3 # CT error Run but it's unclear whether it's a good idea to support because: * typing it is awkward on standard keyboards, and likely requires copy paste * some unicode symbols ma

codegendecl on a const

2021-06-17 Thread timothee
this is not a good solution for embedding large binaries as the string encoding blows up by a factor 4X. Really, the correct way is to build upon what I wrote in and make it cross-platform and wrapped with an easy to use API , it's possible and not nece

Nim 2.0 -- thoughts

2021-06-17 Thread timothee
> The mere possibility of offering "continue after a panic" means that the > standard library has to use defer: resource.close instead of the mere > resource.close call. And every other library is better when it does the same Great news to hear we're finally embracing the correct by construction

How to rewrite nim programming langauge to be pythonic as possible?

2021-06-17 Thread timothee
> (bad scoping rules, lack of type safety, design flaws like stateful default > parameters, no multi-line lambdas, lack of case statements) not that i disagree with the general statement but it's good to keep comparisons up to date * python 10 has now not only case statements but also structu

codegendecl on a const

2021-06-17 Thread timothee
there are better ways to embed large binary data in an executable. I think it'd be worthwhile adding APIs to make this easier (both to store and retrieve), this can be useful and it's tricky (but doable) to make this work cross-platform (hence the need for an API to implement it) eg, see: *

codegendecl on a const

2021-06-15 Thread timothee
`codegenDecl` is under-specified and should be improved in meantime this works, however ugly: when defined case2: from strutils import escape let myFile2 {.importc, nodecl.}: cstring {.emit: [""" __attribute__((section("DATA,.myFile"))) const char* myFile2 = """,

strformat on the fly

2021-06-15 Thread timothee
> it's also plain not possible with the way how Nim currently works. Nim is not > a scripting language where every variable is just an entry in a hash table. > Things like variable names etc. are lost once compiled, it's not possible to > look up a variable by it's name with an arbitrary string

Associate an enum with strings

2021-06-15 Thread timothee
type A = enum a0 = "foo" a1 = "bar" or const Names = [a0: "foo", a1: "bar"] Run see also symbolName

documentation for the `do` keyword?

2021-06-14 Thread timothee
the obvious missing feature here is to make keywords/pragmas searcheable in nim doc's search bar + theindex, so that searching for `do` would show the corresponding docs

Proposed table changes - get and getOrDefault

2021-06-14 Thread timothee
> Another way to address both is to have a new 2-body template (I called this > editOrInit in adix/lptabz.nim) there's already `tables.withValue` which I think is what you're describing but it's less flexible than the proposed `getPtr` from , eg see

Improving the documentation: Roadmap, community engagement.

2021-06-13 Thread timothee
As already mentioned multiple times, if you want to improve docs, writing a PR is more productive than complaining about docs here.

Proposed table changes - get and getOrDefault

2021-06-13 Thread timothee
* see for 1st part * see for 2nd part, in which I'm proposing `getPtr` instead of `Option` (see rationale)

lowerBound and upperBoud from module “algorithm”

2021-06-13 Thread timothee
@lscrd please always check devel to see if the problem you're having was already fixed.

Improving the documentation: Roadmap, community engagement.

2021-06-11 Thread timothee
> Nim documentation and manual is supported by devdocs : > / neat, TIL. some aspects are better than nim's docs (, some are worse, ideally these could borrow from each other. where to report bugs and where is the bridge describ

-d:release = awesome

2021-06-07 Thread timothee
`-d:lto` is not portable (eg doesn't work on osx) and doesn't follow best practices (should be a nim flag or be named `-d:nimLto`); until this is fixed, manually `--passc` works (eg `--passc:-flto` works on osx)

Improving the documentation: Roadmap, community engagement.

2021-06-06 Thread timothee
> There should be a coordinated effort with a roadmap, a standard and some form > of a protocol maybe, but in practice, actual PR's tend to be more effective than simply talking about how we need coordinated effort, roadmap, protocol. eg PRs like these:

NimVM eventually get replaced?

2021-06-05 Thread timothee
> I consider the VM's performance to be good enough for most cases maybe, but a 20_000 X slowdown for some tasks (eg ) justifies the need for `{.vmhook.}` (aka user defined vmops). That said, if at least some code needs the VM then the VM still ne

NimVM eventually get replaced?

2021-06-05 Thread timothee
The way I'd do this is which would allow user code to be registered as vmops, which run natively: proc fn(a: int): int {.vmhook.} = # this will be compiled as machine code # and run like a vmops ... Run

How to make Nim more popular

2021-06-05 Thread timothee
> But I don't want to write sum(table.values), I want to have singlie unified > funciton calls convention and write it as`table.values.sum`. it works, i solved this problem with iterable PR (: import std/tables template sum*[T](a: i

Nim JSON parsing is 30 times slower than Node.JS

2021-06-04 Thread timothee
@alexeypetrushin I've investigated this and fixed the performance problem, see now `jsonutils.jsonTo` doesn't have any overhead compared to `json.to` (the PR actually makes a 20x speed improvement compared to before PR)

How to make Nim more popular

2021-06-04 Thread timothee
> And maybe it would be better to avoid things like that > sum(table.values.toSeq) even if it will cause a little more overhead or > complexities in the implementation. As a possible way, maybe call it > differently (until it will be possible to integrate iterators flawlessly) > like table.valu

sequtils insert sink problem

2021-06-04 Thread timothee
> I included another file that imported sequtils please post complete, minimized examples otherwise it's impossible to tell if there's an actual bug or not

compiling and running nim progam via wine on osx: almost works, help welcome

2021-06-03 Thread timothee
finally got it to work! CC=/usr/local/opt/mingw-w64/toolchain-x86_64/bin/x86_64-w64-mingw32-gcc $nimb c --os:windows --lib:lib --cc:env --nimcache:/tmp/c02 -f $timn_D/tests/nim/all/t12357.nim Run (requires a small compiler patch; will make a PR soon)

compiling and running nim progam via wine on osx: almost works, help welcome

2021-06-03 Thread timothee
> I just used choosenim which after running allows me to compile how do you use it for getting windows binaries on non-windows host? eg `~/.choosenim/toolchains/nim-1.4.2/bin` only contains non-windows binaries note that I'm making some progress as follows: `brew install mingw-w64` after that i

compiling and running nim progam via wine on osx: almost works, help welcome

2021-06-03 Thread timothee
thanks, but the problem is how to get gcc.exe in the 1st place, on a non-windows platform (eg on OSX): wine64 winepath -w /Users/timothee/Downloads/nim-1.4.2/bin Z:\Users\timothee\Downloads\nim-1.4.2\bin Run WINEPATH="Z:\Users\timothee\Download

compiling and running nim progam via wine on osx: almost works, help welcome

2021-06-03 Thread timothee
@ElegantBeef thanks; but what do you recommend to get gcc.exe (e.g. from osx), so that it works with wine?

Nim JSON parsing is 30 times slower than Node.JS

2021-06-03 Thread timothee
@alexeypetrushin can you explain? > 1.4.2 without jsonutils -> 1.4.6 with jsonutils (became slower) your snippet uses jsonutils, so how can you compare apples to apples with a version that doesn't have it? please post a version that works with some prior version and is slower in devel than that

Nim JSON parsing is 30 times slower than Node.JS

2021-06-02 Thread timothee
> It seems like JSON in Nim became very slow, after recent update I noticed > that my data processing scripts became slower * slower compared to what nim version? jsonutils didn't exist in 1.2 and the snippet is faster in devel 0de3d4292f328f94c7a94af7e3e61e58ff43a252 than in 1.4.0 * ben

high(Natural) == high(int)

2021-06-01 Thread timothee
@rockcavera this isn't specific to nim, style guides in some other languages also recommend APIs with signed types to avoid wrap-around issues. > Should they only be avoided in this loop situation or in other situations as > well? anytime you can have wraparound as an unexpected edge condition

How does no parenthesis function call syntax work?

2021-05-25 Thread timothee
see the question is: how can we improve things here without introducing parser ambiguties?

Nim version 1.4.8 released

2021-05-25 Thread timothee
> Based on our testing, this shouldn't happen with v1.4.8.

Int/Floating Point Cast Result

2021-05-17 Thread timothee
use `int(x)` ? for a in [0.4, 0.5, 0.6, 1.4, 1.5, 1.6]: echo (a, a.int, a.toInt) let b = -a echo (b, b.int, b.toInt) Run (0.4, 0, 0) (-0.4, 0, 0) (0.5, 0, 1) (-0.5, 0, -1) (0.6, 0, 1) (-0.6, 0, -1) (1.4, 1, 1) (

Implicit line joining rules

2021-05-09 Thread timothee
We should do this: > parser should accept parenthesized (unambiguous) multiline expression

Issue with Nim Manual on Windows Chrome

2021-05-06 Thread timothee
chrome on osx doesn't have this issue Version 90.0.4430.93 (Official Build) (x86_64)

What is the correct way of mapping C functions with return type "const char *"?

2021-05-05 Thread timothee
see also the thread starting here: > How do I express const char* in Nim? Doesn't work for me with clang 3.7.1 either. which evolved into a good solution for expression something like `const char*` (and more generally `const T

Nim doc lists procs by random order?

2021-04-30 Thread timothee
followup here: , PR welcome, this shouldn't be too complex

Assertions in the documentation.

2021-04-30 Thread timothee
this would be entirely covered by , both pre-conditions and post-conditions: proc sleep(t: int) {.requires t>=0.} = ... Run would render the pragma in the doc comment AND (when checks are enabled) would check the condition

XML parsing performance

2021-04-26 Thread timothee
> Hmm, looks like opt:speed might interfere with debugging can you show such example (ideally reduced) ? I could see how that would be the case with `-d:nimStackTraceOverride --import:libbacktrace --debugger:native` (see also: `--passc:"-fno-omit-frame-pointer -fno-optimize-sibling-calls"` refs

How to create const object of non-root object type

2021-04-26 Thread timothee
it works with which should've been merged long ago, IMO when defined case2: type A {.inheritable.} = object a0: int type B = object of A b0: int type C = object of RootObj c0: int cons

some sizeof results

2021-04-26 Thread timothee
relevant issues: * [`array[0, T].sizeof` incorrect · Issue #14786 · nim-lang/Nim]() * [CT sizeof(T) is wrong if T or any member is empty object · Issue #13945 · nim-lang/Nim](https://github.com/nim-lang/Nim/issues/13945) * [sizeof for importc e

Is there a reliable way to round?

2021-04-24 Thread timothee
(ryu) is the proper way to fix this

On term rewriting macros

2021-04-22 Thread timothee
also: * they hide infinite recursion bugs by truncating to a max depth * the syntax is too foreign and not flexible enough (major point against) the TRW general idea is useful though: * optimization (eg: `ret &= a & b & c`) * debugging + other use cases where you want to change behavio

Documentation comments before the item being commented?

2021-04-19 Thread timothee
both these work: const Answer1* = 42 ## doc comment here const Answer2* = 42 ## doc comment here Run if you can't find this in docs, please make a PR

string split by {';'}

2021-04-16 Thread timothee
* repr has indeed a bug as mentioned in * use `echo (e,)`, which works better and doesn't depend on --gc:refc|arc unlike repr: include prelude var s = "foo\rbar\cbaz\lend" for e in split(s, {';'}): echo e echo e.rep

Tables and hashes

2021-04-15 Thread timothee
=> PR

strformat: using a ':' in a string literal possible?

2021-04-14 Thread timothee
Use Devel

conditional expressions don't work in a formatted string

2021-04-14 Thread timothee
this works: import std/strformat let x = 3.14 assert fmt"{(if x!=0: 1.0/x else: 0):.5}" == "0.31847" assert fmt"{(if true: 1 else: 2)}" == "1" assert fmt"{if true\: 1 else\: 2}" == "1" Run and avoids conflicts with format specifier. See

strformat: using a ':' in a string literal possible?

2021-04-14 Thread timothee
this works: import std/strformat let x = 3.14 assert fmt"{(if x!=0: 1.0/x else: 0):.5}" == "0.31847" assert fmt"{(if true: 1 else: 2)}" == "1" assert fmt"{if true\: 1 else\: 2}" == "1" Run and avoids conflicts with format specifier. See

Error: invalid token: trailing underscore

2021-04-13 Thread timothee
you can't, until we reconsider

Trouble with... I don't know :)

2021-04-11 Thread timothee
@japplegame please file a bug under and cross-link it to here; if possible try to minimize to 3 files instead of 4, otherwise 4 is ok

Twitter in 100 lines of Nim, no JS

2021-04-06 Thread timothee
> You write Server code and it magically turned into Interactive FrontEnd UI. doesn't that mean any UI interaction requires talking to the server? if so, I don't see the improvement over karax or equivlent for frontent + some backend

handle "-" and variations as valid input

2021-04-06 Thread timothee
what does `program -shortopt --longopt cmdarg1 -cmdarg2` give? we could define `--` as a separator if needed (grep uses `-e` for that IIRC)

Twitter in 100 lines of Nim, no JS

2021-04-06 Thread timothee
why not leverage karax?

quit considered evil: bypasses `defer` and `try/catch/finally` which might do important cleanups

2021-04-05 Thread timothee
=>

converting a hex string to uint32 in JS context

2021-03-31 Thread timothee
it's just a bug in compiler, IMO, and is fixable; followup: * *

converting a hex string to uint32 in JS context

2021-03-30 Thread timothee
spec: bitwise ops in js are signed (which seems like a bad design decision) see also the correct fix is for nim compiler to insert `>>> 0` note that `>>> 0` i

Are Source Code Filters still needed now that we have strformat?

2021-03-30 Thread timothee
yes, it's trivial to write the control flow logic in separate (reusable!) templates whenever `fmt` falls short; I still think source code filters is a hack that we should deprecate: * makes code less readable / maintanable and doesn't fit with rest of nim syntax * adds some complexity to ni

Mysterious problem with shift left, uint64 and compile-time constants

2021-03-30 Thread timothee
@tord thanks but please always cross-reference (both ways) to help people reading this =>

Safety of staticRead and StaticExec?

2021-03-30 Thread timothee
relevant: * `--experimental:vmopsDanger` which enables certain vmops that can affect reproducible builds * `--experimental:compiletimeFFI` which allows FFI at CT * this PR which attempted to have sandboxed VM as default (but IMO not the right ap

Location of nimdoc.css ?

2021-03-27 Thread timothee
followup

globalThis is not defined although node version is v14.4.0

2021-03-24 Thread timothee
ok; so next step is figure out if it's a user error, or if `findNodeJs` is buggy, or if findExe is buggy (findExe has many bugs, but maybe this isn't related) proc findNodeJs*(): string {.inline.} = ## Find NodeJS executable and return it as a string. result = findExe("

globalThis is not defined although node version is v14.4.0

2021-03-23 Thread timothee
@lotib48819 I can't reproduce your issue, please provide more info: * nim -v * cat main.nim (minimize it first) * which OS, etc * does the generated code (without -d:nodejs) work in browser * node -v (you already did, but double check) * try also running `node main.js` directly with ma

Easiest way of charting module inter-dependencies

2021-03-19 Thread timothee
* try `nim genDepend` * but IMO the best would be separation of concerns, via a `--dump:out.json` `nim cmd --dump:out.json args` which would include compilation side information to out.json, from which another program could extract that information (there is a `nim dump --dump.format:json`

getCurrentDir vs getHomeDir output

2021-03-16 Thread timothee
=>

getCurrentDir vs getHomeDir output

2021-03-16 Thread timothee
IMO it's a bug that should be fixed (with the usual `-d:nimLegacyHomeDir`), upvote PR welcome to see what would break. > `getHomeDir() == getCurrentDir()` note, paths should be compared semantically (with os.cmpPaths) but that's a separate issue.

How can I see all the threads I ahve started or I have contributed to?

2021-03-16 Thread timothee
known issue, please upvote

Retrieve content from a URL under the JS backend

2021-03-16 Thread timothee
jsfetch?

async - noob question

2021-03-15 Thread timothee
=> followup for a proposal on how to improve this

Templating dynlib calls

2021-03-12 Thread timothee
libffi to the rescue? see also how `compiletimeFFI` implemented, which solves a similar problem, at compile time (ie at runtime for nim compiler)

Thorough CI Travis and Azure Pipelines scripts

2021-03-12 Thread timothee
> Let me guess, Bash refuses to use ';' as the path separator even though it's > standard on Windows and uses ':' instead. see: [findExe and getAppFilename are full of bugs · Issue #14292 · nim-lang/Nim](https://github.com/nim-lang/Nim/issues/14292) (sorry to resurrect this, but i was searching

  1   2   >