Win10 terminal game

2020-11-17 Thread lqdev
I could squeeze a bit more performance out of a Linux terminal by only updating characters that changed between frames, but the Linux terminal works much differently than the Windows console. In fact, the Windows console is buffered, and can probably be controlled much faster with the WinAPI fu

Passing iterators as arguments

2020-11-17 Thread KnorrFG
But this misses the point a little. I wanted to avoid passing around containers that would then get copied, and pass around iterators instead. In your examples ivec, fvec and dict would get copied, wouldn't they? With the help of the Discord chat, I now ended up defining `toFirstClassIter` like

Win10 terminal game

2020-11-17 Thread Araq
Please teach your child how to write simple games with SDL 2.

GC Safe Problem

2020-11-17 Thread Araq
We will fix the library, of course. As a workaround use: {.cast(gcsafe).}: let x = parseSql(...) Run

Win10 terminal game

2020-11-17 Thread lepot311
Teaching my kid how to program and using Nim as an alternative to Python. Trying to write simple games that output to stdout in windows terminal. But echoing rows of strings, sleeping, and repeating results in the text flowing onto the terminal too slowly, so it appears to be hopping around as i

GC Safe Problem

2020-11-17 Thread SFR0815
Thank you. We did not have an issue with the error messages, though. The issue is that are using parsesql quite a bit within our code and need to get threads running. This breaks because we can't get renderSQL gcsafe. Any idea on how we could get rendersql (resp. parsesql) gcsafe?

are nim exceptions "zero cost" (on error-free execution) ? (if so, `defer` should be used more)

2020-11-17 Thread Araq
I think for the old GCs and big programs the `setjmp` based exceptions can be faster than goto-based exceptions.

ANN: NimDBX, a super-fast persistent key-value store

2020-11-17 Thread snej
New improvements: * Now uses Nimterop to build libmdbx and statically link it, automatically. * Also using Nimterop to generate a Nim wrapper of the C header, instead of my hand-written one. * Added subscript operators on CollectionShortcut as a convenience for creating Cursors.

amysql - Async MySQL Connector write in pure Nim.

2020-11-17 Thread bung
good question! I add history section to project's readme, also paste here. When I starting this project, I have `wiml/nim-asyncmysql` and `asyncmysql` for inspiration, the initial goal is provide basic asynchronous apis compare to Nim std library `db_mysql`'s synchronous apis, `asyncmysql` provi

How to make code GC-Safe when a global constant is used in a proc ?

2020-11-17 Thread jbcomps
My understanding is that strings are sequences of bytes, allocated on the heap, and therefore are cleaned up by GC (?more frequently?). You could also do a `deepCopy` : import prologue import nwt ## To just set up threadvar and initialize per thread. var globa

How to make code GC-Safe when a global constant is used in a proc ?

2020-11-17 Thread jbcomps
Ah. OK. This may help Also lines 21-23 and line 26

How to make code GC-Safe when a global constant is used in a proc ?

2020-11-17 Thread mildred
The problem occurs when you try to use the library in a `{.gcsafe.}` environment when threads are disabled. Threads enabled, I suppose the use of thread local variable is helping. Outside of `{.gcsafe.}` context, there is no problem.

How to make code GC-Safe when a global constant is used in a proc ?

2020-11-17 Thread jbcomps
Yes. I gathered as much by the OP. Building and running with 1.4.0 and 1.5.1 with `nim c -r --threads:on client.nim` works flawlessly for me on Windows 8.1.

How to make code GC-Safe when a global constant is used in a proc ?

2020-11-17 Thread juancarlospaco
`let SERVER_FIRST_MESSAGE_VAL = create Peg` ?.

a DSL to construct Nim AST based on karax

2020-11-17 Thread slonik_az
The `min` macro is wrong. To see it try assert min("d", "c", "b", "a") == "a" Run The assertion fails because the macro returns "c". I just filed an issue

GC Safe Problem

2020-11-17 Thread mildred
The error message is quite understandable... The `ra` procedure is not gcsafe because it calls `rs` which itself is not gcsafe. `renderSQL` is not gcsafe because it calls `ra` which is not gcsafe. To understand why a procedure might ot might not be gcsafe, you should add `{.gcsafe.}` to it and

How to make code GC-Safe when a global constant is used in a proc ?

2020-11-17 Thread juancarlospaco
That dot is kinda secretly optional, but is best practice to use it anyways.

