00:00:23 | FromDiscord | <Elegantbeef> Glad i could stand by and just be confused! đ |
00:00:39 | ehmry | anytime |
00:02:59 | ehmry | https://git.syndicate-lang.org/ehmry/preserves-nim/src/branch/trunk/src/preserves.nim#L639 |
00:03:39 | ehmry | translating Nim types to some binary encoding |
00:05:08 | FromDiscord | <codic> Prestige: It doesn't work, Xephyr uses software rendering |
00:05:21 | FromDiscord | <codic> I saw somewhere a way to pass through the GPU but I don't remember way |
00:05:24 | FromDiscord | <codic> Where |
00:09:43 | arkanoid | does a converter act more like a template or a proc? |
00:09:52 | FromDiscord | <Elegantbeef> It's a proc |
00:10:05 | arkanoid | ok thanks |
00:10:19 | arkanoid | so I bet it's faster to make a template for frequent conversions |
00:10:41 | arkanoid | (like for C interop frequent cast) |
00:10:52 | FromDiscord | <Elegantbeef> Small procs will get inlined in release/danger builds built with -d\:lto |
00:11:17 | FromDiscord | <Elegantbeef> Guess `-d:lto` isnt needed for that but it helps |
00:11:25 | FromDiscord | <Elegantbeef> helps performance |
00:11:31 | arkanoid | well, ok, less typing |
00:12:59 | arkanoid | may I ask you a favor? I'm binding libgirepository and I'm testing it against this example here https://gi.readthedocs.io/en/latest/writingbindings/libgirepository.html , but the original example fails with SIGABRT to me |
00:13:07 | arkanoid | could you plese try to compile and run on your box? |
00:13:56 | arkanoid | I compile with "gcc example.c -o example -I/usr/include/gobject-introspection-1.0 (pkg-config --cflags --libs glib-2.0) -lgirepository-1.0" |
00:17:22 | FromDiscord | <Elegantbeef> Getting an erro it cannot find `glib-object.h` |
00:17:29 | FromDiscord | <Elegantbeef> And yes i have the package installed |
00:18:30 | FromDiscord | <Elegantbeef> Well actually it bitches about the `()` |
00:19:41 | arkanoid | sorry, I use fish shell, you have to $(...) with bash/zsh |
00:19:48 | arkanoid | my fault |
00:20:03 | FromDiscord | <Elegantbeef> Prints fine here |
00:20:50 | arkanoid | good! I've just waster 3 hours for a version mismatch |
00:20:52 | arkanoid | thanks |
00:20:59 | arkanoid | what does it print? |
00:21:01 | FromDiscord | <Elegantbeef> No problem |
00:21:04 | arkanoid | just for the sake of clarity |
00:21:07 | FromDiscord | <Elegantbeef> "Hello world" |
00:22:11 | arkanoid | no "domain", no "line 42"? |
00:22:27 | FromDiscord | <Elegantbeef> Just "hello world" |
00:22:44 | FromDiscord | <Elegantbeef> Wait a minute i'm dumb |
00:23:10 | FromDiscord | <Elegantbeef> I had a program i tested earlier that i was running cause i named the C file `test` and forgot c doesnt output a binary with that name |
00:23:25 | arkanoid | :D |
00:23:28 | FromDiscord | <Elegantbeef> Yep i also get the abort |
00:23:29 | FromDiscord | <demotomohiro> Are you trying to make a libgirepository binding in different way from gintro?â”https://github.com/StefanSalewski/gintro |
00:24:04 | arkanoid | Elegantbeef, ok thanks, so it's just a rubbish example. Not sure |
00:25:37 | arkanoid | demotohiro, I'm just getting my hands dirty with the new automatic nim binding generator futhark, and for my experiment I've been targetting libgirepository to enable generic interfacing to gobject universe. It does work, at least it seems to apart from this bad example |
00:28:03 | FromDiscord | <demotomohiro> Nice! |
00:28:29 | arkanoid | demotomohiro, gintro is a lib that not only uses actual GIR files, but creates good nim wrappers. Mine is a raw approch to up a C interop quickly without even using GIR |
00:29:10 | arkanoid | I mean, libgirepository uses them, I'm talking about the wrapping of libgirepository |
00:33:05 | nrds | <Prestige99> thanks @codic, I think I'll need to get that set up so I can test some things.. without having to restart my running wm after every change lol |
00:33:34 | FromDiscord | <codic> what do you need to test with compositor for? curious |
00:33:51 | FromDiscord | <codic> btw you could also run 2 x sessions, I often do that |
00:34:57 | FromDiscord | <codic> oh it seems that the opengl acceleration is in some forks, not in master |
00:35:23 | nrds | <Prestige99> this issue https://github.com/avahe-kellenberger/nimdow/issues/189 |
00:35:46 | nrds | <Prestige99> having windows hide in the bg when there's a fullscreen window, basically |
00:36:24 | * | src quit (Quit: Leaving) |
00:36:30 | FromDiscord | <codic> Oh that is an interesting feature, should implement in Worm |
00:37:02 | FromDiscord | <codic> Yeah can probably iterate over all clients except the fullscreen one and set that |
00:38:30 | nrds | <Prestige99> There are some edge cases that need to be covered - I think I'll just "hide" the windows by moving them offscreen |
00:38:44 | nrds | <Prestige99> but annoying to test, I'll check out xephyr forks |
00:39:05 | FromDiscord | <Elegantbeef> Does unmapping the window not solve that? |
00:39:28 | nrds | <Prestige99> It would, just want to actually test that all edge cases work |
00:39:55 | nrds | <Prestige99> Like if I have a fullscreen window open, and another fullscreen app starts, etc |
00:42:47 | FromDiscord | <codic> Would the past one be hidden or not? |
00:42:55 | FromDiscord | <codic> past = 1st fullscreen one |
00:43:00 | FromDiscord | <codic> In reply to @nrds "<Prestige> There are some": why not unmap? |
00:43:06 | FromDiscord | <codic> isn't unmap how you implement workspaces too? |
00:44:42 | nrds | <Prestige99> I actually just move them offscreen to get around a weird issue I was having, it's the same way dwm handles things |
00:45:11 | nrds | <Prestige99> If I get bored enough one day I'm going to restructure how it all works |
00:45:15 | FromDiscord | <codic> Oh huh |
00:45:17 | FromDiscord | <codic> What was the issue? |
00:45:39 | nrds | <Prestige99> Don't recall exactly |
00:45:49 | FromDiscord | <codic> yeah weird |
00:45:58 | FromDiscord | <codic> have not had any yet |
00:56:13 | * | GreaseMonkey quit (Remote host closed the connection) |
01:08:46 | arkanoid | is cstring a char* or is a char that requires .addr ? |
01:09:51 | FromDiscord | <Elegantbeef> cstring is a ptr char |
01:09:58 | arkanoid | thanks |
01:10:15 | arkanoid | sorry but I'm not a C programmer but I'm using nim to dive into it |
01:11:48 | FromDiscord | <Elegantbeef> Ah i'm very much not a C programmer either so i scream at it until it behaves |
01:13:33 | FromDiscord | <Rika> What do you need to qualify as a c programmer |
01:14:50 | FromDiscord | <Elegantbeef> Someone that likes writing and using C would be up in the qualifications imo |
01:18:24 | FromDiscord | <codic> In reply to @Elegantbeef "Someone that likes writing": You will find a shortage of C programmers |
01:18:34 | FromDiscord | <codic> There are almost no C programmers anymore by that definition lol |
01:20:14 | arkanoid | is there something already included in nim that does int to bool conversion like in C (true if i !=0 else otherwise) or I have to write my own? I know it's trivial |
01:23:04 | FromDiscord | <demotomohiro> !eval var x = 1; echo x!=0 |
01:23:06 | NimBot | true |
01:25:43 | FromDiscord | <demotomohiro> !eval var x = 1; echo bool(x) |
01:25:45 | NimBot | true |
01:27:20 | FromDiscord | <demotomohiro> Anyway, Nim doesn't convert int to bool automatically. |
01:27:39 | FromDiscord | <exelotl> arkanoid: you mean implicitly? You can use converters for that, with bool as the example: https://nim-lang.org/docs/manual.html#converters |
01:28:13 | FromDiscord | <exelotl> It's not recommended to do this though :P |
01:29:04 | FromDiscord | <demotomohiro> Just writing `x != 0` would be fine. |
01:29:23 | FromDiscord | <exelotl> Yep, that's the Nim way |
01:31:53 | FromDiscord | <demotomohiro> When I learned C language long time ago, there was no bool type in C. int was used as bool type. When int value was 0, it is false, otherwise it is true. |
01:32:04 | arkanoid | how curious, using converter in my context doesn't work, but == 0 does |
01:46:02 | * | krux02 quit (Remote host closed the connection) |
01:50:42 | arkanoid | I've successfully wrapped and tested libgirepository via futhark! It's so easy not with futhark that I've opened an issue asking what's the proper way to deliver "raw" C bindings, and if is more convenient to distribute autogenerated .nim files or just bring futhark with the package deps: https://github.com/PMunch/futhark/issues/7 |
02:16:44 | arkanoid | s/not/now |
02:36:49 | * | vicecea quit (Remote host closed the connection) |
02:37:20 | * | vicecea joined #nim |
02:44:45 | FromDiscord | <DaiChimpo> if a string contains an escape character, is there a way to print the literal? so "Hello\n" would print as "Hello\n" instead of "Hello" with a newline? |
02:46:34 | FromDiscord | <DaiChimpo> .strip(chars={'\n','\r'}) is NOT removing newlines and it's frustrating why |
02:59:41 | FromDiscord | <Mocha> If you're trying to print "Hello\n", then you can just escape the backslash: "Hello\\n". Similarly, you can use `strutils`'s `replace` to replace every `'\n'` with a `\\n`. Let me know if that works for you! @DaiChimpo |
02:59:57 | FromDiscord | <Mocha> (edit) ""Hello\\n"." => ""Hello\\\n"." |
03:00:30 | FromDiscord | <Mocha> (edit) "`'\n'`" => "`"\n"`" | "`\\n`." => "`"\\n"`." |
03:01:22 | FromDiscord | <DaiChimpo> well then I can use replace to replace every \ with a \\? |
03:01:30 | FromDiscord | <DaiChimpo> that's... a way |
03:02:15 | FromDiscord | <Mocha> no, you can't use replace to replace every `\` with `\\`; `\` is not a character on its own, `\n` is the full character. |
03:02:43 | FromDiscord | <Mocha> You'd have to replace each escaped character separately, e.g. `\n` -> `\\n` and `\r` -> `\\r` |
03:02:59 | FromDiscord | <DaiChimpo> cringe |
03:03:12 | FromDiscord | <Mocha> ..? |
03:03:43 | FromDiscord | <Mocha> That's how strings work in near every language I know of, the escape character is simply a human-friendly way to represent the newline byte. |
03:04:17 | FromDiscord | <Mocha> `\n` is itself a newline byte, if you want to replace that with a `\\n`, then it makes sense that you'd have to use `replace` |
03:04:51 | FromDiscord | <Mocha> Anyway, if you have something more constructive to say other than "cringe" then feel free |
03:07:37 | FromDiscord | <Mocha> If you are responsible for the string literals themselves, then you can always use raw string literals; however, if you are being passed a string, then `replace` is the only solution afaik. |
03:08:54 | FromDiscord | <DaiChimpo> so no conversion from string to raw string? |
03:10:45 | FromDiscord | <Mocha> No, once the string is in memory, it is simply a list of numerical values, e.g. the newline is represented as the byte `0x0a`, not as the backslash-n. |
03:11:12 | FromDiscord | <Elegantbeef> Dont know what mocha said due to the bridge but you can also do `"""Hello\n"""` |
03:11:36 | FromDiscord | <Mocha> ^ Yes if you are able to create the literals themselves then multiple ways to handle it |
03:11:36 | FromDiscord | <DaiChimpo> it's reading from file/user input, I do not control what goes into values or this is trivial |
03:11:43 | * | [R] quit (Ping timeout: 256 seconds) |
03:11:44 | FromDiscord | <Mocha> yep, then just use replace |
03:12:00 | FromDiscord | <DaiChimpo> for every escape character |
03:12:17 | FromDiscord | <Elegantbeef> User input shouldnt be escaped |
03:13:03 | * | arkurious quit (Quit: Leaving) |
03:13:43 | FromDiscord | <Mocha> They are talking about line feeds/carriage returns/tabs/other characters represented with an escape code |
03:13:54 | FromDiscord | <Mocha> E.g. a file containing newlines |
03:14:07 | FromDiscord | <Elegantbeef> Yea but those arent escape sequences |
03:14:28 | FromDiscord | <DaiChimpo> reading through I can make readfile() pass back a raw string by giving the filename as a raw string |
03:14:32 | FromDiscord | <Elegantbeef> It's just \`replace({'\\0'..'\\032'}\`\` |
03:14:59 | FromDiscord | <Mocha> Actually, there is a function in `strutils` called `escape`, hadn't thought of it yet since I've never had to use it but it should do what you want. |
03:15:16 | FromDiscord | <Mocha> Or you can use the replace with a sequence like elegantbeef suggested. |
03:15:23 | FromDiscord | <Elegantbeef> set |
03:15:26 | FromDiscord | <Mocha> (edit) "sequence like" => "setlike" |
03:15:30 | FromDiscord | <Mocha> (edit) "setlike" => "set like" |
03:15:35 | FromDiscord | <Mocha> :) my brain is totally working |
03:15:55 | FromDiscord | <Elegantbeef> Wait i guess there isnt a replace that takes a set |
03:15:57 | FromDiscord | <Elegantbeef> So i'm a dumb dumb |
03:16:05 | FromDiscord | <DaiChimpo> damn, knew it was too good to be true |
03:16:27 | FromDiscord | <Mocha> https://media.discordapp.net/attachments/371759389889003532/917615510273798194/unknown.png |
03:16:35 | FromDiscord | <Mocha> just check `strutils` |
03:18:13 | FromDiscord | <DaiChimpo> it prints the hex, which is 100% workable. I read through strutils before asking here but must've missed this, thank you |
03:18:53 | FromDiscord | <Mocha> np! Glad there was a less painful solution than the replace. |
03:19:27 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3HeH it's not too hard to impl |
03:21:13 | FromDiscord | <Mocha> oo, Elegantbeef that doesn't quite seem to be a "replace", more like a "remove" o.o |
03:21:47 | FromDiscord | <Elegantbeef> I may or may not have misread what they wanted |
03:21:56 | FromDiscord | <Elegantbeef> Escape is indeed what they want |
03:22:31 | FromDiscord | <Rika> Lol |
03:42:48 | * | rockcavera quit (Remote host closed the connection) |
04:06:01 | * | supakeen quit (Quit: WeeChat 3.3) |
04:06:30 | * | supakeen joined #nim |
04:33:28 | madprops | how do I echo a `ref int` ? |
04:40:18 | FromDiscord | <impbox [ftsf]> dereference it with [] |
04:40:52 | FromDiscord | <retkid> ok so when using --gc:arc |
04:41:02 | FromDiscord | <retkid> is everything just bigger? |
04:41:24 | FromDiscord | <retkid> im manually dealloc every var i can but the ram usage is still insane? |
04:42:37 | FromDiscord | <impbox [ftsf]> Same code but getting higher ram usage? |
04:42:44 | FromDiscord | <retkid> well, yea |
04:42:46 | FromDiscord | <retkid> as close as it can be |
04:42:48 | FromDiscord | <Rika> If the ram usage is still insane then there is something wrong with your algorithm |
04:42:51 | FromDiscord | <retkid> cant really run with the normal gc |
04:43:25 | FromDiscord | <impbox [ftsf]> Tried orc? |
04:43:30 | FromDiscord | <impbox [ftsf]> Do you have cycles? |
04:43:32 | FromDiscord | <retkid> In reply to @Rika "If the ram usage": what are some things i should be looking for specifically |
04:43:37 | FromDiscord | <retkid> In reply to @impbox "Do you have cycles?": no? |
04:43:40 | FromDiscord | <Rika> If you are using async use orc |
04:43:41 | FromDiscord | <retkid> In reply to @impbox "Tried orc?": segfault |
04:43:59 | FromDiscord | <Rika> If you get a segfault then there is something wrong with your algorithm |
04:44:01 | FromDiscord | <impbox [ftsf]> Sounds like problems you should investigate |
04:44:17 | FromDiscord | <retkid> so when it works on arc but not orc, i'm fucking up somewhere |
04:44:20 | FromDiscord | <impbox [ftsf]> Likewise with why it won't run with normal gc |
04:44:40 | FromDiscord | <retkid> remember that lockless thing from earlier |
04:50:34 | FromDiscord | <retkid> sent a long message, see http://ix.io/3Hf0 |
04:50:40 | FromDiscord | <retkid> yea thats not normal |
04:50:41 | FromDiscord | <retkid> (edit) "http://ix.io/3Hf0" => "http://ix.io/3Hf1" |
04:53:56 | FromDiscord | <retkid> alright actually |
04:53:59 | FromDiscord | <retkid> i see tons of places |
04:54:02 | FromDiscord | <retkid> everything should be a ptr\ |
04:54:03 | FromDiscord | <retkid> (edit) "ptr\" => "ptr" |
04:55:35 | FromDiscord | <Rika> Pointers do not get tracked by the GC |
04:56:02 | FromDiscord | <retkid> In reply to @Rika "Pointers do not get": So I can dealloc it manually |
04:58:48 | * | kayabaNerve_ is now known as kayabaNerve |
05:00:44 | FromDiscord | <Rika> Sure |
05:08:02 | * | Lord_Nightmare quit (Read error: Connection reset by peer) |
05:09:58 | * | Lord_Nightmare joined #nim |
05:14:03 | FromDiscord | <retkid> is there anyway i can use code as a paramater for a function? |
05:14:09 | FromDiscord | <retkid> (edit) "paramater" => "parameter" |
05:14:31 | FromDiscord | <Elegantbeef> templates can take code, but functions can only type compilable types |
05:14:39 | FromDiscord | <Elegantbeef> take compilable types\ |
05:14:51 | FromDiscord | <retkid> well i was gonna make a template anyway because i think of it like a function |
05:15:03 | FromDiscord | <Elegantbeef> Well they're not |
05:17:45 | FromDiscord | <Rika> You cannot think of a template as a function that takes in code; that is a macro (and even then you must further specify) |
05:18:39 | FromDiscord | <retkid> In reply to @Rika "You cannot think of": so marcos take code? or can you setup a template to take code? |
05:18:49 | FromDiscord | <Rika> They both take code |
05:19:32 | FromDiscord | <Rika> But a template isnât a function, it has very limited ways to modify the code it takes as a parameter |
05:50:44 | * | greaser|q joined #nim |
05:51:47 | * | greaser|q quit (Changing host) |
05:51:47 | * | greaser|q joined #nim |
05:51:51 | * | greaser|q is now known as GreaseMonkey |
07:01:10 | FromDiscord | <Michal58> Consider this solution to todays aoc https://media.discordapp.net/attachments/371759389889003532/917672064956117002/SPOILER_unknown.png |
07:01:30 | FromDiscord | <Michal58> How hard would it be for the compiler to realise that ||numbers.mean.int|| does not depent on it and calculate it only once? |
07:01:54 | FromDiscord | <Michal58> (edit) "||numbers.mean.int||" => "||`numbers.mean.int`||" | "it" => "`it`" |
07:03:21 | FromDiscord | <Rika> It probably does in the C compiler |
07:05:07 | FromDiscord | <Michal58> no it doesn't |
07:05:24 | NimEventer | New thread by Jorjun_arch: Advent of Code Q7 Pt 2, see https://forum.nim-lang.org/t/8685 |
07:14:14 | FromDiscord | <impbox [ftsf]> In reply to @Michal58 "no it doesn't": You checked the assembly? |
07:14:19 | * | [R] joined #nim |
07:15:12 | FromDiscord | <impbox [ftsf]> And you're compiling with optimisations? |
07:16:15 | FromDiscord | <Rika> You canât force a C compiler to store extra runtime information implicitly |
07:16:25 | FromDiscord | <Rika> So if this is a runtime thing then you must put the extra variable |
07:17:34 | FromDiscord | <Rika> In reply to @Rika "You canât force a": Nim compiler as well |
07:18:01 | FromDiscord | <Rika> Though thatâs not because âitâs against the philosophyâ itâs just it doesnât |
07:18:12 | FromDiscord | <Rika> Most likely most people think itâs not a good idea |
07:20:43 | FromDiscord | <Michal58> In reply to @impbox "You checked the assembly?": I didn't but I did check the times. It is numbers.len times slower than if I put it in a variable. |
07:23:58 | FromDiscord | <Michal58> In reply to @Rika "Though thatâs not because": I see, it might not always be desirable.. if that data would be large... but here it is just 1 int? Seems like a good tradeoff. :D |
07:25:01 | FromDiscord | <Rika> Detection is hard |
07:25:25 | FromDiscord | <Rika> Would need stronger CFA I assume |
07:25:31 | FromDiscord | <Rika> Donât know the status of that |
07:25:31 | FromDiscord | <Michal58> In reply to @Rika "Detection is hard": Yes that's the original question |
07:25:50 | FromDiscord | <Rika> I see |
07:26:15 | FromDiscord | <Rika> I guess itâs not too difficult |
07:26:33 | FromDiscord | <Rika> But the implementation would need to be off by default |
07:27:28 | FromDiscord | <Michal58> In reply to @Rika "But the implementation would": IG some compiler flag would be nice |
07:29:47 | * | [R] quit (Ping timeout: 265 seconds) |
07:29:52 | FromDiscord | <Michal58> In reply to @Rika "Would need stronger CFA": CFA? |
07:35:03 | FromDiscord | <Rika> Control flow analysis |
07:35:51 | FromDiscord | <Rika> I will have to go, someone else most likely knows the compiler better here |
07:36:03 | FromDiscord | <Rika> Iâm tired for no obvious reason |
07:37:17 | FromDiscord | <impbox [ftsf]> Loop invariant hoisting |
07:37:27 | FromDiscord | <impbox [ftsf]> GCC should do it I believe |
07:37:45 | FromDiscord | <impbox [ftsf]> Maybe the int conversion breaks it |
07:38:36 | FromDiscord | <Michal58> In reply to @impbox "Maybe the int conversion": I will try it with numbers.sum div number.len |
07:39:52 | * | jjido joined #nim |
07:41:08 | FromDiscord | <Michal58> In reply to @impbox "GCC should do it": It should? It increases the runtime space implicitly? |
07:41:32 | FromDiscord | <impbox [ftsf]> If you have speed optimisations on |
07:42:05 | FromDiscord | <impbox [ftsf]> -floop-invariant-motion |
07:42:34 | FromDiscord | <impbox [ftsf]> -fmove-loop-invariants i mean |
07:42:47 | FromDiscord | <impbox [ftsf]> Which is enable in O1 and higher |
07:43:27 | FromDiscord | <impbox [ftsf]> But maybe there's something which is causing it to not occur |
07:44:47 | * | neurocyte0132889 joined #nim |
07:44:47 | * | neurocyte0132889 quit (Changing host) |
07:44:47 | * | neurocyte0132889 joined #nim |
07:46:28 | FromDiscord | <Rika> I didnât think it did on O1 |
07:53:40 | FromDiscord | <Rika> Iâm a bit more awake now, I guess a few minutes ago I forgot that optimise flags existed |
08:01:31 | FromDiscord | <Michal58> Surely danger implies O1? |
08:01:51 | FromDiscord | <Rika> o2 |
08:01:56 | FromDiscord | <Rika> It implies O2 |
08:02:01 | FromDiscord | <Rika> So yes |
08:02:07 | FromDiscord | <Michal58> In reply to @Michal58 "I will try it": Doesn't work either |
08:02:23 | FromDiscord | <Michal58> In reply to @Rika "It implies O2": Yeah I meant at least o1 |
08:03:06 | FromDiscord | <Rika> Bad wording on my part |
08:03:34 | FromDiscord | <Rika> Maybe it needs explicit switch |
08:10:49 | FromDiscord | <Hamid Bluri> sent a code paste, see https://paste.rs/cYv |
08:11:13 | FromDiscord | <Hamid Bluri> (edit) "https://play.nim-lang.org/#ix=3HfB" => "https://play.nim-lang.org/#ix=3HfC" |
08:14:08 | FromDiscord | <Yardanico> iterable is weird, yes |
08:14:12 | FromDiscord | <Yardanico> it only works for templates now |
08:14:52 | FromDiscord | <Elegantbeef> It has very annoying semantics but is somewhat nice |
08:15:17 | FromDiscord | <Hamid Bluri> i wanted to implement something like https://github.com/zero-functional/zero-functional without macros |
08:15:29 | FromDiscord | <Elegantbeef> No can do |
08:15:41 | FromDiscord | <Elegantbeef> Unless you use closures |
08:15:53 | FromDiscord | <Hamid Bluri> closure iterators? |
08:16:00 | FromDiscord | <Elegantbeef> Yea |
08:16:19 | FromDiscord | <Hamid Bluri> ok, i try :- \ |
08:16:29 | FromDiscord | <Hamid Bluri> i'll try |
08:18:12 | FromDiscord | <Elegantbeef> Really`iterable[T]` should probably be a static generic which would allow for taking in iterators/using values |
08:47:00 | * | PMunch joined #nim |
09:14:53 | PMunch | arkanoid, you around? |
09:39:49 | * | [R] joined #nim |
09:53:05 | FromDiscord | <frankzig> can a function work on both openArrays and HSlices? |
09:53:25 | FromDiscord | <frankzig> (trying to write generic code on iterable stuff) |
09:55:38 | FromDiscord | <Elegantbeef> What do you mean? |
10:10:52 | FromDiscord | <frankzig> sent a code paste, see https://play.nim-lang.org/#ix=3HfV |
10:11:06 | FromDiscord | <frankzig> is the a way to generalize it? |
10:11:14 | FromDiscord | <frankzig> (edit) "the" => "there" |
10:12:04 | FromDiscord | <Elegantbeef> use iterable + `items` on `openArray` |
10:12:23 | FromDiscord | <frankzig> sorry, i do not understand how... |
10:12:25 | FromDiscord | <Elegantbeef> though i guess `s[i]` isnt possible with an iterator |
10:13:53 | * | lumo_e joined #nim |
10:14:23 | FromDiscord | <Elegantbeef> It's probably just best to make two procs since there will be a lot of `when` statements |
10:14:42 | FromDiscord | <Elegantbeef> Plus it'll break the implicit openarray conversion |
10:15:27 | FromDiscord | <frankzig> this is a little sad, julia handles this much more nicely, anyway thanks! đ |
10:20:40 | FromDiscord | <Hamid Bluri> you can do it with templates btw |
10:23:21 | FromDiscord | <Hamid Bluri> @frankzig |
10:23:22 | FromDiscord | <Hamid Bluri> sent a code paste, see https://play.nim-lang.org/#ix=3Hg1 |
10:23:55 | FromDiscord | <Hamid Bluri> it's a little dirty, i wanted to do it as fast as possible đ |
10:30:06 | NimEventer | New thread by Geohuz: Need explanation of static compiling warning message, see https://forum.nim-lang.org/t/8687 |
10:36:54 | FromDiscord | <Cypheriel> What's the Nim alternative to Python's `sum()`? I'm trying to do something like `sum(@[1, 2, 3])` but that doesn't seems to be working well |
10:38:33 | FromDiscord | <Elegantbeef> !eval import std/math; echo sum @[1, 2, 3] |
10:38:35 | NimBot | 6 |
10:39:16 | FromDiscord | <Cypheriel> ugh... I think there are other modules fighting over `sum` |
10:40:02 | FromDiscord | <Elegantbeef> !eval import std/math echo math.sum(@[1, 2, 3]) |
10:40:04 | NimBot | Compile failed: /usercode/in.nim(1, 17) Error: invalid module name: 'math echo math.sum(@[1, 2, 3])' |
10:40:07 | FromDiscord | <Cypheriel> oh. who knew one could just- yeah... |
10:40:13 | FromDiscord | <Cypheriel> oh or not \đ© |
10:40:22 | FromDiscord | <Elegantbeef> More an issue wit hthe bridge i think |
10:40:28 | FromDiscord | <Elegantbeef> Nah i left out a semi colon |
10:40:30 | FromDiscord | <Cypheriel> yeah |
10:41:01 | FromDiscord | <Solitude> In reply to @NimBot "Compile failed: /usercode/in.nim(1, 17)": wtf, you can have spaces in module names? |
10:41:06 | FromDiscord | <Solitude> or cant |
10:41:16 | FromDiscord | <Solitude> forget about it |
10:41:22 | FromDiscord | <Elegantbeef> Lol |
10:41:40 | FromDiscord | <Elegantbeef> I'm just an idiot that forgot a semicolon |
10:45:01 | FromDiscord | <Solitude> le unicode space has arrived https://media.discordapp.net/attachments/371759389889003532/917728397357096960/unknown.png |
10:46:05 | FromDiscord | <tandy> exciting \:) |
11:20:03 | arkanoid | PMunch: yeah |
11:41:52 | arkanoid | Solitude: are those ascii spaces or weird unicode space characters |
11:48:23 | PMunch | arkanoid, I saw you had some questions about Futhark :) |
11:48:53 | arkanoid | Yes, unsure about what's best for nim ecosystem |
11:49:58 | arkanoid | Is c-like bindings a viable package on its own? |
11:52:45 | arkanoid | Futhark depends on clang, that's a quite important dependency, on the other hand it is not required once furthark has build its cache. Not sure if I delivered the question clearly enough |
11:53:44 | PMunch | I'm typing up a reply in the repo now :) |
11:57:39 | arkanoid | Thanks! |
11:59:52 | arkanoid | Btw how it works now made me peep into the json and clear the cache manually (to re-symlink the last .nim) frequently. Not really sure if opir should stay transparent to the user |
12:01:22 | arkanoid | Actually the symlink was due to vscode not reading cache folder, so it's not really a general problem, but this also links to the delivery question |
12:03:14 | PMunch | Not sure what you mean if Opir should stay transparent to the user |
12:04:02 | PMunch | And you're not really supposed to have to go digging in the json file and the cache. The idea is that you would use the original C documentation for writing your application, and Futhark just makes it transparently work in Nim. |
12:06:02 | * | supakeen quit (Quit: WeeChat 3.3) |
12:06:32 | * | supakeen joined #nim |
12:09:12 | arkanoid | PMunch: I dig into the json to find out which .h I have to add into importc section after the first one. |
12:09:25 | PMunch | Ah right |
12:09:39 | PMunch | Yes this is something that needs to be addressed |
12:10:16 | PMunch | But it shouldn't be needed after I implement either the folder-based approach or something similar |
12:11:09 | arkanoid | It is also to be considered that the smaller the nim file, the faster it is to work with |
12:11:28 | arkanoid | This is why I prefer to include only the required .h |
12:13:56 | arkanoid | Also prettifying opir output json would save some typing :) |
12:15:31 | PMunch | The Opir output isn't really intended to be read though.. However I have piped it through `jq` whenever I wanted to read it |
12:15:52 | PMunch | `cat opir.json | jq | grep "someproc"` |
12:16:16 | PMunch | Maybe `grep -C` to get some lines around it so I can see where in the object it comes from |
12:16:29 | PMunch | I guess I could also use jq to search |
12:21:57 | arkanoid | Sure, I do python3 -m json.tool, it was just to avoid some typing, pretty json is not slower than minefield one afaik |
12:23:36 | FromDiscord | <haxscramper> I want to split my projects into couple of DLLs because it takes a billion years to compile otherwise, and the worst offender is a autogenerated 16k-sloc code that barely ever changes |
12:24:24 | FromDiscord | <haxscramper> I just need to do an --app\:lib and somehow important things back? Or this is not possible, since nim can't do header declarations for procs |
12:24:44 | FromDiscord | <haxscramper> So everything would have to go through the nim-c-nim layer? |
12:25:20 | PMunch | arkanoid, it does take some work for Opir to format it, but only sligthly more work to parse, but it also takes way more space |
12:25:29 | FromDiscord | <enthus1ast> this is what i have also though about, would be super cool if there would be a fully automatic way [haxscramper](https://matrix.to/#/@haxscramper:matrix.org) |
12:25:30 | PMunch | Not that it matters terribly much these days |
12:26:32 | PMunch | @enthus1ast, it would be cool. But you would quickly run into issues with Nim features that don't exist in C |
12:26:38 | FromDiscord | <haxscramper> I wonder what would happen if I importc proc that uses nim gc types and so on |
12:26:52 | FromDiscord | <enthus1ast> but afaik there is'nt so load library, getSymAddr is the way to go |
12:27:17 | FromDiscord | <haxscramper> getSymAddr? |
12:27:21 | PMunch | `proc x(a: int or string): string = when a is string: a else: $a` for example would be tough to do over a DLL |
12:27:46 | FromDiscord | <haxscramper> Assume no generics then |
12:27:54 | FromDiscord | <enthus1ast> or define them in the forward declaration |
12:27:56 | PMunch | @haxscramper, if you use ARC it would probably work fine |
12:27:59 | FromDiscord | <haxscramper> I codegen this 16k abomination, so I can remove these things |
12:28:01 | FromDiscord | <enthus1ast> define/load |
12:28:03 | PMunch | Otherwise you need to use nimrtl I believe |
12:28:44 | FromDiscord | <haxscramper> Alright, looks like in total I would spend just as much time optimizing compilation as compiling |
12:31:47 | FromDiscord | <haxscramper> Hmmm https://github.com/genotrance/plugins that one does also look promising |
12:32:20 | FromDiscord | <haxscramper> What is a nimrtlâ”(<@709044657232936960_=50=4dunch=5b=49=52=43=5d>) |
12:32:46 | PMunch | arkanoid, something like this can be used to list out all names and the files they come from: cat ~/.cache/nim/epaper_d/opir_134442D73E800BC4.json | jq '.[] | .name, .file' |
12:33:14 | PMunch | @haxscramper, a dynamic library containing the garbage collector that has to be used if you want to load a Nim dynamic library in a Nim project |
12:33:29 | PMunch | https://nim-lang.org/docs/nimc.html#dll-generation |
12:34:21 | PMunch | But again, if you use ARC I don't think you need that |
12:34:58 | PMunch | But who knows, ARC documentation is unfortunately quite lacking.. |
12:37:37 | arkanoid | If arc adds memory cleanup at compile time asap, how can it help dealing with the code inside a dll loaded at runtime? |
12:38:17 | FromDiscord | <enthus1ast> the dll also contains cleanup code |
12:39:40 | arkanoid | Well yes, if it is an arc compiled dll |
12:41:37 | * | src joined #nim |
12:41:54 | arkanoid | Can nimsuggest give hints to ide from a nim .so/.dll? |
12:42:49 | NimEventer | New thread by Loczaj: For loop using iterator `..`, see https://forum.nim-lang.org/t/8689 |
12:42:52 | PMunch | Nope, it needs sources |
12:47:05 | * | rockcavera joined #nim |
12:47:05 | * | rockcavera quit (Changing host) |
12:47:05 | * | rockcavera joined #nim |
12:59:43 | arkanoid | So it's up to generate the smallest possible .nim file from headers |
13:00:44 | arkanoid | The current approach where you have to explicitly write the headers that you are interested in is not wrong in this context |
13:09:08 | PMunch | Ah you're back to Futhark :P |
13:09:27 | PMunch | It's not wrong if you want the smallest possible Nim file |
13:09:34 | PMunch | But I'm not sure that is actually a goal.. |
13:15:56 | * | PMunch quit (Quit: Leaving) |
13:28:06 | arkanoid | Never changed topic |
13:51:43 | * | rockcavera quit (Remote host closed the connection) |
13:53:39 | * | arkurious joined #nim |
13:55:13 | * | PMunch joined #nim |
13:58:59 | * | lumo_e quit (Quit: Quit) |
14:05:07 | * | xet7 joined #nim |
14:05:10 | FromDiscord | <haxscramper> Can you upload an example of a `.h`, `.json` and `.nim` file, I want to take a look how they are handled for a moderately complex C libraries |
14:07:59 | arkanoid | Haxscramper, I'd be glad to send you the files, but it's better to first address what is a moderately complex c library for you. |
14:08:35 | FromDiscord | <haxscramper> just what you are working right now |
14:08:35 | arkanoid | Also, futhark imports only the symbols from an explicit list of .h, that are not handled recursively |
14:09:35 | arkanoid | Haxscramper, ok, I have apache libarrow-glib and libgirepository already rolling |
14:10:22 | arkanoid | But the imported .h (and so the size of the generated .nim) depends on the code I'm actually trying to compile |
14:11:00 | FromDiscord | <haxscramper> I just want to take a quick look, so no need to try to make it work or anything |
14:13:25 | arkanoid | Let me explain. It's quite simple really (and it might change in the future). Now thers opir that given one or multiple .h traverses them like clang would do and generate a big json (and this includes all symbols it encounters recusrively), then futhark reads this json and generates nim code only for the symbols contained in the explicitly listed .h so it won't clutter the .nim. |
14:13:38 | arkanoid | Let me pick your poison then |
14:16:24 | arkanoid | this is just a strategy PMunch picked, and it is not wrong in my opinion, but it depends (and we're talking about it) on how it's intended to deliver futhark libs. You can join the discussion here https://github.com/PMunch/futhark/issues/7#issuecomment-987861978 |
14:17:10 | PMunch | Well that's not really why it's built this way |
14:18:08 | PMunch | The reason is because Futhark would otherwise pull in everything that your library requires. Including stuff that is already defined it Nim, or stuff which might be supplied by other Nim C wrapper libraries (like e.g. posix) |
14:18:53 | FromDiscord | <haxscramper> Let me remind you ofâ”> Sorry, but I really fear the wrappers that come out of it, it doesn't feel like a step in the right direction. |
14:19:12 | FromDiscord | <haxscramper> I think I need to wrap something myself them |
14:19:14 | FromDiscord | <haxscramper> (edit) "them" => "then" |
14:19:23 | FromDiscord | <haxscramper> probably libgit |
14:19:49 | arkanoid | where do you preder me to send test .json and .nim? |
14:19:55 | arkanoid | s/predef/prefer |
14:20:11 | PMunch | @haxscramper, who's comment was that? |
14:20:14 | FromDiscord | <haxscramper> github gist |
14:20:19 | FromDiscord | <haxscramper> In reply to @PMunch "<@608382355454951435>, who's comment was": araq |
14:20:40 | FromDiscord | <haxscramper> about pulling the world into a wrapper - I think I have a solution to that, but it implies certain model of processing |
14:20:51 | FromDiscord | <haxscramper> Let me organize my thoughts, |
14:20:53 | PMunch | Ah.. Well he doesn't seem to like the concept of automating it to this point it seems |
14:21:11 | arkanoid | sure it's c-like interface, not nim-like, but it's something that could be used to generate nim-like wrappers |
14:21:49 | FromDiscord | <haxscramper> there are clear benefits to providing a `.nim` wrapper that is commited to the VCS, without any extra build dependencies, but it makes stuff so much more complex on the processing side |
14:21:50 | PMunch | I agree that pulling everything into a single wrapper would be a bad idea. I want to add a system in Futhark that only pulls in things defined in a certain folder, that way you can give it a specific folder to include stuff from, and a start .h file and it will wrap an entire library. |
14:22:31 | PMunch | That definitely makes it harder on the processing side, because at that point you have to convert IFDEF logic to Nim logic |
14:23:35 | PMunch | Depends of course what you're wrapping, but this can be a major source of problems with a pre-built wrapper |
14:25:29 | NimEventer | New post on r/nim by stefantalpalaru: Windows stack corruption - a journey into the bowels of the beast, see https://reddit.com/r/nim/comments/rb0ab4/windows_stack_corruption_a_journey_into_the/ |
14:27:06 | NimEventer | New thread by Stefantalpalaru: Windows stack corruption - a journey into the bowels of the beast, see https://forum.nim-lang.org/t/8690 |
14:28:56 | FromDiscord | <haxscramper> So, if I take the `iterator.h`, `string.h` and `vector.h`, each one of them defined in a separate header file, but string and vector import iterators, and then subsequently wrap each file, I get three different translation units, where iterator.h was visited three times. I convert all of them and then merge together in the same order as defined. |
14:29:37 | FromDiscord | <haxscramper> If I see a type/proc definition that I have already seen earlier, I only compare it structurally, to ensure there are no differences via various translation unit wrappings |
14:30:31 | FromDiscord | <haxscramper> If I introduce concept of a "library" in wrapper generator, I can also handle interproject dependencies |
14:31:09 | FromDiscord | <haxscramper> For example, imagine iterator.h was defined in the different wrappers. In that case you would probably better doing `import` for it rather than generating it from scratch |
14:31:37 | FromDiscord | <haxscramper> So I think the right approach is to try and "cut out" unnecessary parts from the translation units generated by libclang |
14:32:08 | FromDiscord | <haxscramper> there is a `isFromMainModule` or something similar check, it would allow to wrap only entries from the main file of the translation file |
14:32:11 | FromDiscord | <haxscramper> (edit) "file" => "unit" |
14:33:10 | FromDiscord | <haxscramper> This is not realiable nough, because some headers provide a toplevel dispatch into multiple smaller headers, for example `<string>` dispatches into 10+ different files, some of which are also used in the vector |
14:33:14 | PMunch | I tried that, but the problem I had with isFromMainModule is that I generate a dummy .h file which includes any defines that are used |
14:33:15 | FromDiscord | <haxscramper> and some in the iterator |
14:34:04 | PMunch | I have this in one of my projects: http://ix.io/3Hh7/ |
14:34:08 | FromDiscord | <haxscramper> If I sequentially process the headers I need to either order them manually, or maybe write down dependencies manually and then do topological sorting |
14:34:35 | PMunch | That XUTIL_DEFINE_FUNCTIONS is entered into the .h dummy file and then I run Opir on the dummy file |
14:34:47 | PMunch | So isFromMainModule would give me false for all symbols |
14:35:18 | FromDiscord | <haxscramper> yes, that's why I said it is not reliable enough |
14:35:55 | PMunch | I guess in Futhark you could create individual x.nim, xutil.nim, xlib.nim, xos.nim, xcomposite.nim, xdamage.nim, damagewire.nim etc. that each just imported one .h file |
14:38:13 | FromDiscord | <haxscramper> I want to do this, instead of just one huge file |
14:38:51 | PMunch | That should be possible with Futhark right now |
14:39:01 | PMunch | Haven't tried it though |
14:39:43 | NimEventer | New Nimble package! gigi - GitIgnore Generation Interface, see https://github.com/attakei/gigi |
14:40:06 | arkanoid | haxscramper: please find here a quick example https://github.com/arkanoid87/nimarrowglib/ |
14:42:20 | FromDiscord | <haxscramper> the `_452985878` parts are not from futhark, right? |
14:42:34 | PMunch | Yes they are |
14:43:36 | FromDiscord | <haxscramper> I don't quite understand the `when not declared(Garrowchunkedarrayclassproc):` sections - they exist to handle multiply type declarations in the C code? |
14:43:37 | arkanoid | in this example I've imported all the .h referenced in original "arrow-glib.h", so the generated .nim is way larger than required, as the nim code really requires just a dozen of symbols |
14:43:40 | FromDiscord | <haxscramper> forward declarations |
14:43:56 | PMunch | Basically all types have three identifiers, one which is used for arguments and fields, one which is used for the actual type definition, and one without the numbers which is tied to the definition through a `when not defined(identifier)` check |
14:45:35 | PMunch | They handle a couple things, first off if I have a procedure or type defined in Nim it won't override it (e.g. if I have posix imported and try to import a C file that includes some of the same symbols), they also allow you to manually override types by simply hand-writing their definition before the imports. |
14:45:38 | FromDiscord | <tbrekalo> how do I avoid making extra copies of the sequence with the .map procedure? or does the compiler avoid copies? https://media.discordapp.net/attachments/371759389889003532/917788949399863296/unknown.png |
14:46:25 | PMunch | So you would only use the identifier without the numbers in your actual code |
14:46:26 | FromDiscord | <haxscramper> ah, so the `.nim` is included, not imported |
14:47:02 | arkanoid | tbrekalo try zero-functional https://github.com/zero-functional/zero-functional |
14:47:09 | PMunch | Yes, the futhark `importc` either returns all that code as a NimNode, or it returns a NimNode which is an include statement for a cached file |
14:47:12 | FromDiscord | <haxscramper> Well, I do understand the reasoning, but damn the codegen looks strange |
14:47:41 | PMunch | Yeah, the codegen is a bit of a mess. But it's similar to Nims C output, it's not really meant to be human-consumable |
14:49:11 | arkanoid | and it works out of the box. PMunch so far every time I ended up with some running toy using futhark, I had never to use/cast to *_<hash> types |
14:50:00 | PMunch | Of course not :) They aren't meant to ever be used |
14:50:15 | PMunch | It's just a little trick for the compiler to be happy |
14:53:45 | arkanoid | PMunch: how different/difficult would be to generate multiple .nim files according to original .h file source of the symbol (name field in json iirc) and rebuild the import hierarchy in the header of each of them? (would this actually work?) |
14:54:41 | PMunch | Hmm, I guess that could work |
14:54:44 | arkanoid | it's actually quite similar to the lantern fish problem. Instead of counting all the fishes, you put them in buckets according to the timer/name in this context |
14:55:20 | PMunch | The only thing is that you might run into issues like circular imports (which are fine in C, but not in Nim) |
14:55:41 | FromDiscord | <haxscramper> this won't work |
14:55:51 | FromDiscord | <haxscramper> you need to build a whole graph of which fields uses what type |
14:56:00 | FromDiscord | <haxscramper> and then clusterize it into nim modules |
14:56:19 | FromDiscord | <haxscramper> the `#include` tracing is meaningless, because you can forward-declare a type in C |
14:56:19 | PMunch | Nah he just means base it off-of which .h file it originally came from |
14:56:31 | FromDiscord | <haxscramper> and use pointer to that type, while in nim you can't |
14:56:40 | PMunch | Well I only include the actual definitions in the Opir output |
14:56:51 | PMunch | So Futhark doesn't see forward decls |
14:59:34 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzzâŠ) |
15:00:28 | arkanoid | PMunch: I think it's worth leveraging on how clang handles this problem and represent it's structure fragmented in something nim likes |
15:04:14 | FromDiscord | <haxscramper> welcome to bullshit |
15:04:14 | FromDiscord | <haxscramper> sent a code paste, see https://paste.rs/hWy |
15:04:53 | FromDiscord | <haxscramper> `nim c '--hint[Path]:on' --hints:on file` |
15:04:58 | FromDiscord | <haxscramper> how does this even work |
15:06:29 | PMunch | Hmm, that's odd indeed @haxscramper |
15:07:02 | PMunch | I assume you're using Nim and not Nimskull there |
15:07:16 | FromDiscord | <haxscramper> Yes, I'm using nim |
15:07:19 | FromDiscord | <haxscramper> I do have an additional `nim.cfg` file, but it explicitly says it added the a path there |
15:07:45 | PMunch | Yeah that looks weird |
15:08:03 | PMunch | Anyways, I'm off |
15:08:12 | * | PMunch quit (Quit: Leaving) |
15:10:23 | FromDiscord | <haxscramper> `nimble install --nimbleDir:(pwd)/deps/pkgs futhark` |
15:10:29 | FromDiscord | <haxscramper> `/mnt/workspace/clean-clone/hack/nim.cfg(2, 3) Error: invalid package name: /mnt/workspace/clean-clone/hack/deps/pkgs/pkgs` |
15:12:31 | FromDiscord | <tbrekalo> sent a long message, see http://ix.io/3Hhv |
15:13:06 | FromDiscord | <haxscramper> `for name, field in fieldPairs()` allows to assign to a `field` is object that you iterate on is mutable |
15:13:23 | FromDiscord | <haxscramper> so assuming fields are written in the same order you just need to loop through CSV |
15:13:35 | FromDiscord | <tbrekalo> ye |
15:13:48 | FromDiscord | <tbrekalo> I am gonna try that now then; â”Thanks @haxscramper |
15:15:49 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3Hhz |
15:16:00 | FromDiscord | <haxscramper> how do I create a `generaed` file from futhark? |
15:17:07 | FromDiscord | <haxscramper> also, how do I import relative file, simple `"file.h"` does not work |
15:18:21 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3HhA |
15:23:39 | FromDiscord | <haxscramper> If I copy-paste the absolute file path it does not provide A wrapped structs anyway |
15:23:52 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3HhD |
15:24:01 | FromDiscord | <haxscramper> cache file is empty |
15:43:18 | arkanoid | haxscramper, I'm back |
15:43:40 | arkanoid | let me read your context, I might help. Not helping on internals, but I've done something |
15:44:45 | FromDiscord | <haxscramper> First I want to know how to wrap a relative file |
15:45:43 | arkanoid | can you share the .h? |
15:48:42 | FromDiscord | <haxscramper> `struct A; struct B; struct A { struct B b; }; struct B { struct A a; };` |
15:49:14 | arkanoid | K. One minute |
15:52:07 | FromDiscord | <haxscramper> PMunch I think you can also look into interfacing with a conan PM. It can generate `.json` with all the include paths, or create a file with gcc linkage/includepath information |
15:52:38 | arkanoid | done, it works to me |
15:53:03 | FromDiscord | <haxscramper> `conan install . --build=missing` generates file that you can then pass as `--passL:"@$(pwd)/conanbuildinfo.gcc"` |
15:53:33 | FromDiscord | <haxscramper> and I think clang can also read everything using just `@$(pwd)/conanbuildinfo.gcc` passed to command-line flags |
15:53:47 | FromDiscord | <haxscramper> `@/absolute/path/to/the.gcc` |
15:53:59 | FromDiscord | <haxscramper> In reply to @arkanoid "done, it works to": can you declare `var a: A` and `var b: B` |
15:54:16 | FromDiscord | <haxscramper> relative paths also works? |
15:56:26 | arkanoid | haxscramper: this compiles on my machine https://play.nim-lang.org/#ix=t%20wr |
15:56:55 | arkanoid | where a_and_b.h is is <nimble_proj_root>/include/a_and_b.h |
15:57:04 | FromDiscord | <haxscramper> > `#!/usr/bin/env python` ? |
15:57:09 | arkanoid | ? |
15:57:37 | arkanoid | whoa! what happened? it must be a play.nim-lang.org app issue |
15:57:40 | FromDiscord | <haxscramper> your paste is a python code with some http request |
15:58:10 | arkanoid | nope, it doesn't come from my pc, it's a backend thing |
15:58:49 | arkanoid | http://sprunge.us/ it's a pastebin service |
15:59:01 | arkanoid | possibly a component of play.nim-lang.org |
15:59:22 | arkanoid | does this work? https://play.nim-lang.org/#ix=3HhL |
16:02:06 | arkanoid | I'm also trying to do A.b = objB.addr and B.a = objA.addr, but I'm getting "Error: 'A.b' cannot be assigned to" |
16:07:48 | FromDiscord | <Pralkarz> sent a code paste, see https://play.nim-lang.org/#ix=3HhO |
16:08:42 | FromDiscord | <Yardanico> yes, you can, but there's "truthy" or "falsey" value for strings by default in nim |
16:08:52 | FromDiscord | <Yardanico> if you want to check the length, just do `if str.len > 0` |
16:09:55 | FromDiscord | <Pralkarz> In reply to @Yardanico "yes, you can, but": I actually want the truthy/falsey behavior, but `if not "":` doesn't compile. |
16:10:07 | FromDiscord | <Yardanico> because "" is not a bool |
16:10:23 | arkanoid | if you want to use a specific constant rule to transform a string into a bool, you can write your own converter, but this would apply automatically to the whole scope so use it with grain of salt |
16:10:34 | FromDiscord | <Yardanico> yes |
16:10:48 | FromDiscord | <Pralkarz> Yup, therefore my question on how I can evaluate empty string to be falsey. |
16:10:59 | FromDiscord | <Yardanico> you can write a converter |
16:11:04 | FromDiscord | <Pralkarz> In reply to @arkanoid "if you want to": Aw, I'll just stick to `if str.len > 0 `in that case. |
16:11:09 | FromDiscord | <Yardanico> but as arkanoid said, it'll apply to the whole scope implicitly |
16:11:10 | FromDiscord | <Pralkarz> (edit) "0 `in" => "0` in" |
16:11:22 | FromDiscord | <Pralkarz> All right, thanks! |
16:11:35 | arkanoid | converter toBool(s: string): bool = s.len > 0 |
16:11:38 | arkanoid | for example |
16:16:57 | FromDiscord | <tbrekalo> can I generate an iterator from the seq[T]? |
16:18:52 | FromDiscord | <tbrekalo> without having to write my own closure; something like `.items` ? |
16:19:42 | FromDiscord | <haxscramper> In reply to @arkanoid "does this work? https://play.nim-lang.org/#ix=3HhL": no, it doesn't work |
16:20:03 | arkanoid | haxscramper, what error do you get? |
16:20:11 | FromDiscord | <haxscramper> same error, file not found |
16:20:42 | FromDiscord | <haxscramper> anyway, I don't care that much to spend more time on this one, so no big deal |
16:21:40 | arkanoid | tbreakalo: maybe this? https://nim-lang.org/docs/iterators.html#items.i%2Carray%5BIX%2CT%5D |
16:22:00 | arkanoid | which file? |
16:22:29 | arkanoid | ok, np. If you intend to continue, just give me a ping. Maybe I can help |
16:25:38 | FromDiscord | <tbrekalo> In reply to @arkanoid "tbreakalo: maybe this? https://nim-lang.org/docs/it": doesn't seems to work |
16:30:38 | arkanoid | tbreakalo, trivial example, but what do you mean? https://play.nim-lang.org/#ix=3HhX |
16:31:08 | FromDiscord | <spotlessapple> Is there a recommended way to add rows to a data frame in datamancer? Saw documention for columns, but having a difficult time finding info for rows |
16:33:15 | * | xet7 quit (Quit: Leaving) |
16:37:41 | arkanoid | spotlessapple, have a look at these templates https://scinim.github.io/Datamancer/dataframe.html#18 |
16:38:11 | FromDiscord | <tbrekalo> In reply to @arkanoid "tbreakalo, trivial example, but": need it as the closure iterator and want to zip it with another iterator |
16:38:30 | FromDiscord | <tbrekalo> can send you the example later today; g2g now :/ |
16:39:12 | arkanoid | tbreakalo, consider this also https://github.com/zero-functional/zero-functional#zip |
16:39:17 | FromDiscord | <tbrekalo> I want to zip values from fieldPairs with seq items iterator; that's the functionality I am looking for |
16:39:50 | FromDiscord | <tbrekalo> In reply to @arkanoid "tbreakalo, consider this also": Ye; have it bookmarked; â”Will check it out |
16:40:21 | * | PMunch joined #nim |
16:44:23 | FromDiscord | <tandy> is anyone here familiar with coro? |
16:44:27 | FromDiscord | <tandy> (coroutines) |
16:44:35 | FromDiscord | <tandy> sent a code paste, see https://play.nim-lang.org/#ix=3Hi0 |
16:44:39 | FromDiscord | <tandy> i dont understand what this proc does |
16:45:50 | FromDiscord | <tandy> "how often" what? |
16:52:35 | PMunch | How often to check whether the coroutine is checked for completion I guess |
16:53:58 | PMunch | So who's ready for some AoC streaming? |
17:01:15 | * | xet7 joined #nim |
17:09:37 | PMunch | Stream is live: https://www.twitch.tv/pmunche |
17:13:23 | * | rockcavera joined #nim |
17:13:23 | * | rockcavera quit (Changing host) |
17:13:23 | * | rockcavera joined #nim |
17:21:06 | arkanoid | here we go again, vscode nim extension is not working for unknown reason |
17:21:16 | PMunch | Take a break and watch a stream :) |
17:24:33 | FromDiscord | <haxscramper> What extension do you most people use? |
17:24:35 | FromDiscord | <haxscramper> saem's? |
17:25:21 | FromDiscord | <dom96> whatever's the oldest |
17:25:28 | FromDiscord | <dom96> haven't tried others though, maybe they are better |
17:27:03 | Amun-Ra | haxscramper: Zaitsev's one |
17:27:40 | Amun-Ra | it's outline pretty suck tho |
17:27:46 | Amun-Ra | s* |
17:29:38 | arkanoid | I use seam, but the real issue is that it doesn't work without any log info |
17:29:59 | arkanoid | what I use to track down if it's working or not is "ps -ae | grep nimsuggest" |
17:31:07 | FromDiscord | <dom96> I don't use nimsuggest at all, only VS Code's dumb auto complete |
17:31:39 | arkanoid | what I've tracked down so far is that changing config.nims sometimes makes the extension unresponsive no matter if you revert it to previous state |
17:31:58 | Amun-Ra | I mostly use (n)vim with nim.vim plugin |
17:32:00 | arkanoid | so you have to restart, and guess |
17:32:46 | arkanoid | vim is a text editor that can be upgraded to ide, vscode is an ide that can also be an advanced text editor |
17:33:41 | arkanoid | I bet nim community will always focus in vscode or next available ide (I'm talking as neovim user too, but I'm focusing on what the community uses) |
17:40:07 | FromDiscord | <Smarc> Hm, how do you guys treat `case` statements syntactically? Do you indent the `of`'s? Do you place a colon after the `case` line? |
17:40:28 | FromDiscord | <dom96> no and no |
17:41:27 | FromDiscord | <Smarc> I also think the colon is unneccessary, but why not indenting the of's? |
17:41:43 | FromDiscord | <dom96> Because that is not how the BDFL intended it |
17:42:18 | FromDiscord | <Smarc> But if the allmighty did not intended it, why is it possible? :x |
17:42:37 | FromDiscord | <Solitude> to let you learn on your own mistakes |
17:43:07 | FromDiscord | <Smarc> I'm not worthy. |
17:43:17 | FromDiscord | <dom96> good question đ |
17:52:53 | arkanoid | I'm parsing a file of X lines one by one, but I have to skip some during the task. To optimize the proc, I'm using newSeqOfCap(totalLines) to avoid reallocations, but at the end of the proc I might also end up with an empty seq in worst case. Is it better to shrink (by copy?) the seq afterwards, or let seq grow on it's own? |
18:00:46 | FromDiscord | <konsumlamm> In reply to @haxscramper "What extension do you": these days everyone recommends saem's (and it also works better ime) |
18:00:49 | * | krux02 joined #nim |
18:03:11 | PMunch | I'm still thrown by the fact that the case line doesn't need a colon... |
18:03:14 | PMunch | I always add one |
18:03:40 | PMunch | arkanoid, probably shrink at the end |
18:04:46 | arkanoid | PMunch: schrink by copy, or there's some black magic to reshape the malloc to correct size? |
18:04:53 | PMunch | Adding as you go will create progressively larger arrays to fit the memory into, and possibly trigger a lot of copies. |
18:05:12 | PMunch | No way to reshape an alloc, but do you actually need to reclaim that space right away? |
18:05:38 | PMunch | The Nim allocator might actually even be able to reuse it if you call setLen, but I kinda doubt it |
18:06:02 | arkanoid | not necessary. I opt for speed, not memory consumption. But so far I fear I'm facing too many copies so I'm focusing on that |
18:07:08 | PMunch | If you're opting for speed just run with gc:none :P |
18:07:13 | PMunch | And never release memory |
18:07:58 | PMunch | Nothing says speed like a gc:none party, because a gc:none party don't stop (until you run out of memory and crash) |
18:11:05 | FromDiscord | <Yardanico> not allocating memory is also faster than allocating memory :P |
18:11:28 | arkanoid | long live to king stack! |
18:12:50 | FromDiscord | <Hamid Bluri> In reply to @dom96 "I don't use nimsuggest": you must have a good memory đ |
18:14:51 | * | terminalpusher joined #nim |
18:14:53 | PMunch | Good memory? |
18:15:23 | arkanoid | he is referring about dom96 not using nimsuggest or any autocompletion thingy |
18:16:14 | PMunch | You don't need that good memory :P |
18:16:33 | PMunch | Well I guess you need to remember the names of different modules |
18:16:42 | PMunch | But you need that anyways don't you? |
18:17:56 | FromDiscord | <IsaacPaul> In reply to @hamidb80 "you must have a": I'm the same. I have terrible memory. I heavily rely on the autocomplete and ide tools when programming. |
18:18:25 | FromDiscord | <IsaacPaul> In reply to @PMunch "But you need that": Nope google will remember for you or any notes you keep lol |
18:19:10 | FromDiscord | <Hamid Bluri> In reply to @IsaacPaul "Nope google will remember": every time you code you google it ? đ |
18:19:48 | FromDiscord | <Hamid Bluri> i google it and use nimsuggest togother đ |
18:20:21 | FromDiscord | <IsaacPaul> Yea, well I'm always switching between kotlin, java, swift, objc. So I might have done xyz before but its long gone |
18:21:40 | arkanoid | I also rely a lot on ide tools. I have to deal daily with 5 or more ecosystems |
18:21:58 | FromDiscord | <Hamid Bluri> In reply to @arkanoid "I also rely a": omg |
18:22:20 | FromDiscord | <Hamid Bluri> youre super human |
18:22:50 | * | jjido joined #nim |
18:22:54 | PMunch | Meanwhile I'm here programming Nim and C# in Vim without much in the way of IDE tools :P |
18:23:25 | FromDiscord | <Hamid Bluri> In reply to @PMunch "Meanwhile I'm here programming": pmunch what are those red lines on your VIM đ |
18:24:02 | arkanoid | PMunch: I was a C# programmer once, and well, it's a compiled thing. Try to mix interpreted and compiled world, with some functional in the middle. I feel stressed |
18:24:03 | PMunch | Which ones? |
18:24:07 | PMunch | The long vertical ones? |
18:24:15 | FromDiscord | <Hamid Bluri> In reply to @PMunch "The long vertical ones?": yes |
18:24:21 | arkanoid | column limit |
18:24:24 | PMunch | arkanoid, I'm not a C# dev by choice to but it that way :P |
18:24:35 | PMunch | @Hamid_Bluri, those are column limits |
18:24:56 | arkanoid | PMunch: I was a videogame programmer once, I used to do that in C# (Unity Engine mainly, but not just that) |
18:24:58 | PMunch | One at 80, and one at whatever it is that GitHub wraps at |
18:25:21 | PMunch | I've also done game programming in Nim for a job |
18:25:57 | FromDiscord | <IsaacPaul> I'm sure you're much more productive when you've internalized everything. I used to work on one code base a few years ago, and it's like you're still thinking about solutions when you're home. Now on several code bases I definitely don't even retain anything lol |
18:26:45 | arkanoid | Exactly, it's context switching |
18:26:56 | arkanoid | I get paid to context switch fast |
18:27:30 | arkanoid | once upon a time, I used to write large codebases. Now is all scripting in different languages |
18:27:33 | PMunch | Oh well, I've gotta run |
18:28:19 | FromDiscord | <Hamid Bluri> @arkanoid , did you find a solution for your async server that couldn;t recover after network corrupt? |
18:28:30 | FromDiscord | <Hamid Bluri> it was a month ago i guess |
18:29:04 | arkanoid | yes, after a quite large refactor the problem went away, but I upgraded nim in the meanwhile ... who knows |
18:29:09 | arkanoid | maybe was a bug |
18:29:31 | FromDiscord | <Hamid Bluri> that's ok : D |
18:30:22 | FromDiscord | <Hamid Bluri> pmunch i've got something for you |
18:30:23 | FromDiscord | <Hamid Bluri> https://github.com/mitchellh/advent-2021-sql |
18:30:36 | FromDiscord | <Hamid Bluri> he's a legend |
18:30:42 | PMunch | Haha, yeah I saw that on HN this morning :P |
18:32:03 | * | PMunch quit (Quit: leaving) |
18:35:00 | arkanoid | what? |
18:35:18 | arkanoid | :D ninja! |
18:52:57 | arkanoid | can "when" be used as expression/block? |
18:53:51 | FromDiscord | <Solitude> !eval echo (when true: 3 else: 4) |
18:53:53 | NimBot | 3 |
18:54:31 | arkanoid | thanks! |
19:00:49 | arkanoid | and can I use case statement at compile time to discriminate generic parameter T? |
19:01:08 | arkanoid | I'm using a long chain of when/elif now |
19:01:59 | arkanoid | I'm getting "Error: selector must be of an ordinal type, float or string" but not sure if I'm using it correctly |
19:04:34 | arkanoid | nevermind, I've found a good way to layout the long chain |
19:04:47 | arkanoid | (using block:) |
19:22:34 | FromDiscord | <victorNine> Hi! I'm trying to compile for openWRT using the info here\: https://nivrrex-github-io.translate.goog/posts/crosscompiling-for-openwrt-with-nim/?_x_tr_sch=http&_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=no |
19:22:59 | FromDiscord | <victorNine> but I'm getting errors like mips-openwrt-linux-gcc\: error\: unrecognized argument in option '-mtune=generic' |
19:23:09 | FromDiscord | <victorNine> any idea what I'm doing wrong |
20:12:05 | arkanoid | oh dear, got a "Error: internal error: expr(skModule); unknown symbol" on nim 1.6.0 |
20:18:26 | * | pch_ joined #nim |
20:18:49 | arkanoid | !eval import std/sequtils; sequtils |
20:18:51 | NimBot | Compile failed: /usercode/in.nim(1, 22) Error: internal error: expr(skModule); unknown symbol |
20:19:24 | arkanoid | I know it's silly, but should this raise an internal error? |
20:19:35 | arkanoid | !eval import std/hashes; hashes |
20:19:37 | NimBot | Compile failed: /usercode/in.nim(1, 20) Error: internal error: expr(skModule); unknown symbol |
20:20:13 | * | pch quit (Ping timeout: 240 seconds) |
20:59:00 | * | vicfred joined #nim |
21:33:14 | * | terminalpusher quit (Remote host closed the connection) |
21:59:48 | FromDiscord | <retkid> Out of memory defects originate from a failed allocation, right? |
22:12:11 | FromDiscord | <konsumlamm> In reply to @arkanoid "I know it's silly,": nothing should raise an internal error, ever |
22:12:18 | FromDiscord | <konsumlamm> an internal error is always a bug |
22:12:39 | FromDiscord | <konsumlamm> arkanoid: i suggest you open an issue for that |
22:36:37 | FromDiscord | <IsaacPaul> Shouldn't it be `from module import whatever` or just `import module` |
22:37:01 | FromDiscord | <ynfle (ynfle)> As apposed to what? |
22:37:16 | FromDiscord | <IsaacPaul> `import std/sequtils; sequtils` mentioned above |
22:38:16 | FromDiscord | <ynfle (ynfle)> The `;` is the equivalent (in many cases) of a newline in nim code |
22:38:41 | FromDiscord | <ynfle (ynfle)> the `import std/sequtils` is import the `sequtils` module from the standard library |
22:39:34 | FromDiscord | <IsaacPaul> ah I think he probably meant to do `std/sequtils as sequtils` |
22:41:07 | FromDiscord | <ynfle (ynfle)> There's no reason for that. It's imported as sequtils. The `std/` is just qualifying it as the standard library version |
22:49:12 | FromDiscord | <ynfle (ynfle)> @arkanoid what were you trying to do with that? |
22:53:52 | FromDiscord | <Rika> Probably just stumbled upon it |
22:54:30 | FromDiscord | <retkid> In reply to @PMunch "Nothing says speed like": same |
23:17:39 | * | krux02 quit (Remote host closed the connection) |
23:52:21 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzzâŠ) |