00:05:35 | * | jaz80 joined #nim |
00:07:38 | jaz80 | Newbie question. Is there a way to reference an array instead of copy it by value? I would like: let a = [1, 2, 3]; var b = a; b[0] = 42; to also affect `a`'s memory. |
00:11:13 | FromDiscord | <ElegantBeef> `a.unsafeAddr` would let you get a's pointer |
00:11:57 | FromDiscord | <ElegantBeef> `addr` and `unsafeaddr` are both considered "unsafe" though |
00:12:06 | jaz80 | any safe way like rust? |
00:12:30 | jaz80 | or i guess most other languages that have arrays |
00:13:35 | FromDiscord | <ElegantBeef> Well you made a an `let` which means you can only mutate it unsafely |
00:13:46 | jaz80 | assuming that both were var, then |
00:13:48 | FromDiscord | <ElegantBeef> (edit) "Well you made ... a" added "'a'" | removed "an" |
00:15:39 | disruptek | why aren't you using a ref? |
00:18:04 | jaz80 | mostly because i'm a newbie and the official tutorial only talks about them in the context of a custom type declaration. not sure how to use them for arbitrary variables |
00:18:21 | disruptek | ah. refs are nim's managed (safe) pointers. |
00:18:24 | disruptek | ~memory |
00:18:24 | disbot | memory: 11The Nim memory model: https://zevv.nl/nim-memory/ |
00:19:04 | * | qwertfisch quit (Ping timeout: 272 seconds) |
00:19:14 | jaz80 | so how to create a reference to an an arbitrary array variable's memory outside of a `type` definition ? |
00:19:29 | jaz80 | i'll read that, thanks |
00:20:50 | disruptek | you cannot create a ref to something that is not a ref; the whole idea is that it's managed. |
00:21:04 | disruptek | if you want to do it unsafely, you can use a pointer. |
00:21:05 | * | beatmox quit (Quit: ZNC 1.8.0 - https://znc.in) |
00:21:51 | FromDiscord | <ElegantBeef> Well you can do this hideousness https://play.nim-lang.org/#ix=2Jkq |
00:21:59 | disruptek | you can have an array of refs, of course, in which case you can share the values (references) as much as you want. |
00:22:36 | disruptek | that's two refs to the same array. |
00:23:24 | FromDiscord | <ElegantBeef> Yea i know |
00:24:45 | * | krux02 quit (Remote host closed the connection) |
00:24:47 | FromDiscord | <ElegantBeef> Guess with expirmental views we can do this https://play.nim-lang.org/#ix=2Jks |
00:26:28 | FromDiscord | <ElegantBeef> The less silly version i guess would just do `b: var a.typeOf = a` |
00:33:33 | FromDiscord | <InventorMatt> jaz80: you could also try this https://play.nim-lang.org/#ix=2Jku |
00:34:59 | FromDiscord | <ElegantBeef> I always forget byaddr exists |
00:38:25 | FromDiscord | <no name fits> π just joined. Was considering doing a renderer in Nim |
00:42:20 | FromDiscord | <ElegantBeef> Hello |
00:48:05 | * | beatmox joined #nim |
00:49:39 | * | qwertfisch joined #nim |
00:54:28 | * | qwertfisch quit (Ping timeout: 268 seconds) |
01:21:29 | * | jaz80 quit (Remote host closed the connection) |
01:26:50 | * | Tanger joined #nim |
01:35:42 | * | qwertfisch joined #nim |
01:40:29 | FromDiscord | <sealmove> is there a way to export fields with the `export` statement? |
01:40:43 | * | qwertfisch quit (Ping timeout: 268 seconds) |
01:41:40 | voltist | @mratsim Ping |
01:42:42 | * | qwertfisch joined #nim |
01:51:43 | * | hnOsmium0001 joined #nim |
01:58:30 | * | matlock quit (Quit: Connection closed for inactivity) |
02:08:46 | * | tiorock joined #nim |
02:08:46 | * | tiorock quit (Changing host) |
02:08:46 | * | tiorock joined #nim |
02:08:46 | * | rockcavera is now known as Guest82066 |
02:08:46 | * | tiorock is now known as rockcavera |
02:12:17 | * | Guest82066 quit (Ping timeout: 265 seconds) |
02:13:04 | * | qwertfisch quit (Ping timeout: 260 seconds) |
02:14:17 | FromDiscord | <shadow.> if i wanted to pack a 4-bit int and another 4-bit int into a char side by side, would `((i1 shl 4) or i2).char` work? |
02:15:01 | FromDiscord | <sealmove> what type are your `i1` and `i2` vars? |
02:15:12 | FromDiscord | <sealmove> you probably want to mask them before anything |
02:15:22 | FromDiscord | <shadow.> well they're going to be bytes, but they won't need more than 4 bits |
02:15:42 | FromDiscord | <shadow.> `type == byte` |
02:16:13 | FromDiscord | <sealmove> if you are sure the upper 4 bits are clear then your code will work, but it's always safe to mask explicitely |
02:18:39 | FromDiscord | <shadow.> kk |
02:19:01 | FromDiscord | <sealmove> `import bitops; (i1.masked(0 .. 3) shl 4) or masked(i2, 0 .. 3)` |
02:19:19 | FromDiscord | <shadow.> thanks |
02:19:26 | FromDiscord | <ElegantBeef> I've never seen anyone space the range like that π |
02:19:59 | FromDiscord | <sealmove> i space all operators :P |
02:20:25 | FromDiscord | <ElegantBeef> So you do `arr[ index ]`:P |
02:20:34 | FromDiscord | <sealmove> ok not all :P |
02:20:35 | FromDiscord | <shadow.> or arr [ index ] |
02:22:11 | FromDiscord | <shadow.> f ( a ) ; |
02:22:16 | FromDiscord | <shadow.> (edit) ") ;" => ");" |
02:22:18 | FromDiscord | <shadow.> lol |
02:22:41 | FromDiscord | <shadow.> is there a way to do that mask without the bitops import? |
02:22:45 | FromDiscord | <shadow.> like using and or something |
02:22:51 | FromDiscord | <sealmove> dunno `1..<3` is cute but i find `1 ..< 3` easier to read |
02:23:31 | FromDiscord | <ElegantBeef> Yea you can shadow it's `il or 0xe` afaik |
02:23:40 | FromDiscord | <ElegantBeef> (edit) "or" => "and" |
02:23:47 | FromDiscord | <sealmove> shadow sure, just do `((i1 and 0x0F) shl 4) or (i2 and 0x0F)` |
02:24:04 | FromDiscord | <shadow.> is that just 4 bit limit? |
02:24:05 | FromDiscord | <ElegantBeef> `0xe` being `15` which should be all the first bits high |
02:24:18 | * | qwertfisch joined #nim |
02:24:28 | FromDiscord | <ElegantBeef> f |
02:24:30 | FromDiscord | <ElegantBeef> yes it's f |
02:24:31 | FromDiscord | <ElegantBeef> π |
02:24:58 | FromDiscord | <ElegantBeef> Guess i forgot 0 existed |
02:25:33 | FromDiscord | <sealmove> i spend too much time with binary these days >_< |
02:25:37 | FromDiscord | <ElegantBeef> Also shadow how is `scantuple`? π |
02:25:51 | FromDiscord | <shadow.> lol i tried it |
02:25:56 | FromDiscord | <sealmove> scantuple? |
02:26:11 | FromDiscord | <shadow.> how's sequtils in prelude? π |
02:26:35 | FromDiscord | <ElegantBeef> scantuple is a macro wrapper for `scanf` that makes it so you dont have to predeclare variables |
02:27:03 | FromDiscord | <ElegantBeef> https://nim-lang.github.io/Nim/strscans.html#scanTuple.m%2Cuntyped%2Cstatic%5Bstring%5D%2Cvarargs%5Buntyped%5D |
02:27:04 | FromDiscord | <shadow.> it's quite spicy |
02:27:25 | FromDiscord | <shadow.> the only one of my pr's that has been accepted added like 10 characters |
02:27:26 | FromDiscord | <shadow.> feelsbadman |
02:27:45 | FromDiscord | <ElegantBeef> My colourise PR is now green on tests π |
02:28:01 | FromDiscord | <sealmove> sweet |
02:28:01 | FromDiscord | <ElegantBeef> So just a few things and it might be accpted |
02:28:21 | FromDiscord | <shadow.> welp my integer compressor is done |
02:28:37 | FromDiscord | <shadow.> sent a code paste, see https://play.nim-lang.org/#ix=2Jl1 |
02:28:39 | FromDiscord | <shadow.> compresses ints in strings to 50% size |
02:28:45 | FromDiscord | <shadow.> lol |
02:28:56 | FromDiscord | <shadow.> as long as string.len mod 2 == 0 |
02:29:03 | FromDiscord | <shadow.> wouldnt be hard to make it work for odds too |
02:29:33 | FromDiscord | <ElegantBeef> what's with the - 48? |
02:29:45 | FromDiscord | <sealmove> but this does not compress ints, it compresses strings |
02:29:45 | FromDiscord | <shadow.> 48 == '0'.ord |
02:29:46 | FromDiscord | <ElegantBeef> `- '0'.ord.byte` |
02:29:54 | FromDiscord | <shadow.> yeah it compresses strings that are ints |
02:30:00 | FromDiscord | <shadow.> it can only do strrings with only digits tho |
02:30:06 | FromDiscord | <shadow.> bc digits only really need 4 bits |
02:30:09 | FromDiscord | <shadow.> rather than the full 8 used in a char |
02:30:19 | FromDiscord | <shadow.> like for instance this could store pi in a txt at 50% size |
02:30:29 | FromDiscord | <ElegantBeef> guess you can just do `'0'.byte` π |
02:30:36 | FromDiscord | <shadow.> yeah that works too |
02:30:43 | FromDiscord | <shadow.> or '0'.ord |
02:30:48 | FromDiscord | <sealmove> sounds unuseful π |
02:30:57 | FromDiscord | <ElegantBeef> It very much is |
02:30:58 | FromDiscord | <shadow.> lmaooo |
02:31:04 | FromDiscord | <ElegantBeef> We've got `zippy` now |
02:31:09 | FromDiscord | <shadow.> i mean how else am i gonna store my pi txt at 50% size π |
02:31:22 | FromDiscord | <sealmove> there are many better ways |
02:31:27 | FromDiscord | <shadow.> i know its sarcasm |
02:31:30 | FromDiscord | <shadow.> im just doing it to learn bitops |
02:31:33 | FromDiscord | <Quibono> Haters gonna hate |
02:31:39 | FromDiscord | <ElegantBeef> I hate that phrase |
02:31:49 | FromDiscord | <Quibono> Said like a real hater. |
02:32:09 | FromDiscord | <shadow.> !eval echo 0b1111 |
02:32:09 | FromDiscord | <ElegantBeef> Well that phrase is used to deflect actual criticism into a "they're just haters" |
02:32:12 | NimBot | 15 |
02:32:16 | FromDiscord | <shadow.> 15 i see |
02:32:20 | FromDiscord | <shadow.> nice |
02:32:28 | FromDiscord | <shadow.> ohhh i get how that works now |
02:32:34 | FromDiscord | <ElegantBeef> lol |
02:32:49 | FromDiscord | <shadow.> bit and 1 preserves bit, so anything higher than those first 4 1 bits is masked out |
02:32:54 | FromDiscord | <shadow.> ensuring that it fits in 4 bits? |
02:32:56 | FromDiscord | <ElegantBeef> yes |
02:32:59 | FromDiscord | <shadow.> smat |
02:33:00 | FromDiscord | <shadow.> smart |
02:33:09 | FromDiscord | <ElegantBeef> shart |
02:33:11 | FromDiscord | <shadow.> shut |
02:33:19 | FromDiscord | <shadow.> what shall i name the decompress function |
02:33:20 | FromDiscord | <shadow.> hmm |
02:33:26 | FromDiscord | <shadow.> uncrush or inflate |
02:33:26 | FromDiscord | <shadow.> lol |
02:33:48 | FromDiscord | <ElegantBeef> doubleSize |
02:33:51 | FromDiscord | <shadow.> lmao |
02:33:56 | FromDiscord | <shadow.> makeReadable() |
02:34:01 | FromDiscord | <shadow.> englishify() |
02:34:16 | FromDiscord | <ElegantBeef> Englishify is the name of my IP -> sentence idea |
02:34:41 | FromDiscord | <ElegantBeef> instead of numbers use a LUT with 255 words to make ip's more human readable |
02:34:50 | FromDiscord | <ElegantBeef> (edit) "instead of numbers use a LUT with 255 ... words" added " 4" |
02:35:24 | FromDiscord | <ElegantBeef> Dont mention ipv6 |
02:35:28 | FromDiscord | <shadow.> if i say "first bit" does that refer to the leftmost or rightmost one |
02:35:36 | FromDiscord | <shadow.> (in a byte, not considering endianess) |
02:35:41 | FromDiscord | <ElegantBeef> Depends on if the system is big endianess |
02:35:46 | FromDiscord | <shadow.> even inside the byte? |
02:35:51 | FromDiscord | <sealmove> shadow it depends |
02:35:53 | FromDiscord | <shadow.> i thought endianess was for multiple bytes |
02:35:55 | FromDiscord | <ElegantBeef> No |
02:35:58 | FromDiscord | <shadow.> oh |
02:36:05 | FromDiscord | <ElegantBeef> Endianness is counting from left or right π |
02:36:08 | FromDiscord | <shadow.> ahh i see |
02:36:25 | FromDiscord | <sealmove> there is byte endianness and bit endianness, though bit endianness is quite uncommon, and most of the time we consider the first bit to be the leftmost one. |
02:36:28 | FromDiscord | <shadow.> i mean little ended processers have the little bit at the end, is that at the right |
02:36:30 | FromDiscord | <shadow.> oh |
02:36:32 | FromDiscord | <shadow.> hm |
02:36:41 | FromDiscord | <shadow.> so first bit is at the left aka front aka most significant place |
02:36:46 | FromDiscord | <ElegantBeef> See i count the first bit the furthest right due to our number system |
02:36:54 | FromDiscord | <ElegantBeef> Where the least significant value is the furthest right |
02:37:11 | FromDiscord | <shadow.> if i wanted to get the 4 leftmost bits out of a byte would i just do byte shr 4? |
02:37:51 | FromDiscord | <sealmove> depends on context actually. when you do `x.masked(0 .. 1)` it means "mask the 2 rightmost bits. |
02:37:59 | FromDiscord | <shadow.> yeah |
02:37:59 | FromDiscord | <ElegantBeef> `byte and 0xf0 shr 4` gets the upper half, and `byte and 0xf` gets the lower |
02:38:08 | FromDiscord | <shadow.> hmm i see |
02:38:14 | FromDiscord | <sealmove> yes |
02:38:23 | FromDiscord | <shadow.> why do you have to mask before shifting? |
02:38:28 | FromDiscord | <ElegantBeef> You dont |
02:38:30 | FromDiscord | <shadow.> wont they be yeeted out the end anyways |
02:38:33 | FromDiscord | <shadow.> lmfao |
02:38:35 | FromDiscord | <ElegantBeef> i just do it cause of the way i work |
02:38:38 | FromDiscord | <shadow.> fair |
02:38:40 | FromDiscord | <shadow.> i love my scientific terms |
02:38:45 | FromDiscord | <shadow.> "yeeted out the end" |
02:39:33 | * | qwertfisch quit (Ping timeout: 272 seconds) |
02:39:58 | FromDiscord | <ElegantBeef> Also if you havent noticed in hex `f` means that nibble is full of 1s |
02:40:17 | FromDiscord | <ElegantBeef> hence 15 π |
02:40:28 | FromDiscord | <sealmove> bits are confusing. in parsing the "first" bit is (usually) the leftmost, but when we refer to them as imaginary indices, we count from right to left (probably because of our number system as ElegantBeef said). |
02:40:34 | FromDiscord | <shadow.> yeah |
02:40:51 | FromDiscord | <shadow.> like if you "get the nth bit" bit 0 is typically the rightmost one on little ended processors right? |
02:41:14 | FromDiscord | <shadow.> sent a code paste, see https://play.nim-lang.org/#ix=2Jl4 |
02:41:22 | FromDiscord | <shadow.> lol |
02:41:27 | FromDiscord | <sealmove> shadow, bit endianness has nothing to do with processors |
02:41:37 | FromDiscord | <shadow.> oh lol |
02:41:42 | FromDiscord | <sealmove> processors only know about byte endianness |
02:41:43 | FromDiscord | <shadow.> what's it determined by? |
02:41:43 | FromDiscord | <ElegantBeef> I guess yea parsing the bits are typically considered in a left to right manner due to how our language is left to right |
02:41:47 | FromDiscord | <shadow.> ohhh |
02:41:59 | FromDiscord | <sealmove> it's just terminology, used differently depending on context |
02:42:03 | FromDiscord | <shadow.> fair enough |
02:44:13 | FromDiscord | <sealmove> not just that, when we say for example "next 14 bits", we want to think of them as continues |
02:45:15 | FromDiscord | <sealmove> with little bit endianness we would parse like this:β΅8 7 6 5 4 3 2 1 - - 14 13 12 11 10 9 |
02:45:38 | FromDiscord | <sealmove> while with big endianness:β΅1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
02:45:51 | FromDiscord | <ElegantBeef> and with end endianessβ΅0 |
02:48:44 | * | a_chou joined #nim |
02:49:55 | FromDiscord | <shadow.> lol |
02:58:43 | * | qwertfisch joined #nim |
03:00:35 | FromDiscord | <shadow.> from now on instead of `x = 0` im just doing `x = x shr 64` |
03:00:54 | FromDiscord | <shadow.> lmao |
03:02:02 | FromDiscord | <Rika> what |
03:03:47 | * | beatmox quit (Ping timeout: 260 seconds) |
03:06:06 | * | beatmox joined #nim |
03:06:14 | FromDiscord | <ElegantBeef> `int.high.div 0` is the better way |
03:06:26 | FromDiscord | <sealmove> why not `x = x xor x` :P |
03:07:01 | FromDiscord | <sealmove> "the classic way" |
03:10:50 | * | beatmox quit (Ping timeout: 264 seconds) |
03:11:31 | * | beatmox joined #nim |
03:11:36 | FromDiscord | <Rika> int.high.div (x (x - x) |
03:11:48 | FromDiscord | <Rika> ) |
03:11:51 | FromDiscord | <Rika> left a parens |
03:14:42 | FromDiscord | <shadow.> wait that xor is smart lol |
03:17:05 | FromDiscord | <Rika> please dont do that |
03:18:30 | FromDiscord | <shadow.> its a joke |
03:18:35 | FromDiscord | <shadow.> i am being sarcastic lmao |
03:19:33 | FromDiscord | <shadow.> why not do `x = cast[array[1, int]]((x shl 64) xor (x shl 64))[0]` |
03:19:47 | FromDiscord | <shadow.> (edit) "shl" => "shr" | "shl" => "shr" |
03:22:25 | FromDiscord | <Rika> cast[int](nil) |
03:22:35 | FromDiscord | <Rika> (i do not actually know what this does...) |
03:22:52 | FromDiscord | <Rika> !eval echo cast[int](nil) |
03:22:55 | NimBot | 0 |
03:22:59 | FromDiscord | <Rika> lol |
03:23:57 | Prestige | I guess it assumes the default int value if given invalid input? |
03:24:22 | Prestige | !eval echo cast[string](nil) |
03:24:25 | NimBot | <no output> |
03:24:33 | Prestige | Empty string |
03:25:25 | FromDiscord | <Quibono> sent a code paste, see https://play.nim-lang.org/#ix=2Jle |
03:26:10 | FromDiscord | <Rika> needs more data, that doesnt give much info |
03:26:57 | FromDiscord | <Quibono> sent a code paste, see https://play.nim-lang.org/#ix=2Jlf |
03:27:28 | FromDiscord | <Rika> cannot await outside of an async proc |
03:27:34 | FromDiscord | <Quibono> aaaaaaah |
03:27:38 | FromDiscord | <Quibono> Right |
03:27:38 | FromDiscord | <Rika> use waitfor instead if you need to do so |
03:29:54 | FromDiscord | <Quibono> Thank you. Async always messes me up |
03:31:14 | * | beatmox quit (Ping timeout: 264 seconds) |
03:32:04 | FromDiscord | <Rika> takes a while to get used to it |
03:38:38 | * | qwertfisch quit (Ping timeout: 258 seconds) |
03:41:57 | * | qwertfisch joined #nim |
03:53:52 | voltist | What's the best way to get the size (in bits) of the int type? |
03:54:31 | FromDiscord | <Rika> sizeof(int) 8 |
03:54:33 | FromDiscord | <Rika> ? |
03:56:22 | FromDiscord | <Rika> voltist do you mean size consumed by the int or min size needed for the number to be represented properly |
03:57:02 | * | muffindrake quit (Ping timeout: 258 seconds) |
03:59:23 | * | muffindrake joined #nim |
04:00:45 | voltist | Mean size yeah |
04:00:52 | voltist | So sizeof should do it, right? |
04:01:02 | FromDiscord | <ElegantBeef> It returns byte size |
04:01:21 | voltist | x8 :) |
04:01:34 | FromDiscord | <Rika> yup thats what i said |
04:02:34 | voltist | `*8`? Interesting it didn't render like that on my IRC client |
04:03:19 | voltist | Thanks for the help |
04:03:27 | * | beatmox joined #nim |
04:03:50 | FromDiscord | <shadow.> yeah asterisks get murdered along the dangerous irc bridge |
04:04:29 | * | rockcavera quit (Remote host closed the connection) |
04:05:03 | * | qwertfisch quit (Ping timeout: 272 seconds) |
04:07:41 | FromDiscord | <Rika> lmao |
04:07:45 | FromDiscord | <Rika> yardanicooooooooooooooo |
04:07:49 | FromDiscord | <Rika> fix thy bridge |
04:08:26 | * | beatmox quit (Ping timeout: 264 seconds) |
04:23:46 | disruptek | it's pointless to ask. |
04:24:05 | FromDiscord | <Rika> i know π¦ |
04:26:03 | disruptek | you should take it over. |
04:29:20 | voltist | Anyone want to judge my bloom filter implementation? |
04:29:21 | voltist | https://play.nim-lang.org/#ix=2Jlu |
04:30:46 | Prestige | Is the bridge open source? |
04:32:59 | FromDiscord | <ElegantBeef> !repo ircord |
04:33:00 | disbot | https://github.com/Yardanico/ircord -- 9ircord: 11Discord <-> IRC bridge in Nim 15 12β 2π΄ |
04:34:18 | * | narimiran_ joined #nim |
04:36:17 | FromDiscord | <Rika> i would if i had my programming keyboard, im suffering without it |
04:47:05 | FromDiscord | <ElegantBeef> Is your programming keyboard a powerglove modified to be a keyboard? |
04:50:39 | * | spiderstew_ quit (Ping timeout: 272 seconds) |
04:51:03 | * | spiderstew joined #nim |
04:55:48 | * | a_chou quit (Quit: a_chou) |
05:03:36 | FromDiscord | <Rika> lol |
05:03:49 | * | Tanger quit (Remote host closed the connection) |
05:15:49 | Prestige | having to use a laptop or something? |
05:18:47 | * | not_lum joined #nim |
05:20:02 | * | bozaloshtsh quit (Ping timeout: 260 seconds) |
05:20:02 | * | sirn quit (Ping timeout: 260 seconds) |
05:20:12 | * | bozaloshtsh joined #nim |
05:20:12 | * | bozaloshtsh quit (Changing host) |
05:20:12 | * | bozaloshtsh joined #nim |
05:20:37 | * | l1x quit (Ping timeout: 260 seconds) |
05:20:37 | * | hpyc9 quit (Ping timeout: 260 seconds) |
05:20:52 | * | hpyc9 joined #nim |
05:22:05 | * | sirn joined #nim |
05:22:22 | * | lum quit (Ping timeout: 260 seconds) |
05:23:17 | * | l1x joined #nim |
05:23:42 | * | qwertfisch joined #nim |
05:26:17 | FromDiscord | <Rika> yeah im on a laptop |
05:36:44 | FromDiscord | <ElegantBeef> Rika just be productive and add the import path to modules docgen π |
05:51:53 | FromDiscord | <Rika> lost me at import |
05:53:40 | FromDiscord | <ElegantBeef> lol |
05:54:11 | FromDiscord | <ElegantBeef> for all modules a `import std/with` for instance should be added to the docgen for using it |
05:55:29 | FromDiscord | <Rika> did i suddenly regress in english comprehension skills or is that sentence incomprehensible |
05:57:10 | FromDiscord | <shadow.> ditto |
06:00:49 | FromDiscord | <ElegantBeef> Here we go for the third time destroying english. All docs generated for modules should have a import path(`import std/with` for the with module) added to the top of the file |
06:02:56 | FromDiscord | <Rika> full (aka std/ for all std modules and pkg/ for all third party)? |
06:03:09 | FromDiscord | <Rika> sounds difficult to implement |
06:04:22 | FromDiscord | <ElegantBeef> Yea |
06:04:51 | FromDiscord | <ElegantBeef> I briefly looked at docgen and went "hmmm, i dont see anything making sense here" |
06:05:18 | FromDiscord | <Rika> then no thanks |
06:06:13 | FromDiscord | <ElegantBeef> Yea i'll probably look at it after my colourise gets accepted |
06:45:08 | FromDiscord | <Cohjellah> Hey guys, why does asyncnet require the termination of mesages through .send to end with \c\l |
06:45:16 | FromDiscord | <Cohjellah> doesn't make sense to me, can't find anything in the docs |
06:46:53 | FromDiscord | <Rika> \c\l == \r\n |
06:50:43 | * | beatmox joined #nim |
06:56:24 | FromDiscord | <Cohjellah> yeeep |
06:56:29 | FromDiscord | <Cohjellah> figured that out now ahaha. |
07:16:52 | * | fowl quit (Read error: Connection reset by peer) |
07:17:08 | * | kwilczynski quit (Read error: Connection reset by peer) |
07:17:38 | * | sirn quit (Read error: Connection reset by peer) |
07:18:34 | * | sirn joined #nim |
07:18:58 | * | kwilczynski joined #nim |
07:19:04 | * | saem quit (Remote host closed the connection) |
07:20:07 | * | fowl joined #nim |
07:50:16 | FromDiscord | <Cohjellah> Just have a problem surrounding a terminal chat app. When client A receives a message from client B, whilst client B is typing his own message, the echo on client B will print everything they're writing, as well as the new message |
07:50:40 | FromDiscord | <Cohjellah> So they'll have to rewrite there message, and it gets ugly |
07:50:51 | FromDiscord | <Cohjellah> Soz |
07:50:53 | FromDiscord | <Cohjellah> Other way around |
07:51:00 | FromDiscord | <Cohjellah> Client B receives message from client A |
07:51:11 | FromDiscord | <Cohjellah> (edit) "A" => "B" | "B," => "A," |
07:51:26 | FromDiscord | <ElegantBeef> Store the currently written characters, clear the line, write the recieved characters then print the users input without a `\n` then carry on |
07:53:19 | FromDiscord | <Cohjellah> That's what I want to do |
07:53:23 | FromDiscord | <Cohjellah> But I'm not sure how |
07:53:35 | FromDiscord | <Cohjellah> Tried used readline but it wait for the user to press enter |
07:53:48 | FromDiscord | <Cohjellah> readAll didn't do anything |
07:54:18 | FromDiscord | <Cohjellah> Also not sure how to print the stored temp message back into the terminal enter spot... Whatever that's called |
07:56:48 | FromDiscord | <ElegantBeef> if you use `getCh` to get the current input you can add it to a buffer, then do all the logic i mentioned |
07:56:52 | FromDiscord | <ElegantBeef> No clue if there is a better way |
07:59:58 | FromDiscord | <ElegantBeef> Ah there is `eraseLine` |
08:03:45 | FromDiscord | <Cohjellah> GetCh hey? |
08:03:46 | FromDiscord | <Cohjellah> Okay |
08:03:54 | FromDiscord | <Cohjellah> How do I add that back to the input line? |
08:04:24 | FromDiscord | <ElegantBeef> you do `stdout.write(ch)` and store it into input |
08:05:19 | FromDiscord | <ElegantBeef> This isnt an amazing example but https://play.nim-lang.org/#ix=2Jna |
08:08:56 | FromDiscord | <Cohjellah> Hey, Thank you |
08:09:00 | FromDiscord | <Cohjellah> Wishing you a merry Christmas |
08:10:08 | Zevv | too soon |
08:10:09 | Zevv | too early |
08:10:22 | FromDiscord | <Rika> its literally christmas eve tho :ThonkDumb: |
08:12:00 | FromDiscord | <Cohjellah> Lmao too soon |
08:12:34 | FromDiscord | <ElegantBeef> But yea hopefully you understand that you'll need to use the ascii form of keyboard inputs for things like deleting and the like |
08:12:59 | FromDiscord | <ElegantBeef> And getch blocks, so... you need to implement your own quite for `3.char` |
08:13:10 | FromDiscord | <ElegantBeef> Well blocks the input from the terminal i mean |
08:14:07 | FromDiscord | <ElegantBeef> own quit |
08:15:31 | * | tane joined #nim |
08:21:05 | FromDiscord | <CodeHz> question:β΅Is it possible to implement method in dynlib(so/dll), and call it in main application? I tried but seems the dynamic dispatching is not working |
08:27:01 | FromDiscord | <ElegantBeef> Are you making the dynlib aswell? |
08:29:32 | * | habamax joined #nim |
08:34:01 | FromDiscord | <CodeHz> Yes, I want to use dll as plugin |
08:56:20 | FromDiscord | <mratsim> Nim methods need to know all existing method for dynamic dispatch, so you can't add an override to methods exposed in a DLL. |
08:56:40 | * | hnOsmium0001 quit (Quit: Connection closed for inactivity) |
08:56:53 | FromDiscord | <mratsim> you need to have a base object with callbacks instead that you override. Aka, Do your Own Vtable. |
08:58:10 | FromDiscord | <mratsim> in general dynamic dispatch doesn't exist in C and a DLL requires a C compatible ABI. |
09:01:01 | * | fowl quit (Ping timeout: 268 seconds) |
09:01:34 | * | kwilczynski quit (Read error: Connection reset by peer) |
09:01:54 | * | sirn quit (Read error: Connection reset by peer) |
09:02:56 | * | fowl joined #nim |
09:03:01 | * | kwilczynski joined #nim |
09:03:59 | * | sirn joined #nim |
09:09:17 | * | sirn quit (Ping timeout: 260 seconds) |
09:11:02 | FromDiscord | <Cohjellah> Uhh so yeah confused by getch because it gets a single character? Why does it block? |
09:11:06 | FromDiscord | <Cohjellah> 3.char? |
09:15:41 | FromDiscord | <ElegantBeef> it doesnt block, it doesnt give the terminal the characters |
09:15:51 | FromDiscord | <ElegantBeef> `3.char` is `ctrl + c` |
09:16:28 | FromDiscord | <ElegantBeef> If you want to see all ascii chars and their shortcut https://theasciicode.com.ar/ascii-control-characters/backspace-ascii-code-8.html |
09:19:41 | * | klaufir_ joined #nim |
09:20:01 | * | tane quit (Quit: Leaving) |
09:20:53 | * | sirn joined #nim |
09:23:55 | * | Tanger joined #nim |
09:25:01 | FromDiscord | <ElegantBeef> @Cohjellah https://play.nim-lang.org/#ix=2Jnv here is a more complete example |
09:25:39 | FromDiscord | <Cohjellah> Ok I'll have a play around and see what's up |
09:25:41 | FromDiscord | <Cohjellah> Cheers! |
09:30:49 | * | habamax quit (Ping timeout: 246 seconds) |
09:32:27 | FromDiscord | <Cohjellah> So, if a message is received, can I loop to get all the getch characters? |
09:32:33 | FromDiscord | <Cohjellah> How does it actually work |
09:32:56 | FromDiscord | <Cohjellah> Looking at the example I'm a bit confused |
09:33:01 | FromDiscord | <ElegantBeef> So the whole while loop would be the client |
09:33:13 | FromDiscord | <ElegantBeef> when you type a `c` it's like getting a message |
09:33:38 | FromDiscord | <ElegantBeef> So when you pull your socket you'd call onrecieved if you get a message and pass it that string |
09:33:44 | FromDiscord | <ElegantBeef> (edit) "pull" => "poll" |
09:35:08 | FromDiscord | <Cohjellah> I see. You are making this more complex than I was thinking but it's good to know all these extra commands and cases |
09:35:16 | FromDiscord | <Cohjellah> Just in case I want it to be fancy |
09:35:53 | FromDiscord | <ElegantBeef> It's gotta be a tad bit more complex |
09:36:54 | FromDiscord | <Cohjellah> Hahaha not at this point. I literally just want to read what's typed in the input line |
09:37:24 | FromDiscord | <Cohjellah> That's all. Do I have to change my main loop to store each character that is typed? |
09:37:42 | * | Arrrrrrrr joined #nim |
09:37:43 | FromDiscord | <Cohjellah> Surely there's an easy way to just get all the characters on the input line |
09:38:07 | FromDiscord | <Cohjellah> (edit) "easy" => "easier" |
09:38:57 | FromDiscord | <ElegantBeef> You might be able to find the last line of characters |
09:39:51 | FromDiscord | <Cohjellah> Oh so will I have to print what is written to the terminal, read that line, delete it and then re add it to the input line? |
09:41:23 | FromDiscord | <Cohjellah> HMMM |
09:46:25 | FromDiscord | <ElegantBeef> You might be able to read the stdout, but i'm uncertain if it'd be possible considering there isnt an end of line char afaik |
09:49:16 | FromDiscord | <Cohjellah> How is a new line created then? |
09:49:27 | FromDiscord | <Cohjellah> There's no \n at the end of each terminal line? |
09:54:06 | FromDiscord | <ElegantBeef> Not a clue π |
10:09:24 | * | superbia joined #nim |
10:12:00 | FromDiscord | <CodeHz> Oh, that's sounds reasonable, so I'm going to create a nimble package for create rust-style trait and impl for my purpose... |
10:14:59 | FromDiscord | <ElegantBeef> Is that... sarcasm? π |
10:21:20 | FromDiscord | <haxscramper> !repo nimtraits |
10:21:20 | disbot | https://github.com/haxscramper/nimtraits -- 9nimtraits: 11Automatic trait implementation for nim types 15 4β 0π΄ |
10:21:47 | FromDiscord | <haxscramper> The idea was absolutely pointless, but API for implementing custom traits is here |
10:21:59 | FromDiscord | <haxscramper> Wrote it |
10:22:00 | FromDiscord | <haxscramper> never used |
10:22:03 | FromDiscord | <haxscramper> Never needed to |
10:22:26 | FromDiscord | <CodeHz> (I mean dyn trait ( generate vtable in callsite |
10:23:12 | FromDiscord | <haxscramper> Well, that is what this library is supposed to be used - more convenient API for custom trait implementation |
10:24:02 | FromDiscord | <haxscramper> Though if you need single vtable trait it would be easier to just implement it manually, yes |
10:24:38 | FromDiscord | <haxscramper> https://github.com/haxscramper/hax-nim/tree/master/wraptests/callback_override and this one might be interesting if you need to override implementation of things in DLL - quite hacky, but should work |
10:24:41 | FromDiscord | <haxscramper> In theory |
10:27:13 | FromDiscord | <CodeHz> (Oh, I'm not going to compatible with c++ vtable, just pure nim |
10:30:40 | * | narimiran_ is now known as narimiran |
10:30:49 | FromDiscord | <CodeHz> so the basic idea is create two macro to generate left side code, it seems not to hard https://media.discordapp.net/attachments/371759389889003532/791613846745251840/unknown.png |
10:34:30 | FromDiscord | <CodeHz> BTW, will the `=destrory` be called if it defined in the dynlib (wrapped as `ref RootObj`) ? |
10:35:25 | * | krux02 joined #nim |
10:56:44 | FromDiscord | <mratsim> good question for an `object`, a `ref RootObj` cannot have a destructor unless they are now syntax sugar for finalizers? |
10:57:21 | FromDiscord | <mratsim> that's the longterm plan but I don't remember if =destroy is equivalent to a finalizer already |
10:58:28 | FromDiscord | <CodeHz> oh, it will call destructor https://media.discordapp.net/attachments/371759389889003532/791620800897482762/unknown.png |
10:58:32 | FromDiscord | <CodeHz> but crashed |
10:59:32 | FromDiscord | <CodeHz> https://gist.github.com/codehz/18dfd092a5f318bbf13472f046da6661 |
10:59:59 | FromDiscord | <CodeHz> (edit) "https://gist.github.com/codehz/18dfd092a5f318bbf13472f046da6661 ... " added " If it got confirm, I will create a bug report (" |
11:00:06 | FromDiscord | <CodeHz> (edit) "confirm," => "confirmed," |
11:05:26 | FromDiscord | <CodeHz> ps: also crash if X contains another ref object like string |
11:05:59 | FromDiscord | <CodeHz> (edit) "ps: also crash ... ifno" added "even" | "X contains another ref object like string" => "no `=destroy` defined" |
11:12:18 | FromDiscord | <CodeHz> (edit) so the basic idea is create two macro to generate left side code, it seems not too hard https://media.discordapp.net/attachments/371759389889003532/791613846745251840/unknown.png |
11:31:29 | FromDiscord | <Recruit_main707> Iβm not sure, but you might be mixing vars and refs, try making your destroy proc argument a var ref X instead |
11:36:36 | FromDiscord | <Recruit_main707> And also make your create function return X, and define it in the other file |
11:38:29 | FromDiscord | <Recruit_main707> Itβs also weird that it prints destroy, since the function is not exported nor imported |
11:42:53 | FromDiscord | <CodeHz> sent a code paste, see https://play.nim-lang.org/#ix=2Jo0 |
11:43:05 | FromDiscord | <CodeHz> (compiling with --gc:arc |
11:43:31 | FromDiscord | <CodeHz> I think the problem is they use different heap for allocate.. |
11:43:44 | FromDiscord | <CodeHz> (edit) "allocate.." => "allocate and deallocate.." |
11:44:05 | FromDiscord | <Recruit_main707> iirc arc has a shared heap |
11:44:24 | FromDiscord | <CodeHz> but they don't shared across dll |
11:44:45 | * | habamax joined #nim |
11:44:46 | FromDiscord | <CodeHz> (and nimrtl doesn't work for arc/orc |
11:47:42 | * | rockcavera joined #nim |
11:47:56 | FromDiscord | <CodeHz> if -d:useNimRtl https://media.discordapp.net/attachments/371759389889003532/791633249507999764/unknown.png |
11:49:28 | FromDiscord | <mratsim> report it |
11:51:11 | FromDiscord | <CodeHz> I'm going to repro it with devel branch |
11:52:57 | FromDiscord | <sealmove> sent a code paste, see https://play.nim-lang.org/#ix=2Jo4 |
11:53:38 | FromDiscord | <sealmove> Is `=>` used in some languages for pattern matching? I think I've seen it. |
11:53:53 | FromDiscord | <CodeHz> (I prefer `of` |
11:55:02 | FromDiscord | <sealmove> sent a code paste, see https://play.nim-lang.org/#ix=2Jo5 |
11:56:37 | FromDiscord | <sealmove> I am asking what `->` and `=>` do in languages so I can pick the most natural one |
11:58:51 | FromDiscord | <CodeHz> wait, what is ParserName |
11:59:13 | FromDiscord | <CodeHz> (edit) sent a code paste, see https://play.nim-lang.org/#ix=2Jo0 |
11:59:33 | FromDiscord | <CodeHz> (edit) (compiling with --gc:arc without -d:useMalloc |
11:59:45 | FromDiscord | <CodeHz> a type? |
12:00:18 | FromDiscord | <sealmove> not exactly, it's a tuple of 2 procs, but in the macro I use it to get to a type |
12:00:34 | FromDiscord | <CodeHz> I think fieldName should be placed in left side of `:` ... |
12:01:07 | FromDiscord | <sealmove> yes I see why you would say so, but my whole DSL does it the other way |
12:01:18 | FromDiscord | <CodeHz> ok |
12:03:45 | FromDiscord | <Vindaar> for the "braces are superior" crowd: Just read about this bug in the C++ code base of some colleagues π€£ https://i.imgur.com/AuyqGbw.png |
12:11:42 | FromDiscord | <exelotl> lol |
12:12:17 | FromDiscord | <mratsim> @zevv https://media.discordapp.net/attachments/371759389889003532/791639377842929664/unknown.png |
12:12:30 | FromDiscord | <mratsim> https://www.youtube.com/watch?v=YrrUCSi72E8&lc=UgzbMFTogM9PZRbU7xF4AaABAg |
12:21:00 | FromDiscord | <mratsim> and @dom96 and disruptek ^, still watching but it starts like it could be madnatory to watch the first few minutes to understand the RFC |
12:39:56 | * | Arrrrrrrr quit (Ping timeout: 256 seconds) |
12:48:33 | ForumUpdaterBot | New thread by Sdmcallister: Is anyone using duckdb with Nim?, see https://forum.nim-lang.org/t/7285 |
12:50:33 | * | Arrrrrrrr joined #nim |
13:22:37 | FromDiscord | <whisperdev> Where can I test regexes for Nim regex implementation? |
13:26:07 | FromDiscord | <exelotl> @whisperdev looks like nim-regex is available in the playground |
13:28:42 | * | superbia quit (Quit: WeeChat 3.0) |
13:29:44 | FromDiscord | <dom96> Lots of interesting discussions here https://news.ycombinator.com/item?id=25520353 |
13:31:03 | FromDiscord | <dom96> Including the assertion that tokio is slow at multi threading. So itβs being used in single threaded workloads specifically |
13:34:02 | FromDiscord | <whisperdev> i was thinking about online tester. https://play.nim-lang.org/#ix=2JoD |
13:34:17 | FromDiscord | <whisperdev> Should not this capture everything after !v_ ? |
13:34:37 | * | dilawar_uchiha[m joined #nim |
13:34:56 | FromDiscord | <Rika> Aren't you looking for match and not split |
13:36:39 | FromDiscord | <whisperdev> No split |
13:40:37 | ForumUpdaterBot | New thread by 19: Nim Seqs to C backend, see https://forum.nim-lang.org/t/7286 |
13:43:59 | * | NimBot joined #nim |
13:45:56 | FromGitter | <gogolxdong> Is there any alternative to Channel of Nim? |
13:53:28 | Q-Master | Hi all. I've got a question: I see that the default async implementation has futures not cancelable. So if i fail or complete any future the underlying proc will be kept on eventloop and complete to work. https://play.nim-lang.org/#ix=2Jof |
13:53:34 | Q-Master | Is this normal? |
13:56:13 | FromGitter | <gogolxdong> How about async pipe of chronos? |
14:27:48 | FromDiscord | <Deleted User 5bd78114> Heya everyone! I'm wonderinv if.i should write a small wrapper around a Nim YAML parser to use in Python, is that a good idea or should i just stick to using Python's normal YAML parser? I was thinking of implementing some C functions with Nim anyway |
14:47:19 | mipri | in general, Nim's fine for making little shared objects for other languages to load through C FFI, especially with the non-GC options. |
14:47:34 | mipri | for Python specifically, 'nimpy' might be useful. |
14:48:06 | FromDiscord | <Deleted User 5bd78114> Yeah that's what i thought |
14:48:31 | FromDiscord | <Deleted User 5bd78114> But if i used Nimpy with the ARC gc? Would anything happen? |
14:51:46 | leorize | nothing bad should happen |
14:52:31 | leorize | since python's memory and Nim's memory is not directly shared (as in Python don't control Nim's (de)allocation), any gc would work |
14:53:11 | FromDiscord | <Deleted User 5bd78114> Thanks! |
14:57:35 | * | abm joined #nim |
15:04:39 | FromDiscord | <Recruit_main707> Iβm not sure if nimpy supports arc yet |
15:04:45 | ForumUpdaterBot | New thread by QMaster: Cancelation points in async, see https://forum.nim-lang.org/t/7287 |
15:06:01 | * | ex_nihilo quit (Quit: Leaving) |
15:15:10 | FromDiscord | <Quibono> Great way to find out |
15:28:55 | * | Vladar joined #nim |
15:34:50 | ForumUpdaterBot | New thread by Archnim: ToBin, see https://forum.nim-lang.org/t/7288 |
15:38:11 | FromDiscord | <CodeHz> so https://github.com/codehz/nim-vtable |
15:39:38 | FromDiscord | <Recruit_main707> Looks great |
15:41:22 | FromDiscord | <krisppurg> is there a way to set proc aliases? |
15:44:49 | FromDiscord | <haxscramper> `let aliased = yourProc` or `const aliased = yourProc` |
15:45:25 | FromDiscord | <haxscramper> `yourProc` should not be overloaded though, maybe there is an alternative that doesn't suffer from this limitation |
16:04:52 | * | muffindrake quit (Ping timeout: 260 seconds) |
16:05:03 | * | leorize quit (Ping timeout: 240 seconds) |
16:06:37 | * | muffindrake joined #nim |
16:07:16 | * | leorize joined #nim |
16:11:54 | FromDiscord | <krisppurg> I don't know if I'm either having a mandela effect, but I swore there was an alias pragma |
16:21:19 | FromDiscord | <shadow.> if you need it overloaded maybe just template it |
16:26:52 | * | narimiran quit (Ping timeout: 268 seconds) |
16:28:08 | * | abm quit (Quit: Leaving) |
16:30:17 | ForumUpdaterBot | New question by SyTax: I installed Nim without any problem, but it gives me this error, what should I do?, see https://stackoverflow.com/questions/65440902/i-installed-nim-without-any-problem-but-it-gives-me-this-error-what-should-i-d |
16:46:53 | FromDiscord | <CosmicLivest> because in the nim compiler it tells me that the permission is denied. |
16:50:16 | * | xet7 quit (Quit: Leaving) |
16:55:10 | * | xet7 joined #nim |
17:10:16 | * | letto quit (Ping timeout: 240 seconds) |
17:10:27 | * | letto joined #nim |
17:18:51 | disruptek | dom96: recent tokio is much faster. |
17:27:01 | * | natrys joined #nim |
17:39:55 | * | a_chou joined #nim |
18:05:36 | * | habamax quit (Ping timeout: 272 seconds) |
18:22:27 | * | lf_ joined #nim |
18:22:50 | FromDiscord | <PizzaFox> hello |
18:22:54 | FromDiscord | <PizzaFox> i am here to complain about nim js generation again |
18:23:18 | FromDiscord | <PizzaFox> sent a code paste, see https://play.nim-lang.org/#ix=2Jqc |
18:23:20 | FromDiscord | <PizzaFox> note the `new Array(ln)` |
18:23:34 | FromDiscord | <PizzaFox> this creates a holey array, which the v8 engine is very very bad at dealing with efficiently |
18:28:38 | * | lf_ quit (Remote host closed the connection) |
18:32:15 | disruptek | what do you propose? |
18:32:50 | disruptek | also, where can we read about holey arrays? |
18:33:49 | disruptek | !repo nodejs |
18:33:50 | disbot | https://github.com/juancarlospaco/nodejs -- 9nodejs: 11NodeJS Standard Library for Nim 15 39β 1π΄ 7& 4 more... |
18:33:55 | disruptek | may be of interest to you. |
18:36:47 | FromDiscord | <PizzaFox> i am making a pr to fix that one instance |
18:37:19 | * | a_chou quit (Quit: a_chou) |
18:43:25 | FromDiscord | <shadow.> how do you accomplish complex numbers in nim |
18:43:41 | FromDiscord | <shadow.> kind of like python's j |
18:43:53 | FromDiscord | <PizzaFox> https://github.com/nim-lang/Nim/pull/16461 |
18:43:54 | disbot | β₯ Avoid creating a holey array in makeNimstrLit for JS target |
18:44:01 | FromDiscord | <PizzaFox> https://nim-lang.org/docs/complex.html |
18:44:14 | FromDiscord | <shadow.> thank you |
18:48:17 | disruptek | pizzafox: do you have a link to some holey array info? |
18:48:47 | FromDiscord | <PizzaFox> there's a link to v8 in there |
18:48:48 | FromDiscord | <PizzaFox> 1 sec |
18:48:59 | FromDiscord | <PizzaFox> https://v8.dev/blog/elements-kinds#packed-vs.-holey-kindsβ΅> V8 makes this distinction because operations on packed arrays can be optimized more aggressively than operations on holey arrays. For packed arrays, most operations can be performed efficiently. In comparison, operations on holey arrays require additional checks and expensive lookups on the prototype chain. |
18:49:21 | FromDiscord | <shadow.> is there an easier way to "toggle" an item in a set other than `if n in s: s.excl n else: s.incl n` |
19:00:11 | * | hnOsmium0001 joined #nim |
19:00:55 | FromDiscord | <shadow.> also, for anyone doing aoc this is a good read |
19:00:56 | FromDiscord | <shadow.> https://www.redblobgames.com/grids/hexagons/ |
19:01:54 | Arrrrrrrr | Maybe cast it to int (or whatever) and neg it |
19:02:08 | FromDiscord | <shadow.> wdym? |
19:02:31 | FromDiscord | <shadow.> wdym neg it lol |
19:02:51 | * | leorize quit (Remote host closed the connection) |
19:03:26 | Arrrrrrrr | cast[set[whatever]](not(cast[byte](mySet))) in case it is 1 byte sized |
19:03:27 | * | leorize joined #nim |
19:03:58 | FromDiscord | <sealmove> nimx vs fidget? |
19:05:30 | * | rockcavera quit (Remote host closed the connection) |
19:16:00 | disruptek | fidget |
19:16:26 | FromDiscord | <shadow.> hmm |
19:16:30 | FromDiscord | <shadow.> this is with a hashset |
19:16:33 | FromDiscord | <shadow.> nvm its fine |
19:17:18 | Zevv | interesting that there have not been any "hard" problems on aoc this year |
19:17:21 | Arrrrrrrr | Oh, for some reason I thought you wanted to flip completely a set |
19:17:26 | Zevv | some were tedious, some needed some insight |
19:17:54 | Zevv | but not like the one with finding the closest 2 starts in a 3D space |
19:18:39 | disruptek | pizzafox: if i'm reading this correctly, this is not a holey array. |
19:19:03 | FromDiscord | <PizzaFox> explain |
19:19:09 | disruptek | we create a new array of the given length. is it not initialized with values? |
19:19:24 | FromDiscord | <PizzaFox> no |
19:19:26 | FromDiscord | <PizzaFox> its filled with |
19:19:36 | FromDiscord | <PizzaFox> empty items |
19:19:38 | FromDiscord | <PizzaFox> not undefine |
19:19:39 | FromDiscord | <PizzaFox> (edit) "undefine" => "undefined" |
19:19:41 | FromDiscord | <PizzaFox> e m p t y |
19:19:49 | disruptek | okay, you're right, then. |
19:19:59 | FromDiscord | <PizzaFox> sent a code paste, see https://play.nim-lang.org/#ix=2Jqm |
19:20:26 | disruptek | yeah; i never write raw js anymore. π |
19:20:55 | FromDiscord | <shadow.> yeahh |
19:20:59 | FromDiscord | <shadow.> today's was really easy for part one actually |
19:21:01 | FromDiscord | <shadow.> and part two seems doable |
19:21:13 | FromDiscord | <shadow.> zevv: does part two start with the flips from part one? |
19:21:17 | FromDiscord | <shadow.> or am i being dumb |
19:21:57 | Zevv | yeah, it's just life on a hex grid |
19:22:13 | Zevv | and if you choose your coordinate system wisely, it's pretty straightforward |
19:22:14 | FromDiscord | <shadow.> fair enough |
19:22:16 | FromDiscord | <shadow.> i mean |
19:22:22 | FromDiscord | <shadow.> i used the doubles horizontal system |
19:22:25 | Zevv | https://www.redblobgames.com/grids/hexagons/ |
19:22:28 | FromDiscord | <shadow.> yup |
19:22:40 | FromDiscord | <shadow.> sent a long message, see http://ix.io/2Jqn |
19:22:47 | Zevv | I happened to know the trick; did the cube coords |
19:22:53 | Zevv | makes it pretty trivial |
19:22:54 | FromDiscord | <shadow.> does the doubles not work for part two? |
19:23:01 | FromDiscord | <shadow.> bc it worked for part one fine |
19:23:10 | Zevv | sure it does |
19:23:12 | FromDiscord | <shadow.> kk |
19:23:14 | FromDiscord | <shadow.> then my logic is just bad |
19:23:35 | Zevv | but the life game exceeds the original tiles, your floor is infinite |
19:23:49 | Zevv | so you need to iterate all of your current board, plus some |
19:24:00 | FromDiscord | <shadow.> yep |
19:24:02 | FromDiscord | <shadow.> im just iterating like |
19:24:08 | FromDiscord | <shadow.> x -100..100 and y -100..100 |
19:24:15 | FromDiscord | <shadow.> i tried expanding it more and same answer so i assumed it worked |
19:24:15 | FromDiscord | <shadow.> LMAO |
19:24:17 | FromDiscord | <shadow.> https://play.nim-lang.org/#ix=2Jqo |
19:24:27 | FromDiscord | <shadow.> so something other than my tile flipping and grid size |
19:29:19 | FromDiscord | <ElegantBeef> Psh shadow using a table for a LUT π https://play.nim-lang.org/#ix=2Jqp |
19:30:25 | FromDiscord | <shadow.> i needa index by string tho dont i? |
19:30:31 | FromDiscord | <ElegantBeef> Why? |
19:30:34 | FromDiscord | <shadow.> bc im parsing |
19:30:38 | FromDiscord | <ElegantBeef> `parseEnum` |
19:30:41 | FromDiscord | <shadow.> well |
19:30:43 | FromDiscord | <shadow.> whats wrong w using a table |
19:30:46 | FromDiscord | <shadow.> lol |
19:30:59 | FromDiscord | <ElegantBeef> Nothing aside from it's slower π |
19:31:47 | FromDiscord | <shadow.> fair enough |
19:32:02 | FromDiscord | <shadow.> ill figure out why part two isnt working then i can do it lol |
19:32:11 | FromDiscord | <ElegantBeef> I never deal with strings |
19:32:15 | FromDiscord | <ElegantBeef> Too ugly π |
19:32:59 | * | blueberrypie quit (Quit: Ping timeout (120 seconds)) |
19:33:14 | FromDiscord | <shadow.> fair enough |
19:33:18 | * | blueberrypie joined #nim |
19:38:20 | disruptek | that's how i feel about blondes. |
19:38:46 | Arrrrrrrr | heh |
19:40:16 | FromDiscord | <ElegantBeef> When i said that and there wasnt an instant comment i figured you werent around |
19:42:26 | disruptek | i'm not as rotund as yourself, but that doesn't mean i'm not waiting to pounce on the subtlest double-entendre. |
19:43:00 | disruptek | my bandwidth is devoted to git right now. |
19:43:53 | FromDiscord | <shadow.> figured out my issue |
19:43:58 | FromDiscord | <shadow.> i did {2..6} instead of {3..6} |
19:44:01 | FromDiscord | <shadow.> one of my many issues |
19:44:05 | FromDiscord | <ElegantBeef> inclusive ranges |
19:44:12 | FromDiscord | <shadow.> yep |
19:44:14 | FromDiscord | <shadow.> well no |
19:44:19 | FromDiscord | <shadow.> just me being dumb |
19:44:25 | FromDiscord | <shadow.> bc every range is bottom inclusive |
19:44:26 | FromDiscord | <shadow.> even non-nim |
19:44:47 | FromDiscord | <ElegantBeef> I've never used ranges outside nim, so sure |
19:44:54 | FromDiscord | <notchris> merry xmas eve all |
19:45:02 | FromDiscord | <ElegantBeef> Hello totally not chris |
19:45:24 | FromDiscord | <notchris> heyyyo the most elegant of beefs |
19:46:44 | FromDiscord | <shadow.> fuck it works on the test input but not on my input |
19:46:50 | FromDiscord | <shadow.> this means my world is over |
19:49:05 | FromDiscord | <notchris> @shadow. it ended a long time ago |
19:49:10 | FromDiscord | <notchris> welcome to dystopia |
19:49:48 | FromDiscord | <shadow.> ah i fixed it |
19:49:53 | FromDiscord | <shadow.> it was bc my check range was too low |
19:49:56 | FromDiscord | <notchris> glad i could help |
19:51:10 | FromDiscord | <shadow.> ty ty |
19:52:18 | FromDiscord | <notchris> @shadow. i was just near buckland |
19:52:26 | FromDiscord | <notchris> waited 30min in traffic |
19:53:15 | FromDiscord | <shadow.> lol rip |
19:53:35 | FromDiscord | <notchris> i bet west farms is worse tbh |
19:54:40 | FromDiscord | <shadow.> i go to west farms often |
19:54:43 | FromDiscord | <shadow.> big traffic |
19:54:43 | FromDiscord | <shadow.> lmao |
19:54:56 | FromDiscord | <notchris> ur stompin grounds |
19:55:02 | FromDiscord | <shadow.> periodt |
19:59:35 | FromDiscord | <SirJosh> does anybody know of the performance of `nlvm` (<https://github.com/arnetheduck/nlvm>) versus the C backend nim uses? |
20:00:24 | FromDiscord | <ElegantBeef> I assume it's similar to what you can get with the C backend and the right optimisation flags |
20:01:27 | FromDiscord | <notchris> t minus 5 min till my doordash arrives |
20:01:28 | FromDiscord | <notchris> yass |
20:09:47 | FromGitter | <ynfle> Why doesn't `1` get translated in to a `Natural` automatically here? https://play.nim-lang.org/#ix=2Jqy |
20:11:57 | mipri | you mean, why doesn't it do that when the type of S.list is seq[Natural]? |
20:12:31 | FromGitter | <ynfle> No it's the index |
20:14:59 | Zevv | shadow.: You found your problem then? |
20:17:18 | * | narimiran joined #nim |
20:19:33 | FromDiscord | <mratsim> @Zevv I found your talk for Fosdem: https://www.youtube.com/watch?v=YrrUCSi72E8 |
20:19:49 | Zevv | Go away |
20:19:50 | Zevv | I don't talk |
20:19:56 | Zevv | I don't understand any of that stuff |
20:19:58 | FromDiscord | <mratsim> I think this should be mandatory explainer for everyone confused about CPS |
20:20:10 | Zevv | It's pretty good indeed |
20:20:23 | Zevv | i skimmed it today |
20:20:31 | FromDiscord | <mratsim> They use state machine instead of splitting into functions |
20:20:43 | Zevv | I'll allow it |
20:20:54 | Zevv | disruptek and me had a good talk the other day |
20:20:57 | FromDiscord | <mratsim> Also I tried to look under the cover of disruptek repo but none of the CPS exampel compile, even the one he gave in the RFC |
20:21:04 | Zevv | about the "where does the environment go" issue |
20:21:23 | Zevv | disrupteks repo works for the 0.0.13 |
20:21:27 | Zevv | you can run the stash/ examples |
20:21:45 | Zevv | that repo is wild, it's a perpetual state of chaos |
20:22:21 | FromDiscord | <mratsim> For me environment does into an object, since we know it's max size at compile-time |
20:22:43 | FromDiscord | <mratsim> then the rules:β΅- if there are ref/seq/string, it's a ref object |
20:22:56 | FromDiscord | <mratsim> -if there is a destructor, for now it's a ref object as well |
20:23:19 | Zevv | but if it's not a ref, we can't use inheritence like we do now |
20:23:29 | FromDiscord | <mratsim> -if it's just say number, we put a note "TODO: put that on the stack once Araq gets heap allocation elision sorted" |
20:23:32 | Zevv | so there's no common convertible type that can be passed around in the trampolines or schedulers |
20:23:46 | FromDiscord | <mratsim> Yes so that's what I wanted to look into |
20:23:53 | FromDiscord | <mratsim> how you use inheritance. |
20:23:57 | Zevv | ok. |
20:24:05 | Zevv | like I said, the 0.0.13 actually works |
20:24:08 | Zevv | with stash/ |
20:24:16 | Zevv | then look at a relative simple one like iterator.nim |
20:24:21 | FromDiscord | <mratsim> yes |
20:24:29 | FromDiscord | <mratsim> all of disruptek example are about eventqueue :/ |
20:24:41 | Zevv | that guy is such a jerk |
20:24:46 | Zevv | he really doesn't get it |
20:25:27 | ForumUpdaterBot | New thread by Adnan: Is it possible to generate a list of all transient dependencies and their sources?, see https://forum.nim-lang.org/t/7290 |
20:25:30 | FromDiscord | <mratsim> Also for conversion I'm not too worried, asyncdispatch, channel, weave are all typed outside, type-erased inside, as long as the external object/handle retains the type we should be good. |
20:25:45 | FromDiscord | <mratsim> anyway, gotta go check my foie gras |
20:26:17 | Zevv | the problem is that if we go pointer, how will we leverage normal GCing of the original refs |
20:26:35 | Zevv | but sure, foie gras goes firs, everybody knows that |
20:27:05 | FromDiscord | <mratsim> if ref, we don't go pointer |
20:27:13 | Zevv | right |
20:27:14 | FromDiscord | <mratsim> if not ref we can go union: https://github.com/mratsim/chirp8/blob/master/src/cpu.nim#L18-L23 |
20:27:25 | Zevv | so I think disruptek and me kind of decided that if you would go pointer, you'd lose us |
20:27:28 | Zevv | so this is good, right :) |
20:27:45 | FromDiscord | <mratsim> π |
20:27:46 | Zevv | becasue this stuff should be /totally/ frictionless on the user |
20:27:59 | Zevv | we can't have users go casting their stuff like in weave |
20:28:02 | Zevv | that will just not fly |
20:28:20 | FromDiscord | <mratsim> users don't cast in Weave |
20:28:51 | * | letto_ joined #nim |
20:28:59 | Zevv | https://github.com/mratsim/weave#data-parallelism ? |
20:29:04 | Zevv | let bufIn = cast[ptr UncheckedArray[float32]](input[0].unsafeAddr) |
20:29:12 | * | letto quit (Ping timeout: 256 seconds) |
20:29:38 | FromDiscord | <mratsim> well refc has heap local garbage management I can't do otherwise |
20:29:44 | Zevv | right |
20:29:46 | FromDiscord | <shadow.> yeah i found the problem |
20:29:49 | FromDiscord | <mratsim> arc is supposed to fix data |
20:29:52 | FromDiscord | <mratsim> that |
20:29:56 | FromDiscord | <shadow.> it was that i was checking x y -100..100 |
20:29:58 | FromDiscord | <shadow.> -125..125 worked |
20:30:04 | FromDiscord | <shadow.> i know, i should check bounds but i like bodging |
20:30:12 | FromDiscord | <mratsim> wow when you replace that by data it's probably very serious |
20:30:12 | Zevv | mratsim: right - so that is why CPS was designed to go fully ARC from day 1 |
20:30:19 | Zevv | shadow.: backfired on you, ha ha ha |
20:30:32 | FromDiscord | <mratsim> I think Weave kind of pushed arc :p |
20:30:47 | Zevv | that's how it should go, right |
20:31:01 | Zevv | and CPS pushes fixing of async :) |
20:31:31 | FromDiscord | <mratsim> https://github.com/weavers-guild/weave-io/blob/master/design/design_1_coroutines.md#use-cases |
20:32:02 | FromDiscord | <mratsim> I have found some use cases where CPS and/or coroutines are awesome but heap alloc is extremely discouraged |
20:32:18 | Zevv | I bet. |
20:32:26 | Zevv | but for practical reasons, that's /some/ use cases, right |
20:32:45 | FromDiscord | <mratsim> - kernel drivers (say wifi, bluetooth, ...) especially the one with sessionsβ΅- crypto protocol with state machine like TLS handshake |
20:33:18 | FromDiscord | <mratsim> that's use case where you want high performance, very clear code and hopeful not a mess of a state machine and no alloc |
20:33:34 | Zevv | ok, but I still have this hole in my brain |
20:33:41 | FromDiscord | <mratsim> https://media.discordapp.net/attachments/371759389889003532/791765560295686144/81551481-386e3680-9382-11ea-81f9-e0a7b55e62b4.png |
20:33:50 | FromDiscord | <shadow.> yeah it did backfire |
20:33:52 | Zevv | if not heap, then the alternative is a fix-size prereserved pool somewhere, right |
20:33:53 | FromDiscord | <mratsim> ^ like if someone need to impelment TLS |
20:34:11 | Zevv | mratsim: these kind of state machines is in my days job |
20:34:21 | Zevv | daily |
20:34:22 | Zevv | job |
20:34:53 | FromDiscord | <mratsim> it's type MyLocalObject = object; fn: ContinuationProc, buf: array[computedMaxEnvSize, byte] |
20:35:25 | FromDiscord | <mratsim> or the buf hides an union type that can be reinterpreted depending on the "stage" of the continuation we are |
20:35:53 | FromDiscord | <mratsim> https://github.com/disruptek/cps/blob/master/talk-talk/manual1.nim#L45-L63 |
20:35:57 | Zevv | Right. So how can we make this a hibrid so that in the disruptek and zevv cases we just have the env a real nim memory managed object, and the mratsim case where you do your magic to alloc/pool/manage that yourself |
20:36:16 | FromDiscord | <mratsim> when supportsCopyMem(T) |
20:36:45 | Zevv | hmm |
20:36:47 | FromDiscord | <mratsim> https://github.com/mratsim/Arraymancer/blob/master/src/arraymancer/laser/tensor/datatypes.nim#L35-L42 |
20:37:04 | Zevv | that's pretty smart |
20:42:27 | Zevv | so the kotlin stuff is basically just what we do, except they split with a switch instead of creating "real" continuation functions. |
20:43:03 | FromDiscord | <mratsim> for the proper supports copymem we need this fix: https://github.com/nim-lang/Nim/issues/13193 |
20:43:05 | disbot | β₯ Type tyAnything can't be matched to proc argument of typedesc type ; snippet at 12https://play.nim-lang.org/#ix=2iWM |
20:43:13 | Zevv | Their stuff looks simple, but that will quickly get hairy when as well you mix this with regular control flow |
20:44:03 | FromDiscord | <mratsim> One thing I'm curious about is about try/except. I've noted that C++ explicitly forbid to suspend in a try except block |
20:44:24 | FromDiscord | <mratsim> I think that's not a fundamental limitation but something to ease implementation though |
20:44:25 | Zevv | I think disruptek spent some time on that |
20:44:57 | FromDiscord | <mratsim> note that some of our async code is flaky because closure iterators have issues with try/finally |
20:45:00 | Zevv | I believe he handles that in the scheduler |
20:45:12 | Zevv | but indeed, it's important |
20:46:05 | FromDiscord | <mratsim> does it require exceptions:goto? |
20:46:16 | Zevv | i don't know |
20:46:51 | Zevv | because there is no magic going on, any thrown exception will propagate to the trampoline or its caller |
20:47:58 | Zevv | kotlin is just nim |
20:49:04 | FromDiscord | <mratsim> yeah, I've hit a roadblock on the C++ like coroutine design, there is a polymorphic return type that either return a coroutine or a value ... |
20:49:22 | FromDiscord | <mratsim> possibly Rust stuff can help |
20:50:02 | FromDiscord | <mratsim> https://axelforsman.tk/2020/08/24/rust-style-futures-in-c.html |
20:50:27 | FromDiscord | <mratsim> but I'd like to deep dive into the continuation first |
20:52:34 | FromDiscord | <Quibono> Can you do an enum of function returns? like x = isGreen("Yellow") |
20:53:02 | Zevv | Quibono: rephrase that question |
20:53:09 | FromDiscord | <mratsim> I don't understnd. Ther eis nothing enumy here? |
20:53:38 | FromDiscord | <Quibono> I want to differentiate between message types quickly and cleanly by seeing if they contain certain text. |
20:53:49 | FromDiscord | <Quibono> So I can then do different things with them. |
20:54:32 | FromDiscord | <mratsim> use object variant? |
20:54:38 | Zevv | yes that's good, but what is your question |
20:55:29 | FromDiscord | <Quibono> My question is, I think a case statement would be best, but can I have an enum where each item is just the same function with a different argument? lol |
20:55:56 | FromDiscord | <mratsim> you can have an object variant of callbacks |
20:56:21 | FromDiscord | <mratsim> but yeah just write proc dispatch(x: string) = case x ... |
20:56:59 | FromDiscord | <mratsim> it really depends how often you will need to dispatch those. Without more code can't say |
20:57:06 | FromDiscord | <mratsim> write something that works first. |
20:57:42 | FromDiscord | <mratsim> btw @Zevv, any idea why I have an extra 0 here: https://play.nim-lang.org/#ix=2JqK I slept on it and I still don't understand. |
20:58:11 | FromDiscord | <mratsim> if it's a bug it seems like async framework may always add an extra iteration? |
20:58:25 | * | narimiran quit (Ping timeout: 240 seconds) |
20:58:53 | Zevv | "Note that system.finished is error prone to use because it only returns true one iteration after the iterator has finished:" |
20:58:56 | Zevv | says the manual |
20:59:05 | Zevv | I tried doing things with iterators, but I find them just too funny |
20:59:11 | FromDiscord | <mratsim> omg! |
20:59:56 | FromDiscord | <mratsim> yeah but still, there is still my <= condition |
21:00:02 | Zevv | iterators is what I started with at the beginning of this journey, but something is wrong with my brain, or with iterators |
21:00:57 | FromDiscord | <mratsim> ah I know why |
21:01:04 | FromDiscord | <mratsim> wow that's complex |
21:01:16 | mipri | https://play.nim-lang.org/#ix=2JqO |
21:02:31 | FromDiscord | <mratsim> so I think what's happening is that there is a suspension point in the while loop. r is saved at this suspension point. WHen I reach the count of 4, r isn't saved but left at the default value of 0 |
21:02:40 | FromDiscord | <mratsim> and that's what ends up being displayed |
21:03:20 | FromDiscord | <mratsim> @mipri, nice |
21:03:32 | FromDiscord | <mratsim> very unintuitivee though |
21:04:06 | Zevv | it is |
21:04:58 | FromDiscord | <mratsim> I've seen in HN and stackoverflowthat in some language (C# I think) programmers had to take a lot of precaution with state around suspension point |
21:11:57 | FromDiscord | <mratsim> leaving, see you |
21:12:58 | Zevv | ciao |
21:17:40 | * | nyaayaya quit (Quit: byeee~) |
21:32:13 | FromDiscord | <Quibono> Any clue why this code is making minmaxheap freak out? https://play.nim-lang.org/#ix=2JqX |
21:37:57 | * | Arrrrrrrr quit (Remote host closed the connection) |
21:38:38 | FromDiscord | <Quibono> Other than I totally don't understand how minmaxheaps work |
21:42:12 | * | kwilczynski quit (Ping timeout: 272 seconds) |
21:43:08 | * | sirn quit (Read error: Connection reset by peer) |
21:45:52 | * | fowl quit (Ping timeout: 260 seconds) |
21:47:14 | * | sirn joined #nim |
21:47:37 | * | fowl joined #nim |
21:47:50 | * | kwilczynski joined #nim |
21:57:37 | * | jaz80 joined #nim |
21:58:13 | jaz80 | Does nim have anything that will get compiled to a copysignf intrinsic with the C backend? ie; not a library/stdlib call |
22:17:31 | * | Vladar quit (Quit: Leaving) |
22:49:42 | * | def- quit (Quit: -) |
22:50:53 | * | def- joined #nim |
22:57:59 | * | natrys quit (Quit: natrys) |
22:58:05 | disruptek | mratsim, zevv: the kotlin technique (and/or variant objects) is fine for mratsim's application, but it doesn't meet my desire for arbitrary continuation return types. also note that variant objects are not really a long-term nim support target per se... just something to keep in mind. |
22:59:36 | disruptek | there's a tiny needle to thread here and i fully expect mratsim to thread it, but i haven't managed to figure out how he will do it in a way that accomodates all our other guarantees. so i await his application of genius. π |
23:00:46 | disruptek | maybe i'll be able to download the kotlin video by christmas. here's hoping santa comes early. |
23:16:44 | FromDiscord | <Cohjellah> Alrighty. Merry Christmas from Australia!! |
23:22:52 | FromDiscord | <ElegantBeef> All of australia |
23:31:57 | * | jaz80 quit (Remote host closed the connection) |
23:44:50 | FromDiscord | <Cohjellah> All of it |
23:44:51 | FromDiscord | <Cohjellah> every inch |
23:44:58 | FromDiscord | <Cohjellah> Also, I'm still having problems with my terminal app ahaha |
23:45:17 | FromDiscord | <Cohjellah> driving me nuts. The docs aren't too clear, and I've run out of terminal options lmao |
23:49:00 | FromDiscord | <Cohjellah> Should I make a forum post? |
23:53:42 | FromDiscord | <shadow.> hm? |
23:53:44 | FromDiscord | <shadow.> what's the issue |
23:55:38 | FromDiscord | <mratsim> I've pushed a POC, just like the C++ dev I think function call are easier to optimize than state machines for compiler and CPU and they are surely easier to debug than goto state machine so the current codegen is fine |
23:55:52 | FromDiscord | <mratsim> @disruptek see: https://godbolt.org/z/enMhad |
23:56:19 | FromDiscord | <mratsim> no kotlin technique and no variant, just monkey patching your base code. |