what does bycopy mean

2021-11-14 Thread leorize
`{.bycopy.}` means that the structure will always be passed via a copy in Nim, which is C semantics. As such you will see it on structures used to interoperate with C code.

Safe `enum` conversion

2021-07-05 Thread leorize
> To be honest a isValidFor function that takes an enum type would be nice to > have in the stdlib.

IRC freenode staff exodus

2021-06-14 Thread leorize
> I think only he can invite people at the moment (or maybe it's because things > are still a bit buggy?) The address for the Nim spaces is: [#nim:envs.net](https://matrix.to/#/#nim:envs.net), and there are currently 12 rooms within the space. Once you join however, you will likely only see 2-

nimsuggest, neovim, nim.nvim trouble

2021-05-25 Thread leorize
Please run `nimsuggest --version`

nimsuggest, neovim, nim.nvim trouble

2021-05-25 Thread leorize
> I had to remove the plugin anyway because the semantic highlighting was > terribly slow. If you ever try the plugin again, can you try adding this to your init.vim? let g:nim_highlight_wait = v:true Run The main thing it does is to only update highlighting after you

Querying on support to CPS development by compiler devs

2021-05-21 Thread leorize
Thanks for confirming. I have tagged several issues under the new `CPS` tag.

Querying on support to CPS development by compiler devs

2021-05-21 Thread leorize
@Araq I am working on [cps](https://github.com/disruptek/cps). Support was [promised](https://github.com/nim-lang/RFCs/issues/295#issuecomment-744277794) for this endeavor, and I would like to know what is the status of this and whether you still stand by that decision.

IRC freenode staff exodus

2021-05-19 Thread leorize
> as far as I know #science is just another channel of freenode with the > corresponding bridges on other services (discord, gitter, matrix). I do not > know of anything different with respect to other channels (maybe less IRC > only users?). #science is bridged directly to discord from matrix

void return type

2021-03-30 Thread leorize
> Is it recommended to use void "type" for procs that do not return a value? > (for the sake of explicitness) No, idiomatic Nim simply omits the return type part. The biggest usage for `void` is in generics, for example type Future[T] = object # Hold a value that migh

How to best access a potentially const variable in a func that is to big for default stack?

2021-03-26 Thread leorize
AFAIK `const` arrays are inlined into the executable and won't take up any stack space (unless you perform a copy to stack, which you're not doing in this example).

Manually initializing exception handling

2021-03-22 Thread leorize
You should call `NimMain()`, which will initialize the GC (yes, `--gc:none`'s seq/string still uses the GC, even if the GC doesn't collect). Alternatively you can use `--gc:arc` or `--gc:orc` instead.

Help needed: Deadlock during allocShared0

2021-02-04 Thread leorize
Yea but it's still using `add()`, which may grow the string.

Help needed: Deadlock during allocShared0

2021-02-04 Thread leorize
The bug is the attempt to allocate memory in an asynchronous signal handler... Signal handlers are like threads but spawned at random points while pausing the thread it's running on. Most code are not and cannot handle this stuff, which is totally understandable. POSIX has a strict definition of

Help needed: Deadlock during allocShared0

2021-02-03 Thread leorize
Are you allocating any memory in the signal handler? If you do, that's the problem.

Why is my program so much slower in Nim than in Rust?

2020-12-22 Thread leorize
I ran some profiling with `callgrind` and found that the `sqrt` "calls" (thes are significantly slower when compiled with `gcc` instead of `clang`: * `clang`: `sqrt` took 4.94% of the runtime, or 27,410,400 units, with other costs being similar to gcc (total program cost 554,136,425 units).

Why is my program so much slower in Nim than in Rust?

2020-12-22 Thread leorize
Can we have the source of the Rust version as well?

NodeJS for Nim

2020-12-18 Thread leorize
This should be a good example of how to use npm with nim.

NodeJS for Nim

2020-12-18 Thread leorize
Hopefully you find this useful: It's a node wrapping macro I made for wrapping Github Actions' toolkit, see how to use here:

replace OpenSSL with statically linked LibreSSL Windows

2020-12-07 Thread leorize
As far as I know, `.lib` files are just stub used for dynamic linking with the dll (you can't "link" directly with a DLL on Windows, instead you either load it at runtime in your code or use the `.lib` stubs). Static archives on Windows share the same `.a` suffix as *nix, however they are almos

Why is reading lines from stdin so slow for me?

2020-12-01 Thread leorize
> Why is that top-level code is not optimized? Simply put, we just don't have anyone volunteering their time into making that happen. The walkaround is really simple (wrap the code in a proc), so the issue is low-priority and development time is spent elsewhere. > I do not know how the compiler

Is there an easy way to bake in parameters at compile time?

2020-11-25 Thread leorize
I'm pretty sure `static[T]` is what you want, quoting the [manual](https://nim-lang.org/docs/manual.html#special-types-static-t): > For the purposes of code generation, all static params are treated as generic > params - the proc will be compiled separately for each unique supplied value > (or

SSL error using httpClient

2020-10-31 Thread leorize
What OS are you running? And what is your OpenSSL/LibreSSL version?

design of large modular projects in nim?

2020-10-25 Thread leorize
> There isn't much which can be done wrong, except for the one nimsuggest > process/per file relict vscode-nim has which doesn't happen if a project file > is specified (admittedly finding the project file can be done mostly > automatically). Yep that's the issue. VSCode can't do it automatical

design of large modular projects in nim?

2020-10-25 Thread leorize
> Apparently, Araq has pointed out that nimsuggest actually does track includes > properly, but editors do not often make use of this feature. Bummer. But this > would enable the 3.B solution, reducing the hoop-jumping by one layer :) AFAIK only nim.nvim and nimlsp uses nimsuggest correctly :P I

Passing data between threads with ARC

2020-10-23 Thread leorize
Here's a bit of magic sauce I found in stdlib channels' implementation: It appears to me that `wasMoved` is a handy little [proc](https://github.com/nim-lang/Nim/blob/f8890a0804b6d05

Passing data between threads with ARC

2020-10-22 Thread leorize
I think this should help: A version of this feature has already shipped in 1.4 and can be used via `import std/isolation`.

Writing binary data to SQLite

2020-10-21 Thread leorize
We can always extend db_sqlite :p There's ndb which is db_sqlite but with prepared statements: And @Araq's ormin is pretty cool too:

[Docker Image] GCC /bin/sh:: file not found

2020-10-21 Thread leorize
You may want to open a bug report at the docker image upstream repository: .

How to avoid deprecation notice for libraies supporting multi-version of Nim?

2020-10-20 Thread leorize
The code in lrucache isn't a template though, it's a generic proc.

Regarding the future of --gc:none and --gc:regions

2020-10-20 Thread leorize
I was actually wondering about the "memory regions" feature in the type system: type P = (ptr object) ptr Region Run AFAICT it was removed because no one found it useful?

Regarding the future of --gc:none and --gc:regions

2020-10-19 Thread leorize
> adds debug checks so that you don't create invalid cross-region pointers... Sounds like a return for the long gone memory regions feature? I didn't follow Nim closely at the time to know why it was phased out, though.

How to avoid deprecation notice for libraies supporting multi-version of Nim?

2020-10-19 Thread leorize
Thanks, I've pin pointed the issue and opened [#15650](https://github.com/nim-lang/Nim/issues/15650) to track it. Currently there is no walkaround for this issue so you'll have to wait until the issue is fixed.

Views of a non thread local var

2020-10-19 Thread leorize
> 1\. Why is this not allowed? The manual doesn't explain it. (also the link in > the error message both doesn't work and why it doesn't work is described in a > different section) The anchor is now `#view-types-path-expressions`, I suppose the error message wasn't up-to-date. > 2\. Is my work

How to avoid deprecation notice for libraies supporting multi-version of Nim?

2020-10-19 Thread leorize
Hmm, what version of Nim are you running? I tried to make a small reproduction of the issue on the playground but there were no deprecation warnings:

Regarding the future of --gc:none and --gc:regions

2020-10-19 Thread leorize
Yes but at that point you can just use a memory pool and those are not hard to implement (see the implementation linked in my previous message). The memory pool can be used side-by-side with ARC/ORC and provide speed up for only the type of objects that need them due to heavy allocation/dealloca

Ubuntu, snap install, "Error: cannot open file: strutils"

2020-10-19 Thread leorize
> First of there's a prefix on all of the nim cmds like "nim-lang.nim, > nim-lang.nimble" etc. That's how snap work, so you can't change that unfortunately. The snap versions are not provided by the Nim project but is instead maintained by members of our community. I'd recommend you to raise an

Regarding the future of --gc:none and --gc:regions

2020-10-19 Thread leorize
> In the other tests however, regions was slightly faster, and it seems to have > a clear advantage when it comes to threads. It's very simple, really. Regions doesn't free the memory since you're not making and/or destroying regions. The best optimization for this use case is to use a memory p

Version 1.4.0 released

2020-10-18 Thread leorize
I started a thread some time ago to keep track of ideas to improve the front page: Unfortunately I've not found the time to spend on actually making a PR to [nim-lang/website](https://github.com/nim-lang/website) to update the wording.

Impressive results with --gc:orc

2020-10-18 Thread leorize
I don't think it makes too much of a difference if you're using `--exceptions:goto`, but might provides considerable boost if `--exceptions:setjmp` is used. `--panics:on` allows the compiler to stop assuming that all procs can throw, as all `Defect` will then be compiled down into `quit()`. Thi

1.4.0 failed with old-ish gcc because of NIM_STATIC_ASSERT bug

2020-10-18 Thread leorize
Please report bugs on Nim's [issue tracker](https://github.com/nim-lang/Nim/issues) so we can track and let you know if the bug is fixed. AFAICT support for older gcc is also a priority in Nim as we aim for embedded support (where there are odd versions of gcc everywhere).

Forcing a memory leak in Nim

2020-10-17 Thread leorize
It turns out that `valgrind` can only function if it could replaces libc's `malloc` calls (see this [FAQ](https://www.valgrind.org/docs/manual/faq.html#faq.hiddenbug)). The page explicitly said that static linking and/or custom memory allocators are not supported by valgrind. This should answer

Forcing a memory leak in Nim

2020-10-17 Thread leorize
> I am stil curious, however, why it does not leak with --gc:refc -d:useMalloc. > Can you explain why this is? Only `--gc:arc` and `--gc:orc` supports `-d:useMalloc`. > Does Nim use its TLSF allocation even when the memory is a `ptr`? Yes. If you're wondering, TSLF is just a memory allocator (l

Help me to configure (neo)vim, please

2020-10-11 Thread leorize
> The only thing left not working is asyncomplete, i leave it for later, that's > not annoying (C-p is still working, so…) That's weird, maybe you can try `ncm2` instead? The configuration for use with `nim.nvim` can be found [here](https://github.com/alaviss/nim.nvim/wiki/Support-for-other-com

Help me to configure (neo)vim, please

2020-10-11 Thread leorize
Instead of that hack, you can just... `set nofoldenable`.

Confusing behaviour with cstringArray

2020-10-03 Thread leorize
> Well, all I was getting was a -1 from `execvp`, so didn't really know what > was going on. I also don't know how to handle C errors in Nim. You would do it exactly like how you would in C. `posix.errno`, `os.osLastError()` can be used to retrieve the error (we also have a proc for converting

abs(int8) returns int8?

2020-09-23 Thread leorize
Yep. When that happens, an exception will be thrown at runtime. Below is a small snippet that demonstrates the behaviour. var x: int8 # Set the variable like this so the compiler don't # block the program from compiling. x = -128 echo abs(x) # throw overflow because 1

Brainstorming ideas to improve Nim's landing page

2020-08-29 Thread leorize
Ideas from @haxscramper on Discord: > I believe that mentioning strong support for functional programming > (closures, higher-order functions, pure functions (with latest .strictFuncs. > addition as well as sum types). Also I think nimscript should be mentioned > too - for things like automatio

Blog post about strict funcs

2020-08-28 Thread leorize
The compiler analysis is sound, `add()` is copying `choices`, which contains references reachable from `seq[Item]` into an another storage location where they can be mutated. I guess what this meant is that `add()` is not truly `{.noSideEffects.}` :P

Brainstorming ideas to improve Nim's landing page

2020-08-28 Thread leorize
For the landing page we should keep it short, the long stuff can be put into the "Features" page for example. Here's my attempt at simplifying the statement: > A language backed with state-of-the-art, research-based design and > emphasizing on speed, readability, flexibility and safety. This s

We should make it simpler for authors to have their blog featured on the Nim front page.

2020-08-28 Thread leorize
Pester @Araq about it enough and he will delegate someone to do the task :P

Brainstorming ideas to improve Nim's landing page

2020-08-27 Thread leorize
### The problem One of the things I've heard a lot that bugged me when I saw discussions regarding Nim out in the wild are: * Why Nim [over ]? (often asked by newcomers) * What is different about Nim? (often asked on online forums, eg. HN, r/programming, etc.) * Why do I need macros? (oft

We should make it simpler for authors to have their blog featured on the Nim front page.

2020-08-27 Thread leorize
As per the title. I think this would help attracts more blog posts about Nim, and help freshen the perception that Nim is being actively developed/used. Currently authors can request to have their posts featured on [the Nim blog](https://nim-lang.org/blog.html), but I don't think most are aware

Compiler Seg faulting when using "object" instead of "ref object" for nested object.

2020-08-14 Thread leorize
Can you please move this to Nim's [issue tracker]([https://github.com/nim-lang/Nim/issues](https://github.com/nim-lang/Nim/issues)) on GitHub? Thanks!

Nim website front page redesign (unofficial and WIP)

2020-08-12 Thread leorize
Maybe change the background as well? It looks random and weird, considering that Nim doesn't even have any notable syntax that use `><` "Try it online" probably can be merged with the examples (eg. make the examples editable)?

Syntax for copy instance of object and update some attribute

2020-08-08 Thread leorize
Pending support for `with` and `dup`: [https://github.com/nim-lang/Nim/pull/14484](https://github.com/nim-lang/Nim/pull/14484)

Sandboxing untrusted Nimscript code

2020-08-06 Thread leorize
See [https://github.com/nim-lang/Nim/blob/devel/compiler/scriptconfig.nim#L85](https://github.com/nim-lang/Nim/blob/devel/compiler/scriptconfig.nim#L85) and [https://github.com/nim-lang/Nim/blob/devel/compiler/vmops.nim](https://github.com/nim-lang/Nim/blob/devel/compiler/vmops.nim) for how the