00:00:04 | FromDiscord | <brainproxy> I need to do a `newCall("foo", ...)`, but I need it to support specifying generic, e.g. `foo[bar]` |
00:00:23 | FromDiscord | <brainproxy> reading the manual, googl'ing, etc., but I'm scratching around again |
00:00:54 | FromDiscord | <ElegantBeef> sent a code paste, see https://play.nim-lang.org/#ix=3nlt |
00:01:20 | FromDiscord | <ElegantBeef> Take a read of my macro tutorial to see how i write macros https://dev.to/beef331/demystification-of-macros-in-nim-13n8 |
00:02:11 | FromDiscord | <ElegantBeef> Basically write the code you want inside a dumptree, then write what you want to do, then take from the input and convert to the desired output |
00:08:40 | ForumUpdaterBot | New thread by Elcritch: Show Nim: Tiny program to reset USB ports on Linux, see https://forum.nim-lang.org/t/8004 |
00:38:16 | * | JStoker quit (Quit: JStoker is gone :() |
00:39:14 | * | JStoker joined #nim |
00:44:43 | * | njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.) |
00:45:09 | * | njoseph joined #nim |
00:45:59 | * | Figworm joined #nim |
00:52:19 | FromDiscord | <reilly> In reply to @geekrelief "Also I have my": It took some fiddling, but it looks like it's working. I understand it's not production-ready, so let's see how nice it plays as I continue to work. |
00:54:33 | * | thomasross quit (Quit: Leaving) |
00:55:16 | FromDiscord | <geekrelief> Cool. It's built on top of godot-nim. So if you use it like godot-nim, it's production-ready. |
00:55:25 | * | nphg joined #nim |
00:56:18 | FromDiscord | <geekrelief> I basically added that warning because of the hot reloading implementation. Early on I was getting a lot of crashy behavior with ORC |
00:57:00 | FromDiscord | <geekrelief> but after tweaking some settings and rewriting the hot reloading, I think you'll find it pretty stable. I haven't made anything serious with it yet though. |
00:57:11 | * | nphg1 quit (Ping timeout: 240 seconds) |
00:57:39 | * | Tlangir joined #nim |
00:59:08 | FromDiscord | <geekrelief> But I'm interested in how hot reloading works out for you. |
01:04:44 | * | arecaceae quit (Remote host closed the connection) |
01:08:03 | * | arecaceae joined #nim |
01:11:52 | FromDiscord | <reilly> I think something has gone slightly wrong. https://media.discordapp.net/attachments/371759389889003532/844744199295467560/unknown.png |
01:20:34 | FromDiscord | <Rika> nah looks normal to me xdd |
01:20:46 | FromDiscord | <Rika> in all seriousness im betting its nimsuggest |
01:21:40 | FromDiscord | <reilly> In reply to @Rika "in all seriousness im": I should have taken a better mental note of exactly what it was, but I'm 99% sure it was endless generic terminal instances. |
01:22:33 | FromDiscord | <Rika> its usually nimsuggest that causes high memory or high cpu usage from what ive seen and experienced |
01:23:20 | FromDiscord | <reilly> I know the Nim extension has a tendency to leak instances of Nimsuggest, but not 1070 of them. |
01:25:33 | leorize[m] | are you using the nimsaem extension? |
01:26:33 | FromDiscord | <reilly> In reply to @leorize "are you using the": Yes. |
01:26:52 | leorize[m] | @saem ^ |
01:26:56 | FromDiscord | <reilly> It has to be a problem with GDNim though, this has never happened before now and it's the only thing that's changed. |
01:27:02 | FromDiscord | <reilly> @geekrelief |
01:28:13 | FromDiscord | <reilly> Nope, nevermind, it's Nimsuggest. Last time it looked like it was "Console Window Host" (but to be fair, I didn't look too hard) but this time it is, without a doubt, Nimsuggest. |
01:28:15 | FromDiscord | <ElegantBeef> Well it probably is spooling up a nimsuggest instance per file since it's not a typical nim project |
01:28:53 | FromDiscord | <reilly> Beef is probably right, cause there's a hell of a lot of files in this project. |
01:29:11 | FromDiscord | <reilly> GDScript it is, I guess 🙃 |
01:29:18 | FromDiscord | <geekrelief> In reply to @reilly "It has to be": Yeah, I disable nimsuggest. Sometimes it works fine, then all of a sudden my system goes to a crawl |
01:29:34 | FromDiscord | <ElegantBeef> You can tell nimsuggest the project file using the config |
01:29:47 | FromDiscord | <ElegantBeef> It's in the nim extensions settings |
01:30:03 | FromDiscord | <reilly> I force-closed VSCode and it gave me this doozy: https://media.discordapp.net/attachments/371759389889003532/844748769961443388/unknown.png |
01:30:12 | FromDiscord | <reilly> So many error windows that the shadow is practically an outline. |
01:31:30 | FromDiscord | <Rika> the operation could not be completed |
01:33:14 | FromDiscord | <Rika> anyway its probably best to turn nimsuggest off |
01:33:22 | FromDiscord | <Rika> how often do you guys use it? i barely do |
01:33:46 | FromDiscord | <ElegantBeef> I always have it on |
01:34:02 | FromDiscord | <reilly> I'd rather know where my problems are before compiling. |
01:34:07 | FromDiscord | <Rika> i mean i have it on but not for suggestions |
01:34:54 | FromDiscord | <ElegantBeef> Yea i use it for suggestions |
01:36:35 | FromDiscord | <reilly> In reply to @ElegantBeef "You can tell nimsuggest": Could you elaborate on this? Does it prevent Nimsuggest from checking files outside of a certain directory? |
01:37:00 | FromDiscord | <ElegantBeef> It just tells it where the root file is so you can properly use nim suggest instead of once per file |
01:38:14 | FromDiscord | <reilly> So does that mean it checks one file or what? The only files that should ever need checking will exist in one directory, so if I can limit Nimsuggest to just that folder, I'm golden. |
01:38:50 | FromDiscord | <Rika> nimsuggest needs a project root file |
01:39:01 | FromDiscord | <Rika> otherwise it will check all files in the project folder |
01:39:58 | FromDiscord | <geekrelief> That might be incompatible with the way hot reloading is setup to work with gdnim. Each `component` is a root file since they each produce a dll. |
01:40:11 | FromDiscord | <reilly> I was about to say ^ |
01:40:18 | FromDiscord | <geekrelief> If you don't want to use hot reloading you can turn it off |
01:40:26 | FromDiscord | <geekrelief> there's a switch in build.ini |
01:40:52 | FromDiscord | <geekrelief> then you can create one component file and a nim.cfg and use that as the root for the rest of your project |
01:42:08 | FromDiscord | <geekrelief> Something like `components/myproject.nim` `components/nim.cfg` the nim.cfg has `--path:"myproject_src"` and then you create a `myproject_src` directory and put your nim files in there |
01:42:19 | FromDiscord | <reilly> I could just use an empty Node2D as my root, since I have to have a main scene anyway. |
01:42:53 | FromDiscord | <geekrelief> you could just create your root as a the only component in the project |
01:42:59 | * | krux02 quit (Remote host closed the connection) |
01:43:00 | FromDiscord | <geekrelief> actually you could still get hot reloading that way |
01:43:10 | FromDiscord | <reilly> I don |
01:43:25 | FromDiscord | <reilly> I don't really care about hot reloading anyway; I just want it to work. |
01:44:11 | FromDiscord | <geekrelief> ok, turn off hot reloading in build.ini, create your root component like I said above |
01:44:56 | FromDiscord | <reilly> I'm going to start from scratch just to make sure I don't have any other funky things going on, so bear with me. |
01:45:24 | FromDiscord | <geekrelief> you can run the `./build init` command to create a clean branch |
01:45:53 | FromDiscord | <reilly> You're right! I was going to do that process all over again like a doofus. |
01:46:54 | FromDiscord | <reilly> Nope, nevermind, I removed all the git stuff after I initialized it since I didn't want that link. I'll be quick. |
01:50:52 | * | ^GaveUp^ joined #nim |
01:51:53 | FromDiscord | <reilly> In reply to @ElegantBeef "It just tells it": Does the nim.cfg have to contain anything, or is it just the existence of the file that matters? |
01:52:39 | FromDiscord | <ElegantBeef> Should just need to exist so it can reason where the root is i believe, saem can probably give more help when he's about |
01:53:10 | * | GaveUp quit (Ping timeout: 258 seconds) |
01:53:10 | * | ^GaveUp^ is now known as GaveUp |
01:59:22 | * | arkurious quit (Quit: Leaving) |
02:09:34 | FromDiscord | <reilly> Looking good right now... Got a basic FPS counter going, VSCode isn't exploding. |
02:20:07 | FromDiscord | <geekrelief> In reply to @reilly "Looking good right now...": Cool, btw. Are you familiar with how gdnative works? If you're going to create 1 file to import all your classes, you'll have to generate `gdns` files for each class you create and have it point to the `gdnlib`. You probably need to edit `tasks.nim` to disable the file modification time check, or compile with the `--nc` flag. |
02:21:06 | * | njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.) |
02:21:10 | FromDiscord | <reilly> In reply to @geekrelief "Cool, btw. Are you": I'll cross that bridge when I come to it. |
02:28:16 | FromDiscord | <reilly> Worst-case scenario, I hit a roadblock and have to use GDScript. Oh well. |
02:30:53 | * | GaveUp quit (Ping timeout: 246 seconds) |
02:33:35 | * | GaveUp joined #nim |
02:38:04 | FromDiscord | <Rika> is there a "runForever" proc in asyncdispatch that doesnt crash when all async procs scheduled are finished |
02:38:12 | FromDiscord | <Rika> "crash" more of raise |
02:44:02 | FromDiscord | <reilly> In reply to @Rika "is there a "runForever"": Why can't you just catch it? |
02:45:13 | FromDiscord | <Rika> i can, i ask for better solutions |
02:46:51 | * | ^GaveUp^ joined #nim |
02:47:15 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=3nlZ |
02:49:11 | * | GaveUp quit (Ping timeout: 240 seconds) |
02:49:11 | * | ^GaveUp^ is now known as GaveUp |
03:03:33 | * | motersen_ quit (Ping timeout: 240 seconds) |
03:04:52 | * | motersen joined #nim |
03:06:52 | * | azed joined #nim |
03:14:34 | * | nisstyre quit (Quit: WeeChat 3.1) |
03:20:21 | * | motersen quit (Ping timeout: 240 seconds) |
03:22:09 | * | motersen joined #nim |
03:28:51 | * | spiderstew_ joined #nim |
03:29:57 | * | bozaloshtsh_ quit (Quit: ZNC 1.7.5 - https://znc.in) |
03:31:41 | * | spiderstew quit (Ping timeout: 258 seconds) |
03:31:47 | * | bozaloshtsh joined #nim |
03:31:48 | * | bozaloshtsh quit (Changing host) |
03:31:48 | * | bozaloshtsh joined #nim |
04:06:05 | FromDiscord | <garett> Thinking of refactoring glm to use clang’s `ext_vector_type`. Maybe possible with `{.emit.}`? |
04:08:45 | FromDiscord | <garett> Not sure how to define a Nim type with emit pragma |
04:09:47 | FromDiscord | <garett> Had my 2nd shot today, so not thinking clearly |
04:12:45 | FromDiscord | <garett> I see the manual has a type emit example 😎 |
04:21:12 | * | fantis quit (Remote host closed the connection) |
04:24:43 | * | snowolf joined #nim |
05:12:19 | * | NimBot joined #nim |
05:14:53 | * | narimiran joined #nim |
05:18:43 | * | azed quit (Quit: WeeChat 3.1) |
05:42:29 | * | stisa quit (Ping timeout: 245 seconds) |
05:42:29 | * | reversem3 quit (Ping timeout: 245 seconds) |
05:43:14 | * | reversem3 joined #nim |
05:43:16 | * | stisa joined #nim |
05:46:30 | saem | Looks like people figured it out, neat. |
05:58:35 | FromDiscord | <ElegantBeef> Yea your saviour was here |
05:59:44 | saem | Thanks |
06:00:06 | saem | You're my beefy jebus |
06:02:38 | FromDiscord | <ElegantBeef> Way to call me fat |
06:06:47 | * | Vladar joined #nim |
06:16:11 | * | rockcavera quit (Remote host closed the connection) |
06:27:58 | ForumUpdaterBot | New Nimble package! tm_client - TwineMedia API client library for Nim, see https://github.com/termermc/nim-tm-client |
06:48:02 | * | al1ranger joined #nim |
07:05:53 | * | al1ranger left #nim ("Leaving") |
07:07:34 | * | al1ranger joined #nim |
07:07:56 | * | al1ranger quit (Quit: Leaving) |
07:30:25 | * | koltrast joined #nim |
07:35:00 | * | hoek quit (Read error: Connection reset by peer) |
07:35:01 | * | ormiret quit (Ping timeout: 250 seconds) |
07:35:24 | * | Adeon quit (Ping timeout: 245 seconds) |
07:35:31 | * | d10n-work quit (Ping timeout: 260 seconds) |
07:36:49 | * | npgm quit (Ping timeout: 276 seconds) |
07:37:47 | * | ormiret joined #nim |
07:37:58 | * | kinkinkijkin quit () |
07:38:15 | * | hoek joined #nim |
07:38:25 | * | Adeon joined #nim |
07:38:38 | * | d10n-work joined #nim |
07:38:39 | * | npgm joined #nim |
07:41:59 | * | npgm quit (Max SendQ exceeded) |
07:46:31 | * | npgm joined #nim |
08:10:45 | * | hendursaga quit (Ping timeout: 240 seconds) |
08:16:13 | * | hendursaga joined #nim |
08:49:22 | * | pbb joined #nim |
09:10:41 | * | Arrrrrrrr joined #nim |
09:22:58 | * | krux02 joined #nim |
09:26:51 | * | PMunch joined #nim |
09:58:32 | ForumUpdaterBot | New thread by Jasonfi: Transpile Nim to Dart/Flutter?, see https://forum.nim-lang.org/t/8005 |
10:17:48 | * | Hasnep[m] joined #nim |
10:18:05 | FromDiscord | <jake> @d4rckh shut up |
10:18:30 | FromDiscord | <jake> anyone know a good library for parsing binaries? |
10:20:39 | PMunch | Did you just tell someone who hasn't spoken all day to shut up? |
10:20:53 | PMunch | binaryparse/binarylang might be what you're looking for |
10:21:03 | PMunch | Depends on what you mean by "binaries" |
10:21:58 | FromDiscord | <jake> In reply to @PMunch "Did you just tell": hes my friend its a joke |
10:22:10 | FromDiscord | <jake> he is romanian |
10:22:33 | PMunch | Haha, is there some Romanian stereotype about not shutting up? |
10:22:45 | FromDiscord | <jake> nah |
10:22:49 | FromDiscord | <jake> i dont think so |
10:23:05 | FromDiscord | <jake> they have a stereotype for trolling though |
10:24:39 | PMunch | Aah, I see |
10:25:14 | FromDiscord | <jake> with binarylang do you think I would be able to check for mitigations? |
10:25:23 | * | wanr[m] joined #nim |
10:25:23 | FromDiscord | <jake> or would I need to use something like readelf |
10:25:28 | * | fifth quit (Quit: WeeChat 3.1) |
10:25:47 | * | fifth joined #nim |
10:26:03 | PMunch | mitigations? |
10:26:13 | FromDiscord | <jake> yes |
10:26:16 | PMunch | I mean with binarylang you would have to write your own ELF parser |
10:26:26 | FromDiscord | <jake> right |
10:26:28 | PMunch | It's just a language for parsing binary objects |
10:26:40 | PMunch | Or for writing parsers to parse binary objects rather |
10:27:01 | FromDiscord | <jake> https://media.discordapp.net/attachments/371759389889003532/844883905545764885/unknown.png |
10:27:01 | FromDiscord | <jake> like this |
10:27:15 | FromDiscord | <jake> I wanted to write something like that in nim |
10:27:17 | PMunch | I mean ELF files aren't the most complicated things to parse though |
10:27:23 | FromDiscord | <jake> ye |
10:31:53 | * | MarderIII joined #nim |
10:52:56 | * | krux02 quit (Remote host closed the connection) |
11:10:56 | * | aeverr quit () |
11:11:51 | * | pbb quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.) |
11:17:33 | * | pbb joined #nim |
11:17:49 | * | pbb quit (Client Quit) |
11:18:39 | * | pbb joined #nim |
11:47:21 | * | xet7 quit (Quit: Leaving) |
11:47:42 | Hasnep[m] | Can someone help explain what megatest is in testament? Thanks :) |
11:47:43 | * | xet7 joined #nim |
12:03:17 | * | Cadey left #nim ("WeeChat 3.1") |
12:25:29 | * | xet7 quit (Quit: Leaving) |
12:25:47 | * | xet7 joined #nim |
12:27:04 | * | Kumool quit (Ping timeout: 245 seconds) |
12:27:37 | * | xet7 quit (Remote host closed the connection) |
12:27:39 | FromDiscord | <ajusa> Anyone know if I can limit the maximum size of a hash table? Use case is a caching mechanism that shouldn't run out of memory, so I don't want the table to grow unbounded |
12:27:58 | * | xet7 joined #nim |
12:28:10 | FromDiscord | <ajusa> (edit) "unbounded" => "unbounded. I don't mind if random keys are removed to make that happen" |
12:32:30 | FromDiscord | <dp> sent a long message, see http://ix.io/3nnE |
12:32:33 | * | rockcavera joined #nim |
12:37:51 | * | arkurious joined #nim |
12:43:45 | PMunch | ajusa, maybe this will be helpful to you: https://github.com/PMunch/nim-cache |
12:50:24 | * | Vladar quit (Remote host closed the connection) |
12:54:35 | * | Vladar joined #nim |
13:00:04 | * | hendursaga quit (Write error: Connection reset by peer) |
13:00:41 | * | hendursaga joined #nim |
13:10:27 | FromDiscord | <Rika> In reply to @dp "Hello! I just tried": you are compiling in debug, which contains stack traces |
13:10:34 | FromDiscord | <Rika> well rather line information |
13:10:40 | FromDiscord | <Rika> the var F is the line info |
13:13:36 | * | tane joined #nim |
13:15:44 | FromDiscord | <dp> In reply to @Rika "well rather line information": Thanks for the answer. Adding -d:release removes all the lines |
13:16:08 | FromDiscord | <Rika> 👍 |
13:18:33 | FromDiscord | <ajusa> Thanks PMunch, I'll check that out |
13:24:54 | * | fantis joined #nim |
13:32:36 | * | Arrrrrrrr quit (Quit: Arrrrrrrr) |
13:39:53 | * | hyiltiz quit (Ping timeout: 240 seconds) |
13:40:33 | * | hyiltiz joined #nim |
13:40:33 | * | hyiltiz quit (Changing host) |
13:40:33 | * | hyiltiz joined #nim |
13:46:21 | Clonkk[m] | What do you do when the compiler throws an excpetion :D ? |
13:48:54 | * | whaletechno joined #nim |
13:49:34 | PMunch | Build a debug build of the compiler and submit an issue |
13:49:55 | PMunch | Or better yet fix it and submit a PR |
13:56:34 | * | PMunch quit (Quit: leaving) |
13:58:02 | Clonkk[m] | Sure, whenever I got time to reproduce it and open an issue. But how do you debug it when the compiler gives you nothing |
14:03:31 | * | rockcavera quit (Remote host closed the connection) |
14:04:56 | * | narimiran quit (Ping timeout: 260 seconds) |
14:06:00 | Prestige | Does it give anything if you build the compiler in debug mode first? |
14:06:14 | * | MarderIII quit (Ping timeout: 245 seconds) |
14:06:20 | * | noeontheend quit (Ping timeout: 246 seconds) |
14:07:42 | FromDiscord | <mischa_u> https://nim-lang.org/docs/intern.html#debugging-the-compiler |
14:17:58 | * | rockcavera joined #nim |
14:23:40 | Clonkk[m] | Got a wonderful stacktrace |
14:23:49 | * | Clonkk[m] < https://matrix.org/_matrix/media/r0/download/matrix.org/SkkluaXfMTYcFWzmaKxyPbQE/message.txt > |
14:23:59 | Clonkk[m] | I still have no clue what part of my code fails :D |
14:26:02 | FromDiscord | <Goat> Is it possible to turn your custom type into an iterator? |
14:27:51 | Clonkk[m] | You can implement ``items`` iterator for any type. It's in the manual |
14:30:23 | leorize[m] | Clonkk: are you using a typed macro by any chance? |
14:30:38 | * | arecaceae quit (Remote host closed the connection) |
14:30:42 | Clonkk[m] | Yup |
14:31:11 | Clonkk[m] | Am I not supposed to 😛 ? |
14:31:45 | Clonkk[m] | Macro with typed parameters are supposed to be allowed I thought ? |
14:32:20 | leorize[m] | do you perform any modification in the macro to call nodes? |
14:36:18 | * | arecaceae joined #nim |
14:36:18 | Clonkk[m] | I call proc & template in my macro, yes |
14:39:14 | Clonkk[m] | It seems the error is linked to the presence of an iterator |
14:39:25 | Clonkk[m] | Removing my macors code actually doesn't change anything |
14:41:22 | leorize[m] | congrats, you hit the most annoying typed macro bug :) |
14:41:23 | leorize[m] | see here for a workaround: https://github.com/disruptek/cps/blob/master/cps/spec.nim#L436 |
14:41:23 | leorize[m] | you can try copying that workaroundRewrites into your macro |
14:41:23 | leorize[m] | then run it on the result ast before returning |
14:41:23 | leorize[m] | usually that would fix it |
14:41:23 | leorize[m] | in the same file linked we also have `normalizingRewrites` that turn typed ast into something that you can modify without the compiler puking on the result |
14:41:24 | leorize[m] | could be useful too |
14:42:44 | * | ehmry left #nim ("leaving freenode") |
14:42:52 | Clonkk[m] | Well, that'll teach me to play with @mratsim's code 😆 |
14:44:25 | Clonkk[m] | This is still very weird because the code I have to remove to make it compile again is iterators implementation |
14:44:56 | leorize[m] | if typed macro is not weird I don't know what is |
14:45:34 | leorize[m] | we documented this stuff a lot in cps, so you can read the procs I told you |
14:46:00 | leorize[m] | the gist of it is typed macros contains many stupid nodes that you can't modify or the compiler will die in very creative ways |
14:46:21 | leorize[m] | like `the first parameter is of type void` for a string literal :) |
14:46:39 | Clonkk[m] | Hmm |
14:47:08 | leorize[m] | and sigmatch crashes is a very frequent sight |
14:48:08 | Clonkk[m] | So it's possible I had the issue. But it's not the only thing that goes wrong. Commenting all of my macros (and generally speaking, not compiling them) still gets me the same errors |
14:48:11 | FromDiscord | <kodkuce> totaly late response, but first thing that killed me for python was that global kayword but i guess you have to have it |
14:52:18 | FromDiscord | <mratsim> In reply to @Clonkk "Well, that'll teach me": what code? |
14:53:34 | Clonkk[m] | <FromDiscord "<mratsim> In reply to @Clonkk "W"> I was playing with Arraymancer slicing code (desugar proc) |
14:53:50 | Clonkk[m] | But actually y he error was un-related |
14:54:04 | Clonkk[m] | It's caused by a weird interaction of template`.` and varargs |
14:58:14 | federico3 | is this channel moving away from freenode? |
14:58:29 | * | noeontheend joined #nim |
14:58:31 | * | rockcavera quit (Remote host closed the connection) |
15:00:23 | * | MarderIII joined #nim |
15:03:00 | Prestige | Hope not |
15:04:13 | FromDiscord | <Rika> Why |
15:04:24 | Clonkk[m] | I'll check it out, thanks for your help leorize |
15:05:22 | leorize[m] | Clonkk: here is how we use it in cps: normalizingRewrites before touching the ast, workaroundRewrites before returning |
15:05:22 | federico3 | Freenode has been victim of a takeover and the whole historical staff left to create libera.chat https://fuchsnet.ch/freenode-resign-letter.txt |
15:05:23 | leorize[m] | hope that helps |
15:05:31 | * | kaliy quit (Remote host closed the connection) |
15:06:09 | Prestige | I'm skeptical about the whole "takeover" and I think moving some people to another server would just fragment the users |
15:06:28 | * | kaliy joined #nim |
15:06:34 | Clonkk[m] | <leorize[m] "hope that helps"> Well, it helped me understood the issue so yes :). For my specific use case, I can have a workaround by using a ``template`` and ``varargs[untyped]`` instead of a ``proc`` and it seems to do the trick |
15:07:01 | Clonkk[m] | I'll see if it still holds true when I'll use it in more complex macros |
15:07:09 | * | kaliy quit (Client Quit) |
15:07:53 | * | kaliy joined #nim |
15:08:40 | * | kaliy quit (Client Quit) |
15:09:04 | fantis | I'm passing a nim callback to a C fn where one of the cb params is a pointer to `struct { char* text; unsigned int length; }`, which I've wrapped nim side as `object text: cstring length: uint`. |
15:09:17 | fantis | In the cb, I receive the struct as `ptr arg` (`sometype* arg` in the C signature) and do `arg[].text = cstring("balls")` and `args[].length = 5` and it will crash because the C code attempts to free it and fails. I've tried other things besides `cstring()` too without luck. Should I be able to use the arg in a way that allows the C code to free it, specifically the `.text`? |
15:09:19 | * | kaliy joined #nim |
15:11:40 | * | Xe joined #nim |
15:12:39 | Clonkk[m] | <fantis "In the cb, I receive the struct "> If your C library calls ``free`` on the ``char *`` pointer you passed, it means you need to pass a ``char *`` that has been allocated using ``malloc`` |
15:13:00 | fantis | so I need to alloc() it nim side? |
15:13:14 | Clonkk[m] | But are you sure this is what's happening ? I would find very un-common (and bad) to have a C library that frees something is hasn't allocated |
15:14:28 | fantis | I'm pretty sure. It doesn't use `free()` it uses a library specific free function on the `args.text` |
15:14:50 | fantis | I should probably come back to this with some code snippets I think |
15:15:00 | Clonkk[m] | So in this case |
15:15:04 | Clonkk[m] | Try to make a working C examples |
15:15:09 | Clonkk[m] | Then bind it |
15:15:22 | Clonkk[m] | * Then convert it |
15:15:37 | fantis | alright, yea, good idea. I'll try that |
15:15:53 | Clonkk[m] | You need to understand how your C library handles memory |
15:16:01 | Clonkk[m] | How it allocate, how it frees, and when |
15:17:42 | fantis | in general though, if I do `alloc()` in nim and then pass the pointer to a C fn, should I be able to free it C side? |
15:18:31 | Clonkk[m] | No, ``alloc`` and ``dealloc`` are not necessarily mapped to ``malloc`` and ``free`` |
15:18:54 | Clonkk[m] | If you specifically want ``malloc`` and ``free`` I would ``importc`` them |
15:19:40 | Clonkk[m] | I think ``alloc`` and ``dealloc`` only correspond to their C counterpart if you compile with ``-d:useMalloc`` (to be confirmed, I'm not 100% sure) |
15:20:00 | fantis | ah, I thought I could so I used it as sort of sanity check which drove me further into despair when it didn't work |
15:20:26 | fantis | thanks. I'll try to implement the callback in C and see if I get there |
15:21:04 | Clonkk[m] | It's usually easier to go from C to Nim than the opposite |
15:30:11 | * | Xe quit (Quit: WeeChat 3.1) |
15:32:29 | fantis | alright, started working when I `importc`'ed `malloc()` and replaced `alloc()` with it. thanks Clonkk :) |
16:00:13 | * | ligist[m] quit (Quit: Idle for 30+ days) |
16:08:45 | * | whaletechno quit (Quit: ha det bra) |
16:10:04 | * | qwr quit (Quit: leaving) |
16:12:31 | FromDiscord | <inv> Hi, I was trying to check if I need new PC or mac or something like this and created the repo with scripts which do nim-build-benchmark: https://github.com/inv2004/bench_nim_build/ |
16:13:07 | FromDiscord | <inv> Because, I suppose it is the only interesting thing for me on laptop/pc 🙂 |
16:13:21 | FromDiscord | <inv> You can find some stats here: https://github.com/inv2004/bench_nim_build/issues |
16:14:20 | FromDiscord | <inv> And, if you would like, you can run the scripts from README and they will automatically create PR's into the repo |
16:15:09 | FromDiscord | <inv> Probably it would help to find good/bad cpu to someone else too, or, at least to keep some statistics |
16:16:11 | FromDiscord | <inv> The interesting thing I found: that my 150$ i5-7500 builds Nim faster in WSL2 that macmini M1 |
16:16:18 | FromDiscord | <inv> (edit) "that" => "than" |
16:16:39 | FromDiscord | <inv> (edit) "in WSL2" => "(in WSL2)" |
16:22:22 | * | vicfred joined #nim |
16:38:16 | * | acidx left #nim (#nim) |
16:53:17 | * | jxy quit (Quit: leaving) |
17:15:22 | * | Vladar quit (Remote host closed the connection) |
17:36:49 | * | l1x joined #nim |
18:05:38 | * | superbia joined #nim |
18:07:53 | * | jjido joined #nim |
18:31:46 | reversem3 | Does nim have bin to hex to hex to bin ? or do I need to calculate by hand ? |
18:32:35 | FromDiscord | <ElegantBeef> strutils has `toHex` and `fromHex` |
18:33:34 | reversem3 | sorry I mean bin to dec or dec to bin |
18:36:55 | FromDiscord | <ElegantBeef> there is `toBin` and `fromBin` aswell there |
18:37:04 | FromDiscord | <ElegantBeef> Only for ints though |
18:43:19 | reversem3 | yeah i see you have to use a string also , ok cool thanks |
18:58:04 | * | federico3 left #nim ("http://quassel-irc.org - Chat comfortably. Anywhere.") |
18:59:33 | * | narimiran joined #nim |
19:02:14 | * | rockcavera joined #nim |
19:12:51 | * | sysadmin joined #nim |
19:41:41 | * | superbia quit (Quit: WeeChat 3.1) |
19:49:56 | * | aenesidemus joined #nim |
19:55:37 | * | l1x quit (Quit: Connection closed for inactivity) |
19:57:23 | * | noeontheend quit (Ping timeout: 246 seconds) |
20:42:58 | * | narimiran quit (Ping timeout: 265 seconds) |
20:49:19 | * | tane quit (Quit: Leaving) |
20:58:27 | * | gangstacat quit (Quit: Ĝis!) |
21:23:10 | * | MarderIII quit (Quit: Leaving) |
21:23:52 | FromGitter | <bung87> Error: cannot instantiate: 'Table[A, B]'; Maybe generic arguments are missing? |
21:24:10 | FromGitter | <bung87> `connectAttrs:Table[string,string] = default(Table[string,string])` my proc defines like this |
21:30:44 | FromGitter | <bung87> hmm define alias type for now |
21:47:06 | * | sagax quit (Ping timeout: 240 seconds) |
21:57:18 | * | jjido quit (Quit: Connection closed for inactivity) |
22:12:57 | * | aenesidemus quit (Quit: Leaving) |
22:13:18 | FromDiscord | <reilly> I think I might just use a pure Nim engine instead. yglukhov/rod doesn't list its features, so how does it compare to liquidev/rapid? (Besides Rod having 3D and Rapid not.) |
22:14:46 | FromDiscord | <reilly> And on that note, if you have any recommendations for Nim game engines that aren't listen on https://github.com/nim-lang/Nim/wiki/Curated-Packages#games, I'm listening. |
22:14:53 | FromDiscord | <reilly> (edit) "listen" => "listed" |
22:17:12 | * | D_ quit (Quit: No Ping reply in 180 seconds.) |
22:18:18 | * | D_ joined #nim |
22:18:42 | * | D_ is now known as Guest26540 |
22:18:58 | FromDiscord | <reilly> I think I may have to use Rapid since the documentation for Rod seems to be... Less than ideal. |
22:20:24 | * | Guest26540 is now known as D_ |
22:22:10 | Zoom[m] | How can I output an array of char all at once? |
22:24:28 | FromDiscord | <reilly> Do you not just mean `echo x`? |
22:25:25 | FromDiscord | <reilly> If you want to print it without the brackets, you can `import strutils` then do something like `echo x.join(", ")` |
22:26:06 | Zoom[m] | Nope, just as a string but skipping the convertion to a seq |
22:30:51 | Zoom[m] | Can't think of anything besides either resorting to stdout.write char by char, or `@` it and then `cast[string](seq)` |
22:32:50 | FromDiscord | <reilly> Maybe I don't understand what you're really asking here, but couldn't you do `x.join("")` to join every item without any spacing between them? |
22:33:45 | FromDiscord | <reilly> The implementation of `join` doesn't use a seq, which seems like what you want. |
22:35:57 | FromDiscord | <reilly> sent a code paste, see https://play.nim-lang.org/#ix=3nq5 |
22:36:30 | FromDiscord | <reilly> Oops, forgot to edit the arguments, and since you're on Matrix you won't see an edit 😛 |
22:36:37 | * | abm joined #nim |
22:36:37 | Zoom[m] | reilly it uses a string, which is a seq, so it's not better than what I already do, except without a cast |
22:38:00 | FromDiscord | <reilly> I have to ask, what are you working on where it makes a difference? |
22:38:35 | Zoom[m] | It doesn't, I just wanted to know how I would do it if it did |
22:39:56 | Zoom[m] | Something like making a cstring of array.len + 1 for a zero char and copymem data from array to it? |
22:40:15 | FromDiscord | <reilly> If all you want to do is print an array of chars to look like a string, with absolutely nothing else happening behind the scenes, then `for char in x: stdout.write(char)` seems like your best bet. |
22:40:35 | FromDiscord | <reilly> To me though, it seems like you're over-engineering the problem. |
22:41:31 | Zoom[m] | I'm just wondering, sorry for taking your time. Thought maybe there's an obvious way to do it |
22:43:26 | FromDiscord | <reilly> Don't apologize, it's not like I have anything better to do. It is an interesting question, I guess, cause `for char in x: stdout.write(char)` isn't exactly "all at once..." |
22:44:22 | Zoom[m] | The thing is, you could in theory do it without a heap, as the length is known. cstring is just a zero-terminated array, so we're almost there. |
22:44:52 | Zoom[m] | If I understand it all correctly |
22:45:56 | FromDiscord | <reilly> Maybe someone else knows a hacky way of getting what you want done, but I wouldn't know since, in my eyes, it's just not a practical thing to worry about. |
22:47:26 | FromDiscord | <reilly> Good luck with figuring out something better, if that's what you want to do. Since you're getting really down-to-the-metal here, maybe some inline assembly or C might be what you need. |
22:49:16 | Zoom[m] | Also, it's probably not the right place, but anyway. If I'm polling getch() in a loop in a thread. Is there a risk it affects outputting to a terminal from another? Do I need to lock stdout? |
22:51:47 | FromDiscord | <reilly> On that note, I was just thinking: Using a for loop to print your char array may not play nice if things are asynchronous or multithreaded. |
22:52:31 | FromDiscord | <reilly> Granted, depending on the size of your array, it should finish so fast that the odds of your echo getting interrupted are tiny, but it's not impossible. |
22:53:14 | FromDiscord | <reilly> I don't know how nice `getch()` plays with threads... I'd just create a little test file to see what happens if I were you. |
22:53:47 | * | abm quit (Read error: Connection reset by peer) |
22:57:57 | Zoom[m] | I don't know. I'd like it to not screw the layout on an occasion, since I actually echo only when the buffer with the data changes, to not burn the cycles |
22:58:36 | Zoom[m] | But seems it works even with the loop for now. I don't trust it, though. |
23:55:41 | * | noeontheend joined #nim |
23:57:47 | * | evan joined #nim |
23:58:11 | * | evan is now known as Guest41628 |
23:59:23 | ForumUpdaterBot | New thread by Fire: Is it possible to get a linux distro to include Nim?, see https://forum.nim-lang.org/t/8007 |
23:59:37 | * | Guest41628 left #nim (#nim) |