raise error using zig as cross compile

2020-05-20 Thread zhouhaiming
# nim c -f --cc:zig --zig.options.linker:"-target arm-linux-musleabihf" --zig.options.always:"-target arm-linux-musleabihf" hello.nim command line(1, 2) Error: unknown C compiler: 'zig'. Available options are: gcc, switch_gcc, llvm_gcc, clang, bcc, vcc, tcc, env, icl, icc, clang_cl

Re: closure procs with the javascript backend

2020-05-20 Thread dawkot
Did you try adding closure annotation the suspect procs yourself? If it works, you could create a pull request.

closure procs with the javascript backend

2020-05-20 Thread mildred
Hi, I would like to use Nim for javascript related work, and I wonder how I can use event handlers in Nim when the proc I want to register is a closure. Often, the event needs to access external data and gets the `{.closure.}` annotation, and I get the following error from the compiler:

Re: How to implement observer (publish/subscribe) pattern?

2020-05-20 Thread dawkot
This should be enough, you can capture whatever type you want inside a closure. type Publisher = ref object subs: seq[proc(data: int)] Run

How to implement observer (publish/subscribe) pattern?

2020-05-20 Thread Kosteg
The publisher has to maintain the list of subscribers. It's easy to implement if all the subscribers are of the same type (or of the multiple pre-defined types). But is it possible to do not specify all possible types of subscribers?

Re: How can I pass shared memory between threads?

2020-05-20 Thread mratsim
You can implement atomic refcounting with destructors. See what I do in my [multithreading runtime](https://github.com/mratsim/weave/blob/33a446ca4ac6294e664d26693702e3eb1d9af326/weave/cross_thread_com/flow_events.nim#L176-L201): type FlowEvent* = object e: EventPtr

Re: Using generic objects and inheritance at the same time.

2020-05-20 Thread mratsim
I've been fighting with inheritance + generics in the past to implement layers of neural networks. I think your example wouldn't work if a `Dog[Domestic]` and a `Cat[Domestic]` are stored in the same datastructure or if you use the value through a proc declared in another module. In the end,

Re: Using generic objects and inheritance at the same time.

2020-05-20 Thread JohnAD
Off-topic: is there the equivalent of a "when case"? I like that nim checks for missing scenarios when writing "case" statements. I like that nim allows for compile-time code decisions with "when" directives. Putting those together would be spiffy. Not a top-tier feature by any means, but it

Using generic objects and inheritance at the same time.

2020-05-20 Thread JohnAD
After many many hours of trying to make this work, I finally got it to go. I suspect I'm not the only person to struggle with this, so I figured I'd document the answer here. Rather than getting into theoreticals, let's just jump into code. Nim supports inheritance for objects. An example:

Re: Checking the gcc/g++ versions used to compile nim program vs the dyn linked .so

2020-05-20 Thread kaushalmodi
Turns out that this issue was because of some mixup in the LD_LIBRARY_PATH. Once was was fixed, the nim program built with even g++ 9.1.0 links fine with the external_lib_64.so built with g++ 6.3.0.

How can I pass shared memory between threads?

2020-05-20 Thread Keithcat1
Hi, Does Nim have some good ways to handle shared memory? The only way I found was manual memory management, but that can't handle inner references and, hello, that's the reason I'm using a garbage collected language in the first place :D The experimental manual says that the parallel statement

Checking the gcc/g++ versions used to compile nim program vs the dyn linked .so

2020-05-20 Thread kaushalmodi
Hello, Today I came across this run time error when running a nim compiled program that dynamically linked with an external c++ library .so (let's call it `external_lib_64.so`) could not load: external_lib_64.so compile with -d:nimDebugDlOpen for more information

Re: NIM Integration Problems with Server Side Postgres

2020-05-20 Thread panchove
Good news: It worked perfectly !! Thanks to both!

Re: NIM Integration Problems with Server Side Postgres

2020-05-20 Thread JPLRouge
hello:-d:useMalloc| ---|--- I feel like I'm faster, is true

Re: NIM Integration Problems with Server Side Postgres

2020-05-20 Thread panchove
Hello, thanks for answering I compile and link in this way $ (MY_LIB_NIM): * .nim Makefile nim c -d: release --passC: -fPIC --noMain --opt: speed --app: staticlib --outdir: $ (NIM_OUTDIR) --nimcache: $ (NIM_CACHEDIR) --out: $ (basename $ < ) .a --header: $ (basename

Re: NIM Integration Problems with Server Side Postgres

2020-05-20 Thread cdome
Do you compile to shared library? Things to check: You do call NimMain or setupForeignThreadGC. Another thing I recommend trying is to compile with \--gc:arc -d:useMalloc this gives you garbage collection free environment that will ease integration with postgres.

NIM Integration Problems with Server Side Postgres

2020-05-20 Thread panchove
Hello everyone I am trying to integrate two server side test functions with Postgres the first one, nimAddOne (int): int works fine integrate it like this: # AddOne adds one to the given arg and retuns it proc nimAddOne (i: cint): cint {.exportc.} = result = i + 1

Re: Terminal keyboard and mouse

2020-05-20 Thread JPLRouge
change terminal key > ATTN PROC CALL Keyboard simulation done by the program and not by the keyboard → ATTN keyboard simulation →Passes program name to application server → PROC keyboard simulation →Transmits the name of the procedure to be executed in Internal → CALL keyboard simulation

Re: How mature is async/threading in Nim?

2020-05-20 Thread mratsim
Regarding multithreading it really depends on your workload but here are 2 kinds of code architectures that would allow mixing async on threads: 1\. If the part of your code that you want threaded is stateless and only allows the following types to crossover threads: * plain old

Re: Change Nim colour on GitHub

2020-05-20 Thread gemath
> So along with being a neat and clean logo it also encapsulates the roots and > initial goal of Nim. Agreed. Unfortunately, most people -- especially outside of the community -- don't know that. It doesn't get across as what it is supposed to mean and that's not good communication.