What's the preferred way to compile nim to WebAssembly?

2021-01-18 Thread srbga
Thank you! That's a lot better than aborting directly!

What's the preferred way to compile nim to WebAssembly?

2021-01-18 Thread srbga
I can contribute some contents regarding WASM (for example, the WASI part is not yet present in treeform's tutorial), though I rarely login to Github so I rarely make PRs.

What's the preferred way to compile nim to WebAssembly?

2021-01-18 Thread srbga
Thank you! I've solved my problem. It's slightly different from the scenario in your tutorial because I'm not running the wasm in a browser, but in a WASI environment, which has its own challenge. I'm glad it's working now. BTW: Your jsony is very sweet, I like it :)

What's the preferred way to compile nim to WebAssembly?

2021-01-18 Thread srbga
Yes, true. Another example is the "nim-debug-example" github repository from which I learnt how to debug with vscode. We can probably collect these topics first and people can "maintain through version updates" only the parts they use often.

What is the best way to override a generic method?

2021-01-18 Thread aredirect
Thank you! they're nice books indeed, yup your code is much cleaner than the one I've in closures branch (which works now) also with some help on telegram apparently my problem was caused by `Constraint` was defined as `object` and not `ref object` which broke the generic methods somehow. It fee

What is the best way to override a generic method?

2021-01-18 Thread b3liever
Hello @xmonader, I see you got the Copec book. It's a nice book, we should port all the samples to Nim. Generics and methods don't mix together. Here is how I solved it with closures: Hope it helps!

What is the best way to override a generic method?

2021-01-18 Thread aredirect
I'm trying to implement a constraint satisfaction framework, already done [here](https://github.com/xmonader/pycsf/blob/master/csf/__init__.py) in python. I tried to port the same code to nim So what I came up with is a `Constraint` type that I inherit later on based on the problem and override

What's the preferred way to compile nim to WebAssembly?

2021-01-18 Thread saem
Even if they get a little stale, that's not entirely a bad thing as little things like that are an easy contribution for people new to Nim. That fix they make is the initial seed of volunteering and becoming an active community member. Anyhow, maybe Nim by Example as a starting point and it can

how to detect Chinese character with regex?

2021-01-18 Thread jiyinyiyong
Thanks. `(*UTF8)` fixes the code. I actually glanced that at but didn't even realized it was related.

how to detect Chinese character with regex?

2021-01-18 Thread jrfondren
The key text in your quote is "In UTF-8 mode", which is never explained. There should be a flag that you can use as well, but with reference [pcreunicode](https://www.pcre.org/original/doc/html/pcreunicode.html), this works: import re echo "中文".match(re"(*UTF)[\x{4e00}-\x{

how to detect Chinese character with regex?

2021-01-18 Thread jiyinyiyong
I was trying some pattern from other languages: echo "中文".match(re"[\x{4e00}-\x{9fa5}]+") Run And I got error: /Users/chen/.choosenim/toolchains/nim-1.4.0/lib/impure/re.nim(102) re /Users/chen/.choosenim/toolchains/nim-1.4.0/lib/impure/re.nim(78) rawCo

Any way to access the Documentation Comment of a procedure?

2021-01-18 Thread cblake
Re: the edit - It's right at the start of the README. I just tried to make it more clear. The default program help doc is lifted from the doc comment of the wrapped proc, just as here (but directly off of `getImpl` since A) `extractDocCommentsAndRunnables` did not exist when I wrote `cligen` and

What's the preferred way to compile nim to WebAssembly?

2021-01-18 Thread benob
I have been using this: and that:

Portable binaries with Nim - what works?

2021-01-18 Thread ggibson
@drkameleon my empathies because Apple does not make this easy. In fact, the community has created a repository of old SDKs because Apple fails to make them available () . Even so, this was a pain to figure out since I don't have a mac and yml-push-run-ch

Help with Nim concurrency – data not persisted

2021-01-18 Thread 0x100
Thanks @PMunch, that makes sense. I'll play around with the different `gc` options in addition to enhancing this sample to have more guarantees. Thanks for the tip @xigoi, that's a miss on me for not reading the docs in detail... :P

What's the preferred way to compile nim to WebAssembly?

2021-01-18 Thread wiltzutm
Perfect. IMHO this kind of tutorials should be linked somewhere in the nim lang page, so one shouldn't be forced to search the nim forum for old and scattered answers. Althought I dunno who is willing to maintenance those tutorials through version updates...

Help with Nim concurrency – data not persisted

2021-01-18 Thread xigoi
BTW, you can replace this: (if f.data.hasKey(k): f.data[k] else: -1) Run with this: f.data.getOrDefault(k, -1) Run

Help with Nim concurrency – data not persisted

2021-01-18 Thread PMunch
As QMaster points out Nim `spawn` will deeply copy the element. That being said it's not a great idea to have a table with strings in a shared structure. Those strings will be owned by whichever thread created them, and the thread might free that memory if it finds it is no longer in use (in tha

Help with Nim concurrency – data not persisted

2021-01-18 Thread 0x100
@Recruit_main707 > IIRC arc's/orc's heap is shared, so your original code should (?) work with > it? You should try it, ptrs are not bad, but you can avoid the casting and > stuff. Ah you meant avoid casting in both `read` and `write` procs, yep, those seem to be redundant :)

Help with Nim concurrency – data not persisted

2021-01-18 Thread xigoi
In this specific case, you could use a [shared table](https://nim-lang.org/docs/sharedtables.html).

Help with Nim concurrency – data not persisted

2021-01-18 Thread 0x100
Thanks for the tip, I'll have a look.

Help with Nim concurrency – data not persisted

2021-01-18 Thread 0x100
I'm not sure I understand, do you mind elaborating a bit more? Maybe a code sample too :)

Help with Nim concurrency – data not persisted

2021-01-18 Thread Recruit_main707
IIRC arc's/orc's heap is shared, so your original code should (?) work with it? You should try it, ptrs are not bad, but you can avoid the casting and stuff.

Help with Nim concurrency – data not persisted

2021-01-18 Thread 0x100
Thank you @QMaster! That was it, here's the updated example for reference: # nim c -r --threads:on -d:debug example.nim import tables, locks, threadpool type Foo = object of RootObj lock: Lock data {.guard: lock.}: Table[string, int]

Portable binaries with Nim - what works?

2021-01-18 Thread PMunch
In general you should be able to compile a program on one machine and send to others. You can even cross-compile from one machine to other machines and architectures. For example I build Windows 64 and 32 bit versions from my 64 bit Linux machine for distribution. Keep in mind though that you ha