Re: About include
Let's look at a minimal code sample which reproduces the compiler error: template foo*(sFoo: untyped) = type A = object str: string sFoo foo: echo A(str: "hello").str Run Type definitions inside a template are by default invisible to code from the instantiation scope (or gensym ed, see the manual chapter @Hlaaftana linked). `sFoo` comes from the instantiation scope, thus the error, which can be avoided by giving `A` an `{.inject.}` pragma. When the definition of `A` is included instead, the `include` is apparently resolved after template substitution: `A` is not defined in the template body, but immediatly inside the instantiating context.
Re: About include
You are doing "interesting" things. First, I can not remember having seen nested templates at all in Nim, at least I never used that construct. And putting a include inside a template is also "interesting". >From my memory an include should be identical to copying the content at that >location.
Re: About include
https://nim-lang.org/docs/manual.html#templates-hygiene-in-templates
About include
My understanding is that `include` is like `template` but for file: in-place code replacement, just like C `#include`. I broke my big file into small includes, and now inapprehensible errors pop up... This example presents the reverse of what I see with my code: big file compiling while includes don't. **myinclude.nim** type A = object str: string template conc(s1: A, s2: string): string = s1.str & s2 Run **foo.nim** template foo*(sFoo: untyped) = block: include myinclude template bar(sBar: untyped) = echo "In bar" sBar echo "In foo" sFoo echo "completed foo" foo: bar: echo conc(A(str: "hello"), "world") Run This compiles and outputs In foo In bar helloworld completed foo Run Now, if instead of including the file, I copy its content replacing the `include myinclude`, to get **foo.nim** template foo*(sFoo: untyped) = block: type A = object str: string template conc(s1: A, s2: string): string = s1.str & s2 template bar(sBar: untyped) = echo "In bar" sBar echo "In foo" sFoo echo "completed foo" foo: bar: echo conc(A(str: "hello"), "world") Run It does not compile anymore, with `Error: undeclared identifier: 'A'` What does `include` do exactly? _Also as a side note, if you don 't declare the type ``A``, Nim compiler optimize the string concatenation and both versions compile..._
Re: NOOB: WINIM is causing my linker to throw an error ...
It's precisely what is going on and the fix could be something like `res2obj file.res` and link the `.obj` file instead.
Re: Nim goes multithreading, Pt. 2: SQLiteral
Sweet this is welcome and thoroughly appreciated . Keep em coming
NOOB: WINIM is causing my linker to throw an error ...
Hi, I try to compile a little tool with CLANG (it works with the default compiler). Apparently the file **winim-3.3.3\winim\lib\winimx64.res** or winim-3.3.3\winim\lib\winim64.res is the problem. ANY object file (.o) after it will throw an error of: > fatal error LNK1107: invalid or corrupt file: cannot read at My guess is that the ".res" files are pre-compiled with a DIFFERENT compiler and thus my CLANG linker is "confused" ? Any help /ideas ? Thanks Robert
Ways to retain users to a mobile application
By the help of looking into data can help you evolve your mobile application based on use needs. Not only is it going to refine the application but help it deliver adept user experiences that are going to make a difference to the users. You must also keep in mind to hire a mobile app developer that has knowledge and understanding of mechanisms that contribute to building users. Through these mechanisms you can choose to send notifications to the users and remind them of your application. Are there any other methods to retain users? [https://www.360digimarketing.com/services/mobile-app-development](https://www.360digimarketing.com/services/mobile-app-development)
Re: Nim zmq binding and poll function
Ah yes that was the cause of the problem. I reported the bug here : [https://github.com/nim-lang/nim-zmq/issues/14](https://github.com/nim-lang/nim-zmq/issues/14) I have a fork of nim-zmq where I added some examples, I can fix the problem and submit a Pull Request.
Re: Nim zmq binding and poll function
I updated my reply, your definition of `TPollItem` didn't match its C declaration.
Re: Nim zmq binding and poll function
Something like this: type TPollItem* = object socket*: PSocket fd*: cint events*: cshort revents*: cshort poller*: pointer proc poll*(items: ptr UncheckedArray[TPollItem], nitems: cint, timeout: clong): cint{. cdecl, importc: "zmq_poll", dynlib: zmqdll.} template asUncheckedArray(a): untyped = cast[ptr UncheckedArray[typeof(a[0])]](addr a[0]) var a: array[2, TPollItem] a[0] = TPollItem(socket: d1.s, events: ZMQ_POLLIN) a[1] = TPollItem(socket: d2.s, events: ZMQ_POLLIN) # Poll on 2 element starting at adress p1 var res : int = poll(asUncheckedArray(a), 2, 1) echo res if res >= 0 : var res1 = bitand(p1.revents, ZMQ_POLLIN.cshort) var res2 = bitand(p2.revents, ZMQ_POLLIN.cshort) echo "res1:", res1, " && res2:", res2 Run
Nim goes multithreading, Pt. 2: SQLiteral
Topic of previous post was StashTable, a thread-safe in-memory key-value store. I have added more tests to it to ensure soundness of data structure. StashTable will be available at Nimble central repository as soon as nimble gate-keepers will accept my pull request. But in-memory data is usually not enough. Today I'm happy to announce SQLiteral: a multithreading SQLite API for Nim, at [https://github.com/olliNiinivaara/SQLiteral](https://github.com/olliNiinivaara/SQLiteral) It's a tasteful mixture of Nim code, SQLite pragmas and other ingredients to combine following features "in parallel": * Parallel access, using WAL mode * Avoids possibility of SQLITE_BUSY * Supports optimize and vacuum * Prepared statements, prepared for you at open and finalized at close * All statements can be logged with parameters substituted * Bind statically to sqlite3.c of your choice * Proper typing, as seen in tiny_sqlite by gulpf * And more... In forthcoming part 3, the topic will be a multithreading integrated HTTP/1.1 + WebSocket v13 server, implemented on top of the new Weave runtime. Stay tuned!
Nim zmq binding and poll function
Hello, I'm trying to use the poll function of the ZMQ (version 4.2) binding. In C (and C++) you just pass an allocated array of zmq_pollitems_t and the length. I tried doing the Nim equivalent : var p1 = cast[ptr TPollItem](alloc0(2*sizeof(TPollItem))) # Allocate memory for 2 TPollItem object var p2 = cast[ptr TPollItem](cast[int](p1) + cast[int](sizeof(TPollItem))) # Get the start adress of the second object p1[] = TPollItem(socket: d1.s, events: ZMQ_POLLIN) # Write first in the memory adress p2[] = TPollItem(socket: d2.s, events: ZMQ_POLLIN) # Write second object in the memory adress var res : int = poll(p1, 2, 1) echo res if res >= 0 : var res1 = bitand(p1.revents, ZMQ_POLLIN.cshort) var res2 = bitand(p2.revents, ZMQ_POLLIN.cshort) echo "res1:", res1, " && res2:", res2 Run But it only works for the first TPollItem (i can swap the socket used in the TPollItem so I know it's not a connexion problem) and I never get a POLLIN flag set in p2. Also, on the same subject, the Nim pollitem are defined as follow : type TPollItem*{.pure, final.} = object socket*: PSocket fd*: cint events*: cshort revents*: cshort poller*: pointer proc poll*(items: ptr TPollItem, nitems: cint, timeout: clong): cint{. cdecl, importc: "zmq_poll", dynlib: zmqdll.} Run What is the pointer poller ? In C it is just defined as a struct : typedef struct { void* //socket//; int //fd//; short //events//; short //revents//; } zmq_pollitem_t; int zmq_poll (zmq_pollitem_t *items, int nitems, long timeout); Run
Re: Automated Nim Packages Security Audit
> malicious actor can always check if it's being run under some tool like this Yes, or simply leave a vulnerability around that can be later exploited.
Re: Just a VSCode question
With the latest freshness ... It gets better I read a lot of fixes on GIT
Re: Just a VSCode question
i have no such issues. i am using the visual-studio-code-bin package - there is a vscode-OSS, and a vscode-git package,, and maybe an appImage exists for download too. later i used the appImage, and tried the others, but ...code-bin worked for me the best. :-? ((maybe a HW issue?))
Re: Idea: Nim Online Conference
Also, if you would like to give more than one talk, that is entirely possible — just fill [the form](https://forms.gle/6TKMiRZ2bP5DyUyZA) multiple times.
Re: ggplotnim - pretty native plots for us
@Vindaar, I am working on doing some bindings to [gr-framework]([https://gr-framework.org/)](https://gr-framework.org/\)). My bindings are not mature, but I believe it could be a better option that using Cairo. I have created both animations, images, ... in both windows and pictures. It could be a better way to abstract the backend. One of the main problems I am facing is documentation.
Re: ggplotnim - pretty native plots for us
Sorry about that. When I started writing this I had no idea cairo would be such a pain on Windows. There's an issue about it here: [https://github.com/Vindaar/ggplotnim/issues/57](https://github.com/Vindaar/ggplotnim/issues/57) I haven't updated the README yet, mostly because I don't have a good solution either yet. The easiest for me on a practical level was to just install emacs and add it to my PATH (which is I guess equivalent to you using the Inkscape libraries). I guess I can think about either adding working versions of the required libraries to the repository for windows (at least win64) or a script which clones the cairo repository and builds it locally. I haven't built cairo locally yet, so I don't know if it works well. Now regarding your actual question. If you want to ship a program, which uses ggplotnim internally, you have to do what people do on Windows as far as I know: bundle all required DLLs with the program. The other alternative would be a static build of cairo. I'll see what I can do to improve the situation. Thanks for the input!
Re: ggplotnim - pretty native plots for us
Do you have instructions on how to properly package a program that uses this library? I managed to get ggplotnim working on my windows system, but it was harder than I’d like. I downloaded the gtk libraries and placed them on the executable folder but that did not work. In the end what worked was copying the dll of another gym based program (Inkscape) into the ggplotnim-based executable. It’s be nice if the library came with some tool that helped you collect the libraries it needs or if there was a way to create stand-alone executables.