00:01:56 | * | njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.) |
00:02:17 | * | njoseph joined #nim |
00:25:11 | * | nekits07 joined #nim |
00:26:55 | FromDiscord | <Sabena Sema> https://github.com/nim-lang/fusion/blob/fb1655420a91c9ad0d0141c657b6d468ed276b4e/src/fusion/btreetables.nim#L851 |
00:27:04 | FromDiscord | <Sabena Sema> what's that `<//>` syntax? |
00:41:30 | FromDiscord | <Yardanico> In reply to @Sabena Sema "what's that `<//>` syntax?": it does nothing right now, initially it was used as a way to specify owned refs in a backwards compatible way so that older nim versions could compile the same code |
00:42:14 | FromDiscord | <Sabena Sema> huh, but fusion's unique pointers don't seem to define `=sink` |
00:42:26 | FromDiscord | <Yardanico> ? |
00:43:16 | FromDiscord | <Yardanico> owned refs were a part of the newruntime, but it didn't go that far, instead arc/orc were developed |
00:43:16 | FromDiscord | <Yardanico> https://nim-lang.org/araq/ownedrefs.html |
00:45:40 | FromDiscord | <Yardanico> In reply to @Sabena Sema "huh, but fusion's unique": also smartptrs is going to be added to stdlib, so check code in https://github.com/nim-lang/Nim/pull/17333 instead of fusion for it |
00:46:18 | FromDiscord | <Yardanico> and =sink is compiler-provided by default - https://nim-lang.org/docs/destructors.html#lifetimeminustracking-hooks-eqsink-hook |
00:46:41 | FromDiscord | <Yardanico> http://nim-lang.github.io/Nim/destructors.html "When not provided the compiler is using a combination of =destroy and copyMem instead. " |
00:56:18 | FromDiscord | <Sabena Sema> Except you can't call destroy after moving from a unique ptr |
00:56:32 | FromDiscord | <Sabena Sema> Bagh Ill figure it out later |
01:03:46 | * | Tlangir joined #nim |
01:23:06 | FromDiscord | <Avatarfighter> What does the smartptrs package do/what is a use case ? |
02:31:26 | * | layers joined #nim |
02:31:46 | * | layers quit (Client Quit) |
02:54:08 | * | thomasross quit (Remote host closed the connection) |
03:10:05 | * | spiderstew joined #nim |
03:11:25 | * | spiderstew_ quit (Ping timeout: 250 seconds) |
03:59:12 | * | letto quit (Quit: Konversation terminated!) |
04:01:10 | * | rockcavera quit (Remote host closed the connection) |
04:01:11 | * | letto joined #nim |
04:19:31 | * | Gustavo6046 quit (Ping timeout: 260 seconds) |
05:02:46 | * | narimiran joined #nim |
05:07:50 | saem | Hmm, so `--path:.` is not implied if you don't specify path. Huh |
05:33:47 | * | haxscramper joined #nim |
05:45:17 | * | inamannerofspeak joined #nim |
05:47:53 | ForumUpdaterBot | New thread by Bpr: Interesting post from D forum, see https://forum.nim-lang.org/t/7791 |
06:00:57 | FromDiscord | <TennisBowling> In reply to @haxscramper "You can show code": https://play.nim-lang.org/#ix=2W8D |
06:05:38 | FromDiscord | <haxscramper> https://wandbox.org/permlink/ExyAy7Fi9kPDIj0c |
06:05:53 | FromDiscord | <haxscramper> https://nim-lang.org/docs/manual.html#procedures < |
06:06:07 | FromDiscord | <haxscramper> I think someone linked that already, but manual has example on how to define procedure with return type |
06:38:04 | * | johnnynitwits quit (Quit: Bridge terminating on SIGTERM) |
06:38:04 | * | threenp quit (Quit: Bridge terminating on SIGTERM) |
06:48:52 | * | inamannerofspeak quit (Ping timeout: 252 seconds) |
07:05:43 | * | vicfred quit (Quit: Leaving) |
07:08:37 | * | skelett quit (Quit: WeeChat 2.9) |
07:19:06 | FromDiscord | <mattrb> Can someone explain what's going on here? https://play.nim-lang.org/#ix=2W8P |
07:21:12 | * | natrys joined #nim |
07:23:50 | * | johnnynitwits joined #nim |
07:23:55 | * | threenp joined #nim |
07:30:05 | ForumUpdaterBot | New thread by Mikkom: Fastest method for writing and loading cached binary object data to file, see https://forum.nim-lang.org/t/7792 |
07:31:51 | FromDiscord | <ElegantBeef> @mattrb based off this seems unsigned bit shift returns the value if it goes out of bit bounds https://play.nim-lang.org/#ix=2W8U |
07:33:47 | FromDiscord | <mattrb> Hmm but why? I don't see that documented anywhere, and it doesn't seem like that's what the compiler emits? https://github.com/nim-lang/Nim/blob/devel/compiler/ccgexprs.nim#L633 |
07:33:50 | FromDiscord | <mattrb> I could also be misreading |
07:36:09 | FromDiscord | <ElegantBeef> Seems that's just what C does |
07:36:35 | * | haxscramper quit (Remote host closed the connection) |
07:36:51 | FromDiscord | <ElegantBeef> If you shift over the size of the type it returns the value it seems |
07:37:02 | * | haxscramper joined #nim |
07:39:22 | FromDiscord | <ElegantBeef> Since it's a direct wrap to C we get that odd behaviour |
07:41:27 | FromDiscord | <mattrb> It doesn't do it with 8-bit ints though? https://play.nim-lang.org/#ix=2W8Y |
07:41:38 | FromDiscord | <mattrb> (edit) "8-bit ints" => "uint8s" |
07:45:33 | FromDiscord | <ElegantBeef> Cause it doesnt happen in C either |
07:46:13 | FromDiscord | <ElegantBeef> https://onlinegdb.com/rJqrJuH8d |
07:49:39 | * | neceve joined #nim |
07:51:57 | FromDiscord | <ElegantBeef> Yea it's certainly odd C behaviour https://onlinegdb.com/SyZW9gOBUu |
07:52:06 | * | PMunch joined #nim |
07:52:14 | FromDiscord | <ElegantBeef> My suggestion is to do https://play.nim-lang.org/#ix=2W8Z |
07:52:47 | FromDiscord | <mattrb> Unless `b` is 0 |
07:52:52 | FromDiscord | <mattrb> But yeah I think I'll have to do that |
07:52:53 | FromDiscord | <mattrb> Thanks |
07:52:56 | FromDiscord | <mattrb> C sucks lol |
07:53:06 | FromDiscord | <ElegantBeef> Indeed |
07:53:25 | FromDiscord | <ElegantBeef> But now for you to do your part and document that oddity 😄 |
07:54:20 | FromDiscord | <ElegantBeef> Though i do agree that the shift ops should return 0 in this case |
07:55:20 | FromDiscord | <Rika> this behavior shouldnt carry into nim tho should it |
07:55:49 | FromDiscord | <ElegantBeef> Certainly not that's quite unintuitive |
07:56:50 | FromDiscord | <mattrb> Yeah if this was just a documentation change I'd happy add it to the docs, but I feel like Nim should override the C behavior here |
07:57:08 | FromDiscord | <ElegantBeef> Well time for an RFC i imagine |
07:57:32 | FromDiscord | <mattrb> I can likely get to it this weekend if it's not picked up prior to then |
07:59:00 | FromDiscord | <Rika> inb4 cant add, breaking change |
07:59:05 | FromDiscord | <ElegantBeef> lol |
07:59:12 | FromDiscord | <ElegantBeef> I mean it's not difficult to change |
07:59:40 | FromDiscord | <ElegantBeef> Dont even have to change the generated C, just make the `shr` a `shrImpl` and then `shr` calls it |
08:00:01 | FromDiscord | <ElegantBeef> > However, do note that a shift operand value which is either a negative number or is greater than or equal to the total number of bits in this value results in undefined behavior. For example, when shifting a 32 bit unsigned integer, a shift amount of 32 or higher would be undefined. |
08:00:07 | FromDiscord | <ElegantBeef> Ah so it is UB |
08:00:13 | FromDiscord | <ElegantBeef> Fuck i love C! |
08:00:21 | FromDiscord | <mattrb> Yeah I just found basically the same thing lol |
08:00:29 | * | haxscramper quit (Remote host closed the connection) |
08:00:31 | FromDiscord | <mattrb> https://en.cppreference.com/w/c/language/operator_arithmetic#Shift_operators↵> The behavior is undefined if rhs is negative or is greater or equal the number of bits in the promoted lhs. |
08:00:48 | FromDiscord | <Rika> nice |
08:00:51 | FromDiscord | <ElegantBeef> So yea certainly needs addressed, having UB is just silly |
08:00:55 | * | haxscramper joined #nim |
08:01:00 | FromDiscord | <Rika> just divide by 2 ez |
08:01:07 | FromDiscord | <ElegantBeef> lol |
08:01:16 | FromDiscord | <mattrb> I imagine this would also affect `shl` |
08:01:24 | FromDiscord | <Rika> i dont think it does actually lol |
08:01:32 | FromDiscord | <Rika> maybe check |
08:01:43 | FromDiscord | <ElegantBeef> If you shit more than 32 bits left it should be zero regardless what was there |
08:01:49 | FromDiscord | <ElegantBeef> inb4 it wraps around |
08:01:57 | FromDiscord | <Rika> shit lmao |
08:02:08 | FromDiscord | <ElegantBeef> !eval echo 0xffu32 shl 32 |
08:02:15 | NimBot | 0 |
08:02:19 | FromDiscord | <ElegantBeef> Wehew |
08:03:09 | FromDiscord | <mattrb> Phew |
08:03:14 | FromDiscord | <Rika> lmao |
08:03:23 | FromDiscord | <Rika> yall i love c so much :DDDDDDDDDDDD |
08:03:42 | FromDiscord | <mattrb> The docs I linked above seem to imply that the behavior for both `<<` and `>>` out of range is undefined, so I think we just lucked into that one being 0 lol |
08:03:49 | FromDiscord | <ElegantBeef> Ah |
08:03:56 | FromDiscord | <mattrb> Nim should define implementations for both imo |
08:04:17 | FromDiscord | <ElegantBeef> Yea proper shifting that's done properly |
08:04:42 | FromDiscord | <Rika> inb4 it actually is just a for loop and dividing/multiplying |
08:05:55 | FromDiscord | <clyybber> Theres an open PR which addresses this |
08:06:06 | FromDiscord | <clyybber> AFAIRC |
08:06:32 | FromDiscord | <ElegantBeef> As far as internet relay chat? |
08:07:34 | FromDiscord | <clyybber> lol I meant as far as i remember correctly but i just realized that i mixed two things there |
08:07:40 | FromDiscord | <clyybber> <https://github.com/nim-lang/Nim/pull/11555> |
08:08:22 | FromDiscord | <Rika> lmao IIRC and AFAIR |
08:08:49 | FromDiscord | <Rika> AFAIIRC, as far as if i recall correctly |
08:08:50 | FromDiscord | <Rika> xd |
08:14:13 | ForumUpdaterBot | New thread by Halloleo: How do I get the fields/attributes of an object type at run time?, see https://forum.nim-lang.org/t/7793 |
08:16:14 | FromDiscord | <Rika> oh man here we go again |
08:16:47 | FromDiscord | <Rika> oh okay its more okay than i thought |
08:16:51 | FromDiscord | <spkinguy1> sent a long message, see http://ix.io/2W97 |
08:16:53 | FromDiscord | <Rika> In reply to @spkinguy1 "guys which one of": low? |
08:17:04 | FromDiscord | <Rika> as in which i like least? |
08:17:07 | FromDiscord | <Rika> oh |
08:17:09 | FromDiscord | <spkinguy1> (edit) "http://ix.io/2W97" => "http://ix.io/2W98" |
08:17:11 | FromDiscord | <Rika> low level huh |
08:17:18 | FromDiscord | <Rika> id say zig |
08:17:46 | FromDiscord | <spkinguy1> In reply to @Rika "id say zig": u know most of them ? |
08:17:51 | FromDiscord | <mattrb> sent a code paste, see https://play.nim-lang.org/#ix=2W99 |
08:18:57 | FromDiscord | <clyybber> In reply to @mattrb "Looks like this PR": Yeah, the PR will guarantee wrap around |
08:19:44 | FromDiscord | <Rika> In reply to @spkinguy1 "u know most of": to a small extent at least, from what ive seen |
08:22:34 | FromDiscord | <mattrb> I don't follow the logic for forcing the wraparound. If we're defining the undefined C behavior, I feel like we'd want to instead make all of those return 0? |
08:23:20 | * | inamannerofspeak joined #nim |
08:25:48 | FromDiscord | <Rika> maybe new operators if wrap is desired? wshl wshr? |
08:26:06 | * | PMunch quit (Ping timeout: 240 seconds) |
08:26:38 | FromDiscord | <mattrb> I'm having flashbacks to when Araq reviewed the `ashr` PR :cringeharold: |
08:26:49 | FromDiscord | <mattrb> (I wasn't around at the time, but read the discussion there :p) |
08:29:16 | * | PMunch joined #nim |
08:29:38 | PMunch | Going to stream again today, around 5PM UTC as last time |
08:29:40 | PMunch | Implementing I²C to communicate between the two halves |
08:29:46 | PMunch | Did some preliminary testing to just blink an LED over the port expander with the libraries for Arduino, and it took a bit over 3000 bytes, a solid 33% larger than the entire keyboard firmware so far. So this might get interesting |
08:37:29 | FromDiscord | <mattrb> In reply to @mattrb "I don't follow the": Also, I feel like without a defined implementation, this is going to have different behavior on different architectures. (I'm just making an assumption, but I know that arm shifts out of range result in 0). Leaving this up to undefined behavior in C definitely isn't the way to go, and I'd argue that making shifts out of range return 0 is the way people would _expect_ this to work |
08:40:09 | FromDiscord | <ElegantBeef> Yea this `if toShift >= sizeOf(a) 4: 0 else: a shr toShift` seems like it'd be fine to my tired mind |
08:41:12 | FromDiscord | <ElegantBeef> i mean ` 8` ofc |
08:53:25 | * | arecaceae quit (Remote host closed the connection) |
08:53:44 | * | arecaceae joined #nim |
08:56:41 | * | Tlangir quit (Quit: Leaving) |
09:10:01 | FromDiscord | <clyybber> I'm worried about the performance impact |
09:12:28 | FromDiscord | <ElegantBeef> Yea i was worried aswell, only thing i could think of is make `shl/shr` the C versions and `<<`/`>>` the "safe" versions but that seems ugly considering the other ops |
09:12:51 | PMunch | Are you messing with shifting? |
09:13:12 | FromDiscord | <ElegantBeef> Nah just talking about how borked shifting is due to using C's directly |
09:13:55 | FromDiscord | <clyybber> I wonder how zig or crystal do it |
09:14:37 | PMunch | Probably the same, unless they get really poor performance on some architectures |
09:15:15 | PMunch | I mean the differences in shifting is just down to how the low level instructions work on different architectures isn't it? |
09:15:17 | FromDiscord | <ElegantBeef> Suppose we could have ah `-d:nimUseFastShifts` 😄 |
09:15:24 | FromDiscord | <ElegantBeef> (edit) "ah" => "a" |
09:15:27 | FromDiscord | <clyybber> In reply to @PMunch "I mean the differences": yeah |
09:16:04 | FromDiscord | <mattrb> In reply to @Clyybber "I wonder how zig": Shifts out of range on crystal result in 0 |
09:16:26 | FromDiscord | <mattrb> I know because I’m porting my Crystal gba emulator to Nim and this is a new bug for me 😆 |
09:16:30 | PMunch | I guess it could be a compile-time thing so the behaviour we want isn't wrapped, but platforms that are wrapped could show an error with a hint to use -d:nimUseFastShifts |
09:16:38 | PMunch | Or -d:nimUseNativeShifts |
09:16:56 | FromDiscord | <clyybber> In reply to @mattrb "I know because I’m": ah, I suspected that :D |
09:17:21 | PMunch | What architecture are you on where that doesn't happen anyways? |
09:19:13 | FromDiscord | <clyybber> <https://github.com/crystal-lang/crystal/issues/305> |
09:20:03 | FromDiscord | <clyybber> seems like they split it into seperate ops |
09:21:33 | FromDiscord | <ElegantBeef> So seems my suggestion isnt terrible, just odd that the new ops would be the safe ones i guess |
09:21:48 | FromDiscord | <clyybber> I think a global switch is a bad idea |
09:22:17 | FromDiscord | <ElegantBeef> I mean the `shl` and `<<` |
09:22:18 | saem | Less switches plz. :) |
09:22:28 | FromDiscord | <ElegantBeef> I was joking with the global switch |
09:22:31 | FromDiscord | <clyybber> oh :D |
09:22:32 | PMunch | I don't think this is really needed.. |
09:22:55 | PMunch | If anyone actually needs to have a safe version of shl that sacrifices performance let them create a small template.. |
09:23:47 | FromDiscord | <clyybber> I guess we could also just declare it illegal behaviour, instead of undefined; then debug mode could have an assertion there; and when you need the wraparound/zero-out behaviour, DIY |
09:24:28 | FromDiscord | <mattrb> In reply to @Clyybber "seems like they split": https://github.com/crystal-lang/crystal/blob/dd40a2442fa186add8a82b74edb14a90aa1dae05/src/int.cr#L203↵↵Haha amusing. I was literally just looking at this code earlier for another reason. I had a bug in my emulator because I assumed crystal shifts were logical even on signed numbers, but they’re arithmetic |
09:24:53 | Clonkk[m] | Is there an easy way to specify that ``Complex[Complex32]`` should return ``Complex32`` at compile-time (i.e. usable in generics) ? |
09:24:58 | FromDiscord | <ElegantBeef> Yea the worst part was there was no "there'll be dragons" message |
09:25:10 | saem | It could be a check one turns off? |
09:25:17 | * | lritter joined #nim |
09:25:28 | Clonkk[m] | I have an input ``T: SomeFloat|Complex`` that should return ``Complex[T]`` basically. |
09:28:01 | FromDiscord | <Goel> sent a code paste, see https://play.nim-lang.org/#ix=2W9y |
09:30:16 | FromDiscord | <ElegantBeef> iterating ranges annoyingly requires `min, max` |
09:30:44 | FromDiscord | <clyybber> use countdown yeah, `..` is countup |
09:37:26 | * | clyybber joined #nim |
09:41:54 | narimiran | Nim 1.4.6 and 1.2.12 are out!! https://nim-lang.org/blog/2021/04/15/versions-146-and-1212-released.html |
09:43:35 | narimiran | There were no complaints during the release candidate phase. (But I'm sure somebody will find some issue 2 seconds after we announce the releases to the broader audience :D) |
09:44:35 | giaco__ | to go from 4 chars long string to uint32, is mystr.toHex.parseHexInt.uint32 the way to go? |
09:45:02 | giaco__ | it is a bytestring, obviously |
09:46:47 | FromDiscord | <ElegantBeef> `cast[uint32](myStr[0])` |
09:48:06 | PMunch | Hmm, I'm trying to spit this out from a macro, but it throws an internal error: http://ix.io/2W9E |
09:48:06 | liblq-dev | well not really |
09:48:15 | PMunch | Error: internal error: getTypeDescAux(tyAnything) |
09:48:21 | liblq-dev | @ElegantBeef this will only get the first byte of the string |
09:48:35 | liblq-dev | `cast[ptr uint32](myStr[0].unsafeAddr)[]` |
09:48:38 | liblq-dev | is the right solution |
09:49:34 | liblq-dev | giaco__: ^ |
09:51:10 | PMunch | Spotted one error, trying to use `auto` in the emit |
09:51:31 | PMunch | Now I have a different error :) |
09:53:50 | * | krux02 joined #nim |
09:55:51 | giaco__ | liblq-dev: thanks. Will the result of that cast be refcounted as the string or will live on the stack? |
09:56:12 | liblq-dev | it will get copied out of the string |
09:56:32 | giaco__ | thanks |
09:56:40 | liblq-dev | that expression is equivalent to `*((uint32_t *)&myStr[0])` in C |
09:57:32 | giaco__ | I wish I had more C experience before diving into nim, but I'm slowly catching up :P |
10:00:18 | * | haxscramper quit (Remote host closed the connection) |
10:00:43 | * | haxscramper joined #nim |
10:01:20 | liblq-dev | so basically what this does is the following: 1. it takes the memory address of the first character in the string, 2. it reinterprets that address's type from a char pointer to a uint32 pointer, 3. it dereferences that pointer, which essentially means: it reads the memory at the address the pointer is pointing to |
10:02:37 | * | haxscramper quit (Read error: Connection reset by peer) |
10:03:08 | * | haxscramper joined #nim |
10:03:48 | * | haxscramper quit (Remote host closed the connection) |
10:05:29 | FromDiscord | <Clonkk> sent a code paste, see https://play.nim-lang.org/#ix=2W9M |
10:08:08 | giaco__ | liblq-dev: and for the other way around, to go from uint32 to bytestring, is there something better than "myuint.toHex.parseHexStr" ? |
10:08:30 | ForumUpdaterBot | New thread by Miran: Versions 1.4.6 and 1.2.12 released, see https://forum.nim-lang.org/t/7794 |
10:08:42 | liblq-dev | well that ain't gonna do what you want anyways so |
10:08:47 | liblq-dev | going the other way 'round is a bit harder |
10:09:02 | liblq-dev | you can turn your uint32 into a cstring |
10:09:14 | giaco__ | no? I'm using it and it seems working so far |
10:09:24 | liblq-dev | define "bytestring" |
10:09:30 | PMunch | Can I convert an object to an array of bytes on compile-time? I'm guessing no |
10:09:50 | giaco__ | a string with same sizeof the original thing and with 1:1 bytes |
10:10:53 | liblq-dev | PMunch: frosty? |
10:11:12 | PMunch | No thanks I prefer regular corn flakes |
10:11:16 | PMunch | Could you pass the milk though? |
10:11:55 | PMunch | Hmm, Frosty looks like it might be able to do it |
10:16:58 | giaco__ | am I wrong? |
10:21:12 | FromDiscord | <sealmove> is there a way to expand a list to arguments similar to Python's `` prefix? |
10:22:32 | ForumUpdaterBot | New thread by Pietroppeter: Lost thread? (Fastest method for writing and loading cached binary object data to file), see https://forum.nim-lang.org/t/7795 |
10:23:04 | liblq-dev | giaco__: excuse my lack of response but i'm having a lesson right now so i can't really respond in real time |
10:23:17 | liblq-dev | and nim playground seems to be down. |
10:24:25 | giaco__ | absolutely no need to excuse, thanks for the feedback! |
10:25:26 | PMunch | Hmm, rebooted the playground, let's see if that works |
10:26:11 | * | liblq-dev < https://matrix.org/_matrix/media/r0/download/matrix.org/EVAGOgwOAlqNfaLqGBBffMls/message.txt > |
10:26:16 | liblq-dev | giaco__: ^ |
10:27:12 | liblq-dev | results in "DCBA" being written to stdout, because little endian |
10:30:05 | giaco__ | thanks! but I wonder if toHex.parseHexStr is more or less conveniente. I should write some tests |
10:31:48 | giaco__ | side question: doing "0x41424344u32" or doing "0x41424344.uint32" is the same thing, or the second one implies a conversion? |
10:36:31 | liblq-dev | it's the same thing |
10:36:45 | liblq-dev | toHex.parseHexStr is slower |
10:37:07 | liblq-dev | because you first convert the string to a hex representation, and then back to a normal string |
10:37:14 | liblq-dev | here you just directly operate on bytes |
10:42:42 | giaco__ | I've run some -d:danger benchmarks over the two versions with benchy. You're right, the cast version is faster but not so much. Over 1_000_000 operations the cast version has an average time of 36ms, 40ms for the toHex.parseHexStr |
10:43:52 | giaco__ | liblq-dev: this is the benchmark http://ix.io/2Wa3 |
10:45:12 | giaco__ | also the cast version lacks the endianess fix, that could slow it down |
10:47:36 | liblq-dev | you're discarding the result |
10:47:50 | liblq-dev | so the compiler optimizes your computation away |
10:48:01 | giaco__ | oh |
10:48:04 | giaco__ | ^^" |
10:50:11 | liblq-dev | unfortunately i don't have a good solution to that as benchy's `keep` doesn't always work |
10:51:13 | giaco__ | yeah I'm moving keep here and there but the benchmarks are not changing |
10:51:52 | liblq-dev | i tried to writeFile the string but then that adds also the cost of reallocating the intermediary string, and syscalls and such |
10:51:57 | liblq-dev | so it's not a fair benchmark |
10:52:19 | liblq-dev | but it gives me 51.830 ms for unsafe vs 70.025 for "safe" |
10:54:19 | * | Vladar joined #nim |
10:55:27 | liblq-dev | juggling bits with shl has a similar outcome |
11:01:38 | giaco__ | how do you fix byte endianess with shl? Don't you need rotate for that? |
11:02:15 | PMunch | Well, with careful bitmasking you should be able to |
11:03:19 | PMunch | ((myUint16 and 0xff00) shr 8) or ((myUint16 and 0xff) shl 8) |
11:03:21 | PMunch | Something like that |
11:04:00 | giaco__ | yeah, but with uint64 is like playing hanoi tower :D |
11:04:33 | PMunch | Well, it's just more of the same |
11:06:30 | PMunch | ((myUint32 and 0xff000000) shr 26) or ((myUint32 and 0x00ff0000) shr 8) or ((myUint32 and 0x0000ff00) shl 8) or ((myUint32 and 0x000000ff) shl 26) |
11:06:36 | PMunch | That's for 32 bit |
11:07:19 | liblq-dev | woah pmunch |
11:07:26 | liblq-dev | didn't you get your bits mixed up? |
11:07:32 | PMunch | Did I? |
11:07:36 | liblq-dev | where'd you get 26 from? |
11:07:45 | PMunch | 32 - 8? |
11:08:03 | giaco__ | 24 :P |
11:08:11 | PMunch | Oh, woops :P |
11:08:24 | PMunch | I was looking at that thinking it looked wrong |
11:08:32 | liblq-dev | that's 24 bumbo |
11:08:56 | PMunch | I'm a computer scientist, not a mathematician :P |
11:09:21 | FromDiscord | <Rika> computer science is highly linked to mathematics |
11:09:31 | giaco__ | btw I got the point. I also see there's a module for that https://nim-lang.org/docs/endians.html |
11:09:48 | PMunch | Oh yeah, you shouldn't actually do it that way in real code :P |
11:09:54 | liblq-dev | here's how i (wouldn't) do it |
11:09:55 | liblq-dev | reason: it's better to append bytes to an existing string buffer rather than allocate a new string each time you want to convert |
11:10:14 | * | liblq-dev < https://matrix.org/_matrix/media/r0/download/matrix.org/QxZfHIFXDQeesElBXmjldHxV/message.txt > |
11:10:42 | liblq-dev | also, isp is being unkind |
11:10:56 | PMunch | @Rika, I was just joking. But having been sat in front of a computer since I was a kid I haven't really had much use for doing math in my head |
11:11:06 | giaco__ | I'm quite puzzled with your initial solution liblq-dev, what doas swap the endianess? |
11:11:08 | PMunch | It's literally a big glorified calculator :P |
11:11:40 | liblq-dev | giaco__: in the first one? nothing |
11:11:47 | liblq-dev | it stores the number in native endianness |
11:12:06 | liblq-dev | on little endian that's reverse of how hex literals are written |
11:12:27 | giaco__ | but it comes out swapped compared to what mystr.toHex.parseHexStr produces |
11:12:42 | liblq-dev | that's how it should be |
11:12:50 | liblq-dev | toHex converts the number to a string |
11:12:56 | liblq-dev | rather than bytes |
11:13:10 | liblq-dev | 0x41424344 is stored as 44 43 42 41 in memory on little endian architectures |
11:13:48 | liblq-dev | and my first solution is literally just copying bytes around |
11:13:49 | liblq-dev | that's why it's endian dependent |
11:14:16 | liblq-dev | toHex will convert your int to a hex number, rather than bytes represented as hex |
11:14:25 | liblq-dev | so the initial order of 41424344 is preserved |
11:14:43 | PMunch | Hmm, I wonder what the performance of `let x = cast[array[4, uint8]](myUint32); return cast[uint32]([x[3], x[2], x[1], x[0]])` would be |
11:15:04 | giaco__ | got it. Thanks for your patience. I'm just dealing for the first time with memcopy and endianess, and I'm quite scratching my head |
11:15:27 | liblq-dev | you'll understand it in due time |
11:18:01 | giaco__ | back to the roots! https://developer.ibm.com/articles/au-endianc/#end |
11:23:30 | giaco__ | ok I got the point! Article says that endianess doesn't matter with c-style strings, so is just the uint32 layed in little-endian in my x86 memory and the copyMem is just reading it as-is |
11:29:15 | giaco__ | ok, so now I need to understand how to properly write the "toStringUsafe" in a endian independent way |
11:30:15 | giaco__ | where I need to swap bytes for ints larger than 8 on little-endian machines before copyMem into the string |
11:32:13 | liblq-dev | or just don't use copymem and use my solution above |
11:32:34 | liblq-dev | which always orders the bytes in little endian order |
11:32:37 | * | narimiran quit (Quit: leaving) |
11:36:24 | giaco__ | liblq-dev: but if I run your shr based solutions, would it work on big-endian architectures? There char(x and 0xff) would be the lsb so result[3]. I might be wrong, still wiring my head around this |
11:38:22 | giaco__ | or nim ints are always little endian no matter the undelying memory when not dealing with casts and other unsafe stuff? |
11:38:41 | liblq-dev | it will work no matter the architecture |
11:38:47 | liblq-dev | because shl works the same no matter the endianness |
11:41:27 | giaco__ | but "x and 0xff" would pick the LSB or MSB of the int depending on the arch endianess, or not? |
11:49:34 | liblq-dev | no |
11:49:42 | liblq-dev | bit operations don't care about endianness |
11:49:52 | liblq-dev | because it wouldn't make much sense |
11:50:19 | liblq-dev | they operate on the int as a whole, not individual bytes |
11:56:31 | giaco__ | that makes things easier. Thanks agains. I know I must look noob on this, but I've been working with high level languages all my life and now I have to unlearn to learn |
11:56:59 | liblq-dev | that's fine |
12:07:42 | giaco__ | liblq-dev: I'm not quite sure of anything. Still reversed with shr and bitmask solution not http://ix.io/2Was |
12:07:55 | giaco__ | omit last "not" |
12:08:03 | liblq-dev | because i'm saving it in little endian |
12:08:11 | liblq-dev | but it'll be little endian no matter what |
12:08:23 | liblq-dev | you can change it to big endian by reversing the indices |
12:08:32 | liblq-dev | in toStringUnsafe |
12:11:11 | PMunch | Well shit.. I tried to update and restart the playground.. Now I can't log back in |
12:24:26 | giaco__ | liblq-dev: my fault, did it with pen and paper and it is cristal clear now. Thanks for your patience again |
12:24:39 | liblq-dev | np |
12:26:46 | giaco__ | and also proper benchy now shows it is 3 times faster than toHex.parseHexStr, and also no unsafe stuff. great |
12:32:12 | giaco__ | with arc and -d:danger is almost 5 times faster |
12:47:18 | * | rockcavera joined #nim |
13:07:24 | * | NimBot joined #nim |
13:09:17 | * | hsh quit () |
13:32:32 | * | hsh joined #nim |
13:32:56 | FromDiscord | <madman> this proc is not available on the NimScript/js target; usage of 'existsOrCreateDir' is an {.error.} |
13:33:37 | FromDiscord | <madman> how to change nimscript target? 🤔 |
13:34:24 | PMunch | What do you mean change NimScript target? |
13:34:43 | * | haxscramper joined #nim |
13:35:32 | FromDiscord | <madman> sorry, why cant i use the os module in NimScript |
13:37:11 | PMunch | Because it's built around system calls that aren't available in the VM |
13:37:26 | PMunch | There are a couple options though IIRC |
13:37:31 | PMunch | What exactly are you trying to do? |
13:37:51 | FromDiscord | <madman> oh i see |
13:38:04 | FromDiscord | <madman> nothing just trying to create a dir if it doesnt exist |
13:38:25 | FromDiscord | <madman> maybe i should just use Nim and execute it from nimscript |
13:38:44 | PMunch | I mean it depends on what your actual use-case here is |
13:39:55 | FromDiscord | <madman> im building cross platform executables on win mac linux, i just want to create this directory and use it as outdir |
13:42:01 | PMunch | Ah I see, you might be able to use this: https://nim-lang.org/docs/nimscript.html#mkDir%2Cstring |
13:42:12 | PMunch | Along with `dirExists` |
13:43:03 | FromDiscord | <madman> oh why thank you |
13:43:39 | FromDiscord | <madman> can we give nimscript command line args? |
13:44:09 | PMunch | Yup |
13:44:36 | FromDiscord | <madman> oh cool |
13:55:10 | Amun_Ra | is there a way to get specific cause of "can have side effects" error? |
14:00:39 | * | rockcavera quit (Remote host closed the connection) |
14:03:45 | giaco__ | liblq-dev: there's one last thing I need to fix: I'm using the proc you suggested to turn a bytestring into an int "proc toInt*[T:SomeInteger](x: string): T = cast[ptr T](x[0].unsafeAddr)[]", and it correctly turns the byte array into the corresponding little-endian memory layout of the int (result.toHex prints the string backwards). What's the correct way to fix this? |
14:04:49 | * | PMunch quit (Quit: leaving) |
14:09:26 | liblq-dev | so using the cast method, you're actually reinterpreting the bytes in the string as if they were an int of native endianness |
14:09:42 | liblq-dev | giaco__: i suppose you're working with big endian data here? |
14:12:02 | * | birdspider joined #nim |
14:12:32 | * | liblq-dev < https://matrix.org/_matrix/media/r0/download/matrix.org/NAkcXCZcDzJOZrIqgUSrECNx/message.txt > |
14:12:41 | liblq-dev | this would be the proc then |
14:12:47 | liblq-dev | albeit it's quite inefficient |
14:12:58 | liblq-dev | changing the string to an openArray[char] would help |
14:13:52 | liblq-dev | as a string is implicitly convertible to that, plus you can actually slice a string using toOpenArray and that allows you to read from a specific offset in the string without making any copies or allocations |
14:15:00 | giaco__ | I would see some advantage only if I could slice it backwards, or not? |
14:21:45 | FromDiscord | <haxscramper> In reply to @Amun_Ra "is there a way": No, currently it is not possible to get the actual source of the side effect |
14:21:47 | * | birdspider quit (Quit: Leaving) |
14:24:26 | * | birdspider joined #nim |
14:31:12 | * | rockcavera joined #nim |
14:37:08 | * | inamannerofspeak quit (Ping timeout: 246 seconds) |
14:38:02 | * | Gustavo6046 joined #nim |
14:48:01 | stefantalpalaru | How do I override `cmp()` for a specific custom type? By redefining it directly, or do I need to define `==` and `<` instead? |
14:49:13 | FromDiscord | <Rika> you can redefine it directly if the original cmp function is a generic |
14:49:26 | stefantalpalaru | It is: https://nim-lang.org/docs/system.html#cmp%2CT%2CT |
14:50:19 | FromDiscord | <konsumlamm> ye, just overload it with a more specific type, functions using `cmp` will use the the most specific overload |
14:51:13 | stefantalpalaru | Thanks. |
14:51:43 | FromDiscord | <konsumlamm> although afaik most functions use `==` and `<` directly (which are not defined in terms of `cmp`), so it's better to overload those |
14:52:42 | * | haxscramper quit (Remote host closed the connection) |
14:53:08 | * | haxscramper joined #nim |
14:53:15 | * | haxscram` joined #nim |
15:01:12 | FromDiscord | <konsumlamm> @Tavon the difference to the range type (which is assume you mean by "every other aspect of the language") is that there, the bounds are always known at compile time (as opposed to only sometimes) and it's even more rare to have the type depend on some flags |
15:05:43 | FromDiscord | <Tavon> Yeah. Maybe only we could apply the check only on fully static set's ranges, to be 100% sure it's a mistake |
15:06:07 | FromDiscord | <Tavon> (edit) removed "only" |
15:15:59 | FromDiscord | <zetashift> Is there a way to see some more detailed information about compilation, e.g. time to compile of each file? I'm compiling a simple project with gdnim and it takes up to 1 minute for a full cold compile and I'm wondering what takes so long |
15:20:36 | * | inamannerofspeak joined #nim |
15:23:47 | FromDiscord | <DuckKing89> Hi, I tried to run my first nim program after installing it, but my mac terminal couldn't recognize the command 'nim' |
15:25:16 | FromDiscord | <DuckKing89> I created a directory .nimble/bin in my user folder for all the nim files, but maybe I wasn't supposed to do that |
15:26:45 | FromDiscord | <DuckKing89> the installation seemed to run smoothly in my terminal though... |
15:27:34 | FromDiscord | <haxscramper> Did you add `~/.nimble/bin` to your `$PATH`? Choosenim installer shows this message at the end of installation if I remember correctly. |
15:27:58 | * | birdspider left #nim ("Leaving") |
15:31:02 | FromDiscord | <DuckKing89> Ok I will do some research, I don't even know what $PATH means, even though I've seen it a couple of times. I'm not a very experienced programmer, dabbled in Objective-C, before trying Python for some months and now nim 🙂 |
15:33:22 | FromDiscord | <DuckKing89> Ok, I did echo $PATH and this came up "/Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin" |
15:42:53 | FromDiscord | <haxscramper> I'm not exactly sure how it is done on Mac, but you probably need to add something like `export PATH="$HOME/.nimble/bin:$PATH"` to `~/.bashrc` |
15:43:45 | * | Vladar quit (Remote host closed the connection) |
15:56:40 | FromDiscord | <TennisBowling> In reply to @haxscramper "I think someone linked": thanks! finally got it |
16:04:21 | ForumUpdaterBot | New thread by Quokka70: Migrating from v 1.0: "raise effects differ", see https://forum.nim-lang.org/t/7796 |
16:10:40 | * | beshr joined #nim |
16:19:29 | * | inamannerofspeak quit (Ping timeout: 265 seconds) |
16:21:38 | * | inamannerofspeak joined #nim |
16:38:15 | * | zedeus quit (Ping timeout: 260 seconds) |
16:38:33 | FromDiscord | <mlokis> what is up with all these bots sending messages for ppl? |
16:40:39 | leorize[m] | this channel is bridged to irc |
16:40:56 | leorize[m] | the bots you see are people in different platforms |
16:41:03 | * | zedeus joined #nim |
16:41:23 | FromDiscord | <Yardanico> In reply to @mlokis "what is up with": they are real people, and if you mean ForumUpdaterBot - it's a bot that posts new posts/threads/questions/packages etc from the forum/reddit/stackoverflow/nimble |
16:41:53 | FromDiscord | <mlokis> In reply to @Yardanico "they are real people,": yes i get that but why do they use bot user |
16:42:14 | FromDiscord | <Yardanico> they're not "using" that |
16:42:23 | FromDiscord | <Yardanico> Discord always shows all messages sent through webhooks as "bot" |
16:42:42 | FromDiscord | <mlokis> oh i see that answer i wos looking for |
16:43:07 | FromDiscord | <Yardanico> the bridge is https://github.com/Yardanico/ircord |
16:43:33 | FromDiscord | <mlokis> its not really casual thing |
16:44:15 | FromDiscord | <mlokis> In reply to @Yardanico "the bridge is https://github.com/Yardanico/ircord": now i see why |
16:45:14 | FromDiscord | <mlokis> just nobody knows about nim, how annoying |
16:46:27 | FromDiscord | <Yardanico> ??? |
16:55:08 | * | shmorgle joined #nim |
16:55:57 | FromDiscord | <mlokis> i mean considering how powerful the language is, there is very small community around it, browser sometimes associates nim with something else. It probably makes difference when there is company behind a language, compared to... volunteers i guess |
17:00:05 | * | conkker quit (Quit: The Lounge - https://thelounge.chat) |
17:00:23 | * | hnicke joined #nim |
17:03:39 | * | vicfred joined #nim |
17:04:45 | * | conkker joined #nim |
17:09:36 | * | hsh quit () |
17:12:07 | * | hnicke is now known as hnicke2 |
17:12:13 | * | hnicke2 is now known as hnicke |
17:12:35 | * | hsh joined #nim |
17:14:56 | * | hnicke quit (Quit: Connection closed) |
17:15:22 | * | hnicke joined #nim |
17:20:29 | FromDiscord | <Hi02Hi> well despite rust having companies backing it, there is a game with the name rust. i think the browser associated nim with something else because there is a game called nim as well |
17:21:11 | * | PMunch joined #nim |
17:21:29 | FromDiscord | <IDF(ardek66)> there are atleast two other significant things called nim, and search engines dont really favour names of short length |
17:22:45 | FromDiscord | <Yardanico> New Indented Modula |
17:24:03 | FromDiscord | <Hi02Hi> In reply to @ClassyIDF "there are atleast two": c ends up being so short its unique |
17:24:18 | FromDiscord | <IDF(ardek66)> thats true |
17:25:44 | FromDiscord | <Yardanico> In reply to @mlokis "i mean considering how": it also depends on the data collected by a search engine about you :) |
17:26:02 | FromDiscord | <Yardanico> if it knows that you like programming topics, it's more likely to give you nim (the language) over nim (the game) |
17:26:57 | PMunch | My biggest issue there is the IBM thing called Nim |
17:27:02 | FromDiscord | <mlokis> In reply to @Yardanico "if it knows that": yes i search almost only programming topics |
17:27:06 | PMunch | It's computer related so Google seems to struggle in telling them apart.. |
17:27:29 | FromDiscord | <IDF(ardek66)> yeah when i started learning nim i ended up reading a good part of the ibm nim thing until i realised they are totally different |
17:27:32 | PMunch | But the Nim game tends to go away after a while of searching for Nim the language related stuff |
17:27:41 | FromDiscord | <Yardanico> true |
17:28:14 | PMunch | Stream is live now by the way (sorry for the delay), today I'm doing I²C :D |
17:28:22 | PMunch | https://www.twitch.tv/pmunche |
17:31:02 | FromDiscord | <jtiai> sent a code paste, see https://play.nim-lang.org/#ix=2Wcl |
17:31:29 | FromDiscord | <IDF(ardek66)> why new |
17:31:38 | FromDiscord | <Yardanico> In reply to @jtiai "Trying to make some": you can't do "new result" |
17:31:43 | FromDiscord | <Yardanico> and don't need to, since it's not a ref type |
17:31:48 | FromDiscord | <Yardanico> just remove that line |
17:32:15 | FromDiscord | <Yardanico> also you should probably rename the proc from newSomeType to initSomeType :) |
17:32:30 | FromDiscord | <Yardanico> that's the nim "convention" - heap allocating types are created with newX, stack - initX |
17:33:12 | FromDiscord | <jtiai> stackoverflow bit me again 🙂 (note to myself: remember how crappy SO is) |
17:33:37 | FromDiscord | <jtiai> How do I know when things go to stack and when heap? |
17:34:19 | FromDiscord | <Yardanico> if you're dealing with strings/seqs/ref/new something then it's probably on heap |
17:34:44 | FromDiscord | <jtiai> well there will be seq. |
17:35:15 | FromDiscord | <jtiai> okay now I did get "no generic parameters allowed for SomeType"... |
17:38:09 | ForumUpdaterBot | New question by Joshua Cohen: Cube not appearing in OpenGL, see https://stackoverflow.com/questions/67113403/cube-not-appearing-in-opengl |
17:38:31 | FromDiscord | <Yardanico> In reply to @jtiai "okay now I did": what's your SomeType definition? |
17:39:58 | FromDiscord | <jtiai> sent a code paste, see https://play.nim-lang.org/#ix=2Wco |
17:42:15 | FromDiscord | <Yardanico> and what's the full error? |
17:42:53 | FromDiscord | <jtiai> sent a code paste, see https://play.nim-lang.org/#ix=2Wcp |
17:42:58 | FromDiscord | <dk> the code you posted compiles |
17:43:31 | FromDiscord | <jtiai> Ah bummer. Different file 😄 |
17:46:03 | FromDiscord | <jtiai> What's the difference between func and proc? I seem to use both without any knowledge is there a difference or not... |
17:47:27 | FromDiscord | <Yardanico> func is a proc with a {.noSideEffect.} pragma |
17:47:37 | FromDiscord | <Yardanico> https://nim-lang.org/docs/manual.html#pragmas-nosideeffect-pragma |
17:49:51 | hnicke | hey! maybe someone can help me out: https://forum.nim-lang.org/t/7798 |
17:50:42 | ForumUpdaterBot | New thread by Hnicke: Generic type parameters and inheritance, see https://forum.nim-lang.org/t/7798 |
17:51:22 | FromDiscord | <Yardanico> I'm not sure, but I don't think that generics works with inheritance like that |
17:59:05 | * | Vladar joined #nim |
18:00:29 | FromDiscord | <jtiai> sent a code paste, see https://play.nim-lang.org/#ix=2Wcy |
18:00:48 | FromDiscord | <Yardanico> again |
18:01:01 | FromDiscord | <Yardanico> it explicitly that it got seq[Memory] and ref Memory |
18:01:06 | FromDiscord | <Yardanico> Memory and ref Memory are two different types |
18:01:15 | FromDiscord | <Yardanico> you're trying to add ref Memory to Memory |
18:01:19 | FromDiscord | <jtiai> I tried to ref Memory but no change.. |
18:01:33 | FromDiscord | <jtiai> (edit) "I tried to ... refchange" added "change" | "change.." => "change in error.." |
18:02:13 | FromDiscord | <jtiai> sent a code paste, see https://play.nim-lang.org/#ix=2Wcz |
18:02:26 | FromDiscord | <Yardanico> did you have programming experience apart from nim? |
18:02:34 | FromDiscord | <jtiai> 37 years. |
18:02:36 | FromDiscord | <Solitude> bus should be var |
18:02:44 | FromDiscord | <jtiai> But bus is var... |
18:02:53 | FromDiscord | <Solitude> then its doomed |
18:03:17 | FromDiscord | <jtiai> sent a code paste, see https://play.nim-lang.org/#ix=2WcB |
18:03:55 | FromDiscord | <Solitude> kinda hard to deduce whats your problem by fishing for 1 line snippets from you |
18:04:52 | FromDiscord | <jtiai> sent a code paste, see https://play.nim-lang.org/#ix=2WcC |
18:05:16 | FromDiscord | <jtiai> sent a code paste, see https://play.nim-lang.org/#ix=2WcD |
18:05:37 | FromDiscord | <jtiai> sent a code paste, see https://play.nim-lang.org/#ix=2WcE |
18:05:49 | FromDiscord | <Solitude> sent a code paste, see https://play.nim-lang.org/#ix=2WcF |
18:06:12 | FromDiscord | <Solitude> https://nim-lang.org/docs/manual.html#procedures-var-parameters |
18:06:50 | FromDiscord | <jtiai> so I need to put var in front of everything? |
18:07:03 | FromDiscord | <Solitude> you need to put var in front of things you want to mutate |
18:07:06 | FromDiscord | <jtiai> And if it's not var it's something like let/const |
18:07:59 | FromDiscord | <0000> 37 years of experience in what? logo motion? |
18:08:56 | FromDiscord | <jtiai> various basic, various assembers, pascal, c/c++, mdl, smallworld magik, and lately python. |
18:09:04 | FromDiscord | <jtiai> https://nim-lang.org/docs/tut1.html#the-var-statement |
18:09:36 | FromDiscord | <jtiai> But that tutorial says I can put vars with indentation... |
18:09:48 | FromDiscord | <jtiai> like in my code. is tutorial wrong? |
18:09:58 | FromDiscord | <Yardanico> no, it's not wrong |
18:10:09 | * | lritter quit (Quit: Leaving) |
18:10:12 | FromDiscord | <Yardanico> it's just simplified so that _beginners_ can understand normal vars |
18:10:19 | FromDiscord | <Yardanico> you got a link to the manual explaining var in procedures |
18:10:36 | FromDiscord | <jtiai> I'm quite beginner of Nim. |
18:10:46 | FromDiscord | <Yardanico> in Nim all value types are immutable when passed to procedures/funcs (like in any other native language), you have to specify `var` if you want to modify the original |
18:10:49 | FromDiscord | <jtiai> I don't understand why tutorial doesn't work with my code. |
18:11:24 | FromDiscord | <jtiai> so its not about my variable definitions but my funcs/procs? |
18:11:29 | FromDiscord | <jtiai> and their arguments |
18:11:35 | FromDiscord | <Solitude> https://nim-lang.org/docs/manual.html#procedures-var-parameters |
18:12:38 | FromDiscord | <Yardanico> right now with your code `connectMemory` _copies_ Bus and all of its contents (including the seq of Memory, since seqs and strings are value types too) |
18:12:40 | FromDiscord | <Yardanico> same for connectIO |
18:12:49 | FromDiscord | <Yardanico> same for write/read |
18:12:56 | FromDiscord | <jtiai> so parameter by value. Right. |
18:13:02 | FromDiscord | <Yardanico> because it's a value type |
18:14:50 | FromDiscord | <jtiai> What's the convention for naming parameters that do conflict with built ins? |
18:15:48 | FromDiscord | <Yardanico> for example? |
18:15:48 | FromDiscord | <Solitude> naming them something else? |
18:16:05 | FromDiscord | <Solitude> if it has same name as keyword, pretty sure you can still use it |
18:16:10 | FromDiscord | <Yardanico> yes, just with stropping |
18:16:19 | FromDiscord | <Yardanico> and for things like `len` or similar in most cases it'll work anyway |
18:17:12 | FromDiscord | <Yardanico> but don't do that |
18:17:12 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=2WcK |
18:18:34 | FromDiscord | <jtiai> probably nim doesn't like my `addr` parameter name... |
18:19:11 | * | natrys quit (Ping timeout: 240 seconds) |
18:20:03 | FromDiscord | <Yardanico> that's a keyword |
18:20:21 | FromDiscord | <Yardanico> https://nim-lang.org/docs/manual.html#lexical-analysis-identifiers-amp-keywords |
18:20:24 | FromDiscord | <Yardanico> lists all keywords |
18:30:59 | * | natrys joined #nim |
18:44:40 | FromDiscord | <dom96> PMunch: you around? playground is down |
18:44:49 | PMunch | I know, but I can't SSH into it.. |
18:45:38 | PMunch | Oh wait, now it does |
18:46:23 | PMunch | Hmm, it appears to be running |
18:46:46 | PMunch | But it's updating the images (probably prompted by the 1.4.6 version) and cleaning up all the old ones takes a while.. |
18:47:15 | PMunch | It should be back to normal in a while, I hope |
18:47:22 | PMunch | I'll check on it when I'm done streaming |
18:47:26 | PMunch | @dom96 ^ |
18:49:49 | FromDiscord | <mlokis> doesn't stackowerflow recognize nim in markup |
18:49:57 | FromDiscord | <Yardanico> it doesn't |
18:51:10 | FromDiscord | <jtiai> sent a code paste, see https://play.nim-lang.org/#ix=2WcS |
18:53:04 | FromDiscord | <sealmove> well, is it it declared? :p |
18:53:45 | FromDiscord | <jtiai> sent a code paste, see https://play.nim-lang.org/#ix=2WcU |
18:54:09 | FromDiscord | <mlokis> nim does not even have a tag on overflow, jeez |
18:54:37 | FromDiscord | <mlokis> i have to get that reputation and create it, |
18:55:57 | FromDiscord | <Yardanico> In reply to @mlokis "nim does not even": it does lol |
18:56:16 | FromDiscord | <mlokis> how is it called? |
18:56:25 | FromDiscord | <mlokis> Nim? |
18:56:33 | FromDiscord | <Yardanico> or is this just mass hallucination https://media.discordapp.net/attachments/371759389889003532/832328557518389328/unknown.png |
18:56:35 | FromDiscord | <Yardanico> @mlokis nim-lang |
18:56:42 | FromDiscord | <Yardanico> https://stackoverflow.com/questions/tagged/nim-lang |
18:56:45 | FromDiscord | <mlokis> i see |
18:57:07 | FromDiscord | <Yardanico> but it's rarely used for Nim |
18:57:19 | FromDiscord | <Yardanico> since you're more likely to get an answer here or on the forum |
18:58:24 | ForumUpdaterBot | New question by Jakub Dóka: How to pass multiple code-blocks to template in nim?, see https://stackoverflow.com/questions/67114529/how-to-pass-multiple-code-blocks-to-template-in-nim |
18:58:32 | FromDiscord | <Yardanico> @mlokis are you Jakub^? |
18:58:35 | * | inamannerofspeak quit (Ping timeout: 246 seconds) |
18:58:38 | FromDiscord | <mlokis> yea i hed an idea to add some q&a for things that were paifull to figure out |
18:58:45 | FromDiscord | <Yardanico> but isn't that not allowed on SO |
18:58:57 | FromDiscord | <Yardanico> oh, apparently it is, okay |
18:59:11 | FromDiscord | <mlokis> yea they explicitly support it |
18:59:23 | FromDiscord | <Yardanico> i can spam hundreds of questions then if I wanted to :) |
18:59:50 | FromDiscord | <mlokis> even that can help if you give answers |
19:07:32 | FromDiscord | <sealmove> is the author of nimpy active here? |
19:08:33 | FromDiscord | <Solitude> barely, you have more chance catching him on forum |
19:09:37 | FromDiscord | <sealmove> Ok. I am having trouble with it because a py library I am loading uses overloaded operators which are not exposed to Nim. |
19:09:47 | FromDiscord | <sealmove> Or if they are, I don't know how to use them. |
19:10:22 | FromDiscord | <Yardanico> can you show a simple example for me to test? |
19:10:33 | FromDiscord | <Yardanico> i'm goot at bruteforcing solutions for things like that |
19:10:49 | FromDiscord | <sealmove> thanks! let me try |
19:11:00 | FromDiscord | <Yardanico> In reply to @รєคɭ๓๏שє "thanks! let me try": https://github.com/yglukhov/nimpy/issues/151 |
19:11:09 | FromDiscord | <Yardanico> there's an example |
19:11:31 | FromDiscord | <sealmove> oh, hmm, this might work |
19:12:54 | FromDiscord | <sealmove> wow!!! it works! |
19:14:14 | FromDiscord | <sealmove> thanks so much Yarda |
19:15:25 | FromDiscord | <sealmove> now the last thing I'd like to find a workaround for, is finding an equivalent of `` expansion |
19:16:56 | FromDiscord | <Yardanico> you mean args and/or kwargs? |
19:17:13 | FromDiscord | <Yardanico> @sealmove |
19:17:16 | FromDiscord | <Yardanico> and from which side to which |
19:18:05 | FromDiscord | <Yardanico> because there's https://github.com/yglukhov/nimpy/blob/master/tests/tnimfrompy.py#L10 https://github.com/yglukhov/nimpy/blob/master/tests/nimfrompy.nim#L12 |
19:18:28 | FromDiscord | <sealmove> `` instead of ``? |
19:22:10 | FromDiscord | <sealmove> um, I am noob in Python so not sure if it's args/kwargs. there is a method in python that accepts varargs, and I have the arguments i want to pass to it in an array. so instead of writing `theMethod(arr[0], arr[1], ...)` I want to expand them, because they are too many. In Python examples this is done like: `theMethod(arr)`. |
19:22:26 | FromDiscord | <sealmove> (edit) "an array." => "a seq." |
19:27:07 | * | inamannerofspeak joined #nim |
19:27:30 | * | hsh quit () |
19:29:22 | FromDiscord | <sealmove> In reply to @Yardanico "and from which side": from python to nim (in nim module) |
19:32:27 | * | inamannerofspeak quit (Ping timeout: 268 seconds) |
19:35:16 | * | justsomeguy joined #nim |
19:35:46 | * | inamannerofspeak joined #nim |
19:35:47 | * | hnicke quit (Quit: Connection closed) |
19:39:02 | FromDiscord | <sealmove> hmm nevermind, it seems to work now without using any operators for expanding the seq |
19:39:10 | FromDiscord | <sealmove> that's nice |
19:45:17 | * | rolha joined #nim |
19:51:41 | FromDiscord | <Mustache Man> are there other great books on Nim besides Nim In Action? |
19:54:06 | FromDiscord | <zetashift> Not really a book but I really liked: https://xmonader.github.io/nimdays/ as a follow up to NIA |
19:54:06 | FromDiscord | <Yardanico> there are no other "real" nim books (with ISBN and stuff) |
19:54:20 | FromDiscord | <Yardanico> there's http://ssalewski.de/nimprogramming.html |
19:54:39 | FromDiscord | <Yardanico> which focuses a bit more on the CS side of the things |
19:54:49 | FromDiscord | <Mustache Man> awesome, thank you both |
19:55:08 | FromDiscord | <Yardanico> generally check out https://nim-lang.org/documentation.html |
20:03:34 | FromDiscord | <jtiai> sent a code paste, see https://play.nim-lang.org/#ix=2Wdr |
20:04:19 | FromDiscord | <sealmove> because this is not how you construc tobjects |
20:04:34 | FromDiscord | <Yardanico> In reply to @jtiai "if I have constructor:": nim doesn't have "constructors" |
20:04:40 | FromDiscord | <Yardanico> newMemory is just a proc, and should be called as such |
20:04:48 | FromDiscord | <Yardanico> var ram = newMemory(...) |
20:05:58 | FromDiscord | <sealmove> sent a code paste, see https://play.nim-lang.org/#ix=2Wds |
20:06:04 | FromDiscord | <Yardanico> Memory |
20:06:06 | FromDiscord | <Yardanico> not newMemory :) |
20:06:10 | FromDiscord | <sealmove> (edit) "https://play.nim-lang.org/#ix=2Wds" => "https://play.nim-lang.org/#ix=2Wdt" |
20:06:14 | FromDiscord | <Yardanico> but he wants to use a his own proc in this case |
20:06:17 | FromDiscord | <Yardanico> (edit) removed "a" |
20:06:26 | FromDiscord | <sealmove> yeah, it's a common pattern in Nim |
20:07:25 | FromDiscord | <jtiai> makes sense because there is no actual oop either. |
20:07:58 | FromDiscord | <Yardanico> depends on what you mean by OOP |
20:08:04 | FromDiscord | <Yardanico> nim has inheritance and methods |
20:10:08 | FromDiscord | <jtiai> Sorry meant class based oop. (just happen to call it oop because it's been my dayjob last 25 years... 🙂 ) |
20:11:00 | * | inamannerofspeak quit (Ping timeout: 265 seconds) |
20:11:09 | * | haxscram` left #nim ("ERC (IRC client for Emacs 27.2)") |
20:13:57 | * | hsh joined #nim |
20:14:38 | FromDiscord | <zetashift> @haxscramper how is haxorg coming along? I was thinking about making a small org file viewer with fidget as a weekend, is there any low hanging fruit I can help with? |
20:14:39 | * | hsh quit (Client Quit) |
20:19:11 | FromDiscord | <zetashift> @jtiai Nim has " minimal" OOP support, fancy stuff can be implemented by macros: http://www.cross-code.com/en/home |
20:19:17 | FromDiscord | <haxscramper> In reply to @zetashift "<@!608382355454951435> how is haxorg": No, there are really no blockers except for lack of time. I'm considering rewriting parser implementation to use proper lexer, but everything else is pretty straightforward so you can just test it and report found bugs (or even try to fix them). That is for org-mode parser stuff |
20:19:18 | FromDiscord | <zetashift> https://github.com/bluenote10/oop_utils |
20:19:23 | FromDiscord | <zetashift> (edit) "macros: http://www.cross-code.com/en/home" => "macros" |
20:19:50 | FromDiscord | <haxscramper> I can already generate org-mode tree together with all drawers, headers etc. https://media.discordapp.net/attachments/371759389889003532/832349516438831134/unknown.png |
20:19:50 | FromDiscord | <Yardanico> oh, github updated previews |
20:19:59 | FromDiscord | <jtiai> sent a code paste, see https://play.nim-lang.org/#ix=2Wdw |
20:20:12 | FromDiscord | <zetashift> In reply to @Yardanico "oh, github updated previews": I didn't even notice, pretty cool |
20:20:14 | FromDiscord | <Yardanico> In reply to @jtiai "when I try to": you need to export the field if you're using it from a different file |
20:20:21 | FromDiscord | <Yardanico> all symbols/fields are private by default |
20:20:37 | FromDiscord | <jtiai> Good point. Forgot the asterisk. |
20:20:39 | FromDiscord | <zetashift> In reply to @haxscramper "No, there are really": I'll try to help whereever possible! |
20:21:26 | FromDiscord | <haxscramper> In reply to @haxscramper "I can already generate": But I got my attention evenly spread across haxorg/haxdoc/hcparse/hmisc(minor fixes) so I probably need to focus on the thing more and push it to some logical v0.1 |
20:21:38 | FromDiscord | <zetashift> There is also : https://github.com/gagbo/tree-sitter-org which might be interesting to look at |
20:21:49 | FromDiscord | <jtiai> Finally my cpu emulation basics is coming together. |
20:21:57 | FromDiscord | <zetashift> In reply to @haxscramper "But I got my": I get that, thanks for your time 😄 |
20:25:57 | FromDiscord | <haxscramper> In reply to @zetashift "There is also :": Yes, I've seen it (along with basically every other org-mode parser in existence), but most of them are only targeted at supporting subset of org-mode, and don't really try to improve it (like you can't have full words for priority cookies, only single `[#C]`aracter, or lack of good old `#hashtags`). Also no attention to embedded source code evaluation and support for external tools usually |
20:28:07 | FromDiscord | <zetashift> Those are very hard problems to solve, no? |
20:28:16 | FromDiscord | <haxscramper> No, they are trivial |
20:29:40 | FromDiscord | <jtiai> Can I cast `var foo = Foo()` to `ref Foo` somehow? |
20:29:53 | FromDiscord | <haxscramper> In reply to @zetashift "Those are very hard": This gets a little more involved when I add single lexer (that is why I'm still considering whether this has to be done or not), but overall this is just https://github.com/haxscramper/haxorg/blob/17b05663a430c37a931bf8a7bf7e49a895be34e9/src/haxorg/parser.nim#L728 |
20:30:05 | FromDiscord | <Yardanico> In reply to @jtiai "Can I cast `var": you're trying to do it the wrong way |
20:30:12 | FromDiscord | <Yardanico> if you want a ref type, you can just do var foo = new Foo() |
20:30:13 | FromDiscord | <Yardanico> if Foo is a type |
20:30:44 | FromDiscord | <jtiai> That's what I thought too. |
20:30:53 | FromDiscord | <zetashift> In reply to @haxscramper "This gets a little": ah I see |
20:30:57 | FromDiscord | <Yardanico> you have some really weird ref/non-ref mixing in your code @jtiai |
20:31:04 | FromDiscord | <Yardanico> not sure why |
20:31:08 | FromDiscord | <dom96> PMunch: according to Cloudflare it's been like this since 11am |
20:31:22 | FromDiscord | <jtiai> Because it has evolved over last few days. |
20:31:27 | FromDiscord | <dom96> anyway, why does rebuilding the images just freeze it? |
20:31:31 | FromDiscord | <jtiai> And based mostly on my knowledge how to do that in C(++) |
20:32:30 | FromDiscord | <haxscramper> In reply to @zetashift "<@!608382355454951435> how is haxorg": Though for it is probably won't be ready for "org file viewer" unless you just need the AST for org-mode. If that is the case it is available already (though I found out I need to push the new version because of some broken dependencies) |
20:35:14 | FromDiscord | <zetashift> From the AST I can just decide what to render right? |
20:35:36 | FromDiscord | <jtiai> Also I do have less than 20 hours experience with nim so gets a while to be proficient. |
20:37:14 | FromDiscord | <Yardanico> In reply to @jtiai "Also I do have": sorry for such an impolite question, but I'm just curious - how old are you? |
20:39:04 | FromDiscord | <jtiai> Only 46 :) |
20:40:33 | FromDiscord | <haxscramper> In reply to @zetashift "From the AST I": Correct. There is a "raw" AST https://github.com/haxscramper/haxorg/blob/master/src/haxorg/ast.nim which only contains document structure (mostly implemented, only bugs & missing features should be added) and "semchecked" AST that is still mostly in design stage (https://github.com/haxscramper/haxorg/blob/master/src/haxorg/semorg.nim). I'm still considering some smaller implementation details |
20:41:08 | FromDiscord | <haxscramper> > only bugs & missing features should be added↵only bugs should be fixed & missing features added |
20:41:18 | FromDiscord | <zetashift> In reply to @haxscramper "Correct. There is a": Sweet a lot seems done already |
20:48:07 | PMunch | @dom96, sorry just got done streaming |
20:48:21 | PMunch | It's been buggy for a couple of days now |
20:49:07 | PMunch | Started two days ago I think, then I upgraded it and it worked for a while until the new release came out I guess.. |
20:49:38 | PMunch | Rebuilding the image shouldn't freeze it. But docker prune seems to lock up all docker activity until it is done |
20:50:02 | PMunch | And docker isn't very good at cleaning up all these small containers that the playground is creating, so when it's starting to clean it takes a while |
20:53:11 | FromDiscord | <zetashift> In reply to @jtiai "Also I do have": I mapped C#/Python semantics to Nim a lot when I started, try to let it go a bit then things become clear |
20:55:05 | FromDiscord | <zetashift> Also I found this also very enlightening: https://peterme.net/nim-types-originally-a-reddit-reply.html |
21:02:21 | FromDiscord | <jtiai> I just try to apply all my expertise I have. And it helps because when I started programming there wasn't websites... :) those came much later. |
21:18:04 | FromDiscord | <ElegantBeef> Prestige have you got nimscripter working for your bot, dont recall if you told me the progression? |
21:22:32 | FromDiscord | <clyybber> @timotheecour Are you still on gitter mostly? We have a #nim-internals channel on IRC/Discord; it's not briged to gitter right now (maybe it should, but gitter seems dying)? |
21:22:37 | * | haxscramper quit (Remote host closed the connection) |
21:22:39 | FromDiscord | <clyybber> (edit) "dying)?" => "dying)" |
21:26:35 | Prestige | @ElegantBeef sorry haven't gotten to it, been busy. Might be trying it out soon |
21:38:16 | * | inamannerofspeak joined #nim |
21:40:38 | PMunch | @dom96, I seem to have broken it completely now. Disabled the docker and cron services so it wouldn't get stuck in the update script. Then I rebooted, but now it doesn't seem to come back online.. |
22:06:51 | * | inamannerofspeak left #nim (#nim) |
22:09:29 | * | pbb quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.) |
22:10:25 | * | pbb joined #nim |
22:15:04 | * | Vladar quit (Quit: Leaving) |
22:37:25 | * | clyybber quit (Quit: WeeChat 3.1) |
22:55:26 | kinkinkijkin | hmm, is there a way to make a seq the length of another quickly? |
22:55:41 | kinkinkijkin | without just iterating .add() in a loop |
22:57:42 | FromDiscord | <ElegantBeef> `seq.setLen` |
23:00:01 | kinkinkijkin | thx |
23:00:23 | * | audiophile joined #nim |
23:00:46 | audiophile | hi anyone know if a package exists for wrapping anki? like the spaced repetition thingy |
23:00:51 | audiophile | nimble search says no |
23:27:24 | PMunch | Ugh, I need to get some sleep before work tomorrow. The playground is still rebuilding the containers, so it won't be back online until tomorrow |
23:27:33 | * | PMunch quit (Quit: leaving) |
23:43:43 | * | abm joined #nim |
23:48:35 | FromDiscord | <Sabena Sema> does the `static T` = `static[T]` syntax only work with `static`? |
23:53:11 | * | natrys quit (Ping timeout: 240 seconds) |
23:53:38 | * | natrys joined #nim |
23:53:48 | * | natrys quit (Client Quit) |
23:54:11 | federico3 | https://www.reddit.com/r/embedded/comments/mr9uxx/highlevel_language_for_embedded_systems_that_is/ |