Re: Lambdas?
[https://nim-lang.github.io/Nim/manual.html#procedures-anonymous-procs](https://nim-lang.github.io/Nim/manual.html#procedures-anonymous-procs) just omit the procedure name
Re: Nim source size
Base images for Ubuntu and Alpine don't include GCC ¯_(ツ)_/¯
Re: Nim beginners tutorial
Great work miran! Your Asciidoctor css layout looks nice. I was never fully satisfied with the default Asciidoctor style, and also liked the Asciidoctor Stylesheet Factory themes not really. So I tried tuning them a bit, but was not too successful. It seems you tuned CSS for html, pdf and even the CSS for code listings successful. Looks all nice. I think Dom's book was also written with Asciidoctor, and the initial draft was looking good in ebub and pdf version, but unfortunately Manning made it uglier in the final release, so I newer read the final version.
Re: Can someone help me fill in missing info about Nim's 8 GC models?
@Sixte: > the new keywords owned, sink and lent... As @Araq has explained as a follow-up, they are in the library system.nim, but they aren't explained very well or at all in the library documentation. The best source of documentation for them is [the "destructors" document](https://nim-lang.org/docs/destructors.html). The top part of this page describes Nim's implementation of destructor/assignment/move semantics including sink/=sink (move) and the bottom part the implementation of owned ref, lent, etc. @treeform: > For Destructors what function can I call to free? That's the point, with \--gc:destructors you don't need to call anything to free standard library allocated items that allocate heap space as in string's and seq's as this turns on the generation of =destroy/=/=sink "hooks" for these whose functionality is as described in the above documentation. That said, the default destruction time is when the binding goes out of scope at the end of a proc and if one wants to force destruction, =destroy can be called whenever immediate destruction is desired. For your own allocated pointers, you can tap into this at any time (you don't need the \--gc:destuctors compiler flag) by wrapping them in an object for which you have defined your own custom override versions of these "hooks" that take care of destruction/assignment/move semantics; The compiler flag just makes it available automatically for the standard library structures.
Re: Unexpected error using parseInt
Yes, that may be a bit confusing, there are two parseInt() procs in stdlib. You may go to [https://nim-lang.github.io/Nim/lib.html](https://nim-lang.github.io/Nim/lib.html) and type parseInt into the "search" field. Then you get parseutils: parseInt(s: string; number: var int; start = 0): int strutils: parseInt(s: string): int
Re: Unexpected error using parseInt
You are using the module parseutils instead of strutils. See the [parseutils docs](https://nim-lang.org/docs/parseutils.html#parseInt%2Cstring%2Cint%2Cint). How I found this was using [the index](https://nim-lang.org/docs/theindex.html) and using ctrl-F.
Unexpected error using parseInt
_I get this error on parseInt_ type mismatch: got but expected one of: **proc parseInt(s: string; number: var int; start = 0): int** first type mismatch at position: 2 missing parameter: number expression: parseInt(param)** _but the manual states that parseInt only has one argument:_ [https://nim-lang.org/docs/strutils.html#parseInt%2Cstring](https://nim-lang.org/docs/strutils.html#parseInt%2Cstring)
Lambdas?
i don't seem to find any documentation on lambdas, so far i'm enjoying programming in nim, but i would love to try those multi-line lambdas that nim says it features, so... how do i use 'em?
Re: Nim source size
I think Alpine Linux comes with wget by default, and you can do wget -O - url to achieve the same effect as curl.
Re: Nim for Beginners Video Series
Here i go again ! #4 Live [https://youtu.be/a0qAcCC_Mhk](https://youtu.be/a0qAcCC_Mhk)
Re: Nim beginners tutorial
great ! thanks for the nice PDF version..
Re: Nim source size
> For anyone who want to get in with Nim quickly - use Manjaro Btw, Nim v1.0 has already hit Manjaro Testing branch (only half a day after the release!), and it will be part of the next Stable update. (Bleeding edge Arch still has Nim v0.18, lol)
Re: Nim source size
For anyone who want to get in with Nim quickly - use Manjaro LXDE. I've created myself Bootable USB and when run in Live Nim works out of the box. Mount your home partition (with your Nim folder)and you have your environment ready
Re: Can someone help me fill in missing info about Nim's 8 GC models?
> However, for this purpose, I expected (but failed) to find the new keywords > owned, sink and lent in the lexer's token list. So, if not there, where are > they? Oh simple, they are in system.nim, no need to make them keywords, Nim's syntax is flexible enough to allow for `wordHere T`.
Re: Can someone help me fill in missing info about Nim's 8 GC models?
Does Boehm work for threads and async? For Destructors what function can I call to free? Is it possible to use normal RefC for everything but use region's withScratchRegion for critical sections? @Araq, may I remove v2, generational or stack from the code base? They appear to be disabled and deprecated and not documented.
Shared table with ref objects from different heaps. Will this work?
> I am created a shared table but then each value comes from a ref object > located on a different thread. So in the end globalTable will point to 10 ref objects all from different heaps. Will this cause memory corruptions? import os, collections/sharedtables type Foo = ref object a, b, c: int var globalTable: SharedTable[int, Foo] thr: array[0 .. 10, Thread[int]] proc threadFunc(index: int) {.thread.} = for i in 0 ..< 10: echo index, " ", i globalTable[index] = Foo(a: index, b:i, c:123) sleep(5) globalTable.init() for i in 0 ..< thr.len: createThread(thr[i], threadFunc, i) sleep(1) Run
Re: Accessing Mysql on Windows
I renamed the program - no effect. And yes, its definitely the 64 bit version of the DLL. So, compiling works, I get a exe file. But when I execute it, it can't find the DLL. Are there any parameters I have to add to the compiling process? Or when I execute the app?
Re: Can someone help me fill in missing info about Nim's 8 GC models?
Oh, everywhere I read about Boehm it said is a very conservative algo, like constantly cleaning, so I was thinking it was slow.
Re: Can someone help me fill in missing info about Nim's 8 GC models?
Actually Nim helps Boehm by telling it about "pointer free" data that doesn't have to be scanned. Secondly, the fact that it's conservative scanning over lots of little objects where many words are pointers anyway (can be quite common in compilers ;-) ) can speed up the scanning process. Winning over Boehm isn't so easy on a 64 bit system.
Re: Nim source size
[https://github.com/juancarlospaco/nim-minifyc#minifyc](https://github.com/juancarlospaco/nim-minifyc#minifyc) 路♀️
Re: Nim source size
These 19 MB probably don't include GCC and git and curl and other packages necessary to build Nim.
Re: Nim source size
On Linux, I just run this for deploying Nim at work: [http://ix.io/1X9Y/bash](http://ix.io/1X9Y/bash) It results in a meager 19MB install size.
Re: Can someone help me fill in missing info about Nim's 8 GC models?
In [https://github.com/nim-lang/Nim/blob/devel/compiler/commands.nim](https://github.com/nim-lang/Nim/blob/devel/compiler/commands.nim) , at command line option "newruntime", I could locate `defineSymbol(conf.symbols, "nimV2")` and `conf.selectedGC = gcDestructors` So something like nimV2 and gcDestructors seems to exist. However, for this purpose, I expected (but failed) to find the new keywords `owned`, `sink` and `lent` in the lexer's token list. So, if not there, where are they?
Re: Nim beginners tutorial
Well done! This was one of the resources I used when learning Nim and I'm happy it is continually updated. It's always a struggle when learning a new language and all of the tutorials are outdated. Also, very nice PDF - the design is very clean and easy to read.
Re: Nim beginners tutorial
To celebrate the release of Nim v1.0, the tutorial has been updated. Several typos and errors have been fixed, but the most noticeable improvement is in the [PDF version](https://github.com/narimiran/nim-basics/raw/master/nim-basics.pdf) of the tutorial, which is now much nicer to read, and not just an afterthought like previously. If you prefer the web version, it is still at [https://narimiran.github.io/nim-basics](https://narimiran.github.io/nim-basics)/
Re: object message bus for embedded systems
Damn, yet again I'm facing with binary parsing requirement. Is looks like there is no way is only implement it myself from scratch in Nim, it's a bad perspective. [https://arxiv.org/pdf/1507.06988.pdf](https://arxiv.org/pdf/1507.06988.pdf)
Re: object message bus for embedded systems
> ( don't know detail how memory management is implemented in Nim core Yeah but I do and that's why I'm pointing out to you it's usually simpler than you think.
Re: object message bus for embedded systems
MQTT gives me much more control than raw socket: authorization, encryption, cast groups, pub/sub with different policies (at most one, send for every, buffer if offline,..). But the blob stays the same blob.
Re: object message bus for embedded systems
blobs also require deserialization, how can I know what object must be created every time I see incoming blob? It requires some binary parser which able to do blob decoding and validating, starting from the classical TLV encoding (with first byte/int indicates the object type, then length, value, and CRC to check all before object accepted into the queue).
Re: Nim source size
Haha. I was just going to submit the pull request. I think doc and tests can be removed as well.
Re: Nim source size
Removed `c_code` from the Docker images, which got them **almost three times** thinner, from 1.3 GB to 527 MB. Thanks, @charlieH!
Re: Set Literal Problems
How about something like this: type MyRange = range[0'u8 .. 15'u8] var s = {12.MyRange} Run
Re: Nim source size
Doesn't nim requires openssl and pcre as dependency? It seems you didn't install them in the dockerfile, or are they already included in the nim source itself?
Re: Nim source size
> Just to confirm that I can delete the c_code directory and everything will > function as normal? That is correct, yes.
Set Literal Problems
Consider this code: var x: 0..15 = 12 var s: set[0..15] = {12} Run The first line defining x works fine. The second line defining s fails with this error: /usercode/in.nim(1, 21) Error: type mismatch: got but expected 'set[range 0..15(int)]' Run After some experimentation it seems like a set literal with bare numeric literals inside is always interpreted as a `set[range 0..65535(int)]` unless there's some other variable in there to force the typing. ex: var x: 0..15 = 11 var s: set[0..15] = {x, 12} Run works. Is this a bug/oversight in Nim? Is there a way to specify the type on a set literal? Is there a way to create a range number constant? (apart from `range[0..15](12)` which is quite ugly.)
Re: Nim source size
If you find a way to reduce the installment size, please consider contributing to the Docker images at moigagoo/nimage.
Re: 1.0.0 is here
@jehan: Thanks for the summary on Boehm; thought the disadvantage might be latency, but as you say only a big problem if one does a lot of allocations/deallocations. @Araq: If you are impressed with Boehm (other than if latency is a problem) as compared to the current default, it must be good and it looks like I'll have to try it.
Re: Nim source size
Just to confirm that I can delete the c_code directory and everything will function as normal?
Re: object message bus for embedded systems
What's wrong with sending raw bytes over a socket. Nim doesn't stop you from using blobs, `addr myseq[0], myseq.len * sizeof(myseq[0])` is your friend. ;-)
Re: Can someone help me fill in missing info about Nim's 8 GC models?
Hm. For one of my projects I did a sinful thing: shared objects between threads by pointer. To atone my doings I also set gc mode to 'none'. Is --newruntime really an option for my doings ?
Re: Can someone help me fill in missing info about Nim's 8 GC models?
Boehm is actually often the fastest these days, and it has the best support for shared libraries and threading. Its downside is that it's not for realtime. `--newruntime` is very likely to stay as the much better alternative for `--gc:none`. > Where can I find libbohem.dll for 64 bit windows? I was not able to compile > it from source. They are now included [here](https://nim-lang.org/download/windeps.7z)