How to use SharedList

2021-05-05 Thread Araq
> E.g., I haven't heard anything from Mamy since 4 weeks. Has he fallen ill, or > doesn't he have any time to maintain Weave any more. He's alive and well but very busy. :-) > So, there must be some confidence that a PL and its essential libraries will > be maintained in the future. Certainly,

Add a JS-backend only option to nim.cfg

2021-05-05 Thread Araq
Because the global nim.cfg contains @if release or danger: stacktrace:off excessiveStackTrace:off linetrace:off debugger:off line_dir:off opt:speed define:release @end Run and is processed **before** your custom config file,

Is anyone using duckdb with Nim?

2021-05-05 Thread Araq
Nim's `dealloc` is not C's `free`! You need to call C's free: proc free(p: pointer) {.importc: "free", header: "".} free(p) Run

Add a JS-backend only option to nim.cfg

2021-05-05 Thread Hlaaftana
I believe you have to do: @if js: define:release @end Run With a `.nims` file: if defined(js): --define:release Run This might need `when` instead of `if`, but I'm not sure.

Add a JS-backend only option to nim.cfg

2021-05-05 Thread halloleo
I use `~/.config/nim/nim.cfg` to adjust the default compiler options. In there I would like to set the `-d:release` option, but only when the JS backend was selected. Is this possible in the `nim.cfg` file?

How to http post nested data?

2021-05-05 Thread jackhftang
[multipart/mixed](https://www.rfc-editor.org/rfc/rfc2046.html#section-5.1) actually allow different mime type per part, but current `MultipartEntry` implementation do not support it.

How to http post nested data?

2021-05-05 Thread xioren
I need to use json but the post procs only accept MultipartData/Entries.

Is anyone using duckdb with Nim?

2021-05-05 Thread sdmcallister
The following code works.. my understanding is that memory doesn't need to be allocated or freed: var res: duckdb_result if duckdb_query(con, "SELECT * FROM integers", addr(res)) == DuckDBError: echo "Error" # 3 Rows for row in 0..<3: # 2 Col

How to http post nested data?

2021-05-05 Thread treeform
HTTP does not support nested data, so you need to use some thing like json (how @juancarlospaco shows) or some other http encoding scheme (maybe like dotted keys`?keyA.keyB=valueB`) to send it.

How to http post nested data?

2021-05-05 Thread juancarlospaco
{"keyA": """{"keyB": "valueB"}"""}

How to http post nested data?

2021-05-05 Thread xioren
I am trying to make a post request with nested data, {"keyA": {"keyB": "valueB"}} Run however MultipartEntries only accepts strings. MultipartEntries = openArray[tuple[name, content: string]] Run Am I missing something?

No difference between asyncHttpClient and httpClient?

2021-05-05 Thread b3liever
You actually need an `AsyncHttpClient` per request: proc asyncHttp() {.async.} = echo "Async started" for i in 0 .. 30: let client = newAsyncHttpClient() let resp = await client.get("http://example.com";) echo resp.status ech

No difference between asyncHttpClient and httpClient?

2021-05-05 Thread alexeypetrushin
> Async calls aren't related to cpu speed (like for loops are), instead they're > related to network connection and response time within a timeout (sync calls > usually will wait forever if there is no response) Doing for loops like those > in the example above are unconsistent, because suppose

How to use SharedList

2021-05-05 Thread shirleyquirk
> \--gc:orc was a game changer| > ---|--- indeed, the initial code (with minor edit) works with gc:arc/orc. import sharedlist import os import sugar var thr: array[0..1, Thread[void]] var list: SharedList[string] list.init() proc thredA(

setControlCHook

2021-05-05 Thread Clonk
Ah indeed, I forgot to remove my debug echo.

No difference between asyncHttpClient and httpClient?

2021-05-05 Thread enthus1ast
These are export markers, these fields will be accessible from another module when imported.

No difference between asyncHttpClient and httpClient?

2021-05-05 Thread talaing
Thanks, worked perfectly :D This is literally my first time using Nim and I'm already impressed how friendly and helpful the community is. Do you know by any chance what do these asterisks mean?

setControlCHook

2021-05-05 Thread Araq
I definitely don't meant: proc stop*() {.noconv.} = echo("SIGINT receive") shouldRun.store(false) Run As you cannot use `echo` either in a signal handler. ;-)

No difference between asyncHttpClient and httpClient?

2021-05-05 Thread Symb0lica
I think you need to remove the **await** in let statuscode = await result.status Run

No difference between asyncHttpClient and httpClient?

2021-05-05 Thread enthus1ast
Have a look at the AsyncResponse Type. There you see that status is just a string (not a future) so just access result.status (without await, you only await future types)

How to use SharedList

2021-05-05 Thread HJarausch
@Araq "you're much better off with external Nimble packages" That's a problem (with any PL). E.g., I haven't heard anything from Mamy since 4 weeks. Has he fallen ill, or doesn't he have any time to maintain Weave any more. Hopefully this isn't the case, but if it is, anybody who has built his s

No difference between asyncHttpClient and httpClient?

2021-05-05 Thread talaing
That works well. But how can I print status code when response is received? This doesn't seem to work: import asyncdispatch, httpclient, times proc httpInfo(client: AsyncHttpClient, url: string): Future[AsyncResponse] {.async.} = result = await client.get(url) l

setControlCHook

2021-05-05 Thread Clonk
I think this is what Araq meant: import std/[atomics, os] var shouldRun: Atomic[bool] shouldRun.store(true) type ThreadArg = tuple[name: string, argint: int] proc stop*() {.noconv.} = echo("SIGINT receive") shouldRun.store(false)

setControlCHook

2021-05-05 Thread FabienPRI
@ggibson : I tried your code and with nim 1.4.6, ctrl_c_handler is not called, under Windows 10 I am not sure to be clear. So let's try to explain it another way: I have a web server in the main thread, that uses a sqllite db I need to create a thread as a background worker that do heavy work,

How to use SharedList

2021-05-05 Thread hankas
On a related note, how come the following code works: import threadpool, locks type SyncList = tuple [ lock: Lock, list: seq[string], ] var list: SyncList list.list = newSeq[string]() initLock(list.lock) proc setA(l: ptr SyncList) =

Counting word frequencies with Nim

2021-05-05 Thread cblake
Hilarious! Well, it is a common design/re-design/iteration problem. :-)

Counting word frequencies with Nim

2021-05-05 Thread Araq
> It is true that my wf.nim is imperfect (I never meant to suggest otherwise). Ha, I didn't look at your `wf.nim` and didn't mean to criticize it, I only made some general remarks.

No difference between asyncHttpClient and httpClient?

2021-05-05 Thread enthus1ast
i would try to create another async function that awaits your http response and prints a message when its done. Then you would queue not the http calls but your function.

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

2021-05-05 Thread kaushalmodi
@timothee Thanks for those pointers. I don't know how I can use this with my svdpi module though. 1. The proposed `constChar` type looks like something that should ship with Nim in system or some std lib. If I introduce this new type in svdpi, I need to export that type as the svdpi API is us

Counting word frequencies with Nim

2021-05-05 Thread cblake
Well, ok, page replacement dynamics (and control thereof) can be real issues. Very true, but very "algo dependent". :-) Many read all the input like DB "full table scans" while others can save. There are also things like `madvise` on Unix. Your argument can find support from _other_ things that

