Add item to Set?

2021-03-11 Thread drkameleon
Perfect! Good that I asked then... Thanks a lot!

Add item to Set?

2021-03-11 Thread juancarlospaco
`chmod "file.ext", 0o644`

new blogpost: pattern matching (and fusion)

2021-03-11 Thread Araq
> I perceive the elegance of the solutions with the pattern matching built into > the language greater than the Nim solution. I thought the post was clear about that -- we're still improving the design. Maybe pattern matching will make it into Nim's core too, who knows.

Add item to Set?

2021-03-11 Thread Araq
You include a set element via `incl`. `perms.incl fpUserExec` Yes, this is implemented by bitwise operators but Nim doesn't confuse the different layers of abstraction.

Add item to Set?

2021-03-11 Thread drkameleon
I'm trying to use `setFilePermissions` from the **os** module. This function takes a `set[FilePermission]`. If I have a type like `var perms: set[FilePermission]`, how do I gradually add new `FilePermission` types to it - e.g `fpUserExec`? (I would expect something like a bitwise operator, but

There are a Nim Linter for SublimeText?

2021-03-11 Thread timothee
Welcome Marcone, the linter from sublimetext's NimLime plugin is based on `nimsuggest`, it can be made to work with some effort but NimLime is very usable without `nimsuggest`. I've also used D a lot in the past, maybe you'll find helpful in mapping co

Nim online meetup, Friday 12th at 4pm UTC

2021-03-11 Thread jasonfi
Will the meetup be recorded for those that can't attend?

Strange "lock levels differ" error with HttpClient

2021-03-11 Thread halloleo
Thanks for this! The pragma `{.gcsafe, locks: 0.}` works. (I do get a `Warning: declared lock level is 0, but real lock level is ` though.) The big question for me is: Why does the compiler complain in the first place? Why does `httpclient` do recursive locking? From my understanding it doesn't

new blogpost: pattern matching (and fusion)

2021-03-11 Thread alexeypetrushin
> I perceive the elegance of the solutions with the pattern matching built into > the language greater than the Nim solution. +1, something like let [(first, second), trail...] = [(12, 3), (33, 4), (12, 33)] Run Looks much better than code with special characters like

bad destructor causing crash in arc/orc?

2021-03-11 Thread geekrelief
Hi Araq! Thanks! It feels nice to have a giant in the community acknowledge your work. :) I think I have to install WSL on my windows machine to get access to valgrind. I've implemented a form of hot reloading with godot-nim, , and it works fine with `--gc:o

new blogpost: pattern matching (and fusion)

2021-03-11 Thread bpr
Looking at the code, and comparing it with the OCaml right below it (I used to code in OCaml) and the Rust later (I coded in Rust for a while, back to C++ now) I perceive the elegance of the solutions with the pattern matching built into the language greater than the Nim solution. I understand,

new blogpost: pattern matching (and fusion)

