00:00:15 | Araq | but it depends on the representation |
00:00:26 | Araq | .bufferpacked is nice but should be done differently |
00:00:52 | FromGitter | <xmonader> Guys!! i'm almost done with my parsec for nim wanna take a look? :D |
00:00:55 | FromGitter | <xmonader> https://gist.github.com/xmonader/474f926c7481b43a0c0160ef0e416c17 |
00:01:01 | Araq | the ascii based representation is kinda shitty, but as I said, for json it has plenty of advantages |
00:01:58 | FromDiscord | <treeform> Some thing like: https://gist.github.com/treeform/1c1cb10fd18342b05efe73003ecd285b |
00:02:15 | FromDiscord | <treeform> so that the struct just grows and stays together instead of fragmenting pointers and stuff? |
00:02:53 | FromDiscord | <treeform> This would not be good for all structs, but for some it might be good? I think its very similar to json use case? |
00:03:32 | FromDiscord | <treeform> For structs that contains mostly strings and you don't change them often. |
00:03:50 | Araq | sure, sounds reasonable |
00:04:07 | FromGitter | <xmonader> i need help with just 1 thing to achieve forward declarations that's how i do it in python ⏎ https://github.com/xmonader/pyparsec#forward-declarations not sure how to do it in nim, even untyped templates doesn't work so i'm not sure? |
00:05:46 | Araq | sorry, I need to sleep. |
00:05:55 | FromDiscord | <treeform> have a good night! |
00:05:56 | Araq | forward decls only work for procs |
00:06:09 | Araq | they are covered in the tutorial |
00:06:14 | Araq | good night |
00:06:23 | FromGitter | <xmonader> thanks good night araq i'll try |
00:17:06 | * | Snircle quit (Quit: Textual IRC Client: www.textualapp.com) |
00:33:07 | FromDiscord | <2vg> awesome araq's packedjson |
01:09:24 | * | endragor joined #nim |
01:14:09 | * | endragor quit (Ping timeout: 268 seconds) |
02:31:39 | * | leorize quit (Quit: WeeChat 2.1) |
02:35:42 | * | leorize joined #nim |
02:40:27 | * | endragor joined #nim |
02:41:44 | * | dddddd quit (Remote host closed the connection) |
03:20:16 | * | aleandros left #nim ("Textual IRC Client: www.textualapp.com") |
03:21:08 | * | FuntDobra joined #nim |
04:07:20 | * | leorize quit (Ping timeout: 265 seconds) |
04:36:54 | * | FuntDobra quit (Ping timeout: 260 seconds) |
04:52:46 | * | xkapastel quit (Quit: Connection closed for inactivity) |
04:56:38 | * | cspar_ quit (Ping timeout: 265 seconds) |
05:04:05 | * | mal`` quit (Quit: Leaving) |
05:14:24 | * | miran joined #nim |
05:17:14 | * | mal`` joined #nim |
05:24:42 | * | leorize joined #nim |
05:29:00 | * | nsf joined #nim |
05:43:08 | * | skrylar joined #nim |
05:55:25 | * | leorize quit (Ping timeout: 256 seconds) |
06:09:04 | * | xkapastel joined #nim |
06:10:09 | * | miran quit (Ping timeout: 268 seconds) |
06:12:49 | * | yglukhov quit (Ping timeout: 248 seconds) |
06:14:20 | * | leorize joined #nim |
06:26:00 | * | gokr joined #nim |
06:49:25 | * | FuntDobra joined #nim |
06:57:30 | * | FuntDobra quit (Ping timeout: 256 seconds) |
07:05:30 | * | FuntDobra joined #nim |
07:10:18 | * | jaco60 joined #nim |
07:20:05 | * | yglukhov joined #nim |
07:28:02 | * | shodan45 quit (Remote host closed the connection) |
07:28:09 | * | shodan45 joined #nim |
07:52:04 | * | CodeVance joined #nim |
07:55:12 | FromGitter | <data-man> Morning! ⏎ parsetoml's author are no longer interested in Nim. ⏎ I propose to create the NimParsers organization and move his project to new address (or to Nim-Lang). https://github.com/ziotom78/parsetoml/issues/12 |
07:59:03 | livcd | that's a shame |
07:59:07 | livcd | did he mention why ? :) |
08:01:42 | FromGitter | <data-man> Looking at his repositories, the reason in Julia. :-) |
08:02:28 | * | athenot_ joined #nim |
08:02:41 | FromGitter | <xmonader> anyone has the time to help me a bit finishing off a parser combinator library? i'm struggling with forward declarations? |
08:03:39 | * | athenot quit (Ping timeout: 255 seconds) |
08:07:27 | FromGitter | <data-man> Sorry, I'm almost asleep. Tea is no longer helps. :) |
08:13:19 | * | FuntDobra quit (Ping timeout: 260 seconds) |
08:18:45 | FromGitter | <xmonader> cute timezones in this channel xD |
08:22:00 | FromGitter | <data-man> Just I hadn't slept > 24 hours. |
08:22:11 | FromGitter | <narimiran> @xmonader i'm not almost asleep, but i don't know if i can help you :) |
08:23:28 | FromGitter | <xmonader> @narimiran oh thanks! can u take a look at this ? https://github.com/xmonader/pyparsec#forward-declarations |
08:23:41 | FromGitter | <xmonader> i'm trying to do the same in nim but it won't let me |
08:24:30 | * | xet7 joined #nim |
08:24:45 | FromGitter | <narimiran> what exactly are you trying to do? are you looking for some kind of closures? |
08:25:30 | FromGitter | <narimiran> or partially applied functions? or something else? |
08:25:36 | FromGitter | <xmonader> yeah that doesn't evaluate until called |
08:25:36 | FromGitter | <xmonader> i tried to use template with untyped |
08:25:37 | FromGitter | <xmonader> but that didn't work too |
08:26:38 | FromGitter | <xmonader> the problem is to define `jsonValue` u need to define `jsonList` and to define `jsonList` u need the `jsonValue` to be already defined, that's why i need a way to forward declare `valp` to be used from `listp` |
08:27:56 | FromGitter | <xmonader> so what i did in python i write a closure that when evaluated will call that expression |
08:28:52 | FromGitter | <kayabaNerve> I need help for once |
08:28:59 | FromGitter | <kayabaNerve> Well. Not for once. |
08:29:03 | FromGitter | <kayabaNerve> I need help often. |
08:29:10 | FromGitter | <kayabaNerve> I need Nim help for the first time in months |
08:29:59 | FromGitter | <kayabaNerve> I have a C function which can be summarized as follows: ⏎ ⏎ char* cFunc(char* data) { ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/nim-lang/Nim?at=5afe8f07b84be71db917e592] |
08:30:26 | FromGitter | <kayabaNerve> The array is filled properly, is null terminated, and printf handles it successfully |
08:31:35 | * | FuntDobra joined #nim |
08:31:43 | FromGitter | <kayabaNerve> My Nim code though? ⏎ proc cFunc(data: cstring): cstring {.header: "../c/header.h", importc: "cFunc".} ⏎ ⏎ proc nimFunc*(data: string): string = ⏎ ... [https://gitter.im/nim-lang/Nim?at=5afe8f6e8c24fe61eaf5072f] |
08:32:01 | FromGitter | <kayabaNerve> The C Function works perfectly. However, nim gets a blank string/nil in return |
08:32:15 | FromGitter | <kayabaNerve> Printing it prints a blank line. That array accessing crashes the program. |
08:36:54 | * | yglukhov quit (Read error: Connection reset by peer) |
08:37:27 | * | yglukhov joined #nim |
08:37:47 | Araq | your C function is wrong, it returns memory to a stack frame that is about to disappear |
08:38:19 | FromGitter | <kayabaNerve> Should I pass in a cstring an edit that directly? |
08:38:25 | Araq | you can easily write this in Nim and Nim would tell you the unsafety ('addr') |
08:38:39 | Araq | write it in Nim. |
08:38:43 | FromGitter | <kayabaNerve> I can't |
08:38:52 | FromGitter | <kayabaNerve> Not without adding hours to my work |
08:39:08 | Araq | well it's broken C code |
08:39:13 | FromGitter | <kayabaNerve> This is a C SHA512 header file I cleaned and made into a singular function |
08:39:18 | FromGitter | <kayabaNerve> That singular function is my code |
08:39:20 | FromGitter | <mratsim> @brentp squeeze the [1, 300, 4] tensor or unsqueezed(0) the [300, 4] tensor |
08:39:30 | FromGitter | <kayabaNerve> I can edit my singular function |
08:39:34 | FromGitter | <mratsim> unsqueeze* |
08:39:36 | FromGitter | <kayabaNerve> Or write that in Nim |
08:39:42 | Araq | yeah, do that. |
08:39:45 | FromGitter | <kayabaNerve> But then I have 3 C functions and a datastruct |
08:40:18 | FromGitter | <kayabaNerve> Unless I rewrite the whole header. Hundreds of lines and a pain in my ass, especially as this is one of many C libraries I need |
08:40:52 | FromGitter | <mratsim> cstring is the equivalent of C 0-terminated string |
08:40:54 | FromGitter | <kayabaNerve> I wish I had the time and patience to do that |
08:41:05 | FromGitter | <kayabaNerve> @mratsim So cstring is a char* |
08:41:11 | FromGitter | <mratsim> yes |
08:41:24 | FromGitter | <kayabaNerve> And the solution here, as I can't rewrite this in Nim, is to pass in a cstring and have C edit it |
08:41:30 | FromGitter | <kayabaNerve> Because then the frame is Nim's, not C |
08:41:37 | FromGitter | <kayabaNerve> Yes? No? Am I missing something? |
08:41:51 | FromGitter | <mratsim> pass the cstring to the C function |
08:41:59 | FromGitter | <kayabaNerve> If so, my question is what's the best way to allocate 129 chars to a cstring |
08:42:06 | FromGitter | <kayabaNerve> Or do I have to use C's memalloc? |
08:42:25 | FromGitter | <kayabaNerve> Right now, I'm just using char returnData[129] |
08:42:35 | FromGitter | <mratsim> var foo: cstring = “yourNimString" |
08:42:52 | FromGitter | <kayabaNerve> That doesn't help... at all |
08:42:55 | FromGitter | <mratsim> and then pass foo[0].addr |
08:43:04 | * | yglukhov quit (Ping timeout: 260 seconds) |
08:43:09 | FromGitter | <kayabaNerve> Unless your suggestion is to write a junk string with 128 chars |
08:43:22 | FromGitter | <mratsim> or pass as cstring directly. I think it should work. |
08:43:30 | FromGitter | <kayabaNerve> Thanks for the info on passing it |
08:43:40 | FromGitter | <kayabaNerve> I do appreciate it. Right now, my issue is memory allocation though |
08:43:57 | FromGitter | <mratsim> Nim will allocate the cstring properly |
08:43:59 | FromGitter | <kayabaNerve> How do I get 129 chars allocated? Just have "128_CHAR_LENGTH" as the string? |
08:44:04 | FromGitter | <kayabaNerve> Not if I edit it from C |
08:44:12 | FromGitter | <kayabaNerve> I'm not passing data. I did that |
08:44:15 | FromGitter | <kayabaNerve> I'm getting the data back |
08:44:26 | FromGitter | <mratsim> what do you want to do with it? |
08:44:29 | FromGitter | <kayabaNerve> ... |
08:44:31 | FromGitter | <kayabaNerve> From the top |
08:44:38 | FromGitter | <kayabaNerve> I have a C function which can be summarized as follows: ⏎ ⏎ char* cFunc(char* data) { ⏎ ⏎ ```var res: cstring = cFunc(data) ⏎ echo res[0] ⏎ echo res[3] ⏎ return $res``` ... [https://gitter.im/nim-lang/Nim?at=5afe92768c24fe61eaf510ef] |
08:44:42 | FromGitter | <kayabaNerve> C works fine |
08:44:45 | FromGitter | <kayabaNerve> C prints my string |
08:44:54 | FromGitter | <kayabaNerve> Nim prints a breakline and crashes on [0] and [3] |
08:44:57 | FromGitter | <kayabaNerve> Complaining it's null |
08:45:10 | FromGitter | <kayabaNerve> Araq said the issue had to do with the frame of the variable |
08:45:18 | FromGitter | <kayabaNerve> They suggested rewriting it in Nim |
08:45:20 | FromGitter | <kayabaNerve> I can't |
08:45:39 | FromGitter | <kayabaNerve> So now I have to figure out how to get the data to Nim's frame. My idea was to pass in a cstring, and just have C edit it |
08:46:04 | FromGitter | <kayabaNerve> Then Araq disappeared (which is fine; they're probably busy and they don't have to give me support; no one does) |
08:46:13 | FromGitter | <kayabaNerve> And then you popped in to try to help me. I appreciate that |
08:47:17 | FromGitter | <mratsim> let me try something. btw you should use triple-quote for proper formatting of code |
08:47:45 | FromGitter | <kayabaNerve> Thanks. I'm used to Discord which is `. |
08:50:18 | FromGitter | <kayabaNerve> Also, Nim has two compiler bugs, as far as I can tell. My inclusion of the header is forced to be "../c/header.h" since it places the C file in nimcache/. Also, it doesn't recompile my header when it changes. ⏎ ⏎ I said as far as I can tell, because I'm guessing I'm misusing the compiler on the first (maybe some cli switch or a pragma) and the second is... not a bug but a not yet implemented feature? I actually |
08:50:18 | FromGitter | ... don't know. Just wanted to bring them up in case I did find a bug. V0.17.3 (working on upgrading that today). Does anybody know for sure if either of those are bugs? |
08:52:37 | Araq | > Yes? No? Am I missing something? |
08:52:40 | Araq | Yes. |
08:53:09 | Araq | C does not work "fine", you print the string before it disappeared |
08:53:30 | Araq | try to print it in a C function that calls your function and you would see the same. |
08:53:37 | FromGitter | <mratsim> @kayabaNerve ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5afe9491b84be71db917f755] |
08:54:11 | Araq | regarding your other question, nim doesn't track headers, use -f to force a recompile |
08:54:25 | Araq | nim assumes that you don't program in C header files |
08:54:30 | * | yglukhov joined #nim |
08:54:53 | FromGitter | <kayabaNerve> Araq: Yes. The issue is with C. Not with Nim. However, the issue is appearing on the Nim-side of things, thanks to C. That was my point. That stated, I am trying to find the way to fix this. |
08:55:03 | FromGitter | <kayabaNerve> Thanks for the -f switch |
08:55:07 | FromGitter | <mratsim> if you want to stay with C header use something like this: https://github.com/status-im/nim-ttmath/blob/master/src/ttmath.nim#L5 |
08:55:30 | FromGitter | <mratsim> passC: “-I” and the path to the header files |
08:56:02 | FromGitter | <kayabaNerve> @mratsim Does that solve this issue or is it something for me to test |
08:56:50 | FromGitter | <mratsim> I don’t know what your fillArray function is but that doesn’t return a blank string |
08:57:40 | FromGitter | <kayabaNerve> """char* sha512(char* hexData) { ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ }""" [https://gitter.im/nim-lang/Nim?at=5afe9584d245fe2eb7bde5a3] |
08:58:04 | FromGitter | <kayabaNerve> There we go |
08:58:04 | FromGitter | <mratsim> i.e. your C function signature were wrong, you returned char instead of char *, you accepted char instead of char * |
08:58:09 | FromGitter | <mratsim> char \* |
08:58:22 | FromGitter | <data-man> @kayabaNerve: Just use nimcrypto package |
08:58:28 | FromGitter | <mratsim> ^ |
08:58:51 | FromGitter | <kayabaNerve> Doesn't have what I need |
08:58:56 | * | sendell joined #nim |
08:59:30 | FromGitter | <kayabaNerve> The point isn't SHA512 in Nim |
08:59:39 | FromGitter | <kayabaNerve> The point is C Cryptographic Libs in Nim |
08:59:43 | FromGitter | <kayabaNerve> SHA512 was just the first |
08:59:51 | FromGitter | <kayabaNerve> I need a lot more from a lot of places |
09:00:02 | FromGitter | <mratsim> how about nim-libsodium? |
09:00:13 | FromGitter | <mratsim> or nim openssl? |
09:00:21 | FromGitter | <kayabaNerve> NaCl is one of my most hated projects and most loved |
09:00:26 | FromGitter | <kayabaNerve> It does so much yet it has so many gaps |
09:00:32 | FromGitter | <kayabaNerve> Also not applicable sadly |
09:00:45 | FromGitter | <kayabaNerve> OpenSSL may be except for the required linkages and licenses involved |
09:00:56 | FromGitter | <kayabaNerve> TL:DR Options exist, this is the one my project forces me to do |
09:01:32 | FromGitter | <kayabaNerve> @mratsim What's the differences in the signatures of our two pieces of code? |
09:02:29 | FromGitter | <mratsim> probably a copy pasting artefact, your \* disappears due to Gitter |
09:02:35 | FromGitter | <kayabaNerve> Got it |
09:02:49 | FromGitter | <kayabaNerve> Oh. To be clear, I could use nimcrypto for this. I'd just be back when it comes to lib #2 @data-man |
09:05:35 | FromGitter | <kayabaNerve> That emit code broke... a lot of things |
09:05:45 | FromGitter | <kayabaNerve> Can I memalloc a cstring from Nim? |
09:06:15 | FromGitter | <mratsim> system.calloc or system.calloc0 |
09:06:46 | FromGitter | <mratsim> ah, it’s alloc and alloc0 |
09:07:50 | FromGitter | <mratsim> if you need C proc from Nim there is an ansi_c hidden module not sure if you can import it but you can try: https://github.com/nim-lang/Nim/blob/devel/lib/system/ansi_c.nim |
09:09:44 | * | Vladar joined #nim |
09:13:41 | FromGitter | <xmonader> @mratsim ok i figured it out and now u can define recursive grammar ^_^ |
09:24:04 | FromGitter | <gogolxdong> Does the type with {.magic.} have exported fields? How to know the detail of a magic type? |
09:27:13 | FromGitter | <mratsim> search in github for mAddI if your magic was AddI |
09:27:33 | FromGitter | <mratsim> magic are defined in the compiler folder |
09:29:07 | FromGitter | <gogolxdong> ```type ⏎ NimNodeObj = object ⏎ ⏎ NimNode* {.magic: "PNimrodNode".} = ref NimNodeObj``` [https://gitter.im/nim-lang/Nim?at=5afe9ce252194a4a67f55c27] |
09:32:38 | FromGitter | <mratsim> yes search for mPNimrodNode: https://github.com/nim-lang/Nim/search?utf8=✓&q=mPNimrodNode&type= |
09:32:46 | * | xkapastel quit (Quit: Connection closed for inactivity) |
09:35:10 | * | dddddd joined #nim |
09:36:20 | FromGitter | <gogolxdong> finally, thank you @mratsim |
09:36:45 | FromGitter | <mratsim> you’re welcome |
09:36:46 | FromGitter | <gogolxdong> I thought it's just magic :) |
09:37:20 | FromGitter | <gogolxdong> since @kux said lucky finding. |
09:37:21 | FromGitter | <mratsim> well it is, I don’t really understand but it looks like mPNimrodNode are just wrappers |
09:41:10 | FromGitter | <kayabaNerve> Thanks @mratsim |
09:41:35 | FromGitter | <mratsim> Glad you sorted it out @kayabaNerve |
09:43:08 | FromGitter | <mratsim> @xmonader For your parsec: maybe check this GSoC idea, it has some guidelines: https://github.com/nim-lang/Nim/wiki/GSoC-2016-Ideas#implement-re2nim-a-lexer-generator-for-nim |
09:53:14 | FromGitter | <xmonader> @mratsim oh thanks! can u guys check https://github.com/xmonader/nim-parsec |
09:59:35 | * | leorize quit (Ping timeout: 240 seconds) |
10:02:43 | FromGitter | <mratsim> someone did much haskell in a past life :P |
10:04:06 | FromGitter | <mratsim> here is a curry macro by the way: https://github.com/Araq/metapar/blob/master/livedemo/curry.nim |
10:08:07 | FromGitter | <xmonader> @mratsim haskell is mind changer i guess won't say i fully grasp it though, but some patterns are nice thanks for the macro ^_^ |
10:11:34 | * | regtools quit (Quit: Lost terminal) |
10:19:32 | FromGitter | <mratsim> Haskell was my first lang ;) https://github.com/mratsim/haskell-numbertheory |
10:19:41 | FromGitter | <mratsim> besides Bash VBA or SQL I mean. |
10:22:05 | FromGitter | <xmonader> why did u work fully on nim now? with the traction haskell is getting every where? |
10:22:35 | * | FuntDobra quit (Ping timeout: 240 seconds) |
10:23:22 | FromGitter | <mratsim> I’m not a dev, at the time I was support/sysadmin, I was just curious about programming and I always try to do hard things first (my first linux distro was Gentoo :D) |
10:24:11 | FromGitter | <mratsim> but IO in haskell was a pain, and speed too. I remember trying to get my Sieve of Atking as fast as C, and was stuck, even with mutable Vector. |
10:25:39 | FromGitter | <mratsim> then I did a programming pause for like 4 years. 2 years ago, I got back to programming, wanted to do a Go playing bot. Figured Haskell would be too slow so I looked for a new language, found Nim and Rust. I started with Rust |
10:26:29 | FromGitter | <andreaferretti> can anyone tell me what is the syntax to depend on the `#head` version of a package in nimble? |
10:26:31 | FromGitter | <mratsim> That was 3 months of fighting the borrow checker instead of learning reinforcement learning and game AI. Finished a functional but super weak and slow go bot |
10:26:38 | FromGitter | <andreaferretti> I always get that wrong |
10:26:44 | FromGitter | <mratsim> @#head ? |
10:26:50 | FromGitter | <andreaferretti> I tried that |
10:27:03 | FromGitter | <andreaferretti> `requires "nim >= 0.18.0", "nimPNG@#head"` |
10:27:19 | FromGitter | <andreaferretti> nimble would then try to donwload the non-existing package `nimPNG@` |
10:27:27 | FromGitter | <andreaferretti> so I tried |
10:27:33 | dom96 | nimPNG#head in your .nimble file |
10:27:34 | FromGitter | <andreaferretti> requires "nim >= 0.18.0", "nimPNG #head" |
10:27:42 | FromGitter | <andreaferretti> ah ok without spaces |
10:28:04 | FromGitter | <andreaferretti> great, that works! |
10:28:07 | FromGitter | <andreaferretti> thank you! |
10:28:08 | FromGitter | <xmonader> 3 months with the borrow checker :( |
10:28:09 | FromGitter | <andreaferretti> :-) |
10:28:26 | FromGitter | <xmonader> compiler error driven development with Rust :D sounds like a good title for a book @mratsim |
10:28:30 | dom96 | with space should work too |
10:28:34 | dom96 | please make an issue |
10:29:20 | FromGitter | <mratsim> @xmonader Then, programming pause again, I learned Data Science, I had a competition with 1.5Gb 3D images, Python was too damn slow to preprocess it. Did more competitions, Scikit-learn had tensor pipelining inefficiencies, so I wanted to learn this stuff from scratch |
10:29:54 | FromGitter | <mratsim> Rut or Haskell would be too foreign a syntax if I wanted to build something so I figured I could try Nim this time |
10:29:57 | FromGitter | <mratsim> Rust* |
10:30:08 | FromGitter | <xmonader> oh would u like to share resources? i never got the chance to get into AI only some basics minmax and such |
10:30:47 | FromGitter | <mratsim> I learn everything here: https://www.kaggle.com/ |
10:31:21 | FromGitter | <mratsim> For neural net: I started with this: https://karpathy.github.io/neuralnets/ and the CS231n Stanford courses |
10:31:43 | * | FuntDobra joined #nim |
10:32:26 | FromGitter | <xmonader> thanks a lot hopefully i get the time to invest in AI |
10:32:39 | FromGitter | <mratsim> For reinforcement learning and game AI, try with Monte Carlo Tree Seach for tictactoe or Othello/Reversi |
10:32:51 | FromGitter | <mratsim> and You can see a really in-depth overview of techniques here: https://drive.google.com/file/d/1xeUDVGWGUUv1-ccUMAZHJLej2C7aAFWY/view |
10:33:17 | FromGitter | <xmonader> actually nim makes sense because it's still growing and doesn't have most of basic libraries so doing it all will give u a broader experience |
10:33:47 | * | leorize joined #nim |
10:34:14 | * | regtools joined #nim |
11:00:09 | * | FuntDobra quit (Ping timeout: 260 seconds) |
11:02:45 | * | Yardanico quit (Ping timeout: 256 seconds) |
11:03:49 | * | Snircle joined #nim |
11:08:47 | * | floppydh joined #nim |
11:10:16 | * | fredrik92 joined #nim |
11:12:38 | * | FuntDobra joined #nim |
11:13:27 | * | couven92 quit (Ping timeout: 240 seconds) |
11:15:30 | * | Yardanico joined #nim |
11:18:46 | * | sendell quit (Remote host closed the connection) |
11:19:55 | * | leorize quit (Ping timeout: 265 seconds) |
11:22:33 | * | couven92 joined #nim |
11:23:29 | * | pwntus quit (Ping timeout: 260 seconds) |
11:23:46 | * | fredrik92 quit (Ping timeout: 264 seconds) |
11:23:46 | * | pwntus joined #nim |
11:27:51 | * | athenot_ quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
11:28:20 | * | fredrik92 joined #nim |
11:30:21 | * | couven92 quit (Ping timeout: 240 seconds) |
11:33:05 | * | fredrik92 quit (Ping timeout: 240 seconds) |
11:39:19 | * | CodeVance2 joined #nim |
11:39:21 | * | CodeVance quit (Read error: Connection reset by peer) |
11:48:57 | * | Cthalupa quit (Ping timeout: 240 seconds) |
11:50:11 | * | Cthalupa joined #nim |
12:01:11 | livcd | mratsim: do you have the source for your Go bot ? |
12:01:20 | livcd | sorry "go bot" |
12:05:18 | FromGitter | <narimiran> @livcd https://github.com/mratsim/rustygo ? |
12:05:42 | FromGitter | <narimiran> and nim version: https://github.com/mratsim/golem-prime |
12:12:29 | * | athenot joined #nim |
12:14:09 | * | Vladar quit (Quit: Leaving) |
12:17:06 | * | Vladar joined #nim |
12:17:47 | FromGitter | <mratsim> yes |
12:18:58 | FromGitter | <mratsim> Note that for Rust I struggled to put code in multiple files and then couldn’t be bothered xD |
12:21:16 | livcd | just curious. Did you get back to Rust or did not even try after sticking to Nim ? |
12:30:15 | dom96 | When I tried Rust its module system was the biggest turn off for me, I guess you've found that too |
12:31:17 | * | leorize joined #nim |
12:38:46 | * | yglukhov quit (Read error: Connection reset by peer) |
12:39:17 | * | yglukhov joined #nim |
12:43:05 | * | nuxdie joined #nim |
13:14:25 | * | gokr quit (Ping timeout: 268 seconds) |
13:18:24 | * | FuntDobra quit (Ping timeout: 260 seconds) |
13:24:56 | * | sendell[m] joined #nim |
13:25:55 | * | cspar_ joined #nim |
13:27:10 | livcd | I am going to try karax in the evening but the examples look complicated :( |
13:32:16 | * | DarkArctic quit (Read error: Connection reset by peer) |
13:34:09 | FromGitter | <mratsim> @livcd, I read Rust code but I don’t want to program in Rust anymore. Though if I ever got back, after developing in Nim I will have a much better feel for lifetime, borrows, Boxed types |
13:34:58 | FromGitter | <mratsim> I can see where and how they make sense now, but I don’t need them in my face. |
13:38:14 | FromGitter | <brentp> @mratsim . thanks. unsqueeze did it. and thanks @Vindaar |
13:38:14 | * | endragor quit (Remote host closed the connection) |
13:39:09 | * | vivus joined #nim |
13:39:56 | FromGitter | <mratsim> @livcd Some of the pain points I had in Rust are in this article: https://andre-ratsimbazafy.com/why-rust-fails-hard-at-scientific-computing/ |
13:46:51 | * | xet7 quit (Ping timeout: 265 seconds) |
13:54:38 | dom96 | livcd: Are you familiar with React-like frameworks? |
13:56:58 | * | endragor joined #nim |
13:59:28 | livcd | dom96: not really...i did one course on pluralsight on React :d |
13:59:51 | dom96 | Karax is basically React |
14:00:06 | dom96 | So you need to get in that way of thinking |
14:00:36 | dom96 | i.e. instead of setting attributes on the DOM you re-render the whole DOM |
14:00:44 | dom96 | with the attributes you want |
14:01:00 | dom96 | and karax figures out the most efficient way to do so |
14:01:11 | * | xet7 joined #nim |
14:01:56 | * | endragor quit (Ping timeout: 276 seconds) |
14:04:04 | livcd | i'll go through the examples and will try to build something small |
14:05:42 | livcd | btw what's the "include karax/prelude"... Did not really find the include keyword in the docs |
14:07:21 | Araq | https://nim-lang.org/docs/manual.html#modules-include-statement |
14:07:36 | Araq | I used https://nim-lang.org/docs/theindex.html and searched for 'include' |
14:08:43 | livcd | oh ok |
14:08:55 | livcd | i used the search function in "manual" and "std library" :| |
14:14:33 | * | PMunch joined #nim |
14:34:32 | PMunch | Hmm, dom96 I noticed something with nim doc. Some people like to create lines in their comments by having lot's of # symbols, this breaks with "Error: new section expected". I assume this is an rst thing, but maybe it could be easily solved by expecting exactly 2 # symbols and a space before doc-comments? |
14:39:36 | dom96 | Maybe Araq should answer that one |
14:45:08 | * | floppydh quit (Quit: WeeChat 2.1) |
14:48:39 | * | rockcavera quit (Ping timeout: 256 seconds) |
14:49:54 | FromGitter | <tim-st> I found a bug where the parser/compiler crashes silently: https://pastebin.com/Hp65ZZjA |
14:50:09 | FromGitter | <tim-st> I think my source code is wrong though |
14:51:44 | subsetpark | Open an issue! |
14:52:15 | FromGitter | <tim-st> does somone know how can I use `{.NoInit.}` on the returning `result` of a return type of a proc? |
14:53:06 | FromGitter | <tim-st> result.data {.NoInit.}: ... was my idea, that doesnt work, it seems I have to explicitly create an other variable and assign it to result.data |
14:55:19 | Araq | PMunch: I don't know what you mean |
14:57:20 | PMunch | Right now it reads "##########################" which causes an error, I'm guessing because the doc format puts some meaning on # characters. If Nim were to only interpret "## " as the beginning of doc comments then those would never enter the documentation. |
14:58:09 | PMunch | This is what is causing issues: https://github.com/NimParsers/parsetoml/blob/master/src/parsetoml.nim#L1258 |
14:59:59 | Araq | well that's invalid RST |
15:00:29 | * | athenot quit (Max SendQ exceeded) |
15:01:06 | PMunch | I know, but only because the remaining ### characters after the first two are added to the RST |
15:01:24 | PMunch | If Nim required "## " you would still be able to do this |
15:01:31 | PMunch | And I believe most people do that anyways |
15:02:03 | * | athenot joined #nim |
15:03:07 | * | CodeVance2 quit (Read error: Connection reset by peer) |
15:04:30 | * | CodeVance2 joined #nim |
15:06:00 | * | CodeVance2 quit (Read error: Connection reset by peer) |
15:06:09 | * | CodeVance joined #nim |
15:09:53 | * | aleandros joined #nim |
15:09:54 | Araq | well how would I be able to write |
15:09:55 | Araq | ############### |
15:10:01 | Araq | ## my awesome header |
15:10:02 | Araq | ############### |
15:10:05 | Araq | otherwise? |
15:10:30 | PMunch | What do you mean? That's exactly the thing I want to allow :P |
15:10:46 | PMunch | Oh wait, that's valid RST isn't it? |
15:11:01 | PMunch | For headings |
15:11:32 | Araq | yep. |
15:13:21 | * | gokr joined #nim |
15:13:55 | FromGitter | <tim-st> Is there a fixed size array based Ring type in nim stdlib? |
15:14:23 | FromGitter | <tim-st> (or as a nimble package) |
15:15:54 | Araq | unlikely, Nim is pretty 'seq' heavy |
15:16:35 | FromGitter | <tim-st> here is one "fixed size" but is uses seq :(( https://github.com/megawac/RingBuffer.nim |
15:17:08 | FromGitter | <tim-st> I tried to build my own it's nearly finished, but I cant get the new Contructor to work |
15:18:42 | * | aleandros quit (Quit: Textual IRC Client: www.textualapp.com) |
15:18:54 | Araq | why would it use 'new' ? |
15:19:08 | Araq | you can keep it on the stack, it's of a fixed size |
15:20:45 | * | aleandros joined #nim |
15:21:09 | FromGitter | <tim-st> I want a proc `newRingBufferE (cap: static[Positive]): RingBuffer[E]` or similar to get it very easy |
15:21:22 | * | Sembei quit (Read error: Connection reset by peer) |
15:21:52 | FromGitter | <tim-st> How would I define the type for this, if the cap is const and differs? |
15:22:16 | * | xkapastel joined #nim |
15:22:24 | * | skrylar quit (Remote host closed the connection) |
15:23:26 | Araq | pretty much like you wrote it, proc newRingBuffer[E: static[int]](): RingBuffer[E] |
15:23:56 | * | aleandros left #nim (#nim) |
15:24:17 | * | aleandros joined #nim |
15:24:34 | FromGitter | <tim-st> I meant this: |
15:24:35 | FromGitter | <tim-st> type RingBuffer[I: SomeOrdinal, E] = tuple ⏎ indexFirst: int ⏎ length: int ⏎ data: array[I, E] [https://gitter.im/nim-lang/Nim?at=5afef0331cfca775e11caa32] |
15:24:52 | FromGitter | <tim-st> and the array should be {.NoInit.} |
15:25:05 | Araq | dlm |
15:25:19 | Araq | don't use a tuple here, that's clearly a nominal type (object) |
15:25:53 | FromGitter | <tim-st> what is the difference? |
15:26:26 | FromGitter | <tim-st> I dont want to use any object features, object size is likely bigger than tuple |
15:26:46 | Araq | it is not. |
15:27:12 | FromGitter | <tim-st> can it still be stack only when it's object? |
15:27:35 | FromGitter | <aboisvert> object is like a `struct` in C |
15:27:46 | FromGitter | <tim-st> and what is tuple then? |
15:27:51 | FromGitter | <tim-st> where is the difference |
15:28:46 | aleandros | Hey everyone! I'm experiencing something funny with nimble. I'm building a project with one dependency and everything is going normal. Then I added NimYAML and it's re-downloading it everytime I build and asking if I want to overwrite the existing version. Have you experienced it? Do you know a way around it? |
15:29:42 | FromGitter | <aboisvert> they are both struct-like, tuples can be indexed by name of field or by index of field |
15:32:32 | FromGitter | <tim-st> ok, but I still cant understand how I would define a type that holds a fixed size array. The array itself is constructed using `array[A: Ordinal, B]` I think my type would need this too, but when I tried this the compiler failed like the issue I posted |
15:33:01 | FromGitter | <aboisvert> take a look at this example: https://github.com/notTito/nim-100days/blob/master/structures/ringbuffer_concurrent.nim |
15:33:47 | FromGitter | <tim-st> This was literally the same syntax I used, but tuple instead of object also static 😟 |
15:34:00 | FromGitter | <tim-st> thanks for the link that helps 👍 |
15:34:16 | * | CodeVance quit (Quit: Yaaic - Yet another Android IRC client - http://www.yaaic.org) |
15:34:24 | FromGitter | <aboisvert> yeah, `static[int]` is the crux of it |
15:34:54 | FromGitter | <tim-st> one last question: when I want the array to be {.NoInit.}, can I write |
15:34:56 | FromGitter | <tim-st> var buffer {.noInit.}: array[I, E] ⏎ result.data = buffer |
15:35:16 | FromGitter | <tim-st> it can not be done directly one result.data; dont know why it doesnt work |
15:35:30 | FromGitter | <tim-st> or will that create two arrays? |
15:37:04 | FromGitter | <aboisvert> i'm not 100% clear what you mean ... but `var buffer` above would allocate that array on the stack (without init) |
15:37:22 | FromGitter | <aboisvert> for `result.data = buffer` then it copies the value from one to the other |
15:38:09 | FromGitter | <aboisvert> maybe you can provide a fuller example? |
15:38:11 | FromGitter | <tim-st> I mean that my array should get the {.NoInit.} pragma, but where should I write this at? At the type definiton or at the result.data in the proc |
15:38:50 | FromGitter | <aboisvert> don't know off the top of my head, let me check if NoInit is supported at definition site |
15:39:29 | FromGitter | <tim-st> your example link was very good: https://github.com/notTito/nim-100days/blob/master/structures/ringbuffer_concurrent.nim ; the only thing he misses here is `{.NoInit.}` to the array; I want to have that in my implementation |
15:39:57 | FromGitter | <tim-st> his array is initialzed although he doesnt uses the init elements in an empty ring |
15:41:33 | FromGitter | <aboisvert> searching quickly, it doesn't appear {.NoInit.} can be used at definition site as you intend |
15:42:21 | FromGitter | <tim-st> ok, thanks, I think the only possibility then is to not supply a contructor proc and to trust the user that he uses {.NoInit.} although he likely doesnt |
15:42:25 | FromGitter | <aboisvert> but you can use it on your proc result, e.g. `proc myProd: Buffer[I, E] {.noinit.} = ...` |
15:42:43 | FromGitter | <tim-st> ah, very nice, thank you very much, now everything is clear :) |
15:43:49 | Araq | damn it, fix .noInit |
15:44:03 | FromGitter | <tim-st> what do you mean? |
15:44:09 | Araq | there is even some logic for it in the backend to detect the case |
15:44:27 | FromGitter | <tim-st> do mean that is not implemented? :D |
15:44:28 | Araq | I mean, the compiler can easily be smart enough to not require .noInit |
15:44:40 | FromGitter | <tim-st> ah, that would be super cool |
15:44:41 | Araq | and it already is implemented, somewhere |
15:45:22 | Araq | btw this is why "just derive the $ operator for objects" is bad: https://ci.appveyor.com/project/Araq/nim/build/4254/tests |
15:45:42 | Araq | it's a misfeature, code that shouldn't compile, compiled and only the tests found it |
15:46:29 | Araq | it's also part of this "everything must be generic" mindset... |
15:48:04 | FromGitter | <tim-st> ok, one question I forgot: I saw many people make there arrays of size nextPowerOfTwo, I read indexing on these sizes is much quicker and of course the mod operation, is there any other thing that is better if I dont resize? |
15:48:39 | FromGitter | <tim-st> compared to a size like 50 |
15:49:05 | FromGitter | <aboisvert> can prevent "false sharing" of cache lines |
15:49:09 | Araq | you need to benchmark, bigger sizes means the cache is less effective |
15:49:33 | FromGitter | <tim-st> ok, thanks |
15:49:42 | Araq | and a 'mod' operation never showed up in my profile |
15:49:53 | Araq | (in fact the GC uses one in a critical section) |
15:50:06 | FromGitter | <tim-st> you replaced it by `(i+1) and msk` |
15:51:18 | * | jjido joined #nim |
15:53:40 | * | aleandros left #nim (#nim) |
15:58:45 | FromGitter | <tim-st> I updated https://github.com/nim-lang/Nim/issues/7839 ; it seems my source code was wrong and the compiler didnt expect the square brackets at the return typ |
15:58:54 | FromGitter | <mratsim> When I benched `div` and `mod`, often the perf counters are on the `mov` that is folling the `idiv` operation |
15:59:06 | FromGitter | <mratsim> following* |
16:05:16 | FromGitter | <krux02> @mratsim I don't know what you want to say with that |
16:06:08 | FromGitter | <mratsim> that profiling might highlight the wrong operation |
16:06:17 | FromGitter | <krux02> ah, ok |
16:07:16 | FromGitter | <krux02> I am now manually writing OpenGL code again, because I am working on a new code generater. and hey I have the famous black screen to get my debug information |
16:09:15 | FromDiscord | <emekoi> is the `noInit` pragma implemented or does it not actually do anything? |
16:12:35 | PMunch | It does something |
16:13:05 | PMunch | Why do you wonder |
16:14:16 | * | avsej quit (Ping timeout: 265 seconds) |
16:18:02 | FromDiscord | <treeform> krux02, openGL black screen is the best. On windows (but not mac) there is the debug callback that is kind of more helpful now. |
16:18:22 | * | noonien joined #nim |
16:18:29 | FromDiscord | <treeform> "glDebugMessageCallback" |
16:19:33 | PMunch | Hmm, is there a way to pass a docstring to a template? I have a template to generate an accessor procedure for a given type and name the proc by a given name. Would be nice to also be able to pass a docstring for the generated proc |
16:24:47 | * | avsej joined #nim |
16:24:56 | * | avsej quit (Changing host) |
16:24:56 | * | avsej joined #nim |
16:27:12 | * | Trustable joined #nim |
16:32:18 | * | PMunch quit (Quit: leaving) |
16:35:34 | * | jjido quit (Ping timeout: 260 seconds) |
16:39:12 | FromDiscord | <emekoi> @PMunch I tried the example in the manual, but when I call `repr` on it and `echo` it out the array is initialized. here is the example: https://nim-lang.org/docs/manual.html#statements-and-expressions-var-statement |
16:49:51 | * | vivus quit (Quit: Leaving) |
16:49:58 | Yardanico | https://github.com/pascalmouret/assyria another OS (well, mostly kernel) in Nim :) |
16:50:01 | * | Trustable quit (Remote host closed the connection) |
17:11:11 | * | Ven`` joined #nim |
17:11:39 | * | Ven`` quit (Client Quit) |
17:12:35 | * | CodeVance joined #nim |
17:15:48 | * | nsf quit (Quit: WeeChat 2.1) |
17:24:11 | FromGitter | <mratsim> @emekoi what do you mean by the array is initialized? all values are 0? |
17:26:33 | FromGitter | <data-man> @mratsim Yes. ⏎ ⏎ ```var ⏎ a {.noInit.}: array[0..1023, char] ⏎ echo a``` [https://gitter.im/nim-lang/Nim?at=5aff0cc9bd10f34a68129a98] |
17:28:32 | FromGitter | <data-man> !eval var i {.noInit}: int; echo i |
17:28:34 | NimBot | 0 |
17:29:35 | FromGitter | <Varriount> !eval var i {.noInit}: array[0..20, int]; echo i |
17:29:38 | NimBot | [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] |
17:30:01 | FromGitter | <Varriount> I think noinit might only work on non-global variables. |
17:30:08 | leorize | !eval echo NimVersion |
17:30:10 | NimBot | 0.18.0 |
17:30:37 | leorize | Varriount: IIRC .noInit is only recently fixed in devel and was broken in 0.18.0 |
17:31:10 | * | cspar_ quit (Ping timeout: 256 seconds) |
17:31:14 | FromGitter | <mratsim> @leorize, noInit for ref object was broken |
17:31:39 | FromGitter | <mratsim> but noInit for stack objects was working, but maybe not for arrays? |
17:32:04 | * | SenasOzys joined #nim |
17:32:07 | FromGitter | <mratsim> I had a noInit bug last week so I’m sure it worked on devel for stack object. |
17:32:36 | leorize | maybe the allocated array happens to end up in a zero-ed area in memory? |
17:32:53 | FromGitter | <mratsim> no chance |
17:33:29 | FromGitter | <mratsim> !eval var i {.noInit}: array[0..20, float32]; echo i |
17:33:31 | NimBot | [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] |
17:36:12 | FromGitter | <data-man> Docs says: ⏎ ⏎ > Var statements declare new local and global variables and initialize them. A comma separated list of variables can be used to specify variables of the same type ⏎ > If an initializer is given the type can be omitted: the variable is then of the same type as the initializing expression. Variables are always initialized with a default value if there is no initializing expression. ⏎ > The default |
17:36:12 | FromGitter | ... value depends on the type and is always a zero in binary. ... [https://gitter.im/nim-lang/Nim?at=5aff0f0c1cfca775e11d2484] |
17:37:06 | * | miran joined #nim |
17:37:47 | * | FuntDobra joined #nim |
17:39:26 | * | rockcavera joined #nim |
17:47:41 | miran | seems like there is some activity here currently.... maybe somebody would like to be a volunteer to review my nim tutorial for beginners? |
17:48:43 | FromGitter | <mratsim> well {.noInit.} for stack variables is not a big optimization anyway: arrays are small due to the small stack and memset is either optimized away by the compiler (?) (which it cannot do for seq/heap arrays). |
17:49:34 | FromGitter | <tim-st> btw is there something like https://godbolt.org/ for nim? |
17:49:59 | FromGitter | <mratsim> unfortunately no |
17:50:21 | FromGitter | <tim-st> ok, thanks |
17:51:21 | dom96 | https://github.com/mattgodbolt/compiler-explorer/issues/206 |
17:53:10 | FromGitter | <tim-st> would be really nice |
17:53:28 | dom96 | I wonder if everyone that sees "Nim compiles to C" immediately thinks "well that sucks, I'll have to manually deal with the C code and call a C compiler" |
17:54:31 | FromGitter | <mratsim> “Nim uses C as an intermediate representation" |
17:56:25 | Araq | no, Nim produces C code, but it's not its IR |
18:01:27 | * | FuntDobra quit (Ping timeout: 240 seconds) |
18:06:02 | federico3 | dom96: yes and people asked me - that's why I usually say "Nim comples to C and then ..." |
18:11:08 | FromGitter | <data-man> But x64-code generation on pure Nim in future plans. ⏎ Why not? |
18:13:56 | Yardanico | miran, I'm not really good at reviewing articles, but I can read it and give some feedback :) |
18:14:24 | Yardanico | You should probably make a post on the forum so a lot of people can point out any issues with the article |
18:15:33 | * | nsf joined #nim |
18:18:46 | FromDiscord | <emekoi> @data-man so even with the pragma nim initialized the array? |
18:19:11 | FromGitter | <data-man> Yes |
18:21:04 | FromGitter | <data-man> Just it's not covered by tests. :( |
18:21:21 | * | SenasOzys quit (Ping timeout: 248 seconds) |
18:24:10 | miran | Yardanico: it is not an article, it is more like mini-book :) |
18:24:38 | miran | and i don't want to go in public until i get some more (private) reviews, so i implement those changes/improvements |
18:25:26 | FromDiscord | <emekoi> then doesn't that mean the pragma doesn't actually work? |
18:27:07 | Yardanico | it does |
18:28:37 | * | smt joined #nim |
18:28:44 | * | SenasOzys joined #nim |
18:29:26 | Yardanico | miran, well, you can link it to me in PM :) also maybe dom96 or @data-man can read it if they're not busy |
18:31:15 | FromGitter | <data-man> I can read, but nothing more :) |
18:31:50 | FromGitter | <data-man> @emekoi: works for local vars |
18:34:26 | * | FuntDobra joined #nim |
18:34:42 | FromGitter | <data-man> https://lemire.me/blog/2018/05/16/validating-utf-8-strings-using-as-little-as-0-7-cycles-per-byte/ https://github.com/lemire/fastvalidate-utf-8 |
18:44:51 | * | FuntDobra quit (Ping timeout: 240 seconds) |
18:59:02 | Araq | miran: let me read it |
19:02:22 | FromGitter | <data-man> @Araq: is all ok with CritBits? |
19:03:36 | FromGitter | <tim-st> just tested `{.noInit.}` pragma in dev version and can confirm that it works for arrays |
19:13:49 | * | noonien quit (Quit: Connection closed for inactivity) |
19:13:57 | Araq | data-man: merged it but it's offensive this nonsense got the "high priority" tag :P |
19:15:05 | FromGitter | <data-man> Thanks! ⏎ I didn't know how else to pay attention! :) |
19:16:14 | FromGitter | <data-man> So, maybe move pathMatches to ospaths? |
19:20:26 | * | skrylar joined #nim |
19:25:24 | Yardanico | wait, changelog says "nil for strings/seqs is finally gone. Instead the default value for these is "" / @[]." but it's not true for the result type of a proc (If I declare a proc which has a return type of seq[int] and don't initialize result, the returned seq will be nil) |
19:26:04 | Yardanico | is this supposed to be like this or it'll be fixed before the next release? |
19:28:07 | FromGitter | <krux02> Yardanico: did you test to not initialize seq string on the vm? |
19:28:13 | FromGitter | <krux02> (in a static block) |
19:28:25 | FromGitter | <krux02> (or in a macro) |
19:29:02 | Yardanico | No, I just wrote "proc test(): seq[int] = discard " and did echo test() |
19:31:33 | Yardanico | It should output @[] instead of "nil" |
19:32:29 | miran | can you try it with {.experimental.} and see if it works then? |
19:33:13 | Yardanico | miran, it's still "nil" for me, strange... |
19:33:26 | FromGitter | <data-man> echo test().isNil() ? |
19:33:39 | Yardanico | true |
19:33:51 | Yardanico | well, it "works" if I add something to resulting sequence |
19:34:10 | Yardanico | e.g. "proc test(): seq[int] = result.add 1" and echo test() will print @[1] |
19:35:58 | Araq | well the $ for seqs is wrong :P |
19:36:02 | FromGitter | <data-man> echo test().len ? :) |
19:36:08 | Araq | it should print @[] for nil :P |
19:36:14 | Araq | and 'nil' shouldn't compile |
19:37:07 | Araq | unfortunately, when I completed my work on it, I got totally weird GC crashes |
19:55:33 | * | athenot quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
20:05:49 | * | nolanv quit (Quit: WeeChat 2.0.1) |
20:22:16 | * | Sembei joined #nim |
20:25:16 | FromGitter | <zetashift> @miran I'd love to read it too x) |
20:45:29 | * | Vladar quit (Quit: Leaving) |
20:51:51 | * | pwntus quit (Ping timeout: 240 seconds) |
20:55:14 | * | pwntus joined #nim |
20:56:34 | FromDiscord | <awr> what's the easiest way to convert a seq of enum values to a set |
20:59:05 | * | avsej quit (Ping timeout: 240 seconds) |
20:59:50 | skrylar | for x in someseq: incl(someset, x) # ? |
21:00:42 | FromDiscord | <awr> preferably as a single expression |
21:01:22 | * | avsej joined #nim |
21:01:22 | * | avsej quit (Changing host) |
21:01:22 | * | avsej joined #nim |
21:01:22 | FromDiscord | <awr> i tried `enumSeq.foldl(a.incl(b), {})` but i got `Error: cannot infer the type of the set` |
21:03:58 | * | gb00s quit (Remote host closed the connection) |
21:04:32 | skrylar | template lazybones*[T](salad: seq[T]): set[T] = foreach x in salad: incl (result, x) # ? |
21:05:37 | skrylar | might work better as an inline proc. templates sometimes get disobedient |
21:07:57 | * | gb00s joined #nim |
21:12:27 | * | athenot joined #nim |
21:35:21 | * | gokr quit (Ping timeout: 240 seconds) |
21:40:14 | * | rockcavera quit (Remote host closed the connection) |
21:40:51 | * | miran quit (Ping timeout: 255 seconds) |
21:55:05 | * | cakesauce joined #nim |
21:57:39 | cakesauce | Just discovered nim last week and great odin’s beard, it is glorious. Well done. |
21:59:57 | dom96 | welcome :D |
22:06:41 | * | sz0 joined #nim |
22:09:04 | * | cakesauce quit (Ping timeout: 260 seconds) |
22:15:09 | * | rockcavera joined #nim |
22:17:44 | skrylar | i just had the weird urge to document and comment exclusively in dead/dying languages |
22:17:52 | skrylar | "It's fully commented and there's a 200 page manual" |
22:18:12 | skrylar | the arse wrote it in cunieform what the crap |
22:18:21 | FromDiscord | <treeform> deepCopy has really odd API, why not `proc deepCopy[T](original: T): T = deepCopy(result, original)` |
22:19:19 | FromGitter | <tim-st> is nim `mod` operation defined like it says in the comment in `system.nim`? |
22:19:47 | FromGitter | <tim-st> it gives different results as Python |
22:19:56 | FromGitter | <tim-st> for -1 mod 4 |
22:20:03 | FromDiscord | <treeform> are you having issues with negatives |
22:20:10 | FromDiscord | <treeform> yeah python does not do it the c way I think. |
22:20:24 | FromDiscord | <treeform> languages do negative mod differently |
22:21:02 | FromDiscord | <treeform> !eval -1 mod 4 |
22:21:03 | NimBot | Compile failed: in.nim(1, 4) Error: expression '-1' is of type 'int literal(-1)' and has to be discarded |
22:21:04 | FromGitter | <tim-st> oh, I see, the problem is `div` not mod |
22:21:11 | FromDiscord | <treeform> !eval echo -1 mod 4 |
22:21:13 | NimBot | -1 |
22:21:35 | FromDiscord | <treeform> and python says 3 |
22:21:48 | FromGitter | <tim-st> is -1 expected from math point ov view? |
22:22:01 | FromDiscord | <treeform> mod is not really a math thing |
22:22:19 | FromDiscord | <treeform> I think its not defined usually |
22:22:48 | FromDiscord | <treeform> "When either a or n is negative, the naive definition breaks down and programming languages differ in how these values are defined." from Wikipedia |
22:22:51 | FromDiscord | <treeform> https://en.wikipedia.org/wiki/Modulo_operation |
22:23:27 | FromGitter | <tim-st> ok, thanks |
22:27:16 | FromGitter | <tim-st> I have a solution: I use half of positive int64 as start than it wont get negative^^ |
22:28:02 | FromGitter | <tim-st> well, no :( |
22:28:36 | FromDiscord | <treeform> maybe https://gist.github.com/treeform/51db7a31b1bb64daf5bdb662a9b8e6c8 ? |
22:29:20 | FromGitter | <tim-st> yes, that's possible but seems a bit slow, but I will take it for now, thanks! |
22:32:37 | FromGitter | <tim-st> hm, the idea with half of positive int64 could work, do you think it's harder to calc bigger numbers mod? |
22:33:20 | FromDiscord | <treeform> ok here is the fixed version: |
22:33:21 | FromDiscord | <treeform> https://gist.github.com/treeform/51db7a31b1bb64daf5bdb662a9b8e6c8 |
22:34:00 | FromGitter | <tim-st> that's two times mod^^ |
22:34:06 | FromDiscord | <treeform> I think there is no meaningful difference in computing big or small mods. |
22:34:35 | FromGitter | <tim-st> nice, so as long my number never become negative it should work |
22:35:14 | FromGitter | <tim-st> since all array sizes are smaller than Positive.high / 2 I could use this as start index for my ring buffer |
22:36:56 | FromDiscord | <treeform> it looks like C is more of a remainder then a modulo |
22:37:04 | FromDiscord | <treeform> and so Nim's |
22:37:27 | FromDiscord | <treeform> I think python version is more mathematically correct. |
22:37:44 | FromGitter | <tim-st> yes, and also more usable, since mod is often used for indexing |
22:39:22 | FromGitter | <tim-st> this is my start now, should always work in theory: `Positive.high shr 1` |
22:39:23 | FromDiscord | <treeform> in python you can have negative indexes, in nim you cannot. |
22:39:43 | FromDiscord | <treeform> why not div 2 more readable? |
22:39:57 | FromDiscord | <treeform> `Positive.high div 2` |
22:40:02 | FromGitter | <tim-st> ok, yes, I tried / 2 and got float |
22:40:16 | FromDiscord | <treeform> shr would work badly for non power of 2 numbers |
22:40:49 | FromDiscord | <treeform> nim has float * / and integer mul and div. |
22:40:51 | FromGitter | <tim-st> isnt shr 1 and div 2 always the same? |
22:41:03 | FromDiscord | <treeform> I don't think so. |
22:41:18 | FromDiscord | <treeform> !eval echo 13 shr 1 |
22:41:20 | NimBot | 6 |
22:41:33 | FromDiscord | <treeform> !eval echo 13 div 2 |
22:41:36 | NimBot | 6 |
22:41:41 | FromGitter | <tim-st> ^^ |
22:41:43 | FromDiscord | <treeform> hmm your might be right |
22:42:05 | FromDiscord | <treeform> it just throws a way the .5 or .1 in binary |
22:42:15 | FromGitter | <tim-st> yes |
22:42:25 | FromDiscord | <treeform> 1101 -> 110.1 |
22:42:41 | FromDiscord | <treeform> |110.1| is 110 |
22:42:44 | FromDiscord | <treeform> so you you are right |
22:42:57 | FromDiscord | <treeform> 13 is 1101 in binary |
22:43:37 | FromDiscord | <treeform> but I still think div 2 is more readable |
22:43:43 | FromGitter | <tim-st> I just remembered that I tried that some years before in Python with >> and // |
22:45:17 | federico3 | any way to iterate over fiels of an object type (not an instance)? |
22:47:14 | FromGitter | <tim-st> dont know, maybe you see this in marshal package |
22:47:45 | FromGitter | <tim-st> or https://nim-lang.org/docs/typetraits.html |
22:48:37 | * | CodeVance_ joined #nim |
22:49:12 | FromDiscord | <treeform> also https://stackoverflow.com/questions/42467627/how-to-iterate-over-fields-names-types-of-a-tuple-object-in-a-macro |
22:50:47 | * | CodeVance quit (Read error: Connection reset by peer) |
22:54:55 | Notkea | hello, is it possible to use a particular module from the stdlib on the devel branch while staying on the stable branch for all the other? |
22:55:46 | FromDiscord | <treeform> I kind of done this in the past by just copying the file to my folder |
22:55:54 | FromDiscord | <treeform> if its self contained enough you can do it. |
22:56:36 | FromDiscord | <treeform> i usually just use the devel branch for everything now |
22:57:24 | * | rockcavera quit (Remote host closed the connection) |
22:58:30 | * | rockcavera joined #nim |
22:59:16 | * | athenot_ joined #nim |
22:59:29 | * | athenot quit (Ping timeout: 276 seconds) |
22:59:35 | Notkea | thanks, I'll try this |
23:00:16 | * | nsf quit (Quit: WeeChat 2.1) |
23:03:26 | * | athenot joined #nim |
23:04:08 | * | athenot_ quit (Ping timeout: 265 seconds) |
23:19:03 | * | CodeVance_ quit (Quit: Leaving) |
23:23:53 | * | CodeVance joined #nim |
23:24:50 | * | athenot quit (Ping timeout: 276 seconds) |
23:25:02 | * | athenot_ joined #nim |
23:27:15 | * | deech joined #nim |
23:27:46 | * | NimBot joined #nim |
23:28:28 | deech | Is there a way to expose the non function members of object variants as C structs/unions? |
23:33:41 | * | athenot joined #nim |
23:33:48 | * | athenot_ quit (Ping timeout: 255 seconds) |
23:35:55 | FromDiscord | <awr> can you elaborate on what you mean |
23:38:21 | * | athenot quit (Ping timeout: 240 seconds) |
23:42:32 | * | Snircle quit (Quit: Textual IRC Client: www.textualapp.com) |
23:44:44 | deech | I want call a Nim proc returns an object. If I can expose that object as a struct than I don't have to do any unmarshalling. |
23:44:58 | * | xet7 quit (Remote host closed the connection) |