How to make code GC-Safe when a global constant is used in a proc ?

2020-11-17 Thread mildred
I got it wrong, when I replace `let` by `const` the code does not compiles.

How to make code GC-Safe when a global constant is used in a proc ?

2020-11-17 Thread juancarlospaco
`.gcsafe` ?, `isolation` ?,

How to make code GC-Safe when a global constant is used in a proc ?

2020-11-17 Thread mildred
The linked code solves GC safety when compiled with threads. The problem is that my procedure requires gcsafe even when not compiled with threads. The code: when compileOption("threads"): var SERVER_FIRST_MESSAGE_VAL: ptr Peg SERVER_FINAL_MESSAGE_VAL: ptr Peg

How to make code GC-Safe when a global constant is used in a proc ?

2020-11-17 Thread jbcomps
When cloning the repo in question, changing the `let` to `const`, and building with nim version `1.4.0` and `1.5.1 (devel)`, I get the following. No errors. test 1 passed test 2 c=biws,r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,p=v0X8v3Bz2T0CJGbJQyF0X+HI4Ts= passed

are nim exceptions "zero cost" (on error-free execution) ? (if so, `defer` should be used more)

2020-11-17 Thread juancarlospaco
Should `setjmp` be deprecated?.

How to make code GC-Safe when a global constant is used in a proc ?

2020-11-17 Thread jbcomps
Looks like the code is missing a closing `.` for the pragma on line 36. `proc prepareFirstMessage*(s: ScramClient, username: string): string {.raises: [ScramError].} =` vs `proc prepareFirstMessage*(s: ScramClient, username: string): string {.raises: [ScramError]} =`

How to make code GC-Safe when a global constant is used in a proc ?

2020-11-17 Thread mildred
Replying to myself. gcsafe is needed because otherwise a global variable could be collected by multiple threads. Is there a way to mark an object as immutable and impossible to collect so it could be shared between threads ?

Nim based Firmware -- it's tiny!

