00:01:34 | * | xet7 quit (Remote host closed the connection) |
00:03:57 | * | xet7 joined #nim |
00:12:00 | * | jmd_ joined #nim |
00:25:08 | FromDiscord | <hotdog> In reply to @Corazone "Thank you so much,": No problem at all. I’d prefer the header style too, easier to add extra values if you need them in the future. Feel free to ping me on here if you have more questions or get stuck with it |
00:32:48 | FromDiscord | <huantian> In reply to @dani "Hi. I'm new to": I don’t think you can store `typedesc`s, even at compile time |
00:33:03 | FromDiscord | <huantian> Or at least not in an array like that? |
00:33:23 | FromDiscord | <huantian> Maybe you could make a macro to do it |
00:36:25 | FromDiscord | <iffy (Matt Haggard)> This code succeeds on the playground, but fails with SIGSEGV locally (nim 1.6.10). Locally, if I run with `--mm:orc` the assertion fails (`res` is empty string). Does the code fail for you locally? |
00:36:28 | FromDiscord | <iffy (Matt Haggard)> https://play.nim-lang.org/#ix=4h8Z |
00:40:22 | FromDiscord | <dani> @huantian thanks for the feedback. The idea is to store their string representation ( $ typedesc ). Should I walk the AST gathering their idents ? |
00:41:02 | FromDiscord | <huantian> sent a code paste, see https://play.nim-lang.org/#ix=4h91 |
00:41:21 | FromDiscord | <huantian> (edit) "https://play.nim-lang.org/#ix=4h91" => "https://play.nim-lang.org/#ix=4h92" |
00:42:02 | FromDiscord | <iffy (Matt Haggard)> I should also add, I'm on macOS. Running the same code in docker nimlang/nim\:1.6.10-alpine it works with `refc`, and fails with SIGSEGV with `orc` and `arc` |
00:42:30 | FromDiscord | <huantian> though the error with yours seems to be because of some weird interaction with generics and teypdesc |
00:43:55 | FromDiscord | <huantian> sent a code paste, see https://play.nim-lang.org/#ix=4h94 |
00:44:17 | FromDiscord | <Yepoleb> In reply to @iffy (Matt Haggard) "This code succeeds on": i think unsafeAddr dereferences the reference, but when you cast it back to `ptr[MyObj]` you get a pointer to a ref object |
00:46:22 | FromDiscord | <iffy (Matt Haggard)> I should back up. I'm trying to interface with a c library which accepts some data as a `void ` and later calls some of my procs with that same `void ` so my proc can use the associated data. I'm failing to get it right, so I made this minimal example. Now I'm yak shaving the example. Is it producing inconsistent behavior because I'm using `unsafeAddr` wrong? |
00:48:42 | FromDiscord | <dani> sent a code paste, see https://play.nim-lang.org/#ix=4h96 |
00:49:00 | FromDiscord | <dani> I'm trying to figure out how to harness the compile time magic. But it's difficult to find good introduction material about the topic. Can anyone point me to a good resource to learn from? |
00:57:05 | FromDiscord | <Yepoleb> In reply to @Yepoleb "i think unsafeAddr dereferences": i was wrong about that |
01:03:40 | FromDiscord | <iffy (Matt Haggard)> Alright, this works in all the places now\: https://play.nim-lang.org/#ix=4h98 Am I liable to run into problems storing the dereferenced `ref` address? https://play.nim-lang.org/#ix=4h98 |
01:08:16 | FromDiscord | <Yepoleb> you are still casting the dereferenced pointer to an implicit reference, because you defined MyObj as ref object |
01:08:50 | FromDiscord | <Yepoleb> i don't understand why it works lol |
01:09:09 | FromDiscord | <Yepoleb> imo you should define a non-ref base type and pass around pointers to that |
01:13:56 | * | arkanoid quit (Ping timeout: 268 seconds) |
01:15:31 | FromDiscord | <iffy (Matt Haggard)> Yeah, it doesn't feel right -- I think you're right |
01:23:44 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=4h9c |
01:24:25 | FromDiscord | <Rika> problem with first is you get a stack address (result.addr, points to stack of call to makeObj function) and that gets invalidated quickly |
01:24:50 | FromDiscord | <Rika> second is that you cast that stack address pointer (ptr ref object) into MyObj (ref object) |
01:29:48 | FromDiscord | <iffy (Matt Haggard)> Does `new` not allocate on the heap? |
01:30:19 | FromDiscord | <Yepoleb> hi rika |
01:30:44 | FromDiscord | <Rika> In reply to @iffy (Matt Haggard) "Does `new` not allocate": new allocates the ref |
01:31:05 | FromDiscord | <Yepoleb> thanks for the explanation, i forgot how references work internally for a moment |
01:31:28 | FromDiscord | <Rika> you dont want to mix references and pointers |
01:31:32 | FromDiscord | <Rika> they wont work right |
01:32:28 | FromDiscord | <iffy (Matt Haggard)> So changing it to `type MyObj = object` is likely a good idea, like Yepoleb said |
01:33:00 | FromDiscord | <Rika> if you really want `pointer` sure maybe |
01:33:08 | FromDiscord | <iffy (Matt Haggard)> Okay, I think I see (I'll need to think through it for a minute)↵(@Rika) |
01:33:44 | FromDiscord | <voidwalker> blah, I have a 4 byte string that has the values of an ipv4 address. How do I convert that to IpAdress type, which has array[0..3] uint8 type ? |
01:33:48 | FromDiscord | <iffy (Matt Haggard)> The library wanting a `void ` is my only requirement |
01:34:17 | FromDiscord | <Rika> if its a c library it is unlikely to understand a reference |
01:34:30 | FromDiscord | <voidwalker> Tried something like `IpAddress(family: IpAddressFamily.IPv4, address_v4: (cast[seq[uint8]](x[p..p+3])))` but I am not good with the casting, got `type mismatch: got 'seq[uint8]' for 'cast[seq[uint8]](x[p .. p + 3])' but expected 'array[0..3, uint8]'` |
01:34:32 | FromDiscord | <Rika> maybe you can do with some gcref or whatnot but thats not my territory |
01:34:42 | FromDiscord | <iffy (Matt Haggard)> It's doesn't interpret the data, it just passes it back as I passed it in |
01:35:24 | FromDiscord | <Rika> then maybe you can cast the ref to a pointer |
01:36:09 | FromDiscord | <Rika> `cast[pointer](result)` of course not really that safe because reference structure layout might change in the future etc |
01:36:56 | * | rockcavera joined #nim |
01:37:02 | FromDiscord | <Yepoleb> just combine dereference and addr and it should be safe |
01:37:20 | FromDiscord | <Yepoleb> instead of casting directly to pointer |
01:38:01 | FromDiscord | <Rika> then you get the issue of getting the address to the stack entry of the reference pointer again |
01:38:56 | FromDiscord | <Yepoleb> no, that's why you dereference first |
01:40:29 | FromDiscord | <iffy (Matt Haggard)> Looks like `thing = cast[pointer](result)` and `thing = result[].unsafeAddr` cause `thing` to have the same value (at least according to `.repr` w/ `--mm:refc`) |
01:41:05 | FromDiscord | <Yepoleb> yes, that's expected |
01:41:56 | FromDiscord | <iffy (Matt Haggard)> Oh, I thought you said "combine dereference and addr ... instead of casting directly to pointer" |
01:43:21 | FromDiscord | <Yepoleb> it does effectively the same thing, but the deref variant would still work with a changed reference layout |
01:43:37 | FromDiscord | <iffy (Matt Haggard)> oh, I see |
01:44:16 | FromDiscord | <iffy (Matt Haggard)> Well thank you both! |
01:44:55 | FromDiscord | <Yepoleb> you're welcome, thanks for the interesting question |
02:35:59 | FromDiscord | <ringabout> Can someone reproduce it on Macos? https://github.com/nim-lang/Nim/issues/20949 |
02:36:10 | FromDiscord | <ringabout> I cannot reproduce it on Windows or Linux. |
02:37:28 | NimEventer | New Nimble package! cgi - Helper procs for CGI applications in Nim., see https://github.com/nim-lang/cgi |
03:05:09 | FromDiscord | <iffy (Matt Haggard)> sent a long message, see http://ix.io/4h9D |
03:05:23 | FromDiscord | <iffy (Matt Haggard)> sent a long message, see https://paste.rs/lCd |
03:05:33 | FromDiscord | <iffy (Matt Haggard)> sent a long message, see http://ix.io/4h9F |
03:08:40 | FromDiscord | <ringabout> In reply to @iffy (Matt Haggard) "I can't repro\: \`\`\`$": I see. Thank you! |
04:00:57 | * | arkurious quit (Quit: Leaving) |
04:12:46 | * | derpydoo quit (Remote host closed the connection) |
04:21:56 | FromDiscord | <yrashk> Are there any efforts similar to `nimfmt` with some more recent activity? |
04:51:48 | FromDiscord | <voidwalker> trying to parse a string that has each 6bytes - ips/ports, encoded as 4bytes ip, 2 bytes port (in big endian order) |
04:52:13 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4ha0 |
04:52:20 | FromDiscord | <voidwalker> cand it be done better than this ? |
04:53:54 | FromDiscord | <voidwalker> (edit) "https://play.nim-lang.org/#ix=4ha0" => "https://play.nim-lang.org/#ix=4ha1" |
05:18:39 | FromDiscord | <ynfle> sent a code paste, see https://play.nim-lang.org/#ix=4ha4 |
05:19:37 | * | vicecea joined #nim |
05:24:22 | * | rockcavera quit (Remote host closed the connection) |
05:27:32 | FromDiscord | <ringabout> In reply to @ynfle "Anyone here have any": I dunno. But it works with ORC. |
05:28:03 | FromDiscord | <ringabout> Perhaps a gc issue. |
05:32:46 | FromDiscord | <ynfle> Doesn't work for me with orc |
05:32:54 | FromDiscord | <ynfle> Did you try hitting the endpoint? |
05:33:37 | FromDiscord | <ringabout> Yeah |
05:33:38 | FromDiscord | <ringabout> https://media.discordapp.net/attachments/371759389889003532/1047022506579595364/image.png |
05:34:04 | FromDiscord | <ringabout> I'm on windows. |
05:34:16 | FromDiscord | <ringabout> I also tested 1.6.8 |
05:36:16 | FromDiscord | <voidwalker> crashes for me on linux, 1.6.8, default everything |
05:42:30 | FromDiscord | <ynfle> Interesting I'm on 1.6.8 on macOs |
05:42:32 | FromDiscord | <ynfle> (edit) "macOs" => "macOS" |
05:44:22 | FromDiscord | <ringabout> In reply to @voidwalker "crashes for me on": Could you also try `--mm:orc`? |
05:48:54 | FromDiscord | <voidwalker> no crash with orc @ringabout |
05:49:13 | FromDiscord | <ringabout> That's weird. |
05:54:51 | FromDiscord | <ynfle> In reply to @ringabout "Could you also try": Same |
06:02:52 | * | ltriant quit (Ping timeout: 256 seconds) |
06:30:02 | * | ltriant joined #nim |
06:34:28 | * | ltriant quit (Ping timeout: 248 seconds) |
06:49:23 | * | jmd_ quit (Ping timeout: 265 seconds) |
07:36:54 | * | kenran joined #nim |
07:40:58 | * | PMunch joined #nim |
07:41:36 | * | kenran quit (Remote host closed the connection) |
08:20:42 | * | krydos joined #nim |
08:24:25 | FromDiscord | <luteva> Hi! I want to start using/learning macros and as my first "project" i would like to inspect an object that has a special field/property (to do some AST manipulation) and getting the caller (to intercept the call and do something before the call). So can anyone help me to start?↵I there a tutorial on macros that shows how to inspect objects, intercept calls and do something with it? |
08:25:02 | FromDiscord | <ShalokShalom> dumbTree |
08:25:07 | FromDiscord | <ShalokShalom> Gimme a second |
08:25:21 | FromDiscord | <ShalokShalom> https://dev.to/beef331/demystification-of-macros-in-nim-13n8 |
08:25:36 | FromDiscord | <ShalokShalom> @luteva |
08:36:51 | PMunch | @luteva, define "intercept" a call |
08:37:29 | PMunch | What you'd probably do is to create some kind of wrapper handler thing |
08:41:46 | FromDiscord | <tbrekalo> Is there a way to use gRCP with nim? Or something similar? |
08:44:13 | PMunch | @tbrekalo, is there a way? Of course. Is there a ready made library for Nim? Not so much |
08:46:38 | PMunch | If you just need some RPC maybe have a look here: https://nimble.directory/search?query=rpc |
08:47:30 | FromDiscord | <luteva> In reply to @PMunch "<@954521401073754212>, define "intercept" a": yes, exactly! any hint/starting point? |
08:48:46 | FromDiscord | <luteva> (edit) "point?" => "point?↵beside "demystification-of-macros"" |
08:51:58 | FromDiscord | <tbrekalo> In reply to @PMunch "<@894896849461325844>, is there a": Thanks 🙂 |
08:52:42 | PMunch | @luteva, what? I was asking you what you where trying to achieve.. |
08:57:32 | FromDiscord | <Vitality> how do i stop system.nim from including <string.h> |
08:58:09 | FromDiscord | <Yardanico> In reply to @Vitality "how do i stop": first of all, why do you need that? |
08:58:19 | FromDiscord | <Vitality> osdev |
08:59:10 | PMunch | I assume something like --os:any might do it |
08:59:27 | FromDiscord | <Yardanico> for that you don't avoid it, you usually write string.h implementation in Nim code yourself (or in C if you want to) and for example just add an empty string.h header |
08:59:33 | FromDiscord | <Yardanico> that's how hobby OSes in Nim did that |
08:59:59 | FromDiscord | <Yardanico> also make sure to at least also use `-d:useMalloc --gc:arc` |
09:00:17 | FromDiscord | <Yardanico> probably you'd want `-d:danger` too because it disables all the stack tracing and stuff (although you can disable that yourself separately too) |
09:00:42 | FromDiscord | <Vitality> ok |
09:05:47 | FromDiscord | <luteva> In reply to @PMunch "<@954521401073754212>, what? I was": uh sorry! I misunderstood. so what i would like to do is: inspect an object for a property (with a given type). And whenever the object has this property, do "something special" when the object is used. |
09:06:17 | FromDiscord | <Vitality> In reply to @Yardanico "for that you don't": wait how do i write that in nim |
09:06:49 | FromDiscord | <Yardanico> you just write nim code with functions with same name as in string.h that also have the exact same argument and return types |
09:06:58 | FromDiscord | <Vitality> oh |
09:08:34 | PMunch | @luteva, yes that's the same thing you said earlier, just with the words in a slightly different order |
09:08:46 | PMunch | I still don't exactly know what you're trying to achieve |
09:08:51 | FromDiscord | <luteva> like e.g. i could do some validation. whenever an email adress is set. or do some caching cleanup/updates whenever a value has changed. or somethign like this. |
09:09:10 | FromDiscord | <Rika> you dont need macros for that |
09:09:11 | NimEventer | New thread by drkameleon: Not able to get `in` for sets to work properly, see https://forum.nim-lang.org/t/9674 |
09:12:35 | FromDiscord | <luteva> i think i need macros as a would like to build a library, that could be dropped in just by using a pragma or a property of a special type in an object. so the code that uses this library is not yet written. So as far as i understand, i need some compiletime evaluation/AST manipulation etc. |
09:12:47 | FromDiscord | <luteva> (edit) "a" => "i" |
09:14:06 | FromDiscord | <luteva> but maybe i am totally wrong and this could be easier being done without macros? |
09:18:03 | FromDiscord | <luteva> also: the main goal for me is to learn about macros. so even if it is possible without macros, it could maybe help to do the same thing in two different ways: with and without macros. |
09:18:24 | PMunch | Try to write up an example of what you want |
09:19:43 | FromDiscord | <Phil> In reply to @luteva "i think i need": If you want to do something if pragma x is present (or not do something if pragma x is present) all you need is a template to build the pragma, when statements and the typetraits lib to be able to check if a given object / field is annotated with a pragma |
09:22:53 | FromDiscord | <Stuffe> does anyone know how to call name spaced functions in a dll from nim using the dynlib library? |
09:23:45 | FromDiscord | <Stuffe> For example `lib.symAddr("Galaxy::init")` doesn't work |
09:24:28 | PMunch | C++ does name mangling much the same way Nim does doesn't it? |
09:24:50 | PMunch | So the identifier in the binary wouldn't be called `Galaxy::init` any longer |
09:25:28 | PMunch | Since you mentioned DLL I guess you're on windows, but maybe you have something similar to `nm` on there which you can use to get the symbol table |
09:29:15 | FromDiscord | <luteva> how can i paste code? it is like ↵'''nim ↵#my code↵''' |
09:29:42 | FromDiscord | <Yardanico> yes, with triple backquotes |
09:29:49 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4haI |
09:30:10 | FromDiscord | <ringabout> Why does `nimble publish` require password? |
09:30:28 | FromDiscord | <ShalokShalom> Which password? |
09:30:36 | FromDiscord | <ringabout> > Output: remote: Support for password authentication was removed on August 13, 2021. |
09:30:37 | FromDiscord | <Yardanico> In reply to @ringabout "Why does `nimble publish`": because it pushes to github |
09:30:39 | FromDiscord | <ShalokShalom> Someone yesterday said, it requires a Github account |
09:30:44 | FromDiscord | <Yardanico> it forks the nimble packages repo |
09:30:51 | FromDiscord | <Yardanico> adds the package to the index and crates a PR |
09:30:54 | FromDiscord | <Yardanico> (edit) "crates" => "creates" |
09:31:04 | FromDiscord | <ringabout> I use a full access token but it doesn't work. |
09:31:05 | FromDiscord | <Yardanico> In reply to @ringabout "> Output: remote: Support": yes, use a token instead |
09:31:22 | FromDiscord | <ShalokShalom> It seems to try with password. |
09:31:45 | FromDiscord | <Stuffe> In reply to @PMunch "Since you mentioned DLL": Ok thanks I will check out `nm` |
09:31:50 | FromDiscord | <Yardanico> In reply to @ShalokShalom "It seems to try": you can use the token as a password |
09:31:52 | FromDiscord | <Yardanico> on github |
09:31:56 | FromDiscord | <ShalokShalom> Ah. |
09:32:45 | FromDiscord | <luteva> sent a code paste, see https://play.nim-lang.org/#ix=4haJ |
09:33:34 | FromDiscord | <arkanoid> Elegantbeef\: just landed on your blog post from 2020 about macros. Thanks! Very well done. Actually I'd be happy to read more posts like that |
09:33:54 | FromDiscord | <ringabout> In reply to @Yardanico "yes, use a token": Thanks, it is misleading. I tried with a full access token, it works. |
09:34:13 | FromDiscord | <ringabout> (edit) "works." => "works now." |
09:34:21 | FromDiscord | <Yardanico> yeah kind of, it's just not updated since nimble is not really maintained that much :P |
09:34:43 | FromDiscord | <luteva> sent a code paste, see https://play.nim-lang.org/#ix=4haK |
09:35:31 | FromDiscord | <luteva> (edit) "https://play.nim-lang.org/#ix=4haK" => "https://play.nim-lang.org/#ix=4haL" |
09:35:40 | FromDiscord | <ringabout> In reply to @Yardanico "yeah kind of, it's": I mean the pop window |
09:35:45 | FromDiscord | <ringabout> https://media.discordapp.net/attachments/371759389889003532/1047083432393576478/image.png |
09:36:40 | FromDiscord | <ringabout> (edit) "In reply to @Yardanico "yeah kind of, it's": I mean the pop window ... " added "of GitHub" |
09:36:41 | FromDiscord | <Yardanico> well blame github for that |
09:36:53 | FromDiscord | <Yardanico> vscode just does the usual Git stuff, and Git knows username and password |
09:37:01 | FromDiscord | <Yardanico> it is github that removed password auth and replaced it with tokens :P |
09:37:57 | FromDiscord | <ringabout> Yeah |
09:38:50 | FromDiscord | <ShalokShalom> Funny, considering they are both done my the same company |
09:39:00 | FromDiscord | <Yardanico> In reply to @ShalokShalom "Funny, considering they are": what? |
09:39:06 | FromDiscord | <Yardanico> ah, you mean vscode, meh |
09:39:11 | FromDiscord | <Yardanico> vscode integrates with Git first of all |
09:39:24 | FromDiscord | <Yardanico> that popup is integrated with git, not github |
09:39:49 | FromDiscord | <ShalokShalom> Yep |
09:39:52 | FromDiscord | <ShalokShalom> I know |
09:39:59 | FromDiscord | <ShalokShalom> Still, it creates issues |
09:40:21 | FromDiscord | <ShalokShalom> And I mean, VSCode could at least say "Password or Token" |
09:40:39 | FromDiscord | <ShalokShalom> That would already create a much clearer context 🙂 |
09:50:39 | FromDiscord | <ringabout> https://github.com/nim-lang/packages/pulls/ringabout more stdlibs are going to move to nimble packages, especially some libraries which are used internally. |
09:52:35 | FromDiscord | <ringabout> Once I can manage to have the corresponding PR pass CI. |
10:10:53 | * | dnh joined #nim |
10:19:51 | NimEventer | New Nimble package! asyncftpclient - FTP client implementation (originally in the stdlib)., see https://github.com/nim-lang/asyncftpclient |
10:35:27 | FromDiscord | <emanresu3> Is there a way to coalesce a seq indexation to false if the index is not reachable? |
10:37:02 | NimEventer | New post on r/nim by ModishNouns: xmltree: Attrs in closing tag?, see https://reddit.com/r/nim/comments/z7qdlc/xmltree_attrs_in_closing_tag/ |
10:37:20 | FromDiscord | <Yardanico> In reply to @emanresu3 "Is there a way": what do you mean by false? and no, I don't think there is if you mean "return something else if seq doesn't have this index" |
10:37:33 | FromDiscord | <Yardanico> but it's just a few lines of code to do |
10:39:29 | FromDiscord | <emanresu3> If I want to grab myseq[3], but there's no element in index 3, I would like to get false |
10:39:52 | FromDiscord | <Yardanico> but wouldn't that be a different type from your seq's type? |
10:39:55 | FromDiscord | <Yardanico> or your seq contains booleans? |
10:40:18 | FromDiscord | <Yardanico> nim is statically typed after all, so if you want multiple types then you need extra stuff like object variants |
10:40:25 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4haS |
10:40:26 | FromDiscord | <Yardanico> this is what i meant with just a few lines of a proc |
10:40:29 | FromDiscord | <Kermithos> In reply to @ringabout "https://github.com/nim-lang/packages/pulls/ringabou": will httpclient be moved out of the stdlib too? |
10:40:43 | FromDiscord | <ringabout> No |
10:40:59 | FromDiscord | <Yardanico> In reply to @Kermithos "will httpclient be moved": httpclient is used quite commonly white asyncftpclient not at all :P |
10:41:16 | FromDiscord | <Kermithos> yea thats true |
10:41:37 | FromDiscord | <Kermithos> so only unpopular packages are moved out of stdlib? |
10:41:41 | FromDiscord | <ringabout> Only if it doesn't break too many important packages because I'm too lazy to fix them all 😛 |
10:41:57 | FromDiscord | <ringabout> There is a RFC |
10:42:19 | FromDiscord | <ringabout> (edit) "a RFC" => "an RFC." |
10:42:48 | FromDiscord | <ringabout> (edit) "There" => "Joking aside, there" | "RFC." => "RFC for the list." |
10:43:22 | FromDiscord | <emanresu3> No it doesn't, yeah my bad. I'm instead trying to get a boolean comparing a seq's value↵(@Yardanico) |
10:43:30 | FromDiscord | <ringabout> In reply to @Kermithos "so only unpopular packages": https://github.com/nim-lang/RFCs/issues/473 |
10:43:45 | FromDiscord | <Yardanico> In reply to @emanresu3 "No it doesn't, yeah": can you show example code that you'd like to work? |
10:43:49 | FromDiscord | <Kermithos> okay, thank you |
10:44:32 | FromDiscord | <emanresu3> sent a code paste, see https://play.nim-lang.org/#ix=4haT |
10:44:43 | FromDiscord | <emanresu3> In a loop |
10:45:14 | FromDiscord | <emanresu3> So when the seq is empty, indexation no longer works and I'd like to get a false from that comparison |
10:45:49 | FromDiscord | <Yardanico> you can make it simpler, and actually should, since modifying a seq during iteration isn't really allowed |
10:46:34 | FromDiscord | <Yardanico> but again, instead of those you can just check the seq length |
10:46:43 | FromDiscord | <Yardanico> you don't need any special stuff, just check if seq length is == 0 |
10:48:50 | FromDiscord | <emanresu3> Yeah, I tried with with sorting the array first, and then pop, but still there's an error at some point, I could check the seq's length, but I didn't want to add another conditional, since entering that loop already checks the seq's length↵(@Yardanico) |
10:49:23 | FromDiscord | <Yardanico> then can you give a bit more code? I don't see how checking if the seq is empty is different from checking `seq.length == 0` |
10:49:28 | FromDiscord | <Yardanico> (edit) "`seq.length" => "`seq.len" |
10:50:15 | FromDiscord | <Yardanico> i just feel like your code can be implemented in a shorter way but I don't know what exactly you want to do with the seq values and seq itself |
10:50:59 | FromDiscord | <emanresu3> alright just give me a minute |
10:55:32 | FromDiscord | <luteva> In reply to @Isofruit "If you want to": do you have any concrete example of that? |
10:55:59 | FromDiscord | <ShalokShalom> sent a long message, see http://ix.io/4haV |
10:56:15 | FromDiscord | <ShalokShalom> (edit) "http://ix.io/4haV" => "http://ix.io/4haW" |
10:56:45 | FromDiscord | <Yardanico> I don't think "functionalprogramming" is a good tag though :P |
10:57:00 | FromDiscord | <ShalokShalom> Yeah, I didnt knew how to do that |
10:57:00 | FromDiscord | <Yardanico> just "functional" |
10:57:04 | FromDiscord | <emanresu3> Hello @ShalokShalom that's awesome, thanks a lot!↵(@ShalokShalom) |
10:57:06 | FromDiscord | <ShalokShalom> yeah, was thinking about that |
10:57:16 | FromDiscord | <ShalokShalom> Can I just add a PR, that changes that? |
10:57:22 | FromDiscord | <ShalokShalom> Ah, I know how to do. |
10:57:24 | FromDiscord | <Yardanico> just edit your PR itself? |
10:57:28 | FromDiscord | <ShalokShalom> Yeah |
10:57:30 | FromDiscord | <Yardanico> no need to create another one |
10:57:59 | FromDiscord | <emanresu3> Here's the code I'm trying to simplify https://codeberg.org/emanresu3/nim-pipexp/src/commit/6acf3675541b7ebef866af301887538696eb4792/src/pipexp.nim#L33↵(@Yardanico) |
10:59:28 | FromDiscord | <ShalokShalom> done |
10:59:48 | FromDiscord | <ShalokShalom> In reply to @Yardanico "no need to create": yeah, this was what I meant, its just early in the morning and my English is still sleeping 😄 |
11:01:41 | FromDiscord | <emanresu3> So I'm doing an `in` in the conditional, but since the seq `u` is sorted I though I could optimize it by checking the first index [0] and then deleting the first element. But if I do that, when the seq is empty it raises an error |
11:02:13 | FromDiscord | <Yardanico> well optimization here is really a minor thing since it's a macro and doesn't do thousands of iterations, so it's all precomputed at compile-time and doesn't affect runtime |
11:02:21 | FromDiscord | <Yardanico> i don't think deleting the elements would actually speed it up |
11:03:37 | FromDiscord | <Yardanico> but if you meant shorten, you can for example replace that loop with ` for i, elem in fn: result.add if i in u: arg else: elem` |
11:03:43 | FromDiscord | <Yardanico> with the newlines back of course :P |
11:03:59 | FromDiscord | <emanresu3> I see, I thought so, and since this is an operator that pipes into another proc, I don't think people should use that many parameters in their procs to begin with |
11:05:08 | FromDiscord | <Yardanico> does the multiple placeholder branch already has tests for that? |
11:05:17 | FromDiscord | <Yardanico> so i can check |
11:08:21 | FromDiscord | <emanresu3> Not yet, I'll add them in a bit when I put the new proc in the other `pipe` macro↵(@Yardanico) |
11:08:47 | FromDiscord | <Phil> sent a long message, see http://ix.io/4hb2 |
11:09:40 | FromDiscord | <Phil> (edit) "http://ix.io/4hb2" => "http://ix.io/4hb3" |
11:09:58 | FromDiscord | <Yardanico> In reply to @emanresu3 "I see, I thought": wait so this multiple placeholder thing is only for when people want to pass the same argument more than once? |
11:10:27 | FromDiscord | <Phil> (edit) "http://ix.io/4hb3" => "http://ix.io/4hb4" |
11:10:43 | FromDiscord | <Yardanico> also you can just remove the separate conditional for u.len == 0, since you check with `in` anyway and if `u` is empty then it'll just never hit that branch |
11:15:10 | FromDiscord | <Phil> Sometimes I wonder if I'm overdoing it with my desire to do all the stuff that I do in generics and with compiletime procs |
11:15:21 | FromDiscord | <Phil> But it just works so well |
11:17:40 | FromDiscord | <emanresu3> @Yardanico\: I just pushed tests for that branch↵(@Yardanico) |
11:18:07 | FromDiscord | <Yardanico> okay |
11:18:18 | FromDiscord | <emanresu3> Yeah, to multiple arguments, do you think is it not a good idea?↵(@Yardanico) |
11:18:49 | FromDiscord | <Yardanico> i mean it's nice to support, but I doubt anyone would actually need that |
11:18:50 | FromDiscord | <emanresu3> The argument comes from a previous pipe so I though it would be convinient |
11:18:55 | FromDiscord | <luteva> In reply to @Isofruit "Sometimes I wonder if": one day, every developer will do so and we all know why.... it's just a matter of time 😄 |
11:19:06 | FromDiscord | <Yardanico> i mean passing the same argument multiple times into the same proc |
11:19:18 | FromDiscord | <Yardanico> but it's okay to support it, even for consistency |
11:20:39 | FromDiscord | <luteva> so: declaring a custom pragma is (always?) done using a template? or is this just a specific case? |
11:20:51 | FromDiscord | <luteva> (edit) "specific" => "special" |
11:24:10 | FromDiscord | <emanresu3> It doesn't pass `nimble test` thou↵(@Yardanico) |
11:24:30 | FromDiscord | <Yardanico> yeah I didn't fully understand the code when i said that, now I do :P |
11:24:48 | FromDiscord | <emanresu3> I'll add comments, yeah |
11:25:58 | FromDiscord | <Yardanico> i mean your code looks simple enough already, there isn't much left to simplify |
11:27:35 | FromDiscord | <Yardanico> well there is one possibility of shortening it a bit |
11:29:16 | FromDiscord | <Yardanico> or not, I thought you can insert 1 to u if it's empty, but it changes the code because fn[1] wouldn't get inserted |
11:30:24 | FromDiscord | <Yardanico> even then you can shorten it, but it'll be a bit weird |
11:30:39 | FromDiscord | <Yardanico> basically this https://media.discordapp.net/attachments/371759389889003532/1047112350672633886/image.png |
11:30:55 | FromDiscord | <Yardanico> it will always check `if i in u` even if u is empty, but we get less code :P |
11:31:05 | FromDiscord | <Yardanico> and it wouldn't really matter for compilation speed at this scale |
11:40:43 | FromDiscord | <Phil> In reply to @luteva "so: declaring a custom": I'm not sure about always or if it's even possible to do with macros, but I haven't seen a usecase where I'd need to do it in any other way.↵I can only exclude procs so far from being able to do pragmas... on the sole basis that I've never seen it done |
11:41:39 | FromDiscord | <Phil> This is a "special case" in the sense though that it's a pragma with a value |
11:41:40 | FromDiscord | <luteva> In reply to @Isofruit "I'm not sure about": oh i found it:↵https://nim-lang.org/docs/manual.html#userminusdefined-pragmas-custom-annotations |
11:42:05 | FromDiscord | <luteva> (edit) "it:↵https://nim-lang.org/docs/manual.html#userminusdefined-pragmas-custom-annotations" => "it:↵https://nim-lang.org/docs/manual.html#userminusdefined-pragmas-custom-annotations↵so thx, phil!" |
11:42:07 | FromDiscord | <Yardanico> yeah for pragma _annotations_ you just use templates with the pragma pragma |
11:42:21 | FromDiscord | <Yardanico> yes, it is called a pragma pragma btw |
11:42:22 | FromDiscord | <Yardanico> https://nim-lang.org/docs/manual.html#userminusdefined-pragmas-pragma-pragma |
11:42:28 | FromDiscord | <Yardanico> pragma pragma pragma pragma |
12:20:03 | NimEventer | New thread by sls1005: Ideas about the exception-tracing system, see https://forum.nim-lang.org/t/9675 |
12:37:30 | FromDiscord | <emanresu3> Oh interesting, thanks, yeah if the code is so small then it wouldn't matter, but I'm thinking if anyone would use this pipe operator thousands of times in their codebase, their compilation time could scale badly↵(@Yardanico) |
12:37:57 | FromDiscord | <Yardanico> nope, I think even 1000 times wouldn't slow it down at all |
12:38:27 | FromDiscord | <Yardanico> You can actually check, just generate a Nim file with 10000 lines :P |
12:40:53 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4hbi |
12:41:28 | FromDiscord | <sOkam!> it seems to be breaking the code that i had before, which was using `GLEnum` from nimgl/opengl. But switched to the official bindings and having this probl |
12:50:43 | FromDiscord | <Phil> In reply to @sOkam! "Can you define a": IIRC types are compile-time information that goes away at runtime |
12:50:48 | FromDiscord | <Phil> (edit) "goes" => "go" |
12:51:16 | FromDiscord | <Phil> Feel free to correct me here Yard, that's just how I keep explaining to myself why I can't have seqs of typedescs |
12:52:45 | FromDiscord | <Phil> ~~Because if I could have seqs of typedescs, my job with snorlogue would be a crapton easier~~ |
13:08:24 | FromDiscord | <arkanoid> In my head types just vanish during compilation. They don't/can't exist at runtime |
13:08:37 | FromDiscord | <arkanoid> Correct me too if I'm wrong |
13:12:33 | FromDiscord | <sOkam!> nvm, i was needing to use `cGL_FLOAT` which is a GLEnum, instead of `GLFloat` which is a typedesc 🤷♂️ |
13:42:42 | * | bola joined #nim |
13:45:41 | * | bola quit (Client Quit) |
13:48:48 | * | derpydoo joined #nim |
13:55:41 | FromDiscord | <ali> More nuanced I'd say. Size differences obviously remain |
13:57:07 | FromDiscord | <huantian> The object will keep type information if you make it an `object of RootObj` |
14:15:04 | FromDiscord | <ali> More nuanced I'd say. Size differences obviously remain (so do floats) [realised this is entirely unrelated] |
14:29:41 | FromDiscord | <VisakhChekur (VisakhChekur)> Hi. I just started learning Nim and I was going through Nim in Action. It mentions that sets are used to represent a collection of unique flags whereas in C flags are represented by integers. It also mentions that the approach taken by C is unsafe. Why is that? |
14:42:05 | * | derpydoo quit (Ping timeout: 265 seconds) |
14:42:39 | FromDiscord | <planetis> well it's simple, if a function takes an enum the parameter is of that type, but when it expects a set it's set[T] |
14:43:51 | FromDiscord | <planetis> but with C bit flags it's all the same, so you can pass an OR'ed values when it should have been just a single flag |
15:01:49 | * | PMunch quit (Quit: Leaving) |
15:38:03 | * | LuxuryMode joined #nim |
15:40:14 | * | Phytolizer joined #nim |
15:42:38 | FromDiscord | <A Very Merry Reimu ッ> when is the general rule of using `method` vs `func`/`proc` |
15:46:54 | Phytolizer | `method` is for when you need dynamic dispatch, ie when you're doing OOP. if you aren't doing that, the other two are preferable |
15:49:05 | FromDiscord | <A Very Merry Reimu ッ> will `method` allow me to have two "classes" with seperate `visit` functions defined? |
15:50:04 | Phytolizer | yes, and itll pick the correct one |
15:50:20 | FromDiscord | <A Very Merry Reimu ッ> so then i would want to use method right |
15:50:28 | Phytolizer | whereas if you have a base object ref and call a proc on it, it will always pick the base version |
15:50:37 | Phytolizer | yeah that application makes sense |
15:51:37 | FromDiscord | <choltreppe> is there a way to get line/column num of where NimNode is in code ? |
15:56:09 | NimEventer | New Nimble package! smtp - SMTP client implementation (originally in the stdlib)., see https://github.com/nim-lang/smtp |
16:05:25 | * | derpydoo joined #nim |
16:10:30 | FromDiscord | <locria> How do I hide a field from struct in the default `$` implementation |
16:26:48 | * | Phytolizer quit (Ping timeout: 260 seconds) |
16:27:58 | * | Phytolizer joined #nim |
16:30:12 | FromDiscord | <auxym> define your own $ implementation |
16:31:48 | * | wallabra quit (Ping timeout: 265 seconds) |
16:35:17 | NimEventer | New thread by samdze: Polymorphism doesn't work building a dylib for Playdate (Cortex M7) with ARC, see https://forum.nim-lang.org/t/9676 |
16:36:57 | * | wallabra joined #nim |
16:42:12 | * | wallabra quit (Ping timeout: 264 seconds) |
16:58:42 | * | wallabra joined #nim |
17:09:33 | FromDiscord | <Phil> Question, anyone have an idea how these docs were generated?↵http://filcuc.github.io/nimqml/ |
17:11:23 | FromDiscord | <locria> nimdoc |
17:11:33 | FromDiscord | <locria> (edit) "nimdoc" => "nim doc" |
17:11:43 | FromDiscord | <Jessa> Woot, working custom REPL for windows https://media.discordapp.net/attachments/371759389889003532/1047198185690505296/2022-11-29_18-09-59.mp4 |
17:13:10 | FromDiscord | <Phil> Hmmm I've only seen those for doc-comments for individual modules |
17:28:46 | * | jmdaemon joined #nim |
17:39:25 | * | pro joined #nim |
17:39:59 | * | pro left #nim (#nim) |
17:54:19 | FromDiscord | <@thatrandomperson5-6310e3b26da03> sent a code paste, see https://play.nim-lang.org/#ix=4hcU |
17:54:47 | FromDiscord | <@thatrandomperson5-6310e3b26da03> sent a code paste, see https://play.nim-lang.org/#ix=4hcV |
17:54:51 | FromDiscord | <@thatrandomperson5-6310e3b26da03> sent a code paste, see https://play.nim-lang.org/#ix=4hcU |
18:00:14 | FromDiscord | <@thatrandomperson5-6310e3b26da03> Never mind, i found the issue |
18:07:07 | * | dnh quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
18:07:34 | * | dnh joined #nim |
18:11:21 | FromDiscord | <@thatrandomperson5-6310e3b26da03> How would i do these charchters and not those, right now im using this\: `{' '..'~'} !{'\\','"'}` and i don’t think it’s working |
18:12:11 | * | dnh quit (Ping timeout: 264 seconds) |
18:22:31 | FromDiscord | <Phil> I will admit I could read pretty much none of that... was that because matrix mangled it up? |
18:22:46 | FromDiscord | <Phil> This is what I got https://media.discordapp.net/attachments/371759389889003532/1047216065769373757/image.png |
18:23:16 | FromDiscord | <Phil> Can't say I understand anything that's going on there |
18:29:37 | FromDiscord | <hotdog> In reply to @@thatrandomperson5-6310e3b26da03 "How would i do": You can subtract sets, try `({' '..'~'} - {'\\','"'})` |
18:29:49 | FromDiscord | <hotdog> Though it might not work in npeg |
18:30:02 | FromDiscord | <hotdog> (thatrandomperson5-6310e3b26da03) |
18:30:57 | FromDiscord | <hotdog> In reply to @Isofruit "Can't say I understand": I think peg parser grammar using https://github.com/zevv/npeg |
18:31:15 | NimEventer | New post on r/nim by Outrageous_Stomach_8: Godot projects to learn from, see https://reddit.com/r/nim/comments/z81v2t/godot_projects_to_learn_from/ |
18:43:10 | * | ltriant joined #nim |
18:48:19 | * | ltriant quit (Ping timeout: 260 seconds) |
19:40:18 | * | arkurious joined #nim |
19:43:42 | FromDiscord | <ShalokShalom> Hey, that looks quite cool |
19:43:43 | FromDiscord | <ShalokShalom> https://github.com/status-im/questionable |
19:45:13 | * | pro joined #nim |
19:45:54 | FromDiscord | <huantian> `?!int` always looked kinda funny fro me |
19:45:58 | FromDiscord | <huantian> it's like they're confused and angry |
19:46:21 | FromDiscord | <huantian> it is cool tho |
19:51:32 | FromDiscord | <ShalokShalom> yeah |
19:51:38 | FromDiscord | <ShalokShalom> I like it cause its expressive |
19:51:50 | FromDiscord | <ShalokShalom> And true, it looks like its angry and confused a bit ^^ |
20:28:29 | FromDiscord | <guttural666> sent a long message, see http://ix.io/4hdP |
20:30:51 | FromDiscord | <amadan> You could use `inNanoseconds` first (or one of the other inUnit procs for what ever precision you want) and then get the average time in that unit |
20:32:37 | FromDiscord | <guttural666> In reply to @amadan "You could use `inNanoseconds`": yeah, this sounds really reasonable, gonna try and implement that |
20:32:43 | FromDiscord | <guttural666> thanks! |
20:39:41 | FromDiscord | <guttural666> just made sure my expected micro seconds won't overflow an int64 like an idiot 😄 |
20:45:22 | * | pro quit (Quit: pro) |
20:45:37 | * | pro joined #nim |
20:53:47 | * | ltriant joined #nim |
20:55:34 | FromDiscord | <Yepoleb> i always work in float seconds whenever it is reasonable |
21:05:30 | * | junaid_ joined #nim |
21:07:20 | FromDiscord | <guttural666> user will know millisecond differences, so I'm choosing microseconds |
21:07:27 | FromDiscord | <guttural666> (edit) "user" => "users" |
21:08:14 | FromDiscord | <guttural666> any tips on how to juggle int <> int64 conversions, most algos in the std seem to be written for the more generic int |
21:08:39 | FromDiscord | <guttural666> time prefers the explicit 64 bit int so the compiler is mad at me 🙂 https://media.discordapp.net/attachments/371759389889003532/1047257807981912184/image.png |
21:08:50 | FromDiscord | <guttural666> toFloat uses the generic int |
21:09:29 | * | pro quit (Quit: pro) |
21:09:39 | FromDiscord | <Generic> What function do you need which is only available for int? |
21:11:13 | FromDiscord | <guttural666> the avg time calculation foldl all the int64 durations and devides it by the int64 number of items, which yields an int64, which toFloat does not approve of 😄 |
21:11:37 | FromDiscord | <Generic> Ah the string functions |
21:12:00 | FromDiscord | <Generic> Don't they use BiggestInt though? |
21:12:24 | FromDiscord | <guttural666> string functions= |
21:12:25 | FromDiscord | <guttural666> ? |
21:12:34 | FromDiscord | <guttural666> (edit) "functions=" => "functions?" |
21:12:43 | FromDiscord | <guttural666> not using any here |
21:13:19 | FromDiscord | <Generic> Eh yeah I somehow had addFloat in my head sorry |
21:13:53 | FromDiscord | <Generic> For conversion between number types just use the type as a function call |
21:14:05 | FromDiscord | <guttural666> toFloat expects an int which on my machine is in fact 64 bit, but the compiler isn't happy with me giving an int64 ^^ |
21:14:07 | FromDiscord | <Generic> Like C++ style casts |
21:14:16 | FromDiscord | <guttural666> oh okay |
21:14:36 | FromDiscord | <Generic> I'm not sure why toFloat is a thing |
21:15:12 | FromDiscord | <Generic> might be something old (and I'm already using Nim for quite a few years) |
21:17:08 | FromDiscord | <guttural666> amazing, thanks, didn't even know that kind of casting yet |
21:17:58 | FromDiscord | <guttural666> and it does compile 🙂 not the prettiest thing in the world but if I have to use force, I shall xD https://media.discordapp.net/attachments/371759389889003532/1047260151641554994/image.png |
21:18:44 | FromDiscord | <guttural666> In reply to @Generic "I'm not sure why": curious, why you think that should not be a thing, how would you handle that? |
21:19:38 | FromDiscord | <Generic> Because the other casts exist |
21:20:09 | FromDiscord | <guttural666> casting was kind of looked down upon in cpp |
21:21:07 | FromDiscord | <Generic> Well yes it is better to keep things in one type as long as possible |
21:21:22 | FromDiscord | <guttural666> maybe templating things like toFloat to be able to deal with var len integers? I dunno |
21:21:49 | FromDiscord | <Generic> There is no such thing in the language or the stdlib |
21:22:08 | FromDiscord | <guttural666> no? generics? |
21:22:12 | FromDiscord | <guttural666> or whats the term |
21:22:30 | FromDiscord | <guttural666> proc pls[T](thing: T) |
21:22:35 | FromDiscord | <pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4he4 |
21:22:46 | FromDiscord | <Generic> Haha |
21:23:19 | FromDiscord | <Generic> In reply to @guttural666 "proc pls[T](thing: T)": I still don't understand what you mean |
21:23:52 | FromDiscord | <Generic> For a moment I thought you meant arbitrarily sized integers |
21:24:15 | FromDiscord | <guttural666> yeah, beginning to think I haven't thought this through on a deeper level hahaha |
21:24:25 | FromDiscord | <pyolyokh> you wouldn't need templating, you'd just need another `toFloat` overloaded for the other type you want to handle |
21:25:08 | FromDiscord | <guttural666> or wait, aren't int and int64 distinct types |
21:25:14 | FromDiscord | <guttural666> templating should work then |
21:25:21 | FromDiscord | <Generic> Also I think one thing to consider is that Nim type conversions (iirc that's their proper name) are different from casts |
21:25:30 | FromDiscord | <pyolyokh> you still wouldn't need templating. Just a `proc toFloat(i: int64) = float = ...` |
21:25:57 | FromDiscord | <guttural666> In reply to @pyolyokh "you still wouldn't need": sure that would be human function overloading vs. compiler function overloading |
21:25:58 | FromDiscord | <Generic> I've been saying cast the whole time, but they're actually something and indeed unsafe |
21:26:02 | FromDiscord | <guttural666> same thing |
21:26:26 | FromDiscord | <Generic> (edit) "I've been saying cast the whole time, but they're actually something ... and" added "different" |
21:26:42 | FromDiscord | <guttural666> (but you do the mental work and typing vs. the computer 😄 ) |
21:27:10 | FromDiscord | <pyolyokh> OK, what you mean is that that a generic toFloat could take any type and float(x) it. |
21:27:40 | FromDiscord | <guttural666> yes and it would instantiate the appropriate version, i dunno I'm a pleb coming from c++ |
21:27:52 | FromDiscord | <pyolyokh> and this would've saved you the trouble of noticing that stdlib doesn't have a lot of support for int64 |
21:28:37 | FromDiscord | <pyolyokh> that's easy to understand, I was just confused by the way you introduced the topic |
21:29:05 | FromDiscord | <guttural666> In reply to @pyolyokh "and this would've saved": I too am confused about my thoughts so no worries mate hahaha |
21:30:01 | FromDiscord | <pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4he6 |
21:31:59 | FromDiscord | <guttural666> yeah, wonder why this is not the standard way to do things, don't even know if these nim templates have the same problems the cpp ones have |
21:32:39 | FromDiscord | <guttural666> most of what I've seen in the std seems to be type explicit i.e. using system dependent types |
21:33:30 | FromDiscord | <guttural666> things like time of course require a certain type width to fit etc. so it's enforced there |
21:33:32 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4he9 |
21:33:46 | FromDiscord | <4zv4l> `time ./crunch 5 8 abcdefgh > wd.txt` |
21:33:50 | FromDiscord | <4zv4l> that's how I benchmark it |
21:34:04 | FromDiscord | <pyolyokh> they have similar potential problems of confusing error messages, taking longer to compile, not existing unless instantiated (usually a plus), resulting in N instantiations when used with N types (mixed bag). And they might fight with the benefits of distinct types: you go to the trouble of saying "this is a special int, don't just treat it like an int" and then the generic toFloat instantiates for it anyway |
21:34:11 | FromDiscord | <Generic> In reply to @guttural666 "and it does compile": You can just directly cast int64 to float |
21:34:46 | FromDiscord | <Generic> Also writing it like C style casts does work |
21:34:49 | FromDiscord | <guttural666> In reply to @pyolyokh "they have similar potential": yeah makes sense, thanks for your insight |
21:34:56 | FromDiscord | <Generic> But it's dangerous |
21:35:17 | FromDiscord | <guttural666> In reply to @Generic "But it's dangerous": there be dragons, even in Nim |
21:35:23 | FromDiscord | <guttural666> haha |
21:35:54 | FromDiscord | <Generic> (int)variable is the same as int variable |
21:36:06 | FromDiscord | <Generic> So command style calling |
21:36:21 | FromDiscord | <Generic> So it binds differently |
21:36:50 | FromDiscord | <Generic> Casting has very high precedence in C |
21:36:53 | FromDiscord | <guttural666> yeah, so if say my times would overflow an int32 and I'm forcing it into one just do use a convenient abstraction, I may get fucked |
21:36:56 | FromDiscord | <huantian> In reply to @4zv4l "`time ./crunch 5 8": I would try timing just the computational parts of each code |
21:37:13 | * | junaid_ quit (Remote host closed the connection) |
21:37:33 | FromDiscord | <Generic> In reply to @guttural666 "yeah, so if say": For conversions to signed types you get an overflow defect |
21:37:45 | FromDiscord | <huantian> (edit) "code" => "code, remove any variance due to printing and such" |
21:37:46 | FromDiscord | <guttural666> In reply to @huantian "I would try timing": not a benchmark, it's a gui thing |
21:37:55 | FromDiscord | <4zv4l> In reply to @huantian "I would try timing": you mean that would be the redirection the issue ? |
21:37:59 | FromDiscord | <Generic> Unsigned types are defined to always mask in Nim |
21:38:33 | FromDiscord | <guttural666> (edit) "In reply to @huantian "I would try timing": not a benchmark, it's a gui thing ... " added "(sorry, got confused with the profile pics)" |
21:39:24 | FromDiscord | <pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4hec |
21:39:28 | FromDiscord | <guttural666> In reply to @Generic "Unsigned types are defined": you mean they just loose precision and nothing more |
21:39:44 | FromDiscord | <Generic> You loose the upper bits |
21:40:00 | FromDiscord | <Generic> Which don't fit |
21:40:07 | FromDiscord | <guttural666> In reply to @Generic "You loose the upper": which is basically what I said yeah? |
21:40:22 | FromDiscord | <Generic> Well no |
21:40:24 | FromDiscord | <guttural666> oh no it's not with int |
21:40:30 | FromDiscord | <4zv4l> In reply to @pyolyokh "some possibilities: 1. you": with danger it goes wayyyyyyyy faster, why ? |
21:40:32 | FromDiscord | <pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4hed |
21:40:39 | FromDiscord | <Generic> Loosing precision would be loosing lower bits |
21:40:49 | FromDiscord | <guttural666> In reply to @Generic "Loosing precision would be": yeah, so I'm fucked haha |
21:40:56 | FromDiscord | <Generic> Yeah |
21:41:08 | FromDiscord | <guttural666> (edit) "In reply to @Generic "Loosing precision would be": yeah, so I'm fucked ... haha" added "and my earlier statement was correct" |
21:41:14 | FromDiscord | <Generic> Unsigned in Nim is for low level worj |
21:41:16 | FromDiscord | <pyolyokh> In reply to @4zv4l "with danger it goes": what were you doing before? -d:release ? If not even that, you're making a debug build with -Og passed to the C compiler. With -d:danger you strip asserts and range checks. |
21:41:37 | FromDiscord | <Generic> (edit) "worj" => "work" |
21:41:41 | FromDiscord | <4zv4l> I was doing↵`nim c --opt:speed --d:release --d:useMalloc crunch` |
21:42:11 | FromDiscord | <guttural666> In reply to @Generic "Unsigned in Nim is": yeah, okay got a good grasp on the situation now, thanks so much for helping, really helped me understand @pyolyokh thank you as well! |
21:42:52 | FromDiscord | <4zv4l> In reply to @pyolyokh "also, `echo` might flush": well in C stdout is new newline buffered right ? just like echo in nim I guess |
21:43:00 | FromDiscord | <huantian> Also not really relevant but the fact that lines and bytes are floats and not ints is cursed to me ↵Ig it makes slightly more sense for huge values but still |
21:43:35 | FromDiscord | <pyolyokh> In reply to @4zv4l "well in C stdout": typically libc decides between line- or block- buffering based on a tty check, probably of stdout |
21:45:12 | FromDiscord | <pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4hee |
21:45:27 | FromDiscord | <pyolyokh> in the second case you'll get a single write() syscall for the first loop, then ten syscalls for each of the echos |
21:45:33 | FromDiscord | <pyolyokh> because `echo` flushes |
21:45:57 | FromDiscord | <guttural666> In reply to @Generic "Unsigned in Nim is": I'm thinking doesn't any (int)int64 instantly make your application incompatible with 32 bit machines? i think int just means this or the other when compiling right? I think 32 bit machines have ways to deal with 64 bit integers? |
21:46:00 | FromDiscord | <pyolyokh> in the first case you get twenty syscalls because libc decided to line buffering |
21:46:47 | FromDiscord | <Generic> In reply to @guttural666 "I'm thinking doesn't any": Yes, it will just be slower |
21:47:11 | FromDiscord | <4zv4l> In reply to @pyolyokh "some possibilities: 1. you": is there another way I could use to concat the string then ? |
21:47:21 | FromDiscord | <Generic> So e.g. one add will be an add and an adc |
21:47:27 | FromDiscord | <guttural666> In reply to @Generic "Yes, it will just": okay, so the compilation target still fixes those things, was just wondering |
21:47:59 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4heg |
21:48:14 | FromDiscord | <Generic> Also don't use the C style casts 😬 |
21:48:14 | FromDiscord | <4zv4l> I gain 30% speed |
21:48:40 | FromDiscord | <guttural666> In reply to @Generic "Also don't use the": only if I have to haha, but very insightful discussion thanks a lot for the insight |
21:48:57 | FromDiscord | <Generic> No you never have to |
21:49:11 | FromDiscord | <Generic> I think you might have misunderstood me |
21:49:42 | FromDiscord | <Generic> I when I say C style cast I mean (int)variable |
21:49:56 | FromDiscord | <Generic> Those only work accidentally in Nim |
21:50:18 | FromDiscord | <Generic> When I say C++ style casts I mean int(variable) |
21:50:59 | FromDiscord | <Generic> Thanks to universal calling convention you can also write variable.int |
21:51:15 | FromDiscord | <Generic> Or int variable |
21:51:57 | FromDiscord | <Generic> (edit) "Thanks to universal ... calling" added "function" | removed "convention" |
21:52:38 | FromDiscord | <pyolyokh> In reply to @4zv4l "is there another way": `s.add c` |
21:52:59 | FromDiscord | <guttural666> In reply to @Generic "Or int variable": so these should be the same https://media.discordapp.net/attachments/371759389889003532/1047268963060547774/image.png |
21:53:21 | FromDiscord | <Generic> Yes |
21:53:48 | FromDiscord | <Generic> But (int)a+b in Nim is int(a+b) |
21:54:12 | FromDiscord | <Generic> While in C++ it is ((int)a)+b |
21:54:22 | FromDiscord | <guttural666> yeah, got tripped up by some of that when iffing and if notting etc. |
21:54:31 | FromDiscord | <guttural666> yeah yeah |
21:55:46 | FromDiscord | <guttural666> the .int() syntax is way better imo |
21:56:17 | FromDiscord | <guttural666> well I actually don't know, (int) does seem to be more expressive, since this is not a normal occurrence |
21:59:17 | FromDiscord | <huantian> sent a code paste, see https://play.nim-lang.org/#ix=4hei |
22:02:21 | FromDiscord | <4zv4l> well mostly changing from `echo` to `c_printf` changed everything |
22:03:04 | FromDiscord | <4zv4l> with echo: `./crunch 5 8 abcdefgh > wd.txt 3,08s user 18,53s system 99% cpu 21,624 total` |
22:03:06 | FromDiscord | <huantian> slapping it in benchy gives me a 5x improvement without the string allocs it seems |
22:03:12 | FromDiscord | <guttural666> sent a code paste, see https://play.nim-lang.org/#ix=4hem |
22:03:24 | FromDiscord | <4zv4l> with c_printf `./crunch 5 8 abcdefgh > wd.txt 0,68s user 0,10s system 99% cpu 0,783 total` |
22:03:35 | FromDiscord | <4zv4l> In reply to @huantian "slapping it in benchy": I'll check that |
22:03:53 | FromDiscord | <4zv4l> In reply to @guttural666 "you are aware that": lmao what ? what's the sin ? |
22:04:13 | FromDiscord | <guttural666> In reply to @4zv4l "lmao what ? what's": such heresy cannot remain unanswered haha |
22:04:18 | FromDiscord | <guttural666> just kidding haha |
22:04:51 | FromDiscord | <guttural666> the fool comes blasting in here claiming Nim is slow, ridiculous! the king shall hear of this hahaha |
22:04:58 | FromDiscord | <guttural666> I'm a bit stupid tonight |
22:08:01 | FromDiscord | <4zv4l> with this code |
22:08:08 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4hep |
22:08:09 | FromDiscord | <4zv4l> I get same performance as C |
22:08:23 | FromDiscord | <4zv4l> well |
22:08:24 | FromDiscord | <4zv4l> almost |
22:08:34 | FromDiscord | <4zv4l> 0.550 Nim↵0.450 C |
22:08:55 | FromDiscord | <huantian> sent a code paste, see https://play.nim-lang.org/#ix=4heq |
22:09:09 | FromDiscord | <huantian> no need for the float conversions |
22:09:10 | FromDiscord | <huantian> (edit) "https://play.nim-lang.org/#ix=4heq" => "https://play.nim-lang.org/#ix=4her" |
22:10:20 | FromDiscord | <huantian> probably has minimal speed implications but just in case |
22:11:00 | * | Phytolizer quit (Remote host closed the connection) |
22:11:20 | * | Phytolizer joined #nim |
22:11:46 | FromDiscord | <4zv4l> I changed, indeed much cleaner |
22:12:59 | FromDiscord | <4zv4l> and |
22:13:03 | FromDiscord | <4zv4l> exactly the same speed as C |
22:13:05 | FromDiscord | <4zv4l> if not faster |
22:13:12 | FromDiscord | <4zv4l> 0.434 Nim |
22:13:20 | FromDiscord | <4zv4l> what does `-d:danger` does ? |
22:13:29 | FromDiscord | <huantian> it disables bound checks |
22:13:37 | FromDiscord | <4zv4l> oh it doesn't change the speed |
22:13:44 | FromDiscord | <4zv4l> gonna remove the flag then |
22:14:27 | FromDiscord | <huantian> yeah it can have speed improvements based on the situation |
22:14:33 | FromDiscord | <4zv4l> In reply to @4zv4l "oh it doesn't change": I meant I tried now and it didn't change it |
22:14:44 | FromDiscord | <4zv4l> well |
22:14:47 | FromDiscord | <4zv4l> pretty amazed |
22:14:52 | FromDiscord | <4zv4l> same speed as C |
22:24:07 | FromDiscord | <guttural666> In reply to @4zv4l "0.550 Nim 0.450 C": this is what we want to see haha |
22:24:30 | FromDiscord | <huantian> yeah Nim can definitely be as fast as C, just depends on the code! |
22:25:25 | FromDiscord | <guttural666> yeah, that [depending on the code] is a huge question mark in most cases, especially stuff like c++ |
22:25:32 | FromDiscord | <guttural666> sadly |
22:27:50 | FromDiscord | <guttural666> languages that give you the tools to and through bad training for decades have encouraged shit software engineering will result in really bad performance, even if stuff like c++ theoretically is really just better c |
22:28:26 | FromDiscord | <guttural666> (edit) "c" => "c, will always yield bad results" |
22:28:46 | FromDiscord | <4zv4l> I'm wondering why people still write tools in C when there is a language like Nim |
22:29:00 | FromDiscord | <4zv4l> I got interested in Nim again because of `dnscat2` in which the client is made in C |
22:29:04 | FromDiscord | <4zv4l> could totally be made in Nim |
22:29:11 | FromDiscord | <A Very Merry Reimu ッ> im torn between loving this language, and really really really hating parts of it |
22:29:11 | FromDiscord | <4zv4l> would be easier to read/write/improve/... |
22:29:20 | FromDiscord | <guttural666> In reply to @4zv4l "I'm wondering why people": I do too honestly, I pray for a GUI framework like Qt in Rust, Nim, Zig, Odin every day |
22:29:29 | FromDiscord | <A Very Merry Reimu ッ> anyone else relate? |
22:29:38 | FromDiscord | <guttural666> In reply to @A Very Merry Reimu ッ "anyone else relate?": talking about c++? |
22:29:41 | FromDiscord | <A Very Merry Reimu ッ> nim |
22:29:56 | FromDiscord | <A Very Merry Reimu ッ> i love the syntax but hate the objects/enum types |
22:30:08 | FromDiscord | <4zv4l> the thing that is missing about Nim is a bigger amount of libraries to me |
22:30:09 | FromDiscord | <A Very Merry Reimu ッ> i am not a fan of pascal style OOP |
22:30:32 | FromDiscord | <4zv4l> like I am coding in Perl now mostly because Ruby didn't have the libs I needed for networking |
22:30:49 | FromDiscord | <4zv4l> and the only advantage Go has over Nim to me, is the amount of libs |
22:31:29 | FromDiscord | <guttural666> In reply to @A Very Merry Reimu ッ "i love the syntax": started couple weeks ago, already wrote 2 console apps, loving it every step of the way, the cock and ball torture that was reflection less c++ in 22 was just a faint memory |
22:31:41 | FromDiscord | <A Very Merry Reimu ッ> not on about that |
22:31:46 | FromDiscord | <4zv4l> same goes for Zig, missing some libs to me↵and I don't wanna write wrappers for each libs I need |
22:31:54 | FromDiscord | <A Very Merry Reimu ッ> having to prefix enums and not having proper ADTs like in rust/haskell |
22:32:16 | FromDiscord | <A Very Merry Reimu ッ> but then also not having a fully baked OOP w/ inheritance either |
22:32:28 | FromDiscord | <A Very Merry Reimu ッ> (edit) "enums" => "enum members to avoid conflicts" |
22:32:36 | FromDiscord | <A Very Merry Reimu ッ> these are the only things i dislike |
22:32:43 | FromDiscord | <A Very Merry Reimu ッ> dont get me wrong the language is greta |
22:32:49 | FromDiscord | <A Very Merry Reimu ッ> (edit) "greta" => "great aside from these" |
22:33:18 | FromDiscord | <A Very Merry Reimu ッ> (edit) "having to prefix enum members" => "hungarian notation" |
22:33:27 | FromDiscord | <A Very Merry Reimu ッ> @guttural666 |
22:33:48 | FromDiscord | <4zv4l> @A Very Merry Reimu ッ I agree about `ISO 8601` date format |
22:34:04 | FromDiscord | <A Very Merry Reimu ッ> fellow iso 8601 enjoyer |
22:34:27 | FromDiscord | <4zv4l> USA people always confused me↵using MM-DD-YYYY |
22:36:57 | FromDiscord | <guttural666> In reply to @A Very Merry Reimu ッ "dont get me wrong": yeah, you're probably more experienced than i am |
22:37:35 | * | xet7 quit (Read error: Connection reset by peer) |
22:40:56 | FromDiscord | <guttural666> I just see serialization that I have to do for a hobby project in standard c++ and I already get mad, get the name of a field? nope, alright just fill all fields of an obj with an index? nope |
22:41:14 | FromDiscord | <A Very Merry Reimu ッ> In reply to @guttural666 "yeah, you're probably more": in nim? no↵in programming in general? maybe idk |
22:41:23 | FromDiscord | <guttural666> the compiler knows all this stuff and it simply doesn't talk to me |
22:42:32 | FromDiscord | <guttural666> In reply to @A Very Merry Reimu ッ "in nim? no in": and people do type erasure and crazy perverse things just to trick the damn compiler and it's just crazy |
22:43:28 | FromDiscord | <A Very Merry Reimu ッ> sent a code paste, see https://play.nim-lang.org/#ix=4hez |
22:43:33 | FromDiscord | <guttural666> if a human understand something, the compiler should, that is my naiive pleb expectation of a user 🤣 |
22:44:50 | FromDiscord | <guttural666> D is the language of the funny and genious Balkan guy right? |
22:44:59 | FromDiscord | <A Very Merry Reimu ッ> its like C++ but actually good |
22:45:03 | FromDiscord | <A Very Merry Reimu ッ> unfortunatelt its very niche |
22:45:20 | FromDiscord | <guttural666> who talks on CPP conferences as well? |
22:45:31 | FromDiscord | <A Very Merry Reimu ッ> walter bright? |
22:46:23 | FromDiscord | <albassort> i want to have a proc as a parameter, where i can put any proc which has the same parameters in the same place but is allowed to have extra |
22:46:28 | FromDiscord | <albassort> oh wait that mekes no sense |
22:46:38 | FromDiscord | <albassort> (edit) "mekes" => "makes" |
22:46:40 | FromDiscord | <albassort> ignore that |
22:47:50 | * | Phytolizer quit (Remote host closed the connection) |
22:48:10 | * | Phytolizer joined #nim |
22:50:40 | FromDiscord | <guttural666> Andrei Alexandrescu |
22:51:52 | FromDiscord | <guttural666> yeah, not Bright, which would be the other designer ^^ |
22:54:22 | FromDiscord | <guttural666> source compatibility with C/CPP is a must though, think that's one reason It's niche maybe? |
23:13:00 | FromDiscord | <guttural666> cant I comma seperate these bad boys? https://media.discordapp.net/attachments/371759389889003532/1047289101004570694/image.png |
23:14:39 | FromDiscord | <huantian> I think you can use underscores |
23:15:05 | FromDiscord | <guttural666> yes, thank you, just got it right |
23:16:18 | * | Phytolizer quit (Ping timeout: 260 seconds) |
23:32:14 | FromDiscord | <guttural666> how do I reduce the stringyfied version of a float to x,xx without too much hassle? https://media.discordapp.net/attachments/371759389889003532/1047293940300255232/image.png |
23:33:38 | FromDiscord | <guttural666> https://media.discordapp.net/attachments/371759389889003532/1047294295050305626/image.png |
23:34:02 | FromDiscord | <huantian> https://nim-lang.org/docs/strformat.html#formatting-floats |
23:34:37 | FromDiscord | <guttural666> grazie mille |
23:36:49 | FromDiscord | <guttural666> 200 lines of code and I've written an API to Metal Archives in Nim it's just bonkers how much fun this is |
23:39:06 | FromDiscord | <ahungry> sent a long message, see http://ix.io/4heI |
23:39:57 | FromDiscord | <ahungry> (edit) "http://ix.io/4heI" => "http://ix.io/4heJ" |
23:41:05 | FromDiscord | <huantian> well if you want to use libcurl and SDL, there are already existing wrappers I believe |
23:43:13 | FromDiscord | <ahungry> direct nim implemented/supported cross platform would be preferable I think - maybe I should just dive in 😀 the lang seems like a lot of fun - couldnt get nimlsp to work with Emacs eglot, but lsp-mode was fine |
23:47:49 | * | disso_peach quit (Ping timeout: 260 seconds) |
23:49:08 | * | disso_peach joined #nim |
23:52:23 | FromDiscord | <pyolyokh> I'd go with raylib and start with std/httpclient myself. Should be few snags that way. |
23:54:24 | FromDiscord | <guttural666> In reply to @ahungry "Hi all - hopefully": "Hi all - hopefully I can come in and bombard with all the noob questions"↵moves on to be a sophisticated young person who knows a lot, just shut up alhungry xD |
23:55:40 | FromDiscord | <guttural666> vim works (smirking ultra chad) |
23:56:18 | FromDiscord | <pyolyokh> a sophisticated young person who knows a lot seems pretentious if humble in a middle school class room, but seems arrogant if not humble among professionals at a conference. That remark's just some high expectations |