00:01:54 | * | dwdv quit (Ping timeout: 240 seconds) |
00:03:41 | zacharycarter | sweet - SSE intrinsics are working |
00:04:17 | zacharycarter | time to work on shader hot reloading |
00:05:56 | * | Zectbumo joined #nim |
00:06:26 | * | dsrw quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
00:18:58 | FromGitter | <awr1> yes |
00:19:52 | FromGitter | <awr1> my original idea for it, because using `_m128`s invoke their own problems, was to have a "fast" vector type and a "strict" vector type |
00:20:02 | * | sleepyqt joined #nim |
00:20:57 | FromGitter | <awr1> `_m128`s aren't tightly packed, for instance |
00:27:05 | * | qbradley joined #nim |
00:32:51 | ryukoposting | text entry box with support for japanese and chinese input almost finished :) |
00:35:14 | ryukoposting | https://cdn.discordapp.com/attachments/673968364598853662/697242864383426600/2020-04-07_19-29-43.mp4 |
00:45:49 | * | dsrw joined #nim |
00:48:17 | FromDiscord | <ejstembler> Does Nim have something equivalent to Ruby's ERB (https://ruby-doc.org/stdlib-2.7.1/libdoc/erb/rdoc/ERB.html), or Crystal's ECR (https://crystal-lang.org/api/0.21.1/ECR.html) ? Basically the ability to render templates with embedded nim code. |
00:49:46 | leorize | source code filter seems to be the closet thing that I could think of |
00:50:08 | * | NimBot joined #nim |
00:50:17 | leorize | https://nim-lang.org/docs/filters.html |
00:55:20 | FromDiscord | <ejstembler> Thanks @leorize ! Looks like that may work for my use-case. I'll give it a try... |
01:01:48 | * | krux02_ quit (Remote host closed the connection) |
01:19:09 | * | chemist69 quit (Ping timeout: 265 seconds) |
01:21:00 | * | chemist69 joined #nim |
01:28:26 | * | sleepyqt quit (Ping timeout: 256 seconds) |
01:34:38 | * | dsrw quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
01:37:23 | * | dsrw joined #nim |
01:41:04 | * | lritter quit (Ping timeout: 256 seconds) |
01:41:25 | * | lritter joined #nim |
02:15:25 | FromDiscord | <Benumbed> Wow that was a quick turnaround on the httpclient bug I filed, thanks Araq and narimiran! |
02:27:27 | * | endragor joined #nim |
02:32:37 | * | muffindrake quit (Ping timeout: 265 seconds) |
02:34:41 | * | muffindrake joined #nim |
02:46:27 | * | oculuxe quit (Ping timeout: 265 seconds) |
02:46:34 | * | ikan_keli joined #nim |
02:48:20 | * | kotrcka left #nim ("https://quassel-irc.org - Chat comfortably. Anywhere.") |
02:48:22 | * | kotrcka joined #nim |
02:48:26 | * | kotrcka left #nim ("https://quassel-irc.org - Chat comfortably. Anywhere.") |
02:53:27 | FromGitter | <awr1> @ryukoposting looks cool! are you using the SDL text input API or are you getting stuff directly from the windows IME |
02:59:18 | ryukoposting | awr1: I'm using SDL2's text input system. It's not great (no autofill suggestions) but it's portable |
03:01:19 | * | dsrw quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
03:03:31 | * | sleepyqt joined #nim |
03:26:05 | FromDiscord | <Rika> is SDL really easy to use? |
03:27:20 | FromDiscord | <Benumbed> Relatively yeah |
03:27:37 | FromDiscord | <Benumbed> Esp if you're comfortable with C |
03:28:21 | FromDiscord | <Benumbed> I use it in the game engines I've written for the input, window and OS events because it's petty simple and stays out of my way |
03:28:36 | FromDiscord | <Benumbed> and means I don't have to write abstraction layers for that stuff |
03:29:26 | zacharycarter | I'm using sokol in my current game project and like it so far |
03:30:12 | ryukoposting | The nim port of it is pretty much a 1:1 clone of the normal library, so the official wiki is a good resource even though you aren't using C |
03:31:23 | ryukoposting | I plan on stripping my engine's abstraction layer out, and making it into its own library so you can get easy access to some higher-level facilities |
03:31:54 | * | waleee-cl quit (Quit: Connection closed for inactivity) |
03:32:23 | ryukoposting | I'll definitely make my audio thing into a separate library. It's like SDL_Mixer except it can handle multiple audio streams simultaneously. only supports WAV at the moment, though. |
03:32:43 | * | oculux joined #nim |
03:32:53 | * | Asgaroth_ joined #nim |
03:34:05 | shashlick | @zacharycarter - if you have time, would you be able to test how the new ast2 algorithm works on sokol? |
03:35:27 | zacharycarter | shashlick: sure - what do I need to do? |
03:36:03 | shashlick | are you using toast on the command line or cImport in a nim file? |
03:36:12 | zacharycarter | cImport |
03:36:23 | zacharycarter | and cCompile |
03:36:25 | * | Asgaroth quit (Ping timeout: 265 seconds) |
03:37:54 | shashlick | okay, just pushed latest stuff to #head so if you can pull that first |
03:38:02 | zacharycarter | sure |
03:38:05 | * | oculuxe joined #nim |
03:38:13 | shashlick | and then update cImport with a `flags = "-f:ast2"` param |
03:38:38 | shashlick | i've not tagged any of the new stuff until it is good to replace the legacy algo |
03:38:51 | shashlick | but even #head should work the same as 0.4.4 from a legacy perspective |
03:39:22 | * | oculux quit (Ping timeout: 258 seconds) |
03:39:26 | shashlick | idea is to tag 0.5.0 with legacy deprecated but still the default, followed by bug fixes on ast2, finally making ast2 the default in 0.6.0 and removing legacy in 0.7.0 |
03:39:31 | shashlick | let's see how it goes |
03:39:45 | zacharycarter | if I just nimble install from the cloned repo's master branch, will that be okay? |
03:40:12 | zacharycarter | how do I install #head? |
03:41:01 | zacharycarter | oh I guess head is origin - okay let me add that flag |
03:41:28 | shashlick | ya just nimble install nimterop@#head |
03:43:38 | zacharycarter | hmm ran into some errors |
03:44:35 | zacharycarter | I threw it on both of the libs I'm using nimterop with - let me just add it to sokol and see what happens |
03:45:51 | shashlick | i guess first might just want to try #head as is without -f:ast2 and see if it just works |
03:45:59 | shashlick | then try -f:ast2 one at a time |
03:46:12 | shashlick | ast2 has a bunch of stuff fixed so it should be better - https://github.com/nimterop/nimterop/issues?q=is%3Aissue+is%3Aopen+label%3Afixed |
03:46:28 | shashlick | but it is new so bugs for sure |
03:56:19 | zacharycarter | I'm compiling my program with `nim c --gc:arc` and switching to #head causes a SIGABRT |
03:56:39 | zacharycarter | without the ast2 flag |
03:56:53 | shashlick | hmm, i've not tested with gc:arc at all, not even 0.4.4 |
03:57:18 | shashlick | are you compiling toast also with gc:arc? |
03:57:21 | zacharycarter | seems to be working fine with nim devel |
03:57:39 | zacharycarter | I'm just installing it with `nimble install nimterop` |
03:57:52 | zacharycarter | so I guess not |
04:06:01 | * | supakeen quit (Quit: WeeChat 1.9.1) |
04:06:38 | * | supakeen joined #nim |
04:08:59 | shashlick | at the very least, #head should work as is like 0.4.4 so if that's not working, please let me know |
04:09:27 | zacharycarter | doesn't seem to be with gc arc :/ I can try with the default gc if you'd like |
04:11:02 | FromDiscord | <KingDarBoja> Trying to pass to some procedure a inherited type but getting a error message like -> "first type mismatch at position: 2 |
04:11:02 | FromDiscord | <KingDarBoja> required type for nodes: Option[seq[ParentType]] or Option[ParentType] |
04:11:02 | FromDiscord | <KingDarBoja> but expression 'some(@[someChildValue])' is of type: Option[seq[ChildType]]" |
04:12:49 | FromGitter | <zacharycarter> irc or tmux or something just froze... anyway, shashlick: I get that same SIGABRT error with `nimble install nimterop@#head` whether I use `--gc:arc` or not on nim devel |
04:17:00 | shashlick | hmm - can you share something that I could test and reproduce? |
04:17:40 | FromGitter | <zacharycarter> I only have things working on osx atm :/ |
04:18:38 | FromGitter | <zacharycarter> I'm about to watch a movie and go to sleep but I can try to help debug more tomorrow |
04:21:20 | shashlick | sure, don't want to send you down a rathole |
04:21:44 | shashlick | but anything you can send my way to debug, will appreciate |
04:22:51 | * | nsf joined #nim |
04:26:12 | FromDiscord | <KingDarBoja> Found this at the manual: Object fields that should be visible from outside the defining module, have to be marked by *. In contrast to tuples, different object types are never equivalent. |
04:27:06 | FromDiscord | <KingDarBoja> But inherited object types are somewhat equivalent to its parent type. |
04:27:34 | FromDiscord | <Varriount> Yes, but not equivalent |
04:29:32 | FromDiscord | <KingDarBoja> So if I try to pass a object, let's call it ChildA to some procedure whose argument uses ParentOfChildA, it will throw an error, right? |
04:29:37 | * | ikan_keli quit (Ping timeout: 260 seconds) |
04:36:01 | FromDiscord | <KingDarBoja> https://nim-lang.org/docs/manual_experimental.html#covariance Maybe this is what I am asking for? |
04:37:08 | leorize | no, it won't error out |
04:37:27 | leorize | you can just try :P |
04:37:59 | FromDiscord | <KingDarBoja> Well I am getting one unless I cast the child type to the parent type |
04:38:20 | leorize | can you post an example? |
04:42:50 | FromDiscord | <KingDarBoja> Not sure, I do have pushed my code on the repo |
04:43:25 | FromDiscord | <KingDarBoja> But let me explain |
04:43:26 | * | casaca quit (Remote host closed the connection) |
04:43:32 | * | ehmry_ joined #nim |
04:43:53 | FromDiscord | <KingDarBoja> https://github.com/KingDarBoja/Phosphate/blob/master/src/error/graphql_error.nim#L73 This proc should accept any child type (nodes) that inherits from "Node" type |
04:44:54 | FromDiscord | <KingDarBoja> On the test, I am trying to pass the proper sequence whose object type is a child of "Node" https://github.com/KingDarBoja/Phosphate/blob/master/tests/error/test_graphql_error.nim#L51 |
04:46:06 | FromDiscord | <KingDarBoja> https://github.com/KingDarBoja/Phosphate/blob/master/src/language/ast.nim#L140 The inherited type (the child type) is called "SelectionNode", but for some reason, the terminal isn't accepting it unless I cast the value to "Node" |
04:47:39 | FromDiscord | <KingDarBoja> But if I don't cast, I get: "first type mismatch at position: 2 |
04:47:39 | FromDiscord | <KingDarBoja> required type for nodes: Option[seq[Node]] or Option[ast.Node] |
04:47:39 | FromDiscord | <KingDarBoja> but expression 'some(@[fieldNode])' is of type: Option[seq[SelectionNode]]" |
04:48:00 | FromDiscord | <KingDarBoja> Not sure why I am needing the cast on my code... |
04:50:25 | * | ikan_keli joined #nim |
04:57:07 | FromGitter | <awr1> maybe try `let nodes :Option[seq[Node]] = @[fieldNode]` |
04:57:41 | FromGitter | <awr1> the compiler needs more information to know that the sequence isn't just constrained to the root obj |
04:58:15 | FromGitter | <awr1> i mean `let nodes :Option[seq[Node]] = some @[fieldNode]` |
04:59:12 | FromGitter | <awr1> *constrained to the inherited obj |
05:00:00 | FromDiscord | <KingDarBoja> On the test you mean? |
05:00:08 | FromGitter | <awr1> yes |
05:00:24 | FromDiscord | <KingDarBoja> Instead of directly passing the `some(@[fieldNode])` ? |
05:00:28 | FromGitter | <awr1> yes |
05:00:52 | FromGitter | <awr1> if that doesn't work, you may need to do `let node :Node = fieldNode`and then do `some(@[node])` |
05:00:57 | FromDiscord | <KingDarBoja> Nope -> type mismatch: got <Option[seq[SelectionNode]]> but expected 'Option[seq[Node]]' |
05:01:06 | FromDiscord | <KingDarBoja> Let me try |
05:02:52 | FromDiscord | <KingDarBoja> Well it works, either setting as you said or just setting the type to FieldNode to be Node |
05:02:56 | FromDiscord | <KingDarBoja> "let fieldNode: Node = operationDefNode.selectionSet.selections[0]" |
05:03:02 | * | ehmry is now known as ehmry[m] |
05:03:10 | * | ehmry_ is now known as ehmry |
05:03:23 | * | ehmry[m] left #nim ("User left") |
05:03:38 | FromGitter | <awr1> try making it a `method` |
05:03:39 | FromDiscord | <KingDarBoja> But I expected the compiler to treat fieldNode (which is SelectionNode type) as Node |
05:03:58 | FromGitter | <awr1> https://github.com/KingDarBoja/Phosphate/blob/095101d74e236e91a9350034cf1f04b464431ab1/src/error/graphql_error.nim#L71 |
05:04:10 | FromGitter | <awr1> `method newGraphQLError(..` |
05:04:58 | FromDiscord | <KingDarBoja> Doesn't work if doing that, getting same error as before |
05:05:21 | FromGitter | <awr1> use the method with the original call |
05:05:36 | FromGitter | <awr1> `let e = newGraphQLError("msg", some(@[fieldNode]))` |
05:07:55 | FromDiscord | <KingDarBoja> Nop |
05:08:09 | FromDiscord | <KingDarBoja> https://imgur.com/HRMMA10 |
05:09:14 | FromGitter | <awr1> i think maybe this deserves an issue |
05:09:20 | FromGitter | <awr1> a compiler issue |
05:09:26 | FromGitter | <awr1> i did a minimal example, the issue is with the optionals |
05:09:33 | FromDiscord | <KingDarBoja> Arrrh |
05:09:37 | FromDiscord | <KingDarBoja> Again the optionals |
05:09:47 | FromGitter | <awr1> https://play.nim-lang.org/#ix=2h7q |
05:09:50 | FromDiscord | <KingDarBoja> There is another bug (I think) I found with Options module |
05:10:04 | FromDiscord | <KingDarBoja> But related to Table on that same error file |
05:10:48 | FromDiscord | <KingDarBoja> https://github.com/KingDarBoja/Phosphate/blob/master/src/error/graphql_error.nim#L78 If you try to use Option to specify the type with Table[string, string], you will get an error too |
05:11:00 | FromGitter | <awr1> but this is not really `Option[T]` specific on a technical level, it is more with how generics wrap inheritable types and what is supposed to happen in regards to type resolution |
05:11:34 | FromDiscord | <KingDarBoja> I see |
05:12:06 | * | rockcavera quit (Remote host closed the connection) |
05:12:13 | FromDiscord | <KingDarBoja> The other issue (not sure if bug) -> Use something like this: "someArgument: Option[Table[string, string]] = some(Table[string, string])"" |
05:12:44 | FromDiscord | <KingDarBoja> You get the following error: _"first type mismatch at position: 1 required type for val: T but expression 'Table[string, string]' is of type: type Table[system.string, system.string]"_ |
05:13:00 | FromDiscord | <KingDarBoja> Like... both **are** the same type lol |
05:13:27 | FromDiscord | <KingDarBoja> Looking at your repr awe1 |
05:15:52 | FromGitter | <awr1> https://github.com/nim-lang/Nim/issues/2686 |
05:15:53 | disbot | ➥ Dynamic dispatch doesn't work properly when types are generic |
05:17:57 | FromDiscord | <KingDarBoja> Ugh? |
05:18:06 | FromDiscord | <KingDarBoja> By the way, you are right with the bug |
05:19:12 | FromGitter | <awr1> technically what is described here is different |
05:19:47 | FromGitter | <awr1> this is referring to when the ref type itself is the generic i think |
05:20:24 | FromGitter | <awr1> i'm gonna make an issue anyway |
05:20:32 | FromDiscord | <KingDarBoja> Thank you awr1 |
05:20:48 | FromDiscord | <KingDarBoja> I will follow the issue, just be sure to share it here 😄 |
05:21:17 | FromDiscord | <KingDarBoja> In the meantime, I will specify the type so my test work |
05:21:50 | FromGitter | <awr1> https://github.com/nim-lang/Nim/issues/13922 |
05:21:52 | disbot | ➥ Generic call doesn't resolve when working with inherited ref types ; snippet at 12https://play.nim-lang.org/#ix=2h7t |
05:22:32 | FromDiscord | <KingDarBoja> That was fast |
05:25:22 | FromGitter | <awr1> if this is intended behavior, then your workaround is |
05:25:25 | FromGitter | <awr1> `let node :Node = fieldNode; let e = newGraphQLError("msg", some(@[node))` |
05:25:45 | FromDiscord | <KingDarBoja> Yup |
05:25:58 | FromDiscord | <KingDarBoja> Looking forward on the issue (I just subscribed) |
05:26:06 | FromDiscord | <KingDarBoja> Now I must go to sleep, midnight here |
05:26:06 | FromDiscord | <KingDarBoja> 😄 |
05:26:10 | FromDiscord | <KingDarBoja> Cya |
05:28:14 | FromGitter | <awr1> cya |
05:55:27 | * | njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.) |
05:55:38 | * | njoseph joined #nim |
06:02:54 | FromDiscord | <treeform> VTune works with nim through --debugger:native flag. This is amazing. Thank you to who made this work. |
06:17:22 | * | narimiran joined #nim |
06:24:24 | * | sleepyqt quit (Ping timeout: 256 seconds) |
06:25:23 | * | solitudesf joined #nim |
06:27:13 | * | PMunch joined #nim |
06:38:56 | * | xet7 quit (Quit: Leaving) |
06:43:36 | * | arecaceae quit (Remote host closed the connection) |
06:43:53 | * | arecaceae joined #nim |
07:00:00 | * | gmpreussner quit (Quit: kthxbye) |
07:00:26 | * | zacharycarter quit (Ping timeout: 256 seconds) |
07:03:15 | number_one | Hey folks, with the setControlCHook, I assume that it's pretty much an `onSignal(SIGINT)` under the hood. Sorry if it's a dumb question, but if you set a handler for it, can you ever return to the execution point where the SIGINT was raised? |
07:03:40 | number_one | I'm also assuming that you can only really use it for clean exiting etc |
07:05:12 | * | gmpreussner joined #nim |
07:06:02 | FromDiscord | <mayse> hey everyone. i'm trying out the code here : https://nim-lang.org/docs/hcr.html - i've got the sdl bits working, but compiling this ends with `dlopen(libnimhcr.dylib, 2): image not found` |
07:06:32 | FromDiscord | <mayse> I've searched on google and the only source that talks about this is here, back in 21/03/2020 which someone mentioned doing some PATH thing. I haven't been able to progress from there. |
07:07:33 | FromDiscord | <mayse> Here's how I compile it: `nim c -d:nimDebugDlOpen --hotCodeReloading:on --verbosity:2` |
07:07:52 | number_one | Whoal, hotCodeReloading works for C now? |
07:09:00 | FromDiscord | <mayse> do you mean that hotCodeReloading is only for javascript output, @number_one ? |
07:09:07 | leorize | number_one: I think if you don't exit, the execution point will be returned |
07:09:39 | leorize | @mayse: you gotta build nimrtl and nimhcr |
07:10:01 | leorize | the files required are in nim's base directory |
07:10:29 | leorize | how did you install nim? |
07:10:34 | FromDiscord | <mayse> thanks leorize. I'll try that! any idea how to do that with choosenim ? |
07:10:39 | Araq | number_one: signal handling is just broken, don't use it |
07:10:39 | FromDiscord | <mayse> I installed nim with choosenim devel |
07:11:07 | leorize | ok, then it should be in ~/.choosenim/nim-current/lib |
07:11:20 | leorize | if my understanding of choosenim's layout is correct |
07:11:30 | leorize | you'll see the two files: nimrtl.nim and nimhcr.nim |
07:11:50 | number_one | @Araq, Just broken flat out? Any workarounds in circulation? Or should I handle this in C? |
07:12:13 | FromDiscord | <mayse> i see them leorize, they're at `~/.choosenim/toolchains/nim-#devel/lib` |
07:12:32 | leorize | run nim c --outdir:$PWD /path/to/nimrtl.nim |
07:12:39 | leorize | and nim c --outdir:$PWD /path/to/nimhcr.nim |
07:13:12 | leorize | you'll get libnimrtl.dynlib and libnimhcr.dynlib in your current directory |
07:13:23 | Araq | number_one: no it's broken in C... see http://man7.org/linux/man-pages/man7/signal-safety.7.html |
07:13:50 | leorize | number_one: it means: it works, just that the idea is fundamentally broken |
07:14:18 | FromDiscord | <mayse> it's working! thank you so much `leorize` ! . to leave a message for posterity if anyone searched into here, the two commands leorize mentioned should be ran in the source dir where you have your .nim, not in the ...lib/ dir. |
07:14:44 | number_one | :/ |
07:15:03 | number_one | Wow |
07:15:05 | number_one | Daaaang |
07:16:13 | Araq | leorize: :-) |
07:25:42 | FromDiscord | <mayse> a question aside from that, the code that is in that file won't work because nimble package sdl2 changed how it works (a lot). how would I contribute back the version that works to the documentation? (I'm very new to this, please be patient with me) |
07:25:54 | Yardanico | is it expected that this doesn't work? |
07:25:57 | Yardanico | !eval var a = ""; a &= if true: "hello" else: "no" |
07:25:59 | NimBot | Compile failed: /usercode/in.nim(1, 18) Error: expression expected, but found 'keyword if' |
07:26:02 | Yardanico | I thought it'd work |
07:26:30 | narimiran | !eval var a = ""; a &= (if true: "hello" else: "no") |
07:26:32 | NimBot | <no output> |
07:26:38 | narimiran | Yardanico: ^ |
07:26:39 | Yardanico | well but then |
07:26:45 | Yardanico | var a = ""; a = if true: "hello" else: "no" |
07:26:47 | Yardanico | !eval var a = ""; a = if true: "hello" else: "no" |
07:26:50 | NimBot | <no output> |
07:27:06 | Yardanico | i got a bit confused :P |
07:28:30 | FromDiscord | <Rika> i think = isnt a proc, whilst &= is? |
07:28:57 | FromDiscord | <Rika> no clue but yeah if it's an "augmented" equals, then you need parens., even w/ blocks |
07:29:16 | Yardanico | somehow I didn't notice that until now :P |
07:29:35 | FromDiscord | <Rika> and you've been here for real long... |
07:29:38 | Yardanico | xdd |
07:31:34 | Araq | mayse: I don't understand the question |
07:33:32 | FromDiscord | <mayse> @Araq I found it I think. so to change that document, would I need to send a request to change this file on github ? `https://github.com/nim-lang/Nim/blob/devel/doc/hcr.rst` |
07:33:48 | Araq | yes |
07:34:27 | * | zacharycarter joined #nim |
07:34:28 | FromDiscord | <mayse> thanks, will do that |
07:35:11 | FromDiscord | <mayse> it's just that sdl2 changed since (I can see now jun 2019) and the example code does not work anymore. so I'll send in a version that works. (cf: `https://github.com/nim-lang/sdl2/blob/master/src/sdl2.nim`) |
07:37:48 | FromDiscord | <eliezedeck> Hey guys |
07:38:58 | * | zacharycarter quit (Ping timeout: 256 seconds) |
07:44:12 | PMunch | Morning :) |
07:50:12 | FromGitter | <Vindaar> Good morning :) |
08:01:41 | FromDiscord | <eliezedeck> 🙂 |
08:02:07 | FromDiscord | <eliezedeck> @Araq: https://github.com/nim-lang/Nim/issues/13923 ... I could not find any more ways to solve the high memory usage |
08:02:09 | disbot | ➥ Outrageous memory usage due to numerous inefficiencies in the STD lib (async) ; snippet at 12https://play.nim-lang.org/#ix=2h84 |
08:10:48 | FromDiscord | <eliezedeck> I hope this problem is cause by OpenSSL ... but I highly doubt that |
08:10:55 | FromDiscord | <eliezedeck> I hope this problem is caused by OpenSSL ... but I highly doubt that |
08:13:41 | Yardanico | it's easy to test - just compile without -d:ssl and test with an HTTP website |
08:15:00 | FromDiscord | <eliezedeck> good idea ... let me ... |
08:15:45 | * | natrys joined #nim |
08:16:32 | FromDiscord | <eliezedeck> @Yardanico 830 MB -> 530 MB ... so, in some part, it is ... but not fully OpenSSL only |
08:17:13 | * | xet7 joined #nim |
08:23:26 | * | Asgaroth joined #nim |
08:23:31 | * | lritter quit (Ping timeout: 265 seconds) |
08:25:43 | * | Asgaroth_ quit (Ping timeout: 258 seconds) |
08:35:42 | dom96 | Araq, narimiran: we're still doing 1.0.8 right? Can we include #13919? |
08:35:43 | disbot | https://github.com/nim-lang/Nim/pull/13919 -- 3Fixes issues with dynamic loading OpenSSL. Fixes #13903. |
08:36:00 | narimiran | ok |
08:37:13 | narimiran | (when merging, add [backport] tag) |
08:38:31 | * | hpyc9 quit (Quit: ZNC 1.7.5 - https://znc.in) |
08:38:42 | * | hpyc9 joined #nim |
08:39:15 | dom96 | should I modify the commit msg to include that? |
08:50:40 | narimiran | just add it when you (squash) merge |
08:56:43 | dom96 | I might just amend |
08:56:49 | dom96 | Can someone review my PR? :) |
09:11:15 | Araq | eliezedeck: COW strings means "copy on write" |
09:11:31 | Araq | but it's cheaper to fix the stdlib than fixing Nim's builtin string type |
09:12:00 | Araq | with --gc:arc the builtin string type became very hackable but --gc:arc isn't yet ready for async code :-/ |
09:12:34 | FromGitter | <alehander92> eliezedeck just a very friendly note: please try to use objective language in your issues: you can say something is "very high", "outrageous" is subjective (its useful to do in general, would you read a science paper called "outrageous values of protein in mice when a" :D |
09:14:10 | Araq | fwiw I LOL'ed when I read the title |
09:14:24 | * | Asgaroth_ joined #nim |
09:14:32 | FromGitter | <alehander92> otherwise i've heard before that we can use more streams for stuff |
09:15:39 | FromGitter | <alehander92> yeah, it's very human, i like it, but i can just imagine "scandalous segfault when using expr as a type parameter, people riot on the streets" |
09:17:37 | * | Asgaroth quit (Ping timeout: 264 seconds) |
09:17:47 | FromDiscord | <mratsim> Btw, now that we have dup, can we refactor all the strutils proc? |
09:18:14 | FromDiscord | <mratsim> I'm always saying this but it's the biggest performance trap of Nim in my opinion, and I don't use strings that much |
09:18:57 | narimiran | @mratsim it is on my personal (long-term) todo :) |
09:19:08 | * | Asgaroth_ quit (Client Quit) |
09:23:01 | * | dwdv joined #nim |
09:23:33 | * | lbart is now known as lbat |
09:23:59 | * | lbat is now known as lbart |
09:27:43 | federico3 | dom96: what test? |
09:29:57 | Araq | mratsim: fine with me but we should also take the opportunity to introduce strbasics that is a strutils with the few procs that I acually need |
09:30:38 | Araq | the existing strutils can be kept and do 'import strbasics; export strbasics' |
09:31:46 | dom96 | federico3, ci-ssl |
09:32:46 | dom96 | Araq, what's the point? we have dead code elimination for a reason |
09:33:39 | Araq | dom96, we still lack IC though |
09:34:33 | dom96 | so you'll save 1 or 2 seconds at most, not worth the extra maintenance and knowledge about another module |
09:35:34 | Araq | fair enough |
09:43:03 | Araq | (it's much less than 1s btw) |
09:44:32 | supakeen | Speaking off, would it be silly to PR `getBit` as a partner get `getBit` in bitops? :) |
09:45:17 | * | ikan_keli quit (Read error: Connection reset by peer) |
09:45:51 | supakeen | Wow that sentence didn't make sense. As a partner to `setBit`. |
09:46:10 | Araq | I like it |
09:47:04 | supakeen | Neat :) |
09:47:19 | supakeen | I'll make it so then. |
09:47:56 | * | Tyresc joined #nim |
09:51:06 | * | sleepyqt joined #nim |
10:00:41 | FromDiscord | <eliezedeck> @Araq, @alehander92 ... alright, I'll update the title to "very high" 😛 |
10:01:17 | Araq | eliezedeck: I can guide you to the problem |
10:01:18 | FromDiscord | <eliezedeck> and happy to bring about some lols |
10:01:25 | FromDiscord | <eliezedeck> yes please |
10:01:29 | Araq | right here, right now |
10:01:47 | FromDiscord | <eliezedeck> alright, let's go ... |
10:01:59 | Araq | compiler / lambdalifting.nim line 203 |
10:02:35 | Araq | we used the quick string assignment called 'nkFastAsgn' but had to use the slower assignment because of reported bugs |
10:02:37 | FromDiscord | <exelotl> fug |
10:02:38 | FromDiscord | <exelotl> https://cdn.discordapp.com/attachments/371759389889003532/697385906042306671/image0.jpg |
10:02:58 | Yardanico | @exelotl how much RAM? |
10:03:28 | FromDiscord | <exelotl> 512mb |
10:03:49 | FromDiscord | <exelotl> maybe if I close the web browser... |
10:03:54 | Yardanico | yes, and do a swap :P |
10:04:04 | Araq | eliezedeck: you can try to use 'nkFastAsgn' and see if it makes a difference |
10:04:16 | FromDiscord | <eliezedeck> alright |
10:04:19 | Araq | and if it does, we can figure out how to do this properly |
10:04:29 | Araq | via some analysis inside the compiler |
10:06:13 | Araq | and maybe you need to check for ri.kind notin {nkStrLit..nkTripleStrLit} |
10:06:19 | Araq | as the comment indicates |
10:07:04 | FromDiscord | <eliezedeck> ok, thanks for the pointers |
10:07:28 | FromDiscord | <eliezedeck> so, I suppose I have to build_all.sh, right? |
10:07:33 | Yardanico | no |
10:07:41 | Yardanico | you can do ./koch temp c path_to_your_nim_file |
10:07:54 | Yardanico | in the dir with nim compiler |
10:07:56 | FromDiscord | <eliezedeck> alright, that's useful |
10:08:00 | FromDiscord | <eliezedeck> thanks |
10:08:16 | Yardanico | that'll compile nim compiler in debug mode and that compiler will compile your file |
10:08:45 | FromDiscord | <eliezedeck> interesting and much appreciated |
10:10:30 | Araq | https://nim-lang.org/docs/intern.html#debugging-the-compiler |
10:15:16 | FromDiscord | <eliezedeck> unfortunately, it doesn't compile: |
10:15:16 | FromDiscord | <eliezedeck> ``` |
10:15:16 | FromDiscord | <eliezedeck> /Nim/lib/system/gc.nim(239) asgnRef |
10:15:17 | FromDiscord | <eliezedeck> /Nim/lib/system/gc.nim(184) incRef |
10:15:17 | FromDiscord | <eliezedeck> SIGBUS: Illegal storage access. (Attempt to read from nil?) |
10:15:17 | FromDiscord | <eliezedeck> ``` |
10:16:20 | * | dadada joined #nim |
10:16:22 | FromDiscord | <mratsim> mmm |
10:16:30 | FromDiscord | <mratsim> does gc:markandsweep help? |
10:16:43 | * | dadada is now known as Guest51436 |
10:17:29 | FromDiscord | <mratsim> if yes can you compile with "-d:useSysAssert -d:useGcAssert" as well |
10:18:03 | FromDiscord | <Recruit_main707> currently, there is no tool to transpile c/c++ to nim right? |
10:18:45 | Yardanico | if you mean something which works for everything - no :P |
10:19:15 | FromDiscord | <Recruit_main707> and, something that kind of works? |
10:19:21 | Araq | c2nim |
10:19:23 | FromDiscord | <mratsim> c2nim |
10:19:47 | Araq | it parses C89 and C++98, kind of :-) |
10:19:58 | FromDiscord | <Recruit_main707> i hope it likes flatbuffers generated code because if not im gonna go crazy |
10:19:59 | FromDiscord | <eliezedeck> yes, gc:markandsweep got rid of the crash ... but the memory usage hasn't changed |
10:20:09 | Yardanico | what about trying without async and with --gc:arc :P |
10:20:22 | Araq | Yardanico, it's all about async |
10:21:16 | Araq | eliezedeck: if memory usage didn't change we need a better analysis of the problem than just "closure parameters are copied" |
10:21:37 | FromDiscord | <eliezedeck> @Yardanico use multiple system threads? I don't think that would be a good idea for my case, it will receive multiple requests from clients |
10:22:05 | FromDiscord | <eliezedeck> right, so what's the next step? |
10:23:18 | Araq | do you use --gc:arc? |
10:23:38 | FromDiscord | <eliezedeck> no |
10:23:44 | FromDiscord | <mratsim> I thought it didn't work with async yet? |
10:23:52 | Yardanico | it works but leaks memory AFAIK :P |
10:23:57 | FromDiscord | <eliezedeck> and that's the reason I didn't |
10:24:42 | Araq | ok, good, just wanted to be sure |
10:25:04 | FromDiscord | <Recruit_main707> how severe is the leak? |
10:25:46 | FromDiscord | <eliezedeck> @Araq ... just for compleness, --gc:arc increased memory usage back to 700MB |
10:25:58 | FromDiscord | <eliezedeck> and as I leave it running, it went-up to 1GB |
10:26:13 | Araq | well it leaks, it will go as high as you want to go |
10:26:20 | FromDiscord | <eliezedeck> 🙂 right |
10:26:20 | * | Zectbumo quit (Remote host closed the connection) |
10:26:58 | * | zacharycarter joined #nim |
10:28:57 | Araq | open lib/system/sysstr.nim |
10:29:09 | * | Tyresc quit (Ping timeout: 258 seconds) |
10:29:23 | Araq | if (src.reserved and seqShallowFlag) != 0 |
10:29:35 | Araq | is the test you want to be true but isn't |
10:29:43 | Araq | try something like: |
10:30:22 | Araq | if (src.reserved and seqShallowFlag) != 0 or src.len > 6_000: # never copy long strings |
10:30:38 | Araq | as a hack and see if that improves the situation for your test program |
10:30:42 | FromDiscord | <eliezedeck> there are 2 of them ... I should I go to copyString or copyStringRC1? |
10:30:48 | Araq | to both |
10:30:51 | FromDiscord | <eliezedeck> ok |
10:30:58 | Araq | bbl lunch here |
10:31:25 | * | zacharycarter quit (Ping timeout: 265 seconds) |
10:31:55 | FromDiscord | <eliezedeck> @Araq Mazoto homana (a malagasy way to wish you courage in eating 🙂 ) |
10:32:11 | FromDiscord | <eliezedeck> lunch also here, bbl too |
10:32:31 | * | waleee-cl joined #nim |
10:32:55 | * | krux02 joined #nim |
10:45:46 | FromDiscord | <eliezedeck> I have switched to the sample bug report file that I have reported, which uses 830MB RAM without any change ... when doing `if (src.reserved and seqShallowFlag) != 0 or src.len > 6_000:`, the memory usage dropped to 330 MB |
10:47:42 | FromDiscord | <eliezedeck> when just using `nkFastAsgn` and `--gc:markandsweep`, it dropped to 435MB |
10:49:30 | FromDiscord | <clyybber> @eliezedeck I think I have a different solution that doesn't require relying on compiler optimizations |
10:49:38 | FromDiscord | <eliezedeck> when (`nkFastAsgn` and `--gc:markandsweep`) and `if (src.reserved and seqShallowFlag) != 0 or src.len > 6_000` is used, it remains at 330MB |
10:49:51 | FromDiscord | <eliezedeck> I'm all ears |
10:50:07 | FromDiscord | <clyybber> Can you try using ```type rcstring = object |
10:50:10 | FromDiscord | <clyybber> damn |
10:50:13 | FromDiscord | <clyybber> hit enter too fast |
10:50:18 | FromDiscord | <eliezedeck> 🙂 |
10:50:27 | FromDiscord | <clyybber> ```type rcstring = object |
10:50:27 | FromDiscord | <clyybber> s: string |
10:50:27 | FromDiscord | <clyybber> ``` |
10:50:42 | FromDiscord | <clyybber> ```type rcstring = ref object |
10:50:42 | FromDiscord | <clyybber> s: string |
10:50:42 | FromDiscord | <clyybber> ``` |
10:51:00 | FromDiscord | <clyybber> Can you try using this instead of string? |
10:51:20 | FromDiscord | <clyybber> string has value semantics by default in nim, so with this wrapping ref object you would get a refcounted string |
10:51:59 | FromDiscord | <clyybber> `type rcstring = ref string` maybe works too, but I'm not too sure the backend can already handle it 😄 |
10:52:10 | FromDiscord | <eliezedeck> so, i should do a cast? |
10:52:34 | FromDiscord | <clyybber> Nope, do rcstring(s: yourstring) |
10:52:43 | FromDiscord | <clyybber> That should yield you a refcounted string |
10:54:00 | FromDiscord | <eliezedeck> and how do I pass it to the stdlib for use? buff.s ? but then, wouldn't that be the same thing? |
10:54:15 | FromDiscord | <clyybber> Yeah, it will not eliminate all copies |
10:54:31 | FromDiscord | <eliezedeck> https://play.nim-lang.org/#ix=2h80 |
10:54:50 | FromDiscord | <clyybber> Oh, thanks. I didn't see your example yet |
10:55:10 | FromDiscord | <eliezedeck> I can eliminate copies right before the calls, but once it gets passed into the stdlib, I have no control of what it's doing anymore |
10:55:15 | FromDiscord | <clyybber> Yeah |
10:55:26 | FromDiscord | <clyybber> Are you certain the stdlib is the problem here though? |
10:55:29 | FromDiscord | <clyybber> And not async? |
10:55:38 | FromDiscord | <eliezedeck> no, I'm not sure |
10:55:51 | Yardanico | well *technically* async is a part of stdlib :D |
10:55:55 | FromDiscord | <eliezedeck> Araq said it's the async, but what do I know |
10:56:07 | FromDiscord | <eliezedeck> yes |
10:56:47 | FromDiscord | <clyybber> Hmm, I'm gonna take a look at where those copies happen. One moment |
10:57:01 | FromDiscord | <eliezedeck> you can run the example yourself, I'm not experienced Nim developer, may be you could help |
10:57:12 | FromDiscord | <eliezedeck> that would be very helpful |
10:58:17 | FromDiscord | <eliezedeck> as I tried yesterday to find-out where the memory goes to, but I couldn't ... already tried -d:useMalloc, but no ... valgrind won't report anything meaning full or anything close... tried Xcode's Instruments this morning, not much thing either |
10:58:51 | FromDiscord | <clyybber> Yeah, valgrind is best for leaks, so not sure how it would help here |
10:59:15 | FromDiscord | <eliezedeck> valgrind --tool=massif |
10:59:40 | FromDiscord | <clyybber> Ah |
10:59:59 | * | narimiran quit (Ping timeout: 250 seconds) |
11:00:32 | FromDiscord | <eliezedeck> it is very unfortunate that valgrind didn't work |
11:00:44 | Yardanico | well, maybe because ther weren't any leaks? :P |
11:00:46 | FromDiscord | <eliezedeck> it could have been a valuable tool for this |
11:02:16 | FromDiscord | <eliezedeck> @Yardanico if we consider that, then how can we explain 830MB resident memory being consumed? you could try the example yourself and you'll see ... and the thing is: I don't believe it's a leak, it's just that there are too many unnecessary copies of the original 100MB, passing from one proc to another, and so on |
11:02:28 | Yardanico | well, valgrind doesn't detect "copies" and stuff like that |
11:02:34 | Yardanico | I'm not saying it's okay |
11:02:42 | FromDiscord | <eliezedeck> and yes, Xcode said it didn't have any leaks too |
11:03:15 | FromDiscord | <eliezedeck> yes, but valgrind --tool=massif is supposed to help in pin-pointing where are all the memories that were allocated coming from |
11:03:27 | FromDiscord | <eliezedeck> https://www.valgrind.org/docs/manual/ms-manual.html |
11:04:40 | * | zacharycarter joined #nim |
11:08:40 | FromDiscord | <clyybber> @eliezedeck if you remove the async annotation and use the non async httpclient what does the mem usage jump to? |
11:09:27 | * | zacharycarter quit (Ping timeout: 260 seconds) |
11:10:23 | * | liblq-dev joined #nim |
11:11:45 | FromDiscord | <clyybber> Araq: Do the "old" strings use refcounting? |
11:12:08 | FromDiscord | <eliezedeck> without async, the memory usage for that bug report is 101.2MB |
11:12:30 | FromDiscord | <clyybber> Ha, ok. So it really is async |
11:12:30 | FromDiscord | <eliezedeck> 830MB with async |
11:12:35 | FromDiscord | <clyybber> Ok, thank you |
11:13:27 | * | ryan_ joined #nim |
11:13:41 | * | ryan_ is now known as number_two |
11:13:48 | * | narimiran joined #nim |
11:14:55 | FromDiscord | <eliezedeck> if the string is immutable (shallow), it should not be copied, like, **at all** ... is that a wrong supposition? |
11:16:04 | * | number_one quit (Ping timeout: 265 seconds) |
11:16:07 | FromDiscord | <clyybber> Curious, whats the memory usage with gc:arc and without async? |
11:17:23 | FromDiscord | <eliezedeck> 101.1 MB |
11:18:17 | FromDiscord | <clyybber> And with async? |
11:18:21 | FromDiscord | <clyybber> 830 I assume |
11:18:29 | FromDiscord | <eliezedeck> yes |
11:18:32 | FromDiscord | <clyybber> Not more? |
11:18:45 | FromDiscord | <eliezedeck> a little bit more, may be |
11:18:55 | FromDiscord | <eliezedeck> hovers around that number |
11:18:56 | FromDiscord | <clyybber> Ok |
11:19:37 | FromDiscord | <eliezedeck> and I really didn't expect it to be so different |
11:20:22 | FromDiscord | <eliezedeck> bbl |
11:21:06 | FromDiscord | <clyybber> Ok, I'll investigate a bit in the meantime |
11:26:33 | Araq | clyybber: no implementation yet uses COW but I planned to play with it with ARC |
11:27:01 | Araq | because the new implementation is easier to tinker with |
11:28:18 | FromDiscord | <clyybber> Yeah definitely |
11:31:40 | * | Vladar joined #nim |
11:34:05 | * | PMunch quit (Quit: leaving) |
11:39:57 | FromDiscord | <clyybber> @eliezedeck Put a bunch of `echo getOccupiedMem()` s in there. |
11:40:22 | FromDiscord | <clyybber> The mem usage is spiking in the last 2 lines of `infeficientCopiesAllOver` |
11:40:42 | * | chemist69 quit (Ping timeout: 260 seconds) |
11:41:20 | * | chemist69 joined #nim |
11:41:37 | FromDiscord | <clyybber> @eliezedeck Can you try maybe patching asynchttpclient to take rcstrings instead of strings for the body? |
11:41:48 | FromDiscord | <clyybber> Just for testing for now. |
11:42:06 | FromDiscord | <clyybber> Just to test for now. |
11:42:42 | * | Vladar quit (Remote host closed the connection) |
11:42:49 | FromDiscord | <clyybber> @mratsim Hey, I was wondering if you have any fft implementation in laser? |
11:43:04 | FromDiscord | <mratsim> nop, but AFAIK xflywind has one |
11:43:05 | * | Vladar joined #nim |
11:43:10 | FromDiscord | <mratsim> otherwise just use fftw |
11:43:17 | FromDiscord | <clyybber> Ok, thanks! |
11:44:54 | FromDiscord | <mratsim> There are a couple of fft benchmarks in C for multithrading runtime as well |
11:45:02 | FromDiscord | <mratsim> so I wanted to do one for Weave |
11:45:11 | FromDiscord | <mratsim> for example: heather.cs.ucdavis.edu/~matloff/OpenMP/Examples/OmpSCR_v2.0/applications/c_FFT/c_fft.c |
11:45:19 | FromDiscord | <mratsim> and I remember seeing one super complex as well |
11:46:09 | FromDiscord | <mratsim> maybe this one: https://github.com/bsc-pm/bots/blob/master/omp-tasks/fft/fft.c |
11:46:46 | FromDiscord | <mratsim> I nope'd out of this one though |
11:46:53 | FromDiscord | <flywind> Hello, is it wise to use Natural everywhere instead of uint? For example function parameters, minus or plus and return type? |
11:47:22 | FromDiscord | <clyybber> Natural introduces range checks without -d:danger |
11:47:24 | FromDiscord | <mratsim> it's broken as soon as you want to use generics |
11:47:41 | FromDiscord | <mratsim> like "Natural or seq[Natural]" won't type check |
11:48:15 | FromDiscord | <mratsim> https://github.com/nim-lang/Nim/issues/9136 https://github.com/nim-lang/Nim/issues/7446 |
11:48:17 | disbot | ➥ Generics: type mismatch "SomeunsignedInt or Natural" ; snippet at 12https://play.nim-lang.org/#ix=2h98 |
11:48:18 | FromDiscord | <mratsim> otherwise it works |
11:48:48 | FromDiscord | <clyybber> @flywind https://github.com/xflywind/scim/blob/master/src/scim/fft.nim#L146 What does this comment refer to? |
11:52:50 | FromGitter | <alehander92> stacktrace |
11:52:57 | FromGitter | <alehander92> with -d:danger: is it fast ? |
11:53:07 | FromGitter | <alehander92> or do we need libstacktrace? |
11:54:00 | FromDiscord | <flywind> It only supports when array length is 2 ^ N? I can't remeber.@clyybber |
11:54:48 | FromDiscord | <clyybber> Ok, thanks! |
11:55:20 | FromDiscord | <clyybber> @mratsim Do you know of a more up to date fftw wrapper than this one: https://github.com/ziotom78/nimfftw3 ? |
11:59:15 | * | dsrw joined #nim |
12:02:03 | * | dsrw quit (Client Quit) |
12:02:20 | FromDiscord | <flywind> I think this book is a great introduction to fft algorithms. |
12:02:37 | FromDiscord | <flywind> The electronic version of this book is available free of charge at http://www.jjj.de/fxt/#fxtbook, it is identical to the printed version. |
12:03:21 | FromDiscord | <flywind> |
12:03:21 | FromDiscord | <flywind> https://cdn.discordapp.com/attachments/371759389889003532/697416290339651674/fxtbook.pdf |
12:03:48 | FromDiscord | <clyybber> Thanks! |
12:04:11 | FromDiscord | <flywind> no problem. |
12:06:01 | * | supakeen quit (Quit: WeeChat 1.9.1) |
12:06:46 | * | supakeen joined #nim |
12:07:56 | FromDiscord | <clyybber> > radix-2 Cooley-Turkey algorithm: this algorithm can't handle transform of data which size is not a power of 2 |
12:08:11 | FromDiscord | <clyybber> So thats the reason for the comment probably |
12:09:31 | Araq | mratsim: that has nothing to do with generics though, but with the "convertible" type relation |
12:09:55 | Araq | and you can always use 0.Natural much like you can use 0'u32 |
12:16:41 | * | Guest51436 quit (Ping timeout: 250 seconds) |
12:18:35 | * | dadada joined #nim |
12:18:59 | * | dadada is now known as Guest16363 |
12:27:38 | FromDiscord | <eliezedeck> > The mem usage is spiking in the last 2 lines of `infeficientCopiesAllOver` |
12:27:38 | FromDiscord | <eliezedeck> @clyybber yes, that's because that's where the interesting part of the program begins ... I'll try rcstring; is there something you think we should test by doing that? because I can `shallow randomBuff`, which I believe would have the same effect |
12:28:04 | FromDiscord | <eliezedeck> once it enters `HttpClient.send()`, the string becomes immutable, right? |
12:35:33 | dom96 | Araq, can I get a review? #13919 |
12:35:34 | disbot | https://github.com/nim-lang/Nim/pull/13919 -- 3Fixes issues with dynamic loading OpenSSL. Fixes #13903. |
12:39:03 | * | endragor quit (Remote host closed the connection) |
12:48:40 | Araq | bummer |
12:48:56 | Araq | my tool is smarter than me |
12:49:34 | Araq | ah no it isn't |
12:50:47 | FromDiscord | <eliezedeck> @Araq: in `sysstr.nim`, is there anything that would indicate that the souce string is currently immutable? |
12:50:56 | * | sunwukong` joined #nim |
12:50:59 | FromDiscord | <eliezedeck> source* |
12:56:41 | FromGitter | <alehander92> Araq |
12:56:48 | FromGitter | <alehander92> `old` is an interesting annotation |
12:58:03 | FromGitter | <alehander92> can it apply to globals |
12:58:49 | FromGitter | <alehander92> and overally can globals be somehow used in require/ensure? probably impossible, (tho one can indeed count them as "invisible params" as clyybber says) |
12:59:19 | * | filcuc joined #nim |
12:59:21 | Araq | globals don't cause any trouble |
12:59:48 | FromGitter | <alehander92> but can you say `global == old(globalVariable)` |
13:00:07 | * | filcuc quit (Client Quit) |
13:00:09 | Araq | not yet, but in principle, yes |
13:00:13 | FromGitter | <alehander92> e.g. to ensure the function doesnt change this variable |
13:00:18 | * | zacharycarter joined #nim |
13:00:23 | FromGitter | <alehander92> ok |
13:00:30 | FromGitter | <alehander92> what did you decide about break/return etc |
13:00:51 | Araq | return is harmless, just check the .ensures holds |
13:01:09 | Araq | break needs some additional logic but seems to work too |
13:01:38 | Araq | you need to combine the break condition with the condition of the loop |
13:01:41 | Araq | e.g. |
13:01:49 | Araq | while A: |
13:01:50 | FromGitter | <alehander92> so can it detect like dead code , or does the whole analysis happen after dce |
13:01:54 | Araq | if B: break |
13:02:30 | Araq | --> postcondition: not A or B |
13:02:46 | FromGitter | <alehander92> yeah, this makes sense, so basically it can detect some code would be never ran |
13:03:02 | FromGitter | <alehander92> and e.g. `list[list.len + 1]` is not an error after if true: break |
13:04:34 | * | sunwukong` left #nim ("Leaving") |
13:06:50 | * | sunwukong joined #nim |
13:10:22 | * | nsf quit (Quit: WeeChat 2.7) |
13:14:11 | Araq | muhahah 'old' works :-) |
13:19:04 | * | zacharycarter quit (Quit: Lost terminal) |
13:20:19 | * | zacharycarter joined #nim |
13:21:43 | zacharycarter | shashlick: is there an easy way to capture the output from what nimterop produces? I added a call to `cDebug` but if I pipe the output to my clipboard tool it doesn't copy it |
13:21:55 | zacharycarter | I want to compare the output of sokol with nimterop vs nimterop head |
13:23:37 | * | natrys quit (Ping timeout: 264 seconds) |
13:26:46 | * | dddddd joined #nim |
13:35:31 | * | natrys joined #nim |
13:39:13 | FromDiscord | <mratsim> is there a defined(danger)? |
13:39:27 | FromDiscord | <clyybber> Yeah! |
13:39:32 | FromDiscord | <clyybber> And its defined(danger) |
13:39:34 | FromDiscord | <clyybber> :p |
13:51:16 | * | sendai_ joined #nim |
13:59:36 | shashlick | There's no cOutput yet |
13:59:43 | shashlick | But cDebug works usually |
13:59:49 | zacharycarter | hmm |
14:00:01 | zacharycarter | I'll try to figure out how to capture it |
14:03:49 | dom96 | yay, thanks for merge |
14:04:33 | FromGitter | <faulander> hi, nim newbie coming from python here. Ok, originally coming from assembler (6502) in mid 80ie, but that doesn't count. Looking forward to use Nim alot in the future. Just wanted to say hi and thanks for this cool language. |
14:04:53 | FromGitter | <kaushalmodi> @faulander The language and this community is awesome |
14:04:56 | FromGitter | <kaushalmodi> Welcome |
14:05:41 | FromGitter | <faulander> i am still struggling alot, but i'll find my way around. someone who was self-teaching assembler will get the hang of everything - will take a while though :) |
14:05:44 | FromGitter | <zetashift> Enjoy your stay faulander |
14:06:10 | FromGitter | <Vindaar> @faulander Welcome! Don't worry about asking questions, people are really nice around here |
14:06:59 | zacharycarter | welcome! |
14:07:07 | dom96 | hello faulander! Welcome :D |
14:07:13 | FromGitter | <faulander> i have a question indeed. i am using django for web projects alot - but i am not, and never will be a frontend guy. i read that Nim can be compiled to JS - so where would i start reading on it? |
14:07:40 | FromGitter | <mratsim> nim js yournimfile |
14:07:53 | FromGitter | <alehander92> or `nim -d:nodejs js yournimfile` |
14:07:59 | FromGitter | <alehander92> if you just try it in the terminal |
14:08:23 | FromGitter | <alehander92> `nim js` is the browser one tho |
14:09:17 | livcd | and there's karax |
14:09:24 | livcd | although I dislike how karax reads :/ |
14:09:43 | FromGitter | <faulander> i hate c notation - so i would prefer python (or nim) notation to write my frontend code. Do i need to read up on something? how would i create dom manipulation in nim? That's what i meant when asking for a starting point, not how to compile it ;) |
14:10:08 | FromGitter | <alehander92> but this is important too |
14:10:12 | zacharycarter | shashlick: https://gist.github.com/zacharycarter/52030f74296fc3662746b94ae1e87f70 |
14:10:26 | livcd | faulander: https://github.com/pragmagic/karax |
14:10:27 | FromGitter | <alehander92> yeah, you can use karax which does vdom diffing: something like what react/vue/similar do internally |
14:10:39 | FromGitter | <alehander92> you can also just call the normal browser dom API-s |
14:10:44 | FromGitter | <alehander92> or jquery or whatever you need |
14:11:08 | zacharycarter | the jsffi module is a good one to get familiar with |
14:11:23 | FromGitter | <alehander92> you can look at `jsffi` and `js/dom` in stdlib indeed |
14:11:28 | zacharycarter | but there's also this module https://nim-lang.org/docs/dom.html |
14:11:35 | FromGitter | <faulander> ok, i start reading jsffi and karax. thanks guys. |
14:11:39 | zacharycarter | those are the two modules I'd check out |
14:11:54 | livcd | faulander: check dom96's nimforum as a reference |
14:12:02 | FromGitter | <alehander92> and also note: you can use all kinds of 3rd party modules in two way: either dynamically with `JsObject` which you might need to cast on the boundary with normal nim typed code |
14:12:05 | zacharycarter | karax is a library, not part of the stdlib - so you may want to check it out after you see what the dom and jsffi modules have to offer |
14:12:10 | FromGitter | <alehander92> or with annotating them with `importcpp` |
14:12:44 | FromGitter | <alehander92> we can port typescript definitions to nim types one day .. but the older tool that did it isnt maintained anymore :( |
14:13:09 | livcd | is Araq still working on knete? |
14:13:09 | FromGitter | <alehander92> and usually its easy enough to type the several functions you really need typed |
14:13:26 | Araq | livcd: no but why? |
14:13:26 | * | qwertfisch quit (Read error: Connection reset by peer) |
14:13:38 | FromGitter | <faulander> imports made me already struggle, haha. Last time i was writing pascal or code like that was in school in early 90s. Of course i knew i have to create procs before calling them, but since i am so used to python where this is not necessary i forgot it and struggled an hour :) |
14:13:42 | livcd | Araq: because you said it will replace karax |
14:13:46 | FromGitter | <alehander92> something like svelte for nim might be interesting too |
14:13:59 | Araq | livcd: I say many things |
14:14:13 | zacharycarter | can the modern web die already please? |
14:14:56 | * | qwertfisch joined #nim |
14:14:58 | FromGitter | <zetashift> @alehander92 isn't that really hard though? They use some tricks specifically tailored to the dynamic nature of JS I think |
14:15:09 | FromGitter | <alehander92> i am not sure honestly |
14:15:11 | FromGitter | <faulander> i would love to see a modern dreamweaver like tool which creates css and framework code. that would sell like cut bread. |
14:15:14 | zacharycarter | would be cool to see someone build something like blazor with Nim |
14:15:20 | FromGitter | <alehander92> ahh are you talking for typescript sourcemaps |
14:15:25 | FromGitter | <alehander92> types* |
14:15:39 | zacharycarter | I started to make an attempt and then rapidly lost interest when I remembered how much I hate the web |
14:15:51 | livcd | zacharycarter: are you back in the states? |
14:15:57 | zacharycarter | yeah - in Austin now |
14:16:05 | livcd | cool! |
14:16:20 | zacharycarter | yup! just in time for quarantine! |
14:16:39 | livcd | Did you also find a new job? |
14:16:48 | livcd | sorry ...we an perhaps go to #nim-offtopic |
14:18:03 | Araq | zacharycarter: lol :-) +1 for hating the web |
14:18:15 | FromGitter | <zetashift> fwiw alehander92 I do think a no vdom solution for Nim would be nice, e.g. like svelte or this one: https://github.com/raquo/Laminar |
14:18:18 | FromGitter | <faulander> +1 from me to, atleast for fronted |
14:19:11 | FromGitter | <alehander92> maybe! |
14:19:17 | Araq | zetashift: karax has a vdom |
14:19:25 | nisstyre | I'm writing a window manager in Nim. If I want to support dynamically recompiling and reloading, all that's needed is to serialize my state somehow, recompile with nimble, then call execv on the freshly built executable. Does that sound right? |
14:21:19 | Araq | not sure, for NimEdit I used the compiler as a library to make everything theme-able |
14:21:47 | Araq | and while nimEdit sucks big time, I never regretted using nimscript |
14:21:47 | nisstyre | that might be a better idea |
14:22:12 | shashlick | @zacharycarter that's a working version? |
14:22:34 | zacharycarter | shashlick: the file named `nimterop_sokol_master.txt` is the working one |
14:23:00 | zacharycarter | the one named `nimterop_sokol_head.txt` is the one that is produced when I run with nimterop@#head |
14:23:26 | zacharycarter | both of those are just from me running `nim c -r` on the wrapper file itself, not on my whole project |
14:23:30 | FromGitter | <sheerluck> sokol is falcon in Russian |
14:23:44 | * | kungtotte quit (Read error: Connection reset by peer) |
14:23:45 | zacharycarter | so they don't produce the SIGABRT I mentioned yesterday |
14:24:05 | zacharycarter | sheerluck: yes it is |
14:25:09 | * | kungtotte joined #nim |
14:26:17 | shashlick | Ok but still arc right? |
14:26:53 | livcd | sokol is falcon in slavic languages |
14:28:25 | zacharycarter | shashlick: no no arc when I produced those |
14:28:40 | zacharycarter | I can produce the crash without involving arc |
14:29:15 | zacharycarter | lmk if you want the same thing but for the entire project - I can produce that as well |
14:33:32 | shashlick | well, so you aren't seeing the failure without the entire project right? |
14:34:34 | zacharycarter | shashlick: yes the runtime error occurs only when I run the entire project |
14:34:42 | zacharycarter | and only when I use nimterop@#head |
14:35:38 | FromGitter | <zetashift> @Araq I know, I ment that Svelte and Laminar don't use one( a VDOM), and that option would be nice to have in Nim too |
14:35:44 | * | sendai_ left #nim ("Leaving") |
14:36:10 | shashlick | @zacharycarter: can you share some minimal example I can reproduce here? do you get a stack trace or something i can debug |
14:36:27 | FromGitter | <zetashift> But I think Svelte offloads a lot of complexity to it's compiler too |
14:36:56 | zacharycarter | shashlick: what OS are you using? |
14:37:05 | * | liblq-dev quit (Ping timeout: 250 seconds) |
14:38:14 | shashlick | i'm on linux but can debug on osx if needed |
14:38:29 | Araq | fwiw I don't want "reactive"ness anymore, it's complex stuff, had reactive seqs in Karax |
14:39:10 | * | liblq-dev joined #nim |
14:39:48 | zacharycarter | shashlick: well the repo is up on github and currently works only on OSX. Give me a few moments though - looking at the files I produced and checking them against sokol.h and the stack trace I have. |
14:40:07 | shashlick | awesome - i can pull and run and see how it works here |
14:41:28 | Araq | but yeah, I'd probably try to make 'Knete' more convenient |
14:42:35 | zacharycarter | shashlick: https://github.com/zacharycarter/junkers - should just need to do `git submodule update --init --recursive` and then `nim c -r src/junkers.nim` from the project root |
14:43:10 | disruptek | fwiw, ic will probably do dce automagically. |
14:43:34 | zacharycarter | I'm wondering if it's being caused by - `sg_buffer_desc* {.importc: "struct sg_buffer_desc", header: headersokol_gfx, bycopy.} = object` in master vs `sg_buffer_desc* {.bycopy.} = object` on #head |
14:45:34 | shashlick | but are you using -f:ast2 with #head or legacy |
14:46:02 | shashlick | oh ya, #head also has the optional {.header.} feature |
14:46:21 | shashlick | can you try with the `-H` flag and see if it works |
14:46:45 | * | liblq-dev quit (Ping timeout: 258 seconds) |
14:48:34 | * | liblq-dev joined #nim |
14:50:21 | zacharycarter | shashlick: sure where does the -H flag go? on `cImport`? |
14:50:31 | zacharycarter | and I'm not using `-f:ast2` yet in any of this |
14:51:32 | shashlick | ya, just provide flags = "-H" |
14:52:11 | shashlick | basically I added https://github.com/nimterop/nimterop/issues/169 |
14:52:11 | disbot | ➥ Skip `{.header.}` generation |
14:52:16 | zacharycarter | yup that fixed it |
14:52:38 | zacharycarter | now let me try with ast2 |
14:52:50 | shashlick | it's interesting - including the header fixes the issue but need to understand why |
14:53:26 | zacharycarter | can I do `flags = "-H -f:ast2"`? |
14:53:34 | shashlick | yes |
14:53:38 | zacharycarter | okay let me try that |
14:53:40 | shashlick | header is opt in |
14:53:57 | shashlick | is this supposed to work on linux |
14:54:04 | zacharycarter | no not yet |
14:54:11 | zacharycarter | only on macosx right now |
14:56:40 | zacharycarter | okay adding - `-f:ast2` to the flags for sokol works, but if I add it to the second library I'm using nimterop with: `physfs` I get an error |
14:57:52 | zacharycarter | and I can reproduce it without the entire project |
14:58:13 | shashlick | nice |
14:58:37 | zacharycarter | need to go to a meeting but will be back after that |
14:58:58 | shashlick | cool |
14:59:17 | * | endragor joined #nim |
15:03:54 | * | couven92 joined #nim |
15:04:16 | shashlick | the original issue without -H, is it failing at runtime? |
15:04:44 | zacharycarter | yup |
15:05:01 | shashlick | okay, need GUI so not running on SSH |
15:06:27 | disruptek | ~stream |
15:06:27 | disbot | stream: 11https://twitch.tv/disruptek (live video/audio) and mumble://uberalles.mumbl.io/ (live voice chat) -- disruptek |
15:06:42 | disruptek | today we try to find a way around broken .loc in the ast. |
15:07:01 | FromDiscord | <Rika> Has anyone ever thought of adding namespaces to nim, or is there a better solution |
15:08:33 | FromDiscord | <Rika> Actually, I have to go, so I'll just ask it again or not some other time, please disregard |
15:08:45 | * | endragor quit (Remote host closed the connection) |
15:08:58 | FromDiscord | <Rika> Don't try pinging either, since you can't exactly ping from irc to discord, so yeah |
15:09:02 | FromDiscord | <Recruit_main707> ngl, i never got the point of namespaces |
15:09:13 | Araq | Rika: modules have namespaces |
15:09:23 | FromDiscord | <Recruit_main707> @Rika |
15:09:56 | FromDiscord | <Recruit_main707> i tried :( |
15:12:24 | FromGitter | <faulander> can you point me to a resource on how to create a list of dict (python) or a linked list of tables (nim) (at least i know that already) |
15:12:33 | FromDiscord | <Rika> I mean like the namespace of C# where you can define a symbol for namespacing within a file |
15:12:47 | FromDiscord | <Rika> I really have to go now, I'll think this over later |
15:12:54 | FromDiscord | <Rika> It's prolly not needed in Nim |
15:13:12 | FromDiscord | <Rika> faulander: see the tables module |
15:13:28 | FromDiscord | <Rika> Then just wrap the Table type you want in a seq |
15:13:40 | FromDiscord | <Rika> I have to go (sleep, it's late) |
15:13:45 | FromGitter | <kaushalmodi> @faulander And list could be sequences (or arrays .. a bit unlikely) on how you implement in Nim |
15:13:54 | FromDiscord | <Recruit_main707> good night Rika |
15:14:39 | FromGitter | <faulander> @kaushalmodi i don't understand? |
15:15:07 | FromGitter | <faulander> so i create a list like a seq and append the table to it? |
15:15:32 | FromGitter | <kaushalmodi> In Nim, there are sequences and arrays.. check out https://narimiran.github.io/nim-basics/#_containers |
15:15:47 | FromGitter | <kaushalmodi> > so i create a list like a seq and append the table to it? ⏎ ⏎ Yes, you can create a seq of any type |
15:16:21 | FromGitter | <kaushalmodi> If you haven't already, check out https://play.nim-lang.org/ |
15:16:31 | FromDiscord | <Rika> Python list == Nim seq |
15:16:41 | FromDiscord | <Rika> Python diff == Nim table |
15:16:43 | FromGitter | <kaushalmodi> first play with Nim tables there.. and then extend that to play with seqs of tables |
15:16:48 | FromDiscord | <Recruit_main707> u need to sleep |
15:16:48 | FromGitter | <faulander> and what is the type of the seq? |
15:17:01 | FromDiscord | <Rika> I don't know why I'm still here :) |
15:17:15 | FromGitter | <kaushalmodi> @faulander check out that nim-basics link |
15:17:29 | FromGitter | <kaushalmodi> you can have a seq of *any* type.. ints, floats, objs, tables, you name it |
15:17:33 | FromGitter | <faulander> @kaushalmodi will do, thanks. i know i am asking basics :( |
15:19:20 | FromGitter | <kaushalmodi> no worries; that's why I pointed you to a good resource |
15:19:23 | FromGitter | <faulander> i read the article. It states nowhere, what the type of the seq must be if it's tables. |
15:20:02 | FromGitter | <kaushalmodi> it will be of the `Table` type: https://nim-lang.github.io/Nim/tables#Table |
15:20:13 | FromGitter | <kaushalmodi> so, first play with the Table type |
15:20:14 | FromGitter | <faulander> that's what i wanted to hear :) thanks |
15:20:48 | FromGitter | <kaushalmodi> I built up some Nim notes over time.. here are some on tables: https://scripter.co/notes/nim/#tables |
15:33:36 | FromGitter | <faulander> Error: cannot instantiate 'Table[A, B]' inside of type definition: 'tradl'; Maybe generic arguments are missing? |
15:33:52 | FromGitter | <faulander> var possible_downloads: seq[Table] = @[] |
15:35:52 | FromGitter | <eagledot> This is my first time .Can i just ask a question directly? |
15:35:55 | FromGitter | <faulander> same error on the playground |
15:36:44 | FromGitter | <faulander> @eagledot if someone is still here? :) |
15:36:56 | FromGitter | <eagledot> yes. i am here. |
15:37:10 | FromGitter | <faulander> i meant, someone who can answer your question :) |
15:37:24 | FromGitter | <faulander> i presumely cannot - also newbie |
15:37:44 | FromGitter | <zetashift> You can just ask the question directly heh |
15:37:54 | FromGitter | <eagledot> Ok. Thanks |
15:38:15 | FromGitter | <eagledot> I am having a problem as raised in issue here. https://github.com/dom96/nim-opencv/issues/11#issue-595597351 |
15:38:41 | FromGitter | <eagledot> I thought of asking here directly than waiting on github. |
15:39:40 | dom96 | $ and then toSeq with 'cast' seems like you're asking for trouble :) |
15:39:59 | dom96 | no idea what's in frame.imageData but have a look at how they do it in C and just translate that |
15:40:18 | FromGitter | <eagledot> I am a newbie to Nim donot know my way around much. :) |
15:40:39 | FromGitter | <faulander> me neither, stuck on soooo many basic problems - but its fun! :) |
15:40:57 | * | sunwukong quit (Quit: Leaving) |
15:41:50 | FromGitter | <eagledot> i have stated the problem more clearly here . https://forum.nim-lang.org/t/6163#38052 |
15:43:09 | FromGitter | <eagledot> I have pointer (i.e cint type) for a camera frame. So the data size i think should be fixed for a frame? |
15:43:37 | FromGitter | <Vindaar> @faulander your error message says what's wrong. You need to specify the table, e.g. `Table[string, int]`, so `seq[Table[string, int]]` or whatever types your table should hold |
15:44:09 | FromGitter | <eagledot> @dom96 how to get data from a cint type into a sequence? |
15:44:21 | FromGitter | <zetashift> @faulander glad to know you're enjoying it |
15:45:15 | dom96 | Firstly a `cint` is not a `pointer` |
15:45:23 | dom96 | either the wrapper is incorrect or you're doing something wrong :) |
15:45:43 | FromGitter | <faulander> @Vindaar so if its 6 times string i do Table[string, string,string,string,string,string,] |
15:45:58 | FromGitter | <faulander> or Table[string:string, string:string ..] |
15:45:59 | FromGitter | <eagledot> @sorry my bad i wanted to say cstring as pointer not cint |
15:46:11 | dom96 | I guess the frame data is an fixed size array? If so you can just cast[array[64, uint8]](myPointer) |
15:46:31 | FromGitter | <Vindaar> @faulander no, a Table holds keys of one type (the first arg in `Table[arg1, arg2]`) and has values for each such key of type `arg2`. |
15:46:58 | FromGitter | <Vindaar> The table doesn't care how many elements it has to hold |
15:47:01 | FromGitter | <faulander> aaah, yes. of course. so its key:value pairs, dumb me. so its string, string |
15:47:36 | FromGitter | <Vindaar> and your `seq` of tables is only required if for some reason you actually need several Tables of course |
15:47:50 | FromGitter | <eagledot> It defines it as imageData*: cstring # Pointer to aligned image data. |
15:48:36 | FromGitter | <eagledot> @dom96 So i can directly cast imageData as array[64,uint8] |
15:48:53 | FromGitter | <faulander> yes, i have a table with 2 key:value pairs and a seq of many of these tables, its a small downloader for internal use. the table holds filename:filename, url:url and the seq is a list of these |
15:49:08 | dom96 | eagledot: if that is what the C code examples do, then yes |
15:51:05 | FromGitter | <eagledot> @dom96 i meant to ask if a variable is of type cstring. Then would it mean it is a pointer to an array of bytes/characters ? |
15:51:06 | FromGitter | <Vindaar> @faulander ah, I see! |
15:51:27 | FromGitter | <faulander> @Vindaar it works, thank you so much! |
15:51:33 | FromGitter | <Vindaar> you're welcome! |
15:51:37 | dom96 | eagledot: sometimes, it can be anything really |
15:52:39 | dom96 | assuming that the wrapper is correct though, it is an array and likely contains bytes, yes. |
15:54:39 | FromGitter | <eagledot> @dom96 Your nim-opencv code works fine. and it returns a reference to type i put here. https://forum.nim-lang.org/t/6163#38052 . Can u take a look? |
15:54:55 | zacharycarter | shashlick: back - sorry that meeting was long |
15:55:22 | shashlick | No worries, I'm meetings myself |
15:55:47 | * | Trustable joined #nim |
15:56:01 | shashlick | How much of sokol are you using in your code |
16:05:44 | * | couven92 quit (Quit: Client Disconnecting) |
16:07:25 | FromGitter | <eagledot> @dom96 Sorry you were right .It was foolish of me first casting `cstring` to string using `$` .Direct casting to |
16:10:26 | FromGitter | <eagledot> @dom96 As i gather casting to desired type generally using `cast[T]` works basede on T .It is heavily overloaded proc right?? |
16:14:46 | ryukoposting | how efficient is iteration over key-value pairs in a table? Say, versus iteration over just the keys, just the values, or a seq |
16:14:56 | Yardanico | @eagledot "cast" is not "type conversion" |
16:15:02 | Yardanico | it's literal casting with same memory representation |
16:15:17 | Yardanico | you usually only use it when doing FFI or some low-level stuff |
16:15:30 | FromDiscord | <mratsim> key should be efficient, values and key-values should be same speed and slower because there is a need to dereference |
16:16:22 | FromGitter | <eagledot> @Yardanico Can u tell me a more about `cast ` operation. I am generally confused. |
16:16:33 | Yardanico | https://nim-lang.org/docs/tut2.html#object-oriented-programming-type-conversions |
16:16:42 | ryukoposting | thanks mratsim. Was just curious. Chroma uses tables to store the objects representing each UI element, character, dialogue, etc declared by the user, and there are many places where it has to iterate over those tables. |
16:17:23 | Yardanico | "cast" is not really implemented as a normal procedure, it's a compiler magic |
16:17:52 | ryukoposting | Trying to figure out why it occasionally has a weird performance hiccup. |
16:17:57 | Yardanico | you can "cast" any type to any type, but it's an unsafe operation so you can get crashes and all sorts of interesting stuff ;) |
16:18:25 | FromDiscord | <mratsim> cast does that conversion just for integer/floats but that's likely inherited from history, now it's really a reinterpretation of the memory layout for everything else |
16:19:00 | FromDiscord | <mratsim> @ryukoposting, if you search for hash or table and performance on the github there are several threads |
16:19:08 | ryukoposting | yup, cast[T](x) is exactly like doing (T)x in C. Just gives you a variable at the same place in memory with a different type. Very useful for interfacing with C libraries, very dangerous otherwise |
16:19:19 | FromDiscord | <mratsim> many were addressed but had other corner case perf issues |
16:19:31 | FromGitter | <eagledot> @Yardanico Thanks for explanation.I wanted to know that i can get different results based on what i cast ? |
16:20:04 | Yardanico | what do you mean? |
16:20:22 | Yardanico | well, if you do something like casting a int to a pointer and try to dereference it... |
16:20:38 | Yardanico | !eval echo cast[ptr string](123123)[] |
16:20:38 | ryukoposting | embedded guys be like |
16:20:41 | NimBot | Traceback (most recent call last)↵/usercode/in.nim(1) in↵SIGSEGV: Illegal storage access. (Attempt to read from nil?) |
16:21:05 | FromGitter | <eagledot> like if i cast a `cstring` to int and if i cast the `cstring` to an array[64,uint8] |
16:22:05 | FromDiscord | <Chiqqum_Ngbata> How to accomplish https://play.nim-lang.org/#ix=2heZ |
16:23:16 | FromDiscord | <mratsim> you can directly cast the cstring to arra[64, byte] |
16:23:36 | ryukoposting | Chiqqum_Ngbata looking at your code rn, one moment |
16:23:44 | FromDiscord | <mratsim> fn should be untyped |
16:23:57 | FromDiscord | <mratsim> in the macro |
16:24:35 | ryukoposting | haven't touched pragma macros much, so trying to read this is making me dizzy |
16:24:42 | FromGitter | <eagledot> @mratsim Ok Earlier i tried to first cast it using $ and then to a sequence.It gave weird results. |
16:25:11 | FromDiscord | <mratsim> don't cast to GC-ed type unless you now the internal representation of set:string |
16:25:54 | FromDiscord | <mratsim> I thought I had a forum post or Nim issue with lots of example of macro as pragma mmm :/ |
16:26:14 | FromDiscord | <Chiqqum_Ngbata> That errs @mratsim https://play.nim-lang.org/#ix=2hf9 |
16:26:19 | FromDiscord | <mratsim> ah yes: https://forum.nim-lang.org/t/5450 |
16:26:48 | FromDiscord | <mratsim> see the second version: https://forum.nim-lang.org/t/5450#34078 |
16:27:04 | zacharycarter | shashlick: I'm using sokol_gfx and sokol_app atm |
16:27:19 | FromGitter | <eagledot> @mratsim Ok,So i know the exact data type like `T= array[64,uint8]` I just use casting as `cast[T](x)` while interfacing with C libraries? |
16:27:22 | zacharycarter | but will eventually be using some more of the modules i imagine |
16:28:48 | FromDiscord | <Chiqqum_Ngbata> I don't think I've seen an example that does what I want. Is it actually possible for the pragma macro to return a non-function |
16:29:36 | FromDiscord | <mratsim> @eagledot, you can directly use array[64,uint8] in your wrapper signature |
16:30:32 | FromDiscord | <mratsim> @Chiqqum_Ngbata yes |
16:30:50 | FromDiscord | <mratsim> if you modify the runHook macro in my example |
16:30:55 | FromDiscord | <mratsim> you can make it return anything |
16:31:15 | FromDiscord | <mratsim> it's just an AST transformation and the last argument gets passed the proc declaration |
16:31:48 | * | Trustable quit (Remote host closed the connection) |
16:32:11 | FromDiscord | <mratsim> use the example and put some "toStrLit" on some of the AST node, it should be simple enough |
16:33:03 | FromDiscord | <Chiqqum_Ngbata> Is there an obvious reason why this minimal example does not work https://paste.ofcode.org/YzB78fSG2AwgfcqgZdKfqf |
16:35:31 | * | Trustable joined #nim |
16:41:46 | FromDiscord | <Recruit_main707> how did i initialise a result sequence? |
16:42:21 | Yardanico | nim seqs are initialized by default since 0.20 or something like that |
16:42:24 | Yardanico | same for strings |
16:42:37 | Yardanico | if you still want to do it explicitly, "result = @[]" |
16:42:56 | FromDiscord | <Recruit_main707> yep, i was doing something else wrog, thanks anyway |
16:43:19 | Yardanico | Also, does anyone know what's the best way to implement thread timeouts? |
16:44:01 | Yardanico | so that for example I can stop all threads which execute for longer than 10 seconds |
16:44:07 | Yardanico | while having a lot of threads running simultaneously |
16:56:05 | shashlick | @zacharycarter awesome cause just wrapping doesn't mean much, need to use the generated procs too so glad I can test with your code base |
16:56:21 | shashlick | Will do the same with lqdev's rapid as well |
16:58:18 | * | lritter joined #nim |
16:58:31 | zacharycarter | nice! |
17:00:21 | FromGitter | <dumjyl> Chiqqum_Ngbata: you can't use an nnkProc as an nnkLambda, you need to transform it: https://play.nim-lang.org/#ix=2hfr |
17:05:13 | FromDiscord | <Chiqqum_Ngbata> Oh, right. This makes sense |
17:05:16 | FromDiscord | <Chiqqum_Ngbata> Thanks |
17:09:01 | * | Guest16363 is now known as dadada |
17:09:28 | dadada | hi |
17:21:40 | dadada | maybe you guys can appreciate some Miles Davis https://www.youtube.com/watch?v=OcIiu1kQMx0 |
17:22:32 | companion_cube | that's a good idea |
17:24:52 | companion_cube | dadada: https://www.youtube.com/watch?v=YYTIXJuxvgY |
17:27:40 | * | dongbei joined #nim |
17:29:04 | dongbei | good day, I was reading about arc and then I watched this vid on the different memory management models https://youtu.be/yA32Wxl59wo?t=20m43s |
17:29:24 | dongbei | at that time in the video rumpf talks about object pools |
17:29:40 | dongbei | I don't understand what he's explaining |
17:29:54 | dongbei | does that have anything to do with arc and how can I use it? |
17:30:33 | dadada | rumpf is Araq here |
17:30:37 | dongbei | yah |
17:30:41 | dongbei | ok so Araq |
17:30:52 | dongbei | sorry |
17:31:18 | dadada | no need to be sorry |
17:31:41 | FromGitter | <yglukhov> Hey guys, how do I make an object outlive NimMain with --gc:arc. Or better - all objects. |
17:32:14 | FromGitter | <yglukhov> A global variable that is |
17:33:07 | leorize | I thought global vars are not destroyed? |
17:34:04 | leorize | but what would be the use case for outliving NimMain? doesn't that basically mean that your program continues to run after it exits? |
17:34:27 | FromGitter | <yglukhov> I thought so too, but apparently gdb shows `eqdestroy___Zdkyao3Rp9cTCBDO7vWqjWw` for a global var at the end of `NimMainModule` |
17:34:55 | FromGitter | <yglukhov> It makes sense for a library. |
17:35:11 | Araq | hmm well it's a feature |
17:35:22 | leorize | dongbei: it's a specialized scheme of memory management |
17:35:40 | leorize | basically you allocate a large pool with enough space for all of your objects |
17:35:46 | Araq | makes no sense to me, but it's a feature |
17:35:48 | leorize | say, a big seq[T] |
17:36:38 | leorize | when you "free" an object, just basically mark the space as empty and re use it later |
17:36:54 | leorize | save you the time spent allocating and deallocating memory |
17:37:42 | leorize | @yglukhov: that sounds like a bug then |
17:38:11 | Araq | yglukhov: tried --noMain ? |
17:38:34 | leorize | global vars shouldn't be destroyed in a shared lib because we don't know when the program that use it quits |
17:38:44 | FromGitter | <yglukhov> Araq: so I'm using this pattern a lot. for nimpy, for emacs, for android and emscripten apps. It basically goes like this. NimMain is called first to initilialize and execute global scope, setup callbacks etc. then other exported functions are called and they kinda may rely on the global vars. |
17:38:58 | leorize | Araq: --noMain just disable to auto initializer |
17:39:07 | leorize | NimMain is still there |
17:40:17 | FromDiscord | <Recruit_main707> can you convert a sequence into an array? |
17:40:17 | FromGitter | <yglukhov> Araq: noMain would not help, as i still need to execute main. If I do noMain and run main manually I bet I would still see the same result |
17:40:53 | leorize | @Recruit_main707: yes |
17:41:06 | leorize | not that I'd recommend it :P |
17:41:10 | FromDiscord | <Recruit_main707> how would that be done? |
17:41:42 | leorize | a for loop copying/moving all elements over :P |
17:42:18 | FromGitter | <yglukhov> Araq: as a counterstatement,I see no sense in destroying global vars in NimMain in app:lib mode :) |
17:43:02 | * | tane_ joined #nim |
17:43:09 | FromGitter | <yglukhov> Why would anyone call _dllmain if it can't setup the global state |
17:45:41 | Araq | sure, consider it fixed |
17:46:33 | FromGitter | <yglukhov> Wow, really? That was easy. Thanks :) |
17:47:36 | FromDiscord | <Recruit_main707> `seqToArray*(aseq: seq[(Vector3, float)]): array[aseq.len, Vector3]` how would i do something like this? |
17:47:44 | leorize | you can't |
17:47:54 | leorize | arrays are statically-sized |
17:48:01 | FromDiscord | <Recruit_main707> passing the length as another argument? |
17:48:22 | * | sleepyqt quit (Ping timeout: 256 seconds) |
17:48:26 | FromGitter | <zetashift> I think you'd need an other data structure for that as leorize says arrays need to know their size |
17:48:36 | leorize | if you want a variable sized array it's a seq :P |
17:48:59 | FromDiscord | <Recruit_main707> ill try something else then |
17:52:02 | * | tribly quit (Quit: WeeChat 2.7.1) |
17:52:35 | FromGitter | <yglukhov> Araq: same goes for staticLib I think. |
17:53:04 | leorize | to be fair we might need a nimrtl for static libs :P |
17:53:41 | leorize | nim's handling of static libs is kinda useless atm |
17:54:20 | companion_cube | you mean it's ahrd to statically link? |
17:54:28 | companion_cube | to build a statically linked binary* |
17:55:39 | leorize | no, the static lib created by nim is well, not the best |
17:56:35 | stefantalpalaru | It can be done: https://github.com/status-im/nimbus/blob/927a5f3afeee05e82557f1070cd4ee3e1b69ec7f/Makefile#L129 |
17:57:04 | leorize | basically you will have a "fat" static lib |
17:57:14 | stefantalpalaru | Here it's being used from C and Go: https://github.com/status-im/nimbus/blob/927a5f3afeee05e82557f1070cd4ee3e1b69ec7f/Makefile#L147 |
17:57:54 | leorize | Nim don't split functions into smaller objects (it's hard anyway), so you are certain to have a "fat" static lib that increase the binary size by a ton when linked |
17:58:28 | FromGitter | <yglukhov> leorize: for android i'm actually produce a staticlib with nim, which is later fed to gradle. |
17:58:46 | leorize | not to mention because of the stdlib, you can't link two static objects into a binary because of symbol clashing between them |
17:58:53 | leorize | though libnimrtl can be used to mandate this |
17:58:57 | leorize | but NimMain will still clash |
18:01:04 | * | tribly joined #nim |
18:01:10 | * | tribly quit (Changing host) |
18:01:10 | * | tribly joined #nim |
18:04:40 | companion_cube | leorize: ah ok, I was just wondering about producing one statically linked *binary*, not a lib |
18:04:46 | companion_cube | something easy to copy on other machines |
18:05:15 | leorize | ah, that part is simple, if you're using musl libc :) |
18:05:34 | companion_cube | ✔ cool. |
18:05:56 | * | natrys quit (Ping timeout: 265 seconds) |
18:14:05 | * | rockcavera joined #nim |
18:18:59 | * | natrys joined #nim |
18:24:17 | * | Zectbumo joined #nim |
18:25:46 | FromGitter | <kaushalmodi> companion_cube: https://scripter.co/nim-deploying-static-binaries/ |
18:26:28 | FromGitter | <kaushalmodi> That blog post and the technique described there came to fruition thanks to a lot of help from leorize and folks in this Gitter/IRC |
18:26:47 | companion_cube | thank you 😊 |
18:29:03 | companion_cube | nimble.directory doesn't list the dependencies of a package, that's strange |
18:29:56 | leorize | @kaushalmodi: zig cc support has been merged :) maybe time to revisit that post? |
18:32:01 | FromGitter | <kaushalmodi> yes I know.. I am staying away from another rabbit hole |
18:32:22 | FromGitter | <kaushalmodi> *if it's working, don't touch it right now* |
18:34:24 | Yardanico | I've also had success with https://github.com/richfelker/musl-cross-make |
18:34:32 | Yardanico | for building a cross-compiling toolchain |
18:34:39 | Yardanico | and then manually building libressl with it and then a nim app :P |
18:34:45 | Yardanico | (statically of course0 |
18:37:49 | kungtotte | Am I misunderstanding what "side effect" means in Nim, or does func/noSideEffect not work? I'm able to modify external values passed in without a single complaint from the compiler. It picks up on things like using I/O though. Is that the only side effect that Nim is concerned about? |
18:38:18 | FromDiscord | <Rika> Side effects mean anything not accessible by params |
18:38:34 | FromDiscord | <Rika> Var params can still be edited with no issue |
18:39:04 | FromDiscord | <Rika> YES I KNOW ITS BEEN 3 HOURS SINCE I SAID I'LL SLEEP |
18:39:22 | leorize | I didn't even notice :) |
18:39:43 | leorize | kungtotte: Nim's idea of "side effect" is no where near FP's "pure" definition |
18:40:00 | narimiran | kungtotte: yes, you are misunderstanding what it means in nim :) |
18:40:20 | kungtotte | Yeah I can tell :D |
18:40:29 | FromDiscord | <Rika> Why are they different though I wonder |
18:41:06 | leorize | because Nim's idea is much more practical :p |
18:41:15 | kungtotte | It's not named well in my opinion. CS and pretty much every other programming language (FP or not) has mostly the same idea about what "side effect" means, so Nim using it to mean something different is for sure a gotcha! |
18:41:49 | solitudesf | but its not a side effect, you clearly annotate parameter with `var` |
18:42:20 | FromDiscord | <Rika> That is true, all params in fp are immut aren't they |
18:42:35 | leorize | "in theory" |
18:44:10 | leorize | I'd say that Nim's version of noSideEffect is much more practical than the FP version |
18:44:29 | FromDiscord | <Rika> You said that already |
18:44:35 | leorize | we should clarify this pragma in bold so people stop being confused :P |
18:46:50 | FromGitter | <iffy> @krux02 I'm interested to know your qualitative opinion about what it's like to use https://github.com/arnetheduck/nim-result throughout a project. Do you like how things end up when using it? Or do you miss try/except at all? Does the code seem better or too cluttered? |
18:47:19 | leorize | not krux but I use both that and exceptions in the same project |
18:48:03 | narimiran | @iffy that Arne is not the Arne you mentioned :P |
18:48:26 | FromGitter | <iffy> oh, oops |
18:49:01 | leorize | @arnetheduck is the one you're looking for |
18:49:42 | FromGitter | <iffy> Thanks -- and now I know there are 2+ Arne's in the community :) |
18:50:18 | leorize | I'd say that nim-result works well when you have to handle all of the errors (ie. interfacing to C, or a proc used on the public interface of your web server) |
18:51:06 | leorize | otherwise I like exceptions more, since stacktraces are a killer feature :) |
18:54:00 | FromDiscord | <Rika> I only use a result when there is explicitly a value of none for the field, like an "optional" field or so |
18:54:01 | FromGitter | <iffy> Right... I didn't consider the absence of stack traces. The forced handling of errors is what's making me consider it. |
18:54:18 | FromDiscord | <Rika> In where the optionality isn't defined by a kind |
18:54:51 | leorize | @iffy: if forced handling is something you desire, then nim-result is what you want |
18:54:55 | FromDiscord | <Recruit_main707> i dont know what scares me more, that you havent slept yet, or that you have already woken up |
18:55:15 | leorize | but the moment you found yourself using the `?` operator too much, I'd say exceptions is what you want |
18:55:23 | FromDiscord | <Rika> I haven't slept :P |
18:55:54 | FromDiscord | <Recruit_main707> u should :) |
18:56:13 | Yardanico | @Rika is nim chat that interesting? 🤔 |
18:56:46 | Yardanico | I should probably sleep too, I've been awake for like 18 hours at least |
18:57:07 | * | NimBot joined #nim |
18:58:51 | * | Prestige joined #nim |
19:01:47 | FromDiscord | <Rika> No, I'm thinking that I'm just deprived of programming |
19:05:15 | leorize | you can take Yardanico and make it work without having to restart every 8 hours or so |
19:06:24 | leorize | Yardanico's bot* |
19:06:26 | leorize | :P |
19:06:30 | leorize | the discord bridge |
19:07:17 | FromDiscord | <Recruit_main707> what kind of float is "inf"?? |
19:07:22 | Yardanico | infinity |
19:07:33 | Yardanico | ∞ |
19:07:40 | FromDiscord | <Recruit_main707> that would also explain the overflow |
19:08:33 | Yardanico | well, about the bot - it seems that "irc" nim module is really stable, but the discord part is much more meh (they are very "modern" and use stuff like websockets) |
19:08:48 | Yardanico | well it might be the discordnim's fault, i'm not sure |
19:11:27 | leorize | I'd be worried if irc module is not stable :P |
19:12:17 | Yardanico | also sad to say but matterbridge is really stable too |
19:12:44 | leorize | it might be that the web server disconnects after `n` packets or so |
19:12:52 | leorize | so you just have to reconnect when that happens |
19:13:30 | * | uvegbot joined #nim |
19:13:32 | companion_cube | haven't looked, does `irc` auto-reconnect? I saw it supports TLS, whcih is already more than most IRC libraries in other langs |
19:13:44 | FromDiscord | <Rika> leorize: I have been trying already for a few months |
19:13:55 | leorize | companion_cube: I guess it does |
19:14:02 | leorize | it's the backbone of NimBot and disbot |
19:14:19 | leorize | and they almost never disconnects |
19:14:40 | FromDiscord | <Rika> I have a feeling I know pinpoint the issue with discordnim but haven't gone into it yet |
19:14:41 | companion_cube | yeah that's quite neat |
19:14:51 | Yardanico | i'm embarrased to say that the current running version of matterbridge in this channel is from march 2018 :D |
19:15:01 | Yardanico | maybe I should finish ircord |
19:15:04 | Yardanico | with @Rika |
19:15:07 | FromDiscord | <Rika> Basically I think it doesn't handle disconnected websockets that well |
19:15:30 | FromDiscord | <Rika> Oh, no, my code changes are insanely radical |
19:15:34 | * | zyklon quit (Ping timeout: 240 seconds) |
19:15:35 | Yardanico | that's for the best |
19:15:48 | FromDiscord | <Rika> I made a God macro for the objects... |
19:15:53 | Yardanico | ircord doesn't need a lot of advanced discord functionality anyway |
19:16:13 | FromDiscord | <Rika> I'll have to refactor that macro |
19:16:42 | FromDiscord | <Rika> It's 3 am |
19:16:45 | Yardanico | also seems like "ircord" is used by at least 5 other projects on github which do irc <-> discord, because I'm very good at naming projects |
19:16:47 | Yardanico | 22:16 here |
19:16:56 | FromDiscord | <Rika> I should have slept 6 or 7 hours ago |
19:17:35 | FromDiscord | <Rika> I just name my bots with some anime or Japanese game character name |
19:19:45 | Yardanico | well I've only watched ~200 anime but I guess I should do the same as you |
19:21:36 | * | dongbei quit (Read error: Connection reset by peer) |
19:23:50 | FromDiscord | <Rika> I mean, if you want to do so sure |
19:23:55 | FromDiscord | <Rika> I'm just saying what I do |
19:24:03 | FromDiscord | <Rika> Also 200 is a lot |
19:24:12 | FromDiscord | <Rika> I think I only number at a hundred |
19:24:21 | FromDiscord | <Rika> Though I do number at 600 manga |
19:25:16 | FromDiscord | <mratsim> 200 x 26 episodes x 20 minutes --> 72 days 24/7 of watching animes? |
19:26:02 | FromDiscord | <Rika> Most anime have one cour, that is to say, 13 or 12 episodes |
19:26:33 | FromDiscord | <Rika> Some people don't skip openings and endings, which makes an episode 24 minutes |
19:39:44 | * | al1ranger joined #nim |
19:40:57 | * | dddddd_ joined #nim |
19:42:54 | * | dddddd quit (Ping timeout: 240 seconds) |
19:43:01 | * | dddddd_ is now known as dddddd |
19:44:39 | dadada | Rika: what's a god macro?= |
19:49:24 | * | Tyresc joined #nim |
19:51:28 | FromDiscord | <mratsim> `macro worship(altar: untyped): untyped = discard` |
19:52:00 | dadada | heh |
19:52:15 | FromDiscord | <mratsim> But I suppose it's similar to a god object in OOP |
19:52:32 | FromDiscord | <mratsim> A macro that does everything including the coffee and the kitchen sink |
19:54:31 | dadada | what's a devil macro? |
19:56:26 | FromDiscord | <clyybber> the same |
19:58:28 | dadada | so god and the devil are one? :-) |
19:59:40 | dadada | just found the naming funny |
20:01:47 | * | dongbei joined #nim |
20:07:20 | supakeen | I sometimes see procs with a signature such as `proc foo(value: var Something)`. What does the var denote here? |
20:07:30 | supakeen | (it's a bit of a difficult searchterm) |
20:07:49 | dadada | supakeen: mutability |
20:07:54 | FromDiscord | <clyybber> It denotes that its a mutable parameter |
20:07:59 | solitudesf | https://nim-lang.org/docs/tut1.html#procedures-parameters |
20:10:44 | supakeen | Aha. |
20:11:09 | supakeen | So that implies that functions like this: https://nim-lang.org/docs/bitops.html#setMask%2CT%2CT will mutate their argument instead of returning a new value? |
20:12:11 | * | al1ranger quit (Quit: Leaving) |
20:13:32 | solitudesf | yes. lack of return type also implies that. |
20:13:33 | leorize | Araq: resolved all conflicts in #13201 |
20:13:35 | disbot | https://github.com/nim-lang/Nim/pull/13201 -- 3Make file descriptors from stdlib non-inheritable by default |
20:14:01 | leorize | solitudesf: that could be parsed in the wrong way :P |
20:15:32 | supakeen | solitudesf: Thanks for the explanation, I guess the 'returns' text in the docstring confused me :) |
20:23:19 | * | disruptek quit (Ping timeout: 250 seconds) |
20:24:03 | * | disbot quit (Ping timeout: 256 seconds) |
20:24:41 | * | Zectbumo quit (Remote host closed the connection) |
20:29:02 | * | narimiran quit (Quit: leaving) |
20:39:34 | * | Vladar quit (Quit: Leaving) |
20:48:34 | companion_cube | hmm I'm surprised, the stdlib doesn't have zlib bindings |
20:51:34 | FromGitter | <awr1> i think it used to |
20:51:35 | leorize | bindings are only in the stdlib because it's used somewhere in there |
20:51:45 | leorize | if it's not then it won't be in the stdlib |
20:51:55 | FromGitter | <awr1> https://github.com/nim-lang/zip |
20:52:03 | FromGitter | <awr1> https://github.com/nim-lang/zip/blob/master/zip/zlib.nim |
20:52:08 | companion_cube | are the DB bindings used in the compiler then? |
20:52:23 | FromGitter | <awr1> the compiler uses sqlite |
20:52:57 | leorize | companion_cube: the stdlib provides db_* abstractions |
20:53:20 | companion_cube | yeah that's why I ask, I'm surprised |
20:53:27 | companion_cube | anyway, thanks for the answer. It makes sens |
20:53:29 | companion_cube | e |
20:53:34 | leorize | the stdlib used to be a kitchen sink |
20:53:55 | leorize | we kinda slim it down and cut parts that no one use into packages |
20:54:34 | Prestige | Was looking at this comparison of nim vs typescript https://github.com/nim-lang/Nim/wiki/Nim-for-TypeScript-Programmers#comparison does it say typescript code is formatted with npm? O.o |
20:57:19 | Yardanico | ask @juancarlospaco :P |
20:57:38 | Yardanico | maybe he meant that it's a package that needs to be installed via npm |
20:58:46 | Prestige | nim looks so nice, going to start using this for everything |
21:00:22 | * | dwdv quit (Quit: quit) |
21:08:06 | FromDiscord | <arnetheduck> @iffy see for yourself: https://github.com/status-im/nim-eth/pull/211/files#diff-1428a55e5654ff6e85a6177d4f6101afR343 - like others have said, exceptions work best if you don't care about errors and can crash (which is the only time you need a call stack, if you think about it) |
21:08:23 | ryukoposting | what does it mean if the compiler is saying "export only allowed at the top level" but there's no exports in the module it's complaining about |
21:10:37 | leorize | it means that you might spot an export marker `*` somewhere that's not the top-level |
21:11:21 | ryukoposting | ... is that it |
21:11:32 | ryukoposting | I've spent 2 hours rearranging imports trying to make the damn thing work |
21:11:47 | FromDiscord | <arnetheduck> from a pragmatic point of view - in our medium-sized application, the parts of our codebase that don't use exceptions are also the ones that turn out to be the most solid / have the fewest bugs |
21:13:51 | leorize | though beware that there might be some hidden bias in play |
21:14:36 | FromDiscord | <Varriount> @arnetheduck Personally, I don't mind either style (C-style errors or C++-like exceptions). What I do mind is the fact that it is generally harder to get stack traces when using C-style errors. |
21:14:56 | leorize | +1 |
21:15:22 | FromDiscord | <arnetheduck> yeah, but when do you need stack traces? predominantly when you're not handling errors |
21:15:40 | FromDiscord | <arnetheduck> that's the point kind of -they're great in a script that you're iterating on |
21:15:49 | leorize | I spent hours pin pointing where an error was coming from Haiku code base because they have a strict no-exceptions policy |
21:15:55 | FromDiscord | <Varriount> When I'm debugging? When the system is throwing an exception that I haven't anticipted. |
21:16:26 | dom96 | Varriount++ |
21:16:49 | FromDiscord | <Varriount> With errors, there's then the temptation to add logging before returning each error... and suddenly you get 100 line pseudo-tracebacks that are horrid to read. And you have logging logic in places that shouldn't have logging logic. |
21:17:50 | leorize | arnetheduck: I don't think it's too hard to have nim-result gather stacktrace |
21:18:10 | FromDiscord | <arnetheduck> there's a bias in our issue tracker, that's for sure 🙂 |
21:18:25 | FromDiscord | <Varriount> arnetheduck: That being said, errors in Nim are much more easily handled. |
21:18:42 | FromDiscord | <arnetheduck> leorize: https://github.com/arnetheduck/nim-result/blob/master/result.nim#L344 |
21:18:45 | FromDiscord | <Varriount> You can have templates that do the stock "if err != nil: return" for you. |
21:19:05 | FromDiscord | <Varriount> (or is that too much implicit flow control) |
21:19:11 | dom96 | <leorize> @iffy: if forced handling is something you desire, then nim-result is what you want |
21:19:12 | FromDiscord | <arnetheduck> Varriount: https://github.com/arnetheduck/nim-result/blob/master/result.nim#L516 |
21:19:18 | dom96 | That's wrong, you can also use Nim's exception tracking |
21:19:25 | leorize | @arnetheduck: I mean hidden bias in terms of "this part is more carefully crafted since it's mission critical", and so on |
21:19:57 | FromDiscord | <Varriount> @arnetheduck Yep. That get's rid of 50% of my concerns. |
21:20:25 | FromDiscord | <Varriount> I'll say that trying to determine whether an error should collect a stack trace or not is tricky... |
21:20:27 | leorize | I don't like comparing error handling schemes unless you have two similar projects going with two different schemes |
21:20:49 | FromDiscord | <Varriount> leorize: I'll soon have that, once my port of Go's filepath module is complete. |
21:21:13 | leorize | otherwise there's a lot more to factor in than just "it doesn't use exceptions and it has less bugs" |
21:21:16 | FromDiscord | <Varriount> I have a nearly-semantically-correct version, if not a functional one that I can post. |
21:21:29 | leorize | sure :) that'd be great |
21:22:06 | FromDiscord | <Varriount> https://gist.github.com/Varriount/65a91d2d74baba4d9ec25a173d31e945 |
21:22:36 | leorize | dom96: that works, but when you want forced forced it's different :P |
21:22:44 | leorize | every scheme has it's own use case |
21:22:50 | dom96 | forced forced? |
21:22:56 | dom96 | what does that mean? :) |
21:23:26 | leorize | I'm making an UI, and I want pretty errors :) |
21:24:23 | FromDiscord | <Varriount> leorize: I also posted the Python file used to do the initial syntactic transformation |
21:24:29 | leorize | sure I can use a custom exception handing scheme, but at that point it just look like I'm using `try` in place of `if` |
21:25:07 | FromDiscord | <Varriount> It would be interesting to see a compiler plugin that converted possible exceptions to error return values. |
21:26:13 | dom96 | FWIW I think we should have a Result[T, E] type in the stdlib. But I doubt I'd personally adopt it as much as I have adopted Option[T] |
21:26:40 | FromDiscord | <arnetheduck> exceptions have it in their name that they're good for exceptional situations - that's also when you want to have a call stack - for errors that you intend to actually handle, it's a tremendous waste |
21:27:07 | leorize | a call stack is also useful while debugging fwiw |
21:27:24 | FromDiscord | <arnetheduck> here's a funny thing: `type Option[T] = Result[T, void]` |
21:27:37 | FromDiscord | <Varriount> Hm, is it theoretically possible for a compiler to determine code paths in which an exception is handled, and "turn off" stack traces for those situations? |
21:28:02 | leorize | the problem I have in C: I got an EACCES, I display to the user "Access not granted" |
21:28:19 | leorize | now when I'm debugging, where does that EACCES came from? |
21:28:46 | leorize | I don't know, since it's forwarded from god knows where |
21:29:07 | leorize | that's my biggest issue with the Result scheme |
21:29:24 | FromDiscord | <arnetheduck> you're using it wrong if you're letting that bubble up the abstractions though |
21:29:43 | FromDiscord | <arnetheduck> but whatever, each scheme has its benefits |
21:30:30 | leorize | it's the case in C, sadly |
21:30:41 | leorize | they don't have exceptions so they went with this poor man's scheme |
21:31:41 | leorize | @arnetheduck: do you think having "optional" stack trace support (like -d:resultStackTrace) would be useful? |
21:32:28 | FromDiscord | <arnetheduck> not reallly - I don't believe global defines are ever a good idea beyond toy projects |
21:32:33 | FromDiscord | <arnetheduck> not really - I don't believe global defines are ever a good idea beyond toy projects |
21:32:49 | FromDiscord | <arnetheduck> and toy projects are easy enough to reason about without that kind of crufty |
21:32:51 | FromDiscord | <arnetheduck> and toy projects are easy enough to reason about without that kind of cruft |
21:32:58 | dom96 | Here is the problem with the Result scheme, you have to handle the results explicitly. Then you either end up with Go (simplicity so you just copy and paste `if (err, res) ...` everywhere, or you get more and more complex mechanisms to deal with Result like all sorts of monads and you end up with Hasell |
21:33:00 | dom96 | *Haskell |
21:33:45 | leorize | I don't think we are arguing about that anymore :P |
21:34:26 | leorize | I use a healthy mix of both schemes |
21:34:44 | dom96 | leorize: Are you sure? :P :P :P |
21:35:36 | leorize | the only time that I'd have a problem with the result scheme is when you wanna replace exceptions as the default scheme with it |
21:35:52 | leorize | otherwise they are useful in their own way |
21:39:13 | FromDiscord | <arnetheduck> > a call stack is also useful while debugging fwiw |
21:39:13 | FromDiscord | <arnetheduck> gdb? |
21:40:11 | FromGitter | <awr1> hello all |
21:40:54 | leorize | @arnetheduck: I can either step from the start until I found my error, or I can make it spit out a stacktrace for me and I'd know where to set my breakpoints |
21:41:18 | * | xet7 quit (Quit: Leaving) |
21:41:38 | * | xet7 joined #nim |
21:45:53 | FromDiscord | <arnetheduck> I guess if that's your workflow, gathering stack traces might help sometimes.. or using a `Result[T, cstring]` and making sure each error has a more or less unique string which lands you the line where it was triggered which is usually the part of the stack trace that you're looking at |
21:46:23 | leorize | https://ziglang.org/documentation/master/#Error-Return-Traces <- even something like this will help |
21:46:45 | dom96 | I do actually wonder how Rust/Golang programmers figure out why their program crashes |
21:46:50 | leorize | our exceptions stacktrace when used without --stacktraces:on is also implemented like that |
21:47:08 | dom96 | I often just run things in debug mode so I can get a stack trace on my server |
21:48:30 | companion_cube | I think rust can give stacktraces? |
21:48:52 | FromDiscord | <arnetheduck> well, the stack trace implementation in the nim c backend is preposterous 🙂 |
21:49:29 | FromDiscord | <arnetheduck> rust gives traces for panics - panics in rust btw are exceptions, for all practical purposes: they unwind the stack, you can mostly catch them |
21:51:30 | dom96 | right, but they are likely very rare. What I imagine happens is that everyone spends extra time handling all possible Result variants |
21:51:40 | FromDiscord | <arnetheduck> it's about defaults: exceptions by defualt let you ignore errors, stuff like Result encourage you to handle them - in rust, the default is encourage people to handle/think up-front about errors, but there exists a mechanism to ignore as well - so for example, most of the nim std library is not exception safe, because nobody's really thought about what happens when an exception bubbles up the stack |
21:52:03 | * | solitudesf quit (Ping timeout: 260 seconds) |
21:53:32 | FromDiscord | <arnetheduck> they're rare - yes - they're used as asserts mostly, ie to signal situations the programmer didn't expect would actually happen, and it's even more rare to try to catch them |
21:54:36 | dom96 | yes, and that definitely works much better for certain types of applications |
21:54:57 | dom96 | for Nim that ship has sailed, you'd have to rewrite the stdlib to get the same conventions |
21:55:05 | dom96 | and we all know how that turned out for D. |
21:55:37 | companion_cube | but nim has checked exceptions, right? |
21:55:54 | dom96 | yep |
21:56:15 | FromGitter | <awr1> https://github.com/nim-lang/c2nim/blob/master/doc/c2nim.rst#def-directive |
21:56:38 | FromGitter | <awr1> out of curiosity |
21:57:05 | * | moerm joined #nim |
21:57:07 | FromGitter | <awr1> it seems like #def does everything #define does, so...what's missing? |
21:57:11 | companion_cube | so checked exceptions should be as safe as result types… |
21:57:17 | moerm | Hello everyone |
21:58:28 | leorize | if you know what you're doing, you're safe no matter what scheme you use :P |
21:58:42 | FromDiscord | <Varriount> awr: Normally Nim tries to turn `#define`s into Nim templates. This isn't always possible, because a `#define` can be a syntactically invalid piece of C code. |
21:59:31 | FromDiscord | <Varriount> So `#def` essentially says "don't try to turn this into a template, just treat it like a C define" |
21:59:38 | FromDiscord | <Varriount> *awr1 ^ |
21:59:53 | FromGitter | <awr1> i see |
21:59:56 | FromDiscord | <exelotl> is it recommended to have the "nim" in ".. code-block:: nim" ? |
22:00:16 | FromDiscord | <exelotl> it seems that syntax highlighting will still be applied in docs even if you omit it |
22:00:17 | leorize | yep |
22:00:32 | leorize | for general purpose RST, yea you need `nim` |
22:00:36 | FromDiscord | <Varriount> Well, right now it's applied. That might now always be the case. |
22:01:06 | companion_cube | nim should use readthedocs, it's where RST people go ! |
22:01:20 | leorize | we have our own docgen, no thanks :P |
22:01:45 | FromDiscord | <arnetheduck> and our own RST! |
22:02:01 | FromDiscord | <Varriount> I wish there was a slightly nicer RST... a cross between RST and markdown. |
22:02:37 | FromGitter | <awr1> hm |
22:02:43 | FromDiscord | <Varriount> On the one hand, I love the advanced formatting/markup RST allows... but things like not having line breaks is anooying. |
22:02:44 | moerm | I gave up on md and use asciidoc |
22:02:47 | FromDiscord | <Varriount> *annoying |
22:02:51 | FromGitter | <kaushalmodi> Varriount: Are you being sarcastic? |
22:02:52 | FromGitter | <awr1> i wish c2nim could skip #defines, as like a cmdline arg |
22:02:54 | leorize | Nim's RST is a cross between markdown and rst :P |
22:03:19 | FromDiscord | <Varriount> kaushalmodi: I am not. I used RST to write a user manual for a utility I wrote. |
22:03:23 | FromGitter | <kaushalmodi> *what leorize said.. I am already not liking the hybrid RST/md that Nim uses* |
22:04:05 | FromDiscord | <Varriount> RST -> Sphinx -> HTML -> wkhtmltopdf -> PDF |
22:05:03 | moerm | What an abomination! |
22:06:14 | FromDiscord | <Varriount> Nah, it worked quite well, and the CSS was easy to tweak. |
22:07:25 | FromDiscord | <exelotl> RST is quite painful sometimes, I have a table with 4 columns and some hyperlinks, it's really not nice |
22:08:22 | FromDiscord | <exelotl> it also seems quite hard to style hyperlinks because backtick does so many different things |
22:09:05 | * | liblq-dev quit (Quit: WeeChat 2.7.1) |
22:12:48 | * | natrys quit (Quit: natrys) |
22:20:59 | companion_cube | hmm, I'm trying to use `openapi` but it fails with a `undeclared routine: 'endsWith'` (eevn though strutils seems imported) |
22:21:46 | companion_cube | seems like I need to import it from where I *invoke* the macro? |
22:22:13 | leorize | sounds like a bug to me |
22:22:19 | leorize | ping disruptek |
22:22:25 | leorize | oh he went offline |
22:24:42 | * | tane_ quit (Quit: Leaving) |
22:28:05 | companion_cube | hmmm, build happens out of tree, right? |
22:28:15 | companion_cube | how do I get a .json to be available at build time? |
22:28:45 | leorize | yea, but macros should bind whatever symbols they plan to use beforehand |
22:28:52 | leorize | so you shouldn't have to import things in |
22:29:45 | companion_cube | right |
22:29:57 | companion_cube | it's weird because `strutils` is imported in the original `openapi` code |
22:34:12 | * | bunbunbunbunny joined #nim |
22:34:15 | * | bunbunbunbunny left #nim (#nim) |
22:34:31 | moerm | Have a good time, cu |
22:34:36 | * | moerm quit (Quit: Leaving) |
22:51:23 | * | opal quit (Ping timeout: 240 seconds) |
22:55:06 | FromDiscord | <Varriount> Anyone here running Windows? |
23:01:04 | FromDiscord | <KingDarBoja> Me |
23:02:39 | * | Trustable quit (Remote host closed the connection) |
23:10:55 | FromDiscord | <Varriount> Do you know how one would escape a double quotation mark in the PATH environment variable? |
23:11:59 | FromDiscord | <Varriount> @KingDarBoja So, if you want to add a path containing a semicolon to the PATH environment variable, you surround the path with quotes. But what do you do if you want a single quote in your path? |
23:13:02 | FromDiscord | <KingDarBoja> Like this? `"\'"` |
23:13:36 | FromDiscord | <KingDarBoja> Wait, I think that doesn't work |
23:13:44 | FromDiscord | <Varriount> I don't know. I looked through the Microsoft documentation, on the web, and even the source code of ReactOS/Wine, and couldn't find an answer. |
23:14:03 | FromDiscord | <Varriount> And my personal laptop (which runs Windows) is away on repair. |
23:14:28 | FromDiscord | <KingDarBoja> I think you must escape it |
23:14:57 | FromDiscord | <KingDarBoja> As it is surrounded by double quotes, and viceversa |
23:15:07 | * | opal joined #nim |
23:15:22 | FromDiscord | <KingDarBoja> -> `"some\path\'in\my\dir"` |
23:16:27 | FromDiscord | <KingDarBoja> Nvm, tested it and doesn't work |
23:17:09 | FromDiscord | <KingDarBoja> At least not on CMD, trying powershell |
23:17:36 | FromDiscord | <KingDarBoja> Oh yeah, powershell works |
23:17:49 | * | Tyresc quit (Quit: WeeChat 2.7-dev) |
23:18:14 | FromDiscord | <Varriount> You might want to test by changing the variable value through the system settings, rather than the prompt. |
23:18:37 | FromDiscord | <Varriount> Otherwise prompt parsing comes into play. >_< |
23:19:01 | FromDiscord | <Varriount> And it uses double quotes ("), not single ones (') |
23:19:32 | FromDiscord | <KingDarBoja> Not sure what you wanna do |
23:19:41 | FromDiscord | <Varriount> Hm. |
23:20:50 | FromDiscord | <KingDarBoja> https://imgur.com/CZSWiOQ |
23:21:30 | FromDiscord | <KingDarBoja> Now let me see if I can set it using the env system settings that's what I think you asking for |
23:23:00 | FromDiscord | <KingDarBoja> I set the same path and echo on my CMD |
23:23:24 | FromDiscord | <KingDarBoja> `...;D:\Programming\ts_projects\some'sample;...` |
23:23:57 | FromDiscord | <KingDarBoja> Just copied and pasted the path into the system PATH list |
23:39:52 | * | krux02_ joined #nim |
23:44:03 | * | krux02 quit (Ping timeout: 260 seconds) |
23:54:32 | krux02_ | @iffy: Regarding nim-result. I did not use that particular implementation. But generally speaking such a type is really useful. I really recommend to use it. |
23:54:53 | krux02_ | This is what rust does as well. |
23:55:07 | krux02_ | But after all it all depends on the implementation of that type and how it is used. |
23:55:31 | krux02_ | good night folks |
23:55:38 | * | krux02_ quit (Remote host closed the connection) |