How to pass arguments with NIM?

2020-10-17 Thread blmvxer
import os var argument = commandLineParams() for arg in arguments: if arg == "--my-arg": echo("Yay") elif arg == "--multiple-args": echo("We can use and check multiple arguments") else: discard Run '''

Version 1.4.0 released

2020-10-17 Thread moigagoo
Fresh batch of Docker images has been published to Docker Hub:

How to pass arguments with NIM?

2020-10-17 Thread Yardanico
Hello and welcome to the Nim (yes, it's not capitalized :P) community :) It's not cryptic at all - for example, you can use or paramCount together with paramStr :)

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

A nice read about Nim (blog article)

2020-10-17 Thread disruptek
I didn't read the article. Ryu is `f2s` only. It's for rendering only, no parsing. I will pick it up again when I can afford to, but I've been hoping that @Clyybber or @alaviss would finish their implementations instead. Mine is a naive port from C, because I felt it was more important to make

How to pass arguments with NIM?

2020-10-17 Thread brunomerod
I'm having a really good first impression with Nim, it's a surprisingly interesting language. But some stuff I'm used to do are really cryptic, such as passing an argument when invoking an executable from the command line. All I want is. > ./ $Arg01 How to do this? I read the documentation and

Forcing a memory leak in Nim

2020-10-17 Thread Yardanico
The thing is that even when manually allocating stuff you use Nim's TLSF allocator unless you switch to -d:useMalloc

Forcing a memory leak in Nim

2020-10-17 Thread o24
Thanks, all. I'll go through these one by one. > Just `var mem = create int` should do. `--gc:none` memory is never freed. Using this program: var mem = create int mem = nil Run and compiling with `nim compile --gc:none leak.nim`, I still do **not** get a memory

Karax HTML character entities

2020-10-17 Thread jlp765
Thanks @timothee There is a `div` added around the text with verbatim. Also, the VerbatimRaw will allow the addition of any HTML that isn't already defined by Karax to be added as needed by the user.

Forcing a memory leak in Nim

2020-10-17 Thread Yardanico
useMalloc also works with ORC or refc for that matter

Are there any alternatives to tables with duplicated keys?

2020-10-17 Thread cblake
You can also use [adix/lptabz.nim](https://github.com/c-blake/adix/blob/master/adix/lptabz.nim).

Forcing a memory leak in Nim

2020-10-17 Thread shirleyquirk
I think useMalloc is necessary for valgrind to detect the leak, otherwise it is hidden by Nims TLSF allocation, and useMalloc is only compatible with gcNone or gcArc

Are there any alternatives to tables with duplicated keys?

2020-10-17 Thread shirleyquirk
if you need to associate more than one value with a single key, you can use a `Table[KeyType,seq[ValueType]]`

Version 1.4.0 released

2020-10-17 Thread shirleyquirk
[these three comments](https://www.reddit.com/r/programming/comments/jc91xp/nim_14/g90ysdl/?context=2) from the reddit thread are a highlight. Updating the front page of the Nim website, or how to better word Nim's blurb is often mentioned here, I think this comment nails it.

Can I use async/await to work with JS Promises?

2020-10-17 Thread vijaymarupudi
Something like this should work import asyncjs proc main() {.async.} = let x = await apiFunction() main() Run

Can I use async/await to work with JS Promises?

2020-10-17 Thread akavel
I'm in progress of writing a Firefox Webextension with Nim, using Karax for rendering. I got stuck in a place where: 1. I'm writing a proc used in Karax callback (onclick) 2. I need to access `an async Webextension API (returning a JS `Promise`) <[https://developer.mozilla.org/en-US/docs/Moz

Forcing a memory leak in Nim

2020-10-17 Thread Stefan_Salewski
First you may try to put the Nim code into a main proc, then it will become closer to the C program. And maybe compile with -d:useMalloc and maybe also with --gc:arc.

Forcing a memory leak in Nim

2020-10-17 Thread shirleyquirk
the fact that this doesn't compile with gc:none and -d:useMalloc is a regression you could submit as an issue on github. you can, however use gc:arc and -d:useMalloc, which then leaks as expected.

Forcing a memory leak in Nim

2020-10-17 Thread juancarlospaco
Just `var mem = create int` should do.

Are there any alternatives to tables with duplicated keys?

2020-10-17 Thread mrhdias
After upgrade to Nim v1.4 I got the following warning message: Warning: Deprecated since v1.4; tables with duplicated keys are deprecated; allValues is deprecated [Deprecated] Run Any alternatives?

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

2020-10-17 Thread Recruit_main707
I have been doing some tests: * * (i was told you liked thavlak) * A custom one that i made, where i created a very long sequence, full of ref objects, and did

Handling customisations when upgrading Nim

2020-10-17 Thread sgmoore
Thanks. I'll try that.

Forcing a memory leak in Nim

2020-10-17 Thread o24
I am trying to force Nim to leak memory to better understand the memory model. >From my understanding, the following two programs are identical. #include int main() { int *x = malloc(sizeof(int)); x = 0; } Run var mem: ptr int = c

It's time to make Nim known ! ✊✊✊✊

2020-10-17 Thread archnim
You've right. But there are few programming groups on fb. I try to catch programmers's attention to Nim with publications like this: "Don't choose between C's performance and python's ease. Choose both. Choose Nim. "

Choosenim v0.7.2 released

2020-10-17 Thread dom96
Hello all! Choosenim v0.7.2 is here! Among many bug fixes, support for operating systems has grown as it is now 100% statically linked (thanks @genotrance for help with this!) For a full list of changes, see here:

Inspecting provided `type` within macro

2020-10-17 Thread Akito
@geotre Wow, thank you so much, this helped really A LOT! For future readers, my `macro` expects a type MyObj = ref object of myObj stringField: string power: int Run So here is the spec for retrieving the `RecList` from a `ref object`:

Inspecting provided `type` within macro

2020-10-17 Thread geotre
There's probably a neater way to do it but this works: import macros macro printFields(obj: typedesc) = for field in getType(obj)[1].getTypeImpl[2]: let name = field[0].strVal fieldType = field[1].strVal echo "name: ", name

Version 1.4.0 released

2020-10-17 Thread federico3
Update: has been replaced with a different tarball (without updating the version number) but it's now missing the Nimble sources. I'm being told that a new tarball is being prepared.

Handling customisations when upgrading Nim

2020-10-17 Thread jyapayne
I usually use the git folder to upgrade my Nim installation. This allows me to have my own changes (in a patch file or a branch/commits). Then I can just apply the patch or rebase on top of a new release.

Inspecting provided `type` within macro

2020-10-17 Thread Akito
I am trying learn more about how Nim macros work and get used to them. In this case, I want to pass an `object` `type` as an argument to a `macro`, which then inspects the provided `object` `type` and gets all fields (only `var` or `let` sections are expected) as `NimNode`s. Then, I want to do f

Localized sorting library?

2020-10-17 Thread reneha
An alternative would be to call strcoll() from the C standard library. Of course this works only if the encoding of your locale setting matches the encoding of the strings passed to strcoll(). This used to be a problem on Windows which did't support UTF-8 locales. But now Windows 10 seems to sup

Nim's vision

2020-10-17 Thread Sixte
Nim offers anything that C can offer , but way more convenient than and at least as efficient as C, particulary superceding C because of "GC-elision" : optimized memory management with both space and time in regard. C is still heavily in use for compiler (interpreter) implementations, but anyone

Handling customisations when upgrading Nim

2020-10-17 Thread sgmoore
Just upgraded to Nim 1.4.0 using choosenim and it was fairly painless, but I was wondering what the best way of handling customisations, for example changes to nim.cfg and any changes to nim files in the lib folder. Obviously I can keep a note of my changes and re-apply them after upgrading, bu

Nim's vision

2020-10-17 Thread timothee
> in the meantime we use Nim ... for everything. that. If Nim is the toothbrush that you use everyday and for everything, it can do well without a marketed "killer app". Languages built around a killer app / domain specific use case can thrive, but any sufficiently complex project using those w

Version 1.4.0 released

2020-10-17 Thread Arrrrrrrrr
Congratulations to the nim staff. Great work and interesting new features, I'm always curious where the arc/orc thing is going on, and the new Views type looks promising.

Karax HTML character entities

2020-10-17 Thread timothee
IIRC this creates a div, in cases where you don't want that, I came up with

Karax HTML character entities

2020-10-17 Thread jasonfi
You can use the verbatim syntax, e.g.: p(): verbatim "nbsp;" Run

Version 1.4.0 released

2020-10-17 Thread moigagoo
Congrats! My personal favorite with this release is the docgen improvement. And `nim r` is great too!