2021-03-11 Thread shirleyquirk
beautiful work, @haxscramper, especially the documentation! the error messages are so inscrutable i couldn't have made any progress without it. generics require you to wrap the matching code in a `template(foo:typed)` here's my [red black tree](https://rosettacode.org/wiki/Pattern_matching#Nim)

bad destructor causing crash in arc/orc?

2021-03-11 Thread Araq
For debugging I usually recommend `--gc:orc -d:useMalloc` and `valgrind`. Also, unfortunately, `--gc:orc` is still getting lots of fixes so you're better off with "Nim devel". Having said that, I am really happy nim-godot is getting ported to Orc! Keep up the good work!

atomicMax how to implement it?

2021-03-11 Thread HJarausch
The trivial comp_max was just for demonstration, I know about the problems with the usage of random in multithreading applications. Thanks!

atomicMax how to implement it?

2021-03-11 Thread mratsim
And here is the version using `parallelForStaged` import random, weave, locks proc maxReduce(n: int): float64 = var max = -Inf let maxAddr = max.addr var lock: Lock lock.initLock() let lockAddr = lock.addr parallelForStaged i

atomicMax how to implement it?

2021-03-11 Thread mratsim
Here are a few comments: 1. Computing max via atomics is non-trivial. Reserving it for the `epilogue` is a good idea. 2. `proc comp_max() : float = rand(1.0)` is problematic, `rand` uses a global mutable RNG state underneath, you cannot access that via multiple thread as it will at best req

There are a Nim Linter for SublimeText?

2021-03-11 Thread kcvinu
Welcome to Nim forum. I am also using ST3. And as JohnAD said, i too feel the intellisense sucks. I don't know why. Why i am using ST3 instead of VSC, is the starting speed and performance. Happy to know that you are also a fan of D. High five, a D fan here.

atomicMax how to implement it?

2021-03-11 Thread HJarausch
Provably my current solution can be approved upon. Thanks for any comments, Helmut # compile nim --threads:on -d:release c -r Count.nim import random, weave, atomics var GlobalMax : Atomic[float] let GMax_ptr = addr GlobalMax proc comp_max() : fl

bad destructor causing crash in arc/orc?

2021-03-11 Thread geekrelief
I think the issue might be with Godot after all. It's not clear why a library created with godot-nim doesn't crash when it's unloaded and the editor exits. But it does crash when it's still loaded. And it's unclear why the godot engine doesn't unload the library every time before exiting.

Running Nim on android

2021-03-11 Thread marcomq
Sounds like a good idea that actually might solve my issue! Naketools also looks good. Contains much more than I probably need, but really worth a look. Thx!!

bad destructor causing crash in arc/orc?

2021-03-11 Thread geekrelief
I'm not sure I follow. Isn't it the other way around, `linkedObjectPtr` being cast to ref object (NimGodotObject)? In any case, `GC_ref()` is being called on `linkObjectPtr`, and `GC_unref()` to release it. proc setNativeObject*(nimObj: NimGodotObject, nati

Compile Nim to JavaScript from inside Nim?

2021-03-11 Thread drkameleon
I'm experimenting with the idea of producing javascript code too, as a 2nd backend (pretty much like Nim). Chances are it will be implemented in the language itself. But I am just experimenting. I don't want the whole code in JS. I just want the option t

Custom allocator with --gc:arc

2021-03-11 Thread vitreo12
Following up: In config.nims I have tried all these different options without any success. `patchFile("system", "", "custom_alloc")` `patchFile("system", "mm/malloc", "custom_alloc")` `patchFile("system", "memalloc", "custom_alloc")` Whenever I use something like `allocImpl` in my code, I have

Compile Nim to JavaScript from inside Nim?

2021-03-11 Thread drkameleon
Yep, that's pretty much what I was thinking of. I just want to ... test the waters first and not start experimenting with something that could possibly not work at all after all... Thanks for the input!

bad destructor causing crash in arc/orc?

2021-03-11 Thread mratsim
How is this even working? type NimGodotObject* = ref object of RootObj ## The base type all Godot types inherit from. ## Manages lifecycle of the wrapped ``GodotObject``. godotObject: ptr GodotObject linkedObjectPtr: pointer # ...

bad destructor causing crash in arc/orc?

2021-03-11 Thread geekrelief
I've tried to convert for use with orc. And while it's been working for the most part, I'm getting a crash in a destructor that I've mechanically converted from a finalizer. godot-nim relies on gc:refc and when converting to orc I had to convert the final

Running Nim on android

2021-03-11 Thread yglukhov
It's a lot more beneficial to build a static lib all the way with nim, and then link it during gradle build. Nimx/naketools does just that.

Compile Nim to JavaScript from inside Nim?

2021-03-11 Thread kamilchm
To send a dynamically generated JS code to the browser?

Compile Nim to JavaScript from inside Nim?

2021-03-11 Thread pietroppeter
I guess that easiest way to send dynamicall generated JS to the browser would be to write nim to file and run nim compiler on it with JS backend, then read and send the result. I guess this would not qualify as happening **inside** the executable (you also depend on the compiler for this).

There are a Nim Linter for SublimeText?

2021-03-11 Thread JohnAD
I use NimLime for syntax highlighting. In theory, it does other things such as error checking and auto-completion, but I've gotten any of that to work. I strongly suspect there is some undocumented setup involved. If you find more useful information, please let us all know. (Of note: I run Subl

Exception handling without doing rest of the program

2021-03-11 Thread SebastianM
Thank you very much. The code now works.

Compile Nim to JavaScript from inside Nim?

2021-03-11 Thread Clonk
Genuine question : Why would you do that ?

Running Nim on android

2021-03-11 Thread marcomq
Hi all! I hope I'm not spamming here, as I already made a recent post 3 days ago. I'm also not sure if I made this too complicate to get some piece of Nim code running on android... I create an empty JNI Android Studio project and used a nimble task to create C Code for multiple CPU targets ou

Nim online meetup, Friday 12th at 4pm UTC

2021-03-11 Thread miran
Tomorrow (Friday, March 12th) at 4pm UTC (when this post is exactly 24h old), we will hold a casual online Nim dev meet where you can find out about our plans for Nim future, what we've been working on, and ask any question about the stuff you always wanted to know. Join us at:

Compile Nim to JavaScript from inside Nim?

2021-03-11 Thread Araq
I'm not sure what you mean but you can import the Nim compiler into your Nim code and compile the Nim code to JS via the JS code generator...

Exception handling without doing rest of the program

2021-03-11 Thread Araq
Try this variation:

Exception handling without doing rest of the program

2021-03-11 Thread SebastianM
Hi Guys, It's another time that I'm stuck learning Nim with Python Crash Course book. Now it's time for exceptions. The point is that program handles IOError that file is missing on disk (on purpose - like in the book) but still gives info about amount of words. Could anyone tell how to prevent

Compile Nim to JavaScript from inside Nim?

2021-03-11 Thread drkameleon
OK, so... I know that a Nim program can be compiled to JavaScript using the corresponding backend. The question is: **inside** a compiled (C/C++) Nim program, can I convert Nim code to JavaScript using the very same backend? Is that accessible the way I think it could be?

SQLite getRow data changing

2021-03-11 Thread michaelrust
Python can do everything rather than java... In artificial intelligence, Data Science, Machine learning, Web development (flask, Django), and all other kinds of development.

SQLite getRow data changing

2021-03-11 Thread michaelrust
Python can do everything rather than java... In artificial intelligence, Data Science, Machine learning, Web development (flask, Django), and all other kinds of development.

Custom allocator with --gc:arc

2021-03-11 Thread vitreo12
Thanks! However, it's not working for me. I'm doing: patchFile("system", "memalloc", "patches/memalloc") Run Does it look good? my `memalloc.nim` file contains the same procs that are defined in the `system/memalloc` one, but hooked into my allocator. However, it see

Custom allocator with --gc:arc

2021-03-11 Thread Araq
There is a `patchFile` mechanism for `config.nims`.

Strange "lock levels differ" error with HttpClient

2021-03-11 Thread mratsim
The type system is really annoying right now with closures. Use explicit `proc send_via_httpclient (url:string): bool {.gcsafe, locks: 0.} =` I think `locks` are a remnant of an idea to facilitate preventing deadlocks if some code does recursive locking (?) but I think it was quite fully develop

Custom allocator with --gc:arc

2021-03-11 Thread vitreo12
Sorry to come back to this again. Is there a way that I can import my own `memalloc.nim` file without having to modify the one in the `nim` installation? This would allow me to easily bundle the implementation together with my code.