2020-11-17 Thread b3liever
You can use the `.nodestroy.` pragma to prevent it. See [smartptrs](https://github.com/nim-lang/fusion/blob/400c77be4f39b77302cabf19951b25dfc85bfce9/src/fusion/smartptrs.nim#L35) Same trick is also used in seq's [add](https://github.com/nim-lang/Nim/blob/devel/lib/system/seqs_v2.nim#L110)

How to make code GC-Safe when a global constant is used in a proc ?

2020-11-17 Thread mildred
Hello, Since I upgraded my code to 1.4.0 and updates some dependencies, I have issues with my code. I have a warning that it is not gc-safe. Investigating (by adding the gcsafe annotation), I found out that a library I'm using is not gc-sage. Here is the code:

Possible usage of Nim & Z3 for embedded?

2020-11-17 Thread moerm
Btw, there have been found north of 1000 bugs in Z3 and other solvers are unlikely to be much better. Maybe we need a solver written in Ada, F star or at least in Nim ...

Nim based Firmware -- it's tiny!

2020-11-17 Thread elcritch
> Thanks a lot! Now I want to wet my feet in microcontroller programming with > Nim :-) Any tips or tutorials for a beginner? Oops, sorry missed your question. [Nesper](https://github.com/elcritch/nesper/) is based on the ESP32 programming sdk (called ESP-IDF). They have a pretty good [programm

amysql - Async MySQL Connector write in pure Nim.

2020-11-17 Thread pwernersbach
This is cool. When I wrote , I had to introduce a lot of scaffolding code to use Qt's synchronous C++ MySQL library, as there was no better MySQL library available in Nim. I'm tempted to resurrect

a DSL to construct Nim AST based on karax

2020-11-17 Thread b3liever
It's now in fusion! Docs at: Get it with nimble: `nimble install fusion@#head` or `./koch --latest fusion`

Getting random non-equal int pairs, comparison of routines.

2020-11-17 Thread Vindaar
They already do share the exact same scale, ranging from 900 to 1100. Hence why most are ~yellow. Or do you mean the opposite that each has an independent color scale?

Empty proc body

2020-11-17 Thread moigagoo
I believe the parens are optional, too. func doNothing = discard Run

Getting random non-equal int pairs, comparison of routines.

2020-11-17 Thread Zoom
That's super cool. Is it possible to modify the results so all the graphs would share the same temperature scale?

Empty proc body

2020-11-17 Thread b3liever
`proc doNothing() = discard ` Run

Passing iterators as arguments

2020-11-17 Thread Sixte
> And how would I do that? Take this: import tables iterator vecitems[S](x:openarray[S]) : S = for y in x: echo "k ",y yield y iterator tabitems[A,B]( vtb : Table[A,B]) : B = for a,y in vtb : yield y #proc v

Error: system module needs: appendString

2020-11-17 Thread AlectronikHQ
Thanks, I tried JackOS now - they fixed the first issue but I get another one: Error: system module needs: nimErrorFlag Afaik we don't yet have a more advanced kernel around in Nim, do we?

Empty proc body

2020-11-17 Thread moigagoo
Just put a discard statement there.

Empty proc body

2020-11-17 Thread vitaliy
Hi all! Silly question: how can I define a noop proc? proc doNothing(): = Run And what should follow?

Empty proc body

2020-11-17 Thread moigagoo
Also the colon is redundant.

Nim's rst parser now supports markdown tables

2020-11-17 Thread miran
Funny, I didn't even notice that my second rst table is wrong - I didn't change the number of `=`'s. The way it is written, the contents of the first column of the last row will be `"I need "`. Here is the correct version: == Header 1

are nim exceptions "zero cost" (on error-free execution) ? (if so, `defer` should be used more)

2020-11-17 Thread AmjadBHD
>Quote

are nim exceptions "zero cost" (on error-free execution) ? (if so, `defer` should be used more)

2020-11-17 Thread spip
@timothee, I know that this thread is talking about exception but perhaps the revised documentation should precise that `defer` works with exception scope. `defer` code won't run at closure iterator end of scope like in the following example. import os proc bar(name: strin

Error: system module needs: appendString

2020-11-17 Thread xflywind
These is also a fork version of nimkernel. It may be useful.

Error: system module needs: appendString

2020-11-17 Thread Araq
Try to compile with `--gc:arc --os:any -d:useMalloc` or with `--os:any -d:StandaloneHeapSize=1048576` (heap of 1 MB). But I don't remember what nimkernel uses and needs. > Same errors with nim 1.2.0 (the oldest version I was able to get, 1.1.0 gives > a 404) There is no 1.1.0, it would be the

Error: system module needs: appendString

2020-11-17 Thread AlectronikHQ
Hi, I've tried to build nimkernel (, a tiny OS kernel written in nim & compiled with --os:standalone. It fails with this error message. I have asked there but seems like the project has been abandoned, and since it concerns nim in general and other projects

Nim's rst parser now supports markdown tables

2020-11-17 Thread miran
If you're using Nim devel (v1.5.1), you're not limited anymore to use just rst tables in your documentation: === Header 1Header 2 === Content More content Foo Bar Baz Quux

a DSL to construct Nim AST based on karax

2020-11-17 Thread b3liever
Yes I'm aware, I fixed it's compilations errors and borrowed the idea from breeze readme. I thought it would be easier to start over by modifying karaxdsl.

Gedit syntax highlighting.

2020-11-17 Thread b3liever
KDE editors (kate, kwrite, kdevelop and other qt applications) have [nim syntax highlighting](https://github.com/KDE/syntax-highlighting/blob/master/data/syntax/nim.xml) in the official repo since August!

Open-ended slices

2020-11-17 Thread doofenstein
instead of nil you could use something like this: type PositiveInf = object NegativeInf = object proc `..`(a: typedesc[NegativeInf], b: int) = discard proc `..`(a: int, b: typedesc[PositiveInf]) = discard which then can be used like this: 0..Posit

Passing iterators as arguments

2020-11-17 Thread KnorrFG
> However, structural expansion of the template "in place" might still be an > interesting alternative. And how would I do that?

Kill thread?

2020-11-17 Thread elcritch
> In general, killing threads is considered a bad idea. The problem is that the > thread stops at some arbitrary point and can’t clean up things like locks or > file descriptors or whatever. If you work around this by making the thread > raise an uncatchable exception, so that stack unwinding ca

are nim exceptions "zero cost" (on error-free execution) ? (if so, `defer` should be used more)

2020-11-17 Thread moigagoo
Huh, my reaction after reading the updated doc was a complete opposite: I now want to rewrite `try-finally` blocks in Norm into `defer` 😂 I didn't know it was called at the end of the call site block, I think it's a nice feature ¯_(ツ)_/¯