00:26:13 | * | teal joined #nim |
00:27:04 | * | njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.) |
00:27:24 | * | njoseph joined #nim |
00:32:37 | * | NimBot joined #nim |
01:19:00 | * | SofarUpYa joined #nim |
01:37:53 | ForumUpdaterBot | New thread by RainbowAsteroids: How does Nim ARC/ORC compare to Rust?, see https://forum.nim-lang.org/t/7905 |
01:49:40 | * | SofarUpYa left #nim (#nim) |
02:02:58 | reversem3 | <FromDiscord "<ElegantBeef> nixfreak i've neve"> https://github.com/filcuc/nimqml/blob/master/examples/connections/main.nim |
02:03:53 | * | teal quit (Quit: food) |
02:08:47 | * | abm quit (Read error: Connection reset by peer) |
02:27:53 | * | hyiltiz quit (Ping timeout: 240 seconds) |
02:30:38 | * | hyiltiz joined #nim |
02:30:38 | * | hyiltiz quit (Changing host) |
02:30:38 | * | hyiltiz joined #nim |
02:33:58 | ForumUpdaterBot | New thread by Adnan: How to make Nim more popular, see https://forum.nim-lang.org/t/7906 |
02:57:50 | FromDiscord | <codic> is it safe to rely on an experimental feature like codereordering? |
02:58:30 | FromDiscord | <Rika> i would argue no |
02:59:28 | FromDiscord | <ElegantBeef> Well code reordering i believe is an exception since it's eventually going to be no longer needed as Nim will by default figure out how to layout the code as needed |
02:59:45 | FromDiscord | <ElegantBeef> Atleast i think that's the goal |
03:00:45 | * | wasted_youth2 quit (Quit: Leaving) |
03:01:18 | leorize | you should not rely on it now |
03:01:41 | leorize | the current implementation is horrible and a proper one requires IC to be completed |
03:15:00 | FromDiscord | <codic> ah ok |
03:15:15 | FromDiscord | <codic> so i'll just forward declare for now then |
03:44:05 | ForumUpdaterBot | New thread by Masiarek2: File - copy Line by line - error , see https://forum.nim-lang.org/t/7907 |
03:47:56 | * | spiderstew joined #nim |
03:50:41 | * | spiderstew_ quit (Ping timeout: 240 seconds) |
04:06:48 | FromDiscord | <codic> If I'm fairly certain that I'm not going to have my own cyclic structures should I use `arc` instead of `orc` for that speed boost? I don't think I'll run into speed performance but in my project (an init system) speed is critical. I might have non-blocking services, so I'm leaning towards `orc` |
04:07:08 | FromDiscord | <codic> But as for the implementation of those non blocking services I'm not sure if I should use regular threads, which I'm more familiar with, or async |
04:07:57 | FromDiscord | <ElegantBeef> Well if you know it doesnt have cyclical structures Arc seems fine to my dummy knowledge |
04:08:02 | leorize | there is no speed boost from using arc if your project is full of acyclic structure |
04:08:06 | * | thomasross quit (Ping timeout: 240 seconds) |
04:08:25 | leorize | you can tag your types with `{.acyclic.}` and orc will work like arc on those structures |
04:08:41 | FromDiscord | <ElegantBeef> Yea Orc falls back to the cycle collector when it has to |
04:08:44 | leorize | we have benchmarks on this, orc is not slower than arc |
04:11:47 | FromDiscord | <codic> i wonder if the optimizer does that automatically |
04:11:55 | FromDiscord | <codic> in that case i'll just use orc |
04:12:03 | FromDiscord | <codic> but should I use threads or async? |
04:24:24 | leorize | it depends on the problem you're tackling |
04:24:31 | leorize | if it's computational, use threads |
04:24:43 | leorize | if it's I/O based, use async |
05:24:56 | * | Gustavo6046 quit (Quit: ZNC 1.8.2 - https://znc.in) |
05:32:08 | * | Gustavo6046 joined #nim |
06:02:46 | * | vicfred quit (Ping timeout: 240 seconds) |
06:32:25 | * | kayabaNerve quit (Remote host closed the connection) |
06:32:53 | * | kayabaNerve joined #nim |
06:37:52 | * | kayabaNerve quit (Ping timeout: 240 seconds) |
06:39:15 | FromDiscord | <codic> well I'm not really doing any work, I'm just spawning a child process |
06:39:20 | FromDiscord | <codic> so I guess that's I/O |
06:39:23 | FromDiscord | <codic> probably async then |
06:40:40 | FromDiscord | <codic> or well maybe threads? |
06:40:42 | FromDiscord | <codic> I have no idea |
06:40:48 | FromDiscord | <codic> i don't need futures or anything else async has |
06:41:20 | * | kayabaNerve joined #nim |
06:41:32 | * | kayabaNerve quit (Remote host closed the connection) |
06:41:35 | FromDiscord | <Rika> Async if I/O, threads if computation |
06:41:58 | FromDiscord | <Rika> In reply to @codic "or well maybe threads?": Why did you think to use threads here? |
06:41:58 | * | kayabaNerve joined #nim |
06:42:16 | FromDiscord | <Rika> What exactly are you doing? |
08:14:30 | ForumUpdaterBot | New Nimble package! crowngui - Web Technologies based Crossplatform GUI Framework, see https://github.com/bung87/crowngui |
09:20:04 | * | kayabaNerve quit (Remote host closed the connection) |
09:23:19 | * | kayabaNerve joined #nim |
09:38:37 | ForumUpdaterBot | New Nimble package! nimothello - A teminal othello (reversi) in Nim., see https://github.com/jiro4989/nimothello |
09:57:13 | * | clyybber joined #nim |
10:00:25 | * | Tlangir quit (Ping timeout: 265 seconds) |
10:33:56 | * | wasted_youth2 joined #nim |
11:01:12 | * | lritter joined #nim |
11:02:01 | * | rockcavera is now known as Guest55743 |
11:02:01 | * | Guest55743 quit (Killed (weber.freenode.net (Nickname regained by services))) |
11:02:01 | * | rockcavera joined #nim |
12:19:07 | * | zidsal joined #nim |
12:22:22 | FromGitter | <offbeat-stuff> Hi, I have a nimscript that I want to run with the dir of where the nimscript is located regardless of where it is actually located |
12:38:12 | FromDiscord | <Rika> uh, what |
12:38:16 | FromDiscord | <Rika> i dont understand |
12:41:17 | FromDiscord | <Solitude> he wants paths to be relative to executable, not cwd |
12:42:18 | FromGitter | <offbeat-stuff> actually got it working |
12:42:30 | FromGitter | <offbeat-stuff> let relDir = splitFile(paramStr(2)).dir |
12:42:57 | FromGitter | <offbeat-stuff> it should work always because i run it like ../run.nims |
12:43:03 | FromGitter | <offbeat-stuff> first line of it is |
12:43:11 | FromGitter | <offbeat-stuff> #!/usr/bin/nim e |
12:58:33 | * | fredrikhr joined #nim |
12:59:50 | * | fredrikhr quit (Read error: Connection reset by peer) |
13:00:12 | * | fredrikhr joined #nim |
13:21:15 | * | gangstacat quit (Ping timeout: 260 seconds) |
13:47:25 | * | vsantana joined #nim |
13:50:56 | * | xet7 quit (Remote host closed the connection) |
13:55:02 | * | gangstacat joined #nim |
14:15:21 | * | xet7 joined #nim |
14:52:25 | * | thomasross joined #nim |
14:57:24 | * | thomasross quit (Quit: Leaving) |
15:00:55 | * | thomasross joined #nim |
15:01:18 | * | thomasross is now known as Guest71323 |
15:05:24 | giaco | why does strformat doesn't work with float subrange type? |
15:08:08 | giaco | https://play.nim-lang.org/#ix=3lBP |
15:10:27 | * | Guest71323 quit (Quit: Leaving) |
15:10:44 | * | Guest71323 joined #nim |
15:11:26 | * | thomasross_ joined #nim |
15:11:26 | * | thomasross_ is now known as thomasross |
15:12:04 | * | thomasross quit (Remote host closed the connection) |
15:12:06 | * | Guest71323 quit (Read error: Connection reset by peer) |
15:12:09 | reversem3 | Ok so slots is a macros for qobjects using nimql A QObject is made of : |
15:12:09 | reversem3 | slots: functions that could be called from the qml engine and/or connected to Qt signals |
15:12:20 | * | thomasross joined #nim |
15:12:29 | reversem3 | * Ok so slots is a macro for qobjects using nimql A QObject is made of : |
15:12:29 | reversem3 | slots: functions that could be called from the qml engine and/or connected to Qt signals |
15:22:37 | reversem3 | Damn that’s a lot to unpack creating Qt apps. |
15:36:06 | giaco | https://nim-lang.org/docs/parsexml.html example uses an undefined "=?=" operator |
15:37:45 | FromDiscord | <Rika> It’s defined in example 2 |
15:42:28 | giaco | oh! you're right, damn I need a coffee |
15:54:50 | * | vsantana quit (Read error: Connection reset by peer) |
16:00:04 | * | guelosk[m] quit (Quit: Idle for 30+ days) |
16:01:25 | * | Jesin joined #nim |
16:36:23 | ForumUpdaterBot | New thread by Masiarek2: Wikipedia: nim reference - regex engines - comparison , see https://forum.nim-lang.org/t/7908 |
16:53:24 | * | natrys joined #nim |
17:06:26 | ForumUpdaterBot | New thread by Masiarek2: Regex , see https://forum.nim-lang.org/t/7910 |
17:19:17 | * | zidsal quit (Ping timeout: 260 seconds) |
17:38:02 | FromDiscord | <matf> 👋Anyone have a good guide or intuition for when to use `object` vs `ref object` ? |
17:43:47 | FromDiscord | <dom96> hm, I have an intuition, hard to put it into words |
17:44:04 | FromDiscord | <exelotl> yeah, I want to say use object by default, unless you need to keep a lasting reference to the object |
17:45:18 | FromDiscord | <matf> Oh no. Googling around I was coming to the conclusion I wanted `ref object` most of the time. Heh. I'm glad I'm asking |
17:45:25 | FromDiscord | <dom96> I would say: start with `object`, if you find yourself writing `var T` everywhere for that object it could be time to use `ref`. There are also situations where `ref` is a must, if you for example have an object that needs to reference itself. |
17:47:04 | FromDiscord | <matf> @dom96 That makes sense. in that way, I'm saying `object` is generally immutable. if I'm var T'ing it all over the place, I probably just want to be updating the actual object rather than copying instead. Correct intuition there? |
17:47:48 | FromDiscord | <haxscramper> `object` vs `ref object` is not immutability, it is about heap/vs stack allocation |
17:48:21 | FromDiscord | <haxscramper> `ref` object has reference semantics so it can be viewed as "generally mutable", |
17:48:27 | FromDiscord | <haxscramper> but that is only a consequences |
17:49:32 | FromDiscord | <haxscramper> If you find yourself writing `var T` everywhere it might be a time to use `ref`, but you can also simplify code with `using` statement |
17:50:31 | FromDiscord | <haxscramper> https://github.com/nim-lang/Nim/wiki/Lesser-known-Nim-features#using-statement |
17:52:07 | FromDiscord | <haxscramper> So `objects` vs `ref object` decision also might include considerations like: ↵- how often do you plan to copy it? Copying `ref` is just incrementing counter, copying `object` might be costly |
17:52:26 | FromDiscord | <matf> Hrm. Still trying to figure out a heuristic to use. "small object, rarely updated" -> object. "big object, rarely updated" -> object. "big object, updated often" -> ref object. |
17:52:36 | FromDiscord | <matf> (edit) "Hrm. Still trying to figure out a ... heuristic" added "(rough)" |
17:52:37 | FromDiscord | <dom96> meh, I would avoid using "lesser known features" 🙂 |
17:52:39 | FromDiscord | <haxscramper> no "rarely updated" part |
17:53:03 | FromDiscord | <haxscramper> In reply to @dom96 "meh, I would avoid": `using` is the single best thing I've learned in the long time |
17:53:55 | FromDiscord | <haxscramper> Maybe if you substitute "experimental" instead it would make sense, but "lesser known"? probably not |
17:55:41 | * | natrys quit (Ping timeout: 240 seconds) |
17:57:18 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3lD2 |
17:59:34 | FromDiscord | <matf> Thanks |
18:00:16 | FromDiscord | <haxscramper> More intricate intuition comes after you sorted our this stack/heap difference I guess |
18:00:24 | FromDiscord | <haxscramper> (edit) "our" => "out" |
18:02:29 | * | natrys joined #nim |
18:03:02 | FromDiscord | <matf> Coming from scala/haskell where I don't ever really think about stack vs. heap (it's been a while). In jvm land all my objects are heap I guess, stack is just pointers and methods. |
18:03:25 | FromDiscord | <matf> (edit) "Coming from scala/haskell where I don't ever really think about stack vs. heap (it's been a while). In jvm land all my objects are heap I guess, stack is just pointers ... and" added "to objects (I never see these directly)" |
18:04:13 | FromDiscord | <matf> that's probably wrong. strings are probably somewhere weird. Just trying to get the old brain working this morning. |
18:05:05 | FromDiscord | <haxscramper> strings have value semantics |
18:05:31 | FromDiscord | <haxscramper> But yes, internally they are implemented as pointer-to-data-and-size |
18:05:40 | FromDiscord | <haxscramper> no SSO |
18:07:12 | FromDiscord | <exelotl> sent a code paste, see https://play.nim-lang.org/#ix=3lD9 |
18:09:43 | FromDiscord | <exelotl> but if course it can't do that for `let bar = foo`, the value semantics mean it has to copy in that case |
18:10:20 | FromDiscord | <exelotl> (edit) "if" => "of" |
18:11:01 | FromDiscord | <haxscramper> Also default passing behavior can be overridden with `.bycopy.` (always copy to argument) or `.byref.` (always pass by reference) |
18:11:24 | FromDiscord | <matf> This is where I lose the thread slightly again. Since x isn't being modified, by would `let` make `total` be a copy? |
18:11:34 | FromDiscord | <matf> (edit) "be" => "cause" |
18:12:47 | FromDiscord | <matf> Oh wait. Sorry I read that wrong. `let bar = foo` is not in the example above yes that makes sense why it's ac opy. |
18:13:04 | FromDiscord | <matf> total shouldn't matter if it was by value or by reference, since `x` isn't modified right? |
18:13:14 | FromDiscord | <exelotl> yep exactly |
18:14:07 | FromDiscord | <matf> Ok. I'm going to get my head back down into the editor and mess around a bunch. Thanks for this. It has helped., |
18:14:08 | FromDiscord | <matf> (edit) "helped.," => "helped." |
18:23:53 | FromDiscord | <jtiai> sent a code paste, see https://play.nim-lang.org/#ix=3lDd |
18:36:07 | FromDiscord | <jtiai> Looks like nim tries to use my `Device`-type `read(device, uint16)` from `device.nim` but it should use one from `Bus`. Why that happens? |
18:50:25 | * | clyybber quit (Quit: WeeChat 3.1) |
18:51:41 | * | clyybber joined #nim |
18:57:09 | * | leorize quit (Ping timeout: 240 seconds) |
18:59:40 | * | leorize joined #nim |
19:03:21 | FromGitter | <bung87> how to parse a proc signature ? I want generate to another string representation for its return type params type |
19:06:27 | * | xet7 quit (Read error: Connection reset by peer) |
19:11:41 | FromGitter | <bung87> guess I need procs conveter called from marocs |
19:35:01 | FromDiscord | <queersorceress> @haxscramper any major progress on your orgmode parser? |
19:35:14 | * | blackpawn joined #nim |
19:37:33 | * | leorize quit (Ping timeout: 240 seconds) |
19:40:11 | FromDiscord | <haxscramper> No major progress except for realization that I need to refactor several things. Right now I'm finishing my work on core haxdoc implementation and will focus on the org-mode parser more as I need to for documentation comments. |
19:40:35 | FromDiscord | <haxscramper> Since last time I've only added XML export support and some serialization helpers |
19:43:25 | FromDiscord | <haxscramper> And nim RST importer |
19:43:36 | FromDiscord | <queersorceress> maybe i should try finding an implementation in javascript i like |
19:43:47 | FromDiscord | <queersorceress> hahaha |
19:44:50 | FromDiscord | <queersorceress> did i mention the reason i am going with org is cuz i tried using nim's docutils rst renderer and found it lacking for my needs? |
19:45:21 | FromDiscord | <queersorceress> so i totally know what you are going through there |
19:45:49 | * | arecaceae quit (Remote host closed the connection) |
19:46:07 | FromDiscord | <haxscramper> Well, I'm actually just spending a lot of time on background work, it is not that org-mode parser itself is complicated |
19:47:13 | * | lritter quit (Ping timeout: 240 seconds) |
19:47:28 | * | arecaceae joined #nim |
19:47:31 | FromDiscord | <haxscramper> Like I've spent several days on implementing serialization library that would allow me to tweak output manually |
19:47:45 | * | leorize joined #nim |
19:47:59 | FromDiscord | <haxscramper> Which resulted into deep `typed` AST dive and we all know how things are there |
19:48:34 | FromDiscord | <queersorceress> it's true, though i've promised myself to not write more parser/lexers if i can avoid it, and the stdlib parser/lexer utils are really bare bones to work with. |
19:50:29 | FromDiscord | <haxscramper> They are good but in the end I almost always fall back to char-by-char parsing, especially with org-mode |
19:51:08 | FromDiscord | <haxscramper> By the way, you plan to use it on the JS backend, correct? |
19:51:31 | FromDiscord | <haxscramper> I need to make sure it works there too, because I haven't tested anything but default target so far |
19:53:50 | FromDiscord | <queersorceress> no, it'd be client side javascript if i go that route, otherwise it's server side nim. |
19:56:15 | FromDiscord | <queersorceress> if i do use an existing javascript library for parsing and rendering my orgfiles then it will probably be handwritten javascript to save on size rather than nim using js backend. |
19:57:41 | FromDiscord | <queersorceress> the order of magnitude is just too great afaict to do that. if it were run locally or in node then that'd be different. |
19:58:58 | FromDiscord | <queersorceress> it i do it in another language like python or something then it'd have to be server side and i'm back with my resource contention problem. |
20:29:41 | * | natrys quit (Ping timeout: 240 seconds) |
20:41:12 | FromDiscord | <codic> does spawnProcess run the given process in the background, or do I need to explicitly `spawn` it? |
20:41:27 | FromDiscord | <codic> startProcess |
20:41:40 | FromDiscord | <jtiai> `let c = ula.bus.read(ptrDisp)` why Nim this thinks that `read` should have `Device` (ula is inherited from Device) as parameter and not `bus`? Is dotted path treated differently than I think? |
20:42:56 | FromDiscord | <ElegantBeef> Do you have a read that takes an explicit bus type? |
20:42:56 | * | natrys joined #nim |
20:43:08 | FromDiscord | <jtiai> I have several reads... |
20:43:33 | FromDiscord | <ElegantBeef> @codic yes i believe it is non blocking |
20:43:33 | FromDiscord | <jtiai> One which takes Bus, one which is base class Device and few that are inhertied from Device. |
20:43:50 | FromDiscord | <ElegantBeef> Ok so then the answer is yea |
20:44:03 | FromDiscord | <ElegantBeef> Is that read exported and accessible from the current module |
20:44:17 | FromDiscord | <ElegantBeef> Finally does the compiler agree with the issue or is it just the editor lying? |
20:44:44 | FromDiscord | <jtiai> Nope. Compiler doesn't like me 🙂 |
20:45:06 | FromDiscord | <jtiai> sent a code paste, see https://play.nim-lang.org/#ix=3lDB |
20:45:38 | FromDiscord | <jtiai> And yes read is accessible and exported.... |
20:46:52 | FromDiscord | <ElegantBeef> oh it's a method |
20:46:59 | FromDiscord | <ElegantBeef> did you mark the method with `{.base.}` |
20:47:14 | FromDiscord | <jtiai> I have base method in Device. |
20:48:22 | FromDiscord | <jtiai> This worked fine with my "Memory" device which is very simple. Now I'm adding another device which also reads the bus (memory) and now the problem popped up. |
20:48:58 | FromDiscord | <ElegantBeef> Considering the error i can only imagine the issue is that the bus read isnt accessible |
20:49:19 | FromDiscord | <jtiai> Must be because CPU emulation uses that... |
20:49:27 | FromDiscord | <ElegantBeef> Is the base object accessible in this scope? |
20:49:34 | FromDiscord | <jtiai> Yes. |
20:49:48 | FromDiscord | <ElegantBeef> Then yea with only the error and behaviour i cannot say much |
20:50:16 | FromDiscord | <jtiai> I could push this mess to github... |
20:51:00 | FromDiscord | <ElegantBeef> Can just make a branch then destroy it afterwards if you so wish |
20:54:34 | FromDiscord | <jtiai> <https://github.com/jtiai/nimoric> |
20:54:41 | FromDiscord | <jtiai> Well there. It's in the main branch. |
21:01:39 | FromDiscord | <ElegantBeef> So your issue was not importing bus, followed by a recursive dependancy |
21:02:58 | * | NimBot joined #nim |
21:03:35 | * | Guest94576 joined #nim |
21:04:20 | FromDiscord | <jtiai> Thank you. And then tons of other errors. |
21:04:34 | FromDiscord | <codic> sent a code paste, see https://play.nim-lang.org/#ix=3lDG |
21:05:27 | FromDiscord | <ElegantBeef> Well you can clean it up by peeking it's exit code every so often then calling close |
21:05:48 | FromDiscord | <codic> hmm... |
21:05:52 | FromDiscord | <codic> doesn't seem like the cleanest of solutions |
21:06:13 | FromDiscord | <ElegantBeef> Well it's for non blocking processes afaik |
21:08:54 | FromDiscord | <codic> it looks like there is a process option `poDaemon` which does it non-blocking, but then I'm not sure when to close still |
21:11:00 | FromDiscord | <codic> sent a code paste, see https://play.nim-lang.org/#ix=3lDH |
21:13:31 | FromDiscord | <ElegantBeef> Nah you dont want to defer |
21:13:44 | FromDiscord | <ElegantBeef> cause it'll just start the process then close it |
21:14:21 | FromDiscord | <codic> so I have to poll? |
21:16:13 | FromDiscord | <ElegantBeef> sent a code paste, see https://play.nim-lang.org/#ix=3lDI |
21:16:16 | FromDiscord | <ElegantBeef> And yes do yourself a favour and use named parameters 😛 |
21:16:30 | FromDiscord | <codic> hm ok |
21:17:31 | FromDiscord | <ElegantBeef> Might be able to use async or a watching thread for this but idk |
21:17:53 | FromDiscord | <codic> sent a code paste, see https://play.nim-lang.org/#ix=3lDJ |
21:18:20 | FromDiscord | <ElegantBeef> Well you have to get rid of the Nim resources |
21:18:28 | FromDiscord | <ElegantBeef> And system resources |
21:22:06 | * | Guest94576 quit (Quit: Guest94576) |
21:23:58 | FromDiscord | <codic> well the polling approach works |
21:24:01 | FromDiscord | <codic> i'll wrap it in a thread |
21:24:32 | FromDiscord | <ElegantBeef> You can just alias the start thread with your variation that throws it into the procPool then have 1:1 api |
21:24:39 | FromDiscord | <ElegantBeef> (edit) "thread" => "process" |
21:25:12 | FromDiscord | <codic> true |
21:27:11 | ForumUpdaterBot | New thread by Alexeypetrushin: Why async server fails with "Too many open files"?, see https://forum.nim-lang.org/t/7911 |
21:29:49 | FromDiscord | <codic> sent a code paste, see https://play.nim-lang.org/#ix=3lDL |
21:30:35 | FromDiscord | <codic> and if I did a mutable iteration and tried doing p.close... |
21:30:38 | FromDiscord | <codic> huh, it still works |
21:30:43 | FromDiscord | <codic> is it then modifying a local copy? |
21:30:55 | FromDiscord | <ElegantBeef> Nah it's cause `Proccess` is a ref |
21:31:38 | * | vicfred joined #nim |
21:31:46 | FromDiscord | <ElegantBeef> Didnt realize that was teh case before hand |
21:31:50 | FromDiscord | <ElegantBeef> (edit) "teh" => "the" |
21:32:04 | FromDiscord | <codic> oh so that should work anyways then |
21:32:20 | FromDiscord | <codic> sent a code paste, see https://play.nim-lang.org/#ix=3lDM |
21:32:26 | FromDiscord | <ElegantBeef> Also worth noting you may want to iterate the collection backwards so you can remove elements |
21:32:41 | FromDiscord | <ElegantBeef> Well if you use the default GC the threads have seperate heaps |
21:33:39 | FromDiscord | <codic> oh yeah I need to remove them too |
21:34:20 | FromDiscord | <codic> and I can't just x.delete x.find y |
21:34:26 | FromDiscord | <codic> because it's immutable |
21:35:55 | FromDiscord | <ElegantBeef> Well if you use `orc` you can do this rather easily |
21:37:36 | FromDiscord | <codic> i am using gc=orc yes |
21:39:00 | FromDiscord | <ElegantBeef> I believe this should work then https://play.nim-lang.org/#ix=3lDN |
21:39:38 | FromDiscord | <ElegantBeef> Orc shares the heap so aslong as you lock and override the thread analysis for the "unsafe" stuff you're fine, dont know if the cast is actually needed here |
21:41:43 | FromDiscord | <creonico> Does 0 count as nil or false in a boolean expression?↵`if not something: echo "something is 0"` |
21:42:10 | FromDiscord | <ElegantBeef> the only falsely value is `false` |
21:42:22 | FromDiscord | <ElegantBeef> You can write converters or explicitly compare |
21:42:30 | FromDiscord | <creonico> what about nil? |
21:42:36 | FromDiscord | <ElegantBeef> Like i said |
21:42:45 | FromDiscord | <ElegantBeef> `isNil` exists |
21:42:51 | FromDiscord | <ElegantBeef> and `!= nil` |
21:43:05 | FromDiscord | <ElegantBeef> You can write converters for this |
21:43:22 | FromDiscord | <ElegantBeef> But it's not very idiomatic and isnt overly readable |
21:43:37 | FromDiscord | <creonico> ok, thank you |
21:44:51 | FromDiscord | <ElegantBeef> sent a code paste, see https://play.nim-lang.org/#ix=3lDP |
21:45:05 | FromDiscord | <codic> oh thats a better solution |
21:45:08 | FromDiscord | <codic> sent a code paste, see https://play.nim-lang.org/#ix=3lDQ |
21:45:08 | FromDiscord | <ElegantBeef> I mean |
21:45:15 | FromDiscord | <ElegantBeef> No reason to cast |
21:45:22 | FromDiscord | <ElegantBeef> you can do `1.bool` |
21:45:47 | FromDiscord | <ElegantBeef> or `bool(1)` If you prefer |
21:45:53 | FromDiscord | <ElegantBeef> Yes |
21:45:55 | FromDiscord | <codic> sent a code paste, see https://play.nim-lang.org/#ix=3lDR |
21:46:14 | FromDiscord | <codic> (edit) "https://play.nim-lang.org/#ix=3lDR" => "https://play.nim-lang.org/#ix=3lDS" |
21:47:16 | FromDiscord | <codic> hmm, when I tried your earlier example (had to change to `spawn pollProcs()` I got `'spawn' takes a GC safe call expression` |
21:47:47 | FromDiscord | <ElegantBeef> add `{.gcsafe.}` to the procedure, and you probably can remove the casting after then |
21:48:00 | FromDiscord | <ElegantBeef> so `proc pollProcs{.gcSafe.} =` |
21:48:20 | FromDiscord | <codic> yeah, but then it complains that it is not actually GC safe because it accesses procPool which is using GC'd memory |
21:48:27 | FromDiscord | <ElegantBeef> Even with the cast? |
21:48:36 | FromDiscord | <ElegantBeef> I've never used spawn so dont know what it requires |
21:49:26 | * | natrys quit (Quit: natrys) |
21:49:43 | giaco | what's the point of using "var T" when T is a ref type? https://nim-lang.org/docs/xmltree.html#mitems.i%2CXmlNode |
21:50:22 | FromDiscord | <ElegantBeef> Well it allows reassigning of the input value, so in this case, more dangerous code possibly 😄 |
21:50:34 | FromDiscord | <ajusa> (you can change what the variable refers to basically) |
21:50:48 | FromDiscord | <ajusa> (edit) "what" => "which reference" |
21:50:50 | FromDiscord | <codic> I kinda feel like this is a bit overkill to spawn a process in the background and close it when it's done; can't I just close all the processes at the end of my program or will that have some consequences? |
21:50:51 | FromDiscord | <ElegantBeef> It's pointless here unless the input has to be `var` for the output to be `var` |
21:50:53 | FromDiscord | <codic> and yeah, with the cast |
21:51:27 | FromDiscord | <ElegantBeef> Yea just use `startProcesses` |
21:51:45 | FromDiscord | <ElegantBeef> Sorry exec |
21:51:47 | * | gangstacat quit (Ping timeout: 260 seconds) |
21:52:05 | FromDiscord | <codic> oh |
21:52:06 | giaco | k thanks |
21:52:11 | FromDiscord | <codic> well |
21:52:21 | FromDiscord | <codic> i should have read the docs page for osproc lol |
21:52:32 | FromDiscord | <codic> but do I still have to close when I am done? |
21:53:02 | * | gangstacat joined #nim |
21:53:06 | FromDiscord | <codic> i don't believe so |
21:55:19 | FromDiscord | <ElegantBeef> Dont think so |
21:55:44 | FromDiscord | <ElegantBeef> You can always look at the source 😛 |
21:56:15 | FromDiscord | <ElegantBeef> Yep calls close |
22:25:05 | * | sagax quit (Remote host closed the connection) |
22:44:12 | FromDiscord | <codic> I wonder why execProcesses doesnt block but execprocess does |
22:45:48 | FromDiscord | <codic> > Executes the commands cmds in parallel. Creates n processes that execute in parallel.↵> ↵> countProcessors: -> number of cores↵what if you have more processes than cores? |
22:49:39 | FromDiscord | <ElegantBeef> Well it does block but does each process in parallel |
23:00:21 | * | leorize quit (Ping timeout: 240 seconds) |
23:03:43 | * | leorize joined #nim |
23:04:52 | FromDiscord | <codic> oh ok |
23:05:10 | FromDiscord | <codic> I think I might ask on the forum, maybe I'll get some more responses on how to do this in an idiomatic way there |
23:08:28 | FromGitter | <awr1> @ElegantBeef `isNil` is preferred iirc, there are some silly edge cases where `!= nil` will type mismatch |
23:13:19 | * | blackpawn quit (Ping timeout: 252 seconds) |
23:14:05 | * | xet7 joined #nim |
23:17:25 | ForumUpdaterBot | New thread by Codic12: Idiomatic way to run a process in the background and close it when appropriate?, see https://forum.nim-lang.org/t/7912 |
23:18:49 | FromDiscord | <carpal> @Matt_ lol |
23:25:52 | * | ehmry quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.) |
23:27:11 | * | ehmry joined #nim |
23:31:21 | FromGitter | <awr1> @codic use `startProcess`for non-blocking |
23:31:56 | FromGitter | <awr1> then use either `waitForExit` or poll using `running` |
23:34:07 | FromGitter | <awr1> the docs for osproc aren't clear but because, e.g. `execProcesses` return the exit code and not a process handle it will wait for that process to finish |
23:35:22 | FromGitter | <awr1> if you want you can use a future on top of this, e.g. https://forum.nim-lang.org/t/5001#31394 |
23:36:47 | FromGitter | <awr1> `asynctools` might be preferable, as also mentioned in that thread |
23:58:53 | FromDiscord | <creonico> Are custom pragmas a thing? |