New Nim Discussion Site

2021-07-18 Thread Fire
Sorry for being curt in my response to your reply. I totally agree that "Nim is at a stage where the more communication channels it covers, the better.". Go/Rust/Swift all have companies with billions backing them. Nim really only has it's features.

New Nim Discussion Site

2021-07-18 Thread moigagoo
> It was an available Quora space name, and descriptive. If you would prefer, I > can shorten it. Oh no, please don't take is as an offense. I just noted that the URL was long, not bad. Also, I'm in no position to tell other people what's wrong or right. I've started on the wrong foot, sorry. H

Template or macro for heterogeneous tuple expressions?

2021-07-18 Thread aEverr
You can probably use an implicit generic (`tuple` with no generic parameters) and use

Template or macro for heterogeneous tuple expressions?

2021-07-18 Thread stu002
I've been implementing functions for concepts where the implementing types are heterogeneous tuples of 2,3,4 or more elements. Something like: type Eq* = concept x, y eq(x, y) is bool # ordinals implement Eq func eq*(x, y: SomeOrdinal): bool = x == y

New Nim Discussion Site

2021-07-18 Thread Fire
It was an available name, and descriptive. If you would prefer, I can shorten it.

New Nim Discussion Site

2021-07-18 Thread moigagoo
Wow, that's one long ass URL.

Native GUI development for MacOS

2021-07-18 Thread AIR
I've been plaing with 'objc_runtime' this weekend, and wanted to show how I created a subclass of NSObject with methods, property, and iVar. Idea came from this`StackOverflow post `

Question about "thread-local heap" garbage collectors and threads.

2021-07-18 Thread GordonBGood
@tsojtsoj: Yes, spawning as per your code is still fine (as long as you use `--threads:on` in your compiling command line and import `threadpool`) but you should make sure the object pointed to doesn't get collected due to no reference, as per the following working code: # compil

Question about "thread-local heap" garbage collectors and threads.

2021-07-18 Thread tsojtsoj
Hi, What are the implications of using a "thread-local heap" garbage collector (e.g. `--gc:refc`) when I am spawning new threads? For example, is this still allowed: func doStuff(data: ptr seq[Type]) = ... var data: seq[Type] = ... spawn doStuff(addr data)

Which macOS installation method for Nim?

2021-07-18 Thread stu002
Good to know -- thanks.

New Nim Discussion Site

2021-07-18 Thread Fire
Quora, the Q&A site, now has a space purely for Nim discussion. If you are on Quora, please consider contributing to the space.

reverse cipher

2021-07-18 Thread cblake
No great reason. I was probably too suggestible Re performance concerns which likely don't matter (yet!). I _almost_ said "there are several ways to do this". That'll teach me to be brief! Lol. So, here, @deoxyt2... import strutils; echo translated.join # A 3rd way Ru

reverse cipher

2021-07-18 Thread ynfle
Why would you `cast` and not `join()`

reverse cipher

2021-07-18 Thread cblake
If you really are only reversing, that is an included battery: import algorithm var message = "mensaje secreto" message.reverse echo message # Another way... let translated = "mensaje secreto".reversed echo cast[string](translated) Run (The `cas

Base method when returning an iterator

2021-07-18 Thread ynfle
See this example . The warning comes from the fact that the return type is a generic iterator. If you change the return type to an iterator that returns `coldata` then the warning isn't issued, ie. the warning is only issued on the second `getIter` method (you

Base method when returning an iterator

2021-07-18 Thread rtrn
Ok, by changing method to proc fixes the problem. Is this something about `proc` vs `method` ? static vs dynamic dispatch ?

problem of run procedure with interval and stop the running

2021-07-18 Thread jackhftang
I guess this is what you want. import asyncdispatch type Action = proc(): void {.gcsafe.} proc runInterval(cb: Action, interval: int): Future[Action] {.async.} = var running = true result = proc() = running = false proc loop() =

Base method when returning an iterator

2021-07-18 Thread rtrn
I'm pretty much a beginner method fetchDataInterval(self : dbHandle): iterator {.base.} = return iterator (): coldata = for i in self.db.fastRows(sql(self.fetchstring)): yield i.mapIt(parseInt(it)) Run I get a warning > Warning: gene

problem of run procedure with interval and stop the running

2021-07-18 Thread Stefan_Salewski
Maybe what you want is async with cancelation? Chronos supports that, and mashingan gave an example for Nim async here:

reverse cipher

2021-07-18 Thread Stefan_Salewski
And a modified faster variant: #reverse cipher var message = "mensaje secreto" i = message.high translated: string = newString(i + 1) for j, c in message: translated[i - j] = c echo translated Run