00:07:25 | * | ltriant quit (Ping timeout: 250 seconds) |
00:16:41 | * | rockcavera quit (Read error: Connection reset by peer) |
00:17:00 | * | rockcavera joined #nim |
00:17:00 | * | rockcavera quit (Changing host) |
00:17:00 | * | rockcavera joined #nim |
00:23:55 | * | pharonix71 quit (Changing host) |
00:23:55 | * | pharonix71 joined #nim |
00:26:24 | FromDiscord | <gogolxdong> sent a code paste, see https://play.nim-lang.org/#ix=4twV |
00:26:39 | FromDiscord | <gogolxdong> devel latest |
00:32:52 | * | lucasta joined #nim |
00:34:36 | * | ltriant joined #nim |
00:37:36 | FromDiscord | <gogolxdong> sent a code paste, see https://play.nim-lang.org/#ix=4twW |
00:39:39 | * | ltriant quit (Ping timeout: 255 seconds) |
00:41:43 | FromDiscord | <Elegantbeef> They're different version so look into the source to see the cause |
00:43:51 | FromDiscord | <gogolxdong> I've checked stable and finds the cause but have no idea about devel. |
00:55:23 | FromDiscord | <leorize> someone wrote a thing to hook it up with null-ls, which makes it work with nvim lsp\: https://github.com/alaviss/nim.nvim/issues/49↵(@&_dükk ™) |
00:55:54 | FromDiscord | <gogolxdong> How to define int160 and int24 |
00:55:58 | FromDiscord | <leorize> eventually the plugin will be rewritten in lua and bundle with this stuff, but for now this is the best I can offer |
01:22:32 | * | derpydoo joined #nim |
03:29:37 | * | ltriant joined #nim |
03:37:51 | * | ltriant quit (Ping timeout: 255 seconds) |
03:46:17 | * | arkurious quit (Quit: Leaving) |
04:47:37 | * | casaca quit (Ping timeout: 252 seconds) |
04:50:54 | * | casaca joined #nim |
05:04:05 | * | derpydoo quit (Ping timeout: 240 seconds) |
05:09:14 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4txC |
06:08:53 | * | lucasta quit (Remote host closed the connection) |
06:25:04 | FromDiscord | <cmc> sent a long message, see http://ix.io/4txM |
06:25:28 | FromDiscord | <Elegantbeef> You cannot really |
06:25:54 | FromDiscord | <cmc> I see, it's magic? |
06:25:58 | FromDiscord | <Elegantbeef> It is |
06:26:23 | FromDiscord | <Elegantbeef> Do you have a more practical example? |
06:26:40 | FromDiscord | <Elegantbeef> I mean like you obviously do not just want an open array of nothing 😄 |
06:26:55 | FromDiscord | <cmc> Don't judge me! |
06:27:01 | FromDiscord | <cmc> 😉 |
06:28:26 | FromDiscord | <cmc> It would be a custom object with a pointer and a length, so the toOpenArray would allow it to be indexed |
06:28:35 | FromDiscord | <Elegantbeef> Right |
06:29:37 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/G1U |
06:29:57 | FromDiscord | <Elegantbeef> Use overloading instead of attempting to convert |
06:30:33 | FromDiscord | <cmc> Yeah that's not that bad either, thanks. I was mostly irked I couldn't find the seq mechanism |
06:30:40 | FromDiscord | <Elegantbeef> you can even make a `template toOa(myFoo: Foo): untyped = myFoo.data.toOpenArray(0, myFoo.len)` |
06:30:52 | FromDiscord | <Elegantbeef> so anywhere you need to convert you can just do `myFoo.toOa()` |
06:31:14 | FromDiscord | <Elegantbeef> Yea it's an implicit conversion that cannot be done in user code cause `openArray[T]` cannot be returned from a proc |
06:31:27 | FromDiscord | <Elegantbeef> With views, maybe one day it'll work 😄 |
06:32:38 | FromDiscord | <cmc> Aah, views |
06:32:45 | FromDiscord | <cmc> Oh so that's why! Ok |
06:33:10 | FromDiscord | <cmc> Cool thanks |
06:40:17 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4txT |
06:40:27 | * | onetwo quit (Ping timeout: 256 seconds) |
06:40:39 | FromDiscord | <sOkam!> is the size pragma meant to achieve this? |
06:40:48 | FromDiscord | <ElegantBeef> `type MyEnum {.size: sizeof(int32).}` |
06:40:56 | FromDiscord | <sOkam!> ✍️ ty |
06:59:20 | * | onetwo joined #nim |
07:07:23 | * | henrytill quit (Ping timeout: 248 seconds) |
07:07:44 | * | casaca quit (Ping timeout: 246 seconds) |
07:08:20 | * | henrytill joined #nim |
07:09:13 | * | casaca joined #nim |
07:15:18 | FromDiscord | <sOkam!> is it possible to mark a proc so that it errors during compilation when used? |
07:20:52 | FromDiscord | <Elegantbeef> `{.error.}` |
07:22:45 | * | henrytill quit (Ping timeout: 260 seconds) |
07:23:20 | * | casaca quit (Ping timeout: 260 seconds) |
07:24:10 | * | henrytill joined #nim |
07:25:52 | * | casaca joined #nim |
07:28:43 | * | Notxor joined #nim |
07:43:59 | * | azimut quit (Ping timeout: 255 seconds) |
07:47:31 | FromDiscord | <ajusa> Is std/channels the best module to use when dealing with multiple threads, or are there alternatives? I'm trying to see if there's a way to listen to two channels at once in the same thread, but I'm not seeing any way of doing that |
07:53:18 | FromDiscord | <ajusa> Nevermind, found stashtable which seems to be what I want in the end |
07:54:27 | FromDiscord | <Void> I was doing exercism exercises and wanted to know why the same line works for echo but when I use return the compiler says indentation error: |
07:54:32 | FromDiscord | <Void> sent a code paste, see https://play.nim-lang.org/#ix=4tyb |
07:54:44 | FromDiscord | <Void> (edit) "echo" => "'echo'" | "return" => "'return'" |
08:00:55 | * | lumo_e joined #nim |
08:06:16 | FromDiscord | <cmc> Indent each return line by two spaces. |
08:09:28 | FromDiscord | <Void> the return line is indented two spaces from the if/else point, unless you mean spaces somewhere else |
08:09:43 | FromDiscord | <Yardanico> In reply to @Void "I was doing exercism": because you're using the wrong syntax for `return` |
08:09:49 | FromDiscord | <Yardanico> `echo "One for ", name, ", one for me."` calls echo with 3 arguments |
08:10:17 | * | PMunch joined #nim |
08:10:17 | FromDiscord | <Yardanico> because echo is actually a procedure that takes a variable number of arguments, while `return` is a separate statement that takes the return value if you provide it |
08:10:38 | FromDiscord | <Yardanico> so if you want to concat, use `return "One for " & name & ", one for me."` |
08:10:44 | FromDiscord | <Yardanico> or, for general formatting, there's https://nim-lang.org/docs/strformat.html |
08:11:24 | FromDiscord | <Void> Thanks, I'll go through that |
08:12:05 | * | tiorock joined #nim |
08:12:05 | * | tiorock quit (Changing host) |
08:12:05 | * | tiorock joined #nim |
08:12:05 | * | rockcavera quit (Killed (tantalum.libera.chat (Nickname regained by services))) |
08:12:05 | * | tiorock is now known as rockcavera |
08:16:44 | FromDiscord | <Yardanico> In reply to @Void "Thanks, I'll go through": basically you need to be aware of https://nim-lang.org/docs/manual.html#procedures-command-invocation-syntax |
08:17:12 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4tyf |
08:17:16 | FromDiscord | <Yardanico> both of those echo statements are 100% equivalent |
08:18:19 | FromDiscord | <Yardanico> well, they're not even echo "statements" since echo is just a proc defined in the main system module |
08:18:23 | FromDiscord | <Yardanico> it's not a keyword |
08:19:21 | FromDiscord | <Void> so the proc echo can take multiple arguments but we don't need to specifically put them in the bracket |
08:19:34 | FromDiscord | <Yardanico> In reply to @Void "so the proc echo": it is because of the feature I linked |
08:19:43 | FromDiscord | <Yardanico> Nim doesn't generally require you to use parentheses for proc calls |
08:19:48 | FromDiscord | <Yardanico> it's not specific to echo |
08:19:51 | FromDiscord | <Void> Ah |
08:20:33 | FromDiscord | <Void> I am still getting used to the proc calls but your links help. 👍 |
08:20:35 | FromDiscord | <Yardanico> sent a code paste, see https://paste.rs/ZNF |
08:20:45 | FromDiscord | <Yardanico> all 4 last lines here mean exactly the same |
08:21:30 | Amun-Ra | you only have to add parentheses on a few specific occasions, like let x = … |
08:22:56 | FromDiscord | <Void> Can you explain the let x = ... example? |
08:23:06 | Amun-Ra | let x = foo(bar, baz) |
08:23:24 | Amun-Ra | alhough in that example let x = bar.foo baz is fine |
08:24:01 | Amun-Ra | Nim has Uniform Function Call: foo(x, y, z) is the same as x.foo(y, z) |
08:24:48 | FromDiscord | <Yardanico> In reply to @Void "Can you explain the": I think Amun-Ra was referring to calling a proc without arguments |
08:25:01 | FromDiscord | <Yardanico> because `let x = twoFer` would be ambiguous otherwise - do you want to assign the proc to the variable, or the proc's result? |
08:25:22 | Amun-Ra | Yardanico: and a proc with many arguments |
08:25:29 | FromDiscord | <Yardanico> hm? |
08:25:37 | FromDiscord | <Yardanico> ah, you mean without , with multiple args, yeah |
08:25:42 | FromDiscord | <lauvrens> sent a code paste, see https://paste.rs/Mrd |
08:25:48 | Amun-Ra | I could make an example but the play.nim seems to be down |
08:26:10 | FromDiscord | <Yardanico> In reply to @lauvrens "is it bad practice": it's not bad practice, you didn't even simplify it, you just removed some newlines |
08:26:12 | FromDiscord | <Elegantbeef> Fuuuuck 😄 |
08:26:14 | FromDiscord | <Void> sent a code paste, see https://paste.rs/8RQ |
08:26:20 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/5xY |
08:26:21 | FromDiscord | <Yardanico> In reply to @Void "Nice, I managed to": also you're missing one obvious thing |
08:26:31 | FromDiscord | <Yardanico> you can just set the default `name` to `you` and have one return statement only |
08:26:46 | FromDiscord | <Yardanico> and even then, in Nim `return` is optional if the last expression in your proc is the same type |
08:26:52 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4tyi |
08:27:10 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4tyj |
08:27:23 | Amun-Ra | I write nim code in a way to reduce parenthese usage, byte.sizeof instead of sizeof(byte) or sizeof byte |
08:27:48 | FromDiscord | <Yardanico> In reply to @Amun-Ra "I write nim code": it depends on semantics, for "simple" procs I also use procs without () |
08:27:50 | FromDiscord | <Yardanico> like len |
08:27:55 | FromDiscord | <Elegantbeef> subtle difference with yard's and mine is his causes a string interpolation every call, though it's minor |
08:28:29 | FromDiscord | <Void> Ok since we are on topic, can you explain what the (name = "you") does in this case please. |
08:28:44 | FromDiscord | <lauvrens> default value |
08:28:54 | FromDiscord | <lauvrens> or whatever its called |
08:29:06 | FromDiscord | <Void> Don't we have to set type for parameter or does it infer automatically? |
08:29:28 | FromDiscord | <lauvrens> i guess its inferred from the "you" |
08:29:45 | FromDiscord | <Yardanico> In reply to @Void "Don't we have to": you original code already had that |
08:29:59 | FromDiscord | <Yardanico> `name = ""` means that name is a string argument with the default value of an empty string |
08:30:08 | FromDiscord | <Yardanico> if you provide a default value, the type is optional |
08:30:19 | FromDiscord | <Void> Yea I was confused about that too, but thanks the explanations make sense now |
08:30:40 | FromDiscord | <Elegantbeef> \:d |
08:30:43 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4tyk |
08:31:58 | FromDiscord | <lauvrens> beautiful |
08:33:00 | FromDiscord | <Yardanico> yeah, the power of overloading |
08:33:18 | FromDiscord | <sOkam!> over ❤️ ing |
08:33:21 | FromDiscord | <Void> sent a code paste, see https://play.nim-lang.org/#ix=4tyl |
08:33:46 | FromDiscord | <Yardanico> In reply to @Void "So this example defines": it's not the same proc since one has no arguments, the other has 1 argument |
08:33:49 | FromDiscord | <Yardanico> it's called overloading |
08:33:51 | FromDiscord | <sOkam!> In reply to @Void "So this example defines": exactly. and the compiler knows what to pick |
08:34:45 | FromDiscord | <lauvrens> it will pick by the argument passed, so if you defined two procs with the same parameters the compiler will be like wtf |
08:35:02 | FromDiscord | <Yardanico> In reply to @lauvrens "it will pick by": it depends |
08:35:28 | FromDiscord | <Yardanico> look at this magic: |
08:35:52 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4tyo |
08:36:13 | FromDiscord | <Yardanico> ofc it's a proc call, I just omitted (), basically the overload resolution takes argument names into account as well |
08:36:33 | FromDiscord | <Yardanico> so if they're clearly different the compiler allows you to call different procs, even if their basic signature is the same (excluding argument names) |
08:36:49 | FromDiscord | <lauvrens> huh i did not know that thats cool |
08:36:52 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4typ |
08:38:00 | FromDiscord | <Yardanico> sent a code paste, see https://paste.rs/onK |
08:38:04 | FromDiscord | <Yardanico> but I don't know C++, I might be wrong |
08:38:08 | FromDiscord | <Yardanico> but reinterpret_cast should be Nim's cast, yeah |
08:38:16 | FromDiscord | <sOkam!> ✍️ |
08:39:09 | FromDiscord | <Void> Yea I am definitely writing down ✍️ these extreme optimization tricks too. |
08:39:20 | FromDiscord | <lauvrens> ✍️ same |
08:39:30 | FromDiscord | <Yardanico> In reply to @Void "Yea I am definitely": they're not optimization tricks, casting is a different thing :) |
08:39:40 | FromDiscord | <Yardanico> and the proc overloading is just for writing stuff in a nicer way |
08:39:59 | NimEventer | New thread by alexeypetrushin: Mono UI, high productivity, simple and clean code, see https://forum.nim-lang.org/t/10102 |
08:42:17 | FromDiscord | <Void> In reply to @Yardanico "and the proc overloading": at least I am learning how to write stuff better. less lines means cleaner code to my sub-amateur eyes |
08:43:02 | PMunch | Playground should be back up now Amun-Ra |
08:43:24 | Amun-Ra | PMunch: yes, it works, thank you |
08:44:44 | FromDiscord | <cmc> Is there a uniform way to get pointer and length from any type that supportsCopyMem? |
08:45:40 | PMunch | Ooh, that would be useful |
08:46:58 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4tyr |
08:47:30 | FromDiscord | <Elegantbeef> `import std/typetraits` |
08:54:19 | * | derpydoo joined #nim |
08:54:53 | Amun-Ra | that'll exclude some types (mainly from C world) that support copyMem (cstring, etc.) |
08:55:58 | Amun-Ra | that's nice approach imo |
08:56:47 | FromDiscord | <Elegantbeef> Well cstring doesnt really support copymem |
08:56:48 | FromDiscord | <Elegantbeef> If you use a copymem on a cstring you leak memory |
08:57:25 | FromDiscord | <Elegantbeef> It's not about whether you can copymem over the data, it's about whether you can copymem on the data |
08:57:35 | Amun-Ra | perhaps cstring wasn't the best example |
08:58:10 | FromDiscord | <Elegantbeef> `supportsCopyMem` is more like "has no pointers" |
08:58:16 | Amun-Ra | I see |
08:59:14 | FromDiscord | <planetis> nope, it's actually "has no destructors attached". You can have pointers and supportsCopyMem returns true |
08:59:24 | FromDiscord | <Elegantbeef> Lol |
08:59:27 | FromDiscord | <Elegantbeef> That seems like a bug |
09:00:59 | FromDiscord | <Elegantbeef> Well we'll go with "has no managed pointers" |
09:01:26 | FromDiscord | <Elegantbeef> Really need a `hasNoPointers` or `hasPointers` |
09:02:14 | FromDiscord | <planetis> sent a code paste, see https://play.nim-lang.org/#ix=4tyt |
09:02:39 | FromDiscord | <planetis> If it's a bug I am happy to report it |
09:02:58 | FromDiscord | <Elegantbeef> I do not know really |
09:05:50 | Amun-Ra | https://play.nim-lang.org/#ix=4tyu |
09:06:25 | FromDiscord | <Elegantbeef> It thinks differently to how i think |
09:06:34 | FromDiscord | <Elegantbeef> I think a type only supports copymem if it has no pointers |
09:07:13 | FromDiscord | <Elegantbeef> `ptr T` shouldnt support copy mem but `openArray[T]` should |
09:07:49 | FromDiscord | <Elegantbeef> It's a slice of memory, we safely know the length of the data and know we can copy/from it predictible |
09:08:31 | FromDiscord | <Elegantbeef> `ptr T` doesnt support copy mem in my opinion cause if you copymem to it corrupts the pointer leaking memory |
09:08:45 | FromDiscord | <Elegantbeef> Only fully pointless types i'd argue support copymem |
09:10:43 | FromDiscord | <Elegantbeef> But yea the definition fits with planetis' comment |
09:10:48 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/XQR |
09:11:50 | FromDiscord | <Elegantbeef> And with that rambling i'm outta here |
09:13:41 | Amun-Ra | copyMem works on pointers too, https://play.nim-lang.org/#ix=4tyv |
09:14:20 | Amun-Ra | this example is as close to C as it can get ;> |
09:22:25 | * | fredrik92 joined #nim |
09:22:43 | Amun-Ra | with dealloc there's not memory leakage |
09:23:07 | * | fredrikhr quit (Killed (NickServ (GHOST command used by [email protected]))) |
09:23:11 | FromDiscord | <cmc> Neat! |
09:23:14 | * | fredrik92 is now known as fredrikhr |
09:23:33 | * | fredrikhr92 joined #nim |
09:23:49 | Amun-Ra | cmc: this is just a demo, I wouldn't write that way, ever |
09:25:30 | NimEventer | New post on r/nim by h234sd: Mono, Web UI for Nim, high productivity, simple and clean code, see https://reddit.com/r/nim/comments/12o2ju0/mono_web_ui_for_nim_high_productivity_simple_and/ |
09:28:19 | * | rockcavera quit (Remote host closed the connection) |
09:35:40 | FromDiscord | <Phil> I always have such a hard time justifying a webUI framework to myself when the JS bases that already exist have a pretty solid featureset |
09:35:49 | FromDiscord | <Phil> (edit) "bases" => "based ones" |
09:35:50 | FromDiscord | <cmc> Too late! This is now attached to your name! 😉Brutal, yet effective. Good to know sometimes you need this sort of thing↵(<@709044657232936960_=41mun-=52a=5b=49=52=43=5d>) |
09:39:02 | FromDiscord | <cmc> I suppose ptr types would need to be excluded, or you could argue whoever uses them deserves whatever undefined behavior they get |
10:17:39 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4tyI |
10:20:01 | FromDiscord | <sOkam!> is this a usecase for `UncheckedArray[uint8]` ? |
10:30:10 | * | ltriant joined #nim |
10:34:27 | * | lumo_e quit (Ping timeout: 250 seconds) |
10:34:45 | * | ltriant quit (Ping timeout: 240 seconds) |
10:59:31 | * | derpydoo quit (Ping timeout: 240 seconds) |
11:03:07 | NimEventer | New question by Alexandre Daubricourt: How to create strings inside of a Nim formatted string, see https://stackoverflow.com/questions/76027330/how-to-create-strings-inside-of-a-nim-formatted-string |
11:20:35 | * | ltriant joined #nim |
11:27:31 | * | ltriant quit (Ping timeout: 240 seconds) |
11:42:59 | FromDiscord | <cmc> Does an object need to be {.packed.} for a safe copyMem or is it just a performance thing? |
11:49:39 | PMunch | Just a performance thing |
11:49:56 | PMunch | In particular memory size performance, speed performance will actually go down |
11:50:35 | * | pharonix71 quit (Ping timeout: 255 seconds) |
11:53:37 | * | pharonix71 joined #nim |
11:58:44 | FromDiscord | <cmc> Cool thanks |
12:00:20 | * | ltriant joined #nim |
12:06:19 | * | ltriant quit (Ping timeout: 250 seconds) |
12:26:39 | * | ltriant joined #nim |
12:28:14 | FromDiscord | <sOkam!> how do you convert a `pointer` to an `seq[uint8]` or `array[uint8]`? |
12:28:32 | FromDiscord | <sOkam!> (edit) "an" => "a" |
12:30:03 | FromDiscord | <Andreas> In reply to @sOkam! "how do you convert": `cast[UncheckedArray[uint8]](your_seq[0].addr)` |
12:30:31 | FromDiscord | <sOkam!> In reply to @Andreas "`cast[UncheckedArray[uint8]](your_seq[0].addr)`": i dont have a seq. i have a `void` from C, so `pointer` |
12:31:05 | * | ltriant quit (Ping timeout: 240 seconds) |
12:31:39 | FromDiscord | <Andreas> In reply to @sOkam! "i dont have a": AFAIK, one cannot cast a `nim Seq` directly, you need to cast to UncheckedArray, then loop and maybe fill a `seq`. |
12:31:59 | FromDiscord | <sOkam!> no biggie. but... how do you convert it to something usable? |
12:32:10 | FromDiscord | <sOkam!> my issue is from pointer-to-nim |
12:32:28 | FromDiscord | <sOkam!> (edit) "pointer-to-nim" => "pointer-to-nimAnything" |
12:32:39 | FromDiscord | <Andreas> In reply to @sOkam! "no biggie. but... how": cast[UncheckedArray[uint8]](your_pointer) |
12:32:57 | FromDiscord | <sOkam!> that was giving me error last time i tried |
12:33:07 | FromDiscord | <sOkam!> its the first thing i tried before asking |
12:33:38 | FromDiscord | <Andreas> In reply to @sOkam! "that was giving me": maybe try again, i'm confident it will work, unless the C-side gives you a bogus ptr.. |
12:34:24 | FromDiscord | <Andreas> is it a `cstring` char[uint8] you are after ? |
12:34:46 | FromDiscord | <sOkam!> `Error: expression cannot be cast to UncheckedArray[uint8]` |
12:35:25 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4tz3 |
12:36:11 | FromDiscord | <sOkam!> In reply to @Andreas "is it a `cstring`": its a byte buffer, that contains unit8 because i sent it to C in that way, and this is coming back from an async callback |
12:36:24 | FromDiscord | <sOkam!> in this case it fits uint8, but other times might not |
12:36:28 | FromDiscord | <Andreas> sent a code paste, see https://play.nim-lang.org/#ix=4tz4 |
12:36:37 | FromDiscord | <sOkam!> In reply to @Andreas "so you get a": yep |
12:37:17 | FromDiscord | <Andreas> sry, my bad `cast[ptr UncheckedArray[uint8]]`, trz this pls.. |
12:37:26 | FromDiscord | <Andreas> (edit) "trz" => "try" |
12:38:07 | FromDiscord | <sOkam!> that compiled so far, yeah. its the solution i had so far, but since the app is not working i was still wondering if that is the right syntax for this |
12:38:48 | FromDiscord | <Andreas> In reply to @sOkam! "that compiled so far,": i guess this is the recommended way of doing things... AFAIk |
12:40:14 | FromDiscord | <Andreas> (edit) "AFAIk" => "AFAIK↵i found a proposal/solution in the forum - try search for 'CBuffer' smth.." |
12:45:08 | * | ltriant joined #nim |
12:51:45 | * | ltriant quit (Ping timeout: 240 seconds) |
12:58:46 | * | fredrik92 joined #nim |
13:02:31 | * | fredrikhr quit (Ping timeout: 240 seconds) |
13:03:25 | * | couven92 joined #nim |
13:06:47 | * | fredrik92 quit (Ping timeout: 260 seconds) |
13:19:24 | Amun-Ra | cmc: packed object nowadays almost always is going to be slower |
13:20:19 | Amun-Ra | cmc: you do the copy once, you access object members multiple times, extra cycles for misaligned reads will accumulate |
13:34:37 | FromDiscord | <cmc> Amun-Ra\_[IRC]#0000\: neat username btw!↵↵Ok so same tradeoff as on-the-fly compression just less pronounced |
13:39:21 | Amun-Ra | cmc: thanks! |
13:41:05 | * | jmdaemon quit (Ping timeout: 246 seconds) |
13:45:42 | * | ltriant joined #nim |
13:45:44 | Amun-Ra | you should use {.packed.} only in a few cases: to keep your object compliant with some ABI that uses __attribute__((packed)); not do depend on implementation defined struct paddings (if your code writes binary files that need to be read on several different systems) |
13:50:25 | * | ltriant quit (Ping timeout: 240 seconds) |
13:53:44 | * | junaid_ joined #nim |
13:56:46 | * | junaid_ quit (Remote host closed the connection) |
14:32:44 | FromDiscord | <stisa> anyone knows what's the status of hot code reloading with nim v2? Is it working with arc? |
14:37:48 | FromDiscord | <kodkuce> when Nim compiles to C can we force it to use /fp:strict like https://learn.microsoft.com/en-us/cpp/build/reference/fp-specify-floating-point-behavior?view=msvc-170 |
14:42:09 | FromDiscord | <Anuke> Anyone know why the Nim output on godbolt always has an endbr64 at the start of each function, while other languages don't? https://media.discordapp.net/attachments/371759389889003532/1097170068984569967/image.png |
14:54:47 | * | lucasta joined #nim |
15:06:25 | NimEventer | New post on r/nim by TooDeep94: Nim Language Server does often crash in VSCode, see https://reddit.com/r/nim/comments/12oc9mc/nim_language_server_does_often_crash_in_vscode/ |
15:07:11 | Amun-Ra | Anuke: looks like CF protection is on |
15:07:34 | Amun-Ra | if you add --passc=-fcf-protection=none it'll dissapear |
15:07:52 | Amun-Ra | https://nim.godbolt.org/z/63oqbvvMh |
15:08:39 | NimEventer | New question by Alexandre Daubricourt: Nim import from project root directory, see https://stackoverflow.com/questions/76028551/nim-import-from-project-root-directory |
15:08:47 | Amun-Ra | the code is compiled with -fcf-protection=branch by default on godbolt |
15:12:44 | * | azimut joined #nim |
15:13:20 | FromDiscord | <Anuke> In reply to @Amun-Ra "<@123539225919488000>: looks like CF": ah, thanks |
15:16:27 | FromDiscord | <guttural666> can somebody tell me what is wrong here, I thought {.async.} gives me an implicit return value of type Future[void]? https://media.discordapp.net/attachments/371759389889003532/1097178698505011321/image.png |
15:17:00 | FromDiscord | <guttural666> (edit) "can somebody tell me what is wrong here, I thought {.async.} gives me an implicit return value of type Future[void]? ... https://media.discordapp.net/attachments/371759389889003532/1097178698505011321/image.png" added "says that async_api does not have a return type" |
15:17:13 | * | fredrikhr joined #nim |
15:18:30 | NimEventer | New post on r/nim by Akronae: Nim import from project root directory, see https://reddit.com/r/nim/comments/12ocum1/nim_import_from_project_root_directory/ |
15:20:15 | * | couven92 quit (Ping timeout: 260 seconds) |
15:26:31 | NimEventer | New thread by noah: How to make os (e.g. ubuntu) interpret nimscript shebang , see https://forum.nim-lang.org/t/10104 |
15:26:39 | FromDiscord | <Yardanico> In reply to @guttural666 "can somebody tell me": your code seems to be wrong for a few other reasons as we ll, can you actually show the compiler error? |
15:26:52 | FromDiscord | <Yardanico> at least I can see one problem - `var seq` won't work for async procs, you have to use references instead |
15:27:02 | FromDiscord | <guttural666> sent a long message, see http://ix.io/4tA4 |
15:27:03 | FromDiscord | <Yardanico> also [V: Object] - I don't think generic async procs will work |
15:27:06 | FromDiscord | <Yardanico> yeah, probably because of generics |
15:27:34 | FromDiscord | <Yardanico> are you sure you actually want to make this proc async? Nim async is meant for IO, it doesn't spawn a new thread |
15:28:31 | FromDiscord | <guttural666> In reply to @Yardanico "are you sure you": yeah my terminology is wrong here, I want to spawn a bunch of API requests and the round trip to the server and back takes 2 seconds |
15:29:08 | FromDiscord | <Yardanico> yeah that should work if you're just doing http(s) requests, but yeah, no generics and no `var` captures |
15:30:01 | FromDiscord | <guttural666> hmmm |
15:30:17 | FromDiscord | <guttural666> (edit) "hmmm" => "hmmm, yeah doing https requests" |
15:31:49 | FromDiscord | <sOkam!> what matrix client do you guys recommend? |
15:32:09 | FromDiscord | <sOkam!> trying cinny, but no resize.... 😔 |
15:33:15 | FromDiscord | <Ayy Lmao> Is there a way to get `echo` to do printouts in the debug console when debugging a dll hosted inside another program? |
15:39:08 | Amun-Ra | Ayy Lmao: debugprint |
15:39:14 | Amun-Ra | debugecho I mean |
15:39:27 | Amun-Ra | ah, I misread it |
15:40:26 | FromDiscord | <Ayy Lmao> debugEcho doesn't seem to print anything out either. |
15:40:56 | FromDiscord | <Yardanico> @Amun-Ra debugEcho is only regarding Nim `func`, it doesn't relate to DLL stuff |
15:41:10 | FromDiscord | <Yardanico> In reply to @Ayy Lmao "Is there a way": what do you mean by the "debug console"? |
15:42:13 | FromDiscord | <Ayy Lmao> In reply to @Yardanico "what do you mean": So I'm trying to do an audio plugin hosted in a DAW. I have it set up in VSCode where it builds the dll and then launches the DAW. In VSCode there is a debug console where I can see info when there are seg faults. |
15:42:39 | FromDiscord | <Ayy Lmao> I don't seem to get any stack traces or anything though. |
15:44:19 | FromDiscord | <Ayy Lmao> I'm using LLDB to attach to the DAW. |
15:45:02 | FromDiscord | <Yardanico> i think this "debug console" has nothing to do with Nim, it's an LLDB thing probably as you said |
15:45:31 | FromDiscord | <Yardanico> you can make Nim output stack traces and exceptions as windows popup messages instead of the console, so maybe you can somehow reuse that? |
15:45:38 | FromDiscord | <Yardanico> nim does that with --app:gui |
15:46:12 | FromDiscord | <Yardanico> or maybe you can just have a try/except on the top of your code and log all exceptions yourself to a new console window spawned by your DLL, or to a file, or to the DAW's log, you get the idea |
15:47:40 | FromDiscord | <Ayy Lmao> I'm not sure --app:gui is an option with this. Doing some sort of roundabout thing was going to be the next thing I tried but I just wanted to be sure there wasn't a way to somehow pipe the output to LLDB. |
15:48:28 | FromDiscord | <Ayy Lmao> I'll have to see if try/except works. I need to be able to log errors before it crashes the program. |
15:48:32 | FromDiscord | <Yardanico> In reply to @Ayy Lmao "I'm not sure --app:gui": I don't think it'd be any easier than what you're doing already |
15:48:45 | FromDiscord | <Yardanico> In reply to @Ayy Lmao "I'll have to see": well yes, full try/except would do exactly that, unless you'll be getting segfaults that couldn't be caught |
15:49:26 | FromDiscord | <kodkuce> do i like this pass c compiler parasm , nim c --passC=fp:strict -d:release fu.nim |
15:49:46 | NimEventer | New post on r/nim by Sentmoraap: wasMoved and =destroy does not cancel each other out, see https://reddit.com/r/nim/comments/12oeb48/wasmoved_and_destroy_does_not_cancel_each_other/ |
15:49:53 | FromDiscord | <Yardanico> In reply to @kodkuce "do i like this": except the parameter seems to with / https://learn.microsoft.com/en-us/cpp/build/reference/fp-specify-floating-point-behavior?view=msvc-170 |
15:50:03 | FromDiscord | <Yardanico> and since Nim uses a vccexe wrapper it might convert those options already, but yeah, it should just work |
15:50:15 | FromDiscord | <Yardanico> although changing those options might break Nim code |
15:51:04 | FromDiscord | <kodkuce> w8 what |
15:51:07 | FromDiscord | <Yardanico> ? |
15:51:25 | FromDiscord | <Yardanico> I mean not this option exactly, but it seems to modify the behaviour of float operations |
15:51:33 | FromDiscord | <kodkuce> if i use fp:strict i can brake Nim? |
15:51:46 | FromDiscord | <Yardanico> probably it won't do anything, I'm just speaking generally |
15:54:00 | FromDiscord | <kodkuce> you mean i have to pass fp:strict with / infront |
15:54:11 | FromDiscord | <kodkuce> but then it complains about linker stuff |
15:54:22 | FromDiscord | <kodkuce> like it parseses wrongly the command |
15:54:33 | FromDiscord | <guttural666> In reply to @Yardanico "yeah that should work": this is compiling now with var and generics, would have surprised me if this wasn't possible |
15:54:48 | FromDiscord | <Yardanico> In reply to @guttural666 "this is compiling now": can you show the code? :) |
15:56:11 | FromDiscord | <Yardanico> I mean if you're doing it without async, it will of course work, but as far as I know var captures don't work in async because they don't work in closure iterators |
15:56:33 | FromDiscord | <guttural666> In reply to @Yardanico "can you show the": bit of a mess, working on template api rn↵https://pastebin.com/y6nP08Gx |
15:56:53 | FromDiscord | <Yardanico> well, this is a template, so actually types and generics are kinda useless in it :) |
15:57:08 | FromDiscord | <Yardanico> templates are just code substitution, I was talking about using those for an async proc specifically |
15:57:35 | FromDiscord | <Yardanico> ah I see below, hm |
15:58:02 | FromDiscord | <guttural666> yeah, all the types are known at compile time when calling band or album api |
15:58:41 | FromDiscord | <Yardanico> wait, did you actually run the code yet? |
15:58:44 | FromDiscord | <Yardanico> i mean the api template |
15:58:54 | FromDiscord | <Yardanico> since your async proc is a generic, some compiler errors might not appear until you've instantiated it |
15:59:00 | FromDiscord | <guttural666> if I understood it correctly, I will have to await JSON Response in the actual async call to return control flow to the caller to spawn new async calls? |
15:59:12 | FromDiscord | <guttural666> I will in a minute 😛 |
15:59:40 | FromDiscord | <Yardanico> well, my bet is that it wouldn't work, sorry :P |
15:59:46 | FromDiscord | <Yardanico> also any reason you'd have this weird mix of async and non-async? |
16:00:01 | FromDiscord | <Yardanico> e.g. you could make template api itself a proper async proc, and just `await all(futures)` |
16:00:31 | FromDiscord | <guttural666> seems happy 😄 https://media.discordapp.net/attachments/371759389889003532/1097189788097970206/image.png |
16:01:19 | FromDiscord | <guttural666> uhm, I really just want to make the JSON parts async, that is what is taking up 99% of my runtime |
16:01:32 | FromDiscord | <guttural666> waiting for server responses |
16:05:33 | FromDiscord | <guttural666> maybe I'm just clueless and I really need threading for my use case, I guess I'll find out |
16:06:09 | FromDiscord | <Yardanico> In reply to @guttural666 "maybe I'm just clueless": if you just need to do a lot of http(s) requests at the same time and don't want to wait for each one separately, then yeah, async will help |
16:06:15 | FromDiscord | <Yardanico> just be careful with rate limiting if the API has one |
16:06:33 | FromDiscord | <guttural666> In reply to @Yardanico "just be careful with": yeah got that mental note written down 😛 |
16:08:27 | FromDiscord | <guttural666> In reply to @Yardanico "if you just need": yeah, that is what I thought, while the request is doing its round trip I can spawn more, first time I'm doing something like this, but Peter's blog post is helping https://peterme.net/asynchronous-programming-in-nim.html |
16:13:31 | * | fallback_ quit (Remote host closed the connection) |
16:16:41 | FromDiscord | <guttural666> just realized that I don't even need to partition my target sequence for my async tasks to write to, since me own program is still single threaded, so I can still safely seq.add my results contrary to multi-threading where I would use partitioning and give every thread it's own index window to write into |
16:17:14 | FromDiscord | <Yardanico> yeah, that's what I usually did in similar cases too |
16:17:37 | FromDiscord | <Yardanico> <https://github.com/Yardanico/adbscan/blob/master/src/adbscan.nim#L122> using a table instead, but same idea |
16:17:56 | FromDiscord | <Yardanico> and the actual loop in <https://github.com/Yardanico/adbscan/blob/master/src/adbscan.nim#L161> |
16:18:25 | FromDiscord | <kodkuce> nim c --passC= can i see somehow what args did gcc recive for complation |
16:18:33 | FromDiscord | <guttural666> In reply to @Yardanico "and the actual loop": this all looks very familiar 😄 nice |
16:20:47 | FromDiscord | <Yardanico> In reply to @kodkuce "nim c --passC= ": https://nim-lang.org/docs/nimc.html :)) |
16:22:17 | FromDiscord | <Nilts> sent a code paste, see https://paste.rs/WjL |
16:22:32 | FromDiscord | <kodkuce> i think in nimcache it does not show gcc got any param at least not in json file |
16:22:42 | FromDiscord | <Yardanico> In reply to @kodkuce "i think in nimcache": why do you not just read docs :( |
16:22:48 | FromDiscord | <Yardanico> the file i linked has that option |
16:23:03 | FromDiscord | <Yardanico> https://media.discordapp.net/attachments/371759389889003532/1097195459069612212/image.png |
16:24:02 | FromDiscord | <Yardanico> In reply to @not logged in "Idk why, but i": i mean, the big part of your gather proc is the condition for the while statement |
16:24:13 | FromDiscord | <Yardanico> you can instead just use `await all(futs)` at the top of the proc |
16:24:33 | FromDiscord | <Yardanico> ah actually, all does return all the original values too |
16:24:33 | FromDiscord | <Yardanico> https://nim-lang.org/docs/asyncfutures.html#all%2Cvarargs%5BFuture%5BT%5D%5D |
16:24:36 | FromDiscord | <Rika> ~~it reads best without parens~~ |
16:24:37 | * | deadmarshal_ quit (Quit: IRCNow and Forever!) |
16:24:38 | FromDiscord | <kodkuce> cuz i scroll at least 80% of it and i did not see |
16:24:39 | FromDiscord | <Yardanico> so it is quite literally the same as your gather |
16:25:20 | FromDiscord | <Yardanico> sent a code paste, see https://paste.rs/xKF |
16:25:31 | FromDiscord | <Yardanico> asyncfutures defines `all`, but `asyncfutures` is exported by `asyncdispatch` |
16:25:40 | FromDiscord | <Nilts> In reply to @Yardanico "https://nim-lang.org/docs/asyncfutures.html#all%2Cv": It already existed! just under a different name, sneaky |
16:26:03 | FromDiscord | <Yardanico> yeah it might be a bit harder to find since it's in an asyncfutures module which you don't usually import explicitly |
16:26:07 | FromDiscord | <Nilts> Well that made me kind of sad |
16:26:11 | FromDiscord | <Nilts> whatever tho |
16:26:18 | FromDiscord | <Yardanico> In reply to @not logged in "Well that made me": why :forsenDespair: |
16:26:32 | FromDiscord | <Yardanico> more stuff actually being in the stdlib = better 🤔 |
16:27:16 | FromDiscord | <Nilts> In reply to @Yardanico "why <:forsenDespair:964336722118836224>": Because i made something pointless |
16:27:22 | FromDiscord | <Rika> ah i understand that feel |
16:28:07 | FromDiscord | <Nilts> Mine is even less efficient |
16:28:12 | FromDiscord | <Nilts> Sadge |
16:28:39 | FromDiscord | <Yardanico> well, your implementation is simpler :) |
16:29:10 | FromDiscord | <kodkuce> gcc -o .... it does not mention anywhere fp:strict when i do nim c --listCmd --passC:/fp:strict -d:release fu.nim |
16:29:25 | FromDiscord | <kodkuce> (edit) "gcc -o .... it does not mention anywhere fp:strict when i do nim c --listCmd --passC:/fp:strict -d:release fu.nim" => "sent a code paste, see https://play.nim-lang.org/#ix=4tAg" |
16:29:59 | FromDiscord | <Yardanico> In reply to @kodkuce "gcc -o": try with `--forceBuild` |
16:30:23 | FromDiscord | <Yardanico> gcc -o is the last command which is used to link all object files into the executable |
16:30:37 | FromDiscord | <Yardanico> you should get a lot of lines with `CC: ` before that unless Nim already has a cache |
16:30:52 | * | hochata joined #nim |
16:31:01 | * | arkurious joined #nim |
16:31:30 | FromDiscord | <Nilts> notin is valid right |
16:32:21 | FromDiscord | <Rika> yes |
16:32:24 | FromDiscord | <Yardanico> In reply to @not logged in "notin is valid right": yes, it's a keyword |
16:32:27 | FromDiscord | <kodkuce> sent a code paste, see https://play.nim-lang.org/#ix=4tAj |
16:32:35 | FromDiscord | <Yardanico> In reply to @kodkuce "now it shows ": well yes, because that compiler option is for MSVC |
16:32:39 | FromDiscord | <Yardanico> and you're building with gcc (probably mingw) |
16:32:55 | FromDiscord | <Yardanico> search for how to do the same as this argument does with GCC or compile with MSVC instead |
16:33:24 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#ix=4tAk |
16:33:36 | FromDiscord | <Yardanico> btw @kodkuce just curious, why you'd want this argument? |
16:33:40 | FromDiscord | <ieltan> sent a code paste, see https://play.nim-lang.org/#ix=4tAl |
16:33:42 | * | fredrik92 joined #nim |
16:36:27 | FromDiscord | <kodkuce> In reply to @Yardanico "btw <@158560671301107722> just curious,": deterministic lockstep for multyplayer game, tough i am still long away from making anything nice yet |
16:36:47 | FromDiscord | <Yardanico> In reply to @kodkuce "deterministic lockstep for multyplayer": I don't think even with that option you'll achieve full determinism, since you're dealing with floating point operations after all |
16:37:11 | * | deadmarshal_ joined #nim |
16:37:25 | FromDiscord | <Yardanico> check https://stackoverflow.com/questions/3234042/is-there-a-linux-g-equivalent-to-the-fpprecise-and-fpfast-flags-used-in for what you can do in GCC to mimic that MSVC option, I don't know much about determinism, but personally I think that you won't be able to get 100% determinism with floats, no matter the compiler arguments |
16:37:59 | * | fredrikhr quit (Ping timeout: 264 seconds) |
16:41:41 | FromDiscord | <kodkuce> rapier rust can do it |
16:45:41 | FromDiscord | <ieltan> oh man i really am at a loss lol |
16:55:40 | FromDiscord | <ieltan> Just found out about https://github.com/capocasa/limdb and oh my god, documentation. |
17:05:22 | FromDiscord | <Nilts> In reply to @ieltan "Just found out about": Is that just a client or a client and a db backend |
17:07:23 | FromDiscord | <ieltan> I think it's a db backend, the client is just a nim binding to libmdbx |
17:07:53 | FromDiscord | <ieltan> should you say client or interface ? thats not clear to me |
17:07:58 | FromDiscord | <Nilts> In reply to @ieltan "I think it's a": I think you got those revered. |
17:08:25 | FromDiscord | <Nilts> The backend is a server that you connect to, the client is the thing you use to connect |
17:09:43 | * | fredrikhr joined #nim |
17:10:39 | * | rockcavera joined #nim |
17:10:55 | termer | Does anyone know how to create a mutable seq in shared memory? |
17:11:25 | termer | I have an object with a seq parameter, and using createShared on it makes it impossible to mutate the seq |
17:11:44 | termer | impossible to mutate the seq property, taht is |
17:11:53 | FromDiscord | <ieltan> In reply to @not logged in "The backend is a": well the database is a local directory i generate and/or connect to with `mydb = initDatabase("dir/to/db")` then i can just add and remove stuff |
17:12:05 | termer | I can't do createShared on the object if the property is of type var seq[...] |
17:12:08 | FromDiscord | <ieltan> i dont know if that answer your question 😒 |
17:12:11 | FromDiscord | <ieltan> (edit) "😒" => ":c" |
17:12:13 | FromDiscord | <ieltan> (edit) ":c" => "😦" |
17:12:47 | * | fredrik92 quit (Ping timeout: 264 seconds) |
17:15:12 | termer | Looks like if my type is a ref object then it doesn't have that issue |
17:15:13 | termer | very odd to me |
17:15:16 | termer | but it works |
17:15:37 | NimEventer | New Nimble package! mcsrvstat.nim - A hybrid and asynchronous Nim wrapper for the Minecraft Server Status API., see https://github.com/hitblast/mcsrvstat.nim |
17:15:52 | termer | I knew ref objects were mutable so I assumed ptr objects were as well |
17:15:57 | termer | well, pointers to objects rather |
17:18:54 | FromDiscord | <cmc> Why thank you for pointing out LimDB's documentstion! Be the change you want to see in the world.Working on native support for more types and easier transactions.↵(@ieltan) |
17:20:51 | FromDiscord | <cmc> It's in-process, so you don't need to set up a seperate server.↵(@Nilts) |
17:20:59 | * | ltriant joined #nim |
17:25:45 | * | ltriant quit (Ping timeout: 240 seconds) |
17:32:52 | FromDiscord | <Nilts> In reply to @cmc "It's in-process, so you": kinda like sqlite? ncie |
17:32:55 | FromDiscord | <Nilts> (edit) "ncie" => "nice" |
17:58:03 | FromDiscord | <Nilts> Does multipart data = form data |
18:06:41 | FromDiscord | <Nilts> It apparently is not as my thing does not work |
18:10:51 | * | hochata quit (Ping timeout: 248 seconds) |
18:16:22 | FromDiscord | <cmc> Yeah exactly!I use them together a lot, like you would use redis and postgres in python.↵(@Nilts) |
18:22:05 | FromDiscord | <qb> sent a code paste, see https://play.nim-lang.org/#ix=4tAy |
18:24:33 | FromDiscord | <Nilts> sent a code paste, see https://play.nim-lang.org/#ix=4tAA |
18:25:48 | FromDiscord | <Nilts> sent a code paste, see https://paste.rs/XDd |
18:26:22 | FromDiscord | <qb> That's just an example. I'm trying to return any int types and strings as well |
18:27:12 | FromDiscord | <Nilts> In reply to @qb "That's just an example.": then just return them as normal? |
18:27:37 | FromDiscord | <qb> as normal? |
18:30:36 | FromDiscord | <Nilts> In reply to @qb "as normal?": as in my example |
18:31:41 | FromDiscord | <qb> sent a code paste, see https://play.nim-lang.org/#ix=4tAC |
18:34:02 | FromDiscord | <Nilts> In reply to @qb "Well lets make another": That would not work in nim normally |
18:34:05 | FromDiscord | <Yardanico> In reply to @qb "Well lets make another": you can't write Nim code that will violate Nim's own rules |
18:34:08 | FromDiscord | <Yardanico> even if you're using nimpy |
18:34:20 | FromDiscord | <Yardanico> so you have to check the nimpy api for something lower-level, not just return different types |
18:34:52 | FromDiscord | <Yardanico> also, fyi, you can just write `5'i8` and `1.5'd` for an int8 and a float64 respectively |
18:34:59 | FromDiscord | <Nilts> In reply to @not logged in "What is the nim": and bump now that someone who is smart is online |
18:35:23 | FromDiscord | <Yardanico> In reply to @not logged in "and bump now that": just do it manually? |
18:35:35 | FromDiscord | <Yardanico> if you want to submit a form, just concat the same data manually and send it with the post request? |
18:36:34 | FromDiscord | <Nilts> In reply to @Yardanico "if you want to": So do not use multipart? |
18:36:45 | FromDiscord | <Yardanico> no, multipart is for the different type |
18:36:49 | FromDiscord | <Nilts> In reply to @Yardanico "no, multipart is for": ah |
18:36:52 | FromDiscord | <Yardanico> with curl -d it just sends as a form by default |
18:37:02 | FromDiscord | <Yardanico> just use https://nim-lang.org/docs/uri.html#encodeQuery%2CopenArray%5B%5D |
18:37:13 | FromDiscord | <cmc> I think you want to export seperate procs for different return types. Python usually doesn't mix types either.Alternatively, you could return a tuple and populate the field you want, leaving the others as default.↵(@qb) |
18:37:44 | FromDiscord | <Nilts> In reply to @Yardanico "just use https://nim-lang.org/docs/uri.html#encodeQ": thanks! |
18:38:30 | FromDiscord | <Nilts> sent a code paste, see https://play.nim-lang.org/#ix=4tAF |
18:38:37 | FromDiscord | <qb> In reply to @cmc "I think you want": Yea thats what I'm doing atm. I have a ton of procs which actually do the same except returning the correct type. Thinking about one proc which can wrap them |
18:39:31 | FromDiscord | <Yardanico> In reply to @not logged in "wait, so like this:": no, check again, encodeQuery already url-encodes stuff |
18:40:22 | FromDiscord | <cmc> I think you want to export seperate procs for different return types. Python usually doesn't mix return types either, even though you can.↵Alternatively, you could return a tuple with an element for each type you want, and populate the one you need, leaving the others as default. |
18:40:36 | FromDiscord | <Nilts> In reply to @Yardanico "no, check again, encodeQuery": ok |
18:41:57 | FromDiscord | <Nilts> still getting `not enough segments in path` w/ `400 bad request` from the server |
18:42:04 | FromDiscord | <Nilts> but not with curl |
18:42:10 | NimEventer | New question by Oecophylla: Process output encoding using execProcess with Nim, see https://stackoverflow.com/questions/76029679/process-output-encoding-using-execprocess-with-nim |
18:42:32 | FromDiscord | <Nilts> sent a code paste, see https://play.nim-lang.org/#ix=4tAG |
18:42:35 | FromDiscord | <cmc> Ah.Well, the way Nim accounts for different types in the same variable is object variants.That's like I described, except with an added enum field called 'kind' to explicitly set the object subtype. I think that's the best you can do.↵(@qb) |
18:42:46 | FromDiscord | <Yardanico> In reply to @not logged in "Here is the code:": if curl is sending it as a form, you'd have to send the same headers as curl too |
18:43:01 | FromDiscord | <Yardanico> so at least Content-Type - application/x-www-form-urlencoded |
18:43:08 | FromDiscord | <Nilts> In reply to @Yardanico "if curl is sending": idk what headers it sends, and my python version is fine |
18:43:10 | FromDiscord | <Yardanico> and you can really just run curl with debug |
18:43:15 | FromDiscord | <Yardanico> and see what exactly it sends |
18:43:15 | * | fredrik92 joined #nim |
18:43:31 | FromDiscord | <Nilts> In reply to @Yardanico "so at least Content-Type": ah, yeah probably need that. The python version probably automatically does that oo |
18:44:08 | FromDiscord | <Nilts> wait, is there no headers param |
18:44:25 | FromDiscord | <Yardanico> you set headers to your http client |
18:44:38 | FromDiscord | <Yardanico> or pass to newhttpclient when creating it |
18:44:46 | FromDiscord | <Yardanico> https://nim-lang.org/docs/httpclient.html#using-http-post |
18:44:50 | FromDiscord | <Yardanico> third example shows |
18:45:07 | FromDiscord | <Nilts> In reply to @Yardanico "you set headers to": no, I am using one http client for alot of different requests, and only this one needs that header |
18:45:34 | FromDiscord | <Yardanico> In reply to @not logged in "no, I am using": then just set it and unset later |
18:45:49 | FromDiscord | <Yardanico> also, reusing is only useful if you're doing requests to the same domain afaik |
18:45:57 | FromDiscord | <Yardanico> because then you'll retain the same connection |
18:46:15 | FromDiscord | <Nilts> In reply to @Yardanico "also, reusing is only": I am |
18:46:24 | * | fredrikhr quit (Ping timeout: 248 seconds) |
18:46:56 | FromDiscord | <Nilts> In reply to @Yardanico "then just set it": Does just doing `client.request(url, HttpPost, headers=...)` not work |
18:47:24 | FromDiscord | <Yardanico> if you want that way, the `request` proc accepts headers |
18:47:28 | FromDiscord | <Yardanico> yeah |
18:47:47 | FromDiscord | <Yardanico> i don't remember all docs 100%, I just almost always do it the client.headers way so I didn't remember the request one |
19:21:29 | * | pharonix71 quit (Ping timeout: 255 seconds) |
19:24:01 | * | pharonix71 joined #nim |
19:38:16 | FromDiscord | <Nilts> Should nim be taking 99% of 0.5 cpu's? |
19:38:21 | FromDiscord | <Nilts> (edit) "cpu's?" => "cpus?" |
19:38:27 | FromDiscord | <Nilts> (edit) "cpus?" => "vcpus?" |
19:38:52 | PMunch | If you're doing computations, sure |
19:39:33 | PMunch | Nim programs, along any good program, will use 100% of any CPU if there is work to be done |
19:39:39 | FromDiscord | <Nilts> In reply to @PMunch "If you're doing computations,": I'm compiling a pretty small program |
19:40:05 | PMunch | Yeah, that's a computation. The alternative is to use 50% of the CPU and spend twice as long |
19:40:54 | PMunch | If anything Nim is inefficient in this matter as it will only use a single core |
19:41:11 | PMunch | Try to compile something with GCC and see that it takes 100% of the entire CPU |
19:41:59 | FromDiscord | <Nilts> In reply to @PMunch "Try to compile something": Nim uses gcc? |
19:42:58 | FromDiscord | <Elegantbeef> It's the default compiler on linux |
19:43:01 | FromDiscord | <Elegantbeef> Clang on mac and mingw on windows |
19:44:04 | PMunch | Indeed, but even GCC without Nim will do this |
19:44:54 | FromDiscord | <Elegantbeef> Well Nim is single threaded so it can only take 100% of a single thread |
19:51:24 | FromDiscord | <firasuke> In reply to @Elegantbeef "Well Nim is single": so Nim applications can't be multithreaded? |
19:51:41 | FromDiscord | <Elegantbeef> Applications can be |
19:51:48 | FromDiscord | <Elegantbeef> The compiler itself is single threaded |
19:55:19 | * | fredrik92 quit (Quit: Disconnecting) |
19:57:32 | FromDiscord | <Nilts> In reply to @firasuke "so Nim applications can't": the threading is wonky and kind of hard to use cuase the mem is not shared, but it is possible |
19:57:44 | FromDiscord | <Elegantbeef> Mem is shared with Orc/ARc |
19:57:48 | FromDiscord | <Elegantbeef> Which you should be using anyway |
19:58:51 | FromDiscord | <Nilts> In reply to @Elegantbeef "Mem is shared with": with threading? Oooo, I can finally do some of my old ideas! |
19:59:01 | FromDiscord | <Elegantbeef> I mean they have shared heap |
19:59:07 | FromDiscord | <Nilts> Btw, is Orc or Arc better |
19:59:26 | FromDiscord | <Nilts> In reply to @Elegantbeef "I mean they have": Can you access a var from across threads? |
19:59:29 | FromDiscord | <Elegantbeef> If you have to ask that you use Orc |
19:59:31 | FromDiscord | <Elegantbeef> Arc is for a subset of users |
20:00:04 | FromDiscord | <Elegantbeef> Yes, safely is another question though |
20:00:09 | FromDiscord | <guttural666> In reply to @Yardanico "yeah, that's what I": rewritten it to use async, awesome gainz 🥳 https://media.discordapp.net/attachments/371759389889003532/1097250095793193000/image.png |
20:00:38 | FromDiscord | <Elegantbeef> Nice no more IO slowdowns |
20:01:23 | FromDiscord | <Nilts> In reply to @Elegantbeef "Yes, safely is another": what do you mean? |
20:01:27 | FromDiscord | <firasuke> In reply to @guttural666 "rewritten it to use": does using async equal multithreading? |
20:01:33 | PMunch | No |
20:01:35 | FromDiscord | <guttural666> In reply to @firasuke "does using async equal": no |
20:01:46 | FromDiscord | <guttural666> In reply to @firasuke "does using async equal": https://peterme.net/asynchronous-programming-in-nim.html |
20:01:49 | PMunch | Async is co-operative multitasking |
20:01:54 | PMunch | @guttural666, :) |
20:02:27 | FromDiscord | <Nilts> In reply to @firasuke "does using async equal": async is single threaded, with small tasks of bigger tasks lined up on that thread. |
20:03:20 | FromDiscord | <guttural666> In reply to @PMunch "<@375727321958580228>, :)": you should write more, good stuff |
20:03:25 | FromDiscord | <Nilts> Compiling with ORC, RAM go brrrrrrr and explode |
20:03:31 | FromDiscord | <firasuke> In reply to @not logged in "async is single threaded,": yes that was what I initially knew, so it's a bit hard to write a multi-threaded application in Nim? |
20:03:43 | PMunch | Actually the first part of that article explains the difference better: https://peterme.net/multitasking-in-nim.html |
20:03:52 | PMunch | @guttural666, I'm actually writing an article as we speak |
20:04:01 | FromDiscord | <guttural666> In reply to @PMunch "<@375727321958580228>, I'm actually writing": been a while, huh? 😄 |
20:04:01 | PMunch | Hope to publish it before I go to bed |
20:04:04 | FromDiscord | <Nilts> In reply to @firasuke "yes that was what": yes, well, idk about with orc, but with whatever the default is yes |
20:04:17 | FromDiscord | <Elegantbeef> Damn pmunch using two keyboards |
20:04:19 | FromDiscord | <firasuke> I see, thanks for your insight |
20:04:44 | PMunch | @guttural666, February? Not the longest I've gone without an article :P |
20:05:01 | PMunch | @Elegantbeef, I'm writing it asynchronously ;) |
20:05:37 | FromDiscord | <guttural666> In reply to @PMunch "<@375727321958580228>, February? Not the": you're right, but the gap between articles[^1] and articles[^2] 😄 |
20:05:50 | PMunch | Yeah.. |
20:05:54 | PMunch | We don't speak about that :P |
20:05:55 | FromDiscord | <guttural666> 😄 |
20:09:53 | FromDiscord | <Elegantbeef> Imagine writing articles |
20:12:34 | FromDiscord | <Elegantbeef> Sorry i mean imagine publishing articles in an easily accessible place, and not just hidden on your domain 😛 |
20:14:16 | FromDiscord | <guttural666> async goes brrr 😄 apparently 30 requests with 10 ms gaps is fine by them ^^ https://media.discordapp.net/attachments/371759389889003532/1097253647752122399/image.png |
20:14:49 | FromDiscord | <Elegantbeef> Just remember guttural when scraping a site you should be respectful of their server |
20:15:10 | FromDiscord | <Elegantbeef> Just cause you can do 10000 requests per minute doesnt mean you should |
20:15:14 | FromDiscord | <guttural666> In reply to @Elegantbeef "Just remember guttural when": yeah, but this seems fine and it's just for the initial load 😛 |
20:15:36 | FromDiscord | <guttural666> have no clue what "a lot" is for web servers |
20:16:35 | NimEventer | New thread by Oecophylla: ExecProgram() - Managing encoding outputs / indentation, see https://forum.nim-lang.org/t/10105 |
20:18:04 | FromDiscord | <Elegantbeef> a lot depends on the server but depending how much i hate the corporation that runs the server changes my rate 😛 |
20:18:41 | FromDiscord | <Elegantbeef> Though many servers of corporations rate limit |
20:24:13 | FromDiscord | <⃟⃟> is the last name "Rumpf" derived from "rump" |
20:24:21 | PMunch | Article is up: https://peterme.net/wrapping-c-libraries-in-nim.html |
20:24:41 | PMunch | As always it's written without spellcheck, so please report any mistakes :P |
20:25:13 | FromDiscord | <Elegantbeef> Started a sentence with `but` shame on you |
20:25:36 | FromDiscord | <Elegantbeef> 3 sentences in a row starting with but |
20:25:44 | PMunch | >_> |
20:26:30 | FromDiscord | <Elegantbeef> Consider 'however' and other fun conjunctions! |
20:27:40 | PMunch | I don't see what you mean, there's not a single sentence starting with "but" in the first paragraph (at least not after a Ctrl+F5) |
20:28:03 | FromDiscord | <Elegantbeef> Lol |
20:30:19 | FromDiscord | <Elegantbeef> I do appreciate that we right in totally different styles. I go for formal nonsense and you do formal sensible. 😄 |
20:30:30 | PMunch | Haha :P |
20:30:41 | FromDiscord | <Elegantbeef> informal sensible\ |
20:31:11 | PMunch | I mostly just write how I think about a subject |
20:31:49 | FromDiscord | <Elegantbeef> Yea I feel like when I'm writing I want to instil some humour in my writing |
20:32:10 | PMunch | Where do you publish your stuff? I read them when I come upon them, but as you said without an easy to find domain it's not easy to find :P |
20:32:32 | FromDiscord | <Elegantbeef> https://www.jasonbeetham.com/codereuse.html i have a few nimib generated writeups on my domain just hidden |
20:32:51 | FromDiscord | <Elegantbeef> https://www.jasonbeetham.com/pointerexplanation.html |
20:33:04 | FromDiscord | <Elegantbeef> I do want to link to these on my site proper, but havent got to it |
20:33:39 | FromDiscord | <Elegantbeef> As you can see I do not use contractions or 'you' |
20:33:57 | FromDiscord | <Elegantbeef> Makes it technically more formal, but then I load nonsense into it 😛 |
20:35:31 | PMunch | I used to write more formally when I was writing at university, but since my audience now is just other hobbyists I don't bother |
20:36:00 | FromDiscord | <Elegantbeef> "couple of gripes" follows with a list of 3 |
20:36:02 | FromDiscord | <Elegantbeef> Nice 😛 |
20:36:15 | FromDiscord | <Elegantbeef> Sorry list of 4 |
20:36:22 | PMunch | An Amish couple :P |
20:36:28 | FromDiscord | <Elegantbeef> The quartet of three is the scariest |
20:36:49 | PMunch | Quartet of three? |
20:37:36 | FromDiscord | <Elegantbeef> It's the inverse of what you did |
20:37:41 | PMunch | Anyways, I'm off to bed |
20:37:53 | FromDiscord | <Elegantbeef> A quartet is made of 4 hence 'quart' three is not a quartet 😄 |
20:38:01 | PMunch | Yeah I know that part :P |
20:38:36 | PMunch | I was just afraid I had said I have "three" of something and listed four somewhere :P |
20:38:40 | * | PMunch quit (Quit: leaving) |
20:38:51 | FromDiscord | <Elegantbeef> You did say 2 then listed 4 though! |
20:39:57 | FromDiscord | <Elegantbeef> You do seem to skip of `{.passl: "-lcoap-3".}` |
20:39:57 | FromDiscord | <Elegantbeef> skip over\ |
20:47:41 | FromDiscord | <guttural666> if I provide a var string to a proc that takes a non var string, the compiler won't complain, even if I then mutate the string inside the proc, that can't be right? |
20:48:51 | FromDiscord | <guttural666> to be more specific: I define a var string in a proc, then pass it to a template, that expects a non var string, maybe that makes a difference |
20:49:40 | FromDiscord | <Elegantbeef> `var T -> T` is fine |
20:50:01 | FromDiscord | <Elegantbeef> templates do not validate the varness |
20:50:23 | FromDiscord | <Elegantbeef> Since the template expands in place the validation is done by whether you declared it as a var |
20:51:11 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4tAW |
20:54:50 | FromDiscord | <⃟⃟> ill ask again |
20:54:51 | FromDiscord | <⃟⃟> is the last name "Rumpf" derived from "rump" |
20:55:42 | FromDiscord | <Elegantbeef> Doubt we have a etymologist that specialises in names |
20:56:13 | FromDiscord | <frank456> "I'll help anyone interested on how to earn 100k in just 24hours from the crypto market. But you will have to pay me my commission! when you receive your profit! if interested send me a direct message https://t.me/victormarck by asking me HOW |
20:56:28 | FromDiscord | <⃟⃟> wtf |
20:56:34 | FromDiscord | <⃟⃟> crypto scammer |
20:56:36 | FromDiscord | <Yardanico> In reply to @⃟⃟ "is the last name": huh? |
20:56:40 | FromDiscord | <Yardanico> where'd that question come from |
20:56:50 | FromDiscord | <⃟⃟> In reply to @Yardanico "where'd that question come": andreas rumpf |
20:56:53 | FromDiscord | <⃟⃟> made nim |
20:56:56 | FromDiscord | <Yardanico> yes, but why ask here and not in #offtopic |
20:57:05 | FromDiscord | <⃟⃟> its about nim? |
20:57:07 | FromDiscord | <Yardanico> its a really weird question |
20:57:11 | FromDiscord | <Yardanico> In reply to @⃟⃟ "its about nim?": no, it's about names |
21:06:08 | FromDiscord | <pmunch> And quite easy to Google the answer to for that matter |
21:22:35 | * | ltriant joined #nim |
21:23:49 | FromDiscord | <guttural666> I am getting an IOSelectorsException when using asyncdispatch, any tips on how to release system IO selectors manually or how do they work? I am just creating 30 async futures at any time and think I am releasing the sequence of futures again with futures = @[] |
21:27:05 | * | ltriant quit (Ping timeout: 240 seconds) |
21:27:20 | * | Notxor quit (Quit: Leaving) |
22:11:04 | * | pbsds quit (Ping timeout: 276 seconds) |
22:17:50 | * | ltriant joined #nim |
22:25:29 | * | jmdaemon joined #nim |
22:34:26 | * | lucasta quit (Remote host closed the connection) |
22:40:06 | * | tjaden joined #nim |
22:47:13 | * | ltriant quit (Ping timeout: 250 seconds) |
22:53:12 | FromDiscord | <JeysonFlores> how can I get the quantity or the reference to all the running threads in a program? |
22:53:41 | * | ltriant joined #nim |
22:57:32 | FromDiscord | <Elegantbeef> On linux you can just iterate the TID directory iirc |
22:58:29 | FromDiscord | <Elegantbeef> Sorry it seems to be `/proc/$PID/task/threads` |
23:03:11 | FromDiscord | <Elegantbeef> Windows probably has an API for it |
23:05:11 | FromDiscord | <JeysonFlores> so.... there's no function from the standard library to do it? |
23:05:25 | FromDiscord | <Elegantbeef> Doubt it |
23:06:45 | FromDiscord | <JeysonFlores> ok thanks! |
23:07:31 | FromDiscord | <Elegantbeef> There isnt much reason for that afaik |
23:09:37 | FromDiscord | <JeysonFlores> yeah I was afraid of that, it's quite a rare use case |
23:10:40 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4tBa |
23:12:23 | FromDiscord | <Elegantbeef> probably should usue `walkDir` no clue though i'm too lazy to read about the spec for task 😄 |
23:12:43 | FromDiscord | <Elegantbeef> Windows probably does this through 80 bazillion procedure calls that are very tedious |
23:16:02 | FromDiscord | <JeysonFlores> ey thanks for the snippet, don't worry about windows support 😜 this code is meant to be ran in linux servers |
23:18:24 | FromDiscord | <Elegantbeef> Ah you mean it's supposed to be ran on servers 😛 |
23:58:16 | FromDiscord | <Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4tBe |