00:00:15 | * | joast quit (Quit: Leaving.) |
00:20:56 | * | joast joined #nim |
00:41:08 | * | arielp joined #nim |
01:11:15 | * | grobe0ba quit (Quit: ZNC 1.7.5 - https://znc.in) |
01:11:27 | * | grobe0ba joined #nim |
01:21:30 | * | AMG18 joined #nim |
01:21:49 | * | AMG18 quit (Client Quit) |
01:36:59 | * | njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.) |
01:37:21 | * | njoseph joined #nim |
01:39:34 | FromDiscord | <Gary M> Is there a reason why mingw gcc on windows is stuck on version 6? |
01:40:01 | leorize[m] | Araq never updated it, that's all |
01:40:24 | FromDiscord | <flywind> use `mingw-w64` |
01:40:48 | FromDiscord | <Gary M> I know it only affects a very small % of the userbase, but you can't flag it for c++17 because it's just too old |
01:41:15 | FromDiscord | <Gary M> right now I'm actually using WSL2 to compile for windows, which is weird I guess but it works better than default. |
01:41:19 | leorize[m] | you can just point nim to a newer gcc of your choice |
01:41:24 | FromDiscord | <Gary M> default windows behaviour |
01:41:50 | FromDiscord | <Gary M> it's also much easier to install mingw on linux than windows |
01:41:55 | FromDiscord | <Gary M> no dealing with msys stuff |
01:42:54 | leorize[m] | i think araq policy for mingw on windows is to use the oldest supported version |
01:43:15 | FromDiscord | <Gary M> on another note: I encountered some weird behavior with loading shared libs |
01:43:19 | leorize[m] | msys is pretty straightforward tbh |
01:43:32 | FromDiscord | <Gary M> WSL2 is more straightforward, I think |
01:43:54 | FromDiscord | <Gary M> I use VScode which is integrated with WSL2 so I never leave the windows environment |
01:44:15 | FromDiscord | <Gary M> so basically I have "libbgfx-shared-lib(Debug|Release).dll" on windows right |
01:44:21 | leorize[m] | ah true, microsoft is good at building lock-ins |
01:44:36 | FromDiscord | <Gary M> it looks for it right next to the executable just fine |
01:44:41 | FromDiscord | <Gary M> however |
01:44:49 | FromDiscord | <Gary M> "libbgfx-shared-lib(Debug|Release).so" on linux does not |
01:45:02 | FromDiscord | <Gary M> it searches the system directory |
01:45:11 | leorize[m] | that's due to how linux works |
01:45:17 | FromDiscord | <Gary M> it looks like just using "./libbgfx-shared-lib(Debug|Release).so" fixes the "issue" |
01:45:35 | leorize[m] | please don't |
01:45:41 | FromDiscord | <Gary M> don't what? |
01:45:54 | leorize[m] | `./` means "current directory" |
01:46:28 | leorize[m] | it means whatever directory that you happen to be in |
01:46:34 | FromDiscord | <Gary M> well yes |
01:46:39 | leorize[m] | not the executable location |
01:46:45 | FromDiscord | <Gary M> are all linux shared libraries supposed to be in the same location? |
01:46:57 | leorize[m] | by default, yes |
01:47:09 | leorize[m] | there's a way around using rpath |
01:47:21 | FromDiscord | <Gary M> so how would I distribute the shared library? |
01:47:30 | FromDiscord | <Gary M> and better yet link it from the wrapper |
01:48:00 | leorize[m] | hmm, what are you trying to do? |
01:48:18 | leorize[m] | you're trying to ship your software, right? |
01:48:29 | FromDiscord | <Gary M> it's a simple app that opens a window with SDL2 then links bgfx to the window |
01:48:41 | FromDiscord | <Gary M> sdl2 ships in most package managers just fine |
01:48:44 | FromDiscord | <Gary M> but bgfx does not |
01:49:08 | leorize[m] | so your two choices are to either statically link or to use rpath |
01:49:24 | leorize[m] | using rpath is simpler so I'll show you how |
01:49:35 | FromDiscord | <Gary M> okay |
01:50:23 | leorize[m] | pass `--passL:'-Wl,-rpath,$ORIGIN'` to the compiler, which will instruct the dynamic linker to look for libraries in the same directory as the executable |
01:51:24 | FromDiscord | <Gary M> ah I see, cool. |
01:51:35 | leorize[m] | you might notice the use of single quotes, and that's intentional since `$ORIGIN` is a special specifier and not an environment variable, thus has to be passed verbatim to the linker. |
01:53:35 | leorize[m] | you should inspect the generated binary with `readelf -d` to verify that the rpath is set |
01:56:56 | FromDiscord | <Gary M> so I don't know how to `readelf -d` because I'm dumb |
01:57:02 | FromDiscord | <Gary M> but it appears the rpath is not working |
01:57:33 | leorize[m] | can you post the output of `readelf -d <exe>`? |
01:58:21 | FromDiscord | <Gary M> sent a code paste, see https://play.nim-lang.org/#ix=2S6n |
01:58:25 | FromDiscord | <Gary M> now I know how to use readelf -d lol |
01:58:38 | leorize[m] | :P |
01:58:49 | FromDiscord | <Gary M> anyways, nothing there. |
01:59:07 | leorize[m] | looks like the `$ORIGIN` was eaten by your shell or smt :/ |
01:59:35 | leorize[m] | can you compile with `--listCmd:on` and post the output? |
02:00:55 | * | abm quit (Read error: Connection reset by peer) |
02:04:33 | FromDiscord | <Gary M> sent a code paste, see https://play.nim-lang.org/#ix= |
02:06:10 | leorize[m] | Yardanico: ^ broken paste |
02:06:57 | FromDiscord | <Yardanico> Huh |
02:06:57 | FromDiscord | <Yardanico> sent a long message, see http://ix.io/2S6v |
02:06:59 | FromDiscord | <Gary M> -lm -Wl,-rpath,$ORIGIN -ldl -flto |
02:07:53 | leorize[m] | @Gary try `$$ORIGIN` |
02:08:04 | leorize[m] | hopefully that'd work |
02:08:20 | FromDiscord | <Gary M> It doesn't. |
02:08:22 | FromDiscord | <Gary M> I did try that |
02:08:24 | FromDiscord | <Gary M> 0x000000000000001d (RUNPATH) Library runpath: [28620ORIGIN] |
02:12:16 | FromDiscord | <Gary M> GOT IT. |
02:12:29 | FromDiscord | <Gary M> `\\$ORIGIN/` did the trick |
02:12:46 | FromDiscord | <Gary M> for note, it's inside a string in a nimble task |
02:13:00 | FromDiscord | <Gary M> but it did need the \ |
02:16:22 | leorize[m] | what a pain :p |
02:17:00 | FromDiscord | <Gary M> Oh don't I know it |
02:17:12 | FromDiscord | <Gary M> my friend thought bgfx + nim just wasn't working on nim |
02:17:19 | FromDiscord | <Gary M> on linux |
02:17:59 | FromDiscord | <Gary M> also there are some outdated x11 and windows things in Vladar's sdl2 bindings |
02:18:10 | leorize[m] | rpath origin has always been a trouble due to how troublesome passing the flag is |
02:18:24 | FromDiscord | <Gary M> nim's winlean didn't really seem to have all the types, if it did they aren't 1:1 named anymore |
02:18:33 | FromDiscord | <Gary M> so I used winim/lean, but idk |
02:18:35 | * | lritter quit (Ping timeout: 265 seconds) |
02:18:58 | * | lritter joined #nim |
02:19:25 | leorize[m] | yea, use winim, bindings in nim stdlib are terrible |
02:53:43 | * | wasted_youth2 joined #nim |
02:54:10 | * | krux02 quit (Remote host closed the connection) |
02:56:34 | FromDiscord | <Gary M> do we know if vladar is on the irc or somewhere else? |
02:56:54 | FromDiscord | <Gary M> nvm, answered my own question, looks like he's on the IRC |
02:57:05 | FromDiscord | <Gary M> saying his name mentions him yes? |
03:16:30 | * | NimBot joined #nim |
03:20:32 | * | muffindrake quit (Ping timeout: 260 seconds) |
03:22:08 | * | muffindrake joined #nim |
04:02:39 | * | gpanders quit (Remote host closed the connection) |
04:03:34 | * | gpanders joined #nim |
04:20:11 | * | spiderstew joined #nim |
04:21:45 | * | spiderstew_ quit (Ping timeout: 272 seconds) |
04:40:45 | * | a_chou joined #nim |
04:41:42 | * | a_chou quit (Remote host closed the connection) |
04:42:15 | * | a_chou joined #nim |
04:50:05 | saem | PMunch: I'm certain I'm correct as that's how backwards compatibility is maintained for the LSP spec and implementations. Also that's how extension of the protocol are possible for other use cases. It's why the spec uses TypeScript interfaces (structural types) for specification. |
04:51:31 | FromDiscord | <mattrb> sent a code paste, see https://play.nim-lang.org/#ix=2S6T |
05:04:22 | FromDiscord | <Yardanico> You can't store an openarray like that, it's not a "concrete" type |
05:04:34 | FromDiscord | <Yardanico> You can do it with https://nim-lang.org/docs/manual_experimental.html#view-types but I'd recommend just using a seq |
05:05:54 | FromDiscord | <mattrb> Gotcha, makes sense. I can totally just use a seq here. Thanks |
05:09:13 | FromDiscord | <flywind> sent a code paste, see https://play.nim-lang.org/#ix=2S6X |
05:09:15 | FromDiscord | <flywind> compiles with `-d:ssl` |
05:09:26 | FromDiscord | <flywind> use valgrind |
05:09:45 | FromDiscord | <flywind> It says `==1717935== in use at exit: 3,645 bytes in 8 blocks↵==1717935== total heap usage: 33 allocs, 25 frees, 26,741 bytes allocated` |
05:09:49 | FromDiscord | <flywind> does it mean it have some leaks? |
05:10:01 | FromDiscord | <flywind> (edit) "have" => "has" |
05:12:52 | * | njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.) |
05:13:00 | * | njoseph joined #nim |
05:13:52 | FromDiscord | <Rika> That’s not the full output |
05:14:09 | FromDiscord | <Rika> What’s the output of the lines with unreachable in them |
05:14:46 | FromDiscord | <Rika> Those are possible leaks, but people say it doesn’t matter if you’re leaking memory if running in a full fledged OS like Linux or so |
05:14:55 | FromDiscord | <Rika> The OS will take care of it anyway |
05:15:21 | FromDiscord | <flywind> sent a code paste, see https://play.nim-lang.org/#ix=2S6Y |
05:15:26 | FromDiscord | <Rika> Lost being 0 means no leak |
05:15:48 | FromDiscord | <Rika> I don’t remember what reachable means but I remember lost means a leak |
05:15:59 | FromDiscord | <flywind> I see, thanks. |
05:16:13 | FromDiscord | <Rika> It’s on the valgrind quick start guide |
05:16:51 | FromDiscord | <flywind> I found it, thanks |
05:35:13 | * | narimiran joined #nim |
05:54:28 | * | blitzworks joined #nim |
06:05:32 | * | a_chou quit (Quit: a_chou) |
06:10:26 | ForumUpdaterBot | New Nimble package! bio_seq - A Nim library for biological sequence data., see https://github.com/kerrycobb/nim-dna-seq |
06:25:26 | FromDiscord | <Yardanico> In reply to @flywind "I found it, thanks": You're not testing the right way |
06:25:52 | FromDiscord | <Yardanico> You have to use -d:useMalloc as well because Nim uses its own allocator by default |
06:26:38 | FromDiscord | <Yardanico> Also global memory is never freed of course |
06:26:58 | Prestige | Is there a langage syntax spec for Nim? |
06:27:29 | FromDiscord | <flywind> In reply to @Yardanico "Also global memory is": I see |
06:27:41 | FromDiscord | <ElegantBeef> > This document is a draft! Several of Nim's features may need more precise wording. This manual is constantly evolving into a proper specification. |
06:27:44 | FromDiscord | <ElegantBeef> From the manual 😄 |
06:28:04 | FromDiscord | <Yardanico> In reply to @Prestige "Is there a langage": Manual is the closest we have |
06:28:10 | FromDiscord | <Yardanico> Or you mean the grammar? |
06:28:15 | Prestige | Grammar, yeah |
06:28:23 | FromDiscord | <Yardanico> manual contains grammar as well |
06:28:27 | Prestige | Cool, ty |
06:28:44 | FromDiscord | <Yardanico> In the very start |
06:29:20 | FromDiscord | <Yardanico> (there's also some intro about used symbols and stuff)↵https://nim-lang.org/docs/manual.html#syntax-grammar |
06:30:46 | Prestige | I'm looking into writing a tree-sitter grammar, this is really helpful |
06:30:58 | saem | @Yardanico do you stream regularly? |
06:31:05 | FromDiscord | <Yardanico> Not really |
06:31:18 | FromDiscord | <Yardanico> @Prestige isn't there treesitter for Nim already? |
06:31:35 | Prestige | Not that I've found, would be great if there was |
06:32:08 | saem | I tried it today... it takes a lot of getting used to having the monologue running continuously. 😅 |
06:32:50 | FromDiscord | <Yardanico> you don't have to speak that much :) |
06:32:59 | Prestige | a google search shows someone actually asked about a treesitter grammar for nim today, lol https://old.reddit.com/r/neovim/comments/lznywy/question_about_treesitter_support/ |
06:34:02 | saem | Feels like I do when it's working on the compiler, at least for me, it's mostly staring at the code, wondering why something works that way and bouncing around files reading, picking a small change to make, and then repeat. |
06:48:39 | * | vicfred quit (Quit: Leaving) |
06:52:14 | * | narimiran quit (Ping timeout: 264 seconds) |
06:53:01 | * | letto quit (Quit: Konversation terminated!) |
07:01:20 | * | lritter quit (Ping timeout: 265 seconds) |
07:10:30 | FromDiscord | <Yardanico> Yeah that's fine |
07:10:36 | * | waleee-cl quit (Quit: Connection closed for inactivity) |
07:10:44 | FromDiscord | <Yardanico> People don't talk that much on most programming streams |
07:14:44 | * | PMunch joined #nim |
07:18:17 | * | letto joined #nim |
07:45:45 | * | narimiran joined #nim |
07:54:11 | FromDiscord | <haxscramper> Prestige: I have https://github.com/haxscramper/tree-sitter-nim/blob/master/grammar.js that I didn't finish yet, so if you want to give it a try you can start from here |
07:54:45 | FromDiscord | <haxscramper> Though I don't have that much experience writing tree-sitter grammars so the thing kind of halted midway |
07:56:14 | FromDiscord | <haxscramper> Also generated parser is very large (larger than c++) and I'm not sure I'd that is because I did something wrong, or it is due to nim grammar |
07:58:20 | FromDiscord | <haxscramper> And also I need to learn how to make indentation-sensetive lexer |
08:07:42 | saem | Prestige: LMK if you get interested in property based testing, I'd be interested in working with someone to get something basic together to see if it can generate random programs and do some narrowing. |
08:18:37 | * | tane joined #nim |
08:22:37 | ForumUpdaterBot | New Nimble package! nimib - nimib 🐳 - nim 👑 driven ⛵ publishing ✍, see https://github.com/pietroppeter/nimib |
08:30:57 | idf | is the bot showing new nimble packages too now |
08:31:10 | PMunch | Yup |
08:31:38 | idf | nice, i i thought its people making new forum threads for their packages and i was a bit confused |
08:35:04 | PMunch | I've read half the README for that package and I still have no idea what it does.. |
08:35:35 | * | JustASlacker joined #nim |
08:38:25 | FromDiscord | <ElegantBeef> That's exactly what it does, it makes people confused 😛 |
08:39:28 | FromDiscord | <ElegantBeef> Seems like it's a DSL to make web pages |
08:39:46 | FromDiscord | <ElegantBeef> https://pietroppeter.github.io/nimib/hello.html from https://github.com/pietroppeter/nimib/blob/main/docs/hello.nim |
08:40:38 | ForumUpdaterBot | New Nimble package! meta - View and set the metadata for audio files, see https://github.com/RainbowAsteroids/meta |
08:55:32 | FromDiscord | <hugogranstrom> Nimib feels like it would be a nice option to write tutorials in as the code is the same as the page. No more copying of code into a code block in markdown and hoping everything runs 🙃 |
08:56:28 | FromDiscord | <Yardanico> In reply to @idf "is the bot showing": also with that it's easier for people to discover new packages |
08:56:33 | FromDiscord | <Yardanico> and I bet new packages will get more starts too XD |
08:56:40 | FromDiscord | <Yardanico> (edit) "starts" => "stars" |
09:01:24 | * | haxscramper joined #nim |
09:37:42 | * | pbb quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.) |
09:37:48 | ForumUpdaterBot | New thread by Drkameleon: Sorting array by object key, see https://forum.nim-lang.org/t/7589 |
09:38:55 | * | pbb joined #nim |
09:51:49 | ForumUpdaterBot | New thread by Vitreo12: Add "buildLib" option to "envcc", see https://forum.nim-lang.org/t/7590 |
09:54:13 | * | Vladar joined #nim |
10:05:46 | * | krux02 joined #nim |
10:12:15 | FromDiscord | <zetashift> From https://nim-lang.github.io/Nim/contributing.html#writing-tests-stdlib `Each test should be in a separate block: statement, such that each has its own scope. ` why doesn't the stdlib use testament too? |
10:13:43 | FromDiscord | <Yardanico> because for examples it's better to use runnableExamples and because a lot of tests in the stdlib are quite old |
10:13:49 | FromDiscord | <Yardanico> quite a few tests were migrated to use testament instead |
10:14:02 | FromDiscord | <Yardanico> have you seen https://github.com/nim-lang/Nim/tree/devel/tests/stdlib ? |
10:14:48 | FromDiscord | <zetashift> I didn't yet, I was reading the contributing page and just wondered why, I guess sometimes with Nim it's better to just dive in 😛 |
10:14:54 | FromDiscord | <Yardanico> wdym wondered why? |
10:15:04 | FromDiscord | <Yardanico> this line implies testament https://media.discordapp.net/attachments/371759389889003532/818426584120688720/unknown.png |
10:15:06 | FromDiscord | <zetashift> I wondered why stdlib was tested using `block` statements |
10:15:32 | FromDiscord | <Yardanico> https://github.com/nim-lang/Nim/blob/devel/tests/stdlib/thttpcore.nim an example of a stdlib module being tested |
10:15:43 | FromDiscord | <Yardanico> `block` are used to avoid identifier duplication |
10:15:47 | FromDiscord | <zetashift> ooohh |
10:15:48 | FromDiscord | <Yardanico> so you don't need to care to rename your test variables |
10:16:56 | FromDiscord | <zetashift> thanks :D, I overthinked a bit seeing those block statements |
10:18:56 | * | tane quit (Quit: Leaving) |
10:50:26 | * | aeverr joined #nim |
10:51:09 | FromDiscord | <dom96> In reply to @Yardanico "and I bet new": awesome idea 🙂 |
10:55:50 | Oddmonger | i was expecting a custom «repr» with this one : https://play.nim-lang.org/#ix=2S7X |
10:56:34 | FromDiscord | <Yardanico> you should know that more specific procs have higher priority over generic ones :) |
10:57:09 | Oddmonger | so this proc has higher priority ? |
10:57:36 | Oddmonger | i had forgotten the :string return ^^' |
10:57:40 | FromDiscord | <Yardanico> yep |
10:57:50 | FromDiscord | <Yardanico> but yeah, maybe it's just because it's in the same file, I'm not sure :D |
10:58:14 | FromDiscord | <Yardanico> if you do `echo 5` it works even with your code, so nim doesn't call your proc for it |
10:58:15 | Oddmonger | i should rename it `my$` maybe |
10:58:22 | FromDiscord | <Yardanico> (and echo calls $ for each argument implicitly) |
10:59:31 | * | aeverr left #nim ("Konversation terminated!") |
11:04:33 | Oddmonger | thank you, bon appétit :)’ |
11:22:07 | PMunch | Block statements are great .) |
11:25:44 | idf | yeah they are really nice |
11:26:03 | PMunch | Especially since they can also return stuff |
11:26:20 | PMunch | And be broken out of |
11:26:25 | PMunch | Just great stuff all around |
11:26:36 | idf | yeah very useful to break out of a lot of loops |
11:27:18 | idf | kinda easy to overthink with them if you're not careful sometimes |
11:27:22 | FromDiscord | <Yardanico> disruptek intensifies |
11:27:44 | idf | i miss him bros |
11:27:52 | FromDiscord | <Yardanico> @pietroppeter btw I hacked around this with nim's highlite and nim's nimdoc css https://media.discordapp.net/attachments/371759389889003532/818444902160793610/unknown.png |
11:28:15 | FromDiscord | <pietroppeter> In reply to @PMunch "I've read half the": Yeah, I definitely can (and will) improve the README, but I hoped hello example would give it away. Anyway @ElegantBeef's explanation of a "DSL to make web pages" is a good explanation. I plan to clean it up, tag the 0.1 and make a forum announcement later this week. There has been some discussion about it in #science channel |
11:28:28 | FromDiscord | <Yardanico> it's a bit lacking in "color" but we can improve highlite a bit since it's really customizable |
11:28:33 | FromDiscord | <Yardanico> just take identifiers from https://github.com/highlightjs/highlight.js/blob/master/src/languages/nim.js |
11:28:39 | FromDiscord | <Yardanico> like builtin |
11:28:44 | FromDiscord | <Yardanico> and literals too |
11:29:02 | FromDiscord | <pietroppeter> ah, a nimdoc skin 🙂 |
11:29:52 | FromDiscord | <Yardanico> also it's funny how a lot of nim extensions highlight openarray and not openArray (even in your hello world example) |
11:29:56 | FromDiscord | <Yardanico> although openArray is the "canonical" spelling :P |
11:30:04 | FromDiscord | <Yardanico> I mean nim syntax highlighting extensions |
11:30:12 | FromDiscord | <Yardanico> even highlight.js has openarray and not openArray |
11:30:30 | FromDiscord | <Yardanico> (and its case sensitive while it should be only case sensitive for the first letter and also ignore underscores) :P |
11:30:37 | FromDiscord | <Yardanico> but it's so much you can ask from those more generic solutions |
11:30:41 | FromDiscord | <Yardanico> (edit) "but it's ... so" added "only" |
11:31:04 | FromDiscord | <Yardanico> I will try to make highlite make output closer to highlight.js (add the builtin and literal stuff) |
11:31:05 | FromDiscord | <pietroppeter> yep, the idea as I mentioned is just to use those identifiers. I was thinking of having as output the same classes the highlight.js uses so that you can reuse all CSS by highlightjs: https://github.com/pietroppeter/nimib/blob/main/assets/atom-one-light.css |
11:31:19 | FromDiscord | <Yardanico> oh yeah I can definitely use those |
11:31:57 | FromDiscord | <Yardanico> also seems like highlight.js nim grammar is outdated :D |
11:32:03 | FromDiscord | <Yardanico> no `concept` for example |
11:32:04 | FromDiscord | <pietroppeter> very possibly |
11:32:26 | FromDiscord | <Yardanico> also `generic` is not a keyword (was it ever one?) |
11:32:48 | FromDiscord | <Yardanico> ah it was in older nim versions |
11:32:55 | FromDiscord | <Yardanico> from 0.12.0 https://media.discordapp.net/attachments/371759389889003532/818446174368694303/unknown.png |
11:32:59 | FromDiscord | <zetashift> Could use https://shiki.matsu.io/ for highlighting maybe |
11:34:08 | FromDiscord | <Yardanico> i don't see if it works for languages not supported by vscode out-of-the-box? |
11:34:24 | FromDiscord | <Yardanico> yeah need to do https://github.com/shikijs/shiki/blob/master/docs/languages.md#add for nim as well |
11:34:37 | FromDiscord | <zetashift> It uses textmate grammar right? Could re-use: https://github.com/Varriount/NimLime/tree/master/Syntaxes |
11:34:38 | FromDiscord | <Yardanico> I'll play around with highlite a bit more |
11:35:07 | FromDiscord | <Yardanico> @zetashift yeah, github uses this grammar too |
11:35:13 | FromDiscord | <Yardanico> for nim |
11:36:02 | * | tane joined #nim |
11:36:26 | FromDiscord | <zetashift> https://github.com/shikijs/shiki/blob/master/scripts/pullGrammarsFromGitHub.js think you could modify this repo to point to the Nim grammars |
11:36:43 | FromDiscord | <Yardanico> i guess so, you might want to mention it in https://github.com/pietroppeter/nimib/issues/11 |
11:36:58 | FromDiscord | <Yardanico> although I don't see how is it that different from highlight.js (except being able to use vscode themes of course) |
11:37:43 | FromDiscord | <zetashift> Yeah I think that's the main difference |
11:38:40 | FromDiscord | <zetashift> actually Nim is in this PR: https://github.com/shikijs/shiki/pull/102/commits it's a 1 line change ahah |
11:39:05 | FromDiscord | <zetashift> But I see pietroppeter wants to go a non JS way? |
11:39:20 | FromDiscord | <zetashift> In that case shiki isn't gonna cut it |
11:39:48 | FromDiscord | <Yardanico> yeah for that I want one of the options to be nim's own highlighting :) |
11:42:39 | FromDiscord | <zetashift> Yeah that would be better |
11:49:11 | FromDiscord | <Yardanico> yep wasn't that hard to add builtins to nim's highlite https://media.discordapp.net/attachments/371759389889003532/818450270501339147/unknown.png |
11:49:33 | FromDiscord | <Yardanico> now lets try to inline styles from https://github.com/pietroppeter/nimib/blob/main/assets/atom-one-light.css for a test |
11:58:38 | FromDiscord | <Yardanico> @pietroppeter I guess I kind of did it |
11:58:44 | FromDiscord | <Yardanico> default https://media.discordapp.net/attachments/371759389889003532/818452669952819221/unknown.png |
11:58:52 | FromDiscord | <Yardanico> him highlite with my custom code https://media.discordapp.net/attachments/371759389889003532/818452703722078229/unknown.png |
11:59:36 | PMunch | Why is TOP SECRET coloured? |
11:59:43 | FromDiscord | <Yardanico> because it's a link :P |
12:00:55 | PMunch | Aah |
12:01:11 | FromDiscord | <Yardanico> for this simple example the actual html is really close between highlight.js and nim's highlite |
12:01:36 | FromDiscord | <Yardanico> relevant part of code - https://gist.github.com/Yardanico/144caea455c43917a409a22b56f34c03 |
12:01:38 | FromDiscord | <Unaimend> In reply to @Yardanico "for this simple example": What are you working on? |
12:01:51 | FromDiscord | <Yardanico> some experiments for static syntax highlighting for https://github.com/pietroppeter/nimib |
12:02:36 | FromDiscord | <Unaimend> is that a static site generator? |
12:02:56 | FromDiscord | <Yardanico> no, it's more of nim-centric article writing DSL :P |
12:03:35 | FromDiscord | <Unaimend> hmm, still interesting. I plan on writing a few blog posts regarding nim. |
12:03:50 | FromDiscord | <Yardanico> yeah I like nimib a lot too |
12:03:52 | FromDiscord | <Unaimend> Stuff for newcomers, which I am still basically am |
12:08:15 | * | JustASlacker quit (Quit: Leaving) |
12:08:35 | * | JustASlacker joined #nim |
12:12:07 | ForumUpdaterBot | New thread by Marcomq: Nimview - a lightweight UI helper, see https://forum.nim-lang.org/t/7591 |
12:20:18 | * | aeverr joined #nim |
12:20:59 | PMunch | Yardanico, how do you like Hugo so far? |
12:21:18 | FromDiscord | <Yardanico> well, provided I only have 1 hello world blog post on the blog I can't say I have much experience :P |
12:21:26 | FromDiscord | <Yardanico> but it wasn't hard to tinker with the theme to adapt it to my needs |
12:21:28 | PMunch | Haha, fair point :P |
12:21:30 | FromDiscord | <Yardanico> and hugo seems to be very fast |
12:21:46 | FromDiscord | <Yardanico> it can act as an interactive server (rebuilding content on changes) and that is really fast |
12:21:50 | FromDiscord | <Yardanico> under 10-20ms usually |
12:21:57 | FromDiscord | <Yardanico> closer to 1-5 |
12:22:37 | PMunch | Oh cool |
12:23:06 | FromDiscord | <Yardanico> so yeah, this is my small attempt at using highlight js themes for nim highlite module (ignore the last func and missing imports) - https://gist.github.com/Yardanico/144caea455c43917a409a22b56f34c03 |
12:23:36 | FromDiscord | <Yardanico> in the end you get static annotated code that when combined with a highlight jss css theme (there's a lot of them) will result in syntax highlighting :P |
12:24:01 | * | arielp quit (Quit: WeeChat 3.0.1) |
12:25:19 | FromDiscord | <Yardanico> so the highlighting is all colourful even if it's using nim's own highlighting https://media.discordapp.net/attachments/371759389889003532/818459357875929099/unknown.png |
12:25:34 | FromDiscord | <Yardanico> I think we might want to improve rstgen to highlight some of this stuff too - for example builtin types |
12:25:44 | FromDiscord | <Yardanico> the current highlighting is fine but it's a bit too "bland" :P |
12:25:50 | FromDiscord | <Yardanico> only keywords are highlighted |
12:25:56 | FromDiscord | <Yardanico> well, also literals and stuff |
12:29:14 | * | SebastianM joined #nim |
12:35:11 | FromDiscord | <Yardanico> i forgot - is there anything in the stdlib to escape stuff to be HTML-friendly ? |
12:36:58 | FromDiscord | <Yardanico> ah right https://nim-lang.org/docs/cgi.html#xmlEncode%2Cstring can work |
12:37:11 | FromDiscord | <Unaimend> So Is it correct that the `==` operator cannot compare sequence of two different types? |
12:37:27 | FromDiscord | <Unaimend> (edit) "So Is it correct that the `==` ... operatorof" added "" | "operator ... cannot" added "of `seq`" |
12:37:33 | FromDiscord | <Yardanico> of course, how would it do that? |
12:37:49 | FromDiscord | <Unaimend> i.e. seq[StringView] und seq[string] |
12:38:04 | FromDiscord | <Unaimend> in my exampleI do not see a problem |
12:38:22 | FromDiscord | <haxscramper> You can just implement ``func `==`(a: Type1, b:DifferentType): bool`` |
12:39:27 | FromDiscord | <Unaimend> In reply to @haxscramper "You can just implement": yea did that |
12:41:19 | FromDiscord | <Unaimend> sent a code paste, see https://play.nim-lang.org/#ix=2S8w |
12:41:33 | FromDiscord | <Unaimend> (edit) "https://play.nim-lang.org/#ix=2S8w" => "https://play.nim-lang.org/#ix=2S8x" |
12:41:45 | FromDiscord | <Unaimend> (edit) "https://play.nim-lang.org/#ix=2S8x" => "https://play.nim-lang.org/#ix=2S8y" |
12:42:05 | FromDiscord | <Unaimend> (edit) "https://play.nim-lang.org/#ix=2S8y" => "https://play.nim-lang.org/#ix=2S8z" |
12:42:30 | FromDiscord | <Yardanico> no |
12:42:46 | FromDiscord | <Yardanico> wait actually |
12:42:49 | FromDiscord | <Yardanico> yeah it won't work |
12:42:54 | FromDiscord | <Yardanico> you have to define a custom `==` for seqs of different types |
12:43:05 | FromDiscord | <Unaimend> kk |
12:43:19 | FromDiscord | <Yardanico> Nim's own == expect both sides to be the same type |
12:43:52 | FromDiscord | <Unaimend> Do we have a nice way to write commutattive operators↵beause now you have to define |
12:43:55 | FromDiscord | <haxscramper> yeah, you need to implement ``func `==`[T0, T1](a: seq[T0], b: seq[T1]): bool = `` |
12:44:21 | FromDiscord | <Unaimend> ==(a: T, a:B) and ==(a;B, a:T) |
12:44:49 | FromDiscord | <Unaimend> sry my explanation is lacking |
12:44:58 | FromDiscord | <Unaimend> ofc a macro should be easy |
12:44:59 | FromDiscord | <Yardanico> no, actually you won't have to make two of them |
12:45:15 | FromDiscord | <Unaimend> is this not solvable by templates? |
12:45:25 | FromDiscord | <Yardanico> ??? |
12:45:47 | FromDiscord | <Unaimend> sth like defineEquals(type1, typr2) |
12:46:03 | FromDiscord | <Yardanico> as I said, you don't have to define it twice |
12:46:10 | FromDiscord | <Unaimend> sry |
12:46:10 | FromDiscord | <Yardanico> since both arguments are generic |
12:46:19 | FromDiscord | <Unaimend> yeah ok in this case |
12:46:37 | FromDiscord | <Unaimend> but when you normally define `==` you have to do it twice |
12:47:00 | FromDiscord | <Rika> even in this case its not needed, only a `==` for a: strview, b: string (and backwards too probably?) is needed |
12:47:11 | FromDiscord | <Yardanico> no he's right |
12:47:22 | FromDiscord | <Yardanico> in nim order of arguments matters in this case |
12:47:32 | FromDiscord | <Yardanico> for == for string and StringView |
12:47:39 | FromDiscord | <Unaimend> and its the same for `+` etc |
12:47:42 | FromDiscord | <Yardanico> yes |
12:47:47 | FromDiscord | <Rika> i just said what you just said |
12:47:57 | FromDiscord | <Unaimend> Should this be in the nim core lib? |
12:48:06 | FromDiscord | <Yardanico> well, I think it's not used that often |
12:48:12 | FromDiscord | <Unaimend> hmm kk |
12:48:39 | FromDiscord | <Unaimend> Then ofc it should not be in the core lib |
12:49:05 | FromDiscord | <Yardanico> so yeah, something like this |
12:49:11 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=2S8C |
12:49:15 | FromDiscord | <Yardanico> == definition copied from the same one for openArray |
12:49:16 | FromDiscord | <haxscramper> https://nim-lang.org/docs/manual.html#distinct-type-modeling-currencies |
12:49:29 | FromDiscord | <haxscramper> Distinct example just uses template |
12:49:44 | FromDiscord | <Yardanico> it borrows though |
12:49:49 | FromDiscord | <haxscramper> To define everything twice, but you can also implement `{.commutativeOp.}` macro pragma |
12:50:02 | FromDiscord | <Unaimend> In reply to @haxscramper "To define everything twice,": ahhh this I what I was looking fore |
12:50:10 | FromDiscord | <Yardanico> you'll have to make it yourself ;) |
12:50:16 | FromDiscord | <Yardanico> but it shouldn't be so hard |
12:50:32 | FromDiscord | <haxscramper> In reply to @haxscramper "To define everything twice,": sent a code paste, see https://play.nim-lang.org/#ix=2S8E |
12:50:36 | FromDiscord | <Unaimend> In reply to @haxscramper "I'm talking about this": yeah |
12:51:05 | FromDiscord | <haxscramper> I bet arraymancer has this implemented as macro |
12:51:14 | FromDiscord | <haxscramper> I'm 99.9% sure |
12:51:16 | FromDiscord | <Yardanico> XDDD |
12:51:23 | FromDiscord | <Rika> does using two generics guarantee that T0 and T1 are unique? |
12:51:28 | FromDiscord | <haxscramper> no |
12:51:41 | FromDiscord | <Rika> how do i guarantee uniqueness then? |
12:51:55 | FromDiscord | <haxscramper> But it is less generic than one with only single parameter, so it would use `seq[T]` for single sequences |
12:52:17 | FromDiscord | <haxscramper> In reply to @Rika "how do i guarantee": Not sure, maybe `T0, T1: not T0` |
12:52:21 | FromDiscord | <Rika> what if i want to emit an error if theres nothing more specific? |
12:52:28 | FromDiscord | <Rika> does that work... |
12:52:31 | FromDiscord | <Rika> lets see |
12:52:45 | FromDiscord | <haxscramper> It would be awesome if it did |
12:52:56 | FromDiscord | <Rika> !eval proc a[T0; T1: not T0](a: T0, b: T1) = discard |
12:52:57 | NimBot | <no output> |
12:53:05 | FromDiscord | <Rika> oooooooooo |
12:54:02 | FromDiscord | <Rika> !eval proc a[T0; T1: not T0](a: T0, b: T1); a(0, 0); proc a[T0; T1: not T0](a: T0, b: T1) = discard |
12:54:03 | NimBot | Compile failed: /usercode/in.nim(1, 40) Error: type mismatch: got <int literal(0), int literal(0)> |
12:54:08 | FromDiscord | <Rika> should error |
12:54:16 | FromDiscord | <Rika> OML |
12:54:26 | FromDiscord | <Rika> @haxscramper it actually works |
12:54:31 | * | SebastianM quit (Quit: -a- Bye Bye) |
12:54:51 | FromDiscord | <Rika> !eval proc a[T0; T1: not T0](a: T0, b: T1); a(0.int, 0.0); proc a[T0; T1: not T0](a: T0, b: T1) = discard |
12:54:53 | FromDiscord | <Rika> should work... |
12:54:53 | NimBot | <no output> |
12:55:01 | FromDiscord | <Rika> and it does 😮 |
12:55:15 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=2S8K |
12:55:27 | FromDiscord | <haxscramper> Because it is really aambiguous |
12:55:33 | FromDiscord | <haxscramper> (edit) "aambiguous" => "ambiguous" |
12:55:54 | FromDiscord | <Rika> why would it not? |
12:55:58 | FromDiscord | <Rika> i dont see the issue... |
12:56:13 | FromDiscord | <Unaimend> depens how nim implements ths stuff I think |
12:57:18 | FromDiscord | <Unaimend> but I think it would be cool if this would work, but then I dont know a scenario we it would be usefull.↵But at least those template magicians in c++ found a use case for everything |
12:57:28 | FromDiscord | <haxscramper> In reply to @Rika "why would it not?": Generic parameter overlaps. You have one unconstrained that catches absolutely everything, and one more specialized, but it seems like overload resolution does not have such fine-grained selection to prefer first one over second |
12:57:31 | FromDiscord | <Rika> generics are really strong |
12:57:38 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=2S8P |
12:57:50 | FromDiscord | <haxscramper> This works, but because it explicitly uses single type for generic parameter |
12:57:58 | FromDiscord | <Rika> In reply to @haxscramper "Generic parameter overlaps. You": okay |
12:58:00 | FromDiscord | <Rika> understood |
12:59:08 | FromDiscord | <Unaimend> In reply to @haxscramper "Generic parameter overlaps. You": But I we what it it should be possible to implement |
12:59:33 | FromDiscord | <Unaimend> But we should make overload resolution to complicated |
12:59:38 | FromDiscord | <Rika> yes but i feel it would be difficult to implement |
13:00:10 | FromDiscord | <Unaimend> If I rember the overload res. stuff between templates and auto and normal funcs in c++ that was weird stuff |
13:00:26 | FromDiscord | <haxscramper> I think [T0; T1: not T0]` is different from `[T0, T1]` iff `T0 is T1` |
13:00:30 | FromDiscord | <haxscramper> (edit) "[T0;" => "`[T0;" |
13:00:51 | FromDiscord | <haxscramper> And `[T0 is T1]` is basically `[T]` |
13:01:32 | FromDiscord | <haxscramper> And C++ has SFINAE so it can just try to match every possible implementation |
13:02:49 | FromDiscord | <haxscramper> I.e. it does not try to solve any constraints to choose best-matching implementation, it just tries all of them in order and if there is some horrific `std::enable_if` that does not match it just goes over the next one. Well, at least that's what it looks like at first glance |
13:03:43 | FromDiscord | <Rika> is that one reason compilation explodes? |
13:03:47 | FromGitter | <ynfle> You could also put `not T0` in the type of the param |
13:03:48 | * | Tanger joined #nim |
13:04:44 | FromDiscord | <haxscramper> https://github.com/nim-lang/Nim/blob/devel/compiler/semcall.nim#L102 |
13:04:45 | FromDiscord | <haxscramper> https://github.com/nim-lang/Nim/blob/devel/compiler/sigmatch.nim#L302 |
13:05:50 | FromDiscord | <haxscramper> I think main parts of our sigmatch logic is somewhere around here. From what I can tell nim just selects best-fitting candidate over all possible ones by comparing them |
13:06:40 | FromDiscord | <haxscramper> In reply to @Rika "is that one reason": Part of the reason. This, multiplied by repeated reparsing and reinstantiation of templates (because header files) |
13:07:28 | FromDiscord | <Rika> 😄 |
13:07:42 | FromDiscord | <Rika> In reply to @ynfle "You could also put": yeah, implicit generic |
13:08:16 | FromGitter | <ynfle> There is still an issue of it not being discarded which I'm not sure about |
13:09:48 | FromDiscord | <Rika> because the string is not used (not returned or consumed by other function) |
13:09:49 | FromDiscord | <Rika> ? |
13:20:03 | m4r35n357 | Hi all, thought I understood the basics after porting a working program from c to nim, but clearly not! I am now porting a program that fails in c owning to "library rot", and am getting an "undeclared identifier" compiler error. Really basic huh? The error occurs at line 14 of https://pastebin.com/i5WTGjze (obviously plot & generate are stubbed out) |
13:20:28 | FromDiscord | <Unaimend> So can you use the IntelliJ profiler for nim programs? I head that there is an semi-official plugin for IntelliJ |
13:22:34 | FromDiscord | <Rika> m4r35n357: you didnt put the variable declaration keywords (`var` or `let`) before such |
13:22:52 | FromDiscord | <Rika> so it has to be `let c: ...` and `let d: ...` |
13:22:59 | FromDiscord | <Rika> or you can do a block let |
13:23:18 | FromDiscord | <Rika> `let(newline)(indent)c: ...(newline)(indent)d: ...` |
13:23:37 | m4r35n357 | Rika how embarrassing! thx |
13:23:40 | FromDiscord | <Rika> have to do that for every variable you declare |
13:23:49 | FromDiscord | <Rika> so others below too |
13:27:56 | FromGitter | <ynfle> @Rika, not in my version |
13:28:31 | FromDiscord | <Rika> well i dont know what you're running so i cant determiune the issue |
13:32:33 | * | Tanger quit (Quit: Leaving) |
13:33:00 | FromGitter | <ynfle> The playground link I posted |
13:33:05 | FromGitter | <ynfle> Oh sory |
13:33:09 | FromGitter | <ynfle> Forgot to post it |
13:34:09 | FromGitter | <ynfle> https://play.nim-lang.org/#ix=2S8U |
13:34:57 | FromDiscord | <Rika> not returning string |
13:35:07 | FromDiscord | <Rika> (no return type) |
13:36:21 | FromGitter | <ynfle> Oh haha |
13:42:34 | m4r35n357 | at the risk of further humiliation, I am now getting an unused variable error for a used variable (making the last line in the function an explicit return didn't make any difference) https://pastebin.com/6NXJSbz7 |
13:42:58 | FromDiscord | <Rika> dude dont worry |
13:43:04 | FromDiscord | <Rika> no humiliation here |
13:43:20 | FromDiscord | <Rika> what line? |
13:43:24 | m4r35n357 | line 339 |
13:43:30 | m4r35n357 | line 39 |
13:43:31 | FromDiscord | <Rika> i mean in the paste 😛 |
13:43:33 | FromDiscord | <Rika> oh ok |
13:43:53 | FromDiscord | <Unaimend> @Yardanico we need another nim stream, I need distraction from my exam preparation |
13:43:57 | FromDiscord | <Rika> unindent the P P line |
13:44:02 | FromDiscord | <Rika> you accidentally indented it |
13:44:14 | FromDiscord | <hamidb80> how can i print a address of a variable? |
13:44:38 | FromDiscord | <Rika> `echo aVar.addr.int`? not sure if that works... |
13:44:49 | FromDiscord | <Rika> maybe cast |
13:45:02 | FromDiscord | <Rika> `echo cast[uint](aVar.addr)` |
13:45:14 | FromDiscord | <Yardanico> only if it's a `var` of course |
13:45:23 | FromDiscord | <hamidb80> In reply to @Rika "`echo cast[uint](aVar.addr)`": what does `cast` do? |
13:45:28 | JustASlacker | yay for further humiliation |
13:45:31 | FromDiscord | <Yardanico> interpret one type as another type |
13:45:35 | FromDiscord | <Yardanico> bitwise |
13:45:43 | FromDiscord | <hamidb80> i could find docs about it |
13:45:48 | FromDiscord | <hamidb80> (edit) "could" => "couldn't" |
13:45:54 | FromDiscord | <Yardanico> https://nim-lang.org/docs/manual.html#statements-and-expressions-type-casts |
13:46:22 | m4r35n357 | JustASlacker, glad to oblige; rika the indentation was not acccidental, and removing it makes no difference |
13:46:52 | FromDiscord | <Rika> lets see if i misread something |
13:46:54 | FromDiscord | <Rika> one moment |
13:46:55 | m4r35n357 | I tried unindenting, and adding an explicit return |
13:47:01 | m4r35n357 | neither works |
13:47:23 | PMunch | m4r35n357, you have an unmatched ) on line 39 |
13:47:36 | FromDiscord | <hamidb80> hey |
13:47:37 | FromDiscord | <Rika> i told to dedent `P P - delta (p.mu2 r2 + K)` because in the code it's matched with the `let` and not the `proc` |
13:47:40 | FromDiscord | <hamidb80> you cant do that |
13:48:07 | FromDiscord | <Yardanico> ? |
13:48:08 | PMunch | And you're not returning anything.. |
13:48:30 | PMunch | Oh wait, yeah as Rika says line 41 should be unindented |
13:48:34 | FromDiscord | <Yardanico> and why do you need an address btw? |
13:48:34 | m4r35n357 | Rika what about automatic return, does that not work within a "let" |
13:48:40 | m4r35n357 | PMunch, that is it! |
13:48:49 | PMunch | m4r35n357, no it doesn't work within a let |
13:49:03 | PMunch | The let block itself doesn't return anything |
13:49:09 | JustASlacker | Im just glad somebody else is also a noob |
13:49:12 | FromDiscord | <Rika> no, it doesnt make sense, `let` only does variable declaration |
13:49:30 | m4r35n357 | PMunch, OK, I was actually testing that, but the ')' asked the result! |
13:49:37 | m4r35n357 | masked |
13:49:39 | PMunch | By the way, you don't need to declare your variable types |
13:50:18 | m4r35n357 | OK I'll use inference, I was trying to find the bug |
13:50:43 | PMunch | I mean you can if you want to, or if you think it makes it more clear/easier to read. I was just saying that you don't have to |
13:50:50 | PMunch | In case you weren't aware :) |
13:51:50 | m4r35n357 | PMunch, I'm still learning where, I just took out the "let"s and started getting undeclared identifiers again . . . |
13:52:11 | FromDiscord | <Rika> thats not what he means |
13:52:14 | FromDiscord | <Rika> i think |
13:52:22 | m4r35n357 | OK I get it |
13:52:24 | FromDiscord | <Rika> he means you dont need the : float parts and stuff |
13:52:30 | m4r35n357 | sorry,my mistake |
13:52:44 | m4r35n357 | it is very hot & sweaty here ;) |
13:53:28 | PMunch | Oh right, yes you need the let/var/const part, but not the type (float/int/Dual) part |
13:54:15 | PMunch | Bit weird that you got an unused variable error by the way |
13:54:20 | FromDiscord | <hamidb80> !eval var a = 1; echo repr(addr a) |
13:54:22 | NimBot | ptr 0x55df97d70060 --> 1↵ |
13:54:51 | FromDiscord | <hamidb80> In reply to @NimBot "ptr 0x55df97d70060 --> 1↵": i need something like that but without `ptr` and `-->` |
13:55:03 | m4r35n357 | PMunch, AFAICT that was triggered by the unmatched bracket |
13:55:21 | FromDiscord | <dk> !eval var a = 1; echo repr(cast[int](addr a)) |
13:55:23 | NimBot | 94700569542752 |
13:55:31 | FromDiscord | <Rika> !eval var a = 1; echo cast[uint](addr a) |
13:55:33 | NimBot | 94549207056480 |
13:55:34 | FromDiscord | <Rika> ? |
13:55:43 | FromDiscord | <Rika> no need to repr an int... |
13:56:15 | m4r35n357 | PMunch, confirmed, just had the same thing further down ;) |
13:58:01 | m4r35n357 | Great, all fixed, now I can start on the fun part ;) |
13:59:48 | PMunch | import strutils; var x = 1; echo toHex(cast[uint](x.addr)) |
14:00:07 | PMunch | !eval import strutils; var x = 1; echo toHex(cast[uint](x.addr)) |
14:00:11 | NimBot | 000055794BBF9060 |
14:00:33 | PMunch | If you want it as hex @hamidb80 |
14:01:20 | FromDiscord | <Yardanico> @hamidb80 just saying - people from IRC won't see discord reactions :) |
14:01:34 | PMunch | m4r35n357, happy to be of help :) |
14:01:37 | FromDiscord | <hamidb80> In reply to @Yardanico "<@!745944009918251010> just saying -": yeah i know |
14:02:16 | PMunch | Makes it kinda hard for me to see that you liked my message though.. |
14:02:17 | FromDiscord | <hamidb80> In reply to @PMunch "m4r35n357, happy to be": i saw some of your videos, you use `npeg` a lot 😅 |
14:02:37 | PMunch | Haha, I used npeg a lot during AoC because it was an apt tool for the job :) |
14:02:44 | PMunch | But yes, I have used it quite a bit |
14:02:55 | PMunch | Really nice tool |
14:06:48 | FromDiscord | <ITR> Does anything like this exist for Nim? https://youtu.be/8QiPFmIMxFc |
14:07:08 | FromDiscord | <Yardanico> what exactly? |
14:07:33 | FromDiscord | <Yardanico> ah, no, I don't think there's an editor that allows for this interactive-like thing |
14:07:47 | FromDiscord | <ITR> that's a shame |
14:08:02 | FromDiscord | <Yardanico> well, you can kinda do it with hot code reloading but it's not the same |
14:08:15 | FromDiscord | <ajusa> What's the best way to send a seq of bytes in Nim? The send function in net takes a string, so I assume I want to convert a seq of bytes to a string then. Is cast a good option here? |
14:09:03 | FromDiscord | <Yardanico> internally seq[char] is the same as string (except the null terminator), so yeah, you can usually just cast |
14:09:08 | FromDiscord | <Rika> it works kinda i guess but its not really a good idea |
14:09:17 | FromDiscord | <Yardanico> but it's an internal implementation detail, so it's up to you if you want to rely on it or not |
14:09:43 | FromDiscord | <ajusa> I guess my other option is a map to char and reduce to string maybe? |
14:09:53 | FromDiscord | <hamidb80> In reply to @ITR "Does anything like this": wow |
14:10:05 | FromDiscord | <Yardanico> @ajusa your other option is just a for loop, yes |
14:10:28 | FromDiscord | <ITR> In reply to @Yardanico "internally seq[char] is the": if it's a byte sequence then a null-terminated string would be horrible |
14:10:28 | PMunch | @ITR, seems like you have found yourself a project :) |
14:10:38 | FromDiscord | <ajusa> https://github.com/nim-lang/Nim/issues/14810 seems like it would help me |
14:10:39 | PMunch | There's nothing inherently stopping Nim from being used like that |
14:10:52 | PMunch | Either through hot code reloading, or with NimScript |
14:11:35 | FromDiscord | <hamidb80> In reply to @PMunch "There's nothing inherently stopping": right |
14:12:35 | FromDiscord | <ITR> hmm, so one feature he shows off is hovering a line of code to show its effect, so that would have to be some sort of custom editor, right? |
14:12:49 | FromDiscord | <Rika> In reply to @Yardanico "internally seq[char] is the": strings in nim dont have null terminators though do they? |
14:13:02 | PMunch | Ah, yes that would need to be a custom thing |
14:13:35 | FromDiscord | <Yardanico> In reply to @Rika "strings in nim dont": they always do, for C compat, so that a conversion from a string to a cstring is kind of zero-cost |
14:13:38 | FromDiscord | <ITR> tho maybe an alternative with a macro could work |
14:13:39 | PMunch | I mean you could render the image with and without that line and then somehow show the difference |
14:13:46 | FromDiscord | <Yardanico> but null terminator isn't usually used for any string operations |
14:13:48 | FromDiscord | <Yardanico> nim strings have a length field |
14:13:52 | FromDiscord | <Yardanico> it's purely for C compat |
14:15:43 | FromDiscord | <ITR> maybe I'll try and do a project with hot-reloading or nimscript for music instead of graphics |
14:15:46 | FromDiscord | <Yardanico> so that cstring(nimstring) is zero-cost |
14:16:35 | FromDiscord | <Yardanico> and of course null terminator can be useful in hand-written lexers/parsers sometimes |
14:16:48 | FromDiscord | <Yardanico> You can't access a null-terminator of a nim string, but you can if you do cstring(string) |
14:17:03 | FromDiscord | <Yardanico> (in the past null terminator for nim strings was accessible as well) |
14:19:02 | * | abm joined #nim |
14:20:04 | PMunch | This is what a string looks like in Nim: https://play.nim-lang.org/#ix=2S9n |
14:20:06 | PMunch | Pretty much |
14:20:25 | FromDiscord | <Yardanico> in old runtime, yes |
14:21:01 | PMunch | In old runtime? |
14:21:06 | FromDiscord | <Yardanico> with refc/etc |
14:21:15 | PMunch | Is that not what they look like now? |
14:21:16 | FromDiscord | <Yardanico> arc/orc is "new runtime" |
14:21:22 | FromDiscord | <Yardanico> in new runtime there's NimStringV2 = obj with len and p fields, and p is a pointer to NimStrPayload which has cap: int and uncheckedarray data |
14:21:24 | FromDiscord | <Yardanico> https://github.com/nim-lang/Nim/blob/devel/lib/system/strs_v2.nim |
14:21:37 | PMunch | Oooh |
14:21:43 | PMunch | Didn't know that, thanks |
14:23:40 | * | JustASlacker quit (Ping timeout: 276 seconds) |
14:23:41 | FromDiscord | <Yardanico> Also if someone's curious - I mostly finished my nim highlighting "module" based on highlite - https://github.com/pietroppeter/nimib/blob/8dc6bad0ad4572715ea0767ba0a407bc175a4c57/src/nimib/highlight.nim |
14:23:56 | FromDiscord | <Yardanico> it uses highlight.js theme classes but that can be easily changed, and it highlights much more stuff than nim's highlite |
14:24:01 | FromGitter | <redblack3_gitlab> Is there a specific reason why the `len` field of strings is the first field? Why isn't the `ptr` the first field? |
14:24:43 | FromDiscord | <Yardanico> Honestly I don't know an answer for that, you'd have to ask someone like Araq or clyybber |
14:24:44 | PMunch | Cache optimisation perhaps |
14:24:56 | PMunch | You probably read length before starting to read data |
14:24:58 | FromGitter | <redblack3_gitlab> if it was the first field, just doing something like `addr nimstring` would give the null terminated string straight away without having to offset by `sizeof int` |
14:25:02 | PMunch | Or it's just random |
14:25:08 | FromGitter | <redblack3_gitlab> ah alright |
14:25:14 | FromDiscord | <Yardanico> @redblack it still won't because in NimStrPayload cap is the first field :P |
14:25:20 | FromDiscord | <Yardanico> then you'd have to rearrange that too |
14:25:21 | PMunch | I mean the way you do it is mystring[0].addr |
14:25:26 | FromDiscord | <Yardanico> yeah |
14:25:38 | PMunch | To get the pointer to the first character in the string, which is the pointer to the whole string |
14:26:34 | FromGitter | <redblack3_gitlab> ah, didn't realize the `ptr` wasn't the string itself either |
14:28:37 | PMunch | It is with the default GC, but not with the new runtime |
14:30:40 | FromDiscord | <fwsgonzo> Hey all, I have a problem with a multi-project build system. I have made a build script that runs nim on a source file, and then compiles it using CMake |
14:31:01 | FromDiscord | <fwsgonzo> this is for the most part fine, as it doesn't cause much rebuilding - at least I don't think so |
14:31:22 | FromDiscord | <fwsgonzo> so what happens when you add hundreds of projects into the mix? I think it all breaks down |
14:31:56 | * | a_b_m joined #nim |
14:32:04 | * | a_b_m quit (Client Quit) |
14:32:16 | leorize[m] | are you building C from Nim then integrate it with CMake? |
14:32:17 | FromDiscord | <fwsgonzo> with C/C++ hundreds of projects is no big deal, they all run through ninja and it sees only one of the projects changed, and then relinks that |
14:32:22 | FromDiscord | <fwsgonzo> yea |
14:32:33 | leorize[m] | I'd advise against that... |
14:32:59 | FromDiscord | <fwsgonzo> I need to have total control over the build as this is for a custom 64-bit RISC-V toolchain |
14:33:02 | PMunch | Hmm, is there any way to generate JS code like this from Nim? https://developers.home-assistant.io/docs/frontend/custom-ui/lovelace-custom-card#defining-your-card |
14:33:33 | FromDiscord | <fwsgonzo> (edit) "I need to have total control over the build as this is for a custom 64-bit RISC-V toolchain ... " added "- but I'm open to ideas" |
14:34:00 | leorize[m] | you should build nim with the nim compiler :P |
14:34:22 | leorize[m] | the compiler should be able to cross compile |
14:35:48 | FromDiscord | <fwsgonzo> and what happens then, it doesn't rebuild all the projects that haven't changed at the ~speed of ninja? |
14:36:05 | * | abm quit (Ping timeout: 256 seconds) |
14:36:19 | FromDiscord | <haxscramper> In reply to @ITR "Does anything like this": if you want you can write macro that rewrites your code from something like `interactiveConst(10, "Control name")`, which generates list of constants that could be configured at runtime, and it would be only a matter of implementing editor that can edit things interactively. https://play.nim-lang.org/#ix=2S9v < this could be used as a starting point |
14:37:05 | FromDiscord | <haxscramper> So you have all constants, only need to call `setIC` with appropriate IDs somehow |
14:37:20 | FromDiscord | <haxscramper> All locations in original source code are stored in `icMap` |
14:38:42 | leorize[m] | @fwsgonzo ninja does nothing special aside from a better build format than make imo |
14:38:51 | FromDiscord | <ITR> In reply to @haxscramper "*if* you want you": sent a long message, see http://ix.io/2S9x |
14:39:04 | leorize[m] | also your way will just slow you down when IC stabilize in Nim |
14:39:54 | leorize[m] | @fwsgonzo you can just rebuild the nim always :P the compiler knows what it's doing |
14:40:00 | leorize[m] | anyhow, what's your issue right now? |
14:41:05 | FromDiscord | <fwsgonzo> let |
14:41:20 | FromDiscord | <haxscramper> In reply to @ITR "My current idea is": You can in theory use hot code reloading, but it would be much slower compared to set/get for value in sequence at runtime. Even with tcc I doubt you would be able to get decent feedback speeds |
14:42:01 | FromGitter | <redblack3_gitlab> Hey guys, is there an idiomatic way to get a random element out of a `PackedSet`? Or some sort of `pop` function that removes and returns the "last"/random element? I know sets by definition have no order, but I don't care which element I get. Right now I just do ⏎ ⏎ ```for first in self.recycler: ⏎ self.recycler.excl(first) ⏎ return first``` ⏎ ⏎ but my eyes...I could use a `seq` but I |
14:42:01 | FromGitter | ... need `O(1)` performance for search [https://gitter.im/nim-lang/Nim?at=604637b844f5a454a4618a54] |
14:42:19 | FromDiscord | <ITR> hmm |
14:42:19 | FromDiscord | <haxscramper> If you want to change logic at runtime, then yes, HCR is an only option, but for only changing values it is overkill |
14:42:37 | FromDiscord | <fwsgonzo> let's say you have a game, and you are using sandboxed Nim as the game script - and there are hundreds of maps each with its own binary that is the maps logic - to quickly iterate on that you need to be able to have one build command for everything, so that when you edit files from multiple maps it just instantly builds. I'm sadly not convinced that Nim is the way to go. I'm currently using C++ as the script, which is not very user-frien |
14:43:15 | PMunch | @ITR, did you look at NimScript? |
14:43:19 | FromDiscord | <haxscramper> tcc can get you around 200ms for "hello world", but anything complex would take more time to recompile, and IIRC even with IC you recompile on module level |
14:43:27 | FromDiscord | <ITR> was gonna check out nimscript now |
14:43:39 | FromDiscord | <haxscramper> And yes ^ NimScript is also an option, should look into that |
14:43:44 | PMunch | https://github.com/beef331/nimscripter <- ElegantBeef has done some great work on making it usable |
14:44:23 | FromDiscord | <haxscramper> And also there is a series of articles https://peterme.net/how-to-embed-nimscript-into-a-nim-program-embedding-nimscript-pt-2.html |
14:44:48 | leorize[m] | @fwsgonzo I would say calling nim to build the nim part from cmake is wiser than generating the c sources |
14:45:48 | PMunch | @haxscramper, as the author of that series I would go the NimScripter route myself |
14:46:02 | Clonkk[m] | <FromDiscord "<fwsgonzo> let's say you have a "> As @PMunch said, Nim-scripter from elegant beef is quite useful. Otherwise as non-nim solution, Lua is probably what you want |
14:46:18 | PMunch | NimScripter was made right after that series, to make it nice and useable |
14:50:35 | FromDiscord | <ITR> can attest that lua is often used for stuff like that |
15:00:14 | FromDiscord | <Araq> you can also embed Python, it's more heavy weight but works much better than Lua IMHO. |
15:01:18 | Prestige | Lua syntax just doesn't feel right to me |
15:01:30 | FromDiscord | <Araq> in Lua the `nil` state is simply too pervasive, it's far worse than in other languages, Python included |
15:02:22 | PMunch | Use NimScript, popularize it :) |
15:02:48 | FromDiscord | <Araq> I'm sad nobody optimizes our VM, it's X times slower than freaking Python and I dunno why 😛 |
15:03:16 | PMunch | Oh, I thought it was about Python speed |
15:03:26 | Prestige | It got slower |
15:03:44 | FromDiscord | <Araq> in theory we have the much better design, register based VM, fast dispatching, no GC activity for integers |
15:04:50 | PMunch | Ah, well that's not great |
15:04:55 | PMunch | The fact it got slower I mean |
15:05:00 | FromDiscord | <Clyybber> but PNode for objects ;) |
15:05:20 | FromDiscord | <Araq> @Clyybber we lose in the `fib` benchmark |
15:05:28 | FromDiscord | <Araq> same for `fac` |
15:05:50 | FromDiscord | <Araq> there is something very weird going on 🙂 |
15:05:57 | FromDiscord | <Clyybber> hmm |
15:06:26 | FromDiscord | <Araq> the PNodes for objects don't enter the picture and even these are faster than Python's dict based objects |
15:06:30 | FromDiscord | <mratsim> does it use computed gotos? Otherwise to go further some assembly is needed. |
15:06:51 | FromDiscord | <Araq> I never enabled .computedGoto, feared the codegen bugs |
15:07:09 | FromDiscord | <mratsim> but even then I don't think the dispatch is the bottleneck, would need a profile. |
15:07:28 | FromDiscord | <Araq> we dispatch not nearly as often as we generate few instructions |
15:07:31 | FromDiscord | <Clyybber> there are some low hanging fruits like https://github.com/nim-lang/Nim/issues/16790 but that doesnt explain fib either |
15:07:59 | FromDiscord | <Araq> thanks to the register based VM, we don't produce many instructions to begin with |
15:08:28 | FromDiscord | <Araq> we need to look at it via a profiler |
15:08:37 | PMunch | So no-one knows if it is possible to output JS code in a specific way? |
15:09:22 | * | abm joined #nim |
15:10:04 | FromDiscord | <mratsim> if you turn your screen you can output it sideway |
15:10:20 | PMunch | -_- |
15:10:35 | PMunch | I meant more output something that would be compatible with this https://developers.home-assistant.io/docs/frontend/custom-ui/lovelace-custom-card#defining-your-card |
15:10:42 | FromDiscord | <Yardanico> @PMunch I mean you can probably emit the whole JS class if you want |
15:11:45 | FromDiscord | <Yardanico> IIRC classes in JS are just sugar |
15:11:45 | FromDiscord | <Araq> @PMunch we need `class` support for the FFI, somehow |
15:11:59 | FromDiscord | <Araq> this also comes up again and again for C++ interop |
15:12:03 | FromDiscord | <Araq> RFCs are welcome |
15:12:41 | FromDiscord | <Yardanico> found http://xahlee.info/js/js_without_class_keyword.html, might be relevant |
15:12:49 | FromDiscord | <Yardanico> not sure how to do "extends" though |
15:13:23 | FromDiscord | <mratsim> Class for C++ do work |
15:13:39 | FromDiscord | <mratsim> it's "only" the constructor and deleted destructors that are annoying |
15:13:43 | FromDiscord | <Yardanico> about JS - there are packers/etc that polyfill classes to older browsers, etc, so it should definitely be possible |
15:13:55 | FromDiscord | <Araq> @mratsim you cannot inherit and override a method |
15:14:08 | FromDiscord | <Araq> that frequently comes up for UIs |
15:14:12 | FromDiscord | <mratsim> well if you use methods 🤷 |
15:14:27 | FromDiscord | <Araq> I don't, the C++ frameworks do |
15:15:10 | PMunch | @Yardanico, ooh that is interesting |
15:15:37 | PMunch | Extends probably just adds all the prototypes to the new object |
15:15:52 | PMunch | At least that's how we used to do inheritance back in olden days in JS |
15:16:02 | PMunch | Before it got class support |
15:17:26 | FromDiscord | <Yardanico> yeah, also found https://stackoverflow.com/questions/15192722/javascript-extending-class |
15:18:41 | PMunch | Now the problem is, how can I wrap everything Nim outputs in a class.. I can make a class, but a lot of functions and such are still outside of it.. |
15:19:26 | FromDiscord | <Yardanico> I mean you can "emulate" it with older syntax with functions and prototypes and stuff |
15:19:50 | FromDiscord | <haxscramper> We'd have to hack into nim dispatching mechanism, or introduce second notion of 'method' to make it work |
15:20:08 | PMunch | I guess it might work with variables outside a class |
15:20:13 | federico3 | https://arstechnica.com/gadgets/2021/03/more-top-tier-companies-targeted-by-new-type-of-potentially-serious-attack/ |
15:20:13 | PMunch | Maybe.. |
15:20:13 | FromDiscord | <haxscramper> Otherwise the best option is just generate c++ class and make it call him procedures internally |
15:20:20 | leorize[m] | we already have `exportcpp` |
15:20:28 | leorize[m] | shouldn't be hard to make it build classes |
15:21:07 | FromDiscord | <dom96> You could even make a `jsclass` macro 🙂 |
15:21:17 | FromDiscord | <dom96> Instead of fighting the compiler in this case |
15:21:21 | PMunch | That's exactly what I've done @dom96 |
15:21:40 | PMunch | In the dumbest way possible though: http://ix.io/2S9V |
15:21:41 | FromDiscord | <dom96> nice |
15:21:51 | PMunch | Just to have a look at the JS output |
15:22:21 | FromDiscord | <dom96> ahh, well whatever works, but I guess you'll need to make it possible to specify methods |
15:22:25 | FromDiscord | <dom96> and generate them appropriately |
15:22:32 | PMunch | Yeah, that might be tricky |
15:22:48 | PMunch | Because the Nim code still needs to know about the procedures |
15:22:54 | FromDiscord | <haxscramper> exportcpp is not documented in manual. How is it different from exportc and where I can find docs for it? |
15:22:56 | FromDiscord | <dom96> might not be worth the effort tbh |
15:23:19 | PMunch | Oh, probably not. I'm just doing this to see if it is at all possible |
15:23:32 | FromDiscord | <Yardanico> @haxscramper from 1.0 changelog:"exportc now uses C instead of C++ mangling with nim cpp, matching behavior of importc, see #10578. Use the new exportcpp to mangle as C++ when using nim cpp." |
15:23:32 | FromDiscord | <haxscramper> or it just generates unmangled names or something (i.e. difference is not as big as `importc/importcpp`) |
15:23:35 | PMunch | I've already written add-ons for HA in Nim that works great |
15:23:49 | PMunch | Well, apart from some weird async bug that I can't figure out |
15:24:14 | FromDiscord | <Yardanico> https://github.com/nim-lang/Nim/blob/devel/compiler/pragmas.nim#L823 @haxscramper |
15:24:16 | FromDiscord | <haxscramper> @Yardanico Ah, ok, so basically no functional difference to speak of |
15:24:22 | FromDiscord | <haxscramper> Only mangling |
15:41:43 | FromDiscord | <ITR> hmm, getting an issue with nimscripter, it's complaining about not being able to open file "strutils" on line 16 in nimscript.nim |
15:42:02 | FromDiscord | <ITR> which seems to be the buildOS constant |
15:42:59 | FromDiscord | <ITR> this happens runtime when doing loadScript, even with the loaded script being empty |
16:15:19 | FromDiscord | <ajusa> sent a code paste, see https://play.nim-lang.org/#ix=2Saf |
16:17:07 | FromDiscord | <mratsim> so back to @Yardanico and @queersorceress , is `Thread[ref obj]` even supposed to work? maybe cc @Araq https://github.com/jackhftang/threadproxy.nim/blob/master/src/threadproxy.nim#L78-L96 |
16:17:28 | FromDiscord | <Yardanico> yeah not sure about that, but it crashes while trying to deepCopy ThreadToken |
16:17:51 | FromDiscord | <Yardanico> and fails on the string somehow |
16:19:37 | FromDiscord | <Yardanico> but yeah threadproxy looks kind of shady |
16:19:44 | FromDiscord | <Yardanico> with the stuff it does to "avoid GC", etc |
16:19:53 | FromDiscord | <queersorceress> oh nooo |
16:21:45 | FromDiscord | <queersorceress> i was prepared for that anwser, but i really don't want to write the channel code myself. i'll use anything if it means not doing that from scratch. |
16:22:14 | FromDiscord | <Yardanico> honestly I can't help much because I don't know threads/deepcopy/etc in depth |
16:26:23 | FromDiscord | <queersorceress> i'm just trying to make a basic high level api for pushing work to a queue backed by a thread, and then communicating back the results of that work. the hard bit here is that nim's channel and threading apis are fairly bare bones so this is a lot of work to do correctly from scratch. using threadproxy took away most of work of making the low level apis into higher level ones. i'm fine with replacing that with anything, i just don't |
16:28:10 | FromDiscord | <queersorceress> but since the basic apis are built to not intentionally do both, this is Hard problem. |
16:29:01 | FromDiscord | <queersorceress> unfortunately it's this or doing something horrible and confusing with locks and this seems far more elegant. |
16:29:38 | FromDiscord | <mratsim> I managed to get Weave first comment on a the 4 HN entry 🙂 https://news.ycombinator.com/item?id=26385075 |
16:29:44 | FromDiscord | <mratsim> (edit) "4" => "4th" |
16:32:07 | FromDiscord | <queersorceress> and since the base application i'm working with is jester, so this code is going to be running from async already, i don't think i can feasibly do it with locks without causing massive hangups. |
16:33:34 | FromDiscord | <Yardanico> @queersorceress well, I think it's mostly a lib issue because I managed recreate the same minified version of the bug from the "Manually Create Thread" example |
16:33:45 | FromDiscord | <Yardanico> and the breaking point was adding the Queue object |
16:33:55 | FromDiscord | <Yardanico> as a return type to createQueue |
16:33:58 | FromDiscord | <Yardanico> that breaks it |
16:34:16 | FromDiscord | <Yardanico> actuall;y sorry not that |
16:34:23 | FromDiscord | <Yardanico> removing this breaks it |
16:34:29 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=2San |
16:35:08 | FromDiscord | <queersorceress> so that originally wasn't there, the queue got stored onto the queuemanager in a table instead of being returned. |
16:35:47 | FromDiscord | <queersorceress> if that isn't there then the code does nothing, as no work would get pushed onto the thread. |
16:37:21 | FromDiscord | <Yardanico> but this really makes it work :D |
16:37:33 | FromDiscord | <Yardanico> https://gist.github.com/Yardanico/d268f4a97f32f406813291628c19d8d8 |
16:37:39 | FromDiscord | <Yardanico> ` let answer = waitFor proxy.ask("thread_1", "init", newJNull())` and handling that in workerMain |
16:37:40 | FromDiscord | <Yardanico> and it works |
16:37:44 | FromDiscord | <Yardanico> 🥴 |
16:37:56 | FromDiscord | <Yardanico> dont ask me why, I don't know |
16:38:17 | FromDiscord | <Yardanico> actually you don't even have to handle it in workerMain |
16:39:43 | FromDiscord | <queersorceress> wait, what? so pushing block of work onto the thread does something to resolve the deepcopy? |
16:39:50 | FromDiscord | <Yardanico> exactly, I don't know |
16:40:00 | FromDiscord | <Yardanico> so yeah, if you're fine with that strange workaround and the fact that things might break in some other way later, then you can use it :P |
16:41:47 | FromDiscord | <queersorceress> that feels a bit too magic for what i'm trying to do here but i appreciate the work-around. though it makes me worried to make any more progress incase this is totally unsupported behavior. |
16:43:26 | FromDiscord | <Yardanico> juggling raw pointers can sometimes be dangerous, but it all depends on the exact case |
16:45:24 | FromDiscord | <queersorceress> @Yardanico this is the original code, what you were looking at was a more simplified version https://gist.github.com/samdmarshall/4689f3f08aea17c50616296d057a3a6d |
16:46:59 | FromDiscord | <queersorceress> it's what i would like the api to look like, idk if that changes any of the behavior significantly but it's the same deepcopy crash |
16:47:58 | FromDiscord | <Yardanico> well it seems to work fine with that workaround |
16:48:19 | FromDiscord | <Yardanico> just add ` let answer = waitFor ctx.main.ask(thread_name, "init", newJNull())` after `createThread` |
16:48:28 | FromDiscord | <queersorceress> so it's not related to returning the queue? |
16:48:34 | FromDiscord | <Yardanico> i have no clue :D |
16:48:42 | FromDiscord | <Yardanico> its really really strange |
16:49:26 | FromDiscord | <ajusa> In reply to @ajusa "I'm getting a strange": Tries debugging this further, it doesn't seem like I call connect on the same socket twice either. I read through a bit of async/await stuff in Nim but that didn't really help either... |
16:49:37 | FromDiscord | <queersorceress> that is, urgh, i don't think that's okay. i wouldn't even call that okay in C. |
16:49:50 | FromDiscord | <Yardanico> i don't think that this is okay either |
16:49:56 | FromDiscord | <queersorceress> hahaha |
16:50:49 | FromDiscord | <Yardanico> In reply to @ajusa "Tries debugging this further,": you can't reconnect the socket |
16:51:05 | FromDiscord | <Yardanico> you have to make a new one for each connection |
16:52:27 | FromDiscord | <ajusa> hm, I moved the socket creation to be inside of the while loop and now I get a "Bad file descriptor" error. Thanks though, that's one error resolved 😄 |
16:52:35 | FromDiscord | <Yardanico> this might not be in the asyncdispatch/asyncnet docs, but this is how sockets behave everywhere |
16:52:36 | FromDiscord | <Yardanico> e.g. see https://stackoverflow.com/questions/51901478/python2-7-socket-error-37-operation-already-in-progress |
16:52:40 | FromDiscord | <Yardanico> same thing but in Python |
16:53:45 | FromDiscord | <queersorceress> then i think this will have to wait until someone more knowledgeable can take a look. that is, unless you wanna implement this for me (just kidding). it would help a lot of people though! this is unfortunate that this is my holdup, as working in C i could have solved this and moved on already. |
16:55:47 | FromDiscord | <ajusa> In reply to @ajusa "hm, I moved the": fixed this as well, can't close a socket that failed to connect |
16:56:43 | FromDiscord | <mratsim> In reply to @queersorceress "then i think this": write the backend in C maybe and wrap it from Nim. |
16:57:37 | FromDiscord | <Yardanico> In reply to @ajusa "fixed this as well,": you should also use withTimeout |
16:57:40 | FromDiscord | <mratsim> I do plan to write some threadpool code this week or next week. |
16:57:50 | FromDiscord | <Yardanico> @ajusa see https://github.com/Yardanico/adbscan/blob/master/src/adbscan.nim#L101 |
16:59:00 | FromDiscord | <queersorceress> oh, wait a minute. is it possible that because the thread is created manually, it lacks some internal reference inside threadproxy that causes it to get released early when it leaves scope, hence the deepcopy, and by dispatching some work to it, that reference gets held and thus turns out okay? |
16:59:22 | FromDiscord | <Yardanico> maybe it's something like that, yeah |
16:59:42 | FromDiscord | <Yardanico> maybe you should open an issue? |
16:59:54 | FromDiscord | <Yardanico> the person is active on github so they'll probably respond |
16:59:57 | FromDiscord | <queersorceress> if that's all then i can totally live with that as behavior. |
17:01:01 | FromDiscord | <ajusa> In reply to @Yardanico "<@!102899813149855744> see https://github.com/Yarda": Why is this wrapped in a try block? https://github.com/Yardanico/adbscan/blob/master/src/adbscan.nim#L131 |
17:01:07 | FromDiscord | <queersorceress> In reply to @mratsim "write the backend in": if i write this in C then i'd be using libdispatch and that would still be a major pain to wrap for use with nim. |
17:01:18 | FromDiscord | <Yardanico> @ajusa see the comment |
17:01:29 | FromDiscord | <Yardanico> if it's already closed it'll raise an exception |
17:01:43 | FromDiscord | <Yardanico> and isClosed didn't work for me that well |
17:02:04 | * | vicfred joined #nim |
17:02:17 | FromDiscord | <ajusa> In reply to @Yardanico "and isClosed didn't work": gotcha, that's the exact same issue I was running into. It was saying isClosed is false, I would try to close it, and then I would get an exception |
17:03:15 | FromDiscord | <queersorceress> i'd honestly rather do all this in nim as my experience writing multithreaded code in nim isn't too high and i'd like to change that. also getting libdispatch to work on any non-macos platform is a pain. |
17:08:23 | FromDiscord | <mratsim> ah yes libdispatch uses named threads and channels. |
17:09:56 | FromDiscord | <queersorceress> it's my go-to for a nice high level abstraction of concurrency/threading, difference here would be a queue is always backed by a thread, whereas with libdispatch it isn't guaranteed to be. |
17:12:17 | FromDiscord | <queersorceress> the names are so you don't need to pass around the objects, and afaict it would fit into nim's concurrency model fairly easily, if implemented properly - but nobody has implemented this yet. |
17:13:23 | FromDiscord | <mratsim> There are/were a couple of roadblocks. |
17:14:19 | FromDiscord | <mratsim> 1. strings couldn't be sent across threads until arc (or with Boehm GC), which is problematic when you use named threads.↵2. we need a threadsafe table which is also another problem↵3. we need a robust threadpool |
17:14:23 | FromDiscord | <dom96> @ajusa btw note that `await` will also `yield`, so doing `yield` is redundant, it may in fact cause problems |
17:14:32 | FromDiscord | <dom96> (edit) "@ajusa btw note that `await` will also `yield`, so doing `yield` ... is" added "+ `await`" |
17:17:15 | PMunch | @dom96, I'm looking at this async issue I'm having. Is there anything wrong with putting async procedures in a sequence? |
17:17:20 | PMunch | This is my little library: http://ix.io/2SaB |
17:18:28 | PMunch | And this is how I use it: http://ix.io/2SaC |
17:18:49 | FromDiscord | <dom96> what's the issue? |
17:18:54 | FromDiscord | <queersorceress> In reply to @mratsim "1. strings couldn't be": in this case, you wouldn't need to send the string across threads, just the same representation, no? the threadsafe access of the table should be handled by a lock, that would be kinda clunky but would "work". and yes, the lack of robust threadpool has been a problem. |
17:19:26 | FromDiscord | <mratsim> yes we can send a cstring to make them threadsafe 😄 |
17:20:08 | PMunch | That onEvent is triggered just fine multiple times, but for the final time when it turns on all the lights and starts the radio it triggers the actions but is then stuck at high CPU utilisation and won't trigger the next day. |
17:20:23 | FromDiscord | <mratsim> The locked version of the table does exist https://nim-lang.org/docs/sharedtables.html but it's a stop gap for me |
17:23:44 | FromDiscord | <queersorceress> i mean, as long as you the programmer can construct an identical string, everything else doesn't matter. like, with libdispatch, if you are naming threads it's usually because they have a specific purpose so the name is unlikely to not be hardcoded. |
17:25:20 | FromDiscord | <dom96> PMunch: Hard to say, I don't see you doing anything super strange, maybe apart from the `setTimer` |
17:25:27 | FromDiscord | <queersorceress> so in my case i'm making this thread to handle all my disk io, so regardless of where i am, i can always use the same string constant as the thread name to give work to the right thread. |
17:25:45 | PMunch | @dom96, got a better way of doing that? |
17:26:07 | FromDiscord | <dom96> sent a code paste, see https://play.nim-lang.org/#ix=2SaE |
17:26:07 | FromDiscord | <dom96> bbl |
17:26:33 | PMunch | That seems like such a hack though.. |
17:26:48 | FromDiscord | <queersorceress> in a more complex example or use case that might not be true, or for threads created dynamically to do individual tasks, but with libdispatch those usually don't have names. |
17:27:54 | PMunch | I guess I already have the `while true`/`sleepAsync` loop though.. |
17:32:19 | PMunch | Solving this issue means this library would be ready for publishing by the way. And then I can write an article about writing HomeAssistant automations in Nim :) |
17:45:34 | FromDiscord | <Goel> Why gintro have a single monolithic page to scroll instead of separate documents or tabs like the other repos of that kind? https://github.com/StefanSalewski/gintro |
17:46:19 | * | m4r35n357 quit (Ping timeout: 245 seconds) |
17:48:51 | FromDiscord | <queersorceress> author's preference? it might be easier to search a single page than to dig through multiple. i assume people using the api would already be familiar with it's use |
17:48:52 | * | m4r35n357 joined #nim |
17:51:24 | Prestige | PMunch: do you want assistance with the nimlsp with CoC issue? I could look into it, given details on why allowExtra isn't a proper solution |
17:51:39 | Prestige | Been "broken" for a few months iirc |
17:51:52 | PMunch | Right.. It was that.. |
17:52:18 | PMunch | It has sorta been filed away as "someone elses problem" after you created the issue in the CoC client |
17:52:35 | PMunch | Should be a very easy fix I think |
17:55:25 | FromDiscord | <mratsim> Pretty sure it's because Nim docgen isn't suited for multipage documents |
17:55:29 | FromDiscord | <mratsim> @Goel |
17:59:35 | Prestige | PMunch: I can't find the conversation about the issue on nimlsp. Do you have it handy or know details on the prob? I could just try recreating it, I suppose.. |
17:59:51 | PMunch | Which issue? |
18:00:04 | Prestige | https://github.com/PMunch/nimlsp/issues/71 ande https://github.com/neoclide/coc.nvim/issues/1766 |
18:00:43 | FromDiscord | <queersorceress> @mratsim okay thanks to @Yardanico's work-around my code seems to work now, but seems to be performing multiple operations at once on the thread i made. based on the behavior of the async commands i'm giving i thought that this wouldn't be the case; will i have to add my own deque to manage the execution of new work? if so then i'm starting to think that threadproxy is not something i can rely on to do the heavy lifting of channel |
18:02:01 | FromDiscord | <mratsim> I didn't use asyncdispatch much so I don't know the execution model behind (dos it try to drain all the ready work at once or one by one) |
18:03:20 | PMunch | Well this was your original fix: https://github.com/PMunch/nimlsp/pull/44 |
18:04:20 | PMunch | Hmm, you don't seem to have created an issue for that though.. |
18:04:24 | Prestige | Yeah, that was the solution but not much detail was provided |
18:05:06 | PMunch | Well the problem was that CoC sent extra fields, so the messages with extra fields weren't seen as valid messages (because they aren't) |
18:06:11 | Prestige | What was that causing an issue for? I'm not seeing that as forbidden in the jsonrpc spec, at least |
18:07:05 | FromDiscord | <queersorceress> or rather, i think my question is, based on this example (https://github.com/jackhftang/threadproxy.nim/blob/master/examples/simple_ask.nim) if you were to "ask" the `worker_0` thread for multiple sums, it should perform them serially, not concurrently. as the `workerMain` function would block until it was done one operation because of the `waitFor proxy.poll()`. but that seems like it was an incorrect assumption. |
18:07:38 | PMunch | Where does it say you can have extra fields? |
18:07:53 | Prestige | It doesn't, but it also doesn't say it isn't allowed |
18:07:57 | Prestige | as far as I can tell |
18:08:05 | PMunch | Well they define a spec, I've stuck with the spec |
18:08:29 | Prestige | Did this break something by having extra fields? |
18:08:33 | PMunch | Yes |
18:08:38 | PMunch | I'm trying to find the issue |
18:08:40 | Prestige | Kk |
18:10:54 | * | vicfred quit (Ping timeout: 256 seconds) |
18:11:59 | FromDiscord | <dom96> In reply to @PMunch "That seems like such": I use this pattern all the time. Don't see what's hacky about it. You could make it better I guess by implementing a setTimer proc ala JS. |
18:12:46 | PMunch | Well the hacky part is waiting a minute between checks |
18:12:59 | PMunch | For this case it isn't really an issue, but I just don't like the pattern |
18:13:42 | PMunch | Hmm, can't seem to find it Prestige |
18:13:58 | FromDiscord | <dom96> huh, the idea is you set the timer to whatever you want |
18:14:10 | Prestige | Same D: |
18:14:15 | FromDiscord | <dom96> if you want code to run every 60 secs then set it to 60 secs |
18:14:22 | PMunch | But the issue is that notifications and requests are differentiated by if they have an "id" field or not. With allowExtra a notification is seen as a valid request. |
18:14:57 | Prestige | Wait, can't you just check if `id` exists or am I misunderstanding? |
18:15:08 | PMunch | @dom96, well in my code I set the timer to the next alarm on my phone - 30 minutes. Then in steps from there until the alarm rings. |
18:15:16 | FromDiscord | <Daniel> In reply to @Goel "Why gintro have a": Stefan really invested huge work, effort and time into it, but indeed navigation of the website could be more functional. |
18:15:17 | PMunch | Continuously checking if the alarm changes |
18:15:31 | PMunch | Prestige, yes that is exactly what you can do |
18:15:38 | PMunch | And what my solution was going to be |
18:16:03 | FromDiscord | <mratsim> In reply to @Daniel "Stefan really invested huge": Well, I think Nim docgen isn't up to par. |
18:16:07 | FromDiscord | <Daniel> (edit) "In reply to @Goel "Why gintro have a": Stefan really invested huge work, effort and time into it, but indeed navigation of the website could be ... more" added "much" |
18:16:20 | FromDiscord | <mratsim> I did the same thing as him for Weave, dump everything in the README |
18:17:13 | PMunch | Prestige, or rather I was going to run whenValid without allowExtra on the message vs. notification check. And then with it on the parse specific methods parts |
18:18:23 | Prestige | Hm yeah that could work |
18:18:39 | Prestige | Either way I think it would be a good thing to get this working again for us vim users |
18:19:02 | PMunch | Well, I'm a vim user and don't really have an issue |
18:19:39 | PMunch | But yeah, I'm fixing it now |
18:19:54 | Prestige | Thanks! |
18:22:45 | PMunch | Fun fact, nimlsp freaks out completely on nimlsp source-code :P |
18:23:14 | Prestige | Yeah I saw that haha, think because of the way nimsuggest is imported? |
18:25:11 | PMunch | I dunno, it's like it is looking at its own brain and freaking out by what it seems |
18:25:24 | PMunch | Like if you opened the skull of a person and found a nest of gnomes pulling levers |
18:25:32 | PMunch | There, this should fix the issue: https://github.com/PMunch/nimlsp/commit/c0e05cdd750bdada305dac7cd639f0755aa3253c |
18:29:25 | Prestige | lmao PMunch |
18:29:57 | Prestige | I'll test that out |
18:32:31 | PMunch | Ugh, I wish there was a pre-built Nim Docker image for HomeAssistant.. |
18:32:39 | PMunch | It takes foreeeever to build |
18:32:52 | FromDiscord | <Vindaar> I've finally done it. I've reached peak Nim. Compiler uses 10 GB of RAM, but still compiles successfully in 55 s 😎 🤣 ↵(I have no idea what kind of macro or concept madness is happening here) https://media.discordapp.net/attachments/371759389889003532/818551860713095178/unknown.png |
18:33:36 | PMunch | Djeez |
18:37:14 | Prestige | PMunch: verified I have diagnostics with coc-nvim now, thanks for the fix! |
18:37:42 | PMunch | No problem, now tell CoC to get their shit together and stop breaking the spec! :P |
18:38:36 | Prestige | Haha well if I had specifics on what they were sending I would file an issue |
18:39:14 | Prestige | Should be able to close #71 now |
18:40:01 | PMunch | You should be able to see that from the logs from nimlsp |
18:45:02 | * | Gustavo6046 quit (Remote host closed the connection) |
18:49:28 | * | Gustavo6046 joined #nim |
18:50:27 | FromDiscord | <ajusa> In reply to @dom96 "<@!102899813149855744> btw note that": Yep, thank you very much! I found a github issue from a few years ago where you said the same thing, so I've updated my code accordingly. |
19:02:23 | FromDiscord | <dk> sounds like `yield` should be an error in async |
19:08:38 | federico3 | Araq: want to take a look at the old advisories (not the Nimble ones) before I publish them? https://github.com/nim-lang/security/security |
19:15:08 | FromDiscord | <Vindaar> In reply to @Vindaar "I've finally done it.": sent a code paste, see https://play.nim-lang.org/#ix=2Sbf |
19:15:38 | PMunch | Hmmm. I'm looking at some code for the Teensy and I want to write code like `D6.input(); D6.pullup(); D6.high(); D6.low()` and generate Nim code like `portd or (1 shl 6)` |
19:15:51 | PMunch | What would be the best way of doing this? |
19:17:04 | PMunch | I think I can do `Pin[Port: static[string], Num: static[int]]` and then define the procedures as macros that grabs the port and created the correct identifier. |
19:17:13 | PMunch | But that feels like a bit of a hack.. |
19:30:21 | FromDiscord | <x19> is it possible to call external masm procs from a nim program? |
19:31:29 | * | waleee-cl joined #nim |
19:32:39 | FromDiscord | <mratsim> In reply to @x19 "is it possible to": yes |
19:33:02 | FromDiscord | <x19> nice |
19:33:14 | FromDiscord | <mratsim> This is how I compile ASM code alongside Nim: https://github.com/status-im/nim-blscurve/blob/master/blscurve/blst/blst_lowlevel.nim#L25 |
19:33:16 | PMunch | Well this is an annoying issue: http://ix.io/2Sbn |
19:33:28 | PMunch | No further message on what's wrong.. |
19:33:37 | FromDiscord | <mratsim> and otherwise you can just link it if you have an object file |
19:34:10 | FromDiscord | <x19> nice so i just use the compile pragma the masm assembly code with --cc:vcc |
19:34:56 | PMunch | This is my code by the way: http://ix.io/2Sbo |
19:35:06 | PMunch | Wait.. |
19:35:09 | PMunch | I'm an idiot |
19:41:03 | PMunch | Just creating an object out of the pins and making them const works just fine.. |
19:43:37 | FromDiscord | <Gary M> I know this is weird but is there a way to turn off all error checking for a line? |
19:44:18 | FromDiscord | <konsumlamm> comment it out? |
19:44:24 | FromDiscord | <Gary M> the thing is that I have some when defined(linux): code that creates types different than when defined(windows): |
19:44:36 | FromDiscord | <Gary M> so it thinks it has illformedAST when I'm using windows |
19:44:54 | FromDiscord | <Gary M> but everything compiles fine |
19:47:26 | FromDiscord | <mratsim> {.push checks:off.} and then {.pop.} |
19:48:09 | FromDiscord | <Gary M> I did try that earlier but maybe the issue is that I didn't restart vscode |
19:48:10 | FromDiscord | <mratsim> use a template for convenience: https://github.com/status-im/nim-blscurve/blob/master/blscurve/bls_batch_verifier.nim#L170-L180 |
19:48:12 | FromDiscord | <Gary M> so let me try again |
19:48:37 | FromDiscord | <Gary M> nope, it's still showing the erros |
19:48:54 | FromDiscord | <Gary M> https://i.imgur.com/xExb3k4.png |
19:49:39 | FromDiscord | <haxscramper> That is a hard error, you can't disable it with checks etc. You need to wrap everything in `when` |
19:49:59 | FromDiscord | <haxscramper> To conditionally compile for different OS |
19:50:15 | FromDiscord | <Gary M> it is wrapped with when defined(linux): |
19:50:40 | FromDiscord | <Gary M> it's probably a weird issue to do with using WSL2 |
19:51:07 | FromDiscord | <haxscramper> Then some other `define` elsewhere might also hide other parts |
19:51:16 | FromDiscord | <Gary M> but nimsuggest should be running in WSL2 with the linux installs of nimble pkg's |
19:51:29 | FromDiscord | <Gary M> hm, let me see. |
19:53:09 | FromDiscord | <Gary M> okay so the types are wrapped with another define so I think I know how to fix this. Thanks |
19:53:32 | * | xet7 quit (Remote host closed the connection) |
19:54:33 | * | xet7 joined #nim |
19:55:11 | FromDiscord | <Gary M> well, I thought I knew how to fix this |
19:55:51 | FromDiscord | <Gary M> adding the other define to a cfg file isn't being read by nimsuggest |
19:57:05 | FromDiscord | <zidsal> in the `mgetOrPut` runnableExamples it explains that it's easy to accidentally create a copy of the value. Is there anywhere I can read more about when nim copies stuff? Imagine I have a table of `[a, var b]` why does `table.mgetOrPut(a).add` mutable B but `var nowACopy = table.mgetOrPut(a)` make a copy |
19:58:22 | FromDiscord | <konsumlamm> what's a table of `[a, var b]` supposed to be? |
19:58:49 | FromDiscord | <zidsal> lets go with `[string, var seq[string]` |
20:00:15 | FromDiscord | <konsumlamm> the `var` wouldn't be part of the type of the value |
20:00:43 | FromDiscord | <konsumlamm> you'd have a `var Table[string, seq[string]]` |
20:01:03 | FromDiscord | <konsumlamm> In reply to @zidsal "in the `mgetOrPut` runnableExamples": the last part is correct |
20:01:53 | FromDiscord | <konsumlamm> in the first case, you directly pass the `var V` to a new function (`add`) |
20:02:06 | FromDiscord | <mratsim> In reply to @zidsal "in the `mgetOrPut` runnableExamples": copies can happens on assignment to temporaries. |
20:02:12 | FromDiscord | <mratsim> (edit) "happens" => "happen" |
20:02:25 | FromDiscord | <zidsal> and I am presuming add takes a var argument? |
20:02:28 | FromDiscord | <konsumlamm> but assigning ir to a new variable creates a copy (since `Table` is a value type) |
20:02:38 | FromDiscord | <konsumlamm> In reply to @zidsal "and I am presuming": exactly |
20:03:19 | FromDiscord | <zidsal> but why would the table being a value type matter when we're doing a mget surley that's going to return a sequence? I'm prsuming if the seq was a ref type it wouldn't copy? |
20:03:39 | giaco | I have to deal with a string protocol. I have to split all incoming packets into tokens of fixed size. What's the nim way to avoid allocating tons of strings and also gain some nim points with elegant solution? |
20:06:36 | FromDiscord | <konsumlamm> In reply to @zidsal "but why would the": mm ye, `seq` is a value type as well though |
20:06:54 | FromDiscord | <zidsal> ya, I was saying hypothetically if it was a ref type :p |
20:07:21 | FromDiscord | <zidsal> (edit) "ya, I was saying hypothetically if it was a ref type :p ... " added "I come from a java background so all of this is newish to me" |
20:07:38 | FromDiscord | <mratsim> In reply to @giaco "I have to deal": An elegant string solution only exists in Perl. |
20:08:02 | FromDiscord | <konsumlamm> if it was a ref, a `var seq[T]` wouldn't really be useful in the first place, since then you could modify it anyway |
20:08:10 | FromDiscord | <mratsim> if you want to avoid alloc, store the string in one buffer and offsets in another. |
20:08:23 | FromDiscord | <konsumlamm> though the problem would still persist i think |
20:10:26 | giaco | mratsim I will never look back to Perl |
20:13:47 | PMunch | Prestige, now my editor gives me warnings as I type. Is this something you've done Prestige? |
20:14:35 | Prestige | PMunch: that makes sense because I'm checking for diagnostics when a file is modified - we should fix that |
20:14:49 | PMunch | I mean I kinda like it, but it probably means that nimsuggest runs pretty much constantly.. |
20:15:16 | Prestige | There are a couple options. The first that comes to my mind is to only perform the checks after a file has not been modified for X amount of time... |
20:15:20 | Prestige | Yeah |
20:17:38 | PMunch | That sounds like what many editors do with "wait until the user is done typing" |
20:17:44 | PMunch | But even that might be too heavy for Nim |
20:17:51 | Prestige | hmm maybe so |
20:17:54 | PMunch | With lots of macros and such nimsuggest can seriously chug.. |
20:18:36 | PMunch | I've had Vim hang for a couple seconds every time I save because NimLSP is gathering data |
20:18:59 | FromDiscord | <queersorceress> sent a long message, see http://ix.io/2SbG |
20:19:03 | Prestige | Hm can we make it tuneable? |
20:20:20 | Prestige | PMunch: this block of code is responsible https://github.com/PMunch/nimlsp/blob/master/src/nimlsp.nim#L506 if you wanted to test changes |
20:20:31 | Prestige | we still need to call `mod` above, though |
20:21:11 | FromDiscord | <mratsim> In reply to @queersorceress "<@!570268431522201601> if you are": sent a long message, see http://ix.io/2SbH |
20:23:26 | PMunch | I mean if you just change that to didSave isn't it going to fix it? |
20:23:34 | PMunch | Or move it rather |
20:23:56 | Prestige | Essentially the same code exists for didSave, so you'd just need to remove the block that I linked |
20:24:19 | PMunch | Oh |
20:24:29 | PMunch | Wait why did you add that then? Did you intend to add this feature? |
20:25:02 | Prestige | I did, but didn't think about the possible performance issues |
20:25:13 | Prestige | works on my machine, and all |
20:26:26 | FromDiscord | <queersorceress> In reply to @mratsim "It's a bit different": the named thread thing doesn't really matter to me, as long as i can hand work off to a specific/designated worker that behaves a specific way, rather than saying "here is work that needs to be done" and have it be done in a place that i don't control. |
20:26:40 | FromDiscord | <VinKer> How to get the 31st bit from this binary digit ? It's 1 in this case. 01000000000111110000000000000001 |
20:27:36 | FromDiscord | <queersorceress> because then i'm right back to using locks in an environment that isn't conducive for locks, and that isn't going to be nice. |
20:27:48 | FromDiscord | <dk> !eval echo "01000000000111110000000000000001"[30] |
20:27:50 | NimBot | 0 |
20:27:57 | PMunch | -_- |
20:27:57 | FromDiscord | <dk> huh |
20:28:30 | PMunch | !eval let num = 0b01000000000111110000000000000001; echo ((num shr 31) and 1) |
20:28:32 | NimBot | 0 |
20:29:30 | FromDiscord | <queersorceress> and the channel thing only matter to me that i get a response back, not hung up on how, just so long as when the work is done i know what the end result was. channels just seem to be the intended way to do that. |
20:29:42 | FromDiscord | <VinKer> Thanks, let me try |
20:30:13 | PMunch | Well, it would be `let num = 0b01000000000111110000000000000001; echo ((num shr (31 - 1)) and 1)` for what you call the 31st bit |
20:30:43 | FromDiscord | <VinKer> Yes, shr 30 is right |
20:32:33 | PMunch | Here you can see it all working: https://play.nim-lang.org/#ix=2SbJ |
20:33:32 | FromDiscord | <VinKer> Just one more question. How do i get 16-23 bits from this binary number ? 01000000000111110000000000000001 |
20:33:53 | FromDiscord | <mratsim> In reply to @queersorceress "the named thread thing": ah, yeah my threadpool will be hand over type of things |
20:34:04 | FromDiscord | <mratsim> Nim's threadpool does have a distinguished thread thing |
20:34:18 | * | haxscramper quit (Remote host closed the connection) |
20:34:43 | * | haxscramper joined #nim |
20:34:50 | * | haxscramper quit (Remote host closed the connection) |
20:35:11 | FromDiscord | <mratsim> In reply to @VinKer "Just one more question.": you shift by n and then and by 0b11111111 |
20:35:42 | FromDiscord | <mratsim> n being 16 or 64-23 or depending if you are counting from the end or from the start |
20:35:53 | FromDiscord | <mratsim> (edit) "64-23" => "63-23" |
20:36:06 | FromDiscord | <VinKer> @mratsim Thanks, Let me try |
20:36:06 | FromDiscord | <mratsim> 63 being 64-1 assuming 64-bit integer |
20:36:23 | FromDiscord | <mratsim> and 64-1 is equivalent to mod 64 since 64 is a power of 2 |
20:36:38 | FromDiscord | <konsumlamm> In reply to @VinKer "Just one more question.": i suggeat looking at the `bitops` module, that has a lot of useful helper fubctions regarding bit manipulation |
20:36:41 | FromDiscord | <mratsim> (edit) "and" => "`and`" |
20:37:47 | FromDiscord | <Gary M> I can cast an array of uin16's to pointer but I can't cast an array of a nim defined type to pointer, anyone know why? |
20:38:12 | FromDiscord | <VinKer> @konsumlamm Oh, that's good. Let me check |
20:38:46 | PMunch | @Gary M, because uint16's are numbers, and pointers are numbers |
20:38:52 | PMunch | It is probably not doing what you think it is doing |
20:39:02 | PMunch | If you are actually doing casting and not `.addr` |
20:40:59 | FromDiscord | <Gary M> well if I try to addr the 0 index of the unit16 array is says the expression has no address |
20:41:48 | FromDiscord | <Gary M> it needs to return a pointer type |
20:46:21 | FromDiscord | <Gary M> I guess I'll try unsafeAddr in the mean time. |
20:47:03 | PMunch | What exactly are you trying to do |
20:48:42 | PMunch | If you need to return a pointer type and Nim says the expression doesn't have an address it probably means it is stored on the stack and that pointer would point to somewhere in a stack frame that you just popped |
20:48:54 | PMunch | Which will lead to all sorts of funny issues |
20:50:19 | FromDiscord | <Gary M> I'm passing an array of indices to a C library |
20:56:37 | FromDiscord | <William_CTO> sent a code paste, see https://play.nim-lang.org/#ix=2SbR |
20:56:51 | FromDiscord | <Gary M> oh hey that looks like mine and @ElegantBeef 's bot |
20:58:13 | FromDiscord | <Gary M> sent a code paste, see https://play.nim-lang.org/#ix=2SbS |
20:58:53 | PMunch | Uhm @William_CTO, what question? |
20:59:12 | PMunch | @Gary M, and how are you doing that? |
20:59:43 | FromDiscord | <Gary M> the array stuff? |
21:00:07 | FromDiscord | <Gary M> `mIbh[4] = bgfx_create_index_buffer(bgfx_make_ref(sCubePoints[0].unsafeAddr, sizeOf(sCubePoints).uint32))` |
21:00:38 | FromDiscord | <Gary M> however I've opened another can of worms already in that I'm not sure how I'm supposed to load the shader programs 😄 |
21:01:07 | FromDiscord | <William_CTO> Yep, ElegantBeef gave me permissions to use his macro for my own code. I plan to release the code back to y'all as well |
21:01:10 | FromDiscord | <Solitude> PMunch, bridge lost part of the message |
21:01:26 | PMunch | @Gary M, and how is sCubePoints defined? |
21:01:44 | PMunch | @Solitude, ah that explains it :P |
21:01:56 | FromDiscord | <Gary M> sent a code paste, see https://play.nim-lang.org/#ix=2SbX |
21:02:13 | FromDiscord | <William_CTO> Since Beef and Gary may understand better, I am trying to add a way to call a proc before the command is ran to check to see if it can be ran by another user. Am I on the right track or wayy off? |
21:02:19 | FromDiscord | <Gary M> @William_CTO no worries. He can probably help you with that stuff. I didn't write the macro part. |
21:02:44 | FromDiscord | <Gary M> I'm still very macro-shy haha |
21:03:06 | FromDiscord | <Gary M> oh you're trying to filter out commands by role or user id? |
21:03:07 | FromDiscord | <William_CTO> 👍 |
21:03:41 | FromDiscord | <William_CTO> Things like that. Could also be used to implement a different cooldown system, or limit commands to devs only, etc |
21:04:27 | FromDiscord | <Gary M> okay so basically the way I would do that is in the nimcordBot.nim main file on the messageCreate event |
21:04:44 | FromDiscord | <Gary M> the way I filter it already for m.author.bot |
21:04:47 | FromDiscord | <William_CTO> For my bot I need different checks for different users |
21:04:51 | FromDiscord | <William_CTO> (edit) "users" => "commands" |
21:05:00 | FromDiscord | <William_CTO> (edit) "commands" => "commands." |
21:05:11 | FromDiscord | <Gary M> right right |
21:05:33 | FromDiscord | <Gary M> probably just needs a simple modification to mark the commands with an enum or something like that |
21:05:51 | FromDiscord | <Gary M> then you can implement your custom logic outside of the commands |
21:06:49 | FromDiscord | <Gary M> but there's a thousand ways to skin a cat and my way might not be the best 🤷 |
21:23:39 | ForumUpdaterBot | New Nimble package! questionable - Elegant optional types, see https://github.com/markspanbroek/questionable |
21:26:21 | PMunch | Hmm, seems kinda similar to optionsutils |
21:27:30 | * | rwiser[m] joined #nim |
21:30:06 | FromDiscord | <ElegantBeef> @William_CTO i'd say make a new permissions slot which takes a `set[int]` of `allowed` and has an int of `cooldown`, |
21:31:13 | FromDiscord | <ElegantBeef> That way you can just do it on the command and it injects a check if the user is allowed and last time it did it |
21:32:08 | * | PMunch quit (Quit: leaving) |
21:36:24 | * | narimiran quit (Ping timeout: 246 seconds) |
21:38:14 | * | lritter joined #nim |
21:56:35 | * | ex_nihilo joined #nim |
21:58:39 | * | dddddd quit (Ping timeout: 256 seconds) |
22:00:18 | * | dddddd joined #nim |
22:09:49 | FromDiscord | <dom96> ahh, optimising binary data structures is fun |
22:13:00 | FromDiscord | <Araq> IC works for "hello world"! |
22:14:50 | FromGitter | <ynfle> 👏 |
22:16:39 | FromDiscord | <Clyybber> for the second recompile now too? |
22:16:44 | FromDiscord | <Araq> yes |
22:16:51 | FromDiscord | <Clyybber> awesome! |
22:17:54 | FromDiscord | <Araq> yeah, I'm so excited that I had to join here |
22:18:28 | FromDiscord | <Araq> so far no bugfix had to add hacks |
22:18:44 | FromDiscord | <Araq> never seen it to work out like this before |
22:18:56 | FromDiscord | <Araq> maybe I'm getting better at compiler dev 😛 |
22:19:04 | FromDiscord | <Clyybber> :D |
22:19:38 | FromDiscord | <Clyybber> while you are here; is there a reason we do the .Sup chaining instead of casting? |
22:19:48 | FromDiscord | <Clyybber> In ccgexprs.downConv |
22:20:15 | FromDiscord | <Araq> Ansi C's aliasing rules suggest .Sup is the best way to do it |
22:20:56 | FromDiscord | <Clyybber> I see, thanks! |
22:21:06 | FromDiscord | <Clyybber> And good night |
22:21:21 | FromDiscord | <Araq> good night |
22:25:17 | FromDiscord | <Gary M> does nim have a ternary conditional operator? |
22:25:20 | FromDiscord | <Gary M> x ? y : z |
22:25:53 | FromDiscord | <ElegantBeef> If expressions |
22:26:04 | FromDiscord | <Araq> `(if x: y else: z)` |
22:26:13 | FromDiscord | <Gary M> good enough lol |
22:26:19 | FromDiscord | <Gary M> hi Araq |
22:27:07 | FromDiscord | <ElegantBeef> Though someone did show off using `? :` by using that whole `:` allows you to pass the last arg |
22:28:41 | FromDiscord | <ElegantBeef> This abuse of `:` https://play.nim-lang.org/#ix=2Scp |
22:30:44 | FromDiscord | <Araq> https://play.nim-lang.org/#ix=2Scq a template reflects its lazy nature better |
22:31:26 | FromDiscord | <Gary M> is it something you dislike? |
22:33:31 | FromDiscord | <Araq> I would never use it, `if` is available as an expression |
22:36:06 | FromDiscord | <dom96> sent a code paste, see https://play.nim-lang.org/#ix=2Sct |
22:38:58 | FromDiscord | <j-james> Why does the `split` iterator not return an optional enumerator? |
22:39:20 | FromDiscord | <Araq> what is an optional enumerator? |
22:40:05 | FromDiscord | <ElegantBeef> The better question would be why does it need to return an optional enumerator 😛 |
22:40:21 | FromDiscord | <j-james> Like `for thisThing, foo in "string"` |
22:41:30 | FromDiscord | <j-james> Because my sole use of `std/enumerate` is with `split` 🤷 |
22:43:30 | FromDiscord | <Araq> you should probably learn about scanf |
22:43:55 | FromDiscord | <Araq> or use a csv parser, 90% of all usages of split are wrong |
22:45:56 | FromDiscord | <j-james> Probably should |
22:52:26 | * | tane quit (Quit: Leaving) |
22:52:46 | FromDiscord | <ElegantBeef> Hey it just so happens 90% of the uses of split are for copying the string into memory a second time for parsing! |
22:53:43 | FromDiscord | <Araq> first, let's read the full file into memory, even if it's 20 GB. |
22:53:51 | FromDiscord | <Araq> then let us call `lines` on it |
22:54:00 | FromDiscord | <Araq> then for every line we split at `;` |
22:54:17 | FromDiscord | <Araq> and then we strip the indivual cell |
22:54:26 | FromDiscord | <ElegantBeef> advent of code participants are nervously glancing around the room |
22:54:55 | FromDiscord | <Araq> and then we hope the file doesn't contain a single `\` |
22:55:58 | FromDiscord | <Araq> you should resist the temptation to read about parsing. Or anything. The first stack overflow reply surely is good enough for your use case |
22:56:08 | FromDiscord | <Araq> (edit) "you should resist the temptation to read ... about" added "a book" |
22:57:05 | FromDiscord | <Araq> in fact, I wonder if our `split` says "use scanf instead" |
22:57:48 | FromDiscord | <Araq> yeah, no "see also" entry for that... 😕 |
22:57:50 | FromDiscord | <ElegantBeef> Well on the plus side borrowed memory stands to be an easy way to remove atleast some of the pitfalls from running split on a large string |
22:58:19 | FromDiscord | <Araq> hardly. |
23:01:07 | FromDiscord | <Araq> I want COW strings instead, not borrowing |
23:01:35 | FromDiscord | <Araq> but for now, good night |
23:01:40 | FromDiscord | <ElegantBeef> Buh bye |
23:01:49 | FromDiscord | <Araq> "Buh"? |
23:01:57 | FromDiscord | <ElegantBeef> That's what it actually is |
23:02:19 | FromDiscord | <Araq> COW is buh? |
23:02:33 | FromDiscord | <ElegantBeef> No buh bye is saying good bye |
23:02:44 | FromDiscord | <Araq> ah til |
23:02:55 | FromDiscord | <ElegantBeef> some people write bye bye, but it's buh bye |
23:02:56 | FromDiscord | <Recruit_main707> xD |
23:03:19 | FromDiscord | <Araq> bye bye bytes |
23:25:19 | giaco | suddenly, I'm not sure how should I edit an existing string without reallocation |
23:25:50 | FromGitter | <ynfle> Strings are mutable |
23:26:51 | FromDiscord | <ElegantBeef> You just edit the string, if it goes over the current string capacity it'll realloc |
23:27:17 | giaco | sure, but to reuse it from scratch, is it just mystr.setLen(0) mystr.add("foo")? |
23:29:11 | FromDiscord | <ElegantBeef> setLen shouldnt change the capcaity so that should be fine |
23:30:37 | * | Vladar quit (Quit: Leaving) |
23:32:23 | * | NimBot joined #nim |
23:46:23 | FromDiscord | <reilly> In reply to @Gary M "good enough lol": If you want something more symbol-y then there's https://github.com/mattaylor/elvis |