00:06:58 | * | ehmry quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.) |
00:07:19 | * | krux02 quit (Remote host closed the connection) |
00:12:32 | * | ehmry joined #nim |
00:25:22 | FromDiscord | <Gary M> I find it bizarre but otherwise really useful that mingw compiled static libs in `.a` format link for windows executables just like a `.lib` would |
00:25:46 | FromDiscord | <Gary M> because that's like, linux GCC lib format |
00:27:16 | * | tane quit (Quit: Leaving) |
00:43:00 | FromDiscord | <jfmonty2> I've got two types, both objects. The outer type has an array of the inner type. The inner type has a sequence of values. When I try to loop through the outer object's array and apply a mutation to each sequence, I get `expression is immutable, not var`. But the outer object was declared with `var`. How can I get a mutable access to the inner type's field? |
00:43:03 | FromDiscord | <jfmonty2> Example is here: https://play.nim-lang.org/#ix=2THq |
00:44:40 | FromDiscord | <ElegantBeef> Nim's default iterator is `items` which is immutable you need to do `.mitems` to get the mutable references |
00:45:48 | FromDiscord | <jfmonty2> ahh |
00:47:46 | Benjamin[m]2 | <PMunch "Apart from this thing I guess:ht"> I think a Golden Eagle would be a good mascot. |
00:48:02 | Benjamin[m]2 | * I think a Golden Eagle would be a good mascot. |
00:48:02 | Benjamin[m]2 | "Golden Eagles possess astonishing speed and maneuverability for their size, and are one of the fastest, nimblest raptors in North America. Diving from great heights, these eagles have been clocked at close to 200 miles per hour." |
00:48:02 | Benjamin[m]2 | Plus, it's called a "King Eagle" in several languages. |
01:20:44 | * | vicfred quit (Quit: Leaving) |
01:26:09 | * | vicfred joined #nim |
01:39:26 | * | aeverr quit (Remote host closed the connection) |
01:39:52 | * | aeverr joined #nim |
01:52:27 | * | njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.) |
01:52:45 | * | njoseph joined #nim |
02:19:40 | FromDiscord | <sealmove> why don't we have a `newJsonNode` proc, overloaded with `int`, `string`, etc? |
02:26:33 | FromDiscord | <ElegantBeef> Well there is the `%` operator |
02:32:13 | * | Tanger joined #nim |
02:39:08 | * | wasted_youth2 quit (Quit: Leaving) |
03:04:49 | FromDiscord | <jfmonty2> How does one early-exit an iterator? `return` doesn't seem to work, nor does `break` |
03:12:22 | FromDiscord | <Gary M> it should work, what are you doing? |
03:21:05 | FromDiscord | <Yardanico> old nimforum (didn't take long to fix removed deprecated stuff so it compiles again) https://media.discordapp.net/attachments/371759389889003532/823395832849236008/unknown.png |
03:21:33 | FromDiscord | <sealmove> how to configure where testament puts nimcache and testresults? |
03:23:35 | FromDiscord | <Yardanico> @jfmonty2 can you show the code? |
03:24:25 | FromDiscord | <Yardanico> and you can't use `return` in inline iterators anyway |
03:24:32 | FromDiscord | <Yardanico> since they're inlined :P |
03:25:08 | FromDiscord | <jfmonty2> sure, here's my iterator: https://play.nim-lang.org/#ix=2THX |
03:25:48 | FromDiscord | <jfmonty2> I didn't explicitly inline it, but is it perhaps implicit? |
03:25:49 | FromDiscord | <jfmonty2> (probably not since this gets called upwards of 100M times) |
03:25:50 | FromDiscord | <jfmonty2> oh I guess that doesn't really matter though |
03:26:04 | FromDiscord | <Yardanico> @jfmonty2 I mean that default nim "iterators" are _always_ inlined |
03:26:10 | FromDiscord | <Yardanico> the code itself replaces the for loop |
03:26:10 | FromDiscord | <jfmonty2> ah |
03:26:26 | FromDiscord | <Yardanico> how do you call your iterator? |
03:26:35 | FromDiscord | <jfmonty2> This one is being called from another iterator |
03:26:43 | FromDiscord | <Yardanico> i mean with what arguments so I can test it :P |
03:26:54 | FromDiscord | <jfmonty2> oh π sure, just do like `digits(1, 3, 3)` |
03:27:06 | FromDiscord | <jfmonty2> it will give you all 3-digit combinations of 1, 2, and 3 |
03:28:00 | FromDiscord | <Yardanico> oh, nice, although you can make implement the same with algorithm.nextPermutation |
03:28:00 | FromDiscord | <jfmonty2> if it weren't erroring that is |
03:28:25 | FromDiscord | <jfmonty2> Doesn't that enforce uniqueness or something? |
03:28:26 | FromDiscord | <Yardanico> easy solution would be to remove "return" and just add an else branch |
03:28:34 | FromDiscord | <jfmonty2> oh duh π yeah that would work wouldn't it |
03:29:00 | FromDiscord | <Yardanico> yeah something like that |
03:29:02 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=2THY |
03:30:46 | FromDiscord | <Yardanico> @jfmonty2 and so you know, this is how the iterator gets inlined (this also includes new runtime-specific destroys and try: finally: blocks, you can ignore those) |
03:30:46 | FromDiscord | <jfmonty2> yeah, `algorithm.nextPermutation` doesn't appear to work with repeated values unfortunately |
03:30:56 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=2THZ |
03:30:59 | FromDiscord | <Yardanico> the for loop is rewritten to this :) |
03:31:04 | FromDiscord | <jfmonty2> oof |
03:31:10 | FromDiscord | <Yardanico> well there's nothing bad about it |
03:31:10 | FromDiscord | <jfmonty2> yeah I'll have to uh, come back to that one. |
03:31:22 | FromDiscord | <jfmonty2> I'm just glad I have the compiler to do it for me π |
03:31:31 | FromDiscord | <Yardanico> but yeah if you call it too much in many different places, your binary size might grow |
03:32:55 | FromDiscord | <sealmove> is there a way to configure testament's defaults instead of specifying them in `discard` section in each and every file? |
03:33:11 | FromDiscord | <Yardanico> @sealmove honestly not sure, it's still pretty early in EU so I'd recommend you to ask on the forum |
03:33:19 | FromDiscord | <Yardanico> @jfmonty2 so basically when you call inline iterators in a for loop, the for loop's body gets rewritten with the inline iterator, and "yield"s get rewritten into whatever body you have inside the for loop |
03:33:42 | FromDiscord | <jfmonty2> right, that makes sense |
03:34:07 | FromDiscord | <jfmonty2> I can see how it works conceptually, it's just reading the raw unroll that's a little intimidating at first |
03:34:11 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=2TI0 |
03:34:18 | FromDiscord | <Yardanico> well you don't need to read it :P |
03:34:37 | FromDiscord | <jfmonty2> exactly, if we had to read all the code generated by all of our various compilers we'd still be in the 60s |
03:34:48 | FromDiscord | <Yardanico> --expandArc just shows your code after a lot of compiler transformations (including new runtime specific ones for destructors and stuff) |
03:35:07 | FromDiscord | <jfmonty2> I can see that being useful for debugging now and then |
03:53:41 | FromDiscord | <ElegantBeef> I really shouldnt have stumbled on timothee's github page talking about cmdline generator stuff π |
03:53:43 | FromDiscord | <ElegantBeef> https://media.discordapp.net/attachments/371759389889003532/823404042499784734/unknown.png |
04:05:04 | * | spiderstew_ joined #nim |
04:06:38 | * | spiderstew quit (Ping timeout: 264 seconds) |
04:21:21 | * | waleee-cl quit (Quit: Connection closed for inactivity) |
05:17:51 | FromDiscord | <j-james> Out of curiosity, why aren't all symbols exported by default? |
05:18:12 | FromDiscord | <ElegantBeef> Cause that gives 0 access control |
05:18:29 | FromDiscord | <ElegantBeef> Which means you cannot hide any of the underlying logic from users and protect yourself |
05:19:39 | FromDiscord | <j-james> Well, I meant why is the default that all symbols are hidden and `` is a public marker |
05:19:53 | FromDiscord | <j-james> As opposed to all public and `` functioning as a private marker |
05:20:40 | FromDiscord | <ElegantBeef> Coming from C# it's "proper" to me π |
05:20:49 | FromDiscord | <ElegantBeef> So idk why would you default to publiic |
05:20:52 | FromDiscord | <ElegantBeef> Seems like it should be opt in |
05:21:28 | FromDiscord | <j-james> maybe I'm too used to the pseudo-public stuff Java does by default |
05:21:46 | FromDiscord | <ElegantBeef> Private by default means you dont ever accidentally expose code, you have to intentionally do it |
05:39:55 | * | lritter joined #nim |
05:44:28 | * | narimiran joined #nim |
05:51:51 | saem | Beef what was that weird generic parameter bug you ran into or found in the issue tracker a few nights ago? |
06:10:29 | FromDiscord | <ElegantBeef> The the typeclass confusing the explicit generics, gotta find it for you π |
06:10:44 | saem | πββοΈ |
06:11:02 | FromDiscord | <ElegantBeef> 'ere https://github.com/nim-lang/Nim/issues/17212 |
06:13:37 | saem | Time to see if I fixed this or anything else. π
|
06:13:47 | saem | or you know, made it worse. |
06:17:31 | * | mbomba joined #nim |
06:17:47 | saem | another Canadian |
06:19:14 | FromDiscord | <ElegantBeef> Who is? |
06:19:34 | saem | IRC message, your probably don't see it in discord. |
06:19:50 | FromDiscord | <ElegantBeef> Ah |
06:20:00 | FromDiscord | <ElegantBeef> Thought i was going crazy |
06:20:11 | saem | Could still be, just unrelated. |
06:20:46 | Yardanico | yeah, showing all IRC join/leave mesages in Discord would be a bit too much :P |
06:21:04 | saem | Really would be. |
06:23:00 | FromDiscord | <ElegantBeef> Would really confuse the people that thing the irc bridge is a bot |
06:23:12 | FromDiscord | <ElegantBeef> think even |
06:24:18 | saem | hah, I've never used methods in Nim -- except to write tests for nimsuggest. |
06:24:37 | Yardanico | b-b-but OOP!11111 |
06:24:41 | saem | LoL |
06:25:02 | saem | I mean, runtime dispatch is super useful for sure. |
06:25:15 | saem | I guess if you have a big pile of it, for reasons, then I get why. |
06:25:41 | Yardanico | with things like https://github.com/yglukhov/iface I don't think that there are too many places where you really need methods :P |
06:25:46 | saem | But most of the time I don't and where I do it's like... one function pointer and good enough. |
06:26:17 | Yardanico | yeah, e.g. the streams module is just "raw" interfaces with proc pointers |
06:26:48 | saem | Yeah, methods in a very conceptual sense are great in some cases, but as the very specific dispatch scheme/mechanism, I'm not sure. An yeah, iface is pretty cool -- though I don't know the edges well. |
06:27:40 | saem | Streams are where I think concepts (I know, I know) might obviate even that? |
06:28:13 | * | mbomba quit (Quit: WeeChat 3.1) |
06:28:15 | FromDiscord | <ElegantBeef> What's the "i know i know" about? |
06:28:34 | saem | some people have feelings about it, I'm pre-forgiving myself. |
06:28:51 | Yardanico | saem: yeah, I think that even generics/concepts should work for implementing the streams module |
06:28:59 | Yardanico | maybe it wasn't done because streams module was made a long time ago |
06:29:20 | saem | Partially, also it's advantageous when you want to swap that stuff out at runtime, use cases and all that. |
06:29:40 | Yardanico | yeah |
06:34:59 | saem | It'd be hella difficult, but being able to take a single set of types (library author), then being able to specify having them somewhere on compile-run-time spectrum (library user) with the dispatch/RTTI being traded off appropriately would be slick. |
06:39:55 | saem | huh, that's weird, why wouldn't semMethodPrototype look at the return type. |
07:36:00 | saem | holy crap.. I fixed the bug. |
07:36:48 | FromDiscord | <ElegantBeef> Holy bug man robin! |
07:37:15 | FromDiscord | <ElegantBeef> Congrats, keep this up and the issue count might go down π |
07:38:55 | saem | spoke too soon. :D |
07:39:52 | saem | Though, i might know where it is now. |
07:43:42 | * | fredrikhr joined #nim |
08:03:49 | * | PMunch joined #nim |
08:15:39 | * | PMunch quit (Quit: leaving) |
08:21:44 | * | PMunch joined #nim |
08:57:12 | PMunch | Hmm, I can't put an array of unsigned integers in my main procedure without getting the Error: system module needs: nimErrorFlag error.. |
08:58:20 | saem | π€ that sounds like my badπ |
08:58:41 | PMunch | Your bad? |
08:58:46 | PMunch | What did you do? :P |
08:59:13 | saem | It's late here, I can't get into that now. |
08:59:20 | saem | :D |
08:59:46 | PMunch | I get the same error from 1.4.0 and up, can't test earlier versions as I use a for loop macro |
09:00:08 | PMunch | Oh, with devel it works |
09:00:40 | saem | Oh ... then the opposite of my bad, perhaps. But only half credit. |
09:01:18 | saem | For a teeny example I can look at on pay ground? |
09:01:22 | saem | Got |
09:02:11 | saem | It's probably a good candidate to become a regular test case from the sounds of it. |
09:02:20 | * | Tanger quit (Remote host closed the connection) |
09:04:45 | * | krux02 joined #nim |
09:05:55 | PMunch | Well this is running on the Teensy, so it has a long nim.cfg in order to make that to work |
09:06:17 | PMunch | But it's this project: https://github.com/PMunch/badger/blob/master/badger.nim |
09:06:37 | PMunch | If you try to move rowKeys and colKeys into the `main` procedure it will give that error. |
09:07:13 | saem | Except devel? |
09:08:03 | PMunch | Yeah on devel it works |
09:08:10 | ForumUpdaterBot | New post on r/nim by bitbrist: nim safety in comparision to c, zig and rust, see https://reddit.com/r/nim/comments/maj1lz/nim_safety_in_comparision_to_c_zig_and_rust/ |
09:09:00 | saem | Hmm, so that would trigger compile time, I wonder if that's what it's tripping up on. |
09:09:11 | PMunch | It doesn't do what I hoped it would, but it doesn't trigger that error |
09:09:37 | saem | Oh, what's it so wrong? |
09:10:00 | PMunch | Well I was trying to save data memory, the teensy doesn't have a lot of that |
09:11:04 | saem | Oh, so works as intended but the impact is not what you wanted? |
09:11:10 | PMunch | Yes |
09:11:13 | PMunch | On devel |
09:11:40 | PMunch | It seems to create them as globals still, and then copy them into variables on runtime |
09:11:49 | PMunch | This means that Nim needs to add in error handling features |
09:11:56 | PMunch | Which is where that error was coming from |
09:14:54 | saem | Ah, so not failing where it shouldn't but the semantic _might_ be off |
09:24:40 | PMunch | Well it failed because it was missing something, but that seems to have been fixed. |
09:24:49 | PMunch | And I was just wrong in my assumption |
09:37:01 | * | timdorohin joined #nim |
09:41:22 | PMunch | Hmm, anyone good with nm here? |
09:48:27 | FromDiscord | <Gary M> is there any way to do implicit object creation like `(1, 2.0f)` instead of `myType(myInt: 1, myFloat:2.0f)` |
09:48:58 | FromDiscord | <Gary M> specifically if you already have a value that is of that type |
09:49:21 | FromDiscord | <Gary M> `var ofMyType: MyType()` |
09:49:32 | FromDiscord | <Gary M> (edit) "MyType()`" => "MyType` π" |
09:49:46 | FromDiscord | <Rika> not that i know of, use a tuple if really needed |
09:50:02 | FromDiscord | <Gary M> can't |
09:50:04 | FromDiscord | <Rika> thats fragile imo |
09:50:26 | FromDiscord | <Gary M> what's fragile about it? |
09:50:35 | FromDiscord | <Rika> use a proc `proc myType(x, y: T): MyType` or so |
09:51:18 | FromDiscord | <Gary M> but why does this have to be necessary? |
09:51:40 | FromDiscord | <Gary M> what is fragile about implicit object initialization? |
09:51:42 | FromDiscord | <Rika> i dont know the reason, maybe a core dev would know better |
10:15:06 | FromDiscord | <Gary M> does `high` on a seq only return the index or will it return the value |
10:16:50 | FromDiscord | <mratsim> the index |
10:17:07 | FromDiscord | <mratsim> use s[^1] or s[s.high] if you want the value |
10:17:18 | FromDiscord | <Gary M> ah okay ^1 was what I wanted |
10:17:29 | FromDiscord | <Gary M> why is it not ^0 |
10:17:47 | FromDiscord | <Gary M> like reversed 0 index or whatever |
10:23:57 | FromDiscord | <Rika> woah first time ive gotten a SIGILL on nim |
10:24:50 | FromDiscord | <nuc> Hi guys is there any nim based data format akin to Json? For example using indendation instead of brackets π |
10:25:08 | PMunch | @Rika, how'd you manage that :P |
10:25:13 | FromDiscord | <Rika> i dont know |
10:25:14 | FromDiscord | <nuc> For example Rust has RON https://docs.rs/ron/0.6.2/ron/ |
10:25:29 | FromDiscord | <nuc> So I wonder if anybody invented something for nim π |
10:26:05 | PMunch | @nuc, not really. Since Nim is so flexible you can use pretty much any format and make it feel native, so most people just use an established format |
10:26:14 | PMunch | Why reinvent the wheel if you don't have to |
10:27:55 | FromDiscord | <nuc> Well becasue I don't know of any indendation based data format apart from yaml... |
10:27:59 | FromDiscord | <Rika> i see, div by 0 somehow |
10:28:02 | FromDiscord | <nuc> (edit) "becasue" => "because" |
10:28:24 | FromDiscord | <nuc> (edit) "Well because I don't know of any ... indendation" added "good" |
10:29:57 | PMunch | @nuc, TOML? |
10:30:01 | * | tane joined #nim |
10:31:30 | FromDiscord | <nuc> I am looking for a homoiconic data format |
10:36:32 | * | Vladar joined #nim |
10:37:32 | FromDiscord | <nuc> @PMunch none of the mentioned data format is based of the nim syntax |
10:37:42 | FromDiscord | <nuc> (edit) "format" => "formats" | "of" => "off" |
10:37:55 | FromDiscord | <Rika> In reply to @PMunch "@nuc, not really. Since": did you see this? |
10:38:16 | FromDiscord | <nuc> @Rika Yes, I was not asking for judgement calls. |
10:38:20 | FromDiscord | <Rika> then no |
10:38:23 | FromDiscord | <Rika> there is nothing |
10:38:30 | FromDiscord | <Rika> unless you're willing to use nimscript |
10:38:47 | PMunch | NimScript would work fine |
10:38:59 | PMunch | You could make your own DSL based format |
10:39:09 | PMunch | But if you're doing that, why not just use inline JSON? |
10:40:24 | FromDiscord | <nuc> I was inspried by https://altscript.com/?page_id=16 and thought it might be a cool idea for nim :)) |
10:40:25 | PMunch | I mean we are able to do things like this: https://play.nim-lang.org/#ix=2TIW |
10:40:46 | FromDiscord | <nuc> and https://altscript.com/?page_id=62 |
10:40:49 | PMunch | Just typing JSON directly into your Nim file, so in that way JSON is already Nim syntax :P |
10:51:30 | FromDiscord | <Solitude> In reply to @Gary M "why is it not": len - n |
10:59:52 | PMunch | @juancarlospaco, one comment on my video from yesterday, asking to increase the font size :P |
11:44:42 | PMunch | Trying to reply to a topic on Reddit, does this look about right? https://uploads.peterme.net/nimsafe.html |
11:48:02 | FromDiscord | <Gary M> you forgot checked C π |
11:48:15 | PMunch | Checked C? |
11:48:38 | FromDiscord | <Gary M> also are these correctly formatted https://media.discordapp.net/attachments/371759389889003532/823523559149142066/unknown.png |
11:48:41 | PMunch | It's a reply to this: https://scattered-thoughts.net/writing/how-safe-is-zig/ |
11:49:00 | PMunch | Uhm, that is weird |
11:49:25 | FromDiscord | <Gary M> it's on Edge, chromium based |
11:49:45 | PMunch | That should've been fixed now |
11:49:56 | PMunch | Was missing a meta tag to set the character set to UTF8 |
11:50:06 | PMunch | Looks like FF does that by default |
11:50:18 | FromDiscord | <Gary M> > Checked C adds static and dynamic checking to C to detect or prevent common programming errors such as buffer overruns and out-of-bounds memory accesses |
11:50:38 | FromDiscord | <Gary M> not that it's extremely relevant, but it's tangential |
11:50:48 | PMunch | Ah right |
11:50:54 | PMunch | I was just adding the two Nim columns |
11:50:59 | PMunch | The C column is from the original |
11:51:05 | FromDiscord | <Gary M> yeah now the nim columns are missing π |
11:51:05 | FromDiscord | <mratsim> drNim |
11:51:16 | FromDiscord | <mratsim> compile-time bound checks |
11:52:15 | FromDiscord | <exelotl> I'm unsure about this bit - is Nim really better than Zig at avoiding these or is it just trying to make Nim look good? :P https://media.discordapp.net/attachments/371759389889003532/823524472371806238/unknown.png |
11:52:29 | FromDiscord | <flywind> btw we have https://github.com/nim-lang/RFCs/issues/244 data races is possible to be prevented at compile time. |
11:52:38 | FromDiscord | <flywind> (edit) "is" => "are" |
11:53:17 | PMunch | @Gary M, the Nim columns are missing? |
11:53:51 | FromDiscord | <Gary M> wait one sec |
11:53:54 | PMunch | @mratsim, since he doesn't include external checking tools for C I tried to stay comparative |
11:53:58 | FromDiscord | <Gary M> was the wrong link |
11:53:59 | FromDiscord | <exelotl> (I have no idea how big of a problem use-after-free and such is in Zig) |
11:54:05 | FromDiscord | <Gary M> everything is correct now Mr Munch |
11:54:21 | FromDiscord | <konsumlamm> In reply to @exelotl "I'm unsure about this": i mean, in Nim these usually don't happen in the first place, because you use GC |
11:54:28 | PMunch | @exelotl, no idea what Zig does, but those things aren't really something you'd run into on Nim unless you where doing manual memory management |
11:54:29 | FromDiscord | <konsumlamm> and in Zig rhere is no GC |
11:54:44 | FromDiscord | <konsumlamm> and Zig is not fully memory safe either |
11:55:15 | FromDiscord | <exelotl> if manual alloc/free are commonplace in all Zig code then sure we can say Nim is better x) |
11:55:15 | FromDiscord | <Gary M> isn't Zig mostly C anyways |
11:55:42 | FromDiscord | <Gary M> and the zig compiler is just clang with caching? |
11:55:55 | FromDiscord | <konsumlamm> umm no |
11:56:09 | FromDiscord | <konsumlamm> C doesn't have powerful CTFE last i checked |
11:56:50 | FromDiscord | <Gary M> I mean yes zig is transpiling to C and doing CT checks? |
11:57:09 | FromDiscord | <konsumlamm> CT calculations too |
11:57:19 | FromDiscord | <konsumlamm> like Nim can |
11:57:46 | FromDiscord | <konsumlamm> and through the comptime stuff Zig also gets generics more or less |
11:58:07 | FromDiscord | <konsumlamm> and i don't think the C standard library has a focus on allocators |
11:58:26 | FromDiscord | <konsumlamm> ~~or even exists in a meaningful way in the first place~~ |
11:58:28 | FromDiscord | <Gary M> I'm saying that zig is a lot closer to C than nim is to C π |
11:58:38 | FromDiscord | <konsumlamm> that is correct |
11:58:42 | PMunch | Addad a note about the `Isolated` thing |
11:59:12 | PMunch | Does it otherwise look good to people? |
11:59:22 | PMunch | I'm not over-promising anything here? |
11:59:40 | FromDiscord | <Gary M> I'm not knowledgeable enough to say one way or the other. |
12:03:36 | FromDiscord | <konsumlamm> hmm, looks right do me, though i'm not exactly sure what's meant by "type confusion" |
12:04:54 | FromDiscord | <konsumlamm> also, null pointer dereference for Rust is mostly compile time, since references can't be null, so you usually use an option type, where you're forced to check for "null" before dereferencing... |
12:07:16 | PMunch | @konsumlamm, type confusion is casting types to something it's not I believe |
12:07:51 | FromDiscord | <konsumlamm> hmm, idk what the "only when using tagged unions" comment is supposed to mean then, sounds like the author doesn't understand tagged unions |
12:08:52 | PMunch | Tagged unions are the same as our case types right? |
12:09:58 | * | sacredfrog quit (Quit: ZNC 1.8.2 - https://znc.in) |
12:10:40 | * | sacredfrog joined #nim |
12:10:42 | FromDiscord | <konsumlamm> basically ye |
12:11:12 | FromDiscord | <konsumlamm> but the kind is not exposed directly |
12:11:59 | timdorohin | how would somebody implement delta-objects in nim? |
12:13:30 | PMunch | timdorohin, delta-objects? |
12:14:50 | timdorohin | in C i've implemented them once, and they was something like pointer to base object, bitfield for listing overrided members+uint8 VLA from which i can read said members data |
12:18:37 | PMunch | And what do they do? |
12:19:12 | PMunch | Responded to the Zig thing here by the way: https://www.reddit.com/r/nim/comments/maj1lz/nim_safety_in_comparision_to_c_zig_and_rust/ |
12:21:29 | timdorohin | Isn't it obvious? They usually used for holding incremental changes efficiently |
12:22:21 | * | NimBot joined #nim |
12:22:37 | PMunch | Ah so you want to track the differences made to an object? |
12:24:27 | PMunch | I mean you can do the same thing you did in C a pointer (or better yet a reference) to an object, then a set[] of the edited fields, and a sequence of new data |
12:27:41 | timdorohin | PMunch: i know, question is: how i can make this nim-ideomatically? |
12:29:13 | timdorohin | macro-magically generating object type derived from base object and creating getters/setters for all fields? |
12:30:59 | FromDiscord | <mratsim> you use getTypeImpl to copy the base type fields |
12:34:08 | ForumUpdaterBot | New thread by Mantielero: Winim - onenote, see https://forum.nim-lang.org/t/7677 |
12:34:24 | timdorohin | mratsim: i'm not really asking for _how_ it should work internally, more for what interface it should have |
12:35:29 | timdorohin | getters/setters for every field? overloaded `.` and `.=`? |
12:39:24 | timdorohin | or should it not pretend to be compatible with base object and implement something like getField(enum field): Field where field object would contain info like was it overrided or not and so on |
12:47:23 | PMunch | Depends on what you want really |
12:47:35 | PMunch | I'd create templates for each field I think |
12:58:29 | FromDiscord | <mratsim> same, if you're within a macros creating template is cheap |
12:58:41 | FromDiscord | <mratsim> the `.` and `.=` creates weird error otherwise. |
13:00:16 | * | xet7 quit (Quit: Leaving) |
13:01:44 | * | xet7 joined #nim |
13:16:38 | * | narimiran quit (Quit: leaving) |
13:17:45 | * | narimiran joined #nim |
13:25:01 | FromDiscord | <konsumlamm> @flywind what is `std/tasks` about? is there any RFC or similar for it? |
13:29:06 | * | JustASlacker joined #nim |
13:35:16 | FromDiscord | <flywind> no, but it is half of new threadpool implementation. You can think of it as reimplementing `spawn` with macros. |
13:53:29 | FromDiscord | <konsumlamm> ah, interesting |
14:10:17 | ozzz | libfcgi works finally... |
14:13:02 | ozzz | only smth wrong with FCGX_GetParam, looks like it modifies smth in memory |
14:13:47 | FromDiscord | <exelotl> In reply to @PMunch "I'd create templates for": Oh yeah I'm using dot operators in my code and should really be doing this instead |
14:15:15 | PMunch | @exelotl, two ways to do it, each with pros and cons I guess |
14:17:50 | FromDiscord | <exelotl> Yeah, I think the main con is that dot operators result in some very unclear error messages |
14:19:47 | FromDiscord | <exelotl> I have a proc that acts on a type which has dot operators enabled. I delete the proc, but its still being called somewhere. I get errors about dot operator resolution instead of the attempt to call a nonexistent proc. |
14:20:30 | FromDiscord | <exelotl> (edit) "I have a proc that acts on a type which has dot operators enabled. I delete the proc, but its still being called somewhere. I get errors about ... dotis" added "whatever the" | "resolution" => "is trying to do" |
14:21:12 | FromDiscord | <Yardanico> You can annotate it as error/deprecated to see where it is being called |
14:21:24 | FromDiscord | <Yardanico> I mean the proc itself |
14:21:34 | FromDiscord | <exelotl> Yeah true |
14:23:30 | FromDiscord | <hamidb80> sent a code paste, see https://paste.rs/Fn1 |
14:24:20 | FromDiscord | <InventorMatt> if you need to mutate the value like return a value from a table that you want to change |
14:24:58 | FromDiscord | <Yardanico> Yep, exactly |
14:25:22 | FromDiscord | <Yardanico> You can also return `lent T` but this is a much newer thing |
14:25:41 | FromDiscord | <Yardanico> (it's an immutable view into T, avoids copies) |
14:29:15 | FromDiscord | <hamidb80> In reply to @InventorMatt "if you need to": and that table must not defined in the proc scope |
14:29:46 | FromDiscord | <Yardanico> ? |
14:29:47 | FromDiscord | <Yardanico> Of course |
14:30:10 | FromDiscord | <Yardanico> Because otherwise you'll violate memory safety and return a pointer to a location on local stack |
14:30:16 | FromDiscord | <hamidb80> because it escapes its stack frame |
14:30:23 | FromDiscord | <Yardanico> If it's a ref it should work though |
14:30:33 | FromDiscord | <Yardanico> (not sure) |
14:30:41 | FromDiscord | <hamidb80> anyway |
14:32:24 | FromDiscord | <hamidb80> when should I use `ref type` instead of `type`?β΅for e.g. `TableRef` vs `Table` |
14:33:14 | FromDiscord | <Yardanico> when you need ref semantics - shared ownership, something like that :) |
14:33:54 | FromDiscord | <hamidb80> do you suggest any articles about it? |
14:34:21 | FromDiscord | <Yardanico> There have been quite a lot of forum threads about this |
14:34:22 | FromDiscord | <Yardanico> https://forum.nim-lang.org/t/1207 |
14:34:50 | FromDiscord | <Yardanico> https://forum.nim-lang.org/t/7218 |
14:35:02 | Oddmonger | how can i get number of elements in an enum ? sizeof returns 1, whatever number of elements defined |
14:36:42 | FromDiscord | <Yardanico> Also you might want to give https://zevv.nl/nim-memory/ a read |
14:36:42 | Oddmonger | it's for initializing an array which will have the size of the number of arguments of the enum |
14:37:24 | FromDiscord | <Yardanico> You can just use the enum itself to index the array |
14:37:34 | * | JustASlacker quit (Ping timeout: 256 seconds) |
14:38:09 | Oddmonger | the last element, you mean ? |
14:38:52 | FromDiscord | <Yardanico> I mean https://github.com/nim-lang/Nim/wiki/Lesser-known-Nim-features#using-enums-as-array-indexes |
14:38:52 | FromDiscord | <Solitude> `array[Enum, int]` |
14:39:58 | * | vicfred quit (Quit: Leaving) |
14:40:05 | Oddmonger | ah nice |
14:40:08 | Oddmonger | thank you |
14:40:12 | FromDiscord | <Yardanico> But if you really want to, you can get the length for most normal enums (without holes) with MyEnum.high - MyEnum.low |
14:40:47 | FromDiscord | <InventorMatt> is something like this https://play.nim-lang.org/#ix=2TKc going to be possible with the new views? |
14:41:09 | FromDiscord | <Solitude> In reply to @Yardanico "But if you really": MyEnum.high.ord - MyEnum.low.ord |
14:41:11 | FromDiscord | <Yardanico> Sorry, forgot ord |
14:41:23 | * | vicfred joined #nim |
14:41:33 | FromDiscord | <Yardanico> In reply to @InventorMatt "is something like this": What does this do? |
14:41:56 | FromDiscord | <Yardanico> Ah, if you mean mutable views, then yes, I think |
14:42:33 | FromDiscord | <Yardanico> But I don't think that it works now |
14:42:35 | FromDiscord | <Yardanico> https://nim-lang.org/docs/manual_experimental.html#view-types |
14:42:36 | FromDiscord | <InventorMatt> like I have a bunch of variables that i want to then iterate through but i don't want to initially keep them in a seq |
14:42:52 | FromDiscord | <InventorMatt> and mutate them while iterating |
14:43:48 | FromDiscord | <Yardanico> You can do it with a macro in that case, no? |
14:45:12 | FromDiscord | <InventorMatt> I was just wondering if there was a way without macros. I've done easily with raw pointers in nim before so i was just curious if views would allow an easier way to do it |
14:46:02 | FromDiscord | <Yardanico> Yeah, they eventually should |
14:46:02 | FromDiscord | <aryn> how would you determine which OS a nim app is running on? similar to python's os.name |
14:46:50 | liblq-dev | hostOs |
14:47:01 | FromDiscord | <aryn> ah cheers |
14:47:01 | liblq-dev | https://nim-lang.org/docs/system.html#hostOS |
14:47:14 | FromDiscord | <Yardanico> that's a compile time thing because you're compiling for one OS anyway |
14:47:22 | FromDiscord | <Yardanico> To get the exact version you might need other APIs though |
14:47:24 | FromDiscord | <aryn> oh true, yeah |
14:47:44 | FromDiscord | <Aiz> sent a code paste, see https://play.nim-lang.org/#ix=2TKe |
14:47:49 | liblq-dev | still useful if you need to print it out or check what OS you're compiling for with `when` |
14:47:54 | FromDiscord | <aryn> although i could recompile to windows and it would change? |
14:48:09 | liblq-dev | yeah |
14:48:09 | FromDiscord | <aryn> so i could make an app which is cross platform by checking that? |
14:48:27 | FromDiscord | <aryn> alright, cool |
14:48:59 | liblq-dev | there's also `defined(windows)`, `defined(macosx)`, `defined(posix)`, `defined(linux)` and the like but i don't remember each and every one of them |
14:49:03 | FromDiscord | <Yardanico> You can have different code at compile time depending on the OS, and hostOS is optimal |
14:49:08 | FromDiscord | <Yardanico> Optional |
14:49:17 | FromDiscord | <Yardanico> Yeah the defines |
14:49:30 | FromDiscord | <aryn> yea i saw those defined things in source, but wasnt sure how they worked |
14:50:25 | FromDiscord | <Yardanico> There's nothing complicated about those, it's just checking whether a symbol has been defined |
14:50:34 | FromDiscord | <Yardanico> Compiler defines a lot of symbols you could check for |
14:50:58 | liblq-dev | you can make your own too, by passing `-d:something` during compilation |
14:51:03 | liblq-dev | and then you can check `defined(something)` |
14:51:20 | FromDiscord | <aryn> yea that was what i was confused about. the symbols arent defined in file, but makes sense if they're done by the compile |
14:51:20 | FromDiscord | <aryn> (edit) "compile" => "compilee" |
14:51:21 | FromDiscord | <aryn> (edit) "compilee" => "compiler" |
14:52:23 | FromDiscord | <aryn> alright thanks, everything's working as intended now |
15:01:06 | FromDiscord | <Lefl> sent a code paste, see https://paste.rs/Fjr |
15:02:00 | FromDiscord | <Yardanico> can you show the full error? |
15:02:22 | FromDiscord | <Lefl> That is the full error |
15:02:36 | FromDiscord | <Yardanico> @Lefl it's supposed to be var r |
15:02:48 | FromDiscord | <Yardanico> You need to mutate the random state so it needs to be mutable |
15:02:53 | FromDiscord | <Lefl> Aah |
15:02:56 | FromDiscord | <Lefl> Thank you very much |
15:03:02 | FromDiscord | <Yardanico> In reply to @Lefl "That is the full": The compiler provides a more complete context |
15:03:08 | FromDiscord | <Lefl> Oh I see |
15:13:39 | * | PMunch quit (Quit: leaving) |
15:20:27 | ForumUpdaterBot | New thread by HJarausch: Location of nimdoc.css ?, see https://forum.nim-lang.org/t/7679 |
15:22:27 | ForumUpdaterBot | New thread by HJarausch: RunnableExamples need random - what can I do?, see https://forum.nim-lang.org/t/7680 |
15:25:31 | reversem3 | Is it possible to create a relative large size program using only functional paradigm for nim? Using only the sequtils for closures, filter, map ... and I know there is more but right now that is what I'm up to |
15:26:03 | reversem3 | * Is it possible to create a relative large size program using only functional paradigm for nim? Using only the sequtils for closures, filter, map ... and I know there is more but right now that is what I'm up to in the manual. |
15:26:27 | ForumUpdaterBot | New thread by HJarausch: I'd like to make a tiny contribution to stats.nim - how to?, see https://forum.nim-lang.org/t/7681 |
15:26:46 | reversem3 | Also would this only include function instead of proc because of no side effects? |
15:26:54 | FromDiscord | <mratsim> In reply to @reversem3 "Is it possible to": Sure, do yourself a favor and use https://github.com/vegansk/nimfp and https://github.com/nigredo-tori/classy |
15:27:16 | FromDiscord | <mratsim> you can't write useful programs without side-effects |
15:27:41 | FromDiscord | <mratsim> unless you hardcode everything and your program has no inputs. |
15:27:54 | reversem3 | ok I know about the fp libraries but I would like to just learn how do it via just what nim has. |
15:28:19 | FromDiscord | <Yardanico> @oprypin gitter bridge seems to be down again :( |
15:28:48 | reversem3 | I like elixir and thats functional and works great , but its not nim |
15:28:56 | FromDiscord | <Yardanico> gitter is a wasteland now https://media.discordapp.net/attachments/371759389889003532/823579002190299136/unknown.png |
15:28:57 | FromDiscord | <mratsim> I solved a couple of project euler problems in a fully functional way https://github.com/mratsim/nim-project-euler/blob/master/src/lib/functional.nim |
15:29:21 | reversem3 | very cool |
15:30:18 | FromDiscord | <mratsim> note, that is probably my very first nim code |
15:30:23 | reversem3 | this is great comments |
15:30:24 | reversem3 | proc takeWhile*[T](iter: iterator(): T, cond: proc(x: T):bool): iterator(): T = |
15:30:24 | reversem3 | ## .. code-block:: Nim |
15:30:24 | reversem3 | ## takeWhile(1;2;3;4, proc(x: int): bool = x < 4) -> 1;2;3 |
15:30:45 | FromDiscord | <mratsim> so it's before I understood Nim, and it might not be idiomatic |
15:31:25 | FromDiscord | <mratsim> or even {.closure.} vs {.nimcall.} it seems |
15:32:51 | reversem3 | ok , hey you gave me something so I thank you |
15:33:51 | reversem3 | paradigms for nim is like having a blank canvas , you can do pretty much whatever you want |
15:34:02 | FromDiscord | <Yardanico> i just don't get it - how rosettacode, being such a popular resource, has such bad infrastructure/software? |
15:34:19 | FromDiscord | <Yardanico> there has been an attempt to fork it and make a github repo but it failed (no activity whatsoever) |
15:34:57 | * | asdflkj quit (Ping timeout: 260 seconds) |
15:37:28 | FromDiscord | <mratsim> it's popular but at one point when you have the skill to improve on Rosetta you graduated from needing it. |
15:37:34 | FromDiscord | <Yardanico> XD |
15:37:45 | FromDiscord | <Yardanico> it still might help other people but contributing is really horrible |
15:39:20 | * | asdflkj joined #nim |
15:39:42 | FromDiscord | <Yardanico> and the fact that it uses some outdated PHP software for highlighting which hasn't been updated since 2017 |
15:39:57 | FromDiscord | <Yardanico> GeSHi |
15:40:26 | FromDiscord | <Yardanico> oh actually it's been updated in oct 2019 sorry |
15:46:30 | ForumUpdaterBot | New thread by HJarausch: Generics overload - which one is selected?, see https://forum.nim-lang.org/t/7682 |
15:46:45 | FromDiscord | <Yardanico> HJarausch creating too much forum threads |
16:02:34 | FromDiscord | <Goel> Probably is not necessary, since Nim / Learn page have of resources, but maybe we can have Nimlings too (based on RUstlings and Ziglings) "Welcome to Ziglings! This project contains a series of tiny broken programs. By fixing them, you'll learn how to read and write Rust/Zig/Nim code." |
16:02:45 | FromDiscord | <Goel> (edit) "" => "a lot" |
16:04:38 | FromDiscord | <Yardanico> there's already someone doing that |
16:04:54 | FromDiscord | <Yardanico> https://github.com/sergiotapia/nimlings |
16:11:28 | * | sixtyten joined #nim |
16:15:13 | * | vicfred quit (Quit: Leaving) |
16:16:59 | * | vicfred joined #nim |
16:19:19 | * | haxscramper joined #nim |
16:26:42 | reversem3 | Yep this is fun https://github.com/sergiotapia/nimlings |
16:29:04 | reversem3 | Thanks Yardanico |
16:43:18 | * | fredrikhr quit (Ping timeout: 265 seconds) |
16:46:44 | * | waleee-cl joined #nim |
16:57:34 | * | fredrikhr joined #nim |
17:00:05 | * | Gustavo6046 quit (Quit: ZNC 1.8.2 - https://znc.in) |
17:00:37 | FromDiscord | <haxscramper> I need to start several processes at once, and repeatedly launch new when an old one finishes so that number of concurrently running processes is kept at 10. When process finished it has to report some results to main launcher. What would be the best way to do this using standard library? |
17:01:42 | ozzz | why it appear: type mismatch: got <Thread[system.void], proc (){.closure, gcsafe, locks: 0.}> |
17:01:44 | ozzz | & |
17:01:57 | FromDiscord | <haxscramper> I suppose it can be done with async, but I'm not exactly sure how, so if someone has an example it would really appreciate it |
17:02:14 | ozzz | proc declared as proc worker() {.thread.} = |
17:03:59 | ozzz | afk.. |
17:10:11 | FromDiscord | <haxscramper> Also wrap this all in iterator, so when new process from process pool finished, I would get its results immediately. |
17:14:21 | FromDiscord | <Gary M> C/C++ Macros are the worst |
17:14:52 | FromDiscord | <Gary M> `IRenderDevice_CreateShader(pDevice, &ShaderCI, &pVS);` this looks like innocent enough C code as an extern for C++ code |
17:15:01 | FromDiscord | <Gary M> but they're sneaky. That shit is a macro |
17:15:21 | FromDiscord | <Gary M> `(pDevice)->pVtbl->RenderDevice.CreateShader((IRenderDevice)(pDevice), &ShaderCI, &pVS);` is the actual expanded value |
17:16:07 | FromDiscord | <jtiai> sent a code paste, see https://play.nim-lang.org/#ix=2TLm |
17:16:18 | FromDiscord | <Gary M> stdint sounds like C++ |
17:16:34 | FromDiscord | <Gary M> try compiling with the c++ backend |
17:17:07 | FromDiscord | <Gary M> or I guess it would be i586-elf-g++, if that's a thing |
17:17:21 | FromDiscord | <Gary M> if not, try passing the proper c++ and std args to it |
17:17:23 | FromDiscord | <jtiai> I won't have include files anyway since I'm cross compiling... |
17:17:36 | FromDiscord | <Gary M> well it's looking for a standard lib header π |
17:17:43 | FromDiscord | <Gary M> that's just going to be an include |
17:18:03 | FromDiscord | <Gary M> https://media.discordapp.net/attachments/371759389889003532/823606462940577813/unknown.png |
17:18:54 | FromDiscord | <Gary M> if your code relies on either a C or C++ stdlib header and you're not going to provide it, it just won't compile.. that should be obvious |
17:19:37 | FromDiscord | <jtiai> My code doesn't. |
17:19:44 | FromDiscord | <jtiai> It comes from nim somewhere. |
17:20:21 | FromDiscord | <jtiai> `--os:standalone --gc:none` I use those flags for nim. |
17:20:22 | FromDiscord | <Gary M> well your compiler isn't including the libs necessary for nim to compile then |
17:20:28 | FromDiscord | <jtiai> There are no libs. |
17:20:33 | FromDiscord | <Gary M> I know8 |
17:20:38 | FromDiscord | <Gary M> (edit) "know8" => "know" |
17:21:04 | FromDiscord | <jtiai> Nim shouldn't be expecting anything since at least I try to tell that it's bare metal system. |
17:23:43 | FromDiscord | <mratsim> It should expect a working C / C++ toolchain |
17:24:29 | FromDiscord | <jtiai> I have one. |
17:25:00 | FromDiscord | <jtiai> At least I think I do (for bare metal x86 system) |
17:26:31 | FromDiscord | <jtiai> I'm trying things like this: https://github.com/watzon/JackOS or https://github.com/mikra01/nimkernel_ext or https://github.com/dom96/nimkernel |
17:28:30 | FromDiscord | <Gary M> in nimkernel he's linking ` direShell CC, "-T linker.ld -o main.bin -ffreestanding -O2 -nostdlib boot.o nimcache/main.o nimcache/stdlib_system.o nimcache/stdlib_unsigned.o nimcache/ioutils.o"` |
17:28:53 | FromDiscord | <Gary M> so there's your hint π |
17:28:56 | watzon | Oh hello there lol |
17:29:40 | * | Gustavo6046 joined #nim |
17:35:10 | FromDiscord | <jtiai> In reply to @Gary M "in nimkernel he's linking": But I'm not getting the object files yet... |
17:36:25 | FromDiscord | <Gary M> You might have to pass the flags like -nostdlib to the linker... You could replicate his setup with nake or do it with nimble tasks |
17:37:43 | FromDiscord | <jtiai> Right. Thanks pointing out since now I see that -nostdlib is missing from compilation output... |
17:37:56 | FromDiscord | <jtiai> I knew that here are smart people π |
17:38:08 | FromDiscord | <Gary M> Also, did you check your Nimcache directory for the build artifacts? |
17:38:27 | FromDiscord | <Gary M> If it's only failing on linking you might still have the object files |
17:38:58 | FromDiscord | <Gary M> Also no no I'm not smart |
17:40:42 | FromDiscord | <jtiai> Custom build dir, -nostdlib is there but still nim tries to include stdint.h |
17:41:13 | FromDiscord | <jtiai> sent a code paste, see https://play.nim-lang.org/#ix=2TLq |
17:45:01 | FromDiscord | <Gary M> Are you doing that with passL |
17:46:49 | * | blackpawn_ joined #nim |
17:47:35 | * | blackpawn quit (Ping timeout: 265 seconds) |
17:47:36 | FromDiscord | <jtiai> no? |
17:47:59 | FromDiscord | <jtiai> IOW, I've no clue what "passL" is. |
17:49:37 | * | lritter quit (Ping timeout: 256 seconds) |
17:50:18 | * | blackpawn joined #nim |
17:51:44 | * | blackpawn_ quit (Ping timeout: 265 seconds) |
17:57:00 | FromDiscord | <Gary M> https://nim-lang.org/docs/nimc.html |
17:57:22 | FromDiscord | <Gary M> "pass an option to the linker" |
18:05:46 | reversem3 | so passed nimlings |
18:06:00 | reversem3 | is the deep dive referring to the manual? |
18:06:19 | reversem3 | Covers the 80% of Nim you'll see the majority of the time. |
18:06:19 | reversem3 | If you need to learn the other 20%, we'll provide good sources to dive deep. |
18:17:50 | * | JustASlacker joined #nim |
18:18:22 | FromDiscord | <jtiai> In reply to @Gary M ""pass an option to": Not using that. Though I think my build is stuck at compilation phase. |
18:25:16 | ozzz | Guys, seems I miss something, I created proc proc worker() {.thread.} =, but createThread(thr[i], worker) raises err: Error: type mismatch: got <Thread[system.void], proc (){.closure, gcsafe, locks: 0.}> |
18:25:39 | ozzz | thr defined as: thr: array[10, Thread[void]] |
18:26:12 | ozzz | what may cause this? |
18:29:03 | FromDiscord | <haxscramper> You have `{.closure.}` annotation on procedure, while https://nim-lang.org/docs/threads.html#createThread%2CThread%5Bvoid%5D%2Cproc%29 requires `{.nimcall, thread.}` |
18:29:40 | FromDiscord | <haxscramper> Maybe this is the reason. If you create `worker` in local context it is most likely a closure |
18:29:57 | FromDiscord | <haxscramper> Try to annotate it with `{.nimcall.}` explicitly - it will error out if you capture something |
18:32:12 | reversem3 | so reading the style guide and if you use the std lib you should first reference the std lib? |
18:32:13 | reversem3 | Standard library imports should be prefixed with std/, like std/os, std/[strutils, sequtils], etc. |
18:32:33 | * | vicfred quit (Quit: Leaving) |
18:32:36 | reversem3 | so if I want to use strformat I should use std/strformat ? |
18:32:49 | reversem3 | not just import strformat ? |
18:33:10 | ozzz | haxscramper, thanks, I will try now |
18:33:46 | FromDiscord | <haxscramper> In reply to @reversem3 "so reading the style": Yes, it is recommended to do `std/` for all new code |
18:34:54 | reversem3 | ok didn't know what |
18:35:01 | reversem3 | * ok didn't know that |
18:35:36 | * | icebattle joined #nim |
18:41:50 | * | casaca quit (Ping timeout: 272 seconds) |
18:43:40 | FromDiscord | <haxscramper> Is it possible to create `seq[Future]` and await for its completion, and then add new future to that list? This is still related to my previous question, but I think I can just try and keep several `sleep()` procs at the same time and then introduce processes |
18:46:40 | FromDiscord | <jtiai> sent a code paste, see https://play.nim-lang.org/#ix=2TLT |
18:49:55 | FromDiscord | <haxscramper> @jtiai do you have it in `--includepath` for the C compiler? |
18:50:38 | FromDiscord | <haxscramper> Try running compilation with `--passC:-v` to show include paths (if this gcc toolchain supports it) |
18:50:53 | FromDiscord | <jtiai> No. There are no headers because I'm compiling for bare metal... |
18:51:14 | FromDiscord | <haxscramper> I doubt it matters what you are compiling to |
18:51:45 | FromDiscord | <haxscramper> If your code includes something then header must be present, or you are working with single big C file |
18:52:11 | FromDiscord | <haxscramper> And nim might use some convenience C typedefs from `stdint.h` anyway |
18:53:24 | FromDiscord | <jtiai> That's not how cross compilation works. |
18:54:06 | FromDiscord | <TurtleP> Hey β so Iβm wondering how I can simply read a file and change its binary data. Specifically data on this page: <https://www.3dbrew.org/wiki/SMDH> for example |
18:55:12 | FromDiscord | <haxscramper> In reply to @TurtleP "Hey β so Iβm": I think you can read a file as a string (nim string is a sequence of bytes), change some values and write it back. |
18:56:03 | FromDiscord | <haxscramper> So `var icon = readFile("file.ico"); icon[0] = char(0x40); writeFile("file.ico", icon);` |
18:56:47 | * | Gustavo6046 quit (Ping timeout: 260 seconds) |
18:56:53 | FromDiscord | <haxscramper> I suppose |
18:57:03 | * | Gustavo6046 joined #nim |
18:57:07 | FromDiscord | <Yardanico> You can also try to use file streams |
18:57:08 | * | Gustavo6046 quit (Remote host closed the connection) |
18:57:19 | FromDiscord | <Yardanico> Not sure how easy it would be to modify existing data though |
18:57:51 | * | conkker joined #nim |
18:58:03 | * | Gustavo6046 joined #nim |
18:59:15 | FromDiscord | <haxscramper> In reply to @haxscramper "I need to start": @DefinitelyNotYardanico Do you have any pointers for using async with processes? Or just launching and awaiting multiple procs at once? |
18:59:56 | * | JustASlacker quit (Ping timeout: 256 seconds) |
19:01:47 | FromDiscord | <Yardanico> In reply to @haxscramper "I need to start": Not sure, maybe you can try https://nim-lang.org/docs/osproc.html#execProcesses%2CopenArray%5Bstring%5D%2Cproc%28int%29%2Cproc%28int%2CProcess%29 ? |
19:02:31 | FromDiscord | <lbart> https://benhoyt.com/writings/count-words/ not bad for nim π |
19:06:13 | FromDiscord | <haxscramper> In reply to @Yardanico "Not sure, maybe you": Yes, but I was hoping I could use async somehow to do this (because I also need to get all execution results, not just highest exit code for one process), instead of just copying part of this implementation and rewriting it for my needs |
19:06:33 | FromDiscord | <Yardanico> In reply to @haxscramper "Yes, but I was": But this proc has a callback, no? |
19:06:39 | FromDiscord | <Yardanico> So maybe you can get the output stream |
19:08:57 | FromDiscord | <TurtleP> In reply to @haxscramper "So `var icon =": Hm are there ways to substring? In python I could read it in as binary and then just do str[start:end] |
19:09:09 | FromDiscord | <haxscramper> In reply to @Yardanico "So maybe you can": I need to yield results immediately as they occur instead of waiting for all at once. But I guess implementing this with async is either impossible, or at least too hard (because right now it looks like I would need to use some lower-level details of async, which are basically undocumented, except for some brief description of the procs) |
19:09:30 | FromDiscord | <haxscramper> But I might be wrong |
19:09:36 | FromDiscord | <Yardanico> In reply to @TurtleP "Hm are there ways": It depends on what you want to do, yes you can get a substring or modify a substring |
19:10:49 | FromDiscord | <TurtleP> Alright |
19:33:13 | FromDiscord | <jtiai> Hmm... I think I'm getting why my cross compilation fails. Looks like nim checks certain patterns, like is compiler C99/C11 and makes few decisions in `nimbase.h`. So what would be correct way to resolve it? Provide custom stdint.h? Some flag that says my system doesn't have one? |
19:35:25 | ForumUpdaterBot | New thread by Vitreo12: Manually initializing exception handling, see https://forum.nim-lang.org/t/7683 |
19:48:13 | ozzz | haxscramper, Seems nested function cannot be processed |
19:49:01 | ozzz | same code works outside funct. |
19:56:52 | * | Gustavo6046 quit (Ping timeout: 260 seconds) |
19:58:07 | FromDiscord | <haxscramper> Have you tried using `.nimcall.` explicitly? |
19:59:16 | ozzz | yes, proc worker() {.thread, nimcall.} = |
20:00:02 | ozzz | type mismatch: got <Thread[system.void], proc (){.closure, gcsafe, locks: 0.}> |
20:02:41 | FromDiscord | <jtiai> sent a code paste, see https://play.nim-lang.org/#ix=2TMr |
20:02:54 | * | Gustavo6046 joined #nim |
20:05:54 | FromDiscord | <haxscramper> In reply to @ozzz "yes, proc worker()": That is quite strange, because .nimcall. and .closure. are mutually exclusive. https://nim-lang.org/docs/manual.html#types-procedural-type. so explicit annotation was supposed to solve this. Moving procedure declaration to to top-level makes it .nimcall. automatically (because all external variables it might reference are global, so nothing no capture) |
20:07:15 | ozzz | FromDiscord, thanks for explanation. I need to find another way how solve it |
20:17:54 | FromDiscord | <jtiai> @haxscramper managed to resolve it. Bug was actually in my nim.cfg: `--passc:"-w -I$lib -ffreestanding -O2 -Wall -Wextra -nostdlib ` $lib is empty so -I took -ffreestanging as a paremeter. You can guess the rest... π |
20:21:47 | * | FromGitter joined #nim |
20:22:40 | FromDiscord | <haxscramper> https://media.discordapp.net/attachments/371759389889003532/823652919059808256/unknown.png |
20:25:34 | FromDiscord | <jtiai> Darn I've a winner feeling! π₯³ |
20:26:19 | FromDiscord | <Yardanico> In reply to @haxscramper "": Cursed |
20:28:19 | FromDiscord | <jtiai> Thank you for @Gary M and you too @haxscramper . Pushed me to right direction... Now I can write completely useless operating system. |
20:31:58 | * | casaca joined #nim |
20:32:55 | ozzz | haxscramper, I found issue, it was global constant which I forgot to define in threadProc |
20:40:23 | FromDiscord | <jfmonty2> sent a code paste, see https://play.nim-lang.org/#ix=2TN0 |
20:41:17 | FromDiscord | <jfmonty2> It seems like the per-function percentages are how much of the total runtime was spent in that stack frame, hence `main` being 100% since it wraps the entire program, but if it's spending 46% of the time in `comparisons.nim` then why is this entry only `1.67%`? |
20:42:18 | * | abm joined #nim |
20:46:31 | * | haxscramper quit (Remote host closed the connection) |
20:46:53 | * | haxscramper joined #nim |
20:48:54 | * | haxscramper quit (Remote host closed the connection) |
20:49:49 | * | PMunch joined #nim |
20:56:21 | * | narimiran quit (Ping timeout: 264 seconds) |
20:57:39 | ForumUpdaterBot | New post on r/nim by Alh4zr3d: Stupid, beginner question about the compiler commands..., see https://reddit.com/r/nim/comments/maxqwl/stupid_beginner_question_about_the_compiler/ |
21:03:38 | FromDiscord | <clyybber> In reply to @haxscramper "": https://media.discordapp.net/attachments/371759389889003532/823663230504534046/52qcyc.png |
21:07:40 | FromDiscord | <Yardanico> separators |
21:08:06 | FromDiscord | <Yardanico> separator aah |
21:15:05 | FromDiscord | <sealmove> not nim related but I have an `int64` and an `int32` and I want to encode them in a fixed-length string? is there something better/shorter than printing `a.toHex(16) & b.toHex(8)`? |
21:21:02 | FromDiscord | <Yardanico> @sealmove you can always pad them with zeroes I guess? And still have them in base10 |
21:21:06 | PMunch | Didn't this use to cast an error? https://play.nim-lang.org/#ix=2TNb |
21:22:22 | PMunch | Hmm, it did up until 1.0.2 and 1.2.0 |
21:22:37 | PMunch | That's a weird thing to remove in a patch update to 1.0 |
21:23:05 | FromDiscord | <sealmove> In reply to @Yardanico "<@173424250319929344> you can always": oh hmm, will it be shorter? |
21:23:38 | FromDiscord | <sealmove> i mean in worst case senario base 10 should be longer than base 16, so if i want fixed length it must be longer... |
21:28:37 | timdorohin | sealmove: base64? |
21:31:25 | FromDiscord | <sealmove> how do you convert an integer to base64 though? |
21:32:49 | * | jjido joined #nim |
21:33:33 | FromDiscord | <sealmove> I guess I'll have to write my own code for this. nim's module `base64` is only for encoding strings, which is natural. |
21:34:01 | timdorohin | sealmove: import base64 |
21:34:09 | timdorohin | sealmove: u r wrong |
21:34:26 | timdorohin | base64 function definition -> proc encode[T: SomeInteger | char] |
21:34:59 | FromDiscord | <sealmove> but it's for openArray |
21:35:00 | timdorohin | see SomeInteger? |
21:35:10 | timdorohin | and? |
21:35:26 | FromDiscord | <sealmove> hmm |
21:36:16 | timdorohin | [some-int] would work imo |
21:36:48 | PMunch | So no one knows where the range check for type conversions went? |
21:37:41 | FromDiscord | <sealmove> In reply to @timdorohin "[some-int] would work imo": i guess it works, thanks ;) |
21:37:57 | * | JustASlacker joined #nim |
21:38:16 | FromDiscord | <sealmove> In reply to @PMunch "So no one knows": are you sure it's not intentional? |
21:38:40 | PMunch | It might be, still a bit dubious that it was removed in 1.0.2 but present int 1.0.0 |
21:39:02 | FromDiscord | <sealmove> indeed |
21:40:24 | FromDiscord | <sealmove> In reply to @timdorohin "[some-int] would work imo": ok but... I want to be able to get the integers back |
21:41:03 | FromDiscord | <sealmove> do I need to cast the string that decode returns? |
21:42:33 | PMunch | What exactly is it that you're trying to achieve here? |
21:44:19 | * | JustASlacker quit (Quit: Leaving) |
21:45:23 | FromDiscord | <sealmove> i want to encode 2 integers in fixed-length string, and I want this string to be as small as possible |
21:45:35 | PMunch | Define string |
21:45:45 | FromDiscord | <sealmove> printable chars |
21:46:00 | PMunch | Define printable chars |
21:46:06 | FromDiscord | <sealmove> (no spaces, tabs, new lines, etc) |
21:46:08 | PMunch | And define short |
21:46:15 | FromDiscord | <sealmove> ideally ascii |
21:46:20 | PMunch | Ah |
21:46:34 | FromDiscord | <sealmove> well shorter than printing them as hex :P |
21:48:07 | FromDiscord | <sealmove> base64 sounds a like a good idea, but the nim `base64` module can't help me I think. |
21:48:33 | PMunch | Well it can, but it'll be a bit clumsy to use |
21:48:52 | FromDiscord | <sealmove> i am ok with it being clumsy |
21:48:54 | PMunch | Shortest number system you can make with all printable characters would be base 93 I think |
21:49:17 | FromDiscord | <sealmove> ohh :oo |
21:49:42 | FromDiscord | <sealmove> interesting |
21:50:15 | FromDiscord | <sealmove> maybe I'll make a module for this |
21:55:38 | FromDiscord | <zidsal> I `dumpTree` the following code `Color(70)` out of interest why is the `Call` wrapped in a statement list I'm presuming this is optional as there is only node? |
21:56:11 | FromDiscord | <ElegantBeef> it's probably optional but it's usually safe to do |
21:57:01 | PMunch | It's just because you gave it a statement list |
21:57:06 | PMunch | Compare the output of these two: https://play.nim-lang.org/#ix=2TNn |
21:57:34 | FromDiscord | <zidsal> oh ofc, putting in a block would turn it into a statement list thanks guys |
22:03:42 | * | conkker quit (Quit: The Lounge - https://thelounge.chat) |
22:04:47 | * | conkker joined #nim |
22:07:15 | * | Vladar quit (Quit: Leaving) |
22:09:47 | * | conkker quit (Quit: The Lounge - https://thelounge.chat) |
22:10:06 | * | conkker joined #nim |
22:27:16 | * | PMunch quit (Quit: leaving) |
23:03:01 | FromDiscord | <Hi02Hi> In reply to @PMunch "Shortest number system you": !eval echo "1234567890!@#$%^&()abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`~-_=+[]{}|;:'\"<>,./?".len |
23:07:48 | FromDiscord | <dom96> ouch, looks like NimBot needs to parse the Discord relay's "In reply to ...:" prefix :/ |
23:08:02 | FromDiscord | <dom96> (https://irclogs.nim-lang.org/22-03-2021.html#23:03:01) |
23:08:06 | FromDiscord | <dom96> !eval echo "1234567890!@#$%^&()abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`~-_=+[]{}|;:'"<>,./?".len |
23:08:07 | NimBot | Compile failed: /usercode/in.nim(1, 96) Error: expression expected, but found ',' |
23:09:53 | FromDiscord | <Hi02Hi> oops. accidentaly left in a stray " |
23:10:01 | FromDiscord | <Hi02Hi> !eval echo "1234567890!@#$%^&()abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`~-_=+[]{}|;:'\"<>,./?".len |
23:10:06 | NimBot | 93 |
23:26:34 | * | jess quit (Quit: K-Lined) |
23:27:39 | * | j joined #nim |
23:32:15 | FromDiscord | <Yardanico> !eval echo len '1'..'?' |
23:32:17 | NimBot | 15 |
23:33:14 | FromDiscord | <Yardanico> !eval echo len '!'..'~' |
23:33:17 | NimBot | 94 |
23:37:21 | * | tane quit (Quit: Leaving) |
23:37:58 | * | vicfred joined #nim |
23:49:26 | FromDiscord | <Seedofarson> Bro |
23:49:40 | FromDiscord | <Seedofarson> I lost my Server/VPS |
23:49:43 | FromDiscord | <Seedofarson> And my development folder |
23:49:45 | FromDiscord | <Seedofarson> Iβm sad |
23:50:10 | FromDiscord | <Seedofarson> !eval import httpclient |
23:50:13 | NimBot | <no output> |
23:50:23 | FromDiscord | <Seedofarson> !eval β΅import httpclient |
23:50:24 | NimBot | Compile failed: /usercode/in.nim(1, 1) Error: undeclared identifier: 'β΅import' |
23:58:12 | FromDiscord | <dom96> not using git? |