00:13:35 | * | shalokshalom quit (Remote host closed the connection) |
02:57:30 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
03:16:03 | * | ltriant joined #nim |
03:16:34 | FromDiscord | <⎝⪩﹏⪨⎠> I don't know why my code can't detect `(` and `)`. https://media.discordapp.net/attachments/371759389889003532/946968953887006720/unknown.png https://media.discordapp.net/attachments/371759389889003532/946968954411315210/unknown.png https://media.discordapp.net/attachments/371759389889003532/946968954952351794/unknown.png https://media.discordapp.net/attachments/371759389889003532/946968955141107712/unknown.png |
03:18:37 | FromDiscord | <⎝⪩﹏⪨⎠> `insertToken`: https://media.discordapp.net/attachments/371759389889003532/946969472579817552/unknown.png |
03:20:22 | FromDiscord | <Elegantbeef> Is there really any reason to use regex here? |
03:20:55 | * | ltriant quit (Ping timeout: 256 seconds) |
03:21:33 | NimEventer | New thread by Geohuz: Is there any kalman filter package in Nim?, see https://forum.nim-lang.org/t/8954 |
03:22:41 | FromDiscord | <⎝⪩﹏⪨⎠> In reply to @Elegantbeef "Is there really any": Should I use it only for the numbers? |
03:22:46 | FromDiscord | <⎝⪩﹏⪨⎠> Let me try. |
03:22:50 | FromDiscord | <Elegantbeef> I dont think so |
03:24:44 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3QM0 |
03:24:51 | FromDiscord | <⎝⪩﹏⪨⎠> In reply to @Elegantbeef "You can just iterate": Hmm... |
03:25:37 | FromDiscord | <⎝⪩﹏⪨⎠> I did use Regex 'cause one time used the patterns matching from Lua, and I wanted to try it on Nim. |
03:25:46 | FromDiscord | <⎝⪩﹏⪨⎠> (edit) "patterns" => "pattern" |
03:26:19 | * | arkurious quit (Quit: Leaving) |
03:26:27 | FromDiscord | <Elegantbeef> Ah i dont like regex generally so i'm biased |
03:26:32 | FromDiscord | <Elegantbeef> We have things like `parseutils` |
03:27:08 | FromDiscord | <⎝⪩﹏⪨⎠> I come fresh from ending the chapter 3 of the "nim tutorial", what did you expected. |
03:28:14 | FromDiscord | <Elegantbeef> I mean it's fine i have a dislike of regex |
03:28:30 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/parseutils.html has a tonnes of things that makes this easy |
03:46:43 | nrds | <Prestige99> Am I the only one that loves regex? 🤔 |
03:47:14 | FromDiscord | <⎝⪩﹏⪨⎠> In reply to @nrds "<Prestige> Am I the": I like Regex (well, at least Lua's one). |
03:47:23 | FromDiscord | <Elegantbeef> Perhaps scanf/parseutils is nicer imo |
03:48:12 | FromDiscord | <⎝⪩﹏⪨⎠> And I thing kind of didn't work: https://media.discordapp.net/attachments/371759389889003532/946976919075819551/unknown.png |
03:48:56 | FromDiscord | <⎝⪩﹏⪨⎠> wait what |
03:49:30 | FromDiscord | <⎝⪩﹏⪨⎠> Hmm... I think I know what I'm missing. |
03:50:15 | FromDiscord | <⎝⪩﹏⪨⎠> Done. |
03:52:05 | FromDiscord | <⎝⪩﹏⪨⎠> Ok, I have the Lexer done, now I need to build the Parser. |
03:52:27 | * | Gustavo6046 quit (Ping timeout: 250 seconds) |
04:01:38 | * | krux02 quit (Remote host closed the connection) |
04:02:10 | FromDiscord | <⎝⪩﹏⪨⎠> And that's the part I've always struggled with: I don't have any idea of how to build a parser. |
04:02:18 | FromDiscord | <⎝⪩﹏⪨⎠> Ill ask that in another server. |
04:02:34 | FromDiscord | <Elegantbeef> There is the #langdev channel |
04:04:46 | FromDiscord | <⎝⪩﹏⪨⎠> In reply to @Elegantbeef "There is the <#763409397716090902>": I'm in a server about more generalized programming and with more members than this one. |
04:06:01 | * | supakeen quit (Quit: WeeChat 3.4) |
04:06:32 | * | supakeen joined #nim |
04:37:51 | FromDiscord | <retkid> is there any 3d rendering libraries for nim |
04:38:13 | FromDiscord | <Elegantbeef> You can use raylib, or opengl |
04:38:19 | FromDiscord | <Elegantbeef> The former is much easier 😀 |
04:38:55 | FromDiscord | <retkid> I'll try raylib and if not I'll use it as an excuse to try another language |
04:39:15 | FromDiscord | <Elegantbeef> One could also use Godot with the nim bindings |
04:39:22 | FromDiscord | <retkid> I can, yes |
04:39:33 | FromDiscord | <retkid> but I don't think that suits my project |
04:39:47 | FromDiscord | <retkid> I might do it in a JS framework for browser embeds |
04:40:08 | FromDiscord | <Elegantbeef> Raylib has wasm support |
04:40:23 | FromDiscord | <retkid> isn't compiling nim wasm a MASSIVE pain in the tits |
04:40:27 | FromDiscord | <retkid> i tried to one time |
04:40:38 | FromDiscord | <Elegantbeef> No it's a single config file |
04:40:59 | FromDiscord | <Elegantbeef> Dont know if it's a single config file with raylib, but yea it's a single config otherwise |
04:41:16 | FromDiscord | <Elegantbeef> https://github.com/treeform/nim_emscripten_tutorial |
04:41:21 | FromDiscord | <Elegantbeef> Not a real big pain |
04:41:54 | FromDiscord | <retkid> treeform is a gift to the community and he is so productive it is insane |
04:42:34 | FromDiscord | <retkid> I wish i could focus on anything as much as he does |
04:42:43 | FromDiscord | <retkid> stuff takes me so long because i doze and look at my wall and not workj |
04:42:45 | FromDiscord | <retkid> (edit) "workj" => "work" |
05:05:42 | FromDiscord | <creikey> In reply to @retkid "stuff takes me so": this happens to me too, how to avoid this? |
05:06:31 | FromDiscord | <Rika> somehow build discipline ig |
05:17:47 | NimEventer | New thread by JohnLuck: OrderedTable missing Seq methods, see https://forum.nim-lang.org/t/8955 |
05:37:07 | * | slowButPresent quit (Quit: leaving) |
06:11:32 | FromDiscord | <Deceptive> In reply to @treeform "Here is how you": Damn, this looks a bit easier. Thanks! |
07:00:02 | NimEventer | New thread by Elcritch: Fidget UI: scrolling on OpenGL backend, see https://forum.nim-lang.org/t/8956 |
07:17:38 | * | ltriant joined #nim |
07:22:35 | * | ltriant quit (Ping timeout: 256 seconds) |
08:11:35 | * | shalokshalom joined #nim |
08:13:25 | * | pro joined #nim |
08:15:57 | * | shalokshalom quit (Ping timeout: 240 seconds) |
08:16:33 | * | shalokshalom joined #nim |
08:18:46 | * | shalokshalom quit (Client Quit) |
08:18:59 | * | shalokshalom joined #nim |
08:47:31 | * | shalokshalom quit (Remote host closed the connection) |
08:49:34 | * | shalokshalom joined #nim |
08:55:06 | * | jmd_ joined #nim |
08:55:32 | * | jmdaemon quit (Ping timeout: 240 seconds) |
08:57:27 | FromDiscord | <tracy> is there a way i can use my nim procedures in c#? |
08:57:53 | FromDiscord | <Elegantbeef> You can use `--app:lib` and use it as a system library |
08:58:07 | FromDiscord | <Elegantbeef> Suggested to use `arc` or `orc` for your gc in that regard so you do not need to setup the GC |
08:58:19 | FromDiscord | <tracy> whas a gc |
08:58:38 | FromDiscord | <tracy> oh nvm im slow |
08:58:47 | FromDiscord | <Elegantbeef> Nim has multiple memory management systems, the default is a garbage collector |
08:58:47 | FromDiscord | <tracy> In reply to @Elegantbeef "You can use `--app:lib`": oooh alr |
09:00:21 | FromDiscord | <Elegantbeef> You'l also want https://nim-lang.org/docs/manual.html#foreign-function-interface-dynlib-pragma-for-export |
09:00:38 | FromDiscord | <rakgew> and the other way around? can nim look somehow into .net clr libs and use their logic? |
09:00:51 | FromDiscord | <Elegantbeef> Yes winim has CLR support |
09:01:02 | FromDiscord | <rakgew> ah nice! thx. |
09:09:35 | FromDiscord | <tracy> sent a code paste, see https://play.nim-lang.org/#ix=3QMT |
09:09:37 | FromDiscord | <tracy> why doesnt this work? |
09:09:50 | FromDiscord | <tracy> sent a code paste, see https://play.nim-lang.org/#ix=3QMU |
09:10:27 | FromDiscord | <Elegantbeef> That shouldnt be `string` it should be `char` or w/e C# has |
09:11:01 | FromDiscord | <tracy> sent a code paste, see https://play.nim-lang.org/#ix=3QMV |
09:11:31 | FromDiscord | <Elegantbeef> yea |
09:12:02 | FromDiscord | <tracy> sent a code paste, see https://paste.rs/PuJ |
09:12:05 | FromDiscord | <Elegantbeef> Going to have to do some unsafe C# possibly, supposedly `StringBuilder` is the same as `char` |
09:12:10 | FromDiscord | <Elegantbeef> No it's returning a `cstring` |
09:12:21 | FromDiscord | <Elegantbeef> Which is a pointer to a char |
09:14:36 | FromDiscord | <Elegantbeef> Yea seems like for a `Cstring` inside C# `StringBuilder` is the go to |
09:17:34 | FromDiscord | <tracy> In reply to @Elegantbeef "Yea seems like for": i think stringbuilder is to buildf strings |
09:17:38 | FromDiscord | <tracy> build strings |
09:17:49 | FromDiscord | <tracy> like that |
09:17:51 | FromDiscord | <Elegantbeef> I'm reading a lot that it's usable in place of `cstring` |
09:17:53 | FromDiscord | <tracy> sent a code paste, see https://play.nim-lang.org/#ix=3QMX |
09:17:57 | FromDiscord | <Elegantbeef> sorry `char` |
09:18:15 | FromDiscord | <tracy> maybe a char array will work |
09:18:53 | FromDiscord | <Elegantbeef> You can use `char` but i'm reading it seems fine to use StringBuilder, which is why i mentioned it |
09:19:13 | FromDiscord | <Elegantbeef> I've never done C interop with C#, so looking into it a bit |
09:30:08 | FromDiscord | <Elegantbeef> Seems they might be talking about managed libraries with the `StringBuilder` given https://docs.microsoft.com/en-us/dotnet/framework/interop/marshaling-data-with-platform-invoke |
09:30:23 | FromDiscord | <Elegantbeef> So i guess yay for my annoying abillities |
09:37:28 | FromDiscord | <tracy> sent a code paste, see https://play.nim-lang.org/#ix=3QN1 |
09:37:33 | FromDiscord | <tracy> cuz i tried but i get a memory error |
09:40:21 | FromDiscord | <Elegantbeef> You'd need to get the file handle of the C# stdout and then open that and set the stdout file to that |
09:41:05 | FromDiscord | <tracy> In reply to @Elegantbeef "You'd need to get": what is "the file handle of the c# stdout" |
09:42:16 | FromDiscord | <Elegantbeef> Basically an id of the opened file |
09:42:44 | FromDiscord | <tracy> how i even begin to get that 🤔 |
09:42:56 | FromDiscord | <tracy> never heard of it |
09:43:53 | FromDiscord | <tracy> idk what i did but it just worked |
09:44:12 | FromDiscord | <tracy> just works |
09:44:13 | FromDiscord | <tracy> sent a code paste, see https://play.nim-lang.org/#ix=3QN3 |
09:44:13 | FromDiscord | <tracy> for some reason |
09:44:19 | FromDiscord | <Elegantbeef> Guess i'm just dumb |
09:44:29 | FromDiscord | <Elegantbeef> Figured there was an issue with it getting stdout, but yea that's dumb |
09:44:51 | FromDiscord | <Elegantbeef> Who lets me type messages here |
09:50:32 | FromDiscord | <⎝⪩﹏⪨⎠> What do you think about my way of seeing if parenthesis are ok: https://media.discordapp.net/attachments/371759389889003532/947068105883004978/unknown.png |
09:51:06 | * | jjido joined #nim |
09:51:39 | FromDiscord | <ShalokShalom> @ElegantBeef Do you have any idea, how we can put the union syntax into something more concise? |
09:52:06 | FromDiscord | <ShalokShalom> Like, with a macro? |
09:52:31 | FromDiscord | <Elegantbeef> https://github.com/alaviss/union https://github.com/beef331/sumtypes https://github.com/andreaferretti/patty https://github.com/chocobo333/AlgebraicDataTypes |
09:52:52 | FromDiscord | <Elegantbeef> Oh right that embeds all of them doesnt it |
09:53:19 | FromDiscord | <Elegantbeef> The parenthesis method seems fine but i dont get why you're doing string comparisons for a character |
09:54:52 | FromDiscord | <ShalokShalom> Patty looks a lot like the examples you have shown me |
09:55:06 | FromDiscord | <ShalokShalom> Is pattern matching and tagged unions the same in Nim? |
09:55:20 | FromDiscord | <Elegantbeef> https://github.com/andreaferretti/patty#constructing-variant-objects |
09:55:48 | FromDiscord | <ShalokShalom> aaah |
09:55:50 | FromDiscord | <ShalokShalom> nice |
09:56:36 | FromDiscord | <Elegantbeef> My package is silly and just use union if you want that, it was deprecated by leorize almost instantly 😀 |
09:56:42 | FromDiscord | <Elegantbeef> Probably should add that to the read me |
09:57:35 | FromDiscord | <ShalokShalom> looks good to me |
09:58:20 | FromDiscord | <ShalokShalom> This looks exactly like what I was looking for |
09:58:29 | FromDiscord | <Elegantbeef> Anyway union/sumtypes are for easy to make object variants for heterogeneous holding of types, the last two are for more complex ADT |
09:58:32 | FromDiscord | <Elegantbeef> Patty? |
09:58:39 | FromDiscord | <ShalokShalom> The last link, yeah |
09:58:49 | FromDiscord | <ShalokShalom> Object variants in patty |
09:58:59 | FromDiscord | <ShalokShalom> A shortcut to the syntax you showed me yesterdaay |
09:59:19 | FromDiscord | <Elegantbeef> Yep the joy of macros small core can be expanded in userspace |
09:59:39 | FromDiscord | <Elegantbeef> The syntax is very similar to Rust's ADTs |
09:59:52 | * | kayabaNerve joined #nim |
09:59:56 | FromDiscord | <ShalokShalom> And kind is just a tradition, not a keyword |
10:00:18 | FromDiscord | <ShalokShalom> Thats nice, since I can use something more descriptive to me 🙂 |
10:00:22 | FromDiscord | <Elegantbeef> It's a convention, it can be anything |
10:00:27 | FromDiscord | <ShalokShalom> Yeah, nice |
10:00:50 | FromDiscord | <Elegantbeef> You can also have nested variants, but that requires the tedious api |
10:01:10 | FromDiscord | <Elegantbeef> Or an inner object for a specific field |
10:06:14 | FromDiscord | <ShalokShalom> Well, I see object variants in Patty seem to expand to some more than just the initial setup of the unions |
10:06:30 | FromDiscord | <ShalokShalom> https://github.com/andreaferretti/patty#constructing-variant-objects |
10:07:27 | FromDiscord | <Elegantbeef> If you dont want them time to fork it 😛 |
10:07:51 | FromDiscord | <ShalokShalom> Those things seem so basic to me, I really wish someone could just explain to me, how to use Nim in a functional manner. |
10:08:32 | FromDiscord | <Elegantbeef> It's not a functional language, so you can do some things functionally but it's not going to be like F# |
10:08:49 | FromDiscord | <Elegantbeef> Wait what's basic? |
10:10:07 | FromDiscord | <ShalokShalom> unions |
10:10:14 | FromDiscord | <ShalokShalom> well, but it can do all those things |
10:10:30 | FromDiscord | <ShalokShalom> so, when you can use it as a functional language, why not attract more users by a simple guide |
10:10:46 | FromDiscord | <Elegantbeef> Well it's not capable of using it as a functional language |
10:10:52 | FromDiscord | <Elegantbeef> There are things it just cannot do |
10:12:51 | FromDiscord | <Elegantbeef> https://forum.nim-lang.org/t/8927 is related to this, but the gist is, it's imperative and will take compelling things from FP where it makes sense(strict funcs for instance) |
10:12:57 | FromDiscord | <ShalokShalom> There are things, Nim can do, that FSharp cant, like checking on side effect |
10:13:14 | FromDiscord | <ShalokShalom> I am just asking for records, unions, pattern matching and stuff |
10:13:22 | FromDiscord | <ShalokShalom> But more guides |
10:14:28 | FromDiscord | <ShalokShalom> And I am not asking to make it pure |
10:14:34 | FromDiscord | <ShalokShalom> Just .. functional |
10:14:34 | * | rockcavera quit (Read error: Connection reset by peer) |
10:15:25 | * | rockcavera joined #nim |
10:15:25 | * | rockcavera quit (Changing host) |
10:15:25 | * | rockcavera joined #nim |
10:15:42 | FromDiscord | <Elegantbeef> Well if i had any idea how to write FP I'd probably make a guide, but I'm not a FP user and there are very few here, so I guess time for you to be the one that writes guides in a few months 😛 |
10:15:43 | FromDiscord | <tracy> In reply to @Elegantbeef "Well it's not capable": what does functional lagnauge mean |
10:16:07 | FromDiscord | <tracy> language |
10:16:28 | FromDiscord | <Elegantbeef> A language that is based off mathematics and strives for sideeffect free procedures, is what i generally say |
10:16:53 | FromDiscord | <ShalokShalom> I would like to port the tutorial, I linked yesterday |
10:17:06 | FromDiscord | <ShalokShalom> That is targeted to show people how to do basic fp |
10:17:11 | FromDiscord | <Elegantbeef> https://en.wikipedia.org/wiki/Functional_programming will explain better than anyone here |
10:17:14 | FromDiscord | <ShalokShalom> It can be used as guide then. |
10:17:17 | FromDiscord | <Elegantbeef> The tutorial? |
10:17:34 | FromDiscord | <ShalokShalom> https://github.com/thedevaspect/aspect-fsharp |
10:17:48 | FromDiscord | <tracy> so nim isnt functional right |
10:17:58 | FromDiscord | <ShalokShalom> Its not purely functional |
10:18:03 | FromDiscord | <Elegantbeef> It's procedural |
10:18:11 | FromDiscord | <ShalokShalom> Every language is functional, to a certain extend |
10:18:17 | FromDiscord | <ShalokShalom> func is functional |
10:18:25 | FromDiscord | <ShalokShalom> const/let in a sense also |
10:18:35 | FromDiscord | <ShalokShalom> immutability |
10:18:35 | FromDiscord | <Elegantbeef> In a very loose sense 😛 |
10:18:50 | FromDiscord | <ShalokShalom> I am fine with the feature set |
10:18:56 | FromDiscord | <ShalokShalom> Just not with the documentation. |
10:19:02 | FromDiscord | <Elegantbeef> Functional is a whole paradigm mutability is just a small segment of FP |
10:19:15 | FromDiscord | <ShalokShalom> Yeah, but as an example. |
10:19:31 | FromDiscord | <ShalokShalom> Nim has functional features. I am not complaining about the feature set. |
10:19:50 | FromDiscord | <Elegantbeef> Never said you are, i tend to make jokes |
10:20:12 | FromDiscord | <Elegantbeef> Well t hat's a 300 loc program it seems, doesnt seem too bad to port to Nim |
10:20:16 | FromDiscord | <Elegantbeef> Though i dont understand a lot of FP so... 😀 |
10:20:37 | FromDiscord | <ShalokShalom> Yeah, its just using basics |
10:20:47 | FromDiscord | <ShalokShalom> You could start, by looking the tutorial on Youtube 😛 |
10:20:52 | FromDiscord | <ShalokShalom> Then you know more about FP |
10:21:16 | FromDiscord | <Elegantbeef> that implies i'd like to |
10:21:27 | FromDiscord | <ShalokShalom> You could 🙂 |
10:23:24 | FromDiscord | <ShalokShalom> https://www.youtube.com/watch?v=hsTmLhnzRhE |
10:24:12 | FromDiscord | <Elegantbeef> The typedefs you should be able to port |
10:24:57 | FromDiscord | <ShalokShalom> ok |
10:26:56 | FromDiscord | <Elegantbeef> What things have you stymied anyway? |
11:01:01 | FromDiscord | <ShalokShalom> How to do a single case union? |
11:02:24 | FromDiscord | <ShalokShalom> Is it that way enough? |
11:02:36 | FromDiscord | <ShalokShalom> sent a code paste, see https://paste.rs/XvV |
11:14:08 | FromDiscord | <Rika> Why would you need to do such? Nonetheless I believe that is right |
11:19:13 | * | ltriant joined #nim |
11:19:17 | FromDiscord | <b4mbus> `nimble run -d:ssl`↵I do that and it does compile and run my project but it doesn't pass `-d:ssl` to the compiler, so then I get SSL errors |
11:19:27 | FromDiscord | <b4mbus> what can I do with it |
11:22:05 | FromDiscord | <tracy> In reply to @b4mbus "`nimble run -d:ssl` I": compile it with -d:ssl |
11:22:14 | FromDiscord | <tracy> oh wait |
11:22:28 | FromDiscord | <tracy> isnt nimble the package manager |
11:23:07 | FromDiscord | <b4mbus> it is |
11:23:26 | FromDiscord | <b4mbus> but it's also some kinda build system, I was told |
11:23:34 | FromDiscord | <tracy> In reply to @b4mbus "but it's also some": nim c -r -d:ssl test.nim |
11:23:43 | FromDiscord | <b4mbus> and a project is also called a package |
11:23:52 | FromDiscord | <tracy> In reply to @b4mbus "and a project is": just compile it normally and try it |
11:23:56 | FromDiscord | <b4mbus> In reply to @tracy "nim c -r -d:ssl": I know I can use the nim compiler but it's not a problem |
11:24:00 | FromDiscord | <b4mbus> (edit) "a" => "the" |
11:24:04 | FromDiscord | <ShalokShalom> sent a code paste, see https://play.nim-lang.org/#ix=3QNs |
11:24:14 | FromDiscord | <b4mbus> In reply to @b4mbus "I know I can": the problem is that `nimble` doesn't pass the arguments to the compiler itself |
11:24:22 | FromDiscord | <b4mbus> and Im using exeternal dependencies |
11:24:29 | FromDiscord | <b4mbus> (edit) "exeternal" => "external" | "externaldependencies ... " added "(namely - dimscord and dimscmd)" |
11:24:52 | FromDiscord | <b4mbus> nimble should do that for me |
11:25:10 | FromDiscord | <tracy> have u tried to compile it with nim c |
11:25:23 | FromDiscord | <b4mbus> yes I did |
11:25:29 | FromDiscord | <b4mbus> and as I said |
11:25:43 | FromDiscord | <b4mbus> the issue is that nimble doesn't forward the arguments to the compiler |
11:26:14 | FromDiscord | <ShalokShalom> sent a code paste, see https://paste.rs/laH |
11:26:18 | FromDiscord | <ShalokShalom> How is that semantically different from above |
11:27:19 | FromDiscord | <dom96> In reply to @b4mbus "**the issue** is that": afaik that is indeed an issue with `nimble run` specifically |
11:27:32 | FromDiscord | <b4mbus> alright, so that is a known issue |
11:27:38 | FromDiscord | <b4mbus> is there someone resolving that already? |
11:28:05 | FromDiscord | <b4mbus> https://github.com/nim-lang/nimble/issues/986 |
11:28:06 | FromDiscord | <b4mbus> I see |
11:28:16 | * | ltriant quit (Ping timeout: 272 seconds) |
11:28:55 | FromDiscord | <b4mbus> Id love to file a PR but I just started with nim a few days ago and I would do more harm than good |
11:31:34 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
11:32:10 | * | pro quit (Quit: pro) |
11:32:33 | FromDiscord | <dom96> it should be an easy fix |
11:32:44 | FromDiscord | <dom96> great way to make a first contribution 🙂 |
11:33:25 | FromDiscord | <Rika> In reply to @ShalokShalom "When I capitalize the": because the syntax highlighters use the first letter capitalisation to distinguish "regular idents" to "type idents" |
11:34:01 | FromDiscord | <Rika> though i believe it shouldnt do that in all cases like when its a field since thats definitely never a type |
11:36:05 | FromDiscord | <dom96> you shouldn't name your field names that way, syntax highlighting should nudge you away from that |
11:37:11 | FromDiscord | <ShalokShalom> how else? |
11:37:18 | FromDiscord | <Rika> lowercase first letter |
11:37:26 | FromDiscord | <Rika> feel free to use either snake or camel |
11:37:31 | FromDiscord | <ShalokShalom> Yeah, like in the first example? |
11:37:33 | * | PMunch joined #nim |
11:37:35 | FromDiscord | <Rika> yeah |
11:37:39 | FromDiscord | <ShalokShalom> In reply to @ShalokShalom "When I capitalize the": Like that? |
11:37:49 | FromDiscord | <Rika> the types should be pascal |
11:37:53 | FromDiscord | <Rika> north: Exit |
11:37:56 | FromDiscord | <ShalokShalom> ok |
11:38:05 | FromDiscord | <Rika> its just convention |
11:38:15 | FromDiscord | <Rika> you can disobey, but you might not have such a good time |
11:40:13 | FromDiscord | <ShalokShalom> types in Pascal is a convention? |
11:41:35 | FromDiscord | <Rika> pascal case |
11:41:48 | FromDiscord | <ShalokShalom> ah, ok cool |
11:41:50 | FromDiscord | <Rika> which is camel case with a capitalised first letter |
11:41:58 | FromDiscord | <ShalokShalom> yep |
11:42:13 | FromDiscord | <ShalokShalom> someone told me lowercase first for types are fine |
11:42:17 | FromDiscord | <ShalokShalom> so I was confused |
11:42:21 | Amun-Ra | speaking of conventions, I'd like nimgrep to have an option for suggesting snake case variant |
11:42:28 | FromDiscord | <ShalokShalom> why does syntax highlighting also change its color here as well? |
11:42:30 | FromDiscord | <Rika> theyre fine since its just a convention |
11:42:31 | FromDiscord | <ShalokShalom> when its just a convention |
11:42:34 | FromDiscord | <Rika> because its the convention |
11:42:39 | FromDiscord | <Rika> (edit) "the" => "the" |
11:42:40 | FromDiscord | <ShalokShalom> Ah, ok |
11:42:44 | Amun-Ra | shalokshalom: lower case is fine for consts |
11:43:14 | FromDiscord | <ShalokShalom> ok.. |
11:45:23 | FromDiscord | <ShalokShalom> How to form a list type? |
11:45:41 | FromDiscord | <ShalokShalom> sent a code paste, see https://play.nim-lang.org/#ix=3QNB |
11:45:42 | FromDiscord | <ShalokShalom> I like to make the Items type a list |
11:46:10 | Amun-Ra | you can make it seq[type] |
11:46:17 | FromDiscord | <ShalokShalom> Thanks |
11:46:26 | FromDiscord | <ShalokShalom> seq[Items] yes? |
11:46:31 | Amun-Ra | or array, if the size is known compile time |
11:46:43 | Amun-Ra | seq[TypeOfAnItem] |
11:47:09 | Amun-Ra | shalokshalom: type Items = seq[byte] |
11:47:12 | Amun-Ra | for example |
11:47:13 | FromDiscord | <Rika> In reply to @ShalokShalom "seq[Items] yes?": tes |
11:47:22 | FromDiscord | <Rika> well |
11:47:26 | FromDiscord | <Rika> what is `Items`? |
11:47:41 | Amun-Ra | if "Items" is a list alike type |
11:47:41 | FromDiscord | <Rika> its prolly more appropriate to name it `Item` if you're doing `seq[Item]` |
11:47:46 | FromDiscord | <ShalokShalom> a type from before |
11:47:47 | Amun-Ra | yes |
11:48:05 | FromDiscord | <ShalokShalom> sent a code paste, see https://paste.rs/jkk |
11:48:19 | Amun-Ra | if you don't need to have an explicite list type by name just have seq[ElementType] |
11:48:55 | FromDiscord | <ShalokShalom> true, singular is also written in the original source, from that I port it |
11:49:31 | Amun-Ra | shalokshalom: https://play.nim-lang.org/#ix=3QND |
11:50:09 | FromDiscord | <ShalokShalom> sent a code paste, see https://play.nim-lang.org/#ix=3QNE |
11:50:34 | Amun-Ra | mhm |
11:51:13 | FromDiscord | <ShalokShalom> Thats fine? |
11:51:45 | Amun-Ra | sure |
11:52:12 | FromDiscord | <dom96> nitpicking: convention is also to use 2 spaces vs 4 for indentation 🙂 |
11:52:17 | Amun-Ra | and speaking of coding stype, Nim typically has 2 space indents |
11:54:05 | FromDiscord | <ShalokShalom> Yeah, I am porting F# to Nim |
11:54:11 | FromDiscord | <ShalokShalom> And trying to hold it so close as possible |
11:54:16 | FromDiscord | <ShalokShalom> To compare it 1:1 |
11:55:31 | FromDiscord | <ShalokShalom> Is there a formatter? |
11:55:48 | Amun-Ra | there's nimpretty |
11:57:10 | FromDiscord | <tracy> can someone help me convert some c# code to nim? |
11:57:41 | Amun-Ra | paste somewhere the part you have trouble with |
11:58:04 | * | Amun-Ra 's knowledge of C# is a litle rusty |
11:59:23 | FromDiscord | <tracy> alright let me find it, im just trying to convert it but im rlly new to nim so idrk where to start |
11:59:24 | FromDiscord | <tracy> 1 sec |
12:04:03 | FromDiscord | <tracy> sent a code paste, see https://play.nim-lang.org/#ix=3QNR |
12:06:01 | * | supakeen quit (Quit: WeeChat 3.4) |
12:06:31 | * | supakeen joined #nim |
12:06:34 | Amun-Ra | https://nim-lang.org/docs/streams.html |
12:06:55 | FromDiscord | <tracy> how do i do the rest tho |
12:07:14 | FromDiscord | <tracy> it reads the current exe, and then splits it by "" to get the text after it |
12:08:06 | FromDiscord | <Rika> https://nim-lang.org/docs/strutils.html ? |
12:08:29 | FromDiscord | <tracy> and then last thing, its reading the current exe running |
12:08:51 | FromDiscord | <Rika> good luck with that, i dont know |
12:09:25 | FromDiscord | <Rika> something in https://nim-lang.org/docs/system.html maybe like the app name or w/e |
12:15:23 | FromDiscord | <tracy> sent a code paste, see https://paste.rs/aE1 |
12:15:24 | FromDiscord | <tracy> what does this mena |
12:15:25 | FromDiscord | <tracy> mean |
12:15:28 | FromDiscord | <tracy> i get it when trying to compile |
12:16:13 | FromDiscord | <Rika> you dont have a c compiler? |
12:16:16 | * | PMunch quit (Quit: leaving) |
12:16:22 | FromDiscord | <tracy> https://media.discordapp.net/attachments/371759389889003532/947104803719356416/unknown.png |
12:16:30 | FromDiscord | <tracy> gcc is c compiler right ? |
12:16:39 | FromDiscord | <ShalokShalom> How do I map between two objects? |
12:16:44 | FromDiscord | <ShalokShalom> In another object |
12:16:59 | FromDiscord | <ShalokShalom> This is the original code |
12:16:59 | FromDiscord | <ShalokShalom> sent a code paste, see https://play.nim-lang.org/#ix=3QNU |
12:17:08 | FromDiscord | <ShalokShalom> Map from RoomId to Room |
12:17:15 | FromDiscord | <ShalokShalom> How to do that? |
12:20:52 | NimEventer | New thread by Tcheran: Linux moving to C11, see https://forum.nim-lang.org/t/8958 |
12:21:45 | NimEventer | New post on r/nim by wrestlingwithbadgers: db_postgres handles only strings?, see https://reddit.com/r/nim/comments/t1vvul/db_postgres_handles_only_strings/ |
12:21:47 | FromDiscord | <Rika> nim compiles to c99 no? i dont see reasons for anything to break |
12:26:17 | FromDiscord | <ShalokShalom> @ElegantBeef See, how far I come https://media.discordapp.net/attachments/371759389889003532/947107300529827890/Screenshot_20220226_132534.png |
12:26:33 | FromDiscord | <ShalokShalom> Is this all correct? |
12:29:09 | FromDiscord | <Rika> String -> string, since its a builtin nim type and those are (ODDLY) lowercase |
12:35:31 | FromDiscord | <b4mbus> https://nim-lang.org/docs/nimc.html#compiler-usage-commandminusline-switches↵\> https://nim-lang.org/docs/nimc.html#compiler-usage-commandminusline-switches |
12:35:42 | FromDiscord | <b4mbus> (edit) "https://nim-lang.org/docs/nimc.html#compiler-usage-commandminusline-switches" => "ResultUsed Warn about the usage of the built-in result variable." |
12:35:48 | FromDiscord | <b4mbus> why would that be a warning? |
12:36:30 | FromDiscord | <b4mbus> what's so wrong about using the result variable? |
12:37:25 | FromDiscord | <Rika> if you want it |
12:37:26 | FromDiscord | <Rika> its a choice |
12:38:12 | FromDiscord | <b4mbus> okay but why would that be a warning? Warnings should notify users about potentially misleading/dangerous actions taken in code |
12:38:50 | FromDiscord | <b4mbus> and using the result variable is not only kind of an idiom but just a standard practice in nim isnt it, and defining a new variable of the same name actually uses that variable, instead of the built-in one |
12:39:23 | FromDiscord | <b4mbus> \> and defining a new variable of the same name actually uses that variable, instead of the built-in one↵oh that's my bad actually |
12:39:42 | FromDiscord | <b4mbus> (edit) "actually" => "actually, it does not use the variable, it uses the built-in" |
12:39:43 | FromDiscord | <b4mbus> ok I see now, me being a dumb bitch again, sorry |
12:39:57 | FromDiscord | <Deceptive> yo guys i am trying to integrate the library which i made in nim, what i want is to unity load this library in the game itself |
12:45:07 | FromDiscord | <auxym> yo, ok, sounds cool |
12:53:58 | FromDiscord | <ShalokShalom> How could someone shorten 17 - 30 on the Nim side? |
12:54:12 | FromDiscord | <ShalokShalom> On the right side is F# https://media.discordapp.net/attachments/371759389889003532/947114325879975946/Screenshot_20220226_135252.png |
12:54:54 | FromDiscord | <ShalokShalom> It amounts to line 11 - 14 |
12:55:10 | FromDiscord | <haxscramper> You need to use macros for variant object declarations |
12:55:41 | FromDiscord | <ShalokShalom> Yeah, I think beef has already send me some libraries, but I cant really make sense of it |
12:56:15 | FromDiscord | <ShalokShalom> I like the {}-less approach of Nim |
12:56:22 | FromDiscord | <ShalokShalom> Looks even cleaner. 🙂 |
13:02:34 | FromDiscord | <Rika> In reply to @ShalokShalom "How could someone shorten": I think it’s already pretty concise |
13:11:17 | * | jmd_ quit (Ping timeout: 240 seconds) |
13:13:35 | * | slowButPresent joined #nim |
13:22:58 | FromDiscord | <konsumlamm> In reply to @b4mbus "okay but why would": using `result` can be potentially misleading/dangerous, for example when you forget to initialize it in one code path and then return |
13:26:20 | FromDiscord | <ShalokShalom> In reply to @Rika "I think it’s already": 4 lines vs 13 lines is short? |
13:26:46 | FromDiscord | <Rika> Lines can be inflated or deflated |
13:26:58 | FromDiscord | <Rika> I would be more worried about a 10 vs 80 line difference |
13:27:09 | FromDiscord | <ShalokShalom> well, its overall less boilerplate code on the right side |
13:27:21 | FromDiscord | <ShalokShalom> i like, that its more vertically on Nim side |
13:27:27 | FromDiscord | <Rika> Not really, there’s only like an estimated 5 of boilerplate |
13:27:51 | FromDiscord | <ShalokShalom> Hax says, there are macros, to make it shorter |
13:27:56 | FromDiscord | <ShalokShalom> I am only interested in this |
13:28:24 | FromDiscord | <Rika> Can’t help you, some were suggested above I believe |
13:31:46 | FromDiscord | <deech> Is there any documentation on getting a Nim dev environment up on Windows 10? |
13:33:05 | FromDiscord | <ShalokShalom> There is documentation on how to install Nim. And you can choose VSCode plus Extension. What else do you think about? |
13:39:02 | FromDiscord | <deech> I've seen the official docs, I was thinking a step by step on how to build from scratch with `vcc` ( I'd rather not work with MinGW). |
13:42:28 | FromDiscord | <ShalokShalom> choosenim works without MinGW, it seems: https://github.com/dom96/choosenim#dependencies |
13:53:32 | FromDiscord | <tracy> In reply to @ShalokShalom "<@!145405730571288577> See, how far": theme?! |
13:57:40 | * | kenran joined #nim |
14:08:05 | nrds | <Prestige99> I'm on Linux trying to cross compile something with mingw, but having errors about libwinpthread-1.dll not found. Anyone know what I am missing here? I do have mingw-w64-winpthreads installed, do I have to copy the dll locally and dynamically link it? |
14:09:02 | FromDiscord | <ShalokShalom> In reply to @tracy "theme?!": https://marketplace.visualstudio.com/items?itemName=benjaminmandersen.midnight-pastel |
14:10:56 | NimEventer | New question by Kevin Whitefoot: How can one do a pixel by pixel comparison of an image created by cairo and an image loaded from a file, see https://stackoverflow.com/questions/71277311/how-can-one-do-a-pixel-by-pixel-comparison-of-an-image-created-by-cairo-and-an-i |
14:13:35 | FromDiscord | <tracy> sent a code paste, see https://play.nim-lang.org/#ix=3QOt |
14:13:39 | FromDiscord | <tracy> what about this can have side effects? |
14:13:44 | FromDiscord | <tracy> https://media.discordapp.net/attachments/371759389889003532/947134341899747408/unknown.png |
14:20:25 | FromDiscord | <auxym> I assume opening a file is considered a side effect |
14:24:51 | supakeen | and in general that functions return value is not dependent solely on its inputs |
14:27:21 | FromDiscord | <ShalokShalom> isnt func supposed to prohibit that? |
14:27:28 | FromDiscord | <ShalokShalom> although I heard of some limitations |
14:31:01 | FromDiscord | <tracy> i meant to put proc |
14:31:01 | FromDiscord | <tracy> oops |
14:47:16 | NimEventer | New thread by Rad: Embedded STM32 - Bare Metal Bootstrap, see https://forum.nim-lang.org/t/8959 |
14:53:16 | FromDiscord | <tracy> how do i get the length of a filestream 🤔 |
14:53:41 | FromDiscord | <tracy> im trying to write to the end of a exe file but i have to set the position of the filestream to the end of the stream |
14:53:47 | FromDiscord | <tracy> and idk how to get the length |
14:59:38 | FromDiscord | <tracy> would this be getting the stream length |
14:59:38 | FromDiscord | <tracy> ? |
14:59:38 | FromDiscord | <tracy> sent a code paste, see https://paste.rs/P2g |
15:01:16 | * | arkurious joined #nim |
15:02:48 | FromDiscord | <tracy> sent a code paste, see https://play.nim-lang.org/#ix=3QOS |
15:14:28 | FromDiscord | <haolian9 (高浩亮)> as it is a file, i think posix.stat is good enough; or open the file in fmAppend mode |
15:14:57 | FromDiscord | <haolian9 (高浩亮)> does `cstring` need to be freed explictly?↵there is a pr related to [daniel-j/nim-mpv#1](https://github.com/daniel-j/nim-mpv/pull/1), i think it's unnecessary, and the `free()` does not really exist. |
15:15:41 | FromDiscord | <ShalokShalom> How to use macros for variant object declarations? |
15:16:22 | FromDiscord | <leorize> depends on how you got the string |
15:16:59 | FromDiscord | <leorize> if it comes from a Nim string, it's memory is managed by the originating string so you don't have to |
15:18:06 | FromDiscord | <leorize> if it is allocated manually or originating from a C API for example, then it might have to be manually freed, but consult the API documentation in that case |
15:19:21 | FromDiscord | <leorize> wdym?↵(@ShalokShalom) |
15:19:43 | FromDiscord | <ShalokShalom> I was told, I can shorten my code this way |
15:19:56 | FromDiscord | <tracy> sent a code paste, see https://play.nim-lang.org/#ix=3QP1 |
15:20:00 | FromDiscord | <tracy> and when i run my c# code, it just crashes |
15:20:03 | FromDiscord | <tracy> im trying to use nim in c# as a dllw |
15:20:07 | FromDiscord | <tracy> why does this happen? 🤔 |
15:20:45 | FromDiscord | <tracy> i wrote the args wrong, but i didnt in the actual code |
15:21:14 | FromDiscord | <haolian9 (高浩亮)> sent a code paste, see https://play.nim-lang.org/#ix=3QP2 |
15:21:24 | FromDiscord | <ShalokShalom> leorize: line 17 - 30, see 11 - 14 as comparison https://media.discordapp.net/attachments/371759389889003532/947151369318580334/Screenshot_20220226_135252.png |
15:21:46 | FromDiscord | <ShalokShalom> I like to do it in a more memorable way |
15:22:07 | FromDiscord | <ShalokShalom> This looks like, I have to look up its syntax more often than I am willing to |
15:22:36 | FromDiscord | <ShalokShalom> Its not really a dedicated syntax, more a combination of basic structures. |
15:24:17 | FromDiscord | <tracy> the error: |
15:24:21 | FromDiscord | <tracy> sent a code paste, see https://play.nim-lang.org/#ix=3QP7 |
15:24:31 | * | ltriant joined #nim |
15:28:16 | FromDiscord | <haolian9 (高浩亮)> thank you! @leorize\:envs.net |
15:30:29 | * | ltriant quit (Ping timeout: 256 seconds) |
15:31:36 | FromDiscord | <ShalokShalom> @tracyIs this Jetbrains? |
15:31:37 | * | kayabaNerve quit (Ping timeout: 256 seconds) |
15:32:20 | FromDiscord | <tracy> In reply to @ShalokShalom "<@!946209778584137768>Is this Jetbrains?": is what |
15:32:31 | FromDiscord | <ShalokShalom> your screenshot |
15:32:36 | FromDiscord | <ShalokShalom> do you use the IDE? |
15:32:38 | FromDiscord | <ShalokShalom> for NIm |
15:32:52 | FromDiscord | <tracy> In reply to @tracy "": this error is from when i was calling it from c# |
15:32:58 | FromDiscord | <tracy> its a winform in vs |
15:32:58 | FromDiscord | <ShalokShalom> Ah |
15:33:04 | FromDiscord | <ShalokShalom> (edit) "NIm" => "Nim" |
15:47:00 | FromDiscord | <coldfussion> sent a code paste, see https://paste.rs/Avg |
16:04:09 | FromDiscord | <demotomohiro> Maybe how `cstringArray` and return value of `glfwGetRequi...` hold length of the array differently? |
16:04:26 | FromDiscord | <tracy> In reply to @tracy "": any1 kno a fix for this 🙁 |
16:07:56 | FromDiscord | <coldfussion> idk, `glfwGetRequiredInstanceExtensions` returns `const char` in C which should perfectly map to `cstringArray` in nim..↵(@demotomohiro) |
16:08:26 | Amun-Ra | sometimes ptr cstring is more preferrable to cstringArray |
16:10:08 | FromDiscord | <demotomohiro> https://nim-lang.org/docs/system.html#cstringArrayToSeq%2CcstringArray%2CNatural↵`cstringArrayToSeq()` has `len` parameter but your code doesn't set it. |
16:11:39 | Amun-Ra | you have to iterate over cstingArray to know the length |
16:13:10 | FromDiscord | <coldfussion> oh, yeah, that worked. it just has two versions, one without length, it worked in other cases, so i figured why bother with length... Thanks!↵(@demotomohiro) |
16:15:37 | FromDiscord | <demotomohiro> https://github.com/nim-lang/Nim/blob/d7370ce26962b3b82e6b9be6562f6e88ba7ff86c/lib/system.nim#L2267↵without length version suppose `cstringArray` is terminated by nil. |
16:16:46 | Amun-Ra | yes |
16:17:15 | Amun-Ra | cstringArray == ptr UncheckedArray[cstring] |
16:17:20 | FromDiscord | <coldfussion> oh, so the output of `glfwGetRequiredInstanceExtensions` wasn't nil terminated. makes sense now) |
16:18:04 | FromDiscord | <Phil> Maybe this is sports exhaustion speaking out of me... but how did I loop over a seq of objects again and mutate it's entries again? |
16:18:58 | Amun-Ra | for item in mitems the_sequence: do_sth |
16:19:28 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=3QPo |
16:19:40 | FromDiscord | <Phil> mitems iterator? riiiiight |
16:23:11 | Amun-Ra | there's mpairs iterator too (if you need to know the index value) |
16:27:34 | FromDiscord | <ShalokShalom> How do I map between two objects? |
16:28:33 | FromDiscord | <haxscramper> `std/tables` |
16:28:41 | FromDiscord | <haxscramper> (edit) "`std/tables`" => "`std/tables.Table`" |
16:35:22 | * | kayabaNerve joined #nim |
16:36:11 | * | Gustavo6046 joined #nim |
16:36:18 | FromDiscord | <ShalokShalom> I had a look through the documentation, and while it seems very comprehensive, it doesnt seem to cover my simple use case. |
16:37:26 | FromDiscord | <ShalokShalom> sent a code paste, see https://paste.rs/yfi |
16:38:00 | FromDiscord | <ShalokShalom> So to basically map one object to another, within an object. |
16:38:54 | FromDiscord | <tracy> how to check if string in any item of an array |
16:38:54 | FromDiscord | <tracy> ? |
16:39:46 | FromDiscord | <Phil> sequtils lib has what you're searching for tracy |
16:40:48 | FromDiscord | <tracy> In reply to @Isofruit "sequtils lib has what": whats the proc called 🤔 |
16:40:53 | FromDiscord | <Phil> you want an `any` proc, essentially you feed that an anonymous proc that determines whether an individual entry in the array passes or fails the test.↵If any of the entries in that array fails, "any" will return false |
16:41:34 | FromDiscord | <tracy> oh okay, tyy!! :)) |
16:41:37 | FromDiscord | <Phil> (edit) "test.↵If" => "test. The "test" being your anonymous proc that returns a boolean, passing being "true" returning↵If" |
16:42:33 | FromDiscord | <haxscramper> In reply to @ShalokShalom "I had a look": `Table[RoomId, Room]` |
16:42:38 | FromDiscord | <ShalokShalom> Thanks a lot |
16:43:24 | FromDiscord | <ShalokShalom> Do you see such an example of the official homepage? |
16:43:54 | FromDiscord | <Phil> In reply to @tracy "oh okay, tyy!! :))": No problemo |
16:44:55 | FromDiscord | <tracy> In reply to @Isofruit "No problemo": how do i use it i barely knwo this language im v new jmsadkf |
16:45:13 | FromDiscord | <Phil> In reply to @tracy "how do i use": Ah, you ever done functional programming? |
16:45:28 | FromDiscord | <tracy> In reply to @Isofruit "Ah, you ever done": is c# or python functional 🤔 |
16:45:50 | FromDiscord | <ShalokShalom> Is this correct code? |
16:45:51 | FromDiscord | <ShalokShalom> sent a code paste, see https://paste.rs/tQw |
16:46:05 | FromDiscord | <ShalokShalom> fine |
16:46:06 | FromDiscord | <auxym> In reply to @tracy "is c# or python": Imagine you were doing everything in LINQ |
16:46:07 | FromDiscord | <tracy> sent a code paste, see https://play.nim-lang.org/#ix=3QPv |
16:46:14 | FromDiscord | <ShalokShalom> In reply to @tracy "is c# or python": Both have functional features |
16:46:51 | FromDiscord | <ShalokShalom> Both, LINQ and generics, as well as a whole bunch of other implementations come straight out of F# |
16:47:01 | FromDiscord | <Phil> In reply to @tracy "is c# or python": python has the capability to use functional programming patterns. In python the closest thing would be ... god what was it called again, these types of expressions `[e for e in myArray]` |
16:47:05 | FromDiscord | <ShalokShalom> Generics in C# are actually done by the F# creator |
16:47:45 | FromDiscord | <auxym> In reply to @Isofruit "python has the capability": list comprehensions |
16:47:48 | FromDiscord | <ShalokShalom> And Python has this: https://github.com/cognitedata/Expression↵and this: http://coconut-lang.org/ |
16:47:56 | FromDiscord | <Phil> In reply to @tracy "is c# or python": thank you! Blanked on the name |
16:47:58 | FromDiscord | <ShalokShalom> And Fable can transpile F# into Python |
16:48:12 | FromDiscord | <Phil> (edit) "In reply to @tracy "is c# or python": thank you! Blanked on the name ... " added "@auxym (this was an accident, wanted to respond to tracy)" |
16:48:13 | FromDiscord | <tracy> sent a code paste, see https://play.nim-lang.org/#ix=3QPw |
16:48:14 | FromDiscord | <tracy> In reply to @ShalokShalom "And Fable can transpile": whats fabel |
16:48:15 | FromDiscord | <tracy> fable |
16:48:36 | FromDiscord | <Phil> Anyway, the idea is, that not only can you pass variables as parameters into a proc/function/whatever, you can also pass other procs into them as parameters |
16:48:57 | FromDiscord | <Phil> So that the proc you're handing parameters can call that specific proc at one point in its code |
16:49:35 | FromDiscord | <ShalokShalom> @haxscramper Would you agree, that its sensible to include an example, that explains my use case? Like in the documentation |
16:49:54 | FromDiscord | <ShalokShalom> https://fable.io/ |
16:50:03 | FromDiscord | <ShalokShalom> Mainly a F# > JS compiler |
16:50:12 | FromDiscord | <ShalokShalom> But it can also do Python, to a certain extend. |
16:50:16 | FromDiscord | <ShalokShalom> That feature is new. |
16:51:14 | FromDiscord | <ShalokShalom> (edit) |
16:51:55 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=3QPx |
16:51:58 | FromDiscord | <auxym> In reply to @ShalokShalom "<@!608382355454951435> Would you agree,": there's of examples of tables here? https://nim-lang.org/docs/tables.html |
16:53:22 | FromDiscord | <tracy> sent a code paste, see https://play.nim-lang.org/#ix=3QPy |
16:53:52 | FromDiscord | <Phil> What'll happen in my code example is, that the "any" proc will essentially call "largerThan4" on every entry in the array "blablaSeq" one after another. If an entry causes "largerThan4" to output "false", "any" completes immediately with "false". Otherwise it runs through the entire array, gets "true" every time and thus returns "true" itself |
16:54:55 | FromDiscord | <Phil> seqs have the "contains" proc if you have exact matches |
16:55:32 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=3QPz |
16:56:19 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=3QPz" => "https://play.nim-lang.org/#ix=3QPA" |
16:57:01 | * | acidsys joined #nim |
16:57:07 | FromDiscord | <tracy> this language so hard |
16:57:08 | FromDiscord | <tracy> 😭 |
16:57:15 | FromDiscord | <huantian> In reply to @tracy "im tryna do like": Does this not just work? |
16:57:25 | FromDiscord | <tracy> In reply to @huantian "Does this not just": thats python code |
16:57:43 | FromDiscord | <tracy> wait let me try it |
16:58:03 | FromDiscord | <tracy> oh wait it does |
16:58:03 | FromDiscord | <tracy> LOL |
17:00:31 | FromDiscord | <Phil> Seeing that nim has its own list comprehension syntax |
17:00:35 | FromDiscord | <Phil> Does anyone actually use that? |
17:00:44 | FromDiscord | <tracy> use what |
17:00:45 | FromDiscord | <tracy> 🤔 |
17:01:10 | FromDiscord | <locriacyber> collect↵(@Phil) |
17:01:13 | FromDiscord | <Phil> list comprehensions when "map, any, some, filter" etc. are readily available and seem easier to write and understand |
17:02:04 | FromDiscord | <tracy> In reply to @Isofruit "list comprehensions when "map,": map any some and filter seem hard idek what them mean |
17:02:42 | FromDiscord | <huantian> In reply to @Isofruit "list comprehensions when "map,": Collect is a lot fore readable when you are trying to do more complex things, like nesting for loops and ifs |
17:03:08 | FromDiscord | <huantian> Otherwise you’d get a tree of doom |
17:03:14 | FromDiscord | <Phil> In reply to @tracy "map any some and": They aren't really, you'll want to get into functional programming patterns either way sooner or later, wrapping your head around what happens when you pass a function to a function is fairly beneficial |
17:03:22 | FromDiscord | <Phil> In reply to @huantian "Otherwise you’d get a": tree as in AST |
17:03:33 | FromDiscord | <huantian> More as in indentation |
17:03:34 | FromDiscord | <Phil> (edit) "AST" => "AST?" |
17:03:44 | FromDiscord | <huantian> /visually |
17:03:52 | FromDiscord | <Phil> Ah, that. my solution tends to be dedicated procs because when you do something that complicated it deserves a name |
17:05:03 | FromDiscord | <Phil> Which I guess is why the usecase for collect hasn't happened for me yet, fair |
17:06:48 | * | Gustavo6046_ joined #nim |
17:06:58 | FromDiscord | <tracy> do u guys think cpp or nim is better |
17:07:01 | FromDiscord | <tracy> 🤔 |
17:07:15 | FromDiscord | <Phil> Got curious because I'd be surprised if C# didn't support functional programming features in one way or another. Turns out it does have those features |
17:07:52 | FromDiscord | <Phil> I'm not sure what answer you're expecting from literally the main channel of the nim discord server |
17:08:37 | FromDiscord | <tracy> idek what r pros n cons |
17:08:56 | FromDiscord | <Phil> Specifically to a question that pretty much has no answer without narrowing down its scope as to better in what regard |
17:09:01 | * | Gustavo6046 quit (Ping timeout: 240 seconds) |
17:09:26 | FromDiscord | <Phil> And even there it's insanely hard to answer due to the billion bells and whistles at your disposal typically |
17:10:40 | FromDiscord | <tracy> should i be learning nim as a noobish programmer cuz unlike python (a high level language) nim is like the opposite |
17:11:10 | FromDiscord | <Phil> Is it more memory safe? Certainly.↵Can it reach C++'s performance? Almost anything can if you're enough of a language expert and spend sufficient time optimizing your code.↵Is it more productive? 60% of that depends on the developer, though I'd naturally argue that nim is near the top of the list in terms of being comprehensible. |
17:12:26 | FromDiscord | <tracy> In reply to @Isofruit "Is it more memory": i tried writing cpp code and it is so hard to understand imo syntax wize n stuff |
17:12:52 | FromDiscord | <Phil> The mere nature of having to also deal with memory management opens you up to a whole host of avoidable bugs |
17:13:21 | FromDiscord | <Phil> (edit) "bugs" => "bugs↵And thus also to more complexity. As such nim is by nature simpler if you don't plan on removing the GC that is" |
17:13:37 | FromDiscord | <Phil> Which is something you can actually do in NIM IIRC |
17:13:42 | FromDiscord | <Phil> (edit) "NIM" => "nim" |
17:15:44 | FromDiscord | <Phil> As someone who started out with python/js/java knowledge and went to nim I'd say it's pretty nice to learn. |
17:16:28 | FromDiscord | <tracy> In reply to @Isofruit "As someone who started": ya i wanted to switch cuz the things i wanted to do in python were just not doable (low level kinda stuff) |
17:17:15 | FromDiscord | <Phil> In reply to @tracy "ya i wanted to": I'd suggest with keeping at it.↵One thing you might want to start wrapping your head around is code that runs at compile-time vs. code that runs at runtime |
17:18:21 | FromDiscord | <Phil> That's a significant difference to keep in mind that allows you to do quite a lot to speed up code.↵That and metaprogramming but I'd keep that under wraps for after a month or so of experience |
17:18:31 | FromDiscord | <tracy> oh, i also switched cuz i didnt like my source code being so easy to decompile |
17:19:18 | FromDiscord | <Phil> Can't say much about that |
17:19:54 | * | jjido joined #nim |
17:36:08 | FromDiscord | <ShalokShalom> In reply to @auxym "there's of examples of": Not in the way I was looking for them. |
17:37:09 | FromDiscord | <ShalokShalom> Like, this is how I have done it, and I think my use case is much more simple, than most of what is covered: https://github.com/ShalokShalom/fsharp-nim/blob/master/dev-aspect.nim#L58 |
17:37:49 | FromDiscord | <ShalokShalom> I frequently get the impression, that Nims documentation is generally covering a lot of niche cases, and adding a lot of details to everything. |
17:38:04 | FromDiscord | <ShalokShalom> And basically not covering basics in some cases. |
18:07:44 | * | Gustavo6046_ quit (Quit: Leaving) |
18:07:57 | * | Gustavo6046 joined #nim |
18:09:37 | * | ltriant joined #nim |
18:14:49 | * | ltriant quit (Ping timeout: 256 seconds) |
18:37:40 | NimEventer | New post on r/nim by Familiar_Ad_8919: is the vscode extension still being worked on?, see https://reddit.com/r/nim/comments/t23udx/is_the_vscode_extension_still_being_worked_on/ |
18:38:45 | FromDiscord | <b4mbus> What does really `isMainModule` mean? What does Nim consider as a `main module`? |
18:39:18 | FromDiscord | <b4mbus> > True only when accessed in the main module. This works thanks to compiler magic. It is useful to embed testing code in a module. |
18:39:23 | FromDiscord | <b4mbus> The docs dont really say much to me |
18:39:59 | NimEventer | New thread by Gcao: Anyone working on a new Nim book or second edition of Nim in Action?, see https://forum.nim-lang.org/t/8960 |
18:59:47 | NimEventer | New post on r/nim by plutoniator: Trouble trying to import a Cython module, see https://reddit.com/r/nim/comments/t24btz/trouble_trying_to_import_a_cython_module/ |
19:04:12 | Amun-Ra | b4mbus: are you familiar with python? |
19:04:36 | Amun-Ra | b4mbus: isMainModule is true if you compile the file directly, it's false if you import it |
19:05:04 | Amun-Ra | it's python's equivalent of if __file__ == '__main__' |
19:08:03 | FromDiscord | <b4mbus> I see, makes sense |
19:08:12 | FromDiscord | <b4mbus> another question - is there some kind of a `string_view` in Nim? |
19:08:17 | FromDiscord | <b4mbus> (edit) "`string_view`" => " C++'s `std::string_view`" |
19:08:29 | FromDiscord | <b4mbus> afair string and cstring always allocate? |
19:10:18 | Amun-Ra | what's the diff. between std::string and std::string_view? |
19:11:36 | FromDiscord | <b4mbus> `std::string` is a heap allocated string with SSO, `std::string_view` is just an immutable view for strings, ptr to the beggining + size (kinda like openArray is for seqs and arrays, string_view is for const char's, std::strings, etc.) |
19:11:54 | FromDiscord | <b4mbus> basically string_view doesnt allocate, it only "views" some data |
19:12:03 | FromDiscord | <b4mbus> I also dont suppose there are references in nim, some kinda: |
19:12:27 | FromDiscord | <b4mbus> sent a code paste, see https://play.nim-lang.org/#ix=3QQ9 |
19:12:28 | FromDiscord | <b4mbus> I only want to view message here |
19:12:37 | FromDiscord | <b4mbus> `proc foo(message: string)` will copy, wont it? |
19:12:41 | Amun-Ra | no |
19:12:45 | FromDiscord | <b4mbus> idk nim that much |
19:12:46 | FromDiscord | <b4mbus> oh? |
19:12:53 | Amun-Ra | I mean it will for very small objects |
19:13:50 | Amun-Ra | you can just pass a string |
19:15:16 | FromDiscord | <b4mbus> oh hmm |
19:15:18 | FromDiscord | <b4mbus> strings are immutable |
19:15:19 | FromDiscord | <b4mbus> I see |
19:15:31 | FromDiscord | <b4mbus> so nim uses COW refcounted strings I suppose |
19:15:44 | Amun-Ra | not in that case |
19:15:51 | Amun-Ra | proc foo(s: string) |
19:15:58 | Amun-Ra | s will always be immutable |
19:16:49 | Amun-Ra | proc foo(s: var string) is sth like foo(s: &std::string) |
19:18:07 | Amun-Ra | proc foo(s: string) == foo(s: const &std::string) |
19:18:35 | Amun-Ra | more or less |
19:20:34 | Amun-Ra | (there are also ref and var ref variants) |
19:35:24 | * | perro joined #nim |
19:37:24 | * | Gustavo6046 quit (Ping timeout: 240 seconds) |
19:41:14 | FromDiscord | <tracy> sent a code paste, see https://play.nim-lang.org/#ix=3QQ4 |
19:41:21 | FromDiscord | <tracy> why doesnt this get the code from the end of the file? |
19:49:26 | * | Gustavo6046 joined #nim |
19:59:02 | FromDiscord | <b4mbus> sent a code paste, see https://play.nim-lang.org/#ix=3QQn |
19:59:08 | FromDiscord | <b4mbus> (edit) "https://play.nim-lang.org/#ix=3QQn" => "https://play.nim-lang.org/#ix=3QQo" |
20:08:27 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
20:12:50 | FromDiscord | <b4mbus> actually the cannot evaluate at compile time is only `nimls` trippin |
20:12:57 | FromDiscord | <b4mbus> the other is still there tho |
20:13:22 | FromDiscord | <b4mbus> `[long path](34, 45) Error: identifier expected, but found '(needle) => msgCopy'` |
20:13:27 | FromDiscord | <b4mbus> I get nothing but that.... |
20:53:20 | FromDiscord | <Phil> @tracy recall how I wanted to point out to keep in mind when code runs at compile time and when at runtime? |
20:53:38 | FromDiscord | <Phil> Variable assignment has one of those things |
20:54:31 | FromDiscord | <Phil> let = variable assignment at runtime but variable is immutable ↵var = variable assignment at runtime, but variable is mutable↵const = variable assignment at compile time (which means no CPU cycles will be wasted assigning a value to this variable, it'll exist like that in the binary) |
20:54:48 | FromDiscord | <tracy> so can i write a const into the code or sm |
20:55:08 | FromDiscord | <Phil> Pretty much, keep in mind though that this also means you can't assign anything to a const var that isn't available at compile time |
20:55:27 | FromDiscord | <Phil> so you can access e.g. type definitions no problems |
20:55:28 | FromDiscord | <Phil> (edit) "problems" => "problem" |
20:55:35 | FromDiscord | <tracy> In reply to @Isofruit "Pretty much, keep in": how would i add in "const settings = "test" |
20:55:35 | FromDiscord | <Phil> (edit) "problem" => "problem. Those are there at compile time" |
20:55:49 | FromDiscord | <Phil> Specific object instances are not available at compile time though |
20:55:52 | FromDiscord | <Phil> add in where? |
20:55:56 | FromDiscord | <tracy> the exe |
20:56:01 | FromDiscord | <tracy> wait what are we talking aobut |
20:57:09 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=3QQH |
20:59:48 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=3QQI |
21:00:53 | FromDiscord | <Phil> This is for elaborating on what using "const" means |
21:01:54 | FromDiscord | <Phil> Since enthus1ast wanted to point you towards using const buffers or whatnot |
21:02:05 | FromDiscord | <tracy> what |
21:02:05 | FromDiscord | <tracy> is |
21:02:06 | FromDiscord | <tracy> buffer |
21:02:07 | FromDiscord | <tracy> 😭 |
21:03:19 | FromDiscord | <enthus1ast> const buffers for directly writing the configuration into the binary (withouth recompilation) i though that was the goal |
21:03:26 | FromDiscord | <tracy> yes it is |
21:03:27 | FromDiscord | <tracy> i just dont know |
21:03:28 | FromDiscord | <tracy> what a buffer is |
21:03:46 | FromDiscord | <enthus1ast> just a string or a array |
21:03:49 | FromDiscord | <Phil> That you can ask enthus1ast, never done file reading that way, I tend to use the bog standard solution:↵https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers#Reading-and-writing-files |
21:05:23 | FromDiscord | <Phil> A buffer is typically just something that temporarily stores something, amassing it until something is triggered and then acting on it all at once to make one big call rather than 50 small ones |
21:05:26 | FromDiscord | <Phil> e.g. writing a file |
21:05:49 | FromDiscord | <Phil> It makes more sense to first collect a bunch of text to write to disc and then hand all of it at once to the system to write into a file |
21:06:02 | FromDiscord | <Phil> Than it does making 500.000 individual requests for every single character |
21:06:37 | FromDiscord | <Phil> Buffer mechanisms are generally there to reduce the number of operations being made in a general sense |
21:06:59 | FromDiscord | <tracy> oh alr |
21:07:08 | FromDiscord | <Phil> Another scenario would be log messages |
21:07:57 | FromDiscord | <Phil> Where you can say "buffer me 100.000 log messages first before you send them all to my logging server"↵That way you make 1 big request towards your logging server rather than 100.000 individual ones |
21:08:05 | FromDiscord | <Phil> (edit) "server"↵That" => "server for storage"↵That" |
21:09:02 | FromDiscord | <Phil> Triggering a buffer to do its thing in the context of writing to disc is often referred to as flushing the buffer to disc |
21:09:16 | FromDiscord | <Phil> (edit) "Triggering a buffer to do its thing ... in" added "and send all of its contained data away" |
21:25:50 | * | jjido joined #nim |
21:49:34 | FromDiscord | <tracy> how i convert int64 to itn |
21:49:35 | FromDiscord | <tracy> int |
21:50:51 | nrds | <Prestige99> let i: int = (int) someInt64Variable |
21:51:01 | FromDiscord | <tracy> In reply to @nrds "<Prestige> let i: int": whats prestige |
21:51:08 | nrds | <Prestige99> That's me |
21:51:11 | FromDiscord | <tracy> oh mb |
21:51:12 | FromDiscord | <tracy> 😭 |
21:51:17 | nrds | <Prestige99> haha np |
21:54:04 | FromDiscord | <b4mbus> how do I determine if given Nim's data structures are thread safe or not? |
21:54:06 | nrds | <Prestige99> also you don't need the parentheses, I just do that out of habit |
21:54:35 | FromDiscord | <b4mbus> For example I have my own ErrorQueue, internally it uses a HeapQueue and I dont know if I should lock on every push operation or if the HeapQueue already does that |
21:54:41 | FromDiscord | <b4mbus> docs dont give any info |
21:54:51 | FromDiscord | <ynfle> In reply to @b4mbus "For example I have": Is it global? |
21:55:11 | FromDiscord | <b4mbus> In reply to @ynfle "Is it global?": is what global? |
21:55:19 | FromDiscord | <ynfle> In reply to @b4mbus "is what global?": The queue |
21:55:24 | FromDiscord | <ynfle> Is it a global variable? |
21:55:47 | FromDiscord | <b4mbus> if you mean the one of type ErrorQueue, not quite, it's a part of a bigger Application type, but yes, it's shared across different thread |
21:56:01 | FromDiscord | <b4mbus> I mean, ErrorQueue is a part of an ErrorHandler which is a part of Application |
21:56:42 | FromDiscord | <b4mbus> sent a code paste, see https://play.nim-lang.org/#ix=3QQV |
21:57:22 | FromDiscord | <b4mbus> Im not sure if that's a Nim idiomatic way but that's how I would do that in C++ so that's how Im doing it in Nim |
21:57:43 | FromDiscord | <b4mbus> IM going to post the full code for CR anyway |
21:57:54 | FromDiscord | <b4mbus> for now Im just gonnna implement it with locks; we'll see later |
21:58:59 | FromDiscord | <tracy> how do i write at a certain position with file streams |
22:03:00 | * | jmdaemon joined #nim |
22:11:11 | * | ltriant joined #nim |
22:15:57 | * | ltriant quit (Ping timeout: 256 seconds) |
22:18:09 | rockcavera | tracy https://nim-lang.org/docs/streams.html#setPosition%2CStream%2Cint |
22:19:20 | * | kenran quit (Quit: WeeChat info:version) |
22:40:31 | nrds | <Prestige99> Is there any noticeable mistake with this c binding? https://i.imgur.com/lbgL5Bs.png |
22:41:26 | nrds | <Prestige99> It seems like, when I'm running the code, that `zoom` is actually the x value and `zNear` is the y value |
22:43:36 | * | jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in) |
22:51:58 | * | jmdaemon joined #nim |
23:08:22 | FromDiscord | <Elegantbeef> @ShalokShalom\: seems fine, though i'd use a single `type` block fo them all, and the more important thing is the PIP Expanse watching 😛 |
23:09:21 | FromDiscord | <Elegantbeef> That seems fine prestige |
23:11:09 | FromDiscord | <Elegantbeef> Perhaps throw `{.packed.}` on it? |
23:12:47 | FromDiscord | <b4mbus> sent a code paste, see https://play.nim-lang.org/#ix=3QRj |
23:13:12 | FromDiscord | <Elegantbeef> `const defaultLoggingString = "[$levelname $date::$time]"` |
23:14:54 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
23:24:36 | FromDiscord | <ShalokShalom> In reply to @Elegantbeef "<@208199869301522432>\: seems fine, though": single type? |
23:25:12 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3QRn |
23:28:54 | FromDiscord | <b4mbus> In reply to @Elegantbeef "`const defaultLoggingString = "[$levelname": https://media.discordapp.net/attachments/371759389889003532/947274050294644766/unknown.png |
23:28:56 | FromDiscord | <b4mbus> not really? |
23:29:19 | FromDiscord | <b4mbus> but I guess it's bad design anyway I only use it in `newErrorHandler` |
23:29:23 | FromDiscord | <auxym> unindent it |
23:29:34 | FromDiscord | <auxym> it should not be part of the `type` block |
23:30:01 | FromDiscord | <b4mbus> so it's not possible to do what I want |
23:30:14 | FromDiscord | <b4mbus> I meant something like static class variables |
23:30:21 | FromDiscord | <Elegantbeef> No nim does not have default values for types |
23:30:24 | FromDiscord | <Elegantbeef> It defaults to `0` |
23:30:45 | FromDiscord | <Elegantbeef> You need to make constructors for the default behaviour |
23:31:35 | FromDiscord | <b4mbus> yeah |
23:31:41 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3QRo |
23:31:53 | FromDiscord | <Elegantbeef> Which lets you do `ErrorHandler.defaultLoggingString` |
23:32:01 | FromDiscord | <b4mbus> that's a thing yeah |
23:32:03 | FromDiscord | <Elegantbeef> make it return a `static string` if you want aswell to get it to kick in at CT |
23:32:18 | FromDiscord | <b4mbus> how do you even know you can do `typedesc[ErrorHandler]` when Nim's docs don't mention shit about it |
23:32:24 | FromDiscord | <b4mbus> except `magic type blah` |
23:32:40 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/manual.html#special-types-typedesc-t |
23:33:10 | FromDiscord | <b4mbus> oh? |
23:33:19 | FromDiscord | <b4mbus> manual vs docs |
23:33:23 | FromDiscord | <b4mbus> yeah right |
23:33:45 | FromDiscord | <b4mbus> sent a code paste, see https://paste.rs/GpY |
23:33:46 | FromDiscord | <b4mbus> (edit) "right" => "right, thanks" |
23:34:08 | FromDiscord | <Elegantbeef> You editted it so i cannot see it here, resend it 😛 |
23:34:14 | FromDiscord | <b4mbus> sure |
23:34:39 | FromDiscord | <b4mbus> sent a code paste, see https://play.nim-lang.org/#ix=3QRq |
23:35:32 | FromDiscord | <Elegantbeef> Ah a sugar issue, uhhh one second |
23:35:46 | FromDiscord | <Elegantbeef> Dont use lambda/anonymous procs much so might take a me a minute to reason |
23:36:18 | FromDiscord | <b4mbus> (generally I resolved this issue differently because this approach was wrong on a couple levels, but I still wanna know what is wrong with this) |
23:37:11 | FromDiscord | <Elegantbeef> Generially i say use `applyit` over apply, but yea i'll see if i can make that work |
23:37:46 | FromDiscord | <Elegantbeef> Hmm i cannot get it to play even remotely nice |
23:39:36 | FromDiscord | <Elegantbeef> No clue if that works in your case |
23:39:37 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3QRu |
23:40:32 | FromDiscord | <b4mbus> hmm? |
23:40:39 | FromDiscord | <b4mbus> why did u put `()` in there? |
23:40:54 | FromDiscord | <Elegantbeef> To make it know exactly what statement to use |
23:41:14 | FromDiscord | <b4mbus> okay so it's about how nim parses this |
23:41:25 | FromDiscord | <Elegantbeef> Well i didnt get the same error as you |
23:41:32 | FromDiscord | <Elegantbeef> So clearly i did something wrongish |
23:41:49 | FromDiscord | <b4mbus> oh, also |
23:41:55 | FromDiscord | <b4mbus> why do I have to specify the type here? |
23:42:14 | FromDiscord | <Elegantbeef> Like i said i dont use sugar, so i just guessed |
23:42:17 | FromDiscord | <b4mbus> nim doesnt even have generic lambdas? |
23:42:20 | FromDiscord | <b4mbus> okay, thanks anyway |
23:42:30 | FromDiscord | <Elegantbeef> generic lambdas dont make any sense imo |
23:42:52 | FromDiscord | <Elegantbeef> Firstly it's reversed type inference, secondly a specific type needs to be instantiated |
23:43:08 | FromDiscord | <Elegantbeef> Nim doesnt do reversed type inference |
23:43:16 | FromDiscord | <b4mbus> theyre nice, you dont always want to specify the type explicitly, especially if it doesnt matter or is inferable from an expression literally two characters later |
23:44:12 | FromDiscord | <Elegantbeef> Eh i generally stay away from anonymous procs, so no comment |
23:44:19 | FromDiscord | <b4mbus> ... also std/sugar shows examples of it working without specyfing the type |
23:44:30 | FromDiscord | <Elegantbeef> Well maybe i was wrong to add the type? |
23:44:38 | FromDiscord | <b4mbus> no, you were right |
23:44:41 | FromDiscord | <b4mbus> it doesnt compile without it |
23:45:10 | FromDiscord | <b4mbus> but I guess its because its a template |
23:45:17 | FromDiscord | <b4mbus> in C++ sich a thing wouldnt compile either |
23:45:22 | FromDiscord | <b4mbus> it would require lifting |
23:45:26 | FromDiscord | <Elegantbeef> It's not a template? |
23:45:28 | FromDiscord | <b4mbus> which is more work that simply specyfing the type |
23:45:31 | FromDiscord | <b4mbus> https://nim-lang.org/docs/sequtils.html#apply%2CopenArray%5BT%5D%2Cproc%28T%29_3 |
23:45:38 | FromDiscord | <b4mbus> > proc apply[T](s: openArray[T]; op: proc (x: T) {.closure.}) {.inline,↵> effectsOf: op.} |
23:45:39 | FromDiscord | <b4mbus> I mean, sorry |
23:45:41 | FromDiscord | <Elegantbeef> It's not a template |
23:45:42 | FromDiscord | <b4mbus> a generic |
23:45:47 | FromDiscord | <b4mbus> Nim has a different teminology |
23:45:47 | FromDiscord | <Elegantbeef> Ah |
23:46:07 | FromDiscord | <Elegantbeef> \~\~I'd argue more correct\~\~ 😛 |
23:46:11 | FromDiscord | <b4mbus> (edit) "> proc apply[T](s: openArray[T]; op: proc (x: T) {.closure.}) {.inline,↵> effectsOf: op.}" => "sent a code paste, see https://play.nim-lang.org/#ix=3QRv" |
23:46:29 | FromDiscord | <b4mbus> well yeah |
23:46:33 | FromDiscord | <huantian> maybe just use applyIt for now |
23:46:44 | FromDiscord | <Elegantbeef> Damn was just writing that `applyit` is just better |
23:46:49 | FromDiscord | <b4mbus> it took me some time to understand that templates in nim are not what templates in C++ are |
23:47:03 | FromDiscord | <b4mbus> hmm |
23:47:06 | FromDiscord | <b4mbus> yeah I see |
23:47:41 | FromDiscord | <Elegantbeef> Actually it doesnt work either it seems |
23:47:44 | FromDiscord | <b4mbus> Im not using it anyway, because as I stated before the apply thing was wrong anyway |
23:47:53 | FromDiscord | <b4mbus> But its still a valuable advice, thanksk |
23:47:56 | FromDiscord | <b4mbus> (edit) "thanksk" => "thanks" |
23:48:02 | FromDiscord | <Elegantbeef> Yea applyit expects a mutable collection |
23:48:18 | FromDiscord | <huantian> sent a code paste, see https://play.nim-lang.org/#ix=3QRx |
23:48:22 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/HUb |
23:48:54 | FromDiscord | <huantian> you might want map for what you're doing? |
23:49:16 | FromDiscord | <b4mbus> Ill repeat it third time ;d |
23:49:17 | FromDiscord | <b4mbus> Im not using it anyway, because as I stated before the apply thing was wrong anyway |
23:49:32 | FromDiscord | <b4mbus> (edit) "Im not using it anyway, because as I stated before the apply thing was wrong anyway ... " added "(Im not using apply or any similiar operation)" |
23:49:50 | FromDiscord | <huantian> sent a code paste, see https://play.nim-lang.org/#ix=3QRy |
23:50:14 | FromDiscord | <Elegantbeef> you might want to usue apply it 😜 |
23:50:16 | FromDiscord | <Elegantbeef> So it's a really mess |
23:50:16 | FromDiscord | <Elegantbeef> real\ |
23:50:19 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3QRz |
23:50:24 | FromDiscord | <b4mbus> sent a code paste, see https://play.nim-lang.org/#ix=3QRA |
23:50:24 | FromDiscord | <b4mbus> thats how I do it now |
23:51:16 | FromDiscord | <Elegantbeef> That's quite a inefficient way of doing it |
23:51:37 | FromDiscord | <b4mbus> I dont know shit about Nim :P |
23:51:41 | FromDiscord | <Elegantbeef> Probably doesnt matter though |
23:51:47 | FromDiscord | <huantian> In reply to @Elegantbeef "Joke aside to use": you'd probably want to use a discard map so you don't have to do a dup |
23:51:47 | FromDiscord | <b4mbus> so if there's anything to change, yeah, please correct me |
23:51:51 | FromDiscord | <ynfle> In reply to @b4mbus "if you mean the": So the queue is a global variable? I don't think it's threadsafe for writes |
23:52:00 | FromDiscord | <huantian> In reply to @huantian "you'd probably want to": but honestly a for loop is just better in this case if you're not using the result |
23:52:33 | FromDiscord | <b4mbus> In reply to @ynfle "So the queue is": its not literally global, but it is supppsed to be shared accross threads, yes |
23:52:43 | FromDiscord | <b4mbus> I implemented it with locks |
23:53:00 | FromDiscord | <b4mbus> if the locks are reduntant because seq/HeapQueue is threadsafe already Ill just remove that later |
23:53:01 | FromDiscord | <ynfle> In reply to @b4mbus "its not literally global,": So how do you share it? You pass a ref? |
23:53:11 | FromDiscord | <ynfle> In reply to @b4mbus "if the locks are": I don't think it is |
23:53:21 | FromDiscord | <b4mbus> In reply to @ynfle "So how do you": I havent gotten to that part of the implementation yet |
23:53:23 | FromDiscord | <Elegantbeef> Well the way to do it more efficiently is to iterate over the string if you hit a `$` check if the following characters are the replacement characters and if so plop in the new string and carry on the string from the end of it |
23:53:27 | FromDiscord | <b4mbus> Im starting from the very bits of the app |
23:54:48 | FromDiscord | <ajusa> sent a code paste, see https://play.nim-lang.org/#ix=3QRD |
23:55:34 | FromDiscord | <b4mbus> In reply to @Elegantbeef "Well the way to": oh actually, sorry |
23:55:44 | FromDiscord | <b4mbus> Ive pasted the wrong, old impl here, my bad |
23:56:01 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3QRE |
23:56:04 | FromDiscord | <Elegantbeef> dont need parseutils i guess |
23:56:14 | FromDiscord | <Elegantbeef> Ah |
23:56:20 | FromDiscord | <b4mbus> sent a code paste, see https://paste.rs/nf1 |
23:56:28 | FromDiscord | <b4mbus> this is the correct impl |
23:56:32 | FromDiscord | <b4mbus> and I guess I dont need dup here? |
23:56:52 | FromDiscord | <Elegantbeef> Ah still similar issue, multiple iterations, so if ever care about performance of this easy thing to tend to |
23:56:53 | FromDiscord | <b4mbus> sent a code paste, see https://paste.rs/2CG |
23:57:19 | FromDiscord | <Elegantbeef> Cause replace chained like that iterates the entire string mutliple times instead of once |
23:57:27 | FromDiscord | <b4mbus> hmm true |
23:57:29 | FromDiscord | <Elegantbeef> I was just commenting on a possible performance increase |
23:57:32 | FromDiscord | <huantian> or you can use multiReplace |
23:57:41 | FromDiscord | <b4mbus> great heavens |
23:57:43 | FromDiscord | <Elegantbeef> Oh right multi replace |
23:57:54 | FromDiscord | <Elegantbeef> Everyone forgets about multi replace |
23:58:00 | FromDiscord | <b4mbus> I was wondering why doesnt replace have any overload with an openArray or shi |
23:58:05 | FromDiscord | <b4mbus> Im going to check it out rn |
23:58:20 | FromDiscord | <Elegantbeef> I wonder does multiReplace store a set of the starting characters to optimize it? |
23:58:39 | FromDiscord | <Elegantbeef> It does! |
23:58:45 | FromDiscord | <Elegantbeef> So it's super efficient |
23:59:06 | FromDiscord | <b4mbus> oh not really |
23:59:12 | FromDiscord | <b4mbus> I cant really use multiReplace |
23:59:18 | FromDiscord | <Elegantbeef> Why not? |
23:59:21 | FromDiscord | <b4mbus> oh, no |
23:59:24 | FromDiscord | <b4mbus> sorry, my bad |
23:59:36 | FromDiscord | <b4mbus> it takes a string and a var array of tuples (original, replace) |
23:59:40 | FromDiscord | <Elegantbeef> Was going to say it's literally doing what you're doing just vastly more efficient |
23:59:40 | FromDiscord | <b4mbus> neeaaatt |
23:59:45 | FromDiscord | <ajusa> In reply to @ajusa "Any reason I could": figured out that error - it's because the type of `[]` is not possible to infer. How can I tell it that `[]` is of type `openArray[string, string]`? I tried a cast and that didn't work |