00:00:29 | FromDiscord | <mratsim> And there are other implementations: |
00:00:29 | FromDiscord | <mratsim> - http://bontavlad.com/blog/2017/06/15/simple-neural-network-written-in-nim-running-on-the-web/ |
00:00:29 | FromDiscord | <mratsim> - https://github.com/YafahEdelman/nim-neural-networks |
00:00:29 | FromDiscord | <mratsim> - https://github.com/t8m8/Neural-Network-in-Nim |
00:00:29 | FromDiscord | <mratsim> - https://github.com/unicredit/neurotic |
00:04:01 | * | thomasross quit (Ping timeout: 268 seconds) |
00:04:54 | * | thomasross joined #nim |
00:07:22 | FromDiscord | <treeform> I heard you guys like Transpilers? How about Transputers? Nim's VM is just a Transputer right? https://en.wikipedia.org/wiki/Transputer |
00:07:34 | FromDiscord | <Fern & Simula (They/Them)> is there a way to store a callback proc in an object? |
00:08:52 | rayman22201 | @Fern & Simula, yeah sure: https://nim-lang.org/docs/manual.html#types-procedural-type |
00:10:45 | FromDiscord | <Fern & Simula (They/Them)> `Error: type mismatch: got <proc (): int{.noSideEffect, gcsafe, locks: 0.}> but expected 'proc (){.closure.}'` |
00:11:33 | FromDiscord | <Fern & Simula (They/Them)> and i can't define a closure in the top-level, so i'd have to define it from within a function. but what happens if that function goes out of scope? does the closure still exist? |
00:13:13 | FromDiscord | <Fern & Simula (They/Them)> trying to figure it out gets me `Error: implementation of 'bar.f() [declared in /tmp/inim_1575936575.nim(7, 10)]' expected` |
00:13:36 | rayman22201 | https://play.nim-lang.org/#ix=2413 |
00:13:57 | FromDiscord | <Fern & Simula (They/Them)> thanks! |
00:14:22 | rayman22201 | 👍 I hope that helps. ping back if you still have trouble :-) |
00:16:41 | FromDiscord | <Fern & Simula (They/Them)> just kinda screwing around for now. discovered some stuff in nim that fixes all the issues i was having in a project a while back lol |
00:19:08 | rayman22201 | yay. come to the dark side :-D |
00:19:44 | FromDiscord | <Fern & Simula (They/Them)> all i can say is that fieldPairs is a life saver lol |
00:21:29 | FromDiscord | <mratsim> @treeform AFAIK the transputer design inspiredt the whole Cluster-on-Chip things |
00:21:41 | FromDiscord | <mratsim> with 1000 cores on a single CPU |
00:21:53 | FromDiscord | <Fern & Simula (They/Them)> that's a thing that exists? |
00:22:09 | FromDiscord | <Fern & Simula (They/Them)> lol at what point is that just a gpu? |
00:23:22 | FromDiscord | <mratsim> https://www.adapteva.com/announcements/epiphany-v-a-1024-core-64-bit-risc-processor/ |
00:24:20 | FromDiscord | <Fern & Simula (They/Them)> wow |
00:24:28 | rayman22201 | I believe the idea inspired modern gpu design as well iirc |
00:24:33 | FromDiscord | <mratsim> there are pictures there: https://www.adapteva.com/wp-content/uploads/2013/02/sc11_publish.pdf |
00:25:38 | FromDiscord | <mratsim> the main issue is that there is no memory coherency between cores. I.e. no atomic read:write |
00:25:43 | FromDiscord | <Fern & Simula (They/Them)> 1024 core RISC-V chips in general purpose computers when? |
00:25:46 | rayman22201 | My favorite quote from those slides, "Parallel programming is still too hard!" |
00:26:25 | FromDiscord | <mratsim> you have to use channels (well hardware implemented channels but still channels) to communicate between cores which makes parallel programming super tricky |
00:26:48 | FromDiscord | <mratsim> basically you need to do distributed computing on your own machine |
00:26:52 | rayman22201 | AMD just got 5nm in production, so I expect # of cores to keep going up in desktop pcs :-P |
00:27:09 | FromDiscord | <mratsim> which for some reason is something that Weave has been designed to support quite well 😉 |
00:27:18 | rayman22201 | <3 |
00:27:24 | FromDiscord | <mratsim> Weave being my multithreading runtime (https://github.com/mratsim/weave) |
00:27:48 | FromDiscord | <mratsim> AMD will soon hit a hard limit |
00:28:01 | FromDiscord | <mratsim> Windows has 256 cores hardcoded as the maximum |
00:28:11 | FromDiscord | <mratsim> Windows is harder to overcome than Physics |
00:28:31 | FromDiscord | <Fern & Simula (They/Them)> oh my god, it's always windows holding things back |
00:28:48 | FromDiscord | <mratsim> 😄 |
00:29:01 | rayman22201 | 🤣 |
00:32:15 | * | thomasross quit (Ping timeout: 250 seconds) |
00:33:35 | FromDiscord | <snluu> has anyone here tried calling the JavaScript `fetch` API from nim? https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch |
00:33:47 | FromDiscord | <snluu> How did you go about importing it? |
00:34:19 | rayman22201 | https://nim-lang.org/docs/jsffi.html |
00:35:14 | * | thomasross joined #nim |
00:35:19 | rayman22201 | and probably this to make the async bits easier: https://nim-lang.org/docs/asyncjs.html |
00:36:02 | FromDiscord | <snluu> Thanks! I'm just looking at the doc. When are we supposed to use `importc` and when to use `importcpp`? |
00:36:19 | rayman22201 | for Javascript always use `importc` |
00:36:34 | rayman22201 | `importcpp` is specifically for dealing with C++ |
00:36:49 | * | azed quit (Read error: Connection reset by peer) |
00:37:29 | FromDiscord | <snluu> huh, the jsffi page has this |
00:37:29 | FromDiscord | <snluu> ``` |
00:37:30 | FromDiscord | <snluu> # import the "$" function |
00:37:30 | FromDiscord | <snluu> proc jq(selector: JsObject): JsObject {.importcpp: "$(#)".} |
00:37:30 | FromDiscord | <snluu> ``` |
00:37:44 | FromDiscord | <snluu> typo maybe? |
00:38:10 | rayman22201 | damn. no, it's a hack |
00:38:23 | rayman22201 | https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-importcpp-pragma |
00:39:48 | FromDiscord | <snluu> ok im a bit lost then 🙂 why wouldn't that thing use importc or importjs instead |
00:39:50 | rayman22201 | importcpp does extra regex magic to let you deal with name mangling and namespaces, etc... It's *usually* used with C++ |
00:40:07 | rayman22201 | but because jquery has the weird symbol business, it's being used there |
00:40:22 | FromDiscord | <snluu> ah i see |
00:40:25 | rayman22201 | `imporcpp` is more like `importc` *advanced mode* |
00:40:43 | FromDiscord | <snluu> so now how do i pick between importc and importjs? |
00:41:24 | rayman22201 | good question. I *think* importjs is just an alias for importc |
00:41:48 | FromDiscord | <snluu> well, yolo. i'll report back what i find out |
00:41:50 | FromDiscord | <snluu> ^^ |
00:41:52 | FromDiscord | <snluu> thanks! |
00:42:07 | rayman22201 | good luck :-) |
00:42:44 | rayman22201 | jquery is probably a bad example for that doc page.... |
00:42:46 | * | rayman22201 thinking |
00:43:41 | FromDiscord | <Fern & Simula (They/Them)> i think its a good addition, it shows how something like that is necessary |
00:43:52 | FromDiscord | <Fern & Simula (They/Them)> however, i think it should also have an explanation for that hack |
00:43:56 | rayman22201 | yes, but not for the first example. |
00:43:59 | rayman22201 | exactly |
00:44:05 | rayman22201 | It should be the second example :-P |
00:45:07 | * | krux02 quit (Remote host closed the connection) |
00:46:33 | * | thomasross quit (Ping timeout: 250 seconds) |
00:47:31 | rayman22201 | turns out, I am wrong. importjs is special |
00:47:32 | rayman22201 | https://github.com/nim-lang/Nim/blob/7e747d11c66405f08cc7c69e5afc18348663275e/compiler/pragmas.nim#L795 |
00:47:51 | rayman22201 | it will error if you try using it when not compiling to js |
00:48:54 | rayman22201 | and it supports some similar to magic to importcpp. It lets you define patterns that get re-written into js code. |
00:49:11 | rayman22201 | ughh... little things like this need to be documented better :/ |
00:49:14 | * | thomasross joined #nim |
00:49:16 | rayman22201 | @narimiran |
00:49:25 | rayman22201 | :-P |
00:51:03 | FromDiscord | <mratsim> Anyone know the rules for pushing and pop-ping custom pragmas? |
00:52:08 | rayman22201 | the manual says, "For third party pragmas it depends on its implementation, but uses the same syntax." lol |
00:52:36 | FromDiscord | <mratsim> well it doesn't :p |
00:52:53 | FromDiscord | <mratsim> I tried tracing it also but it doesn't really make sense to me |
00:56:06 | rayman22201 | hrmmmm.... bug maybe? https://github.com/nim-lang/Nim/blob/7e747d11c66405f08cc7c69e5afc18348663275e/compiler/pragmas.nim#L1147 |
01:17:06 | * | dddddd quit (Remote host closed the connection) |
01:18:36 | FromDiscord | <mratsim> I'll just push the problem on a kind soul and go to sleep: https://github.com/nim-lang/Nim/issues/12867 |
01:18:39 | disbot | ➥ Rules for custom pragma push/pop ⚫11mratsim; snippet at https://play.nim-lang.org/#ix=241c |
01:34:42 | * | ng0 quit (Quit: Alexa, when is the end of world?) |
01:37:39 | * | leorize joined #nim |
01:38:44 | leorize | Araq: why is string v2 splitted up into two objects like this? https://github.com/nim-lang/Nim/blob/5929c3da218fdecf70e11ff970e7b7cda50c9144/lib/core/strs.nim#L15-L22 |
01:39:11 | leorize | wouldn't just using one ptr object works just fine? |
01:41:00 | FromDiscord | <mratsim> having length on the stack avoids having to test the nil pointer then retrieving the length |
01:41:11 | FromDiscord | <mratsim> and length of a container is a quite common operation |
01:41:42 | * | nif quit (Quit: ...) |
01:41:52 | * | nif joined #nim |
01:43:30 | leorize | interesting, thanks |
02:07:16 | * | leorize quit (Ping timeout: 260 seconds) |
02:08:56 | * | leorize joined #nim |
02:38:56 | leorize[m] | @mratsim: hmm, wouldn't that design hinder the ability to share strings between threads? |
02:40:38 | * | hexeratops joined #nim |
02:41:19 | * | NimBot joined #nim |
02:45:22 | * | vesper11 quit (Quit: ZNC 1.7.4 - https://znc.in) |
02:45:37 | * | zedeus quit (Ping timeout: 240 seconds) |
02:45:58 | * | zedeus joined #nim |
02:46:08 | * | njoseph quit (Remote host closed the connection) |
02:46:33 | * | vesper11 joined #nim |
02:46:49 | * | sagax quit (Ping timeout: 268 seconds) |
02:47:14 | * | njoseph joined #nim |
03:09:44 | * | pbb quit (Remote host closed the connection) |
03:10:51 | * | rockcavera quit (Remote host closed the connection) |
03:10:59 | * | pbb joined #nim |
03:26:13 | * | endragor joined #nim |
03:26:17 | * | njoseph quit (Ping timeout: 268 seconds) |
03:34:41 | FromDiscord | <snluu> so i'm compiling nim to javascript. |
03:35:13 | FromDiscord | <snluu> if i have something like |
03:35:13 | FromDiscord | <snluu> `req.method = "POST"` in nim, it will compile to `req.method = makeNimstrLit("POST")` |
03:35:59 | FromDiscord | <snluu> i've found that if i did `req.method = cstring("POST")`, it will remove that `makeNimstrLit` overhead. is there anyway to force that behavior always without littering the code with `cstring`? |
03:41:24 | * | hexeratops quit (Quit: Leaving) |
03:44:12 | FromDiscord | <Kaynato> You could make a macro that encapsulates all string literals with cstring? |
03:48:23 | FromDiscord | <snluu> im new to nim/macro. does macro have the power to directly cast `"a"` to `cstring("a")` or will i have to write something like `js"a"`? |
03:48:43 | FromDiscord | <Rika> Yes it does |
03:49:00 | FromDiscord | <Fern & Simula (They/Them)> macros allow you to directly rewrite the AST, so it's basically as powerful as you can get in any language |
03:49:19 | disruptek | fwiw, js"a" is just a proc named js that happens to take a string input. you can use that shorthand with any such proc. |
03:49:46 | FromDiscord | <snluu> nice! i'll have to look into macros. |
03:49:57 | FromDiscord | <snluu> @disruptek--in that case would template be better? |
03:49:58 | FromDiscord | <Rika> I'm looking for the section for you |
03:50:10 | FromDiscord | <Rika> Template is ok if you also need nim strings |
03:50:33 | FromDiscord | <snluu> ah no, i meant template vs proc. less over head? |
03:50:42 | FromDiscord | <snluu> less runtime overhead* |
03:50:45 | disruptek | you could just have a macro that automatically converts every literal into a cstring, but note that cstrings have slightly different semantics. |
03:51:29 | disruptek | my advice is to have fewer string literals. 😉 |
03:52:19 | FromDiscord | <snluu> 😁 |
04:16:12 | * | njoseph joined #nim |
04:16:25 | * | nsf joined #nim |
04:19:08 | FromDiscord | <Fern & Simula (They/Them)> any chance of if expressions being added to nim? something like `var x = if condition then value1 else value2` |
04:19:19 | FromDiscord | <Rika> there is |
04:19:28 | FromDiscord | <Rika> if condition: value else: value |
04:19:43 | FromDiscord | <Fern & Simula (They/Them)> could've sworn that didnt work when i tried it |
04:19:51 | FromDiscord | <Rika> try it again |
04:20:05 | FromDiscord | <Rika> if it still doesnt work tell us your nim version |
04:20:35 | FromDiscord | <Fern & Simula (They/Them)> guess i was just using it wrong last time lol |
04:20:45 | disruptek | it works. also case:, block: |
04:21:15 | FromDiscord | <Fern & Simula (They/Them)> nice |
04:21:19 | FromDiscord | <Fern & Simula (They/Them)> that makes life easier |
04:21:52 | disruptek | the last expression of a block is implicitly passed, which is why you need to discard it otherwise. |
04:23:03 | disruptek | you can't break from case: but you can break from block, and you can name blocks and break from them by name. it feels like i use this in about half my procs. |
04:23:54 | * | sagax joined #nim |
04:49:48 | * | ltriant quit (Quit: leaving) |
04:57:10 | * | narimiran joined #nim |
04:59:28 | * | chemist69 quit (Ping timeout: 245 seconds) |
05:01:23 | * | chemist69 joined #nim |
05:11:22 | * | njoseph quit (Ping timeout: 252 seconds) |
05:33:27 | * | voidlinux-free joined #nim |
05:34:08 | voidlinux-free | what is the equivalent of print(f"value: {test}) -> in nim? |
05:34:34 | voidlinux-free | ^ is python, i know about echo fmt" and echo &" buut that doesnt work with stdout.write |
05:35:03 | shashlick | Why it's just a string |
05:35:19 | voidlinux-free | test is a variable |
05:35:28 | leorize | so? |
05:35:33 | voidlinux-free | i want it to substitute the varibale in {test} |
05:35:41 | shashlick | &"" returns a string |
05:35:58 | leorize | !eval import strformat; var test = "world"; stdout.write fmt"hello {test}" |
05:36:02 | NimBot | hello world |
05:36:21 | voidlinux-free | oh, sorry i didnt import strformat |
05:36:51 | voidlinux-free | which one should be used? fmt" or &" |
05:36:53 | leorize | well, maybe you should pay attention to the error message saying that it didn't find `fmt` :P |
05:37:01 | leorize | usually `&` is preferred |
05:37:02 | leorize | it's shorter |
05:37:07 | leorize | and less surprises |
05:37:20 | voidlinux-free | yeah it said some undeclared identifier, id dint know what it meant |
05:37:46 | voidlinux-free | okay and is it completely safe? like safe from whatever the user inputs? |
05:38:01 | leorize | yes |
05:38:24 | voidlinux-free | !eval import strformat; var test = "tes\";;;;;"; stdout.write &"{test} |
05:38:27 | NimBot | Compile failed: /usercode/in.nim(1, 58) Error: closing " expected |
05:38:33 | voidlinux-free | thanks |
05:38:52 | voidlinux-free | !eval import strformat; var test = "tes\";;;;;"; stdout.write &"{test} |
05:38:54 | NimBot | Compile failed: /usercode/in.nim(1, 58) Error: closing " expected |
05:39:20 | voidlinux-free | oh i think theres a message lenght limit on freenode web, its not taking my last ' |
05:39:27 | leorize | !eval import strformat; var test = "tes\";;;;;"; stdout.write &"{test}" |
05:39:31 | NimBot | tes";;;;; |
05:39:47 | voidlinux-free | and is there an alternative to writing stdout.write everytime? |
05:39:55 | leorize | the formatter just do simple string substitution |
05:39:58 | voidlinux-free | i have around 50 lines of stdout.write |
05:40:13 | leorize | you can use echo, or just make a "write" proc |
05:41:01 | leorize | something like this: template write(stuff: varargs[typed]) = stdout.write stuff |
05:41:07 | leorize | now you can just use write :D |
05:41:19 | voidlinux-free | yeah thats a good idea |
05:41:47 | voidlinux-free | thanks and is proc the equivalent to functions in python? |
05:41:55 | voidlinux-free | i havent used it yet |
05:42:02 | leorize | yes, they're pretty much the same thing |
05:44:26 | FromDiscord | <snluu> anyone here doing Advent of Code with Nim? |
05:44:49 | leorize | a lot |
05:44:57 | leorize | they might not be awake atm though |
05:45:06 | aeverr[m] | me |
05:46:44 | FromDiscord | <snluu> im using it to learn Nim. if you have made it past day 3, would love to get your critique on Nim idiomatic/code reviews 🙂 |
05:47:18 | FromDiscord | <snluu> i just finished day 3 |
05:47:27 | FromDiscord | <snluu> and started learning Nim on day 1 😛 |
05:47:41 | aeverr[m] | day 10 is much harder than other days |
05:47:45 | aeverr[m] | oh lord... |
05:47:56 | aeverr[m] | im done with all days but this day |
05:49:13 | leorize | snluu: I can take a look if you share your repo :) |
05:49:24 | leorize | also we got a thread in the forums discussing AoC :) |
05:49:28 | aeverr[m] | i wanna see it too! |
05:50:07 | FromDiscord | <snluu> https://github.com/snluu/adventcode2019/ |
05:50:15 | FromDiscord | <snluu> be gentle 🙂 |
05:50:51 | FromDiscord | <snluu> @aeverr[m]--day 10 sounds like Knight's tour 🙂 |
05:51:06 | aeverr[m] | knight's tour... let me look into that |
05:51:49 | aeverr[m] | i cant see the connection |
05:52:26 | aeverr[m] | wow, smart, using int64 for day 2 |
05:53:01 | aeverr[m] | ill tell you early, you should use a switch for the op codes :) |
05:53:21 | leorize | snluu: looks pretty idomatic to me |
05:53:27 | leorize | some tips for day 1: |
05:53:52 | leorize | - the `lines` iterator can be used instead of your open() + readLine() loop |
05:54:25 | FromDiscord | <snluu> oof nifty. nice! |
05:55:26 | aeverr[m] | ok this is more just nitpick of your intcode computer but try parsing 99 as an opcode too |
05:55:41 | leorize | - usually strutils.parse(Biggest)Int should be used unless you're writing a parser, as it's designed for parsing all number string |
05:55:47 | aeverr[m] | also strutils also contains |
05:55:47 | aeverr[m] | yeah |
05:55:58 | aeverr[m] | damn it leorize |
05:56:21 | leorize | stuff in parseutils is designed for writing a parser, where it's nice to know how many characters has been parsed |
05:56:59 | leorize | and I don't know why you're using int64, but I'd just assume that the puzzle needs it |
05:57:55 | voidlinux-free | whats wrong with https://play.nim-lang.org/#ix=241E ? |
05:57:57 | aeverr[m] | leorize, it doesnt at day 2 |
05:58:06 | aeverr[m] | it does in a later day |
05:58:18 | FromDiscord | <snluu> strutils.parseBiggestInt, nice. much better than my `assert parseutil.... > 0` haha |
05:58:38 | aeverr[m] | voidlinux-free, you need to discard the proc's result because its not void |
05:58:46 | aeverr[m] | its not returning void i mean |
05:59:15 | leorize | Nim does not let you discard a procedure result implicitly |
05:59:40 | aeverr[m] | best if you remove the `: string` because you arent returning a string anyway |
05:59:45 | FromDiscord | <snluu> RE int64, truth is, I come from C++ and am in the habit of declaring fix sized integers 🙂 |
05:59:49 | voidlinux-free | how do i discard it ? or return a void? |
05:59:53 | FromDiscord | <snluu> but good to know i'll need i64 later |
06:00:05 | FromDiscord | <snluu> `discard test("test")` |
06:00:16 | aeverr[m] | remove trhe last (one before the `=` sign) `: string` if you dont need to return a string |
06:00:18 | leorize | snluu: don't worry, Nim's integer sizes are much more predictable |
06:00:23 | voidlinux-free | okay its working, i removed what aeverr said |
06:00:24 | leorize | it's basically intptr_t :P |
06:00:47 | voidlinux-free | so the one after closing bracket is what we are going to return |
06:00:58 | leorize | yep |
06:01:39 | aeverr[m] | snluu this wouldnt be cheating anymore but day 5, 7, and 9 also utilize the intcode computer |
06:01:59 | leorize | @snluu: more tips: you could use `func` instead of `proc` if the proc doesn't mutate any states unreachable by its parameter |
06:02:01 | aeverr[m] | so i recommend making it its own module |
06:02:17 | leorize | it's basically the `let` equivalent of `proc` :P |
06:02:35 | FromDiscord | <snluu> as in, if it's a pure function? |
06:02:52 | leorize | yep |
06:03:53 | leorize | for maximum efficiency, don't use newSeq unless you need it |
06:04:03 | FromDiscord | <snluu> im trying to think through how the compiler would optimize it, base on what I know about nim |
06:04:23 | FromDiscord | <snluu> ^ RE `func` |
06:04:50 | leorize | no optimizations atm, but the C compiler might be able to do something abt it |
06:05:08 | leorize | the biggest perk is that most `func` can be used at compile time |
06:05:18 | FromDiscord | <snluu> ah, that's true |
06:05:29 | voidlinux-free | and how are modules declared? say i want to use a proc in multiple files |
06:05:39 | leorize | voidlinux-free: every file is a module |
06:05:48 | leorize | the file name sans `.nim` is the module name |
06:06:05 | voidlinux-free | so i could import test; and do test() it will work? |
06:06:14 | leorize | yes |
06:06:21 | voidlinux-free | what about file in another directory |
06:06:29 | aeverr[m] | dir/file |
06:06:32 | leorize | import "another directory" / file |
06:06:33 | aeverr[m] | import dir/file that is |
06:06:37 | FromDiscord | <snluu> leorize, as in, favor `var x: seq[int]` over `var x = newSeq[int](0)`? |
06:06:50 | voidlinux-free | okay thats awesome then |
06:06:50 | leorize | yea, it's less typing :P |
06:06:56 | aeverr[m] | lmao |
06:07:14 | voidlinux-free | and whats the difference b/w func and proc? faq says something about nosideeffect |
06:07:17 | aeverr[m] | i should upload my code too |
06:07:52 | FromDiscord | <snluu> lol |
06:07:53 | FromDiscord | <snluu> and yes |
06:08:08 | leorize | voidlinux-free: it means that you can't do things that affect what can't be reached via parameters |
06:08:38 | leorize | experimentation would explains it better |
06:08:45 | voidlinux-free | oh, i dont understand it |
06:09:00 | voidlinux-free | yeah maybe examples would explain better |
06:09:09 | voidlinux-free | i read an example on rosetta code (?) |
06:09:22 | aeverr[m] | if you change something thats in scope (for example, stdout) it has side effects |
06:09:32 | voidlinux-free | it said you cant echo x before x-y because of nosideeffect |
06:09:34 | aeverr[m] | but if its in the procedure arguments thats ok |
06:09:52 | aeverr[m] | echo writes to stdout, which usually isnt an argument |
06:10:28 | voidlinux-free | so with func, i cant write to stdout before any operation ? |
06:10:32 | leorize | @snluu: also you can do lines("input.txt").toSeq :) |
06:10:38 | leorize | toSeq can be found in sequtils |
06:11:11 | leorize | it stack all return values from an iterator to a seq |
06:11:23 | leorize | which is much better than reading an entire file then split it |
06:12:20 | FromDiscord | <snluu> cool. thank you for your tips! 😄 |
06:12:52 | FromDiscord | <snluu> lots of batteries included. such night n day coming form C++ ^^ |
06:13:13 | aeverr[m] | TFW agent running but gpg says theres none |
06:13:14 | aeverr[m] | aaaaaaaaaaaaaaa |
06:13:59 | leorize | @snluu: oh and sequtils.mapIt() is awesome |
06:14:18 | voidlinux-free | are variables global by deafult? |
06:15:05 | leorize | if you have an array of strings that are numbers, sseq.mapIt(parseBiggestInt it) will give you a `seq` filled with parsed numbers :P |
06:15:22 | leorize | voidlinux-free: no, they're scope bound by default |
06:15:42 | voidlinux-free | from what i understand, funtions are different scope right? |
06:15:43 | leorize | this does mean that top-level variables are global though |
06:15:47 | leorize | yep |
06:15:56 | voidlinux-free | oh okay so varibales in main are global |
06:16:22 | leorize | any indentation is a scope :) really handy |
06:16:52 | leorize | except for `when` statements |
06:17:35 | FromDiscord | <snluu> voidlinux-free: not sure if this will help, if you wanna really reason about pure function, the first and foremost requirement is, it will always behave the same given the same input. |
06:17:35 | FromDiscord | <snluu> that means, no stdout, no file IO, etc. since all of them can fail. |
06:17:35 | FromDiscord | <snluu> |
06:17:35 | FromDiscord | <snluu> that might also mean no random, unless it's a pseudo random function and you're providing the seed. |
06:17:35 | FromDiscord | <snluu> |
06:17:39 | FromDiscord | <snluu> that means it can't mutate anything outside of the function, including global variables (and again, stdio, files, etc.) because that would mean it could behave differently depending on when you call it. |
06:18:22 | Araq | that might be 'pure' but that's not Nim's definition. |
06:18:49 | FromDiscord | <snluu> oh, how so |
06:19:23 | Araq | Nim's definition is only concerned with global variables, access one and you're not .noSideEffect |
06:19:54 | Araq | or you call a proc that accesses a global (indirections are handled too) |
06:20:24 | Araq | the only reason why IO enters the stage here is because 'echo' accesses 'stdout' which is a global variable |
06:20:47 | Araq | so 'echo' has an effect |
06:21:21 | Araq | and you need to use debugEcho in your .noSideEffect proc which hides the fact that it accesses 'stdout' |
06:22:19 | voidlinux-free | so theres no talk of `func` and nosideeffect in nim basiscs, is there a doc somewhere that has examples explaning nosideeffect? |
06:22:37 | leorize | there's a ton in the manual |
06:22:51 | Araq | so what .noSideEffect really means: I only need to inspect the proc's *parameters* to understand its capabilities |
06:24:09 | voidlinux-free | Araq: so that means operations on parameters is not possible? but inspect - so comparision in if like statements is possible right? |
06:24:46 | voidlinux-free | leorize: are you talking about this: https://nim-lang.org/docs/manual.html#procedures-func |
06:24:47 | FromDiscord | <snluu> yep. if everything you need comes from the parameters, that's fine |
06:25:54 | voidlinux-free | https://play.nim-lang.org/#ix=241J so why does this say error test can have sideeffects? |
06:26:16 | FromDiscord | <snluu> because you're mutating the stdout buffer |
06:26:25 | voidlinux-free | oh so i cannot access anything other than parameters? so global variables go out of scope? |
06:26:46 | Araq | yeah, that's one way of looking at it |
06:26:53 | voidlinux-free | what is func useful for? like over proc |
06:27:00 | voidlinux-free | makes sense |
06:29:03 | Araq | it's mostly useful for multithreading |
06:30:30 | voidlinux-free | oh thansk i will look at it |
06:43:11 | * | njoseph joined #nim |
06:44:47 | * | voidlinux-free quit (Ping timeout: 260 seconds) |
06:54:24 | * | voidlinux-free joined #nim |
06:54:52 | voidlinux-free | what is the equivalent to key: value pair in nim? |
06:55:45 | voidlinux-free | array inside an array? |
06:56:48 | Araq | {a: v, b: w} is sugar for [(a, v), (b, w)] |
06:56:57 | Araq | so an array of tuples |
06:57:24 | Araq | until you concert it to some table but whether you need that depends on your problem |
06:57:29 | Araq | *convert |
06:57:41 | voidlinux-free | how will i access all the keys and values with that? |
06:57:55 | voidlinux-free | like test={1:2, 3:4} |
06:58:28 | leorize | !eval echo {1: 2, 3: 4} |
06:58:31 | NimBot | [(1, 2), (3, 4)] |
06:59:15 | voidlinux-free | !eval const t={1:2, 3:4}; echo &"t[1]" |
06:59:16 | NimBot | Compile failed: /usercode/in.nim(1, 26) Error: type mismatch: got <string> |
06:59:24 | voidlinux-free | !eval const t={1:2, 3:4}; echo &t[1] |
06:59:26 | NimBot | Compile failed: /usercode/in.nim(1, 26) Error: type mismatch: got <tuple of (int, int)> |
06:59:27 | voidlinux-free | !eval const t={1:2, 3:4}; echo t[1] |
06:59:31 | NimBot | (3, 4) |
06:59:42 | voidlinux-free | !eval const t={1:2, 3:4}; echo t[0][1] |
06:59:45 | NimBot | 2 |
06:59:56 | voidlinux-free | okay that makes sense, thanks |
07:01:46 | voidlinux-free | !eval const t={1:2, 3:4}; echo len(t) |
07:01:49 | NimBot | 2 |
07:02:15 | * | nif quit (Quit: ...) |
07:02:25 | * | nif joined #nim |
07:04:28 | voidlinux-free | !eval const t={1:2, 3:4}; echo type(t) |
07:04:31 | NimBot | array[0..1, tuple of (int, int)] |
07:07:43 | * | solitudesf joined #nim |
07:08:21 | voidlinux-free | so nim on obsd is v0.16 and choosenim doesnt work, its unmaintained so i dont think it will be updated in next realse |
07:09:11 | voidlinux-free | how do i install latest nim without making much changes ? |
07:09:37 | voidlinux-free | is running the install script on nim-lang.org good idea? |
07:09:48 | leorize | try to follow the manual building guide |
07:11:25 | voidlinux-free | okay |
07:11:31 | voidlinux-free | why doesnt this work?:https://play.nim-lang.org/#ix=241R |
07:11:43 | FromGitter | <gogolxdong> @shashlick, is nimssl going well? |
07:13:10 | leorize | voidlinux-free: `array` is not a type |
07:13:19 | voidlinux-free | !eval const t={1:2, 3:4}; echo type(t) |
07:13:20 | leorize | it has to be array of something |
07:13:22 | NimBot | array[0..1, tuple of (int, int)] |
07:13:28 | voidlinux-free | this says array is a type ^^ |
07:13:40 | voidlinux-free | oh isnt {} an array of tuples? |
07:14:30 | leorize | I mean the type on the proc |
07:14:30 | voidlinux-free | okay, i understand what you want to say, so how will i specify type here? |
07:14:35 | Araq | 'array' is a type-class, please use 'openArray[(int, int)]' as the parameter type |
07:15:04 | leorize | for starters: https://play.nim-lang.org/#ix=241S |
07:15:32 | voidlinux-free | okay open array works |
07:15:59 | voidlinux-free | leorize yeah that too works, but then i will have to take care of length as in my case it is going to be a variable |
07:17:02 | shashlick | @gogolxdong ran into an issue - https://github.com/tree-sitter/tree-sitter-cpp/issues/63 |
07:18:15 | shashlick | Also am traveling and don't have a local dev machine so hard to get any thing done |
07:19:41 | FromGitter | <gogolxdong> Don't worry, enjoy your trip. |
07:21:09 | FromGitter | <gogolxdong> Is seamless interaction with C++ counts on nlvm in the future? |
07:21:48 | * | dddddd joined #nim |
07:26:59 | voidlinux-free | so i have a module and i want to import only proc test and test1 from that module; like `from ../mymodule import test, test1` |
07:27:07 | voidlinux-free | currently with ^ it fails |
07:27:45 | leorize | for `..`, use ".." (with quotes) |
07:31:19 | voidlinux-free | so i used from ".."/mymodule import test, test1 and also from "../mymodule" .... it gives error |
07:31:29 | Kaynato | Found while implementing key-based sorting a la python: https://github.com/nim-lang/Nim/issues/12869 |
07:31:31 | disbot | ➥ Passing anonymous function containing anonymous function to algorithm.sorted produces invalid C @11Kaynato; snippet at https://play.nim-lang.org/#ix=241V |
07:31:39 | voidlinux-free | it says undeclared identifier, which means i guess it doesnt import it |
07:31:48 | leorize | voidlinux-free: do you have a reproducible case? |
07:32:02 | leorize | repl.it allows for multiple files, so you can use that instead |
07:32:47 | voidlinux-free | yes if you can then: touch index.nim, mkdir test, cd test and touch test.nim, |
07:32:55 | voidlinux-free | now i have proc head in index.nim |
07:33:01 | voidlinux-free | and want to import it to test.nim |
07:33:15 | voidlinux-free | index.nim, test/test.nim |
07:36:11 | voidlinux-free | i havent yet seen any example too of import module from parent directory |
07:37:16 | leorize | the compiler does this all the time |
07:37:48 | voidlinux-free | import ../index also doesnt work |
07:39:02 | leorize | did you export the proc? |
07:39:25 | voidlinux-free | no i iddnt do anything in index, i just defined it |
07:39:51 | leorize | https://nim-lang.org/docs/manual.html#procedures-export-marker |
07:40:36 | voidlinux-free | so only exported procs will be imported? |
07:40:48 | leorize | yep |
07:41:22 | leorize | https://nim-lang.org/docs/manual.html#modules |
07:41:27 | leorize | this one got a better explaination |
07:41:32 | voidlinux-free | which syntax is preferred, one import on one line or multiple imports on one line? |
07:42:00 | leorize | whatever fits you |
07:42:45 | Araq | multiple lines mean that you care about the irrelevant |
07:42:47 | Araq | :P |
07:48:10 | voidlinux-free | :) |
07:48:17 | voidlinux-free | so i have an issue, |
07:48:27 | voidlinux-free | there are 2 files 1.nim and 2.nim |
07:48:53 | voidlinux-free | i am importing test from 1.nim and that test proc uses a variable var(const) |
07:49:27 | voidlinux-free | i have defined const var in 2.nim too at the top but when i call test (imported from 1.nim) in 2.nim it uses var from 1.nim andnot 2.nim |
07:51:40 | voidlinux-free | 1.nim {has proc test - uses const var}, 2.nim { imports test from 1.nim and runs test()} - 2.nim is using const var from 1.nim but i have defined it seperately in 2.nim and i want it to use it |
07:52:05 | voidlinux-free | does that make sense? |
07:54:32 | * | solitudesf quit (Ping timeout: 268 seconds) |
07:55:36 | Zevv | everybody has that issue |
07:55:59 | voidlinux-free | oh so is it not an issue? how does it get fixed? |
08:00:00 | * | gmpreussner quit (Quit: kthxbye) |
08:05:09 | * | gmpreussner joined #nim |
08:10:56 | * | PMunch joined #nim |
08:16:20 | * | voidlinux-free quit (Remote host closed the connection) |
08:43:32 | * | floppydh joined #nim |
09:04:38 | FromDiscord | <yewpad> Araq: Thank you for merging! |
09:05:01 | FromDiscord | <yewpad> Guys, Dracula themed docs are just around the corner 😄 |
09:07:03 | * | ng0 joined #nim |
09:27:26 | * | tklohna joined #nim |
09:32:32 | FromDiscord | <kodkuce> voidlinux-free, best linux, anyway duno if right aswer but you can make 1.nim 2.nim shared.nim |
09:40:29 | * | clyybber joined #nim |
09:40:48 | FromDiscord | <Lantos> Frick I'm in a pickle guys I've made a small cli exe with nim. Works on my computer but I can't run it on other computers there is the error pcre32.dll is missing. Is there a way to bundle all the dependencies into the one exec? |
09:41:36 | livcd | there was also nimpcre if i remember correctly |
09:41:37 | FromDiscord | <Lantos> The build line I was using was nim c -d:release src/main.nim |
09:43:47 | FromDiscord | <Lantos> Is there a way to compile/build so I can just plug and play on other computers without nim installed? |
09:44:25 | Araq | yes but in your specific case, ship pcre32.dll next to your exe file |
09:44:56 | * | clyybber quit (Ping timeout: 265 seconds) |
09:45:50 | FromDiscord | <Lantos> Right I'll give that a shot |
09:47:03 | Araq | or use nim-regex which doesn't depend on pcre |
09:48:34 | * | clyybber joined #nim |
09:50:54 | FromDiscord | <Lantos> It worked thanks. |
09:53:03 | FromDiscord | <yewpad> `--passL:-s` wouldn't have helped here, am I right? |
09:53:12 | FromDiscord | <yewpad> `--passL:-static`, sry |
09:56:12 | Araq | depends on the wrapper |
09:56:51 | * | nc-x joined #nim |
09:57:01 | nc-x | Araq: https://github.com/nim-lang/Nim/issues/6540 can be closed |
09:57:02 | disbot | ➥ Need support for Visual Studio 2017 @11GooRoo |
09:57:03 | Araq | in this case it's -d:usePcreHeader but who knows if that works |
09:58:38 | nc-x | disruptek: IMO disbot should not ping people when an issue is posted here |
09:58:52 | * | nc-x quit (Remote host closed the connection) |
09:59:18 | * | voidlinux-free joined #nim |
10:00:20 | voidlinux-free | Zevv, sorry if that came out rude there. i didnt mean that, i was asking if that was a feature and not a bug? |
10:00:26 | voidlinux-free | how do i workaround this issue? |
10:03:32 | FromGitter | <alehander92> ugh return <value> in Future[void] {.async.} in the javascript backend |
10:03:53 | FromGitter | <alehander92> returns "attempting to call jsResolve .. found .. of kind 'var'" |
10:04:03 | FromGitter | <alehander92> what error should i eventually replace it with |
10:04:12 | Zevv | voidlinux-free: no offense, I was just doing other things. The typical Nim-way is to add your shared stuff to a third file - this tends to get messy for me every now and then though. |
10:04:35 | FromGitter | <alehander92> i will look at async but later |
10:05:36 | voidlinux-free | Zevv: oh! so if i make a third file where those variables are not defined? |
10:06:42 | voidlinux-free | thanks! |
10:08:50 | * | ikan-keli_2 is now known as ikan-keli_ |
10:08:59 | FromGitter | <bung87> if the c backend tests passed , js backend fails what should I complain ? |
10:12:12 | FromGitter | <bung87> it raise `Error: Error: unhandled exception: value out of range [RangeError] ` that does not help out. |
10:19:27 | * | voidlinux-free quit (Remote host closed the connection) |
10:23:21 | * | tklohna quit (Ping timeout: 246 seconds) |
10:32:29 | * | krux02 joined #nim |
10:37:40 | shashlick | Lantos: just use nimpcre - it does exactly what you want |
10:40:34 | Araq | bung87: well try 'testament cat js' on your machine to reproduce |
10:43:37 | FromGitter | <bung87> I change to build dev mode then run test it gives more info |
10:43:55 | FromGitter | <bung87> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5def76eb6a85195b9e2f7211] |
10:44:19 | * | azed joined #nim |
10:45:06 | FromGitter | <bung87> just still dont have clue to fix , it ‘ just `let input = strutils.strip(ipt).toLower` seems nothing wrong here |
10:46:18 | * | BarrOff joined #nim |
10:53:34 | FromGitter | <bung87> about testament, I never heared before, and search results doest not show any tools in bing or github |
10:54:53 | shashlick | It ships with Nim |
10:55:01 | shashlick | Used to test Nim itself |
11:08:56 | sealmove | @Zevv |
11:09:41 | sealmove | 1. why is the VM PR not merged yet? |
11:10:46 | sealmove | 2. I realized there is a format specification for ksy files, in JSON form: https://github.com/kaitai-io/ksy_schema/blob/master/ksy_schema.json. Do you think it's possible to integrate a json file like that with npeg? |
11:11:25 | * | Vladar joined #nim |
11:12:06 | Zevv | sealmove: because Araq didn't feel like merging PRs last PR-merge-friday :) |
11:12:16 | FromGitter | <bung87> @shashilick I can’t find the command on my mac |
11:12:25 | sealmove | I think this is a case where your manual-grammar-construction idea would shine |
11:12:44 | Zevv | parsing json is trivial in npeg, examples in the docs |
11:13:07 | sealmove | no I want to produce a grammar based on a json file :) |
11:13:12 | Zevv | I know :) |
11:13:44 | Zevv | but it hurts my head, so I decided to act as if I don't understand your question and hope to get away with that |
11:13:53 | sealmove | lol |
11:14:57 | sealmove | well, since this is awesome feature to have, because it will greatly improve the stability/consistency of nimitai, I am willing to help you implement the manual-grammar-construction API in npeg |
11:15:58 | Araq | Zevv, no, because the PR doesn't go far enough |
11:16:05 | Araq | give us more registers please! |
11:16:09 | Zevv | I added that! |
11:16:35 | Araq | https://github.com/nim-lang/Nim/pull/12777/files |
11:16:37 | disbot | ➥ Increased TInstr field sizes: allow long jumps and 65535 VM registers 🌈11zevv |
11:16:38 | Araq | where? |
11:16:47 | Araq | regABits = 8 |
11:16:47 | Zevv | "65535 VM registers"? |
11:16:50 | Araq | as before |
11:16:56 | Zevv | wut |
11:17:05 | Zevv | argh |
11:18:13 | Zevv | pushing helps |
11:18:35 | Zevv | someone could have told me that right, that I need to push stuff |
11:18:36 | Zevv | pfff |
11:18:41 | Zevv | I was *I* supposed to know?! |
11:19:00 | Araq | everybody can stare at diffs |
11:19:26 | Zevv | ok, CI running, sorry for the messup |
11:19:34 | Zevv | sealmove: because I did not push :) |
11:21:36 | * | rockcavera joined #nim |
11:23:26 | Araq | clyybber, ping |
11:25:50 | PMunch | yewpad, ooh nice! The Dracula theme docs looks nice :) |
11:26:54 | clyybber | Araq: pong |
11:27:10 | Araq | let m = if mode == normal: normal |
11:27:11 | Araq | else: sinkArg |
11:27:44 | Araq | that's what you do, I suppose it's your way of implementing "partial object construction" |
11:28:02 | sealmove | so Zevv, where do I start for manual npeg? |
11:28:20 | clyybber | Araq: yeah |
11:28:31 | Zevv | well npeg does probably not expose everything you need at this point |
11:28:41 | Araq | and that's why you don't do |
11:28:42 | Araq | if mode == normal: |
11:28:42 | Araq | result = ensureDestruction(result, c) |
11:28:44 | Zevv | basicallly everything sholuld be in npeg/patt |
11:28:59 | Araq | but it's wrong for nkObjConstr with ref since the constructor itself allocates |
11:29:02 | Zevv | which is used by parsepatt, look there for examples |
11:29:07 | Araq | that's different from nkBracket |
11:29:08 | sealmove | even running code on match? |
11:29:16 | clyybber | Araq: Argh. I see |
11:29:32 | Zevv | sealmove: that might prove tricky, id have to look into that |
11:29:34 | Araq | I've added 'transparent' to the enum |
11:29:50 | sealmove | ok, I'll check it out and keep you posted! |
11:29:58 | Araq | but I have no clue if it's required |
11:30:16 | clyybber | Araq: Can you send the commit? |
11:30:44 | Araq | it's just one line and I'm thinking about it, nothing to send |
11:30:47 | clyybber | Araq: I'm pretty sure it wont be needed |
11:30:50 | clyybber | Araq: Ah ok |
11:30:57 | Araq | aha, that was the question |
11:31:06 | Araq | so the 3 states are good enough |
11:34:42 | FromGitter | <bung87> does js backend development status behind c backend? |
11:35:03 | Araq | yes |
11:35:34 | Araq | we're currently not investing in the JS backend, PRs are always welcome though |
11:35:59 | Araq | and most developments are frontend or AST to AST transformations that the JS backend also benefits from |
11:36:23 | FromGitter | <bung87> ah , sounds reasonable. using C backend very well , I ‘ve deveoped serveral libs. but fails in first the js backend lib |
11:37:43 | FromGitter | <bung87> I thought maybe target to typescript will make the code gen easier |
11:37:56 | clyybber | Araq: So the problem is exclusive to nkObjConstr that "return" a ref object? |
11:38:11 | Araq | you tell me, I think so |
11:38:44 | clyybber | Hmm, I'm still trying to get it |
11:40:21 | clyybber | Araq: If the nkObjConstr will be consumed/sinked we don't have to destroy it or its args, no? |
11:41:14 | Araq | if it's sinked we don't have to destroy it but it must take ownership of its args |
11:41:38 | Araq | if it's not sinked we must destroy it and so it also must take ownership of its args |
11:43:29 | clyybber | So basically, we should always have `let m = sinkArg` and add a `if mode == normal: ensureDestruction` |
11:43:39 | clyybber | Maybe |
11:43:58 | Araq | no, ensureDestruction for [] is wrong |
11:44:25 | * | gangstacat quit (Quit: Ĝis!) |
11:44:52 | clyybber | Araq: Why? |
11:45:56 | Araq | because it doesn't own the data, we left the ownership to the temporaries involved inside [] |
11:48:31 | clyybber | why don't we make it own the data? |
11:49:23 | clyybber | sorry if I'm missing something ovious, I'm tired :p |
11:50:28 | Araq | same here... |
11:51:33 | Araq | so ... let me start from scratch: C(x) either owns 'x' or it doesn't |
11:51:51 | Araq | if C(x) owns its data, we must consume C(x) |
11:52:13 | Araq | if it doesn't own the data, it's harmful to destroy it (double frees etc) |
11:52:40 | Araq | we have the freedom to choose whether it owns it or not so we are smart about it |
11:53:27 | Araq | and we say, "if passed to a sink we demand C(x) to own its data" |
11:53:55 | Araq | otherwise we say "C(x) is just some temporary storage, it doesn't own anything, don't destroy it" |
11:54:02 | FromGitter | <bung87> a PR make js backend code gen mapping DateTime to Date , does it acceptable ? |
11:54:25 | Araq | bung87: maybe, GULPF will tell you in the review process |
11:55:29 | Araq | but if C(x) is a ref is MUST own its data since we must destroy it |
11:55:35 | FromGitter | <bung87> ah the timezones author, I did use his lib |
11:55:51 | Araq | so then we have no choice but to use 'sinkArg' |
11:56:02 | * | lritter joined #nim |
11:56:10 | * | luis_ joined #nim |
11:56:18 | Araq | yeah, that makes sense |
11:56:44 | clyybber | Araq: Right. But basically the fact that [] doesn't own the data as of now is an optimization |
11:56:48 | clyybber | so not strictly required |
11:57:10 | Araq | except that the 'echo' implementation requires it |
11:57:14 | Araq | ;-) |
11:57:20 | clyybber | Araq: Yeah, but thats a bug IMO |
11:57:32 | Araq | too hard to fix, tried |
11:57:50 | clyybber | Araq: :( I thought it'd be a matter of inserting a genExpr |
11:57:55 | * | luis_ quit (Client Quit) |
11:58:42 | Araq | it doesn't matter, we really want this partial object construction optimization |
11:59:39 | clyybber | Ok. So we need to adapt the conditions to take ref into account |
12:02:21 | Araq | the logic is a bit messy |
12:02:28 | Araq | but omg, all the tests are green |
12:02:33 | Araq | PR incoming... |
12:02:34 | clyybber | \o/ |
12:02:45 | clyybber | Araq: We should add a comment |
12:02:51 | Araq | I did |
12:02:55 | clyybber | Nice |
12:03:18 | clyybber | Araq: Also, can you move the `let m = ...` out of the loop? |
12:03:22 | clyybber | Its unneccessary in there |
12:03:26 | Araq | also done |
12:03:31 | clyybber | aweosme |
12:04:40 | Araq | so yeah, it wasn't a simple oversight from you, it was the optimization at work |
12:06:03 | Araq | but I think it's still wrong |
12:06:29 | clyybber | how? |
12:07:32 | * | solitudesf joined #nim |
12:08:07 | Araq | because my closure test is still red |
12:08:53 | clyybber | are closures also refs? |
12:09:03 | Araq | yes |
12:09:09 | Araq | well tuples with refs inside |
12:12:03 | * | gangstacat joined #nim |
12:16:38 | clyybber | Araq: Does it leak or crash? |
12:16:57 | Araq | leak |
12:18:11 | Araq | https://play.nim-lang.org/#ix=242w see for yourself |
12:23:39 | FromGitter | <bung87> `%0M%0o%0n%0d%0a%0y%0,%0N%0o%0v%0e%0m%0b%0e%0r%0, %0:%0a%0m` found the string output like this |
12:26:24 | FromGitter | <bung87> looks like the js backend doest correctly handle unicode? |
12:39:29 | * | PMunch quit (Quit: Leaving) |
12:39:45 | * | PMunch joined #nim |
12:39:45 | * | PMunch quit (Client Quit) |
12:40:25 | * | PMunch joined #nim |
12:41:56 | * | ng0 quit (Ping timeout: 260 seconds) |
12:42:33 | * | ng0 joined #nim |
12:42:42 | PMunch | @mratsim and Araq, we have 10 minutes left over in the schedule for FOSDEM which is currently assigned to dom96's talk (by random). He proposed the idea that since I'm the first Nim speaker of the day that I could take the extra minutes and spend them on introducing Nim so that people have more context for the last 4 talks, what do you think of that? |
12:42:57 | FromGitter | <mratsim> good for me |
12:43:22 | Araq | you're a good speaker, the more you speak the better |
12:45:19 | sealmove | woho what do I do with "access token"? |
12:45:41 | sealmove | do I tick everything? |
12:48:20 | * | endragor quit (Remote host closed the connection) |
12:48:52 | clyybber | Araq: Could it be that it leaks because of the discard optimization? |
12:49:44 | clyybber | Hmm, nope. Not the problem |
12:49:59 | clyybber | At least it doesn't look like it from looking at the C code |
12:50:22 | PMunch | Haha, thanks Araq :) I'll pitch the idea to the others then |
12:50:51 | PMunch | There was some talk about allocating it to the single Crystal talk we have as well, which would be good as well |
12:55:47 | sealmove | question: do import statements follow the typical Nim identifier convension? for example can I do `import myModule` to import `my_module.nim`? |
12:59:51 | Araq | no and in fact the convention is module_name |
13:00:15 | Araq | uppercase letters don't work well with Unix, so avoid them |
13:01:24 | sealmove | ok great |
13:02:23 | clyybber | Araq: Did you figure out the cause? Can't spot the error in the generated code |
13:04:45 | Araq | nope but I do know that a couple of days ago it did work |
13:04:54 | Araq | it's a regression |
13:05:45 | sealmove | does doing `nimble publish` once suffices for all versions? or do I have to do `nimble publish` each time I change my package? |
13:07:18 | sealmove | I guess only once? then versioning is taken care by github? |
13:08:15 | * | ng0 quit (Remote host closed the connection) |
13:08:31 | aeverr[m] | nim docs has dark mode woo |
13:09:23 | * | ng0 joined #nim |
13:12:22 | PMunch | Hmm, on Windows does "import someFile" work for somefile.nim since names on Windows are case-insensitive? |
13:16:04 | euantor | sealmove: You only `nimble publish` once to add it to the index, then after that you just push to cversion control (update version in the `.nimble` file and create a new tag) |
13:23:07 | aeverr[m] | how do i return a NaN |
13:23:23 | aeverr[m] | or is that not supposed to be possible in nim? |
13:23:56 | aeverr[m] | nvm, found NaN in system |
13:31:08 | FromDiscord | <Fern & Simula (They/Them)> you could always use an option type, that might help if NaN proves difficult |
13:33:28 | Araq | PMunch, there is also logic in the compiler to try and make it work but it's fragile |
13:34:54 | FromDiscord | <michalm> Do you know where I can find explanation of -d:nimOldCaseObjects ? Maybe some article with examples? I have to use it with the newest Nim and moustachu package. Without it, I can not compile my project. |
13:35:44 | FromGitter | <alehander92> probably the |
13:35:58 | FromGitter | <alehander92> moustachu package needs to be updated |
13:36:14 | FromGitter | <alehander92> to not assign stuff to the discriminator |
13:36:27 | clyybber | michalm: To port your code, replace `someobj.somediscriminatorfield = 3` with `someobj = SomeObj(someobjdiscriminatorfield: 3, ...)` |
13:37:57 | leorize | @michalm: it's in the 0.20 release note IIRC |
13:38:02 | FromGitter | <alehander92> which is strange because one of the last commits |
13:38:11 | FromGitter | <alehander92> made exactly that @Clyybber |
13:38:15 | FromGitter | <alehander92> but it seems https://github.com/fenekku/moustachu/blob/master/src/moustachupkg/context.nim#L88 |
13:38:18 | FromGitter | <alehander92> worked before |
13:38:21 | FromGitter | <alehander92> but probably not now? |
13:38:33 | FromGitter | <alehander92> its a simple fix if thats it |
13:40:50 | FromGitter | <mratsim> A pragma for type level oldcaseobject would be nice |
13:41:35 | FromGitter | <mratsim> For now I'm using unions but there are several cases where you want to do lazy enum kind changes |
13:42:13 | * | nsf quit (Quit: WeeChat 2.6) |
13:42:29 | FromGitter | <mratsim> Like when you want to parse a cryptographic key lazily before use instead of parsing it eagerly when loading a database |
13:42:55 | FromGitter | <mratsim> And a crypto key is heavy so avoiding temporaries is important |
13:45:54 | Araq | if you switch the case branch you might as well switch the full object |
13:46:07 | Araq | I don't understand how crypto is anything special here |
13:46:48 | Araq | Nim optimizes x = T() into an in-place construction, heck it did that even it was wrong, we got bug reports about it |
13:51:15 | FromDiscord | <mratsim> no I don't |
13:51:38 | FromDiscord | <mratsim> I have the key data in a buffer but it's not checked that it' a valid key because doing so is very expensive |
13:51:46 | FromDiscord | <mratsim> **very** expensive |
13:52:09 | FromDiscord | <mratsim> before use, I check the key, and if it's valid I change the case to valid key |
13:52:19 | FromDiscord | <mratsim> the data didn't change, but it's 32 bytes of data |
13:52:51 | FromDiscord | <mratsim> so we don't want to copy it because this step is the bottleneck of all ethereum 2 clients |
13:53:12 | FromDiscord | <mratsim> when I say bottleneck the go implementation used to spent 99.9% of their time in validating crypto keys |
13:53:18 | FromDiscord | <mratsim> the Rust implementation 30%+ |
13:53:19 | FromDiscord | <mratsim> and us too |
13:53:29 | * | Araq sighs |
13:53:32 | FromDiscord | <mratsim> any optimization to this is worth a lot |
13:53:42 | Araq | so move the buffer out of the 'case' in your object |
13:54:06 | FromDiscord | <mratsim> when the buffer is checked it becomes a different type, it's just the same data layout |
13:54:19 | Araq | Rust and Go don't even have case objects to begin with |
13:54:29 | FromDiscord | <mratsim> well to bad for them 😉 |
13:54:42 | FromDiscord | <mratsim> they don't have genrics for one and no AST based macro for the other |
13:55:07 | FromDiscord | <mratsim> now, I'm just laying out my case, I can use {.union.} for my need |
13:55:13 | FromGitter | <alehander92> Rust has enums which are similar enough + procedural macros |
13:55:37 | FromDiscord | <mratsim> but I think lazy case objects are probably a common use-case when you want to delay expensive stuff after loading from a DB |
13:56:03 | FromGitter | <alehander92> (rust "enums" are basically adt-s, dunno why they chose this name) |
13:57:28 | FromGitter | <alehander92> mratsim i guess having it change only on init(construction) simplifies a lot of stuff for the type system |
13:57:48 | FromGitter | <alehander92> if thats so araq is right, this should be just optimized somehow without kind= |
13:57:54 | * | sealmove quit (Quit: WeeChat 2.6) |
13:58:26 | Araq | well indeed, previously it was a loophole in the language |
13:59:02 | Araq | we claimed only cast/ptr/addr were unsafe but it wasn't true |
13:59:35 | Araq | so we fixed it for 1.0, and yes, we also considered a much more complex solution to fix it |
13:59:50 | Araq | but in the end the complexity budget is better spent elsewhere |
14:00:36 | FromGitter | <alehander92> what happened with z3 in nim btw |
14:00:45 | FromDiscord | <mratsim> As I said, I'm saying why it's worthwhile. And I'm saying that I can use {.union.} as a workaround |
14:01:39 | FromGitter | <alehander92> mratsim its worthwile to investigate if it can be optimized out by an optimizer somehow |
14:02:28 | clyybber | Araq: Are you bisecting? |
14:02:34 | Araq | clyybber, never |
14:03:02 | clyybber | how do you find the regressions then? |
14:03:24 | FromDiscord | <mratsim> he waits for people to find them |
14:03:42 | clyybber | I meant the cause :) |
14:03:49 | Araq | alehander92: it's scheduled for 2020, need to write an RFC first but prio number one has ARC |
14:04:12 | Araq | clyybber, I simply debug things. |
14:04:51 | Araq | bisecting is the last resort because it can be super misleading |
14:04:59 | clyybber | true that |
14:05:26 | Araq | it's often the case that it only happened to work before and so you're effectively looking at two bugs at the same time without noticing |
14:07:10 | FromDiscord | <mratsim> bisecting narrows down the candidate greatly though |
14:09:09 | Araq | not in the scenario I just described. |
14:09:19 | * | tklohna joined #nim |
14:14:15 | FromDiscord | <mratsim> btw did I miss something obvious for push/pop macros as pragms here? https://github.com/nim-lang/Nim/issues/12867#issuecomment-564011454 |
14:14:17 | disbot | ➥ Rules for custom pragma push/pop ⚫11mratsim; snippet at https://play.nim-lang.org/#ix=241c |
14:14:53 | FromDiscord | <mratsim> I want to add some benchmarking hooks to a whole file but doing so for every proc seems incredibly tedious when push pop would work |
14:17:02 | Araq | clyybber, I think eqdestroy___AbKdm3sBI9bOhxMNLQnbeIQ misses destructions |
14:17:55 | clyybber | Ah, I'm glad its not an injectDestructors bug |
14:18:48 | * | tklohna quit (Ping timeout: 252 seconds) |
14:19:58 | dom96 | PMunch doesn't the Crystal talk already have 30 minutes? |
14:25:08 | PMunch | dom96, yes, I realised that as well |
14:25:19 | PMunch | We got 20 minutes in total, 10 was allocated for Crystal, and 10 for Nim |
14:25:30 | PMunch | But now I see that mratsims talk is also 30 minutes long.. |
14:26:21 | dom96 | huh, Araq's seems to be 30 now |
14:26:26 | * | nc-x joined #nim |
14:27:03 | disruptek | hmm, should i pull the username out of the bot messages so it doesn't ping people who have the same nicks on irc? |
14:29:48 | nc-x | @mratsim if the code works when the pragma is manually applied, but does not work with push, then push may be applying it wrongly. just find where is push applies pragmas in compiler code, and print the result with `debug`, also `debug` the node in the manual case, and compare them. there should be a difference between them if this is the case. or |
14:29:49 | nc-x | it could be that push applies pragma somewhat late, though that is less likely. there may be some other reason though. |
14:30:14 | dom96 | disruptek: yep |
14:32:25 | disruptek | #12867 |
14:32:27 | disbot | https://github.com/nim-lang/Nim/issues/12867 -- 3Rules for custom pragma push/pop ; snippet at 12https://play.nim-lang.org/#ix=241c |
14:36:58 | * | luis_ joined #nim |
14:38:10 | * | luis_ quit (Client Quit) |
14:38:25 | * | luis_ joined #nim |
14:42:49 | FromDiscord | <mratsim> @nc-x I still think it's the overloading resolution |
14:43:10 | FromDiscord | <mratsim> because the pragma is not instantiated so the overload resolution finds nothing |
14:43:34 | nc-x | yeah |
14:43:36 | FromDiscord | <mratsim> now I may be biaised by all the generics/templates bugs I've encountered :p |
14:43:37 | nc-x | just checked |
14:43:49 | nc-x | problem lies in semOverloadedCall |
14:43:54 | nc-x | it returns nil |
14:44:44 | FromDiscord | <mratsim> even the "XXX: why is this here?" doesn't inspire the utmost confidence 😉 |
14:51:59 | * | nc-x quit (Ping timeout: 260 seconds) |
14:52:37 | * | nc-x joined #nim |
14:52:39 | * | luis_ quit (Quit: luis_) |
14:54:07 | * | shadowbane quit (Quit: Konversation terminated!) |
14:55:40 | * | shadowbane joined #nim |
14:59:50 | * | ng0_ joined #nim |
15:00:55 | * | ng0 quit (Disconnected by services) |
15:00:55 | * | ng0_ is now known as ng0 |
15:08:36 | * | PMunch quit (Quit: Leaving) |
15:08:42 | * | luis_ joined #nim |
15:09:46 | * | luis_ quit (Client Quit) |
15:13:56 | nc-x | @mratsim I probably have a fix. will work on it tomorrow |
15:16:46 | FromDiscord | <mratsim> nice, if it's small enough that it can be backported that would be awesome because for now we are staying on the 1.0.X branch |
15:16:51 | FromDiscord | <mratsim> (it's for nimbus) |
15:20:01 | nc-x | if you manually apply the custom pragma to a proc, the proc is added as an argument to the pragma automatically. so the template/macro needs to have an `untyped` as the last argument. If it has zero arguments, then compiler says that the pragma is not found. |
15:20:14 | nc-x | for push, we do not currently add the proc as the last argument. |
15:20:18 | nc-x | so the reverse case works |
15:20:35 | nc-x | macros/templates without any extra `untyped` args work. |
15:20:57 | nc-x | so the solution is to add the `proc` as the last argument here as well |
15:21:28 | nc-x | and document (if not already) / give better error message that custom pragmas need to have last parameter as `untyped` |
15:21:41 | * | ponyride1 joined #nim |
15:23:50 | * | ponyrider quit (Ping timeout: 276 seconds) |
15:24:52 | * | nc-x quit (Remote host closed the connection) |
15:25:50 | FromDiscord | <mratsim> how can you do that during push? |
15:26:13 | FromDiscord | <mratsim> {.push myPragma(procPlaceholder).} |
15:28:50 | * | nc-x joined #nim |
15:29:08 | nc-x | no |
15:29:21 | nc-x | it is done automatically by the compiler |
15:29:48 | * | leorize quit (Quit: WeeChat 2.6) |
15:30:16 | nc-x | in semCustomPragma, to the nkCall we add the last node as the proc (without the pragma) itself |
15:31:12 | nc-x | for manually applied pragma, it is already done at semstmts.nim:1426-1430 |
15:31:40 | nc-x | so if you or anybody else wants to implement this patch, go ahead |
15:33:09 | nc-x | alternative fix could be to change to order so as to apply `push` pragma before sem runs on proc, so that in the end both the above cases follow the same code path (which is not the case now).) |
15:33:25 | nc-x | but that would be a more difficult approach, and maybe not even possible |
15:33:35 | * | nc-x quit (Remote host closed the connection) |
15:33:40 | disruptek | well, the rule is... it has to be possible. |
15:33:48 | disruptek | Araq is a real stickler about that. |
15:34:11 | * | nc-x joined #nim |
15:34:29 | nc-x | ha! and by Araq's logic, disruptek just volunteered to implement the patch ;) |
15:35:38 | disruptek | damn Araqlogic. |
15:35:41 | disruptek | gets me every time. |
15:36:06 | nc-x | :D |
15:36:11 | * | nc-x quit (Remote host closed the connection) |
15:37:14 | * | nsf joined #nim |
15:46:34 | rockcavera | Is it possible to kill a thread? If so, how do I do it? I found nothing at https://nim-lang.org/docs/threads.html |
15:52:27 | FromDiscord | <mratsim> join |
15:53:13 | disruptek | should bitops work on cint/cuint? |
15:55:13 | FromDiscord | <mratsim> cint/cuint are only there for C compat, if you want to do processing beyond just passing them to C proc, convert them to Nim, it's a "zero-cost abstraction" (TM) |
15:55:35 | disruptek | i wish i'd have gotten a warning. |
15:55:57 | FromDiscord | <mratsim> did that launch missiles? |
15:56:34 | disruptek | turns out, i'm stupid. |
15:56:47 | clyybber | you want a warning for that? |
15:56:51 | disruptek | yeah. |
15:58:06 | disruptek | i wrote bitand instead of bitor and every time i looked at the code, my eyes just scanned right past it. |
16:01:08 | clyybber | s/scanned/scammed |
16:01:35 | Araq | clyybber, well... it's time you learn about 'liftdestructors' isn't it? |
16:01:51 | Araq | injectdestructors is now sane |
16:02:00 | Araq | liftdestructors is a mess |
16:02:30 | Araq | anyway, here is something really hard for you guys: https://www.youtube.com/watch?v=i4VqXRRXi68 |
16:06:36 | clyybber | clyybber: I know its a mess :P thats why I haven't dared to touch it yet |
16:06:51 | disruptek | you tell'im, clyybber. |
16:07:20 | disruptek | clyybber: you gonna let clyybber talk to you that way? pffbt. |
16:07:36 | clyybber | guddamn |
16:07:43 | clyybber | errytim |
16:07:53 | Araq | so ... the bug is |
16:08:04 | Araq | the 'callback' field is never destroyed |
16:08:24 | Araq | which makes sense as I made it a 'cursor'?! |
16:09:40 | * | floppydh quit (Quit: WeeChat 2.6) |
16:09:57 | clyybber | weird, when I looked at the code you sent I was about to ask if it is because of the cursor, then I looked at the code again and saw there was no cursor and I misread closure as cursor |
16:10:05 | clyybber | and now there is a cursor?? |
16:10:12 | clyybber | life makes no sense |
16:10:22 | disruptek | because it looked wrong without it. |
16:10:35 | Araq | but then the compiler complains |
16:10:37 | Araq | Warning: ':envP.f4.callback = (:anonymous, :envP)' creates an uncollectable ref cycle; annotate 'callback' with .cursor |
16:10:40 | Araq | [CycleCreated] |
16:11:37 | Araq | I'm bad at breaking up cycles, spent too much time in GC land |
16:13:36 | clyybber | FWIW it doesn't make a difference for the memory leaked with or without cursor |
16:13:39 | Araq | I think 'var f' must be the curcor |
16:13:51 | Araq | clyybber, yeah but it creates a cycle ;-) |
16:13:57 | Araq | you must break it. somehow. |
16:17:54 | * | nc-x joined #nim |
16:18:30 | nc-x | araq: is it possible to change the order of execution sem to sem `push` before `proc`? |
16:24:57 | * | nc-x quit (Remote host closed the connection) |
16:25:06 | Araq | clyybber, anyway, it's not a regression, it merely happened to work before |
16:25:18 | Araq | because of bugs cancelling each other out |
16:26:27 | clyybber | Araq: proved a point today, did we :) |
16:26:42 | clyybber | Araq: Did you test your cycle detector on it? |
16:28:03 | clyybber | s/detector/collector |
16:28:23 | Araq | no |
16:28:46 | clyybber | It should handle it even without cursor right? |
16:29:11 | Araq | right but I doubt it's ready for it |
16:29:19 | * | nc-x joined #nim |
16:29:42 | Araq | nc-x, maybe I think you know more about the code than I do |
16:30:01 | Araq | as I'm deep into something else (yeah, yeah, yeah, naughty stuff) |
16:30:14 | nc-x | lol |
16:30:42 | * | azed quit (Quit: WeeChat 2.6) |
16:30:42 | disruptek | there are some dark corners in araqlogic. best not shine a light in there. |
16:31:43 | nc-x | well, alternatively, I can remove the pragma processing from `semProcAnnotation` (does semProcAnnotation only consist of pragma processing?), so that it gets processed later. this will also unify the code paths for `push` and manual pragma application. |
16:32:06 | nc-x | will test later |
16:32:13 | Araq | listen to your heart |
16:32:35 | disruptek | araq needs to lay off the cough syrup. |
16:33:47 | nc-x | if i was using my brains, i would be studying for my ongoing exams instead of sitting on irc and github ;) |
16:34:29 | disruptek | then scratch that, don't listen to your heart. |
16:34:58 | Araq | fixed it! :-) |
16:35:09 | Araq | one line in the compiler |
16:35:15 | Araq | and now it even makes sense |
16:35:23 | Araq | and previously it didn't |
16:35:26 | nc-x | anyways, Araq is there some estimations on how much time is required to finish the arc implementation to make it reach beta+ quality? |
16:35:40 | clyybber | nc-x: 1 hour |
16:35:51 | clyybber | make it a minute |
16:35:53 | Araq | I'll release in 12 days |
16:35:54 | nc-x | disruptek: I will do better, I am going to listen to both my heart and mind and go to sleep instead. |
16:36:09 | Araq | oh wait, 14 days |
16:36:16 | Araq | can't calculate |
16:36:19 | clyybber | Araq: christmas present? |
16:36:32 | disruptek | nc-x: listen to me instead. |
16:36:38 | disruptek | GET DRUNK. |
16:36:52 | Araq | yeah, it's a christmas special, use all of Nim in an embedded, hard realtime setting |
16:37:35 | disruptek | it ends in an infinite loop. or rather, it doesn't end. |
16:37:54 | Araq | (but better avoid ref, closures and everything that allocates memory) |
16:38:11 | Araq | (or that calls into the OS) |
16:39:01 | Araq | (and maybe also avoid every loop that can run for too long. oh and don't use recursion) |
16:41:11 | * | nc-x quit (Ping timeout: 260 seconds) |
16:41:19 | clyybber | avoid IO embrace P = NP |
16:42:13 | Kaynato | Re: Distance between random points in a square: https://cdn.discordapp.com/attachments/158021079464542208/653999822625570829/unknown.png |
16:42:48 | Kaynato | Don't think anyone has done a symbolic math library yet |
16:42:59 | Kaynato | (In nim, beyond just the algebraic structures one) |
16:46:08 | clyybber | or rather O(0) = T(n) |
16:48:17 | Araq | anyhow, we need to decide what to do with the cycle collector, should it be opt-in or opt-out? |
16:49:12 | clyybber | Araq: Opt-out I'd say |
16:49:27 | clyybber | Araq: You mean per object right? |
16:49:46 | Araq | no, per object is clear, it's .acyclic because legacy |
16:50:20 | Araq | but enabling it is a performance killer |
16:50:54 | clyybber | Araq: How much? |
16:51:35 | Araq | factor of 2, easily |
16:52:06 | clyybber | I thought it would go near noise when we sink? |
16:52:06 | Araq | we need at least some basic optimizations |
16:52:24 | Araq | yeah, when you sink so much that RC == 1 all the time |
16:52:45 | clyybber | Araq: Its only enabled for objects that the compiler is unable to prove are acyclic right? |
16:53:13 | Araq | yeah but look, the compiler needs help via .ayclic already |
16:54:40 | FromDiscord | <mratsim> @zevv @rayman22201 that may be the smallest async-based coroutines implementation I ever saw: https://github.com/naasking/async.h/blob/master/async/async.h |
16:55:00 | FromDiscord | <mratsim> coroutine-based async* |
16:55:48 | clyybber | and most of it is comments |
16:56:42 | * | BarrOff quit (Quit: leaving) |
16:57:45 | rayman22201 | Async is just a state machine. How hard can it be. 😝 |
16:58:53 | clyybber | Araq: Make the compilers compile time potential cycle detector aware of .cursor? |
16:59:15 | FromDiscord | <snluu> random question, does Nim optimize recursive tail calls? Or does it leave that to the C compiler? |
16:59:28 | Araq | clyybber, oh a good one! I missed that |
17:02:37 | Araq | it doesn't help much though, in the end 'owned ref' is more elegant because of the exact aliasing information, consider |
17:03:58 | Araq | +-----------+ +-----------------+ |
17:03:58 | Araq | | | | | |
17:03:58 | Araq | | +---left----> | |
17:03:58 | Araq | | | | | |
17:03:59 | Araq | | | | | |
17:04:00 | Araq | | +----right--> | |
17:04:01 | Araq | +-----------+ +-----------------+ |
17:04:31 | FromDiscord | <mratsim> @snluu, C compiler |
17:04:35 | Araq | can you pass x.left to thread A and x.right to thread B? no. |
17:04:57 | Araq | can you construct this graph? easily. with 'owned ref' you can't |
17:05:00 | rockcavera | Is it possible to kill a thread? If so, how do I do it? I found nothing at https://nim-lang.org/docs/threads.html |
17:05:02 | FromDiscord | <mratsim> and it does that **very** well |
17:05:12 | FromDiscord | <mratsim> much better than C or C++ 😉 https://github.com/drujensen/fib#natively-compiled-statically-typed |
17:05:25 | FromDiscord | <mratsim> @rockcavera, I already replied, use joinThread |
17:05:48 | FromDiscord | <mratsim> the terminology in multithreading is fork/join |
17:05:59 | FromDiscord | <mratsim> I know it's confusing, I was confused as well |
17:06:11 | Araq | that's not "killing" a thread at all |
17:06:16 | Araq | that waits for its completion |
17:06:26 | Araq | killing a thread is deprecated in posix land |
17:06:28 | rockcavera | mrastsim, I want to terminate the thread and not wait for it. |
17:06:33 | FromDiscord | <snluu> @mratsim thanks! |
17:06:44 | Araq | you need to add a flag that is polled by the worker threads |
17:07:02 | FromDiscord | <mratsim> ^ this |
17:07:14 | * | uvegbot joined #nim |
17:07:16 | lqdev[m] | found a bug with converters and varargs: https://play.nim-lang.org/#ix=243W |
17:07:36 | rockcavera | Araq thanks, I thought it had a different shape than that. |
17:07:40 | Araq | the logic in posix is something like "you can't kill it, it could hold a lock" |
17:07:57 | Araq | as usual, it makes no sense. |
17:08:15 | Araq | I might also kill a process that has a file lock, now what |
17:08:27 | Araq | are we gonna deprecate killing processes? |
17:08:37 | * | zyklon quit (Ping timeout: 240 seconds) |
17:08:50 | Araq | these standards are written by fools, it's sad |
17:09:30 | FromDiscord | <treeform> File locking is even worse on windows. |
17:09:59 | FromDiscord | <mratsim> in my runtime i poll a flag for the master thread: https://github.com/mratsim/weave/blob/master/weave/runtime.nim#L129-L131 |
17:09:59 | FromDiscord | <mratsim> and then it sends the instruction to child threads to shutdown: https://github.com/mratsim/weave/blob/master/weave/signals.nim#L63 |
17:10:17 | Araq | treeform: not the point. |
17:10:34 | clyybber | but a fact :) |
17:10:46 | clyybber | all options suck |
17:10:53 | clyybber | I wonder what redux does |
17:10:56 | clyybber | redox |
17:10:59 | Araq | Windows can be as terrible as it wants to be, it doesn't make Posix any better. |
17:11:06 | FromDiscord | <mratsim> compounded by nimsuggest not terminating and prevent git operations on Nim file .... |
17:11:50 | FromDiscord | <treeform> Araq, I would argue that having windows being worse does make posix better choice for things. |
17:12:50 | FromDiscord | <mratsim> That could be reworded as Rust/D/Crystal/V/Zig vs Nim 😉 |
17:14:09 | disruptek | glass houses. |
17:18:42 | FromDiscord | <treeform> @mratsim wow that async.h is pretty small. It does appear to require more housekeeping with flag setting? |
17:19:24 | FromDiscord | <mratsim> I don't know, never used 😛 |
17:19:44 | FromDiscord | <mratsim> don't ask me about coroutines/IO (yet) never touched |
17:20:09 | rayman22201 | I doubt it's very feature complete lol. I will say, C macros always hurt my brain... |
17:20:38 | rayman22201 | Cool PoC though |
17:29:14 | * | ryukoposting joined #nim |
17:29:20 | ryukoposting | howdy |
17:30:16 | * | endragor joined #nim |
17:30:18 | aeverr[m] | hello there |
17:30:32 | ryukoposting | it's been a while, how's 1.0 going |
17:30:43 | ryukoposting | haven't been able to keep tabs on the community lately |
17:39:42 | aeverr[m] | 1.0.4 out now though i dont think theres much of note unless you're deeper into nim |
17:41:58 | rayman22201 | Nim 2020 is where the all the cool kids are: https://github.com/nim-lang/RFCs/milestone/1 |
17:46:19 | ryukoposting | neat |
17:46:43 | ryukoposting | checked up on my nimble packages a few days ago, seems like they still compile |
17:48:05 | * | endragor quit (Remote host closed the connection) |
17:50:00 | solitudesf | make a video or else |
17:52:38 | ryukoposting | reee |
17:52:52 | ryukoposting | what should I make a video about |
17:53:01 | ryukoposting | I have a few ideas sitting somewhere |
17:53:26 | Araq | treeform: the problem with that idea is that Posix will never get any good with this attitude |
17:53:42 | Araq | I mean, I personally don't care, IMHO posix doesn't even exist anyway, but still |
17:56:03 | shashlick | What do you think of NixOS |
17:56:39 | ryukoposting | hot take: unix is bad, windows is bad, posix is bad, android is bad, all of it is based on decades-old assumptions about computer users and the information they manipulate |
17:57:51 | ryukoposting | (most of those assumptions now being completely incorrect, and a hindrance to efficient and user-friendly computer systems) |
17:57:56 | ryukoposting | nixos is cool though |
18:00:41 | Araq | never tried NixOS, heard good things about it |
18:06:39 | clyybber | Hmm, the search field is still light with the dark theme |
18:16:16 | * | Trustable joined #nim |
18:48:05 | FromDiscord | <mratsim> Android doesn't even set basic POSIX constants properly ... |
18:48:44 | krux02 | ryukoposting, well those old operating systems were at least made by people who knew the hardware, "modern" "operating systems" are my in complete ignorance towards the hardware and what it is able to do fast. |
18:50:10 | FromDiscord | <mratsim> The issue with old operating system was that they assume that CPU time was more costly than memory, but nowadays, you wait for memory much more than you wait for CPU, which means, all those linked lists are bad 😛 |
18:51:42 | * | ryukoposting quit (Quit: Lost terminal) |
18:51:46 | rayman22201 | Posted in off-topic but seems relevant here: https://blog.acolyer.org/2019/12/09/a-persistent-problem/ |
18:53:22 | FromDiscord | <mratsim> I thought blockchain were supposed to solve all issues pertaining to transactions and identity and render databases obsolete 😉 |
18:57:16 | krux02 | mratsim: all disruptive technologies are disruptive |
19:08:42 | Zevv | If I have foo: Table[A, B], should foo.keys.toSeq() work? |
19:08:58 | * | adeohluwa joined #nim |
19:09:27 | * | nsf quit (Quit: WeeChat 2.6) |
19:10:13 | FromDiscord | <mratsim> @Araq, can I get collaborator right to the RFCs repo? I can't transfer issues there :/ https://github.com/nim-lang/Nim/issues/12873 |
19:16:49 | FromDiscord | <mratsim> We got another Pimp up this sub post ... |
19:36:52 | * | Vladar quit (Quit: Leaving) |
19:38:40 | * | nsf joined #nim |
19:45:27 | * | nsf quit (Quit: WeeChat 2.6) |
19:50:53 | * | ng0 quit (Remote host closed the connection) |
19:52:00 | * | ng0 joined #nim |
19:58:59 | * | clyybber quit (Quit: WeeChat 2.7) |
20:02:17 | FromDiscord | <itmuckel> Whoa, so many languages |
20:02:17 | FromDiscord | <itmuckel> https://cdn.discordapp.com/attachments/371759389889003532/654050269981573132/unknown.png |
20:02:42 | FromDiscord | <itmuckel> That's the first time I even read about Zig |
20:05:00 | disruptek | does it make your pants tight? |
20:05:10 | FromDiscord | <yewpad> What's the context? |
20:07:04 | FromDiscord | <yewpad> Ha, Crystal. Like all of the listed languages have Windows support and Crystal's still struggling with it, ever since the issue was opened back in 2013. Geez. |
20:07:26 | FromDiscord | <itmuckel> @disruptek Hmmmm, I try hard to see where Zig stands out. 🤔 |
20:07:38 | FromDiscord | <itmuckel> Or Crystal |
20:08:30 | FromDiscord | <yewpad> It's your friendly neighbor Rust but without the annoying compiler and annoying borrow shit. It tries to compete with C, not to depend on it |
20:08:43 | lqdev[m] | why doesn't crystal have windows support though |
20:08:46 | lqdev[m] | it doesn't make any sense to me |
20:08:54 | FromDiscord | <yewpad> idk |
20:08:57 | FromDiscord | <yewpad> it's been 6 years |
20:09:02 | FromDiscord | <yewpad> and they still don't have it |
20:09:08 | lqdev[m] | like, are all the developers using linux or what |
20:09:12 | FromDiscord | <yewpad> i lost hope long time ago |
20:09:18 | lqdev[m] | because I feel like that's very unlikely to be true |
20:09:44 | FromDiscord | <yewpad> no they think it doesn't even matter because all of the people would deploy to Linux/Docker, which, technically is right, but still, most of developers develop on Windows |
20:10:18 | disruptek | a lot of devs are on macs. |
20:10:35 | lqdev[m] | also, game developers are a thing |
20:10:54 | FromDiscord | <itmuckel> A programming language not supporting windows? 😄 |
20:11:11 | lqdev[m] | and if your game's not out on windows, it's p much doomed to fail |
20:11:12 | FromDiscord | <yewpad> Crystal's not alone |
20:11:17 | FromDiscord | <yewpad> Swift is also not supporting win |
20:11:26 | rayman22201 | something I love about Nim. It is extremely cross platform. Even if it's not officially supported, it's easy to port Nim. I got nim working on an old IBM AIX box once. I'm just saying... |
20:11:42 | FromDiscord | <yewpad> :oo lol |
20:12:12 | lqdev[m] | swift is proprietary apple shit, I don't even care about it |
20:12:25 | FromDiscord | <yewpad> i do neither |
20:12:56 | FromDiscord | <yewpad> *m2 |
20:13:23 | lqdev[m] | there's one thing I hate about apple, and it's how much of a closed ecosystem they created. |
20:13:26 | FromDiscord | <yewpad> crystal would see a whole lot more adoption if there were just windows support |
20:13:39 | lqdev[m] | indeed |
20:14:56 | FromDiscord | <itmuckel> @lqdev did you ever hear the tragedy of deprecating OpenGL on MacOS? |
20:15:18 | FromDiscord | <yewpad> Minecraft players are gonna be so bumped |
20:15:18 | FromDiscord | <yewpad> xD |
20:16:03 | * | adeohluwa quit (Remote host closed the connection) |
20:28:16 | lqdev[m] | @itmuckel it's not a story the mac users would tell you |
20:30:32 | * | NimBot joined #nim |
20:36:01 | FromDiscord | <yewpad> can somebody point me to a nim bitmask example? can't find anything |
20:48:32 | lqdev[m] | @yewpad you mean, just basic bitmasking? use `and` for that: `x and 0b10101010 # discards any bits that are 0` |
20:53:23 | * | narimiran quit (Ping timeout: 265 seconds) |
20:53:49 | * | solitudesf quit (Ping timeout: 250 seconds) |
20:57:41 | FromDiscord | <mratsim> what does moving cursor into closures mean? https://github.com/nim-lang/Nim/pull/12872 |
20:57:43 | disbot | ➥ ARC: fixes cycle detection and move the .cursor attribute into closures |
20:59:51 | FromDiscord | <mratsim> @yewpad apparently there is a language for game devs called Jai, but well, no one ever saw the light of the binaries so. And AFAIK it's from one of the most success ful gamedevs |
20:59:57 | FromDiscord | <mratsim> Jonathan Blow iirc, |
21:00:10 | Yardanico | I thought Jai was already released? not yet? lol |
21:00:27 | FromDiscord | <kodkuce> so ARC now up and running? |
21:00:33 | FromDiscord | <mratsim> and I forgot about Odin |
21:00:53 | Araq | kodkuce: depends on what you throw at it |
21:01:00 | Araq | we routinely find showstopper bugs |
21:01:09 | Araq | we also fix them, but... |
21:01:18 | FromDiscord | <kodkuce> ok i am still newb so dont want to go in doom |
21:01:35 | Araq | yeah there are other languages than Nim, this is #nim though |
21:02:02 | disruptek | y'know, #doom is pretty safe, even for newbies. |
21:02:48 | Araq | mratsim: .cursor is the pragma you use to introduce weak, untraced refs |
21:03:00 | Araq | in order to break up cycles or well |
21:03:08 | Araq | to iterate through a tree/list |
21:03:12 | FromDiscord | <mratsim> yeah I know, but why closures |
21:03:29 | Araq | closures create cycles in all sort of surprising ways |
21:03:35 | FromDiscord | <mratsim> or do you mean it wasn't available in closures before? |
21:03:39 | FromDiscord | <kodkuce> i like nim just dont want to think i doing somethign wrong while its a bug so am trying to stay safe |
21:04:01 | Araq | so if we lift a variable into the closure we must remember the .cursor annotation |
21:04:09 | Araq | see the test case |
21:04:26 | FromDiscord | <mratsim> I see |
21:05:01 | Araq | and with this fix async might actually start to work... ha ha ha |
21:05:06 | Araq | good one |
21:05:20 | Araq | at least it doesn't crash anymore |
21:05:22 | Araq | for now. |
21:06:18 | lqdev[m] | what's the first child of nnkEnum for? |
21:07:09 | lqdev[m] | pragmas, I guess? |
21:09:46 | FromDiscord | <mratsim> for sacrifice to the Nim god |
21:10:15 | Araq | planned feature that never happened: enum inheritance |
21:10:18 | lqdev[m] | lol |
21:10:23 | * | donpdonp joined #nim |
21:10:26 | lqdev[m] | ah, I thought that could be the case |
21:10:37 | lqdev[m] | but then I tried to see if it's valid and was not, so I got confused |
21:10:41 | donpdonp | echo &"this {1}" => Error: type mismatch: got <string> |
21:11:14 | * | donpdonp headdesks |
21:11:23 | lqdev[m] | another question, is it possible to get `low(T)` and `high(T)` from an nnkSym without creating an intermediate nnkCall? |
21:12:54 | donpdonp | okay thats a very confusing error meaning strformat was not included |
21:13:50 | Yardanico | donpdonp: well, it's not really confusing if you know that & is a concatenation operator for strings |
21:14:02 | Yardanico | *also |
21:14:20 | FromDiscord | <mratsim> it's hard to know about things that are not imported though |
21:14:41 | Yardanico | in the full error message the compiler tells you all possible `&` where first argument can be a string |
21:16:44 | FromDiscord | <mratsim> yes but it can't tell you about strformat since it's not imported |
21:18:40 | donpdonp | Yardanico: given that its not a two-operand statement, its confusing that nim would be going to a two-operand operation like "string & string" |
21:19:01 | Yardanico | donpdonp: it's not going though? it's just giving you all possible variations |
21:19:04 | donpdonp | unless its evaluating it as (echo()) & (string) ? |
21:19:29 | Yardanico | https://play.nim-lang.org/#ix=2458 try to run it online |
21:19:44 | Yardanico | and you'll get full output which shows that you only got 1 argument |
21:20:09 | Yardanico | in Nim the difference between operators and normal procs is not that big, it's in the way you can call them |
21:20:17 | donpdonp | the short output also says it only got 1 arg |
21:20:25 | Yardanico | you can call string concat operator like this: let c = &(a, b) |
21:21:10 | Yardanico | ah, sorry, I mean `&`(a, b) |
21:21:11 | donpdonp | yeah thats just confusig to have & take on a totally different meaning (and number of arguments) |
21:21:39 | Yardanico | IMO it's not really confusing, and & was specifically chosen because it was already used for string concat |
21:21:43 | Yardanico | there's also "fmt" if you don't like using & |
21:22:17 | donpdonp | thx i do prefer words over symbols |
21:22:57 | donpdonp | var x: ptr int, instead of *int is very nice. along with 'addr' |
21:23:17 | Yardanico | donpdonp: for managed pointers you should use "ref" though |
21:23:26 | Yardanico | `ptr` is usually used for interfacing with other languages |
21:24:25 | donpdonp | how about this riddle |
21:24:32 | donpdonp | offer_filter = proc (o: Offer): bool = o.quote(flipped) < price |
21:24:37 | donpdonp | compiles fine but |
21:24:37 | Yardanico | pretty simple |
21:24:47 | donpdonp | offer_filter = proc (o: Offer): bool = { o.quote(flipped) < price } |
21:24:51 | donpdonp | type mismatch: got <set[bool]> but expected 'bool' |
21:24:56 | Yardanico | Nimd oesn't have {} |
21:25:11 | Yardanico | {} in nim is only used for sets |
21:25:17 | Araq | riddle? maybe need a single tutorial about the language |
21:25:38 | Araq | *read# |
21:26:03 | donpdonp | i see. thx |
21:26:09 | disruptek | that'll take all the fun outta it. |
21:26:09 | donpdonp | Araq: not helpful |
21:26:14 | Yardanico | wat |
21:26:41 | Yardanico | well, there's also nim manual https://nim-lang.org/docs/manual.html |
21:29:09 | FromDiscord | <mratsim> @donpdonp, by your logic "-" shouldn't be used for x - y or for unary -x |
21:29:18 | FromDiscord | <mratsim> I don't see the difference with & here |
21:32:07 | * | tiorock joined #nim |
21:32:07 | * | rockcavera is now known as Guest50476 |
21:32:07 | * | tiorock quit (Changing host) |
21:32:07 | * | tiorock joined #nim |
21:32:07 | * | Guest50476 quit (Killed (cherryh.freenode.net (Nickname regained by services))) |
21:32:07 | * | tiorock is now known as rockcavera |
21:33:17 | donpdonp | the surprising part isnt how & is used, but how &(string) changes it meaning due to an import |
21:33:24 | Yardanico | it doesn't? |
21:33:40 | Yardanico | if you run a & b after importing strformat the result will be the same as without the import |
21:33:43 | disruptek | that's why i never import anything. |
21:33:47 | FromDiscord | <mratsim> &(string) just doesn't exit if you don't import the module that implements it |
21:33:52 | disruptek | it adds all kindsa symbols to my code. |
21:33:56 | disruptek | yuuck. |
21:47:52 | * | dddddd quit (Remote host closed the connection) |
21:48:14 | * | solitudesf joined #nim |
21:49:18 | * | solitudesf quit (Client Quit) |
21:50:06 | * | solitudesf joined #nim |
21:55:58 | * | Trustable quit (Remote host closed the connection) |
22:09:35 | * | nif quit (Quit: ...) |
22:09:44 | * | nif joined #nim |
22:11:23 | * | ltriant joined #nim |
22:12:51 | * | donpdonp left #nim ("WeeChat 2.6") |
22:16:39 | * | solitudesf quit (Ping timeout: 246 seconds) |
22:33:07 | * | fowl joined #nim |
22:33:54 | * | nif quit (Quit: ...) |
22:34:00 | rockcavera | I saw this in the forum: {.experimental: "codeReordering".}. What does codeReordering do? The pragma {.experimental.} I know. |
22:34:03 | * | nif joined #nim |
22:34:28 | * | sammich quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.) |
22:36:12 | FromDiscord | <mratsim> it reorders the proc declarations in the file until your code compiles |
22:36:33 | * | sammich joined #nim |
22:36:36 | FromDiscord | <mratsim> so it saves you having to forward declare everything |
22:37:09 | rockcavera | thanks |
22:37:10 | rockcavera | ;) |
22:37:42 | rockcavera | I didn't find it documented, so I asked |
22:38:59 | fowl | Sup nimmers |
22:46:34 | dom96 | hey fowl, long time no see. Where have you been? |
22:47:04 | * | xet7 quit (Remote host closed the connection) |
23:07:02 | * | xet7 joined #nim |
23:10:45 | * | letto quit (Ping timeout: 250 seconds) |
23:10:47 | * | letto_ joined #nim |
23:13:35 | FromDiscord | <mratsim> @rockcavera yeah there are plenty of stuff undocumented though the manual is growing more and more complete as Nim is moving to spec first |
23:27:45 | * | ltriant_ joined #nim |
23:28:04 | * | ltriant quit (Ping timeout: 252 seconds) |
23:28:40 | * | ltriant_ is now known as ltriant |
23:54:38 | fowl | dom96: hey, a ton has happened since I’ve not been here, I’m married with a 3 month old now |
23:58:15 | dom96 | nice! Congratulations :) |