No difference between asyncHttpClient and httpClient?

2021-05-05 Thread talaing
Thank you, that works well, but there is one problem. Is there any way to print response right after it's received? Code that you shown me, first sends all the requests and after that prints the responses. How can I print the response right after it's received? Also how to print response text? (

How to make HttpServer more robust against too many connection opened?

2021-05-05 Thread DomoSokrat
`serve` has an optional argument `assumedDescriptorsPerRequest` which defaults to `-1`. From the docs: > If `assumedDescriptorsPerRequest` is 0 or greater the server cares about the > process's maximum file descriptor limit. It then ensures that the process > still has the resources for `assume

How to use SharedList

2021-05-05 Thread Araq
> Really? Ok, so channels are the only (or main) way to support concurrency > going forward? There should be an article or something official that states > this. Unless I missed it. No, channels are far from the only thing we can offer. `--gc:orc` was a game changer, allowing for techniques tha

Counting word frequencies with Nim

2021-05-05 Thread Araq
I knew you would bring this up... Ok, true, however: chances are that too many different pages are kept alive when all you really reference from the page might be a couple of bytes which you should have copied into a different memory region.

How to use SharedList

2021-05-05 Thread nnahito
Thank you for your answer. I have successfully completed the implementation as I requested! Thank you very much.

How to use SharedList

2021-05-05 Thread jasonfi
Really? Ok, so channels are the only (or main) way to support concurrency going forward? There should be an article or something official that states this. Unless I missed it.

How to make HttpServer more robust against too many connection opened?

2021-05-05 Thread alexeypetrushin
But shouldn't the server be robust and don't fail? Like it could refuse to take new connection, or maybe drop old, but not crash.

Counting word frequencies with Nim

2021-05-05 Thread cblake
Mostly agreed on broader custom code/type checking points, but a minor correction, lest people needlessly fear mmaping TB-scale files: the file/FS areas behind mmap serve as the swap/pagefile for the data, just file-named, not anonymous. So, it should not fail with less RAM. It does get slower s

How to make HttpServer more robust against too many connection opened?

2021-05-05 Thread giaco
you're probably hitting user limit for your operating system if linux base, what's the output of $ ulimit -n Run ?

How to make HttpServer more robust against too many connection opened?

2021-05-05 Thread alexeypetrushin
Is there a way to make HttpServer more robust? Like if too many connections opened it should fail but maybe somehow find oldest unused connection and close it, or refuse the new connection or something like that? Currently it would fail. import os, asyncdispatch, asynchttpserver, h

How to use SharedList

2021-05-05 Thread Araq
Good idea, done.

A pure nim GUI game for Linux & Windows

2021-05-05 Thread ThirdChild
Awesome! It's great to see people using Nim to edit and create their games. I'm also working on a new 3-D game similar to temple run and it's been helping me a lot.

nim update & choosenim

2021-05-05 Thread FabienPRI
No worry, just a miss of luck to be the one that experienced this issue, bit it gets fixed quickly, so that's ok. For production use, be able to do an update to the last stable version from an existing installation is a real need, because most of the time, that is what NIM users need to do, eve

nim update & choosenim

2021-05-05 Thread Araq
Well I'm sorry, but the move to a different mingw wasn't untested, we tested it for weeks, we have a CI, we test plenty of 3rd party libraries and it didn't occur to me that C header files would be removed. Also the move to a different mingw also fixed existing bugs so it was justified to do it

How to map a JS dictionary paramter in the Nim importjs header?

2021-05-05 Thread halloleo
@DomoSokrat @Hlaaftana Thanks a lot for the info. I guess I have to study `jsffi` in more detail… (Still, _discovery_ of unknown syntax doesn’t seem to be easy for me just from the type/function reference line on the module page.)

How to use SharedList

2021-05-05 Thread Zoom
Put a deprecation header there. I think those articles still got read regularly.

How to use SharedList

2021-05-05 Thread Araq
> There's an example of a shared Table at the end of this article: > Stop it please, that article is outdated and makes my finger nails coil...

Counting word frequencies with Nim

2021-05-05 Thread Araq
In practice, in my experience, when these things start to matter (= when you consider which PL to pick) is when you have lots of data, so your oh-so-efficient O(1) slices into mmap'ed memory **fail** as there is not enough RAM available... ;-) So you need to use streaming and your stdlib's `spli

How to use SharedList

2021-05-05 Thread jasonfi
There's an example of a shared Table at the end of this article: I read an article about channels being high performing in Go when there were a large number of threads. Benchmarking will guide you.

Sequence item del vs. delete?

2021-05-05 Thread Neodim
Got it, thanks. But then what is a special purpose of such function?

Sequence item del vs. delete?

2021-05-05 Thread ElegantBeef
When order doesnt matter and you want a performant method for removing an element. Since it just moves a single element to the index to remove it's cheaper than moving all elements after the one you removed down a single index.

Sequence item del vs. delete?

2021-05-05 Thread doofenstein
it's in the documentation as well. for delete: > Deletes the item at index i by moving all x[i+1..] items by one position. > > > This is an O(n) operation. for del > Deletes the item at index i by moving all x[i+1..] items by one position. > > > This is an O(n) operation. so del is faster, b

nim update & choosenim

2021-05-05 Thread FabienPRI
I've copied include/zconf.h include/zlib.h lib/libz.a and it seems to work again. Did try yet the compile part of my project but should work I will try it later. updating compiler within the same 1.4 version list is quite a big change, may be it could be better to postpone this type of update f

nim update & choosenim

2021-05-05 Thread FabienPRI
OK, before my choosenim try, I've got all in C:\nim-1.4.0 now it seems that choosenim put things in C:\Users\xxx\\.choosenim\toolchains I will try to copy missing parts from older mingw install to C:\Users\xxx\\.choosenim\toolchains\mingw64, is it the right thing to do? I like a lot the languag

Sequence item del vs. delete?

2021-05-05 Thread Araq
Not a bug, documented here:

How to use SharedList

2021-05-05 Thread Araq
I think you're looking for "channels".

nim update & choosenim

2021-05-05 Thread Araq
We updated the mingw and apparently it doesn't ship with `zlib.h` anymore. I'm not sure. :-)

Sequence item del vs. delete?

2021-05-05 Thread Neodim
hello, just faced curious issue: var a = @[1,2,3,4,5] a.delete(0) echo a # returns @[2, 3, 4, 5] as expected Run while var a = @[1,2,3,4,5] a.del(0) echo a # returns @[5, 2, 3, 4] which is little bit confusing Run

nim update & choosenim

2021-05-05 Thread FabienPRI
I was running nim 1.4.0, so I decided to move to 1.4.6 using choosenim It seems to work weel but in fact when I tryed to compile my software, I've got an error from gcc: C:Userspoirier.nimblepkgszip-0.3.1zipprivatelibzip_all.c:34:10: fatal error: zlib.h: No such file or directory 34 | #in

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