00:08:57 | termer | etra, I know, it's a shit situation |
00:09:00 | termer | very few libraries support both |
00:44:50 | NimEventer | New thread by giaco: Idiomatic way to zero-copy iterface with binary bitmap array, see https://forum.nim-lang.org/t/10444 |
00:48:23 | FromDiscord | <Chronos [She/Her]> Do you think that someone is gonna register a listener more than 65535 times? |
01:20:23 | FromDiscord | <salt.die> sent a code paste, see https://play.nim-lang.org/#ix=4ECZ |
01:22:43 | FromDiscord | <Chronos [She/Her]> You'd have to handle this in whatever code the logic is being used in |
01:23:03 | FromDiscord | <Chronos [She/Her]> Assuming the values won't change though, it's as easy as just creating a proc for initialisation of it |
01:23:58 | FromDiscord | <salt.die> yeah, i figured as much |
01:27:27 | FromDiscord | <Chronos [She/Her]> Anyone have a pre-made GitHub Action for releasing Nim docs? |
01:43:36 | * | madprops quit (Quit: biourvgrt445) |
01:45:53 | * | madprops joined #nim |
01:45:54 | * | madprops quit (Changing host) |
01:45:54 | * | madprops joined #nim |
01:53:45 | FromDiscord | <Elegantbeef> Yea Nim does not have dependant typing |
01:54:44 | FromDiscord | <auxym> pretty esoteric feature, only fancy researchy FP languages have that stuff |
01:55:09 | FromDiscord | <Elegantbeef> I mean Nim technically has very limited dependant typing in it's `static T` |
01:59:24 | NimEventer | New thread by ITwrx: EZ Bkup: The easiest backup program on earth!, see https://forum.nim-lang.org/t/10445 |
02:44:39 | FromDiscord | <Chronos [She/Her]> Trying to think what else would make ny event system better |
05:05:43 | * | lucasta_ quit (Ping timeout: 244 seconds) |
08:22:49 | * | junaid_ joined #nim |
11:04:22 | * | nils` joined #nim |
11:05:08 | FromDiscord | <ezquerra> Have you guys tried the cody.ai plugin for visual studio? I just tried it by asking it a few questions about one of the example's in the new version of Araq's book and I think it did pretty well... I need to test it more but so far it seems like a good free alternative to copilot... https://media.discordapp.net/attachments/371759389889003532/1145313036668772404/image.png |
11:08:51 | FromDiscord | <Phil> I have not |
11:10:12 | FromDiscord | <Phil> So far copilot & Co were more better autocompletes than anything, which I appreciate them for definitely |
11:15:13 | FromDiscord | <amjadhd> In reply to @jviega "<@629598664452734989> got it?": No, the capacity == 0 so i == 0 which is within the bounds of `data`. |
11:56:57 | * | junaid_ quit (Remote host closed the connection) |
12:56:12 | FromDiscord | <System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4EFy |
12:59:31 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4EFz |
12:59:49 | FromDiscord | <Phil> Albeit likely a bit slower, but avoids nil |
13:00:52 | FromDiscord | <System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4EFC |
13:01:54 | FromDiscord | <Phil> I can't tell you where that type comes from, but if that's simply a Node, just make it Option[ListNode[netty.Port]] |
13:03:56 | FromDiscord | <System64 ~ Flandre Scarlet> Ah alright |
13:05:30 | FromDiscord | <naaquelo> Hi everyone, I'm trying to install Nim on Windows 11. I followed the official guide, extracted the Nim compiler and ran the `Finish.exe` file confirming Mingw GCC as my C compiler. However I'm getting this error `"Pointer size mismatch between Nim and C/C++ backend. You probably need to setup the backend compiler for target CPU."` ↵I tried googling the error but couldn't find anything |
13:26:39 | * | azimut quit (Ping timeout: 246 seconds) |
14:13:14 | Amun-Ra | naaquelo: (I'm not a windows guy) but seems like you're compiling for different cpu arch target (32-bit on 64-bit or vice versa) |
14:29:04 | * | krux02 joined #nim |
14:40:59 | FromDiscord | <Haze System (they/them)> i was thinking about the brainfuck interpreter/compiler from How I Start (<https://howistart.org/posts/nim/1/>) and was wondering, is it possible to make like a JIT compiling REPL for BF with the AST? or is that compile time only? |
14:42:48 | FromDiscord | <Phil> In reply to @hazesystem "i was thinking about": Generally Node operations are compile-time only |
14:43:16 | FromDiscord | <Phil> Depending on how you go about doing a "REPL" though you might be able to cheat |
14:43:45 | FromDiscord | <Phil> Because inim for example is not a true REPL, yet can easily be used like that.↵It's a hidden nim file that gets compiled and executed every time you write a statement |
15:28:58 | FromDiscord | <wannabelokesh> Will join later, as I'm currently into flutter for my college project of the current semester. I don't wanna feel distracted. Thank you for everything community. Love you, see you later. |
15:34:00 | FromDiscord | <Haze System (they/them)> In reply to @isofruit "Because inim for example": ah okay, that explains why getting results is relatively pretty slow, compared to a true interpreted or JIT language. is there any way other than dynamic recompiling to assembly? |
15:36:20 | FromDiscord | <Phil> sent a long message, see http://ix.io/4EGl |
15:36:47 | FromDiscord | <Phil> (edit) "http://ix.io/4EGl" => "http://ix.io/4EGm" |
15:38:19 | FromDiscord | <Haze System (they/them)> it seems like you're right. thanks for the input :) |
15:40:13 | FromDiscord | <toma400> Is there a possibility to require named tuple instead of anonymous one? For example `proc example (i: namedTuple)`? |
15:45:25 | * | junaid_ joined #nim |
15:56:41 | FromDiscord | <terrygillis> Hi, I suddenly made some mistakes writing an iterator. Write a working one before but I probably got iterator wrong in some way because this time it's not working for a simple linked list. Can I be told what is my mistake? Code here: https://play.nim-lang.org/#ix=4EGu |
15:56:51 | FromDiscord | <terrygillis> (edit) "Write" => "Wrote" |
15:57:37 | FromDiscord | <jviega> ` while not (current != nil):` |
15:57:43 | FromDiscord | <jviega> What's that not doing there? |
15:57:58 | FromDiscord | <odexine> In reply to @toma400 "Is there a possibility": i dont think so |
15:57:58 | FromDiscord | <jviega> That translates to "while current == nil" |
16:03:46 | FromDiscord | <System64 ~ Flandre Scarlet> On the right : Latest version↵On the left, nimble installed one↵Is it normal the left one is outdated?↵It's a local repo https://media.discordapp.net/attachments/371759389889003532/1145388193110306906/image.png |
16:08:52 | FromDiscord | <odexine> in what way did you install the repo if its local |
16:08:59 | FromDiscord | <odexine> i know you can, but there are many ways |
16:12:15 | FromDiscord | <System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4EGy |
16:12:24 | FromDiscord | <System64 ~ Flandre Scarlet> Oh wait https://cdn.discordapp.com/emojis/894487647219761152.webp?size=48&name=Facepalm&quality=lossless |
16:12:37 | FromDiscord | <System64 ~ Flandre Scarlet> Oh wait |
16:12:48 | FromDiscord | <System64 ~ Flandre Scarlet> I just point to the wrong folder |
16:25:13 | * | lucasta joined #nim |
16:27:15 | FromDiscord | <Phil> I kinda wish nim had some implicit init.nim file or so it looks for implicitly if your import path ends in a directory |
16:28:49 | FromDiscord | <Phil> I'd love to have a directory where individual bits and bobs are separated out into separate files and then combine them in some barrel file that you can just import.↵With nicer syntax than `import directory/init` or somesuch |
16:29:38 | * | lucasta quit (Client Quit) |
16:30:05 | FromDiscord | <Phil> I guess I could write myself a template or macro and put that in a prelude to be able to make `barrelImport some/directory` that resolves to `import some/directory/barrel` |
16:35:43 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4EGA |
16:36:32 | FromDiscord | <Phil> What do you want to optimize for for the most part? Readability? |
16:39:28 | FromDiscord | <Phil> Wait, oh wow that is not that easy for me to reason about.↵So basically "If the line is skippable, based on if it starts with KnownSkips, then skip this line "? |
16:39:42 | FromDiscord | <heysokam> In reply to @isofruit "Wait, oh wow that": yeah |
16:39:54 | FromDiscord | <terrygillis> In reply to @jviega "That translates to "while": ah thanks that’s the problem, an oversight |
16:40:26 | FromDiscord | <heysokam> basically, if the line is a `cc something something` or `gcc something something` it should not be skipped↵but it is mixed with a bunch of noise from the shell (the known skips thing) |
16:41:04 | FromDiscord | <heysokam> i could filter -in- instead of filtering out, but then the app won't crash when something unknown comes in, it would just be skipped silently |
16:41:27 | FromDiscord | <Phil> Outsource stuff into procs and write it more like guard clauses, one sec |
16:44:49 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4EGD |
16:45:52 | FromDiscord | <heysokam> I have all my projects organized like that and they can be kept really clean and neat thanks to that |
16:45:53 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4EGE |
16:46:07 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4EGE" => "https://play.nim-lang.org/#ix=4EGF" |
16:46:10 | FromDiscord | <heysokam> (edit) "https://play.nim-lang.org/#ix=4EGD" => "https://play.nim-lang.org/#ix=4EGG" |
16:46:48 | FromDiscord | <Phil> In general, if you have if-statements, 99% of the time I prefer to structure them as guard-clauses / early returns |
16:47:08 | FromDiscord | <heysokam> yeah same |
16:47:18 | FromDiscord | <heysokam> but this innerloop thing I've never encountered before |
16:48:50 | FromDiscord | <Phil> This solves it right?↵I mean your goal is less that you have 2 for-loops, it's more that you have to check 2 conditions in order to figure out whether this line is relevant for you.↵And that just so happens to require you to iterate over some other sequences |
16:49:21 | FromDiscord | <heysokam> yeah true |
16:49:41 | FromDiscord | <heysokam> i like the anyIt thing, never used it |
16:50:02 | FromDiscord | <Phil> If we're very precise, your entire "getCommandLines" is filter over input |
16:50:29 | FromDiscord | <heysokam> wdym? |
16:52:57 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4EGJ |
16:53:39 | FromDiscord | <Phil> Basically if you break it down to its fundamentals, you want to check every entry if it fulfills a condition (it is a command or a line with a command or whatever you want to define it as) and anything not passing that check gets thrown out. |
16:53:48 | FromDiscord | <Phil> (edit) "Basically if you break it down to its fundamentals, you want to check every entry ... if" added "in an iterable" |
16:54:15 | FromDiscord | <Phil> The output is a `filter` of the input |
16:54:18 | FromDiscord | <heysokam> each entry is a line, not a word. but yeah i guess |
16:54:38 | FromDiscord | <heysokam> my function is called "filternoise" so... yeah 🙂 |
16:54:53 | FromDiscord | <Phil> And Rika will chime in here as all of that is functional programming |
16:55:06 | FromDiscord | <odexine> In reply to @isofruit "I kinda wish nim": ? if you have this structure you'd achieve that tho↵src/somedir↵src/somedir.nim↵naturally if you `import somedir` it will go to somedir.nim |
16:55:09 | FromDiscord | <odexine> and you'd get your idea |
16:55:32 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4EGL |
16:56:23 | FromDiscord | <Phil> In reply to @odexine "? if you have": Ah, forgot to reply to that for sOkam! as well:↵I don't particularly like that one because the file defining the barrel is not inside of the folder that is exporting its contents.↵And in my IDE the directory and the file are not shown directly next to one another, so double meh |
16:56:23 | FromDiscord | <odexine> In reply to @isofruit "And Rika will chime": pretty much, there is no "early return" or actually usually even the "return" keyword in fp |
16:56:50 | FromDiscord | <odexine> In reply to @odexine "pretty much, there is": oh man you will prolly go a bit crazy if ever you try elixir |
16:56:56 | FromDiscord | <odexine> "whats return?" |
16:57:05 | FromDiscord | <heysokam> @Phil wait a minute, this doesn't sound right https://media.discordapp.net/attachments/371759389889003532/1145401610739142766/image.png |
16:57:32 | FromDiscord | <heysokam> "if at least one item"... i mean, its a single string? |
16:57:40 | FromDiscord | <odexine> an item in a string is a char |
16:57:51 | FromDiscord | <Phil> In reply to @heysokam "can the `hasCommand` function": Yeah, the line just gets long so I'd make a new proc and I was starting to run out of good names for that |
16:57:55 | FromDiscord | <Phil> (edit) "In reply to @heysokam "can the `hasCommand` function": Yeah, the line ... just" added "of code" |
16:58:02 | FromDiscord | <heysokam> so anyIt is going to fail everytime, or just not compile |
16:58:12 | FromDiscord | <odexine> ?? |
16:58:13 | FromDiscord | <odexine> oh |
16:58:16 | FromDiscord | <odexine> i see what you want |
16:58:18 | FromDiscord | <Phil> In reply to @heysokam "<@180601887916163073> wait a minute,": Knownskips is a seq is it not? |
16:58:27 | FromDiscord | <heysokam> In reply to @isofruit "Knownskips is a seq": could |
16:58:34 | FromDiscord | <heysokam> its an array, but its const, so doens't matter |
16:58:46 | FromDiscord | <odexine> KnownSkips.anyIt(line.startsWith(it)) # true if the line starts with anything in knownskips |
16:58:55 | FromDiscord | <heysokam> oh you mean that we are gettingthe items from the seq |
16:58:59 | FromDiscord | <Phil> so it checks if for any of the entries of KnownSkips it can find that the line starts with the KnownSkips entry |
16:59:07 | FromDiscord | <heysokam> yeah mb mb |
16:59:54 | FromDiscord | <Phil> `mapIt`, `anyIt`, `allIt`, `filterIt` are super useful for one-step transformations you need to apply to an iterable |
17:00:17 | FromDiscord | <Phil> They also have their counterparts without the `it`, you'll just have to define a full callback procedure instead of just an expression if you use those |
17:00:41 | FromDiscord | <heysokam> can the commands function be made with anyIt? |
17:00:54 | FromDiscord | <Phil> Absolutely |
17:01:03 | FromDiscord | <Phil> As stated, the line of code just gets longer than I like ^^ |
17:01:40 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4EGO |
17:02:27 | FromDiscord | <Phil> However, I think `it in line`should suffice.↵At a glance I'm not aware of any scenarios where `line.startsWith(it)` is true where `it in line` wouldn't also be true |
17:02:28 | FromDiscord | <heysokam> In reply to @isofruit "As stated, the line": you can just break the lines after `and` or `or` if it gets too long |
17:03:11 | FromDiscord | <heysokam> In reply to @isofruit "However, I think `it": ` cc arg1 arg2`↵`\ cc arg1 arg2`↵etc etc |
17:03:20 | FromDiscord | <heysokam> it really outputs a bunch of shell noise |
17:03:39 | FromDiscord | <Phil> yeah but you overall just want to check if `cc` is somewhere in there right? |
17:04:04 | FromDiscord | <Phil> So `it in line` should always output what you need, line.startsWith(it) seems superfluous |
17:04:17 | FromDiscord | <heysokam> not really, because it should stop early |
17:04:24 | FromDiscord | <heysokam> what if the line contains `noiseccnoise` |
17:05:21 | FromDiscord | <Phil> Would return true and react same as your first implementation |
17:05:25 | FromDiscord | <fwsgonzo> Hey guys, I am having some strange behavior when calling a nim function from a C trampoline. I get the right behavior when the nim callback is .cdecl., however when it isn't I get zeroes from reading from reading a global var.↵↵The nim callback is not called directly from C, instead I have an intermediary Nim function that is cdecl that then calls the non-cdecl Nim callback function. In my head this should work. |
17:05:41 | FromDiscord | <fwsgonzo> (edit) removed "from reading" |
17:06:00 | FromDiscord | <Phil> CPS and C interaction, I'm out, I have some bare grasps on that but understand none of it |
17:06:18 | FromDiscord | <Phil> (edit) "CPS and C interaction, I'm out, I have some bare grasps on that but understand none of it ... " added "on a "good enough" level" |
17:06:23 | FromDiscord | <fwsgonzo> (edit) "Hey guys, I am having some strange behavior when calling" => "sent" | "nim function from a C trampoline. I get the right behavior when the nim callback is .cdecl., however when it isn't I get zeroes from reading a global var.↵↵The nim callback is not called directly from C, instead I have an intermediary Nim function that is cdecl that then calls the non-cdecl Nim callback function. In my head this should work." => "code |
17:06:40 | FromDiscord | <fwsgonzo> (edit) "https://play.nim-lang.org/#ix=4EGQ" => "https://play.nim-lang.org/#ix=4EGR" |
17:07:08 | FromDiscord | <Phil> In reply to @heysokam "not really, because it": I would assume contains returns the second it finds the first hit |
17:07:25 | FromDiscord | <Phil> the `contains` proc I mean, which gets triggered by `x in y` |
17:07:27 | FromDiscord | <heysokam> the use of the word "trampoline" to describe a "binding" or "wrapper" sounds really foreign to me for some reason, lol |
17:07:47 | FromDiscord | <fwsgonzo> unfortunately, this is a very strange environment, and trampoline is probably for better or worse, the right word |
17:07:58 | FromDiscord | <heysokam> In reply to @isofruit "I would assume contains": yeah that's the idea |
17:08:15 | FromDiscord | <heysokam> In reply to @fwsgonzo "unfortunately, this is a": yeah not judging, just saying it sounds foreign |
17:08:50 | FromDiscord | <Phil> If that's the case then `x in y` still does everything that `x.startsWith(y)` does for you 😛↵Though alternatively, if you can assume cc is ALWAYS at the start of the string (barring whitespaces), then you can just trim the starts of the line |
17:10:22 | FromDiscord | <heysokam> In reply to @isofruit "If that's the case": that'd be another option, but im so sick of this project. i just want to get it done and move on forever 😔↵so i just want something that works and if it fails it will scream at me in the compiler in the future if its needed (instead of silently omitting info) |
17:11:28 | FromDiscord | <Phil> In reply to @heysokam "that'd be another option,": Okay, for the sake of correctness so that this expresses exactly what you want:↵Can you assume that a command should always be the first thing that occurs after all whitespaces from the starts are removed |
17:11:33 | FromDiscord | <Phil> (edit) "removed" => "removed?" |
17:11:58 | FromDiscord | <heysokam> I'm trying to clean up 20+years of crap piled up in an old makefile, and hopefully never have to touch it again ever↵it's taking me months of my life to get rid of it, lol. that tells you how crusty it is |
17:12:07 | FromDiscord | <heysokam> In reply to @isofruit "Okay, for the sake": yeah definitely |
17:12:23 | FromDiscord | <heysokam> problem is I don't know how to trim the whitespaces from the start |
17:13:20 | FromDiscord | <Phil> strip is strutils |
17:13:20 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4EGT |
17:13:30 | FromDiscord | <Phil> https://nim-lang.org/docs/strbasics.html#strip%2Cstring%2Cset%5Bchar%5D |
17:13:54 | FromDiscord | <heysokam> i had no idea that exists, lol |
17:14:00 | FromDiscord | <Phil> This way, you won't run into any bugs with weird as lines that have `cc`somewhere in the middle |
17:14:03 | FromDiscord | <heysokam> would have saved me a couple of hours |
17:14:07 | FromDiscord | <heysokam> (edit) "would have saved me a couple of hours ... " added "of parsing logic" |
17:14:16 | FromDiscord | <heysokam> In reply to @isofruit "This way, you won't": yeah exactly |
17:14:23 | FromDiscord | <heysokam> oh, but wait |
17:14:29 | FromDiscord | <Phil> (edit) "as" => "ass" |
17:14:38 | FromDiscord | <heysokam> some of the commands start with `/something/cc` 😔 |
17:14:54 | FromDiscord | <heysokam> i think that's why i wrote that second switch |
17:14:57 | FromDiscord | <Phil> In that case can you guarantee that after the cc is a whitespace? |
17:15:05 | FromDiscord | <heysokam> for sure |
17:15:11 | FromDiscord | <heysokam> that's definitely a guarantee |
17:15:42 | FromDiscord | <heysokam> I guess i could split into words by whitespace if the startswith check fails 🤔 |
17:16:20 | FromDiscord | <Hamid_Bluri> is there anyway to redefine a specific overload of a function? 😕 ↵https://github.com/treeform/jsony/issues/77 |
17:17:16 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4EGU |
17:17:59 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4EGV |
17:19:09 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4EGW |
17:19:13 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4EGW" => "https://play.nim-lang.org/#ix=4EGX" |
17:21:19 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4EGY |
17:21:40 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4EGZ |
17:22:40 | FromDiscord | <Phil> At least do an explicit return false after the for loop 😛 |
17:23:15 | FromDiscord | <heysokam> i think its evident in this case 🤷♂️ |
17:23:25 | FromDiscord | <heysokam> but i see your point. normally i try to be explicit too |
17:24:01 | FromDiscord | <odexine> In reply to @isofruit "If you want this": why have the return? remove the return here |
17:24:13 | FromDiscord | <odexine> what , did you forget about expression return |
17:24:22 | FromDiscord | <Phil> No, I just am not a fan of it |
17:24:26 | FromDiscord | <odexine> what |
17:24:42 | FromDiscord | <odexine> you will legitimately die if ever you use an fp |
17:24:43 | FromDiscord | <Phil> Unless it's a one-line proc my brain just doesn't immediately recognize expression returns as the return of the proc |
17:25:13 | FromDiscord | <Phil> Or rather I find it hard to find when skimming through an if-construct like this |
17:25:52 | FromDiscord | <heysokam> 👆 yeah same, although not as strongly |
17:25:55 | FromDiscord | <Phil> In reply to @odexine "you will legitimately die": It's not like it kills me, I just prefer explicit returns |
17:26:33 | FromDiscord | <Phil> Expression returns can be prefectly fine as well, I'd just write the code different in those cases to make it more obvious where the return is |
17:26:34 | FromDiscord | <odexine> In reply to @isofruit "It's not like it": you wont know until you see honestly, it takes a bit of rewiring to read code that never has a "return" |
17:26:50 | FromDiscord | <heysokam> as in i don't think its needed to say that this is a discord message when we are writing in discord↵That level of explicit is a bit much for me. but the "im writing a message" level feels fine, even though its obvious it could also not be the case |
17:27:08 | FromDiscord | <Phil> Or rather: The fact that I'm okay with expression returns stems from my 3 or so months I spent in rust where I used it a lot. |
17:27:30 | FromDiscord | <odexine> rust is relatively heavily fp for a non-fp language |
17:27:53 | FromDiscord | <heysokam> short functions always return, and they are clearly there, so if all the checks have true in them, then it feels fine to skip the extra return false |
17:27:54 | FromDiscord | <Phil> I have since in nim found myself gravitating more towards return there, so I can deal with both, in nim return just groks with me more |
17:28:43 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4EH1 |
17:29:10 | FromDiscord | <odexine> perhaps ive been too far into fp indeed as i never really ever want to write return |
17:29:15 | FromDiscord | <Phil> In reply to @heysokam "short functions always return,": Fair, I personally have a hard rule for that one but I agree that it's obvious enough in general |
17:29:25 | FromDiscord | <Phil> (edit) "In reply to @heysokam "short functions always return,": Fair, I personally have a hard rule for that one ... but" added "for myself" |
17:30:22 | FromDiscord | <Phil> I mean if the expressions that return were to get colored in by the IDE in a specific way I'd be perfectly happy with it 😛 |
17:30:37 | FromDiscord | <Phil> It's all about that I want returns to catch my eyey |
17:30:40 | FromDiscord | <Phil> (edit) "eyey" => "eye" |
17:30:44 | FromDiscord | <heysokam> makes sense |
17:31:22 | FromDiscord | <Phil> In reply to @hamidb80 "is there anyway to": That sounds like a case for @treeform |
17:32:11 | FromDiscord | <odexine> In reply to @isofruit "I mean if the": well if everything returns then the idea is muddied |
17:32:47 | FromDiscord | <Phil> Because I am not aware of one.↵If you already have a specific function and given that in jsony it's all static dispatch, the only way you can get in there and do stuff is if the hook that is pre-defined is a generic or something, in that case your specific hook would take precedence |
17:33:35 | FromDiscord | <Fabio Nascimento> As an older pascal programmer here, I would start the function with guard "result = false"... |
17:34:15 | FromDiscord | <Phil> ... wha? |
17:35:02 | FromDiscord | <odexine> what do you mean wha? |
17:35:21 | FromDiscord | <Phil> Like, what does that even do? |
17:35:36 | FromDiscord | <Phil> Missed the t |
17:35:44 | FromDiscord | <odexine> i know |
17:35:59 | FromDiscord | <odexine> the implication is that theyd use result instead of expr/return i assume? |
17:37:40 | FromDiscord | <Phil> Like does pascal also have the implicit result variable or sth? |
17:38:14 | FromDiscord | <odexine> yes i believe nim took it from there |
17:38:41 | FromDiscord | <Phil> That answers one of my questions, the second one: Why would that be valid when result is not a bool type? |
17:38:48 | FromDiscord | <Toli> Nim is so flexible, that you got result and/or return and an implicit return could make rust,c/cpp user's head spin some times... |
17:39:12 | FromDiscord | <Phil> In reply to @Toli "Nim is so flexible,": Entirely fair |
17:39:53 | FromDiscord | <Phil> Ironically I've found myself using all 3.↵Return most of the times, Implicit returns of expressions when I have 1-line procs, and result often when I have short procs where I bould up a seq or string |
17:40:10 | FromDiscord | <Phil> (edit) "bould" => "build" |
17:40:19 | FromDiscord | <odexine> In reply to @isofruit "That answers one of": it wont, the implication is also that you guys were talking about bool types... |
17:40:23 | FromDiscord | <odexine> (edit) "types..." => "typed returns..." |
17:40:28 | FromDiscord | <Phil> ohhhhhhhhh |
17:40:36 | FromDiscord | <odexine> phil can you read today |
17:41:28 | FromDiscord | <Phil> I could never read Rika, I use the sounds of the discord notification to figure out what text was sent and then face-roll my keyboard in the hopes that a decent string of letters comes out |
17:42:36 | FromDiscord | <Phil> Sometimes solar fluctuations interferer with the electrons in my device and the notification comes out sounding slightly off, leading to communications errors.↵It's definitely that and nothing else |
17:42:38 | FromDiscord | <odexine> sent a code paste, see https://play.nim-lang.org/#ix=4EH2 |
17:42:40 | FromDiscord | <odexine> no i do not know what that returns |
17:42:52 | FromDiscord | <odexine> (edit) "returns" => "compiles to" |
17:42:52 | FromDiscord | <odexine> (edit) "https://play.nim-lang.org/#ix=4EH2" => "https://play.nim-lang.org/#ix=4EH3" |
17:44:30 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4EH4 |
17:46:52 | FromDiscord | <heysokam> @Phil it broke in a big way, trying to be too smart with the anyIt and such 😔 |
17:47:02 | FromDiscord | <heysokam> nothing ever was populated lol |
17:47:02 | FromDiscord | <Phil> hm? |
17:47:10 | NimEventer | New Nimble package! shopifyextractor - Shopify ecommerces data in a instant, see https://github.com/thisago/shopifyextractor |
17:47:14 | FromDiscord | <heysokam> idk why, can't say more, just that the list was empty |
17:47:31 | FromDiscord | <Phil> Can you provide an input list for an example? |
17:47:47 | FromDiscord | <heysokam> the clean or the dirty version? |
17:47:57 | FromDiscord | <Phil> Whatever you iterate over |
17:48:03 | FromDiscord | <Phil> The hardest version |
17:48:46 | * | gst joined #nim |
17:49:39 | FromDiscord | <heysokam> https://media.discordapp.net/attachments/371759389889003532/1145414837422260436/example.sh https://media.discordapp.net/attachments/371759389889003532/1145414837896220732/t.sh |
17:49:54 | FromDiscord | <heysokam> the second one is hand-cleaned |
17:50:00 | FromDiscord | <System64 ~ Flandre Scarlet> My server crashes ↵Reason? None |
17:50:42 | FromDiscord | <heysokam> In reply to @isofruit "The hardest version": i haven't even created the hardest version, because im afraid of filtering the inputs correctly 🙈 |
17:51:49 | FromDiscord | <Phil> Let me check |
17:51:51 | FromDiscord | <odexine> nim 2: filter harder |
17:52:47 | FromDiscord | <heysokam> sent a long message, see http://ix.io/4EH9 |
17:52:50 | * | gst quit (Client Quit) |
17:53:08 | * | gst joined #nim |
17:54:31 | gst | hello, can anyone help me understand why this code fails to compile; https://play.nim-lang.org/#ix=4EH8 |
17:54:35 | FromDiscord | <odexine> whats wrong with just startswith again? |
17:55:02 | FromDiscord | <heysokam> In reply to @odexine "whats wrong with just": well that I didn't know about `strip()` |
17:55:22 | FromDiscord | <heysokam> and that sometimes it starts with `/` not with the command word |
17:56:50 | FromDiscord | <odexine> In reply to @heysokam "and that sometimes it": why would it start with / |
17:58:16 | FromDiscord | <odexine> In reply to @gst "hello, can anyone help": feels like a compiler bug |
17:59:30 | FromDiscord | <heysokam> In reply to @odexine "why would it start": `/usr/bin/osxcross arg1 arg2` is a valid compiler command |
18:00:06 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4EHa |
18:00:28 | FromDiscord | <Phil> Before I get told to use readLines: That returns the entire file as a single string and I can't be arsed to look for splitting things up agin |
18:00:39 | FromDiscord | <Phil> (edit) "things up agin" => "line by line" |
18:01:14 | FromDiscord | <odexine> In reply to @heysokam "`/usr/bin/osxcross arg1 arg2` is": `line.split(' ', 1)[0].endsWith(#[cmd]#)` |
18:01:20 | FromDiscord | <Phil> Anyway, returns 78/301 lines |
18:01:33 | FromDiscord | <heysokam> In reply to @odexine "`line.split(' ', 1)[0].endsWith(#[cmd]#)`": i don't even understand what that does |
18:01:38 | FromDiscord | <griffith1deadly> In reply to @sys64 "My server crashes ": use gdb to debugging crashes |
18:02:01 | FromDiscord | <odexine> In reply to @heysokam "i don't even understand": get contents until first space, see if ends with command |
18:02:32 | FromDiscord | <odexine> matches `<anything but space or nothing><command><space>...` |
18:02:46 | FromDiscord | <odexine> so `cc ...` or `/c/c/awdjhaqojwrfm/cc ...` will work |
18:02:59 | FromDiscord | <odexine> better use parseutils |
18:03:05 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4EHd |
18:03:07 | FromDiscord | <odexine> yes |
18:03:09 | FromDiscord | <heysokam> ?? |
18:03:16 | FromDiscord | <odexine> the command name |
18:03:17 | FromDiscord | <heysokam> what is `#[cmd]#` even |
18:03:34 | FromDiscord | <odexine> #[]# block commendt↵cmd comment contents |
18:03:35 | FromDiscord | <odexine> (edit) "commendt↵cmd" => "comment↵cmd" |
18:04:04 | FromDiscord | <heysokam> that syntax inline is giga confusing, thought you were pattern matching in a weird way or something |
18:04:11 | FromDiscord | <odexine> lol |
18:04:28 | FromDiscord | <odexine> block comments arent used often ig |
18:04:38 | FromDiscord | <heysokam> definitely not inline lol |
18:04:49 | FromDiscord | <odexine> i use them inline sometimes |
18:04:54 | FromDiscord | <heysokam> seen them in C, though, it just didn't cross my mind |
18:05:36 | FromDiscord | <heysokam> why the `1` btw? |
18:06:14 | FromDiscord | <Phil> You only want to split once |
18:06:18 | FromDiscord | <Phil> To get the first segment |
18:06:42 | FromDiscord | <heysokam> In reply to @isofruit "Anyway, returns 78/301 lines": honestly, i think i really need to get rid of filtering out explictely, and start filtering in. because this parser is a pain otherwise |
18:07:01 | FromDiscord | <heysokam> In reply to @isofruit "To get the first": why doing `[0]` then, if its only split once? |
18:07:03 | FromDiscord | <Phil> In reply to @heysokam "honestly, i think i": filter in `.`? |
18:07:16 | FromDiscord | <Phil> In reply to @heysokam "why doing `[0]` then,": Because that is the first segment of the line |
18:07:18 | FromDiscord | <odexine> sent a code paste, see https://play.nim-lang.org/#ix=4EHe |
18:07:30 | FromDiscord | <Phil> which is the part of the line that is either cc, gcc or /bla/cc |
18:07:53 | FromDiscord | <heysokam> In reply to @isofruit "filter in `.`?": i mean getting rid of the noise by targeting the cc commands -only-, instead of trying to sort everything explictely |
18:08:32 | FromDiscord | <Phil> But... like the 78/301 worked... |
18:08:45 | FromDiscord | <heysokam> yeah, that wasnt' the hard case |
18:09:00 | FromDiscord | <heysokam> the hard one I dealt with before... and made it work... but omg |
18:09:08 | FromDiscord | <Phil> Well then hand me the hard case becasue t.sh was the easier of the two so I tried example.sh 😛 |
18:09:30 | FromDiscord | <heysokam> In reply to @isofruit "Well then hand me": yeah problem is I don't even know how to generate it anymore |
18:09:35 | FromDiscord | <Phil> Bwahahahahahaa |
18:09:50 | FromDiscord | <Phil> I know that problem when you just want to be rid of shit xD |
18:10:12 | FromDiscord | <heysokam> basically, you would get a list of like 10-15 separate make commands, so that everything is built, and then parse -that- 😄 |
18:10:31 | FromDiscord | <heysokam> as one giant sh file |
18:10:41 | FromDiscord | <heysokam> (edit) "file" => "file, that builds all targets for all 3 systems" |
18:10:52 | FromDiscord | <Phil> I mean the only bug I could possibly think of is if you have super-long single line commands that use `;` to separate multiple commands |
18:10:56 | FromDiscord | <Phil> That one would currently not get picked up |
18:11:08 | FromDiscord | <heysokam> ah true |
18:11:24 | FromDiscord | <heysokam> i don't think `make -n` outputs ocmmands like that though |
18:11:29 | FromDiscord | <heysokam> (edit) "ocmmands" => "commands" |
18:11:49 | FromDiscord | <Phil> I mean based on the requirements provided, yeah make -n would currently get filtered out 😛 |
18:11:58 | FromDiscord | <Phil> If you want them to stay, put them in KnownCommands |
18:12:08 | FromDiscord | <heysokam> no i mean make -n is the one that generates this lists |
18:12:13 | FromDiscord | <heysokam> (edit) "this" => "these" |
18:13:31 | FromDiscord | <Phil> Ohhh that way you mean it↵Well in that case you should be safe |
18:13:54 | FromDiscord | <heysokam> also, side note, how would you deal with the case of lines being sent with `\` escape sequences, and then the next one being just a part of the same line? |
18:14:25 | FromDiscord | <Phil> Within the current task, as in checking for cc/gcc at the start? |
18:14:36 | FromDiscord | <heysokam> no, before giving that task the inputs |
18:14:56 | FromDiscord | <Phil> Oh multi line commands |
18:15:07 | FromDiscord | <odexine> haha, what are you make -n anyway |
18:15:09 | FromDiscord | <odexine> sorry |
18:15:14 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4EHg |
18:15:22 | FromDiscord | <Phil> The current code doesn't deal with it essentially, or rather it does not do it well |
18:15:55 | FromDiscord | <heysokam> In reply to @odexine "haha, what are you": good o -n e 😄 |
18:16:27 | FromDiscord | <Phil> As for this, hmmm I'd likely concat lines together that have newlines |
18:16:44 | FromDiscord | <heysokam> yeah, but how is the question 🙂 |
18:22:04 | FromDiscord | <System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4EHj |
18:25:43 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4EHk |
18:27:03 | FromDiscord | <Phil> `isPartOfMultiLineCommand` should of course also check that you're not running out of the bounds of `lines` or return false if nextLineIndex is out of bounds |
18:27:10 | FromDiscord | <Phil> (edit) "or" => "and" |
18:27:35 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4EHk" => "https://play.nim-lang.org/#ix=4EHl" |
18:28:02 | FromDiscord | <Phil> Also requires an import of std/strformat and isLastLine should just be a simple index == lines.high |
18:29:17 | FromDiscord | <Phil> It's not uber clean, the clean version would be to iterate by index imo, but I am not aware of a way in nim to do loops with iterators whose position you can mutate |
18:29:24 | FromDiscord | <Phil> (edit) "position" => "value" |
18:29:49 | FromDiscord | <Phil> (edit) removed "with iterators" | "value" => "iteration-index" |
18:30:48 | FromDiscord | <Phil> In reply to @heysokam "yeah, but how is": Does the above look doable? |
18:31:25 | FromDiscord | <heysokam> In reply to @isofruit "Does the above look": reading |
18:32:20 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4EHm |
18:33:00 | FromDiscord | <heysokam> im generating the hardcase to see if its manageable. even if regex or strtabs is required for it |
18:33:53 | FromDiscord | <Phil> How I know I have a couple nimsuggest threads running:↵My CPU in powersave mode starts running near 50°C again |
18:34:11 | FromDiscord | <heysokam> yeah true 😔 |
18:34:35 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @griffith1deadly "use gdb to debugging": The worst thing that can ever happen https://media.discordapp.net/attachments/371759389889003532/1145426149007179969/image.png |
18:34:43 | FromDiscord | <Phil> erroneous nimsuggest threads |
18:34:54 | FromDiscord | <Phil> luckuly `killall nimsuggest` exits those quickly |
18:35:00 | FromDiscord | <Phil> (edit) "luckuly" => "luckily" |
18:35:51 | FromDiscord | <griffith1deadly> In reply to @sys64 "The worst thing that": are u compiling with --debugger:native? |
18:37:05 | FromDiscord | <heysokam> In reply to @sys64 "The worst thing that": `bt` inside gdb |
18:38:25 | FromDiscord | <heysokam> also `tui enable` will probably make you stop seeing gdb as a monster |
18:44:56 | FromDiscord | <.maverk> is ``of`` considered an operator in nim ? |
18:46:53 | arkanoid | could you please help me understand why the following piece of code double free only if echo is called? https://play.nim-lang.org/#ix=4EHq |
18:47:05 | * | ntat joined #nim |
18:50:41 | FromDiscord | <Phil> 🏃♂️ me running away from that particular problem |
18:51:55 | FromDiscord | <demotomohiro> @Arkanoid I guess, if you didn't echo `foo2`, `foo2` become a variable initialized but not read. So it is optimized away and double free doesn't happen. |
18:59:31 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @griffith1deadly "are u compiling with": Oh, lemme do that |
19:04:16 | FromDiscord | <heysokam> @Phil https://media.discordapp.net/attachments/371759389889003532/1145433616499867668/hardcase.sh |
19:06:26 | * | junaid_ quit (Remote host closed the connection) |
19:06:39 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @griffith1deadly "are u compiling with": Same result |
19:08:11 | arkanoid | demotomohiro, it makes sense, thanks. But how can I stop this from happening? I though that `var foo2 = foo` would be a copy, and so an error due to `=copy` being and `{.error.}` |
19:09:13 | FromDiscord | <heysokam> In reply to @sys64 "Same result": did you launch with `nim-gdb` or just `gdb`? |
19:09:32 | arkanoid | Foo is a stack object, so var foo2 = foo shold be a copy, and then an error |
19:13:50 | FromDiscord | <.maverk> nim doesn't have ``union`` ? |
19:15:41 | FromDiscord | <heysokam> In reply to @.maverk "nim doesn't have ``union``": https://github.com/alaviss/union |
19:20:21 | FromDiscord | <demotomohiro> @Arkanoid It seems `var foo2 = foo` doesn't copy but does sink or rename `foo` with `foo2`.↵Because I got compile error "Error: '=copy' is not available" if `echo foo[0]` is called after `var foo2 = foo`. |
19:21:59 | FromDiscord | <demotomohiro> https://nim-lang.org/docs/destructors.html#move-semantics↵> A "move" can be regarded as an optimized copy operation. If the source of the copy operation is not used afterward, the copy can be replaced by a move. |
19:24:08 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @heysokam "did you launch with": just gdb |
19:25:20 | FromDiscord | <heysokam> In reply to @sys64 "just gdb": need the nim version, otherwise symbols are not human readable very much |
19:25:39 | FromDiscord | <System64 ~ Flandre Scarlet> Oh alright |
19:25:57 | FromDiscord | <System64 ~ Flandre Scarlet> Where can I find it? |
19:27:27 | FromDiscord | <Elegantbeef> Arkanoid https://nim-lang.org/docs/destructors.html#cursor-inference-slash-copy-elision might explain why that's valid |
19:27:30 | FromDiscord | <Elegantbeef> As to the double free.... |
19:28:33 | FromDiscord | <System64 ~ Flandre Scarlet> The weirdest thing is it doesn't segfault directly, weird! |
19:38:46 | * | junaid_ joined #nim |
19:39:57 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4EHF |
19:40:47 | FromDiscord | <odexine> lol |
19:43:15 | * | junaid_ quit (Remote host closed the connection) |
19:57:48 | * | xet7 quit (Read error: Connection reset by peer) |
20:02:26 | FromDiscord | <odexine> does nim have a modern Path-y way to walk directories |
20:10:41 | FromDiscord | <Elegantbeef> Do you mean https://nim-lang.org/docs/dirs.html#walkDir.i%2CPath ? |
20:14:06 | FromDiscord | <odexine> i did figure it out thanks but the docs never point at it, at least os does not |
20:14:11 | FromDiscord | <odexine> only files and paths |
20:14:24 | FromDiscord | <odexine> sure naturally one would think a dirs would then also exist but eh |
20:15:17 | FromDiscord | <treeform> sent a code paste, see https://play.nim-lang.org/#ix=4EHS |
20:15:51 | FromDiscord | <Elegantbeef> std/os does not use `Path` afaik |
20:16:12 | FromDiscord | <that_dude.> In reply to @treeform "I want to use": If it's already in the Std, can't you just import it directly? |
20:16:12 | FromDiscord | <Elegantbeef> `{importc, nodecl.}` perhaps |
20:16:13 | FromDiscord | <odexine> In reply to @Elegantbeef "std/os does not use": yes but it points at paths and files as a "high level operations for paths and files" thing |
20:16:18 | FromDiscord | <odexine> it should as well for dirs |
20:16:45 | FromDiscord | <that_dude.> I thought there is a header Pragma you can use with importc |
20:16:47 | FromDiscord | <Elegantbeef> `_ _` |
20:17:01 | FromDiscord | <Elegantbeef> The header pragma is only for adding a `#include` |
20:17:10 | FromDiscord | <Elegantbeef> It does not name space a procedure |
20:18:06 | FromDiscord | <Elegantbeef> Rika that's a hangman board in response to your "it should as well for dirs", you can figure out what it means 😄 |
20:18:11 | FromDiscord | <demotomohiro> In reply to @treeform "I want to use": How about to rename to `proc cqsort` and change importc to `{.importc: "qsort".}`. |
20:18:26 | FromDiscord | <Elegantbeef> The issue is the C side |
20:18:44 | FromDiscord | <Elegantbeef> `importc` disables mangling so the same result will happen |
20:19:03 | FromDiscord | <odexine> In reply to @Elegantbeef "Rika that's a hangman": nah i dont feel like it :baqua: |
20:19:09 | FromDiscord | <odexine> i'll pr later |
20:21:09 | FromDiscord | <Elegantbeef> Very few times one can guess hangman without any letters |
20:21:53 | FromDiscord | <treeform> @that_dude.@ElegantBeouf @demotomohiro I can't use Nim's sort because all I have are pointers, I can't use qsort from c because I can't produce `int ()(const void , const void )` type. I think I have figured it out though. I copy the data from the ptr to a tmp seq, use Nim's sort, then copy it back to ptr. Slow, but it works for now. Thank you! |
20:23:31 | arkanoid | demotomohiro, elegantbeef, thanks! It's clear now that copy manifest only on next ops |
20:24:58 | FromDiscord | <that_dude.> Isn't that just function that takes two void pointers as parameters and returns an int? Sorry I haven't worked with c/++ in a long time |
20:26:24 | FromDiscord | <treeform> yes it is |
20:26:34 | FromDiscord | <treeform> but I can't make a C function in nim that has that seg |
20:27:14 | FromDiscord | <djazz> anti const squad |
20:27:58 | FromDiscord | <demotomohiro> sent a code paste, see https://paste.rs/EaoKt |
20:28:38 | FromDiscord | <treeform> its compatible, but it wants that type specifically |
20:28:43 | FromDiscord | <djazz> now how do you convert it to nim pointer inside the sort callback? |
20:28:49 | FromDiscord | <djazz> without C++ complaining |
20:29:45 | FromDiscord | <treeform> sent a code paste, see https://play.nim-lang.org/#ix=4EHY |
20:30:22 | FromDiscord | <treeform> Eventually I hope to make probindex not be a poitner but be a normal seq. So its on the way to a happy path. |
20:30:47 | FromDiscord | <System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4EHZ |
20:31:55 | FromDiscord | <that_dude.> Can't read the language, but it looks like a permission error. Is it already in use? Or is that even in the valid range of ports? |
20:32:05 | FromDiscord | <demotomohiro> @treeform By the way, did you read https://github.com/nim-lang/Nim/issues/22352#issuecomment-1693613557 |
20:32:10 | * | ntat quit (Quit: leaving) |
20:32:18 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @that_dude. "Can't read the language,": yeah it's in the valid range↵How can I know which program uses this port? |
20:33:20 | FromDiscord | <djazz> lsof? |
20:34:50 | FromDiscord | <demotomohiro> netstat? |
20:35:18 | FromDiscord | <treeform> @demotomohiro sorry I did not see that yet, its probably in my github emails. |
20:36:04 | FromDiscord | <that_dude.> Tbh I would just try a different port. It's easier. I generally do my testing in the 20k-30k range |
20:36:28 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @demotomohiro "netstat?": The port is not even used↵Even weirder, it just happened since I rebooted my computer |
20:37:22 | FromDiscord | <treeform> `Pointer size mismatch between Nim and C/C++ backend. You probably need to setup the backend compiler for target CPU.` Is a great error message thank you for adding! Hopefully will help people as they run into it. |
20:39:45 | FromDiscord | <demotomohiro> In reply to @sys64 "The port is not": Maybe you dont have the permission to use that ip and port? |
20:41:44 | FromDiscord | <demotomohiro> In reply to @treeform "`Pointer size mismatch between": I hope so. But we might need to see if newcomer still get confused from the error message. |
20:43:12 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @demotomohiro "Maybe you dont have": Alright so I rebooted my computer again and it works↵Windows cringe forever |
20:43:12 | FromDiscord | <treeform> Yeah maybe saying some thing about 64bit and 32bit I am not sure if new people know that its related to pointer size... but maybe they do, I just don't know. |
20:53:59 | * | oisota5 joined #nim |
20:54:11 | * | om3ga_ joined #nim |
20:54:55 | * | madprops_ joined #nim |
20:56:14 | * | emery joined #nim |
21:01:07 | FromDiscord | <System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4EI8 |
21:02:07 | * | madprops quit (*.net *.split) |
21:02:07 | * | oisota quit (*.net *.split) |
21:02:07 | * | ehmry quit (*.net *.split) |
21:02:07 | * | om3ga quit (*.net *.split) |
21:02:07 | * | NimEventer quit (*.net *.split) |
21:02:07 | * | oisota5 is now known as oisota |
21:02:22 | FromDiscord | <griffith1deadly> sent a code paste, see https://play.nim-lang.org/#ix=4EIa |
21:02:45 | FromDiscord | <System64 ~ Flandre Scarlet> Very nice |
21:02:47 | * | NimEventer joined #nim |
21:04:41 | * | gst quit (Ping timeout: 246 seconds) |
21:06:03 | FromDiscord | <.maverk> how is the ``ptr`` datatype suppose to work ? |
21:06:41 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @.maverk "how is the ``ptr``": It's a pointer↵Do you know what a pointer is? |
21:07:11 | FromDiscord | <.maverk> In reply to @sys64 "It's a pointer Do": in c ↵↵int test = &struct or anything |
21:07:28 | FromDiscord | <System64 ~ Flandre Scarlet> Yeah so it's just a pointer |
21:07:40 | FromDiscord | <.maverk> can you give an example |
21:07:41 | FromDiscord | <System64 ~ Flandre Scarlet> ptr int is a pointer to an int |
21:07:52 | FromDiscord | <.maverk> In reply to @sys64 "ptr int is a": int only ? |
21:09:39 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4EId |
21:10:07 | FromDiscord | <System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4EIe |
21:10:18 | FromDiscord | <System64 ~ Flandre Scarlet> (edit) "https://play.nim-lang.org/#ix=4EIe" => "https://play.nim-lang.org/#ix=4EIf" |
21:10:27 | FromDiscord | <.maverk> is not the dereference ? |
21:11:01 | FromDiscord | <odexine> No |
21:11:02 | FromDiscord | <demotomohiro> In Nim, `[]` is dereference. |
21:11:16 | FromDiscord | <.maverk> In reply to @demotomohiro "In Nim, `[]` is": that is why |
21:11:19 | FromDiscord | <.maverk> i got confused |
21:11:40 | FromDiscord | <Phil> is exporting a symbol |
21:11:44 | FromDiscord | <Phil> (edit) "" => "\" |
21:11:45 | FromDiscord | <demotomohiro> Nim and C are different language. |
21:12:01 | FromDiscord | <.maverk> i see |
21:12:11 | FromDiscord | <.maverk> In reply to @isofruit "\* is exporting a": what do you mean by exporting bro ? |
21:12:12 | FromDiscord | <System64 ~ Flandre Scarlet> in fact, [] makes sense |
21:12:24 | FromDiscord | <.maverk> In reply to @sys64 "in fact, [] makes": that's right |
21:12:34 | FromDiscord | <System64 ~ Flandre Scarlet> and in C, [] is also dereference |
21:12:35 | FromDiscord | <.maverk> in c [] returns the memory by default |
21:12:45 | FromDiscord | <.maverk> char name[] ↵↵printf name[] |
21:12:58 | FromDiscord | <System64 ~ Flandre Scarlet> arrays are just pointers in C |
21:13:08 | FromDiscord | <raynei486> In reply to @sys64 "and in C, []": ? |
21:13:09 | FromDiscord | <.maverk> yeah i now |
21:13:17 | FromDiscord | <.maverk> (edit) "now" => "know" |
21:14:49 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @raynei486 "?": if you allocate an array in C, it's a pointer↵So myArray[10] is dereferencing an address |
21:15:03 | FromDiscord | <raynei486> oh nvm |
21:15:16 | FromDiscord | <raynei486> I forgot `[]` was nice way to dereference |
21:15:33 | FromDiscord | <raynei486> I love my `2[arr]` to get the third element |
21:15:57 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4EIg |
21:16:32 | FromDiscord | <.maverk> sent a code paste, see https://play.nim-lang.org/#ix=4EIh |
21:16:51 | FromDiscord | <Phil> You can also just set yourself up with a playground project with 2 files and try to compile it |
21:17:18 | FromDiscord | <.maverk> i will try |
21:22:52 | * | azimut joined #nim |
21:29:02 | FromDiscord | <.maverk> sent a code paste, see https://play.nim-lang.org/#ix=4EIj |
21:29:45 | FromDiscord | <heysokam> In reply to @.maverk "is * not the": Dereferencing a pointer means `getting the contents of the box pointed by this call number`↵Nim represents that with `thing[]`which could be read as `the box of thing` |
21:30:18 | FromDiscord | <heysokam> so it makes a lot of sense in reality, C might be standard but does things in really weird ways |
21:30:49 | FromDiscord | <.maverk> In reply to @heysokam "so it makes a": yeah |
21:31:19 | FromDiscord | <heysokam> and ptr is the word associated with the pointer, no weird symbol that has triple and quadruple meanings depending on context |
21:31:27 | FromDiscord | <heysokam> (edit) "ptr" => "`ptr`" |
21:32:01 | FromDiscord | <Elegantbeef> Range is not a slice |
21:32:18 | FromDiscord | <Elegantbeef> `var slic = 1..10` |
21:32:19 | FromDiscord | <heysokam> although, you will -very- rarely need actual pointers in nim. references do the same (unless you are interoperating with C, but that's on the C side) |
21:32:42 | FromDiscord | <Elegantbeef> Luckily references are interoperable with pointers depending on what the C code is doing |
21:32:58 | FromDiscord | <.maverk> In reply to @Elegantbeef "Range is not a": what do you mean ? |
21:33:04 | FromDiscord | <heysokam> In reply to @Elegantbeef "Luckily references are interoperable": that's news, didn't know. how does that work? |
21:33:06 | FromDiscord | <.maverk> what about the ``range`` datatype ? |
21:33:23 | FromDiscord | <Elegantbeef> A range is a subrange type it only allows specific ordinal values |
21:33:31 | FromDiscord | <heysokam> In reply to @.maverk "what about the ``range``": slices and ranges are different things. you were trying to assign one to the other |
21:33:33 | FromDiscord | <Elegantbeef> A slice is a start/end |
21:33:47 | FromDiscord | <Elegantbeef> References just pointers |
21:33:59 | FromDiscord | <Elegantbeef> So if you need a `T` in C and have a `ref T` in Nim you can just send it |
21:34:03 | FromDiscord | <.maverk> what am i suppose to do now ? |
21:34:07 | FromDiscord | <.maverk> to make it work |
21:34:16 | FromDiscord | <Elegantbeef> I showed you what to do |
21:34:25 | FromDiscord | <.maverk> sent a code paste, see https://play.nim-lang.org/#ix=4EIk |
21:34:32 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/tut1.html |
21:34:39 | FromDiscord | <Elegantbeef> RTFM if you arent going to listen to me |
21:35:09 | FromDiscord | <Elegantbeef> Really rtfm regardless |
21:35:14 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4EIl |
21:36:04 | FromDiscord | <.maverk> In reply to @Elegantbeef "RTFM if you arent": am i suppose to insult you very badly ? |
21:36:15 | FromDiscord | <.maverk> don't speak tome that way |
21:36:23 | FromDiscord | <.maverk> (edit) "tome" => "to me" |
21:36:31 | FromDiscord | <heysokam> In reply to @Elegantbeef "So if you need": you mean that, as long as the ref is not dealloc by the GC, they are basically equivalent to ptr when it comes to what C knows about them? |
21:37:13 | FromDiscord | <Elegantbeef> Indeed aslong as you are not giving up ownership there is no issue with passing a ref as a ptr |
21:37:26 | FromDiscord | <heysokam> oh that's great to know, had no idea |
21:37:31 | FromDiscord | <Elegantbeef> > am i suppose to insult you very badly ?↵If you want to |
21:37:34 | FromDiscord | <.maverk> sent a code paste, see https://play.nim-lang.org/#ix=4EIo |
21:37:48 | FromDiscord | <Elegantbeef> Lol |
21:37:59 | FromDiscord | <Elegantbeef> Range types are just ordinals they cannot be iterated |
21:38:06 | FromDiscord | <Elegantbeef> Slices can be iterated they have a start/end |
21:38:11 | FromDiscord | <Elegantbeef> Please read the tutorial |
21:38:13 | FromDiscord | <Elegantbeef> Thanks |
21:38:34 | FromDiscord | <heysokam> beef, stop being obnoxious man, he is just new and has my type of obtuse learning. chill |
21:39:25 | FromDiscord | <heysokam> he definitely could use the tutorial, but its nicer to just point to where in the tut its explained, for example↵i don't know where, so cant point them |
21:39:48 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/tut1.html#advanced-types-subranges↵https://nim-lang.org/docs/tut1.html#advanced-types-slices |
21:40:52 | FromDiscord | <heysokam> @.maverk 👆 should explain it |
21:41:09 | FromDiscord | <.maverk> In reply to @heysokam "<@1021771961040375900> 👆 should explain": ok |
22:21:29 | FromDiscord | <heysokam> @Phil parsing the hardcase actually wasn't that bad at all after your help and Rika's↵I think I was making it worse with my silly filtering out instead of filtering in↵ty so much for the help earlier 🙏 |
22:22:18 | FromDiscord | <heysokam> I changed it to first check if the line is a weird case, and echoing a warning↵and then just getting the result assuming its correct |
22:22:34 | FromDiscord | <heysokam> (edit) "its correct" => "the input is already corrected" |
22:28:53 | * | madprops_ is now known as madprops |
22:28:53 | * | madprops quit (Changing host) |
22:28:53 | * | madprops joined #nim |
22:31:50 | FromDiscord | <System64 ~ Flandre Scarlet> What is the best for a game? Options or Nil? |
22:36:06 | FromDiscord | <odexine> i believe a good amount of people would say to never use nil |
22:38:29 | FromDiscord | <Elegantbeef> If you want to represent a bad state `nil` is not really that sensible as it introduces a heap allocation |
22:40:53 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @Elegantbeef "If you want to": and performances wise? |
22:42:31 | FromDiscord | <Elegantbeef> Heap allocations are slow |
22:42:59 | FromDiscord | <System64 ~ Flandre Scarlet> I meant between Nil and Options |
22:43:32 | FromDiscord | <Elegantbeef> Options are stack allocated so they do not introduce substantial performance losses |
22:44:08 | FromDiscord | <System64 ~ Flandre Scarlet> Oh, pretty interesting! |
22:44:19 | FromDiscord | <System64 ~ Flandre Scarlet> Nil, for stack |
22:44:38 | FromDiscord | <arathanis> nil is an empty ref type so by its veyr nature you are working with the heap |
22:44:44 | FromDiscord | <arathanis> at least that is how i understand it |
22:45:16 | FromDiscord | <Elegantbeef> Well if you use `ptr T` you could have a pointer to a stack type |
22:45:19 | FromDiscord | <arathanis> (edit) removed "type" |
22:45:55 | FromDiscord | <Elegantbeef> But i'm not going to suggest using `ptr T` in a memory safe langauge |
22:46:24 | FromDiscord | <System64 ~ Flandre Scarlet> Only use pointers when you know what you're doing |
22:46:45 | FromDiscord | <System64 ~ Flandre Scarlet> With great powers comes great responsabilities |
22:48:13 | FromDiscord | <odexine> how do i know if i know what im doing |
22:48:44 | FromDiscord | <Elegantbeef> Trick question, it's you. You never do |
22:51:11 | FromDiscord | <System64 ~ Flandre Scarlet> Avoid Pointers, avoid C language, boycott C++ |
22:58:47 | arkanoid | mmm I'm back to my previous problem, but now is slightly different. Why I get double free here? https://play.nim-lang.org/#ix=4EIu |
23:00:49 | FromDiscord | <Elegantbeef> `--expandArc:test` |
23:04:46 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @Elegantbeef "`--expandArc:test`": What is that? |
23:05:16 | FromDiscord | <Elegantbeef> It shows the code that is generated |
23:05:27 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=4EIy think this is 'proper' |
23:05:34 | FromDiscord | <Elegantbeef> I do not really know with the new hooks |
23:05:54 | FromDiscord | <System64 ~ Flandre Scarlet> Oh alright |
23:06:25 | FromDiscord | <System64 ~ Flandre Scarlet> Yo what? Object suppports Generics?! |
23:07:07 | FromDiscord | <Elegantbeef> How else do you think `Table[X, Y]` worked? |
23:07:21 | FromDiscord | <System64 ~ Flandre Scarlet> Ah yeah, makes sense now! |
23:08:44 | arkanoid | Elegantbeef! Ok, now this makes sense again. Thanks. But what is the default implementation of the hooks? Can I read them? |
23:08:56 | arkanoid | if any |
23:08:58 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/destructors.html#lifetimeminustracking-hooks |
23:10:46 | FromDiscord | <Elegantbeef> The default implementation is what you would imagine though `sink` is assign left to right, then call `wasMoved` on the right side. `destroy` calls `=destroy` on all fields. `=copy` creates a clone of the data, `=trace` runs `trace` on all possibly GC'd data types |
23:12:07 | arkanoid | so what that page calls "The general pattern in X looks like" really means "hooks are automatically generated but overraidable, here the default version" |
23:12:19 | FromDiscord | <Elegantbeef> Practically yes |
23:13:07 | arkanoid | ok, thanks. I was just confused by the wording used in the manual then |
23:17:06 | arkanoid | would be nice to be able to read the genared hooks for a custom type. Just like expandArc, but expandHooks |
23:17:17 | arkanoid | *generated |
23:17:46 | FromDiscord | <Elegantbeef> You could look at the generated C |
23:18:08 | FromDiscord | <Elegantbeef> Hooks for automatically GC'd types arent that complicated though |
23:21:12 | arkanoid | well sure I can, but generated C is quite far from Nim AST. Otherwise also expandArc would be useless, just read C |
23:21:32 | FromDiscord | <Elegantbeef> Hey I wasnt being that sincere |
23:26:07 | * | xet7 joined #nim |
23:36:43 | arkanoid | just used the wrong words myself. Sure I got your point. I didn't want to sound rude |