00:01:49 | FromDiscord | <enthus1ast> @voidwalker\: https://www.sqlite.org/c3ref/stmt.html#:~:text=A%20prepared%20statement%20object%20is,statement%20object%20using%20sqlite3_prepare_v2(). |
00:03:44 | FromDiscord | <ElegantBeef> If the backtrace is to believed it's an issue with the `cmp` function |
00:03:54 | FromDiscord | <mattrb> Yeah it crashes even with no gc |
00:05:03 | FromDiscord | <mattrb> In reply to @ElegantBeef "If the backtrace is": Hmm I haven't seem that one before, but it doesn't seem to always be the same place |
00:05:25 | FromDiscord | <ElegantBeef> Mine is a consistent backtrace |
00:05:42 | FromDiscord | <mattrb> sent a long message, see http://ix.io/41TV |
00:06:30 | FromDiscord | <mattrb> sent a code paste, see https://play.nim-lang.org/#ix=41TW |
00:07:04 | FromDiscord | <mattrb> Mine is almost always in lib/system/excpt.nim, but the line frequently changes |
00:09:02 | * | CyberTailor quit (Remote host closed the connection) |
00:10:04 | * | CyberTailor joined #nim |
00:10:24 | FromDiscord | <ElegantBeef> Yea seems quite jumpy now that i tried it more |
00:12:47 | FromDiscord | <ElegantBeef> Might be a bug with sdl2, cant really tell |
00:13:21 | FromDiscord | <mattrb> I know it works in isolation with sdl2 at least https://github.com/mattrberry/web_audio_testing |
00:13:54 | FromDiscord | <mattrb> Excuse the code quality, I just translated that directly from some c source last year as a proof of concept :p |
00:14:05 | FromDiscord | <ElegantBeef> It's a private repo |
00:16:21 | FromDiscord | <mattrb> Oh |
00:18:46 | FromDiscord | <mattrb> Basically just showing that this works as expected https://gist.github.com/mattrberry/c645606be8f1ee836e05869cbdaa6585 |
00:18:53 | FromDiscord | <mattrb> Both natively and in emscripten |
00:45:02 | * | CyberTailor quit (Remote host closed the connection) |
00:46:12 | * | CyberTailor joined #nim |
00:53:40 | FromDiscord | <Elegantbeef> @mattrb\: looking at this code further you'll certainly want to compiler with \`--passC\:"-fno-strict-aliasing" |
00:53:45 | * | LuxuryMode joined #nim |
00:54:24 | FromDiscord | <Elegantbeef> It wont fix the issue but you have alot of breaking strict aliasing going on |
00:56:26 | FromDiscord | <ripluke> I have a library that requires httpclient |
00:56:49 | FromDiscord | <ripluke> How can I make it use -d:SSL without specifying it every build |
00:56:57 | FromDiscord | <ripluke> (edit) "-d:SSL" => "-d:ssl" |
00:57:05 | FromDiscord | <Elegantbeef> `config.nims` with `--define:ssl` |
00:57:33 | FromDiscord | <ripluke> In reply to @Elegantbeef "`config.nims` with `--define:ssl`": Do I put this in the directory with my nimble file? |
00:57:35 | FromDiscord | <mattrb> I'm trying to read up briefly on what the no-strict-aliasing flag does. What does that accomplish here? |
00:57:40 | FromDiscord | <ElegantBeef> Yes rip |
00:57:50 | FromDiscord | <Elegantbeef> Wait bridge is working now |
00:57:51 | FromDiscord | <ripluke> Ok thx |
00:57:57 | FromDiscord | <Elegantbeef> What am i doing đ |
00:58:05 | FromDiscord | <ripluke> Wait are discord |
00:58:09 | FromDiscord | <ripluke> (edit) "Wait are ... discord" added "u" |
00:58:35 | FromDiscord | <Elegantbeef> Strict aliasing allows an optimisation to be made but it means you cannot alias a pointer to a different type then it's intial form |
00:59:26 | FromDiscord | <Elegantbeef> So it can cause bugs with code that converts a type through a pointer |
00:59:53 | FromDiscord | <Elegantbeef> It doesnt resolve your present bug but it may stop you from running into them in the future |
01:00:14 | FromDiscord | <Elegantbeef> Funnily enough Wine is actually built with it disabled |
01:00:42 | FromDiscord | <ripluke> How can I get an optional argument in a function |
01:00:53 | FromDiscord | <mattrb> Got it, I think.. Trying to come up with an example where this would fail now to try to understand it better haha |
01:00:56 | FromDiscord | <Elegantbeef> `proc doThing(a = 10)`? |
01:01:24 | FromDiscord | <ripluke> In reply to @Elegantbeef "`proc doThing(a = 10)`?": Ah, so when someone specifies it 10 is overwritten |
01:01:35 | FromDiscord | <Elegantbeef> Yes |
01:01:49 | FromDiscord | <Elegantbeef> It's a very weird rule mattrb most people find it annoying |
01:02:19 | FromDiscord | <Elegantbeef> https://news.ycombinator.com/item?id=11289995 |
01:03:18 | FromDiscord | <Elegantbeef> The fun part with your code matt is even disabling your main update and leaving your key polling logic causes the segfault |
01:03:41 | FromDiscord | <mattrb> Heh, maybe that helps narrow it down then! |
01:03:46 | FromDiscord | <mattrb> Which part did you disable? |
01:04:07 | FromDiscord | <Elegantbeef> Wait one second |
01:04:35 | FromDiscord | <Elegantbeef> It just segfaulted with both `runCycles` and `checkKeyInput` commented out |
01:04:57 | FromDiscord | <Elegantbeef> Yea with `loop` commented out it still segfaults |
01:05:44 | FromDiscord | <mattrb> Hmm not for me.. |
01:05:57 | FromDiscord | <Elegantbeef> It can take some time |
01:06:08 | FromDiscord | <mattrb> I'll try it a few more times |
01:08:27 | FromDiscord | <mattrb> Hmm yeah đ€ |
01:09:19 | FromDiscord | <Elegantbeef> Does that mean you can reproduce that? |
01:10:13 | FromDiscord | <mattrb> I can reproduce it segfaulting even when commenting out `loop` |
01:11:13 | FromDiscord | <mattrb> But replacing the main loop with a sleep I don't see segfaults.. |
01:11:28 | FromDiscord | <mattrb> sent a code paste, see https://play.nim-lang.org/#ix=41U1 |
01:14:28 | FromDiscord | <Elegantbeef> Do you have any top level variables? |
01:14:39 | * | derpydoo joined #nim |
01:16:28 | FromDiscord | <mattrb> Just variables defined freely in nim files? |
01:16:32 | FromDiscord | <mattrb> All over the place |
01:16:43 | FromDiscord | <Elegantbeef> Ok are any of them heap allocated types? |
01:17:06 | FromDiscord | <mattrb> Hmm I think they're all stack-allocated, but I'll look |
01:17:24 | FromDiscord | <mattrb> The majority are definitely just plain objects |
01:17:35 | FromDiscord | <Elegantbeef> Also i despise you somewhat đ |
01:17:52 | FromDiscord | <Elegantbeef> Things like your `Keyinput` type existing is a travesty |
01:18:30 | FromDiscord | <mattrb> I'm always open to pull requests to make this more canonical nim :) |
01:18:39 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=41U5 |
01:18:50 | FromDiscord | <Elegantbeef> I mean i might put the time in after we fix this issue |
01:19:54 | FromDiscord | <mattrb> I haven't seen that enum syntax before. Not sure how it'd play with holes in the values, but I'll definitely take a look |
01:20:24 | FromDiscord | <Elegantbeef> You can have holey enums, just it's not the greatest with it |
01:20:41 | FromDiscord | <Elegantbeef> We have highlevel wirth bitsets so you dont need to make things like that object `KeyInpu` |
01:20:56 | FromDiscord | <Elegantbeef> A `KeyInputs = set[KeyInput]` is cleaner and nicer |
01:21:36 | FromDiscord | <Elegantbeef> Regardless i'm still at a loss at this segfault |
01:21:40 | FromDiscord | <Rika> âWirth bitsetsâ lmao |
01:21:48 | FromDiscord | <Elegantbeef> Your code doesnt seem to be causing it, so it could honestly be a sdl2 bug |
01:21:56 | FromDiscord | <Elegantbeef> I mean whatelse do you call them? |
01:22:08 | FromDiscord | <Elegantbeef> They're common amongst all of Wirth's languages |
01:22:12 | FromDiscord | <mattrb> I have a top-level var on the heap in apu.nim |
01:22:14 | FromDiscord | <Rika> I donât know, bit sets |
01:22:16 | FromDiscord | <mattrb> The buffer |
01:22:39 | FromDiscord | <Elegantbeef> Yea but you arent using it right now |
01:22:43 | FromDiscord | <mattrb> I haven't looked everywhere yet, but there certainly aren't many. Is that a problem? |
01:22:44 | FromDiscord | <Elegantbeef> So i dont imagine that's causing an issuue |
01:22:53 | FromDiscord | <Rika> Canât you Valgrind this out? |
01:22:58 | FromDiscord | <Rika> Itâs a segmentation fault right |
01:23:43 | FromDiscord | <Elegantbeef> Yea it is |
01:24:16 | FromDiscord | <Rika> Tried ASan? |
01:24:45 | FromDiscord | <mattrb> Gotta take the dog out, but definitely happy to continue this conversation in 20 mins |
01:25:27 | FromDiscord | <Elegantbeef> Damn that's a big dog |
01:28:07 | FromDiscord | <mattrb> https://media.discordapp.net/attachments/371759389889003532/994776865183109221/C2E96DFF-0382-4E72-AA5E-B5C2B07A0B2F.jpg |
01:28:13 | FromDiscord | <mattrb> Ah I forgot discord doesn't strip location data from photos. Dox dox |
01:28:23 | FromDiscord | <Elegantbeef> No dog dog |
01:28:38 | FromDiscord | <Elegantbeef> That's not that big of a dog shouldnt take 20 minutes to get it outside |
01:29:23 | FromDiscord | <Rika> In reply to @mattrb "Ah I forgot discord": It doesnât? Damn guess Iâve been doxxing myself |
01:29:44 | FromDiscord | <Rika> Well I downloaded it and it doesnât seem to have location info |
01:30:02 | FromDiscord | <mattrb> Maybe they changed it recently |
01:30:09 | FromDiscord | <ripluke> đ I just made my first nimble package, now I need to wait till it gets merged |
01:30:35 | FromDiscord | <Elegantbeef> The best part about element is i got confetti from that message ripluke đ |
01:31:17 | FromDiscord | <ripluke> In reply to @Elegantbeef "The best part about": Lol that's cool |
01:31:18 | FromDiscord | <!Patitotective> In reply to @ripluke "đ I just made": may i ask what is it about or do i need to wait until it gets merged? đ§ |
01:31:51 | FromDiscord | <ripluke> In reply to @Patitotective "may i ask what": It gets weather info using wttr.in so it doesn't need an owm api key |
01:32:12 | FromDiscord | <ripluke> It very smartly named wttrin |
01:33:25 | FromDiscord | <Rika> Why? Canât you just curl the website and get the info that where are you |
01:33:27 | FromDiscord | <Rika> Way |
01:33:40 | FromDiscord | <Rika> Lol I have a smart replacement for âwyaâ |
01:33:42 | FromDiscord | <!Patitotective> you should at least provide a readme in the repo and a description |
01:34:30 | FromDiscord | <ripluke> In reply to @Rika "Why? Canât you just": Nah my implementation uses httpclient (making it cross platform) and it's not as janky as using execCmd |
01:34:45 | FromDiscord | <Rika> I mean outside of Nim |
01:34:55 | FromDiscord | <Rika> So you can just use the equivalent in windows manually⊠|
01:35:42 | FromDiscord | <ripluke> In reply to @Rika "So you can just": You could, but what if you want the values in a Nim file |
01:35:52 | FromDiscord | <ripluke> Like you want to implement it in your code |
01:35:55 | FromDiscord | <Rika> Oh so itâs a library for it? |
01:36:00 | FromDiscord | <ripluke> Yea |
01:36:01 | FromDiscord | <Rika> Okay so I misread |
01:36:05 | FromDiscord | <!Patitotective> also ripluke, it seems like you pushed `src/wttrin.out` and `src/wttrin/submodule.nim` accidentally :p |
01:36:20 | FromDiscord | <ripluke> In reply to @Patitotective "also ripluke, it seems": Ah so should I delete them? |
01:36:53 | FromDiscord | <!Patitotective> well, you didn't use a submodule at allâ”nimble creates just in case you want to use it |
01:37:00 | FromDiscord | <ripluke> Oh |
01:37:09 | FromDiscord | <ripluke> Well it's gone now đ |
01:37:32 | FromDiscord | <ripluke> I love writing docs |
01:37:39 | FromDiscord | <ripluke> Sarcasm |
01:37:45 | FromDiscord | <!Patitotective> also if you have a single-module library you might want to put it at the root and remove `srcDir` from the nimble file |
01:38:00 | FromDiscord | <ripluke> In reply to @Patitotective "also if you have": Oh I'll do that aswell |
01:38:03 | FromDiscord | <!Patitotective> In reply to @ripluke "I love writing docs": i love writing tests too |
01:38:15 | FromDiscord | <ripluke> Tests aren't that bad ig |
01:38:40 | FromDiscord | <ripluke> I would write tests for my package but the data changes so it's kinda impossible :/ |
01:39:33 | FromDiscord | <!Patitotective> In reply to @ripluke "I would write tests": you could check if a value is in a range `":cloud_snow:"..":fire:"` lol |
01:40:17 | FromDiscord | <ripluke> In reply to @Patitotective "you could check if": True, but that range would be huge |
01:40:28 | FromDiscord | <ripluke> Probably -100..100 |
01:40:47 | FromDiscord | <ripluke> Well I doubt itd ever get to -100 |
01:40:57 | FromDiscord | <ripluke> But 100+ is definitely possible |
01:44:55 | FromDiscord | <!Patitotective> also riplukeâ”in your nimble file you say the license is `GPL-3.0-or-later`â”but in the repo there is no license file :/ |
01:45:32 | FromDiscord | <Elegantbeef> GPL3 for this type of code, interesting |
01:45:53 | FromDiscord | <ripluke> In reply to @Patitotective "also ripluke in your": Yea |
01:45:58 | FromDiscord | <ripluke> Should probably add that |
01:46:09 | FromDiscord | <ripluke> In reply to @Elegantbeef "GPL3 for this type": I license everything gpl lol |
01:46:19 | FromDiscord | <ripluke> It's free software |
01:46:49 | FromDiscord | <ripluke> I realized why everyone thought that it was a binary and not a library |
01:47:21 | FromDiscord | <ripluke> So I kinda let copilot autocomplete my whole packages.json |
01:47:36 | FromDiscord | <ripluke> I double checked it but I missed the description |
01:47:50 | FromDiscord | <ripluke> Soo unfortunately it says a CLI program |
01:48:01 | FromDiscord | <ripluke> Better fix that aswell |
01:49:11 | FromDiscord | <voidwalker> what was that unit that had the % operator for serializing to json? |
01:49:32 | FromDiscord | <Elegantbeef> `std/json` |
01:49:41 | FromDiscord | <Elegantbeef> Also in nim land it's a module |
01:50:06 | FromDiscord | <voidwalker> still with one foot in pascal land I guess |
01:50:51 | FromDiscord | <!Patitotective> nimland sounds so coolâ”like nimlang |
01:51:21 | FromDiscord | <voidwalker> Do you think we'll get more focus on performance after nim 2.0 ? |
01:51:52 | FromDiscord | <Elegantbeef> Nim is fast as is? |
01:52:01 | FromDiscord | <voidwalker> yes, but rust is way faster |
01:52:06 | FromDiscord | <Elegantbeef> No it' |
01:52:09 | FromDiscord | <Elegantbeef> it's not |
01:52:15 | FromDiscord | <Elegantbeef> Nim and Rust are the same speed |
01:52:20 | FromDiscord | <Rika> In reply to @voidwalker "yes, but rust is": Is it? Can you prove it |
01:52:25 | FromDiscord | <voidwalker> well, have not tried it myself, but all benchmarks i've seen rust is like 2-3x faster |
01:52:25 | FromDiscord | <Elegantbeef> The bottleneck is the programmer |
01:52:35 | FromDiscord | <Rika> Benchmark games donât work |
01:52:36 | FromDiscord | <Elegantbeef> Programming benchmarks a joke |
01:52:48 | FromDiscord | <Rika> Theyâre heavily implementation dependent |
01:52:52 | FromDiscord | <Elegantbeef> It benchmarks the intelligence of the programmer and less the language |
01:53:10 | FromDiscord | <voidwalker> well, bubblesort, how can you get that wrong |
01:53:10 | FromDiscord | <Rika> Yeah have you seen some of the Nim code the #science guys make |
01:53:12 | FromDiscord | <Rika> Itâs fucking crazy |
01:53:13 | FromDiscord | <voidwalker> it was way slower in nim |
01:53:28 | FromDiscord | <Rika> Look at the implementation and see if theyâre doing things âthe same wayâ? |
01:53:32 | FromDiscord | <Rika> Most likely they arenât |
01:53:35 | FromDiscord | <Elegantbeef> Were they faithful implementations? |
01:53:47 | FromDiscord | <Elegantbeef> Were they using the equivalent compiler flags? |
01:53:57 | FromDiscord | <Prestige> In reply to @voidwalker "well, have not tried": I've never seen anything like that lol |
01:54:04 | FromDiscord | <Rika> Even if it was faithful, what would the point be in benchmarking then |
01:54:05 | FromDiscord | <mattrb> In reply to @Elegantbeef "That's not that big": Dog has peed, pooped, and played |
01:54:18 | FromDiscord | <Elegantbeef> Exactlyâ”(@Rika) |
01:54:20 | FromDiscord | <Rika> In reply to @mattrb "Dog has peed, pooped,": The joke was you only said âget it outsideâ |
01:54:28 | FromDiscord | <mattrb> Yes |
01:54:41 | FromDiscord | <ripluke> Does Nim have a documentation generator |
01:54:48 | FromDiscord | <!Patitotective> `nim doc` |
01:55:01 | FromDiscord | <!Patitotective> (edit) "doc`" => "doc module.nim`" |
01:55:18 | FromDiscord | <!Patitotective> for libraries you may want `nim doc --project wttrin.nim` |
01:55:43 | FromDiscord | <!Patitotective> (edit) "for libraries you may want `nim doc --project wttrin.nim` ... " added "(which includes all the modules imported in the main module but in your case its the same)" |
01:55:48 | FromDiscord | <ripluke> Yea also can I get it in markdown or rust format? |
01:55:52 | FromDiscord | <mattrb> In reply to @Elegantbeef "Do you have any": Are top-level variables problematic for some reason? |
01:55:53 | FromDiscord | <ripluke> (edit) "rust" => "rst" |
01:56:04 | FromDiscord | <!Patitotective> In reply to @ripluke "Yea also can I": https://nim-lang.org/docs/docgen.html |
01:56:12 | FromDiscord | <Elegantbeef> Only heap allocated ones if you're using threads |
01:56:24 | FromDiscord | <Elegantbeef> The SDL code you're using isnt accessing them so it's fine |
01:56:30 | FromDiscord | <xflywind> More markdown supporting is coming => https://github.com/nim-lang/Nim/pull/19954 |
01:56:48 | FromDiscord | <!Patitotective> In reply to @flywind "More markdown supporting is": đ |
01:57:10 | FromDiscord | <Elegantbeef> https://plummerssoftwarellc.github.io/PrimeView/report?id=davepl-1641120327.json&hi=False&hf=False&hp=False&fi=&fp=mt&fa=wh~ot&ff=uf&fb=uk~ot&tp=False&sc=pp&sd=True is a good showcase of how silly benchmarks can be |
01:58:06 | FromDiscord | <mattrb> Could it be problematic because `AudioSpec` contains a reference to `AudioCallback` which is a proc? |
01:58:31 | FromDiscord | <Elegantbeef> Doubtful |
01:58:48 | FromDiscord | <Elegantbeef> Using asan is probably your best bet, but no clue how to set it up |
01:59:24 | FromDiscord | <mattrb> Hmm yeah still segfaults when I remove all references to the obtained audio spec in the callback |
02:01:28 | FromDiscord | <Rika> In reply to @Elegantbeef "https://plummerssoftwarellc.github.io/PrimeView/rep": God bless Mr Good or whatever his name is if I got that wrong |
02:02:08 | FromDiscord | <Elegantbeef> Yea no clue what their name is |
02:02:14 | FromDiscord | <Elegantbeef> All i know is they're vastly smarter than I đ |
02:02:31 | FromDiscord | <voidwalker> what's wrong with this ? |
02:02:32 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=41Ud |
02:02:45 | FromDiscord | <Elegantbeef> The compiler should tell you |
02:02:59 | FromDiscord | <voidwalker> Error: type mismatch: got <tuple[filename: string, filesize: int]>â”but expected one of:â”func `%`(formatstr, a: string): string |
02:04:09 | FromDiscord | <Elegantbeef> There isnt a variant of `%` that works on a tuple |
02:04:13 | FromDiscord | <voidwalker> late and batteries run out.. would appreciate a codefeed for this.. just want to write/read that seq of tuples from file |
02:04:19 | FromDiscord | <voidwalker> Oh |
02:04:51 | FromDiscord | <Rika> Shouldnât the object % also accept a tuple? |
02:04:52 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=41Ue |
02:04:53 | FromDiscord | <voidwalker> yeah elegantbeef, you could rename to CodeBeefFeed |
02:04:58 | FromDiscord | <Rika> Also be made to accept |
02:05:26 | FromDiscord | <voidwalker> sigh, so i haveto make it an object :\ |
02:05:34 | FromDiscord | <Elegantbeef> I think it could rika, could've sworn i made a PR for this |
02:05:48 | FromDiscord | <Elegantbeef> I mean you should generally use an object over tuple unless it's a one off thing imo |
02:06:13 | FromDiscord | <Rika> Might be merged and heâs just on an old version |
02:06:25 | FromDiscord | <Elegantbeef> nah doesnt look that way |
02:06:31 | FromDiscord | <Elegantbeef> I might've made a PR for something else |
02:06:36 | FromDiscord | <ripluke> How can I get codeblocks in documentation comments? |
02:07:37 | FromDiscord | <Elegantbeef> Also works void |
02:07:40 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=41Uf |
02:07:49 | FromDiscord | <xflywind> In reply to @Rika "Shouldnât the object %": https://github.com/nim-lang/Nim/pull/14638 |
02:08:17 | FromDiscord | <!Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=41Ug |
02:08:27 | FromDiscord | <!Patitotective> (edit) "https://play.nim-lang.org/#ix=41Ug" => "https://play.nim-lang.org/#ix=41Uh" |
02:08:31 | FromDiscord | <!Patitotective> (edit) "https://play.nim-lang.org/#ix=41Uh" => "https://paste.rs/Nzx" |
02:08:33 | FromDiscord | <xflywind> In reply to @flywind "https://github.com/nim-lang/Nim/pull/14638": The issue => https://github.com/nim-lang/Nim/issues/12290 |
02:08:39 | FromDiscord | <ripluke> sent a code paste, see https://play.nim-lang.org/#ix=41Ui |
02:08:46 | FromDiscord | <!Patitotective> i meant the slashes |
02:08:49 | FromDiscord | <!Patitotective> without the back slashes |
02:08:53 | FromDiscord | <!Patitotective> just like in discord |
02:08:56 | FromDiscord | <ripluke> Oh |
02:08:57 | FromDiscord | <ripluke> K |
02:09:12 | FromDiscord | <xflywind> (edit) "https://github.com/nim-lang/Nim/issues/12290" => "https://github.com/nim-lang/Nim/commit/f8e720fda90fcd3cabedc1adf055d14d69df82ba" |
02:10:48 | FromDiscord | <exelotl> sent a code paste, see https://play.nim-lang.org/#ix=41Uj |
02:11:00 | FromDiscord | <exelotl> (edit) "https://play.nim-lang.org/#ix=41Uj" => "https://play.nim-lang.org/#ix=41Uk" |
02:11:04 | FromDiscord | <!Patitotective> markdown forever |
02:11:06 | FromDiscord | <Elegantbeef> You also can use toplevel runnable examples if you want the code to run |
02:11:12 | FromDiscord | <ripluke> In reply to @Patitotective "markdown forever": Yes |
02:12:19 | FromDiscord | <exelotl> I also feel it was a bad idea to shoehorn markdown into RST |
02:12:58 | FromDiscord | <xflywind> Rst code block is fragile in Nim. If you miss blank lines, it can probably act up. |
02:13:24 | FromDiscord | <xflywind> With no errors |
02:14:33 | FromDiscord | <exelotl> iirc it permits no blank line where python's RST requires a blank line and would error without it? |
02:15:56 | FromDiscord | <exelotl> But yeah, right now we have an absolute mess of a markup language, if you use the full range of syntax it won't look correct _anywhere_ except Nim's renderer |
02:18:16 | FromDiscord | <exelotl> I wonder if there's a subset of AsciiDoc markup that doesn't conflict with MD or RST |
02:18:34 | FromDiscord | <exelotl> We could add a 3rd language to the mix :P |
02:19:55 | FromDiscord | <!Patitotective> https://github.com/nim-lang/Nim/pull/19954 ? |
02:23:42 | FromDiscord | <exelotl> Yeah I just don't get this |
02:25:38 | FromDiscord | <!Patitotective> ? the idea is to separate rst from md making two separate commands |
02:25:44 | FromDiscord | <!Patitotective> (edit) "? the idea is to separate rst from md making two separate commands ... " added "(and other fixes)" |
02:33:36 | FromDiscord | <exelotl> But it doesn't really separate them, it's still using the weird hybrid format either way, it just alters the balance in ambiguous situations. So now you can choose between md-ish RST or rst-ish MS |
02:34:06 | FromDiscord | <exelotl> (edit) "MS" => "MD" |
02:36:09 | FromDiscord | <exelotl> And the new MD syntax (being able to set parameters on the code blocks) isn't based on any standard I know of |
02:40:48 | FromDiscord | <exelotl> IMO Nim should just have 1 markup language and offer a rock solid implementation of it, not this weird cobbled together hybrid |
02:41:19 | FromDiscord | <!Patitotective> hmm đ€ agree |
02:42:49 | FromDiscord | <mattrb> In reply to @Elegantbeef "Using asan is probably": Haven't set up asan, but valgrind has a _lot_ to say.. https://gist.github.com/mattrberry/c3722c682b8b1f0e2f9b1650575857ff |
02:43:43 | FromDiscord | <Rika> Compile with arc, -d:useMalloc, and --debugger:native |
02:46:20 | FromDiscord | <mattrb> https://gist.github.com/mattrberry/2d63eac54cccde4bbfca76e516010a58 |
02:48:49 | FromDiscord | <Yardanico> yeah, as Rika said, you need to use ARC or ORC if you want to see meaningful valgrind output |
02:49:06 | FromDiscord | <Yardanico> the default GC is refc and it doesn't really work well on embedded or "weird" targets |
02:49:13 | FromDiscord | <Yardanico> arc is much much more "friendly" in that regard |
02:49:45 | FromDiscord | <Rika> Iâm still not sure whatâs wrong here tbh, Iâm still reading the output |
02:50:11 | FromDiscord | <Yardanico> a lot of the things are from stack frame (for exceptions) |
02:50:15 | FromDiscord | <Rika> This one stands out to me |
02:50:24 | FromDiscord | <Yardanico> @mattrb can you try also compiling with -d:danger ? so that it's pure program "logic" without any Nim checks |
02:50:35 | FromDiscord | <Yardanico> together with options Rika suggested |
02:50:43 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=41Uo |
02:50:51 | FromDiscord | <Rika> Kinda stood out, this one |
02:50:53 | FromDiscord | <Yardanico> popFrame is related to exceptions |
02:50:58 | FromDiscord | <Rika> It is I know |
02:51:40 | FromDiscord | <Rika> How about this one |
02:51:48 | FromDiscord | <Rika> sent a long message, see http://ix.io/41Up |
02:52:11 | FromDiscord | <Yardanico> still exceptions :P as I said it's a good idea to try -d:danger |
02:52:34 | FromDiscord | <Yardanico> to see if it's really something bad in the program itself or it's parts of nim stdlib/exception tracking failing |
02:52:41 | FromDiscord | <Rika> Why would the exception system have invalid reads |
02:53:32 | FromDiscord | <Yardanico> đ€· |
02:54:09 | FromDiscord | <mattrb> So far unable to reproduce the error with -d:danger |
02:54:16 | FromDiscord | <mattrb> (edit) "error" => "segfault" |
02:54:24 | FromDiscord | <Yardanico> interesting, can you try with `-d:release` ? |
02:55:09 | FromDiscord | <mattrb> `-d:release` has been working for the most part iirc. Can't reproduce with release either right now |
02:55:27 | FromDiscord | <mattrb> I think at some point it was having trouble with release, but most of the time it has been fine |
02:55:39 | FromDiscord | <Rika> Are you making exceptions yourself |
02:55:44 | FromDiscord | <Rika> As in constructing them |
02:56:09 | FromDiscord | <mattrb> Nope, nowhere |
02:59:29 | FromDiscord | <mattrb> Uncommenting this line (and the two above it) make it segfault in release as well https://github.com/mattrberry/gba/blob/beef/src/gba/apu.nim#L43 |
03:00:07 | FromDiscord | <Yardanico> oh, so the code is open |
03:00:34 | * | derpydoo quit (Quit: derpydoo) |
03:00:41 | FromDiscord | <Yardanico> can you tell what's the way to run it the same as you do to get the same segfault? |
03:00:44 | FromDiscord | <Yardanico> i mean the GBA rom and stuff |
03:01:25 | NimEventer | New Nimble package! wttrin - A library with functions to fetch weather data from wttr.in, see https://github.com/Infinitybeond1/wttrin |
03:01:54 | FromDiscord | <mattrb> If you clone the branch I linked, you can build with `nimble build` and run with `./gba bios.bin /path/to/rom`, where the rom can be https://github.com/destoer/armwrestler-gba-fixed/blob/master/armwrestler-gba-fixed.gba Really every rom breaks, but this is one I know my emulator runs fine otherwise :p |
03:05:14 | FromDiscord | <Yardanico> ok lemme try |
03:05:37 | FromDiscord | <Elegantbeef> How many nim programmers does it take to stifle a seg fault |
03:06:15 | FromDiscord | <mattrb> Really appreciate the help from all of you, btw :) |
03:09:42 | FromDiscord | <mattrb> My fear is that it comes down to something incredibly stupid on my end and that I'll have wasted all of your time.. |
03:11:59 | FromDiscord | <Elegantbeef> well it likely is on you đ |
03:15:13 | FromDiscord | <mattrb> As long as that's your assumption going in, then great :) |
03:15:19 | FromDiscord | <Yardanico> doesn't sdl run audio on a separate thread? |
03:15:30 | FromDiscord | <ripluke> In reply to @NimEventer "New Nimble package! wttrin": Nice |
03:15:44 | FromDiscord | <Yardanico> In reply to @ripluke "Nice": idk, I don't like those 20-line packages :( |
03:15:50 | FromDiscord | <mattrb> Yeah I believe it puts the callback function on another thread |
03:16:28 | FromDiscord | <ripluke> In reply to @Yardanico "idk, I don't like": Lol it's my package đ, but yea it's just a couple of bits of code I use alot which I thought might be helpful for some other people |
03:16:43 | FromDiscord | <Yardanico> at least make it more nim-ish :( |
03:16:54 | FromDiscord | <ripluke> In reply to @Yardanico "at least make it": What does that mean đ |
03:16:54 | FromDiscord | <Yardanico> you're leaking httpclient instances, `return`, etc |
03:17:07 | FromDiscord | <mattrb> In emscripten it'll run on the main thread, but natively I think it runs on the another thread that sdl creates |
03:17:27 | FromDiscord | <ripluke> In reply to @Yardanico "you're leaking httpclient instances,": ? |
03:17:40 | FromDiscord | <Yardanico> you must close httpclient instances after you use them |
03:17:43 | FromDiscord | <Yardanico> otherwise the FD will leak |
03:17:46 | FromDiscord | <ripluke> Oh |
03:17:59 | FromDiscord | <Yardanico> also you can just omit `return` in your procs |
03:18:16 | FromDiscord | <Yardanico> the last proc return can just be `if 'F' in weather: 'F' else: 'C'` |
03:18:27 | FromDiscord | <ripluke> In reply to @Yardanico "also you can just": Lol yea |
03:18:37 | FromDiscord | <ripluke> I know Nim has tgat |
03:18:40 | FromDiscord | <ripluke> (edit) "tgat" => "that" |
03:18:47 | FromDiscord | <ripluke> But I'm so used to jsđ |
03:18:51 | FromDiscord | <Yardanico> `client ,` |
03:19:06 | FromDiscord | <Yardanico> also you used the doc comments the wrong way |
03:19:08 | FromDiscord | <ripluke> Probably should also have my vars in a block |
03:19:11 | FromDiscord | <Yardanico> they must be _inside_ the proc body, not outside of it |
03:19:16 | FromDiscord | <ripluke> In reply to @Yardanico "also you used the": Yea I need to delete those |
03:19:38 | FromDiscord | <huantian> you might wanna look at wttr.in's json API, it'll make it so you don't have to do weird string parsing |
03:19:43 | FromDiscord | <ripluke> I made a readme which explains pretty much all of it |
03:19:54 | FromDiscord | <ripluke> In reply to @huantian "you might wanna look": Oh they have one? |
03:19:55 | FromDiscord | <Yardanico> @mattrb well it doesn't crash without stack traces, but that's probably not the root cause |
03:20:05 | FromDiscord | <huantian> indeed <https://github.com/chubin/wttr.in#different-output-formats=> |
03:20:14 | FromDiscord | <ripluke> Ah gtk |
03:20:21 | FromDiscord | <ripluke> Probably will implement that |
03:21:16 | FromDiscord | <Yardanico> also @ripluke `string` is not required in `city: string = ""` |
03:21:21 | FromDiscord | <Yardanico> because nim already knows that `""` is a string |
03:21:42 | FromDiscord | <Elegantbeef> Yardanico hasnt yet pointed out the worst part |
03:21:51 | FromDiscord | <Yardanico> `std` imports? |
03:21:52 | FromDiscord | <Elegantbeef> `weather.split"+"[0].strip` |
03:22:01 | FromDiscord | <Yardanico> i mean it's more or less fine in this case |
03:22:03 | FromDiscord | <Yardanico> it's just a small string |
03:22:05 | FromDiscord | <ripluke> In reply to @Yardanico "also <@704106773660827690> `string` is": Ok |
03:22:12 | FromDiscord | <Elegantbeef> I dont care! đ |
03:22:23 | FromDiscord | <ripluke> In reply to @Elegantbeef "`weather.split"+"[0].strip`": Well yea I did do a lot of splitting |
03:22:33 | FromDiscord | <Yardanico> also @ripluke instead you can just make one proc that'll return a tuple/object with all 3 fields |
03:22:39 | FromDiscord | <Yardanico> since you're doing the same request anyway |
03:22:44 | FromDiscord | <Elegantbeef> use strscans! |
03:22:54 | FromDiscord | <ripluke> In reply to @Yardanico "also <@704106773660827690> instead you": K |
03:23:08 | FromDiscord | <Yardanico> and for unit - not sure what that means |
03:23:10 | FromDiscord | <ripluke> I'll probably rewrite the whole thing with the json api |
03:23:16 | FromDiscord | <Yardanico> does wttr.in return different units based on the location or wat? |
03:23:19 | FromDiscord | <ripluke> In reply to @Yardanico "and for unit -": Farenheit or Celsius |
03:23:22 | FromDiscord | <ripluke> In reply to @Yardanico "does wttr.in return different": Yea |
03:23:27 | FromDiscord | <Yardanico> if so, you maybe need to convert it yourself |
03:23:33 | FromDiscord | <Elegantbeef> Remember yardanico fuckos use F |
03:23:35 | FromDiscord | <mattrb> In reply to @Yardanico "<@221832495367323648> well it doesn't": Wonder how user code is messing up the stack traces.. đ€ |
03:23:41 | FromDiscord | <huantian> the json api seems to return both C and F so that'll be fien |
03:23:58 | FromDiscord | <ripluke> In reply to @Elegantbeef "Remember yardanico fuckos use": Said like a true European |
03:24:18 | FromDiscord | <Elegantbeef> Mattrb probably some of your ptr code |
03:24:19 | FromDiscord | <Elegantbeef> Accidently overwriting the stack |
03:24:20 | FromDiscord | <huantian> beef is canadian tho he's fighting off bears as he eats his maple syrup rn |
03:24:27 | FromDiscord | <!Patitotective> hahah |
03:24:36 | FromDiscord | <Elegantbeef> I'm not european |
03:24:37 | FromDiscord | <Elegantbeef> I'm in NA |
03:24:44 | FromDiscord | <Elegantbeef> Thanks huan for the canonical truth |
03:24:44 | FromDiscord | <ripluke> In reply to @huantian "beef is canadian tho": đ anywhere not in the US is European |
03:24:56 | FromDiscord | <Elegantbeef> Said like a true person without healthcare |
03:25:03 | FromDiscord | <mattrb> Back to my process of reviewing all uses of pointers again... |
03:25:25 | FromDiscord | <Elegantbeef> Use the safer variants where possible matt |
03:25:31 | FromDiscord | <mattrb> Yup |
03:25:35 | FromDiscord | <ripluke> In reply to @Elegantbeef "Said like a true": đ atleast our youtube doesn't have to have a level of Canadianism |
03:25:41 | FromDiscord | <Elegantbeef> `ref` exists |
03:25:42 | FromDiscord | <ripluke> Whatever the fuck that means |
03:26:07 | FromDiscord | <ripluke> In reply to @ripluke "đ atleast our youtube": Isn't that just called not free speech |
03:26:11 | FromDiscord | <Elegantbeef> Attacking C-11 is like the lowest insult possible |
03:26:23 | FromDiscord | <Elegantbeef> It's actually not our radio and TV already have the same requirements |
03:26:37 | FromDiscord | <ripluke> đ |
03:26:53 | FromDiscord | <Elegantbeef> Imagine wanting to ensure domestic productions stay alive |
03:27:17 | FromDiscord | <ripluke> So basically you can't publicly talk bad about your country |
03:27:25 | FromDiscord | <Elegantbeef> That's not what it says |
03:27:33 | FromDiscord | <ripluke> In reply to @Elegantbeef "That's not what it": Ik |
03:27:33 | FromDiscord | <Yardanico> #offtopic đ€ |
03:27:47 | FromDiscord | <Elegantbeef> It requires a amount of content to be Canadian content on telecommunications and we'll go back to Nim talking now |
03:27:47 | FromDiscord | <ripluke> But basically it's whats going to happen |
03:28:39 | FromDiscord | <Yardanico> also @mattrb i'm not sure if it applies in your case, but maybe it's the case of strict aliasing |
03:29:14 | FromDiscord | <Elegantbeef> Nah i already tried yard |
03:29:22 | FromDiscord | <Yardanico> all the cast ptr T ? |
03:29:23 | FromDiscord | <Elegantbeef> `-fno-strict-aliasing` doesnt change anything |
03:30:04 | FromDiscord | <Yardanico> nim always passes that option by itself |
03:30:11 | FromDiscord | <Yardanico> so it doesn't matter if you pass it explicitly |
03:30:45 | FromDiscord | <Yardanico> but e.g. in case of zippy the issue was similar, and the fix was to use `copyMem` instead of casting with pointers to read stuff |
03:30:45 | FromDiscord | <Yardanico> https://github.com/guzba/zippy/issues/45 |
03:31:43 | FromDiscord | <Yardanico> also I'm not exactly sure, but why are a lot of casts are even needed in bus.nim ? |
03:31:58 | FromDiscord | <Yardanico> `cast[ptr T](addr bus.iwram[aligned and 0x3FFFF])[] = value` isn't this just `bus.iwram[aligned and 0x3FFFF] = value` |
03:32:59 | FromDiscord | <Yardanico> oh so it's treating the array as an array to another type to e.g. write a uint64 to a uint8 array |
03:34:11 | FromDiscord | <Elegantbeef> Sure but yardanico there was no difference with strict aliasing off |
03:34:13 | FromDiscord | <mattrb> Yup, the point there is to be able to write a value of uint8/uint16/uint32 into the array at that index |
03:34:23 | FromDiscord | <Yardanico> In reply to @Elegantbeef "Sure but yardanico there": but as I said nim always passes that anyway |
03:34:33 | FromDiscord | <Yardanico> try `--listcmd` for the default compile and see the C compiler args |
03:34:51 | FromDiscord | <Yardanico> In reply to @mattrb "Yup, the point there": lemme try to remake some of those with `copyMem` just like in zippy |
03:35:44 | FromDiscord | <Elegantbeef> Oh i thought passing it removed the issue al together |
03:36:16 | FromDiscord | <mattrb> Thank you again for all the help :) |
03:37:01 | FromDiscord | <mattrb> Gotta eat dinner now, back in a bit! |
03:58:19 | FromDiscord | <Yardanico> yeah @mattrb i fixed it |
03:58:26 | FromDiscord | <Yardanico> was just toying with different things and remembered a similar case |
03:58:42 | FromDiscord | <Yardanico> see, because SDL calls audioCallback from a different thread, you also need to compile your program with `--threads:on` |
03:58:52 | FromDiscord | <Yardanico> because otherwise Nim won't know that it needs to create different stack frames per thread and stuff like that |
03:59:03 | FromDiscord | <Yardanico> of course you can just disable stack frames for that specific callback proc, but it's not a proper fix |
03:59:25 | FromDiscord | <Yardanico> and if most of your program is single-threaded (and it is) and you don't want to fix all the gcsafe errors, you can pass `--threadAnalysis:off` |
03:59:49 | FromDiscord | <Yardanico> and yeah, if you compile with the `refc` GC (the default) you must call `setupForeignThreadGC()` at the top of audio callback |
03:59:56 | FromDiscord | <Yardanico> or just always use arc/orc, they're better (as long as they work) :P |
04:00:14 | FromDiscord | <Yardanico> https://forum.nim-lang.org/t/9013 |
04:00:26 | FromDiscord | <Yardanico> similar issue |
04:01:29 | * | kenran joined #nim |
04:02:41 | FromDiscord | <Yardanico> I mean, `--threads:on` is about to become the default on devel anyway, so that'll be less of a problem in nim v2 :P |
04:03:02 | FromDiscord | <Yardanico> ah it was already merged |
04:03:38 | FromDiscord | <Yardanico> time to get the latest devel and see more than half of all nim projects fail to compile unless you pass `--threads:off` (especially those that use nim's stdlib async) :D |
04:08:34 | FromDiscord | <Yardanico> finally I'll feel the joy of Nim devel being too different from stable again |
04:10:49 | FromDiscord | <xflywind> That's less of a problem than defaults to Orc. |
04:10:56 | FromDiscord | <xflywind> (edit) "defaults" => "defaulting" |
04:11:15 | FromDiscord | <xflywind> (edit) "Orc." => "Orc đ" |
04:11:30 | FromDiscord | <Yardanico> In reply to @flywind "That's less of a": eh, actually threads:on is a bigger problem than orc |
04:11:44 | FromDiscord | <Yardanico> most programs nowadays just work with orc, at most you need to add `--deepcopy:on` |
04:11:52 | FromDiscord | <Yardanico> but with threads:on most async programgs become unusable because of all gcsafe stuff |
04:12:09 | FromDiscord | <Yardanico> (edit) "programgs" => "programs" |
04:12:13 | FromDiscord | <Yardanico> unless you explicitly disable threads |
04:12:21 | FromDiscord | <Elegantbeef> Isnt gcsafe also gone though? |
04:12:29 | FromDiscord | <Yardanico> no? |
04:12:41 | FromDiscord | <Yardanico> as funny as it is |
04:12:42 | FromDiscord | <Elegantbeef> I'm thinking of locks arent i |
04:13:34 | FromDiscord | <Yardanico> and yes, gcsafe is also very outdated, it doesn't know that arc/orc have shared heap |
04:16:37 | FromDiscord | <xflywind> In reply to @Yardanico "most programs nowadays just": There are lots of errors like |
04:16:47 | FromDiscord | <xflywind> sent a code paste, see https://play.nim-lang.org/#ix=41UA |
04:16:55 | FromDiscord | <Yardanico> only the minority of Nim projects have finalizers |
04:17:03 | FromDiscord | <xflywind> sent a code paste, see https://play.nim-lang.org/#ix=41UB |
04:17:05 | FromDiscord | <Yardanico> yes, those are usually the bigger ones, but again, that's the minority |
04:17:20 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=41UC |
04:17:23 | FromDiscord | <Yardanico> but still, `--threads:on` will IMO affect more programs at compilation stage |
04:20:47 | FromDiscord | <xflywind> Yeah, I will make PRs to support enable deepcopy for some packages. It seems like months work to enable Arc/Orc for important packages. |
04:21:21 | FromDiscord | <Yardanico> not really, most important packages work with arc/orc just fine as I've tested them with arc/orc over a year ago |
04:23:29 | * | CyberTailor quit (Ping timeout: 268 seconds) |
04:25:58 | * | arkurious quit (Quit: Leaving) |
04:29:13 | * | kenran quit (Quit: WeeChat info:version) |
04:29:37 | * | toluene quit (Read error: Connection reset by peer) |
04:31:19 | * | toluene joined #nim |
04:42:47 | FromDiscord | <mattrb> In reply to @Yardanico "see, because SDL calls": Sweet, thank you!! I'll try it when I'm back at my computer (: |
04:43:22 | FromDiscord | <mattrb> In reply to @Yardanico "or just always use": Why are they better? I remember reading something briefly but forget the precise reasoning |
04:44:26 | FromDiscord | <Elegantbeef> They're partially deterministic and are not conventional GCs so do not require annoying steps to work |
04:46:09 | FromDiscord | <Yardanico> In reply to @mattrb "Why are they better?": well, for one, arc/orc don't do stack scanning like refc |
04:46:22 | FromDiscord | <Yardanico> so you don't have to set up arc/orc for each "foreign" thread like you need with refc |
04:46:37 | FromDiscord | <Yardanico> then arc/orc use destructors in a lot of cases instead of conventional GC, so it's more deterministic |
04:49:52 | FromDiscord | <j-james> wait, what did refc have to scan the stack for? |
04:49:58 | FromDiscord | <j-james> was that for cycles? |
04:51:18 | FromDiscord | <Yardanico> In reply to @j-james "wait, what did refc": I'm not that good at refc knowledge, but stack scanning is one of the main parts of it |
04:51:34 | FromDiscord | <Yardanico> In reply to @j-james "was that for cycles?": iirc that's done with a m&s phase? |
04:52:41 | FromDiscord | <j-james> oh, i see |
04:53:03 | FromDiscord | <j-james> so that probably was for counting references then |
04:53:23 | FromDiscord | <Yardanico> yeah |
04:53:46 | FromDiscord | <Yardanico> and arc is destructors with pure refcounting (not deferred like refc) |
04:53:54 | FromDiscord | <Yardanico> a destructor gets called on a ref, and if the refcount is 0 it's destroyed, simple |
04:55:54 | FromDiscord | <Yardanico> by "simple" I mean in the compiled program, not in the compiler :) |
04:57:13 | bigbyt | I just want prolog in nim |
05:23:29 | * | LuxuryMode quit (Quit: Connection closed for inactivity) |
05:23:38 | * | rockcavera quit (Remote host closed the connection) |
05:34:06 | FromDiscord | <Elegantbeef> Always weird to see notable people join matrix rooms |
05:37:09 | FromDiscord | <Yardanico> you mean discord |
05:37:09 | * | CyberTailor joined #nim |
05:37:30 | FromDiscord | <Yardanico> the matrix bot translates discord server joins to matrix room joins |
05:37:31 | FromDiscord | <Elegantbeef> Didnt show the typical bot info |
05:37:38 | FromDiscord | <Yardanico> image.png https://media.discordapp.net/attachments/371759389889003532/994839659345612820/image.png |
05:37:42 | FromDiscord | <Elegantbeef> Yea i see now |
05:49:19 | FromDiscord | <ajusa> can I cast a string to a fixed size array? |
05:49:33 | FromDiscord | <Elegantbeef> No |
05:49:59 | FromDiscord | <Elegantbeef> I mean you can do like `cast[ptr array[size, char]](myString[0].addr)` |
05:50:22 | FromDiscord | <Yardanico> In reply to @ajusa "can I cast a": what would you need this for? |
05:50:35 | FromDiscord | <Elegantbeef> `openArray[char]` exists |
05:50:40 | FromDiscord | <ajusa> I have a string, which I want to write to a file but make sure it is 200 bytes |
05:50:50 | FromDiscord | <Yardanico> just check the length? |
05:50:59 | FromDiscord | <ajusa> so pad it with nulls if it is too short, and truncate if it is too long |
05:51:08 | FromDiscord | <Elegantbeef> `if myStr.len != 200: raise newException(ValueError, "it's not 200 bytes ya chump")` |
05:51:24 | FromDiscord | <ajusa> considering an alignLeft followed by a slice potentially, not sure if there are better ways |
05:51:35 | FromDiscord | <Yardanico> In reply to @ajusa "so pad it with": `setLen` to truncate or expand, and then if you're expanding assign the added stuff manually |
05:51:43 | FromDiscord | <Yardanico> that way you don't need to copy it around with slices |
05:51:56 | FromDiscord | <ajusa> setLen would zero it out as well I believe, thanks! |
05:52:05 | FromDiscord | <ajusa> I always forget the methods in the system module |
05:52:17 | FromDiscord | <ajusa> (edit) "methods" => "procs" |
05:53:09 | * | CyberTailor quit (Remote host closed the connection) |
05:53:21 | FromDiscord | <Yardanico> In reply to @ajusa "setLen would zero it": ah yeah, i was just reminded that setLen currently has weird behaviour with shrinking |
05:53:27 | FromDiscord | <Yardanico> but for your usecase it's ideal |
05:53:37 | FromDiscord | <Yardanico> In reply to @Yardanico "ah yeah, i was": and then expanding |
05:53:39 | FromDiscord | <Yardanico> https://github.com/nim-lang/Nim/issues/19763 |
05:53:59 | * | CyberTailor joined #nim |
05:59:20 | FromDiscord | <Elegantbeef> trying to use futhark on wlroots and oh boy is that API awful for futhark |
06:02:33 | FromDiscord | <Elegantbeef> Actually futhark is missing a field completely |
06:02:40 | FromDiscord | <Prestige> How can I essentially `tail -f` a file? |
06:03:26 | FromDiscord | <Elegantbeef> Atleast i think it missed this union https://play.nim-lang.org/#ix=41US |
06:03:40 | FromDiscord | <Elegantbeef> what does that do prestige? |
06:03:47 | FromDiscord | <Yardanico> In reply to @Avahe "How can I essentially": one simple way is to use std/enumerate (or just have your own manual index variable) with the "lines" iterator |
06:04:08 | FromDiscord | <Yardanico> although that'll still read the whole file, just line by line |
06:04:16 | FromDiscord | <Yardanico> try streams or memfiles |
06:04:31 | FromDiscord | <huantian> do streams reload on file change tho? |
06:05:37 | FromDiscord | <Yardanico> huh? |
06:06:02 | FromDiscord | <huantian> am I thinking of `tail -f` correctly? i always just used it to show new lines as they were added to say a log file |
06:06:10 | FromDiscord | <Yardanico> yes |
06:06:47 | FromDiscord | <Prestige> Not sure how I'd do that with streams, looking through the docs atm |
06:09:28 | FromDiscord | <Prestige> Unless I just call `proc readLine(s: Stream; line: var string): bool` infinitely waiting for new data to be added to the file, but that sounds unreasonable |
06:12:16 | FromDiscord | <Prestige> oh maybe I could just use a selector here somehow |
06:59:14 | FromDiscord | <ripluke> sent a code paste, see https://play.nim-lang.org/#ix=41V6 |
06:59:59 | FromDiscord | <ripluke> idk how to do it |
07:00:15 | FromDiscord | <ripluke> i couldnt find an example like this in the std/json docs |
07:01:53 | FromDiscord | <huantian> Wat the why are all the numbers strings in the json lmao |
07:04:27 | FromDiscord | <ripluke> idk |
07:04:32 | FromDiscord | <ripluke> its the wttr.in api |
07:05:00 | FromDiscord | <huantian> I personally just use jsony for all my json stuff |
07:05:17 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=41V9 |
07:05:36 | FromDiscord | <ripluke> In reply to @Isofruit "Do you want a": every single one?? |
07:05:44 | FromDiscord | <ripluke> what about the ones in the array |
07:05:52 | FromDiscord | <Phil> Only the ones you care about |
07:06:02 | FromDiscord | <huantian> In reply to @ripluke "what about the ones": Yeah |
07:06:06 | FromDiscord | <huantian> If you wanna use the array |
07:06:15 | FromDiscord | <Phil> That's a second type you'll have to write and that's a field of seq second type |
07:06:25 | FromDiscord | <ripluke> In reply to @huantian "If you wanna use": well all of them are in the array |
07:06:35 | FromDiscord | <huantian> But all the types in the array should be homogenous so you only need to write a type for the thing in the array |
07:07:41 | NimEventer | New Nimble package! nexus - Nexus provides a high-level web framework for Nim, with batteries included., see https://github.com/jfilby/nexus |
07:17:30 | * | cornfeedhobo quit (Remote host closed the connection) |
07:20:05 | FromDiscord | <ripluke> how can i define types lol never done it b4 |
07:20:53 | FromDiscord | <huantian> You just define it like any other object |
07:21:07 | FromDiscord | <huantian> I donât believe that youâve never defined an object before in Nim |
07:21:26 | FromDiscord | <Elegantbeef> "Is it like a tuple?!" |
07:21:40 | FromDiscord | <ripluke> In reply to @huantian "I donât believe that": nevver donr that iether :) |
07:21:47 | FromDiscord | <huantian> How |
07:21:54 | FromDiscord | <Elegantbeef> It scares me |
07:22:27 | FromDiscord | <huantian> I mean ig you donât need objects if you just use anonymous tuples everywhere right đ |
07:22:36 | FromDiscord | <ripluke> In reply to @huantian "How": well it just never came up b4 |
07:22:38 | FromDiscord | <Elegantbeef> Fucking end me |
07:22:56 | FromDiscord | <Elegantbeef> that's to huan not you rip |
07:23:37 | FromDiscord | <ripluke> oh |
07:23:46 | FromDiscord | <ripluke> huh |
07:26:03 | FromDiscord | <huantian> Iâd probably read the bit in the tutorial on objects rq |
07:26:07 | FromDiscord | <huantian> Thatâll be helpful in general |
07:27:37 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=41Ve |
07:27:42 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=41Ve" => "https://paste.rs/Qaj" |
07:27:44 | FromDiscord | <Phil> Or something like it? |
07:28:04 | FromDiscord | <ripluke> never touched either the type or the object keyword |
07:28:15 | FromDiscord | <Rika> How have you been using Nim then huh? |
07:28:22 | FromDiscord | <Rika> (edit) "then huh?" => "then, what?" |
07:28:27 | FromDiscord | <ripluke> although i have seen them before in the nimdow code |
07:28:28 | FromDiscord | <Phil> I am fascinated ripluke, tell me more! |
07:28:43 | FromDiscord | <Phil> I genuinely have no idea how you managed to go without them so far, so now I'm curious |
07:28:44 | FromDiscord | <ripluke> In reply to @Rika "How have you been": idek |
07:29:01 | FromDiscord | <Rika> What have you made so far |
07:29:05 | FromDiscord | <ripluke> ive also never done anything asynchronous either |
07:29:10 | FromDiscord | <Rika> Thatâs normal |
07:29:15 | FromDiscord | <Phil> That's perfectly sane |
07:29:17 | FromDiscord | <Rika> Beef hasnât and heâs been here for a while |
07:29:26 | FromDiscord | <Phil> I didn#t touch async until I had like 1.5-2 years of programming under my belt |
07:29:30 | FromDiscord | <ripluke> In reply to @Rika "What have you made": lots of things, but nothing compared to how much ive used js |
07:29:43 | FromDiscord | <Rika> In reply to @ripluke "lots of things, but": I asked what things not how many |
07:29:43 | FromDiscord | <ripluke> lol i learned about nim from its js backend |
07:30:16 | FromDiscord | <ripluke> In reply to @Rika "I asked what things": well i did quite a bit of scripting for my linux setup |
07:30:40 | FromDiscord | <ripluke> like i have a theme switcher written in nim |
07:30:57 | FromDiscord | <ripluke> also most of the info in my bar is given from a nim script |
07:30:57 | * | cornfeedhobo joined #nim |
07:31:28 | FromDiscord | <ripluke> ive also never used pointers (in nim) |
07:31:32 | FromDiscord | <Rika> And youâve never made a type |
07:31:37 | FromDiscord | <ripluke> i have used them b4 in zig |
07:31:48 | FromDiscord | <Elegantbeef> Not using pointers is fine most shouldnt use them |
07:32:04 | FromDiscord | <ripluke> In reply to @Rika "And youâve never made": nope, it was just a lot easier to just not use them |
07:32:15 | FromDiscord | <Elegantbeef> It's' really not |
07:32:53 | FromDiscord | <ripluke> sent a code paste, see https://play.nim-lang.org/#ix= |
07:33:53 | FromDiscord | <ripluke> my theme script used to be horrible and also very hard to change |
07:34:00 | FromDiscord | <ripluke> but it works a lot better now |
07:34:11 | FromDiscord | <ripluke> still without types/objects |
07:34:40 | FromDiscord | <ripluke> this is it in all of its glory https://media.discordapp.net/attachments/371759389889003532/994869110771036201/themer.nim |
07:35:08 | FromDiscord | <ripluke> we dont talk about the fact that copilot wrote like 75% of it |
07:35:09 | FromDiscord | <Phil> In reply to @ripluke "also most of the": You fascinate me |
07:35:25 | FromDiscord | <ripluke> In reply to @Isofruit "You fascinate me": its alot faster than a shell script tho\ |
07:35:31 | FromDiscord | <ripluke> as its not interprated |
07:35:45 | FromDiscord | <Elegantbeef> Lol |
07:35:50 | FromDiscord | <ripluke> i might also write my river init file in nim |
07:36:01 | FromDiscord | <ripluke> that would be cool |
07:36:42 | FromDiscord | <huantian> Beef you can teach ripluke how to use std/json / jsony Iâm going to sleep |
07:37:11 | FromDiscord | <ripluke> lol first im gonna go hate on the tutorial i used to learn nim :) |
07:37:22 | * | hexeme quit (Quit: co'o ro do) |
07:37:55 | FromDiscord | <ripluke> ah found what i used https://narimiran.github.io/nim-basics/ |
07:39:37 | FromDiscord | <Phil> I can highly recommend the tut linked on the initial nim doc page |
07:40:24 | FromDiscord | <Elegantbeef> I cannot help myself so here you go ripluke |
07:40:25 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=41Vk |
07:40:33 | FromDiscord | <Elegantbeef> Actually extensible |
07:41:15 | * | hexeme joined #nim |
07:46:09 | NimEventer | New thread by Wreedb: Help with sorting a sequence of objects, see https://forum.nim-lang.org/t/9292 |
07:56:15 | NimEventer | New thread by Jasonfi: Nimble CI failing due to Nim v1.6.0 not found, see https://forum.nim-lang.org/t/9293 |
07:58:00 | * | hexeme quit (Quit: co'o ro do) |
08:00:00 | * | hexeme joined #nim |
08:04:32 | FromDiscord | <ripluke> In reply to @Elegantbeef "Actually extensible": What? |
08:17:04 | FromDiscord | <ripluke> sent a code paste, see https://play.nim-lang.org/#ix=41Vv |
08:22:42 | FromDiscord | <ripluke> now how can i convert it |
08:24:17 | FromDiscord | <Josef> Is it possible to implement indexing for arbitrary pointer? |
08:25:22 | FromDiscord | <Josef> Something like `proc getitem(x: pointer, ix: int) = ...` |
08:26:40 | FromDiscord | <dain> is there a way to do generic anonymous functions? |
08:26:47 | FromDiscord | <Rika> No |
08:26:51 | FromDiscord | <dain> oh :( |
08:26:58 | FromDiscord | <Rika> It doesnât really make sense to me |
08:27:18 | FromDiscord | <dain> well im trying to make a template that converts a key function to a cmp function |
08:27:34 | FromDiscord | <Rika> Anonymous functions can be runtime values, generic functions cannot without a type being specified |
08:27:59 | FromDiscord | <dain> like, lots of sorting procs take a `cmp` parameter which i think has to be a function that takes two values to be compared and returns -1, 0, or 1 |
08:28:21 | FromDiscord | <dain> but i prefer the python style of providing a `key` function that takes a single value and gives a number |
08:28:36 | FromDiscord | <dain> there's a way to convert between them but im not sure how to express it with nim's type system |
08:28:38 | FromDiscord | <ripluke> why is json so difficult in nim, in javascript its super simple, and in bash its also quit simple with something like jq |
08:29:36 | FromDiscord | <dain> sent a code paste, see https://play.nim-lang.org/#ix=41Vy |
08:29:44 | FromDiscord | <dain> is this kind of thing possible? |
08:30:35 | FromDiscord | <Yardanico> In reply to @Josef "Is it possible to": cast it to ptr UncheckedArray |
08:30:44 | FromDiscord | <Yardanico> of the type that you want to get out of it |
08:31:59 | FromDiscord | <Rika> In reply to @dain "so i want something": Values must be concrete so not that I know of no |
08:32:15 | FromDiscord | <Rika> Without hacky stuff |
08:33:35 | FromDiscord | <huantian> sent a code paste, see https://paste.rs/cgE |
08:34:00 | FromDiscord | <ripluke> idek wth im doing |
08:34:07 | FromDiscord | <huantian> In reply to @ripluke "now how can i": Idk for std, jsony is jsonString.fromJson(YourType) |
08:34:16 | FromDiscord | <ripluke> i used something called nimjsonn to convert it |
08:34:37 | FromDiscord | <ripluke> In reply to @huantian "Idk for std, jsony": how do i get the json object tho |
08:34:45 | FromDiscord | <ripluke> (edit) "object" => "string" |
08:34:52 | FromDiscord | <ripluke> i already have an object |
08:35:02 | FromDiscord | <ripluke> but how can i get a string from it' |
08:35:04 | FromDiscord | <ripluke> (edit) "it'" => "it" |
08:35:07 | FromDiscord | <huantian> Huh? The json string is the json you got from your web request |
08:35:23 | FromDiscord | <ripluke> oh so you mean the whole object |
08:36:29 | FromDiscord | <Phil> I'm on the to and can help in 7 or so hours |
08:38:42 | FromDiscord | <ripluke> ? |
08:40:08 | FromDiscord | <Phil> sent a long message, see http://ix.io/41VB |
08:40:23 | FromDiscord | <Phil> Look at the docs as to how they work |
08:40:56 | FromDiscord | <Phil> (edit) "http://ix.io/41VB" => "http://ix.io/41VC" |
08:41:27 | FromDiscord | <ripluke> In reply to @Isofruit "If you want to": im scraping data from the web, so would it be in a inline string or a multiline string |
08:41:45 | FromDiscord | <huantian> You just pass the string to the function |
08:41:49 | FromDiscord | <huantian> You donât need a literal |
08:41:58 | FromDiscord | <Phil> Both are just strings |
08:42:08 | FromDiscord | <Phil> You don't really have to care |
08:42:15 | FromDiscord | <huantian> Man I wish I was on PC so I could just show you |
08:42:50 | FromDiscord | <Phil> Just look at the std JSON docs it has multiple minimal examples |
08:43:14 | FromDiscord | <ripluke> In reply to @huantian "You just pass the": K |
08:43:27 | FromDiscord | <ripluke> I'm using jsony |
08:43:43 | FromDiscord | <ripluke> I think I get the idea tho |
08:43:53 | FromDiscord | <ripluke> I'll ask here if I run into any trouble |
08:44:08 | FromDiscord | <huantian> Iâll respond in 8-10 hours to your trouble |
08:44:56 | FromDiscord | <dain> sent a code paste, see https://play.nim-lang.org/#ix=41VD |
08:45:37 | FromDiscord | <Rika> thats because the inner you're returning is `inner(a, b: as_cmp.T)` |
08:45:45 | FromDiscord | <Rika> the T is not a "real generic" |
08:45:52 | FromDiscord | <Rika> so its concrete/specified |
08:47:07 | FromDiscord | <dain> ? |
08:48:01 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=41VE |
08:48:30 | FromDiscord | <dain> ahh i see |
08:48:35 | FromDiscord | <dain> yeah that's what i thought the template would do somehow |
08:51:19 | FromDiscord | <dain> is there a way to specify "orderable" or "sortable" or "comparable" or something |
08:51:23 | FromDiscord | <dain> for the `U` parameter |
08:51:37 | FromDiscord | <Elegantbeef> Concepts |
08:51:52 | FromDiscord | <dain> like `f: proc(x: T): Orderable` rather than any old U |
08:52:33 | FromDiscord | <Phil> Dain allow me to introduce you to traitor |
08:52:35 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=41VF |
08:52:48 | FromDiscord | <Elegantbeef> Traitor isnt needed here |
08:53:24 | FromDiscord | <Elegantbeef> that should be `c == c` of course |
08:53:32 | FromDiscord | <Phil> The way he's going with this I feel tempted to practice it pre emptively |
08:53:44 | FromDiscord | <dain> what is traitor ;o |
08:53:48 | FromDiscord | <Elegantbeef> He hasnt asked for runtime dispatch |
08:53:51 | FromDiscord | <Phil> (edit) "practice" => "prescribe" |
08:54:06 | FromDiscord | <Elegantbeef> A trait-like system for Nim that really needs rewritten and is mostly just for fun |
08:54:44 | FromDiscord | <Elegantbeef> https://github.com/beef331/traitor if interested |
08:55:19 | FromDiscord | <Elegantbeef> I do have a possible rewrite started but still dont know if I like it |
08:56:00 | FromDiscord | <Prestige> Elegantbeef: How do you feel about writing a wayland compositor? |
08:58:16 | FromDiscord | <Josef> How doc comments look like in Nim. Are there doctests? |
08:58:53 | FromDiscord | <Prestige> https://nim-lang.org/docs/tut1.html#lexical-elements-comments |
09:00:25 | FromDiscord | <Josef> Btw, why are multiline comments not indentation based? |
09:02:48 | FromDiscord | <Elegantbeef> Non doc comments arent apart of the ast |
09:03:36 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=41VQ |
09:19:57 | * | CyberTailor quit (Remote host closed the connection) |
09:21:01 | * | CyberTailor joined #nim |
09:24:43 | * | aru-hackZ joined #nim |
09:31:30 | * | aru-hackZ quit (Ping timeout: 240 seconds) |
09:33:15 | FromDiscord | <byteface> Hi, I notice there's a varargs but is there a varkwargs for keyword args? |
09:41:48 | FromDiscord | <bariali07> hi |
09:42:21 | FromDiscord | <vestel> `cstring` is a `char` or `char[]` |
09:42:26 | FromDiscord | <vestel> (edit) "`char[]`" => "`char[]`?" |
09:43:25 | FromDiscord | <vestel> I know that arrays implemented via pointers indexing, what I mean is cstring a pointer to char array or just a char array |
09:44:35 | * | def- quit (Quit: -) |
09:44:40 | FromDiscord | <vestel> oh nevermind |
09:44:48 | * | def- joined #nim |
09:45:32 | FromDiscord | <Rika> In reply to @byteface "Hi, I notice": No |
09:46:04 | FromDiscord | <vestel> In reply to @byteface "Hi, I notice": just do dict? |
09:51:59 | Amun-Ra | vestel: cstring is like ptr UncheckedArray[char] |
09:56:57 | Amun-Ra | in C terms is char* as you can't pass an array to a function in C and retain original type |
09:58:27 | * | aru-hackZ joined #nim |
10:46:06 | FromDiscord | <TryAngle> is there a minus that defaults to the bounds in case of overflow? |
10:47:06 | FromDiscord | <TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=41W7 |
10:51:35 | FromDiscord | <d4rckh> is there any easy way of converting a status (string) from requesting using <HttpClient>.request to a value of HttpCode (enum) |
10:52:16 | FromDiscord | <enthus1ast> does parseEnum work? |
10:52:17 | FromDiscord | <Rika> In reply to @TryAngle "is there a minus": The technical term is âsaturating arithmeticâ and itâs harder to implement |
10:52:46 | FromDiscord | <Rika> Thereâs an implementation in the compiler so you could prolly use it if you copied the file or whatever |
10:53:09 | FromDiscord | <Rika> In reply to @d4rckh "is there any easy": There already is a proc for that no? |
10:53:15 | FromDiscord | <d4rckh> In reply to @enthus1ast "does parseEnum work?": actually, HttpCode is not an enum, http code is defined as `HttpCode = distinct range[0 .. 599]` |
10:53:22 | FromDiscord | <Rika> âcodeâ or something |
10:53:59 | FromDiscord | <d4rckh> `proc code(response: Response | AsyncResponse): HttpCode`? |
10:54:05 | FromDiscord | <Rika> Yes? Is that not what you need |
10:54:07 | FromDiscord | <d4rckh> seems to be it |
10:54:08 | FromDiscord | <d4rckh> thanks |
10:54:37 | FromDiscord | <TryAngle> In reply to @Rika "The technical term is": I see thanks |
10:55:30 | FromDiscord | <TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=41W8 |
10:55:39 | FromDiscord | <TryAngle> (edit) "https://play.nim-lang.org/#ix=41W8" => "https://play.nim-lang.org/#ix=41W9" |
10:55:47 | FromDiscord | <Rika> You canât do that |
10:56:01 | FromDiscord | <Rika> Because overflows make > not work lol |
10:56:56 | FromDiscord | <TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=41Wa |
10:57:03 | FromDiscord | <Rika> Ah for minus |
10:57:12 | FromDiscord | <Rika> I donât know |
10:57:20 | FromDiscord | <TryAngle> ah wait for int this doesn't work |
10:57:31 | FromDiscord | <Rika> Thatâs unsigned |
10:57:39 | FromDiscord | <Rika> For integer itâs not gonna work but as of your writing it does |
10:57:54 | FromDiscord | <TryAngle> ye unsigned is special case |
10:58:07 | FromDiscord | <TryAngle> so for unsigned using what I wrote is better anyways? |
10:58:37 | FromDiscord | <TryAngle> idk tbh, I was thinking myabe there are intrisics or something liek that address registers on the pc or something like that hahha |
10:58:52 | FromDiscord | <Rika> What |
10:59:02 | FromDiscord | <Rika> I donât recall of any saturated integer intrinsically |
10:59:06 | FromDiscord | <Rika> Intrinsics |
10:59:08 | FromDiscord | <d4rckh> is there an async http client? |
10:59:12 | FromDiscord | <Rika> Yes |
10:59:14 | FromDiscord | <TryAngle> yes |
10:59:19 | FromDiscord | <Rika> Itâs in the same module âhttp clientâ |
10:59:21 | FromDiscord | <d4rckh> oh there is in the same library haha |
10:59:38 | FromDiscord | <TryAngle> In reply to @d4rckh "oh there is in": ye u can just swap out the generic If I remember correctly |
10:59:56 | FromDiscord | <d4rckh> yup |
11:00:45 | FromDiscord | <d4rckh> i am trying to make some sort of http proxy |
11:01:12 | FromDiscord | <d4rckh> sent a code paste, see https://play.nim-lang.org/#ix=41Wf |
11:01:19 | FromDiscord | <TryAngle> how do u open the secret nim repl again? |
11:01:23 | FromDiscord | <d4rckh> sent a code paste, see https://play.nim-lang.org/#ix=41Wg |
11:01:37 | FromDiscord | <TryAngle> I remember seeing it in pmunch stream |
11:02:28 | FromDiscord | <TryAngle> oh nim secret and it's dying đ |
11:04:58 | FromDiscord | <fbpyr> @TryAngle\: there is also a secret nim repl?â”I usually use inim\: `nimble install inim` đ |
11:05:11 | FromDiscord | <enthus1ast> @d4rckh\: what listens on "http://localhost:8000" ? |
11:05:21 | FromDiscord | <d4rckh> python http server |
11:05:32 | FromDiscord | <d4rckh> it works with smaller files |
11:05:49 | FromDiscord | <d4rckh> but if i try to access a bigger file it throws that exception |
11:06:03 | FromDiscord | <enthus1ast> what is a bigger file? |
11:06:09 | FromDiscord | <enthus1ast> how large i mean \:) |
11:06:12 | FromDiscord | <d4rckh> um |
11:06:13 | FromDiscord | <d4rckh> its an audio file |
11:06:19 | FromDiscord | <d4rckh> 2.51mb |
11:06:28 | FromDiscord | <d4rckh> the python http server handles the request properly and returns 200 (according to the logs) |
11:07:41 | FromDiscord | <enthus1ast> do you request this with a browser? |
11:08:34 | FromDiscord | <d4rckh> yes |
11:08:40 | FromDiscord | <enthus1ast> I'm asking, because a browser also requests favicon.ico |
11:09:06 | FromDiscord | <enthus1ast> and the python http server is quite limited and cannot do multiple request at once |
11:09:22 | FromDiscord | <enthus1ast> i would try the node http-server |
11:09:22 | FromDiscord | <d4rckh> it already requested a favicon.ico few minutes ago but the http proxy correctly forwarded 404 |
11:09:34 | FromDiscord | <enthus1ast> ok ic |
11:09:35 | FromDiscord | <d4rckh> so its not because of the favicon |
11:16:59 | FromDiscord | <d4rckh> it works if i go to `/` for the first time |
11:17:06 | FromDiscord | <d4rckh> but if i go again to `/` it crashes for the same reason |
11:17:17 | FromDiscord | <d4rckh> if i go to `/mp3file.mp3` the first time it crashes |
11:17:31 | FromDiscord | <d4rckh> first time meaning first time after i start the http 'proxy' |
11:17:58 | FromDiscord | <enthus1ast> i bet that it stuck in the request |
11:18:14 | FromDiscord | <d4rckh> yes, the request to the py http server |
11:18:24 | FromDiscord | <d4rckh> but the py http server returns 200 every time |
11:18:32 | FromDiscord | <enthus1ast> maybe it does not close the connection? |
11:18:47 | FromDiscord | <d4rckh> well the error says it does close it |
11:18:51 | FromDiscord | <d4rckh> but before the request was completed? |
11:19:17 | FromDiscord | <enthus1ast> ahh |
11:19:29 | FromDiscord | <enthus1ast> can you try to create a new httpclient in the request? |
11:19:32 | FromDiscord | <enthus1ast> every time |
11:19:40 | FromDiscord | <enthus1ast> you reuse the http client |
11:19:50 | FromDiscord | <d4rckh> i changed it to a real website located on the internet and i am getting this https://media.discordapp.net/attachments/371759389889003532/994925774572367922/unknown.png |
11:19:57 | FromDiscord | <d4rckh> (the real world website uses http) |
11:20:05 | FromDiscord | <d4rckh> hmm |
11:20:06 | FromDiscord | <d4rckh> i will try |
11:20:33 | FromDiscord | <d4rckh> that worked |
11:20:36 | FromDiscord | <d4rckh> and it works with the mp3 files as well |
11:20:37 | FromDiscord | <d4rckh> damn |
11:20:46 | * | summer joined #nim |
11:21:47 | FromDiscord | <enthus1ast> the invalid header could be a second issue |
11:21:51 | FromDiscord | <d4rckh> myeah |
11:21:59 | FromDiscord | <enthus1ast> good |
11:23:02 | FromDiscord | <d4rckh> could i plug this in chrome http proxy settings? |
11:23:10 | FromDiscord | <enthus1ast> nope |
11:23:30 | FromDiscord | <enthus1ast> http proxy is a special protocol |
11:23:56 | FromDiscord | <enthus1ast> i think it sets a few special headers, and closes the connection each time etc |
11:23:56 | FromDiscord | <d4rckh> ah I see |
11:24:24 | FromDiscord | <enthus1ast> but you could make it work |
11:25:15 | FromDiscord | <TryAngle> what is the nim equivalent to rusts `mem::swap` |
11:25:41 | FromDiscord | <Yardanico> `swap` |
11:25:42 | FromDiscord | <TryAngle> it switches the values of two locations in the memory |
11:25:49 | FromDiscord | <TryAngle> In reply to @Yardanico "`swap`": lol builtin? |
11:25:50 | FromDiscord | <Yardanico> https://nim-lang.org/docs/system.html#swap%2CT%2CT |
11:25:50 | FromDiscord | <TryAngle> thx |
11:33:34 | FromDiscord | <Prestige> Anyone here know python? Trying to convert a bit of code, unsure what this generator is doing: https://github.com/python-kasa/python-kasa/blob/57fac9a156eb34f01f236e620be3449b5f04d927/kasa/protocol.py#L200â”it is essentially an iterator, but we're only using the first byte xor'd with `key` ? |
11:34:14 | FromDiscord | <enthus1ast> "ciphertext " |
11:34:24 | FromDiscord | <enthus1ast> lol |
11:35:20 | FromDiscord | <enthus1ast> seems like\:â”â”integer + bytes |
11:35:33 | FromDiscord | <enthus1ast> net line encoding |
11:35:47 | * | aru-hackZ quit (Ping timeout: 244 seconds) |
11:37:12 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=41Wn |
11:37:32 | FromDiscord | <d4rckh> sent a code paste, see https://play.nim-lang.org/#ix=41Wo |
11:37:34 | FromDiscord | <d4rckh> enthus1ast, these are my headers |
11:37:35 | Amun-Ra | Prestige: no, all the bytes |
11:37:56 | FromDiscord | <d4rckh> should i perhaps replace the host? |
11:38:22 | FromDiscord | <Prestige> Interesting, so it's xor'ing all bytes with `key` and returning the result to be used on line 200? |
11:39:41 | FromDiscord | <Prestige> Python is weird |
11:40:37 | FromDiscord | <d4rckh> this does not seem to work? |
11:40:38 | FromDiscord | <d4rckh> sent a code paste, see https://play.nim-lang.org/#ix=41Wp |
11:41:07 | Amun-Ra | it's not python that's weird, it's this kind of code bloviation |
11:43:14 | FromDiscord | <AsbjĂžrn F> Hello lovelies. Not sure if I should ask here, but what would the process be to compile Nim to WASM? Get the intermediate C and run Emscripten on that? |
11:43:35 | FromDiscord | <Prestige> it's not obvious what it's doing imo |
11:43:42 | FromDiscord | <Prestige> I still don't know what it's doing lol |
11:44:15 | Amun-Ra | I agree :> |
11:44:20 | FromDiscord | <enthus1ast> @d4rckh it seems that one main difference is that the when connecting to a proxy, the client sends the full url in its get |
11:44:58 | FromDiscord | <Prestige> I'll have to research python generators I suppose |
11:45:01 | FromDiscord | <d4rckh> ah |
11:45:09 | FromDiscord | <soundmodel> Is there a framework for Nim which is somewhat like React or Java SDK? |
11:45:11 | FromDiscord | <d4rckh> what about the bad header from the (IIS) web site? |
11:45:21 | FromDiscord | <soundmodel> (edit) "Is there a framework for Nim which is somewhat like React or Java SDK? ... " added "I.e. that it allows developing the complete app?" |
11:45:27 | Amun-Ra | Prestige: they are no different than nim ones |
11:45:31 | FromDiscord | <d4rckh> could it be the host header pointing to localhost:1234 instead to the website name? |
11:45:42 | FromDiscord | <d4rckh> and if yes how can i edit the header before sending? |
11:45:44 | FromDiscord | <enthus1ast> could be |
11:45:51 | FromDiscord | <enthus1ast> maybe you do not need to |
11:46:06 | FromDiscord | <d4rckh> i wanna try it |
11:46:09 | FromDiscord | <enthus1ast> could be that the header is correct when you configure this as a proxy |
11:46:18 | FromDiscord | <d4rckh> i am not using this as a proxy |
11:46:22 | FromDiscord | <soundmodel> Karax is the React, but what's for native? |
11:46:28 | FromDiscord | <Prestige> In reply to @Amun-Ra "<@778498877464117248>: they are no": So that code is just using the first byte |
11:46:30 | FromDiscord | <soundmodel> (edit) "React," => ""React"," |
11:46:39 | FromDiscord | <d4rckh> its more of a redirector |
11:46:40 | FromDiscord | <AsbjĂžrn F> In reply to @soundmodel "Is there a framework": I've been suggested to work on this stack for web, Prologue, Norm / Ormin, HTMXâ”For native I've been doing SDL2. There's imGUI bindings as well |
11:47:10 | FromDiscord | <enthus1ast> yeah, then the host must match the virtual host configured on the serverâ”(@d4rckh) |
11:47:13 | FromDiscord | <TryAngle> is there something like return for iterators to stop them immediatly? |
11:47:19 | FromDiscord | <d4rckh> ah yes |
11:47:21 | FromDiscord | <soundmodel> In reply to @AsbjĂžrn F "I've been suggested to": So are the SDL2 bindings good? |
11:47:28 | FromDiscord | <d4rckh> how do i edit it then? |
11:47:32 | FromDiscord | <soundmodel> (edit) "In reply to @AsbjĂžrn F "I've been suggested to": So are the SDL2 bindings good? ... " added "Often I've found that language bindings are worse than writing in the original language" |
11:47:38 | FromDiscord | <enthus1ast> no you must break out of themâ”(@TryAngle) |
11:47:50 | FromDiscord | <d4rckh> sent a code paste, see https://play.nim-lang.org/#ix=41Wt |
11:48:00 | FromDiscord | <AsbjĂžrn F> In reply to @soundmodel "So are the SDL2": I haven't had issues. Been doing my own OpenGL renderer and shaders in GLSL. All seems fine |
11:48:20 | FromDiscord | <AsbjĂžrn F> There's an example in imGUI one sec |
11:48:37 | FromDiscord | <soundmodel> Might try that then, but I was also thinking that an "enterprise" framework is a possible target for Nim anyways |
11:48:39 | FromDiscord | <enthus1ast> copy the header from the original request, then modify it and sent it with the requestâ”(@d4rckh) |
11:48:58 | FromDiscord | <soundmodel> (edit) "anyways" => "anyways. Just not sure if it already existed." |
11:49:06 | FromDiscord | <AsbjĂžrn F> https://user-images.githubusercontent.com/7249728/60570947-e6787f80-9d72-11e9-8b26-d189f44b1256.gif |
11:49:17 | Amun-Ra | Prestige: no, there's iterator in that generator, like: for x in y: yield x |
11:49:32 | FromDiscord | <d4rckh> In reply to @enthus1ast "copy the header from": how do i copy it? |
11:49:43 | FromDiscord | <enthus1ast> is this nim?â”(@AsbjĂžrn F) |
11:49:45 | FromDiscord | <enthus1ast> ncie |
11:49:48 | FromDiscord | <enthus1ast> nice |
11:49:58 | FromDiscord | <AsbjĂžrn F> si, imGUI bindings. NimGL |
11:50:06 | FromDiscord | <AsbjĂžrn F> I didn't make it btw |
11:54:02 | FromDiscord | <d4rckh> this should work right? |
11:54:03 | FromDiscord | <d4rckh> sent a code paste, see https://play.nim-lang.org/#ix=41Wv |
11:54:37 | FromDiscord | <enthus1ast> responseĂ |
11:54:38 | FromDiscord | <enthus1ast> ? |
11:54:43 | FromDiscord | <enthus1ast> should it not be req? |
11:55:26 | FromDiscord | <d4rckh> wait |
11:55:38 | FromDiscord | <soundmodel> In reply to @AsbjĂžrn F "si, imGUI bindings. NimGL": So how do SDL2 and imgui relate? |
11:56:37 | FromDiscord | <enthus1ast> sdl2 draws and imgui is the gui |
11:57:17 | FromDiscord | <enthus1ast> imgui has a lot of backend options |
11:57:52 | FromDiscord | <Prestige> In reply to @Amun-Ra "<@778498877464117248>: no, there's iterator": yeah but the generator is only called once |
11:57:53 | FromDiscord | <soundmodel> Okay so then we could also consider: https://github.com/zacharycarter/nuklear-nim |
11:57:54 | FromDiscord | <d4rckh> okay, i successfully edited that header đ
|
11:58:09 | FromDiscord | <d4rckh> but the website is still crying about a header |
11:58:09 | FromDiscord | <enthus1ast> @d4rckh\: ;) |
11:58:23 | FromDiscord | <d4rckh> it actually says invalid name header |
11:59:27 | FromDiscord | <enthus1ast> @d4rckh\: to code something like this, i would point the browser and your proxy to a listening ncat (or netcat) then compare the requests |
11:59:53 | FromDiscord | <enthus1ast> your code will fail of course since it will not get a response, but you can see the data |
12:00:31 | FromDiscord | <enthus1ast> then you make it so, that the request your forwarding proxy sends, looks like the one of the browser |
12:03:04 | FromDiscord | <enthus1ast> ncat btw is part of nmap |
12:03:13 | FromDiscord | <enthus1ast> or socat |
12:03:16 | FromDiscord | <d4rckh> i will do that |
12:03:32 | FromDiscord | <enthus1ast> then it will be easy going fixing these issues |
12:04:35 | FromDiscord | <enthus1ast> i actually was in the middle of adding http proxy support to nimSocks, but yeah live happend |
12:05:20 | FromDiscord | <enthus1ast> and its quite a bummer that our http clients cannot (yet) speak to socks |
12:06:29 | FromDiscord | <d4rckh> oof |
12:06:39 | FromDiscord | <d4rckh> well now i am facing another weird problem |
12:06:56 | FromDiscord | <d4rckh> sent a code paste, see https://paste.rs/QZ3 |
12:07:03 | FromDiscord | <d4rckh> i am trying to edit the links on the website |
12:07:08 | FromDiscord | <d4rckh> (edit) "i am trying to edit the links on the website ... " added "to point to my 'redirector'" |
12:07:15 | FromDiscord | <d4rckh> but each echo in that snippet prints nothing |
12:07:38 | FromDiscord | <enthus1ast> why do you do this? \:) |
12:07:44 | FromDiscord | <enthus1ast> you're a proxy |
12:08:13 | FromDiscord | <enthus1ast> or wait you aren't yet right? |
12:08:36 | FromDiscord | <d4rckh> right now its just a web server that forwards requests to other web servers |
12:09:12 | FromDiscord | <d4rckh> but why i cant access the body there? |
12:09:25 | FromDiscord | <d4rckh> the full body is sent when i respond to the original request |
12:23:19 | FromDiscord | <Prestige> Is there another way to convert a string to a byte array without using a string stream and reading uint8s? |
12:23:48 | FromDiscord | <Rika> Casting? |
12:24:07 | FromDiscord | <Yardanico> In reply to @Avahe "Is there another way": casting, `copyMem`, etc |
12:24:16 | FromDiscord | <Yardanico> i wouldn't have even thought of using a stream for this, lol :P |
12:24:21 | FromDiscord | <Yardanico> would be too much overhead |
12:25:08 | FromDiscord | <enthus1ast> does the js backend supports casting or copyMem? |
12:25:35 | FromDiscord | <enthus1ast> would be at least more portable i guee |
12:25:40 | FromDiscord | <enthus1ast> guess |
12:26:26 | FromDiscord | <Yardanico> it supports casting, yes, not copyMem |
12:26:35 | FromDiscord | <Yardanico> casting a string to a seq works with the JS backend |
12:26:44 | FromDiscord | <Prestige> cool didnt know I could just cast it |
12:26:59 | FromDiscord | <Prestige> makes sense |
12:42:35 | * | xet7 joined #nim |
12:48:40 | FromDiscord | <untoreh> can I get the path of a loaded library from a `LibHandle` ? |
12:49:05 | FromDiscord | <untoreh> prob not |
12:50:21 | FromDiscord | <enthus1ast> You can with native api |
12:51:50 | FromDiscord | <enthus1ast> Eg windows\: https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulefilenamea |
13:04:15 | FromDiscord | <d4rckh> why is it 0 đ |
13:04:16 | FromDiscord | <d4rckh> sent a code paste, see https://play.nim-lang.org/#ix=41WP |
13:04:24 | FromDiscord | <d4rckh> (edit) "it" => "it's len" |
13:09:04 | FromDiscord | <enthus1ast> Maybe its a redirect? |
13:09:20 | FromDiscord | <enthus1ast> Print the status code as well |
13:09:54 | FromDiscord | <d4rckh> oh good idea |
13:10:18 | FromDiscord | <enthus1ast> And when its a redirect, it Skips your proxy all together \:D |
13:10:29 | FromDiscord | <d4rckh> its a.... 304 not modified |
13:11:25 | FromDiscord | <d4rckh> https://media.discordapp.net/attachments/371759389889003532/994953854548451368/unknown.png |
13:11:44 | FromDiscord | <d4rckh> how can i use the bodyStream FutureStream? |
13:11:47 | FromDiscord | <d4rckh> (edit) "FutureStream?" => "FutureStream[string]?" |
13:12:26 | FromDiscord | <enthus1ast> Then you must filter the browsers caching headersâ”(@d4rckh) |
13:12:51 | FromDiscord | <d4rckh> ohh |
13:12:52 | FromDiscord | <d4rckh> i see |
13:20:53 | * | xet7 quit (Remote host closed the connection) |
13:23:58 | * | hc0re joined #nim |
13:26:26 | * | xet7 joined #nim |
13:32:24 | * | xet7_ joined #nim |
13:32:46 | * | xet7_ quit (Client Quit) |
13:33:17 | * | xet7_ joined #nim |
13:35:55 | * | xet7 quit (Ping timeout: 260 seconds) |
13:36:02 | * | xet7_ quit (Remote host closed the connection) |
13:37:00 | * | xet7 joined #nim |
13:44:08 | * | xet7 quit (Remote host closed the connection) |
13:55:14 | FromDiscord | <byteface> sent a code paste, see https://play.nim-lang.org/#ix=41X3 |
14:03:14 | FromDiscord | <enthus1ast> @byteface\: go into your repo and execute nimble check |
14:03:48 | FromDiscord | <enthus1ast> It might be that your project has an incorrect structure |
14:04:25 | FromDiscord | <enthus1ast> Btw for local development you can do a\: nimble develop |
14:05:48 | FromDiscord | <d4rckh> how can i get the IP of the http client? |
14:05:52 | FromDiscord | <d4rckh> (edit) "client?" => "client that connected?" |
14:05:56 | FromDiscord | <d4rckh> (edit) "connected?" => "connected and is making the request?" |
14:06:14 | FromDiscord | <d4rckh> the request type has a client: AsynSocket property |
14:08:13 | FromDiscord | <sOkam!> I want to translate some cpp code (not interface with it, manually translate)â”First thing I noticed are the types are different (obviously)â”Where can I read about the differences between compatible types (cfloat, cint, etc) and native nim types?â”Or how can I figure out if a conversion is safe from a compatible type to a native one? |
14:08:30 | FromDiscord | <enthus1ast> @d4rckh hostname https://nim-lang.org/docs/asynchttpserver.html#Request |
14:09:14 | FromDiscord | <d4rckh> i should put that in a header right? |
14:09:18 | FromDiscord | <d4rckh> X-Forwarded or something |
14:09:32 | FromDiscord | <byteface> test is valid. im thinking it might be my setup? |
14:09:36 | FromDiscord | <enthus1ast> @sOkam!\: one option is to put parts into c2nim and translate it |
14:09:49 | FromDiscord | <byteface> if i do nimble isntall somepackage |
14:09:58 | FromDiscord | <byteface> am i supposed to be able to just import it? |
14:10:02 | FromDiscord | <enthus1ast> If you like you can, but it's not requiredâ”(@d4rckh) |
14:10:03 | FromDiscord | <sOkam!> In reply to @enthus1ast "<@186489007247589376>\: one option is": ye, tried. but it breaks due to expecting `;` in every file |
14:10:24 | FromDiscord | <sOkam!> i think its not understanding the namespaces |
14:10:43 | FromDiscord | <enthus1ast> Yesâ”(@byteface) |
14:11:09 | FromDiscord | <enthus1ast> Ahh cpp might not be supported, but don't know for sureâ”(@sOkam!) |
14:11:24 | FromDiscord | <sOkam!> its partially supported, but some things break it seems |
14:11:38 | FromDiscord | <sOkam!> haven't figured out what exactly is breaking it yet |
14:12:00 | FromDiscord | <enthus1ast> Have a look at its options. I can also recommend to just put parts not the whole |
14:12:19 | FromDiscord | <sOkam!> im fine manually porting it. its for learning anyway, so slow will make it sink in betterâ”the issue is I don't know how to find information about the types differences |
14:13:10 | FromDiscord | <enthus1ast> @sOkam!\: google for "nim for c developers" I'm on mobile currently |
14:14:29 | FromDiscord | <sOkam!> This? https://github.com/nim-lang/Nim/wiki/Nim-for-C-programmers |
14:16:45 | * | hc0re quit (Ping timeout: 260 seconds) |
14:17:00 | * | rockcavera joined #nim |
14:17:00 | * | rockcavera quit (Changing host) |
14:17:00 | * | rockcavera joined #nim |
14:25:30 | FromDiscord | <enthus1ast> Yes |
14:26:28 | * | derpydoo joined #nim |
14:31:37 | * | pro joined #nim |
14:33:16 | FromDiscord | <byteface> seems like installing choosenim its not working? |
14:34:53 | * | pro quit (Client Quit) |
14:37:00 | FromDiscord | <sOkam!> @enthus1ast very good read, thanksâ”doesn't answer my question, sadly. but definitely improved my understanding of other aspects |
14:37:55 | FromDiscord | <sOkam!> Still looking for compatible type conversion to native types.â”As in, why are they different, and when could the use of a native type go wrong, compared to using a compatible one instead |
14:39:09 | FromDiscord | <sOkam!> Cheap solution could be to use compatible types everywhere, but would prefer to avoid that if I can |
14:45:51 | FromDiscord | <byteface> got it working. i had bin in the nimble file. |
14:51:57 | * | arkurious joined #nim |
15:02:56 | FromDiscord | <vestel> How to fully disable aligment? `packed` program doesn't work correctly |
15:03:07 | FromDiscord | <vestel> (edit) "program" => "pragma" |
15:03:14 | FromDiscord | <ezquerra> In reply to @sOkam! "Still looking for compatible": Not an expert so take this with a (big) grain of salt but AFAIK the biggest difference is string vs cstring. For numeric types the differences are probably very minor or irrelevant |
15:03:56 | FromDiscord | <enthus1ast> and a string actually contains a cstring |
15:04:08 | FromDiscord | <ezquerra> I think the biggest differences are on automatic casting which in C and C++ is somewhat crazy (in the sense that there are a lot of footguns) |
15:04:08 | FromDiscord | <enthus1ast> since it is null terminated |
15:04:38 | FromDiscord | <ezquerra> (edit) "I think the biggest differences are on automatic casting ... which" added "of numeric values" |
15:12:01 | * | kenran joined #nim |
15:13:29 | FromDiscord | <sOkam!> makes sense. will use natives normally, except for strings, and hope for the best đ€ |
15:20:54 | FromDiscord | <d4rckh> how can i use ssl with asynchttpserver? |
15:21:20 | FromDiscord | <enthus1ast> you can't |
15:21:53 | FromDiscord | <d4rckh> hm, why |
15:22:01 | FromDiscord | <enthus1ast> its not implemented yet |
15:22:46 | FromDiscord | <d4rckh> ..will it be implemented? |
15:23:29 | FromDiscord | <enthus1ast> i know of some discussions lately, but afaik there where for prologue, but since prologue also can use asynchttpserver one might implement it |
15:24:05 | FromDiscord | <enthus1ast> maybe its not too hard to do, maybe you could have a look at it \:) |
15:24:51 | FromDiscord | <enthus1ast> i can imagine its a matter of, upgrading the socket with ssl, listening on https port and a few tweaks here and there |
15:28:38 | FromDiscord | <d4rckh> is there any http server alternative with ssl? |
15:29:24 | FromDiscord | <enthus1ast> not that i know of |
15:37:03 | FromDiscord | <enthus1ast> @d4rckh\: https://datatracker.ietf.org/doc/html/rfc2818 |
15:37:12 | FromDiscord | <enthus1ast> its seems very simple to implement |
15:39:01 | FromDiscord | <enthus1ast> and here i've done some ssl server stuff (warning ooold code) https://github.com/enthus1ast/libch4t/blob/f511e1b371b1d5ced9e42ee9469c3b8a9c1965bf/libch4t_irc.nim#L119 |
15:39:27 | FromDiscord | <enthus1ast> but the devil is in the detail as always |
15:40:45 | FromDiscord | <fwsgonzo> sent a code paste, see https://play.nim-lang.org/#ix=41XE |
15:41:01 | FromDiscord | <fwsgonzo> (edit) "https://play.nim-lang.org/#ix=41XE" => "https://play.nim-lang.org/#ix=41XF" |
15:41:15 | FromDiscord | <fwsgonzo> (edit) "https://play.nim-lang.org/#ix=41XF" => "https://paste.rs/D9S" |
15:49:32 | FromDiscord | <kevin> I am once again asking if it is possible to redirect `stdout` to a variable đŠ |
15:49:45 | FromDiscord | <kevin> still can't figure this out. |
15:50:06 | FromDiscord | <kevin> the `reopen()` trick works to send `stdout` to a file, but not a variable. |
15:50:47 | FromDiscord | <kevin> Does Nim support "Virtual Files" you can use to write to? sorta like a memoryStream |
15:52:02 | FromDiscord | <enthus1ast> why do you want to do this btw? |
15:52:53 | FromDiscord | <kevin> I'm trying to use winim/clr to run .net code |
15:53:24 | FromDiscord | <kevin> I got that all to work and I can use winim/clr's `load()` to load and execute dotnet assemblies |
15:53:34 | FromDiscord | <kevin> but all of the `Console.WriteLine()` code goes to the terminal |
15:53:46 | FromDiscord | <kevin> instead, I want to capture the output and save it into a variable |
15:55:18 | FromDiscord | <enthus1ast> can you access clr variables via nim? |
15:55:28 | FromDiscord | <enthus1ast> then you could redirect it with .net and access this var |
15:55:40 | FromDiscord | <kevin> sent a code paste, see https://play.nim-lang.org/#ix=41XL |
15:56:39 | FromDiscord | <kevin> Hmm... I am not sure. I don't really have control of when `Console.WriteLine()` is called in the invoke'd dotnet assembly |
15:59:05 | FromDiscord | <vestel> So `sizeof` basically ignores `{.packed.}` |
15:59:11 | FromDiscord | <vestel> (edit) "`{.packed.}`" => "`{.packed.}`?" |
16:01:48 | FromDiscord | <kevin> or just preload each execution of a dotnet assembly with .net code that does the redirection for me đ |
16:02:00 | FromDiscord | <kevin> terrible solution lol |
16:02:13 | FromDiscord | <kevin> there must be a way to do this in Nim |
16:08:48 | FromDiscord | <enthus1ast> a few hacky options\: have a wrapper application that starts the .net loader and captures its output; hook into the c procs and capture the output like this; write into a file, then later read it |
16:14:48 | * | hexeme is now known as ldlework |
16:19:19 | FromDiscord | <kevin> sent a code paste, see https://play.nim-lang.org/#ix=41XR |
16:19:20 | FromDiscord | <kevin> here is as close as I have so far |
16:19:27 | FromDiscord | <kevin> this redirects to a file and then restores it |
16:19:43 | FromDiscord | <kevin> I'd like to get to a point where I don't have a temp file I need to read from |
16:21:56 | FromDiscord | <kevin> https://nim-lang.org/docs/memfiles.html # might be useful but Nim doesn't like using `File` and `Memfile` interchangeably |
16:26:40 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=41XS |
16:29:08 | * | kenran quit (Quit: WeeChat info:version) |
16:33:59 | FromDiscord | <sOkam!> Is a C struct just an object in Nim?â”Is that true also for C++ classes? |
16:34:12 | FromDiscord | <enthus1ast> thats quite annoying... |
16:34:13 | FromDiscord | <enthus1ast> image.png https://media.discordapp.net/attachments/371759389889003532/995004896988373002/image.png |
16:35:02 | FromDiscord | <enthus1ast> the bridge i mean |
16:35:05 | FromDiscord | <enthus1ast> not you \:) |
16:35:24 | FromDiscord | <Phil> In reply to @enthus1ast "image.png": What you can't see is the post I replied to, possibly because it was either edited or contains \`\`\`â”Is the bridge commonly torpedoing on these types of posts? |
16:35:58 | FromDiscord | <enthus1ast> noticed this quite often lately |
16:36:28 | FromDiscord | <enthus1ast> argh wife bugs me to leave bbq |
16:36:34 | FromDiscord | <enthus1ast> for |
16:36:39 | FromDiscord | <enthus1ast> cee ya |
16:36:51 | FromDiscord | <Phil> bb |
16:56:13 | NimEventer | New thread by EnteryName: When should i use JsonNode instead of tables, see https://forum.nim-lang.org/t/9294 |
17:09:21 | FromDiscord | <Space Ghost> sent a long message, see http://ix.io/41Y8 |
17:09:24 | FromDiscord | <Space Ghost> sent a long message, see https://paste.rs/G5x |
17:12:14 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=41Y9 |
17:13:32 | FromDiscord | <Space Ghost> sent a code paste, see https://play.nim-lang.org/#ix=41Ya |
17:15:26 | * | Goodbye_Vincent quit (Quit: Ping timeout (120 seconds)) |
17:18:18 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=41Yb |
17:18:30 | FromDiscord | <huantian> It might be helpful if you post the original problem statement as wellâ”One easy thing to optimize is that you can remove that final new line write outside of the loop, but not sure if thatâs optimized already by the compiler |
17:19:20 | FromDiscord | <sOkam!> (edit) "https://play.nim-lang.org/#ix=41Yb" => "https://play.nim-lang.org/#ix=41Yc" |
17:22:20 | FromDiscord | <huantian> You might wanna look at std/bitops for a xor that work on bytes |
17:23:02 | * | Goodbye_Vincent joined #nim |
17:25:28 | FromDiscord | <huantian> In reply to @sOkam! "Is this the correct": I think itâs because Vec3 is a generic |
17:25:42 | FromDiscord | <sOkam!> whats a generic? |
17:29:28 | FromDiscord | <sOkam!> oh, as in it needs to be a `Vec3f` or a `Vec3i`? |
17:29:38 | FromDiscord | <Space Ghost> sent a code paste, see https://play.nim-lang.org/#ix=41Yd |
17:29:58 | FromDiscord | <Space Ghost> Error: undeclared identifier: 'bitxor' |
17:31:29 | FromDiscord | <Space Ghost> But I still run into the problem of the bulk read and write of an array to file. I have to either insert commas by element or line breaks \n by element to store the xor data and then retrieve. Is there a Nim function that allows one to write and then read an array or sequence in bulk? |
17:34:57 | FromDiscord | <Space Ghost> In reply to @huantian "It might be helpful": I need to add the new line with each element (i) of the sequence build up so I can readLine back later into an array. Otherwise it just jams all the ints together into a huge single line in the text file with no delimitator. |
17:37:24 | FromDiscord | <Space Ghost> PS - macro bitxor[T: SomeInteger](x, y: T; z: varargs[T]): Tâ”This requires and integer and will not except chars |
17:39:32 | FromDiscord | <Space Ghost> PS - Sorry my blunder on the first error, forgot to add import std/bitops. It works now and provides the exact same result as xor. There is a long stackflow article on how bitxor and xor are different, but not germane to my topic. |
17:44:00 | FromDiscord | <huantian> I think if you want to read lines from a file the lines interator might be better <https://nim-lang.org/docs/io.html#lines.i%2CFile>â”for writing I'm not too sure, you could concatinate all the strings in memory but that might be slow tooâ”File streams might give you better performance but I don't know much in this area tbh |
17:44:35 | FromDiscord | <Generic> you're likely using a 64-bit processor, so you can xor 8 times the amount of data for free |
17:45:59 | FromDiscord | <Generic> though it likely doesn't make much of a difference when you're then converting them afterwards to decimal?? |
17:47:04 | FromDiscord | <juba> Hi, I am trying to register for Nim forum, but I am not receiving confirmation email. I tried with two different .gmail emails. Also not in spam folder. |
17:47:41 | FromDiscord | <Generic> honestly these kinds of benchmarks are stupid, because what ends up making the big difference will be some tiny difference in how the standard library flushes data to files or something like this which in turn changes the result in some other stupid benchmark |
17:48:16 | FromDiscord | <juba> The reason I tried to register is to ask this question: does nim have something like Python's `next`? Specifically I want to get the next value from an iterator. How to do it without counters and if-statements? |
17:48:53 | FromDiscord | <Generic> In reply to @juba "The reason I tried": you need to use closure iterators for this |
17:49:57 | FromDiscord | <fwsgonzo> In reply to @Isofruit "Out of curiosity, which": JWT from https://github.com/yglukhov/nim-jwtâ”I kinda figured it out though - I'm guessing that it's faster to use 256 because of hardware acceleration support |
17:50:20 | FromDiscord | <fwsgonzo> The ES256 verification takes 0.58ms while ES384 takes over 3ms |
17:50:38 | FromDiscord | <juba> In reply to @Generic "you need to use": OK, you've reached the limits of my knowledge, but I'll start studying, thanks! |
17:51:43 | FromDiscord | <Space Ghost> sent a long message, see http://ix.io/41Ye |
17:53:48 | FromDiscord | <Generic> In reply to @juba "OK, you've reached the": they don't work in all backends and tended to be buggy (which is now mostly solved), so they're not used that much. They might be what you're looking for, but there might also be some better way to do whatever you currently want to archieve |
17:54:26 | FromDiscord | <konsumlamm> In reply to @Space Ghost "Hi Generic, it is": in that case i'd recommend Nim, V simply isn't production readyyet (if it ever will be) |
17:54:27 | FromDiscord | <juba> well I want to skip the first line when using the `"my-file.txt".lines` iterator |
17:54:52 | FromDiscord | <juba> i dont want to put an if statement which will be evaluated million times because i have million lines |
17:54:58 | FromDiscord | <huantian> sent a code paste, see https://play.nim-lang.org/#ix=41Yf |
17:57:02 | FromDiscord | <Generic> In reply to @Space Ghost "Hi Generic, it is": well your code might not be intended to be a benchmark, but atleast your example code looks and behaves exactly like one of those and the same games can be played with it |
17:58:05 | FromDiscord | <Space Ghost> sent a long message, see http://ix.io/41Yh |
17:59:22 | FromDiscord | <dom96> In reply to @juba "Hi, I am trying": what's your profile nickname? |
17:59:30 | * | hc0re joined #nim |
18:00:24 | FromDiscord | <dom96> @Space Ghost you're compiling with -d:release right? |
18:00:30 | FromDiscord | <Space Ghost> In reply to @Generic "well your code might": I do not get it. I came here to ask for help about a function in Nim to optimize io of my arrays or sequences. I could care less which language I use. I program in assembler, Basic, Fortran, C, C++, Lazarus/FP, Ruby, Python, etc. I like Nim and V for many reasons related to native exe's on Windows x64 and their syntax and speed, plus they use C compilers at the end and I can use gdb+ |
18:02:57 | FromDiscord | <juba> In reply to @dom96 "what's your profile nickname?": Burt_Harbinson |
18:03:19 | FromDiscord | <dom96> In reply to @juba "Burt_Harbinson": activated it for you |
18:03:29 | FromDiscord | <Space Ghost> In reply to @dom96 "<@867520740273029160> you're compiling with": Yes, -d:release. I can tell you that in 600 lines of code the only difference between the Nim and V source code is the extra for loop reads and writes in the two xor functions. I am able to use Nim's readAll and fmWrite everywere except when I need to save a sequence or array and then retrieve it. This is a CPU time consuming issue and If I write the V code that wa |
18:03:46 | * | dv^_^ joined #nim |
18:06:29 | FromDiscord | <Generic> can you show us your V code? |
18:09:06 | FromDiscord | <Generic> Nim's `write` seem to rely on fprintf which is a bit of a black box |
18:09:48 | FromDiscord | <Generic> though string formatting in C is usually not that fast |
18:11:56 | FromDiscord | <Generic> using Nim's stdlib functions to convert the number to a string and then writing that to file is probably faster |
18:14:23 | FromDiscord | <Generic> though I do have to ask, why you're converting to decimal in the first place? |
18:16:36 | FromDiscord | <Space Ghost> In reply to @Generic "using Nim's stdlib functions": In Nim I cannot xor bytes. I have a string of numbers and string of letters(text). I am using the one time pad vernam xor to encrypt. The numbers are quantum grade random. In V I can xor (using ^ symbol) with both as u8 bytes. I am going to upload both Nim and V code as you asked. Just cleaning it up to paste into Discord. |
18:17:52 | FromDiscord | <Space Ghost> The key is I must save the coded text as an array and then call it up later....somewhere else. So it saved as a formatted file with some type of delimiter. |
18:17:54 | FromDiscord | <Generic> byte = uint8 in Nim |
18:17:58 | FromDiscord | <Generic> and you can xor uint8 |
18:18:27 | FromDiscord | <juba> In this example, wouldn't it be better to have `f: File` instead of `filename: File`? https://nim-lang.org/docs/io.html#lines.i%2CFile |
18:19:49 | FromDiscord | <Generic> yeah looks like it |
18:22:38 | FromDiscord | <Space Ghost> sent a long message, see http://ix.io/41Yo |
18:23:05 | FromDiscord | <Generic> well that explains everything |
18:23:22 | FromDiscord | <Generic> so in V, you're loading the entire data into memory first, then do the operation on it and then save it again to file? |
18:27:11 | FromDiscord | <Space Ghost> sent a long message, see http://ix.io/41Yp |
18:29:17 | * | derpydoo quit (Quit: derpydoo) |
18:30:11 | FromDiscord | <IDF> have you tried `writeBuffer`? |
18:30:18 | FromDiscord | <Generic> that's for binary data though |
18:30:41 | FromDiscord | <Generic> assuming you want it de-/serialized to text |
18:31:09 | FromDiscord | <Space Ghost> In reply to @Generic "that's for binary data": Thank you! Someone who is answering my question, :). I have not tried this. Can you briefly explain a little. I am about to upload both Nim and V code. |
18:31:40 | FromDiscord | <IDF> https://nim-lang.org/docs/io.html#writeBuffer%2CFile%2Cpointer%2CNatural |
18:31:52 | FromDiscord | <IDF> it should do what V's function does, dump data into a file |
18:31:53 | FromDiscord | <Space Ghost> In reply to @Generic "that's for binary data": That part is all good. I just need to save the coded text and read it in later. |
18:32:27 | FromDiscord | <Generic> if you're only dealing with chars the whole time, you can also just use the read/write overload which works on strings |
18:32:31 | FromDiscord | <Space Ghost> In reply to @IDF "it should do what": Can you point me how to declare a buffer. |
18:32:34 | FromDiscord | <Generic> https://nim-lang.org/docs/io.html#write%2CFile%2Cstring |
18:36:48 | FromDiscord | <IDF> In reply to @Space Ghost "Can you point me": https://nim-lang.org/docs/system.html#new%2Ctypedescâ”â”but in your case i think you can just do `addr data` or if it's a string `cstring(data)` |
18:37:15 | FromDiscord | <Generic> c strings are termined by a null byte though |
18:37:36 | FromDiscord | <IDF> yeah the compiler makes sure the string is transformated correctly |
18:38:04 | FromDiscord | <Generic> it cannot correct though if you put in a 0 byte earlier than the length |
18:38:32 | FromDiscord | <Generic> which in this application can happen when the key and the one of the bytes to be encrypted match up at some point |
18:39:08 | FromDiscord | <Space Ghost> sent a long message, see http://ix.io/41Ys |
18:39:14 | FromDiscord | <IDF> In reply to @Generic "which in this application": fair |
18:39:39 | FromDiscord | <Space Ghost> (edit) "long message," => "code paste," | "http://ix.io/41Ys" => "https://play.nim-lang.org/#ix=41Yt" |
18:40:05 | FromDiscord | <Space Ghost> (edit) "https://play.nim-lang.org/#ix=41Yt" => "https://play.nim-lang.org/#ix=41Yu" |
18:40:26 | FromDiscord | <Space Ghost> (edit) "https://play.nim-lang.org/#ix=41Yu" => "https://play.nim-lang.org/#ix=41Yv" |
18:40:54 | FromDiscord | <IDF> https://github.com/vlang/v/blob/819b6f475a270e29da752199b236d91d6c5d0db7/vlib/os/os.c.v#L1018â”looked the function up and it seems to be equivalent to io.writeBuffer |
18:41:21 | FromDiscord | <Generic> yeah so you're indeed writing binary and not text data in the V version |
18:41:44 | FromDiscord | <Generic> so the Nim code does significantly more work, because it converts the integers to text first |
18:42:13 | FromDiscord | <Generic> (edit) removed "first" |
18:42:37 | FromDiscord | <Space Ghost> In reply to @Generic "yeah so you're indeed": Not sure I understand how to get it in binary in Nim... |
18:43:28 | FromDiscord | <Generic> just convert the char to uint8 |
18:43:40 | FromDiscord | <Generic> do the xoring and then convert it back |
18:44:25 | FromDiscord | <Generic> or better, while possible always extract 8 bytes as a uint64 and do the xoring with that |
18:45:00 | FromDiscord | <Generic> though with code like this, chances are high that even auto vectorisation can take care of this |
18:45:50 | FromDiscord | <IDF> yeah I forgot `write` has generics for other stuff than string |
18:45:58 | FromDiscord | <IDF> so converting to uint8 might just do it |
18:47:19 | FromDiscord | <Space Ghost> Can I just enclose the xor output in char() and save to a string and then write the string. When I read it back into a string then just index each element in the string and xor back? |
18:48:14 | FromDiscord | <Generic> yes |
18:48:29 | FromDiscord | <IDF> yea should work |
18:48:43 | FromDiscord | <Space Ghost> trying now |
18:51:12 | * | pro joined #nim |
18:51:19 | FromDiscord | <Space Ghost> sent a long message, see http://ix.io/41Yx |
18:51:54 | FromDiscord | <Space Ghost> sent a code paste, see https://play.nim-lang.org/#ix=41Yy |
18:52:17 | FromDiscord | <Generic> codedInts2.setLen length |
18:52:25 | FromDiscord | <Generic> before the for loop |
18:53:09 | FromDiscord | <Space Ghost> sent a code paste, see https://play.nim-lang.org/#ix=41Yz |
18:53:26 | FromDiscord | <Space Ghost> The length is set as a constant up top |
18:53:45 | FromDiscord | <IDF> yea but the string needs to have memory allocated |
18:54:22 | FromDiscord | <Space Ghost> sent a code paste, see https://play.nim-lang.org/#ix=41YB |
18:54:39 | FromDiscord | <IDF> sent a code paste, see https://play.nim-lang.org/#ix=41YC |
18:54:42 | FromDiscord | <Space Ghost> I set codedInts2 as a mutable var up top and intialized with " " |
18:54:59 | FromDiscord | <IDF> In reply to @Space Ghost "I set codedInts2 as": yes that results in a string with only one character allocated |
18:55:01 | FromDiscord | <IDF> therefore your error |
18:55:48 | FromDiscord | <Generic> if you know the size in before hand it's still smarter to not use add |
18:55:58 | FromDiscord | <IDF> right |
18:56:03 | FromDiscord | <IDF> then just `newString(length)` |
18:56:08 | FromDiscord | <IDF> and keep the rest |
18:56:16 | FromDiscord | <Generic> yeah |
18:58:19 | FromDiscord | <Space Ghost> good God it worked. Now I need to reverse the code going backward. I am going to try it but might need a hand if I get errors. Thanks so much to you both. |
19:04:38 | FromDiscord | <Space Ghost> In reply to @IDF "then just `newString(length)`": should I read or readAll back into a string? |
19:05:32 | FromDiscord | <IDF> readAll if you want a string |
19:10:26 | FromDiscord | <Mike> Okay, sorry to be begging for help again, but I have an asynchttpserver that's leaking memory and eventually crashing, and I can't figure out why |
19:10:44 | FromDiscord | <Mike> sent a code paste, see https://play.nim-lang.org/#ix=41YI |
19:11:35 | FromDiscord | <Mike> Basically just a client sending a request, and the server responding with a big, memory-eating string. |
19:12:03 | FromDiscord | <Mike> sent a code paste, see https://play.nim-lang.org/#ix=41YJ |
19:12:06 | * | pro quit (Quit: pro) |
19:12:30 | FromDiscord | <Mike> sent a code paste, see https://play.nim-lang.org/#ix=41YK |
19:13:30 | FromDiscord | <Mike> Am I missing something dumb here? Why does the memory inflate, and why does it sometimes inflate with refc, but not always?? |
19:18:11 | FromDiscord | <IDF> try with `-d:release` |
19:20:10 | FromDiscord | <IDF> also try closing the clients after you get the content |
19:20:36 | FromDiscord | <Mike> `-d:release` didn't change anything. I'll try closing clients |
19:21:51 | FromDiscord | <Mike> Nope, no change there either. Still grows every time |
19:33:05 | FromDiscord | <HuskyHacks> sent a code paste, see https://play.nim-lang.org/#ix=41YO |
19:33:10 | FromDiscord | <soundmodel> the more I've read the less any other language than Nim interests me |
19:33:11 | FromDiscord | <soundmodel> odd? |
19:33:20 | FromDiscord | <!Patitotective> In reply to @soundmodel "the more I've read": yes |
19:33:50 | FromDiscord | <soundmodel> no I'm serious, it seems like nothing else seems as versatile |
19:35:13 | FromDiscord | <!Patitotective> yes I'm serious, nim is really cool |
19:35:28 | FromDiscord | <soundmodel> I think objective-C comes closest, but not in platforms |
19:36:28 | FromDiscord | <soundmodel> (edit) "objective-C" => "objective-C/Swift" |
19:42:11 | FromDiscord | <Space Ghost> sent a long message, see http://ix.io/41YQ |
19:46:10 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=41YS |
19:48:35 | FromDiscord | <Generic> if you define a type alias like this, it'll implicitly convert and you can just use it like the aliased type |
19:49:17 | FromDiscord | <Generic> https://play.nim-lang.org/#ix=41YU |
19:51:37 | FromDiscord | <sOkam!> nice, tysm! |
20:10:40 | NimEventer | New thread by Cnerd: Compile time imports, see https://forum.nim-lang.org/t/9295 |
20:11:50 | * | hc0re quit (Ping timeout: 240 seconds) |
20:13:51 | * | hc0re joined #nim |
20:21:46 | * | jmdaemon quit (Ping timeout: 244 seconds) |
20:28:39 | FromDiscord | <dom96> In reply to @Mike "Am I missing something": Good question. I'm curious too, it seems like a GC bug. Probably best to ask Araq (in #internals, forum or Github issues) |
20:29:57 | FromDiscord | <dom96> sent a code paste, see https://play.nim-lang.org/#ix=41YZ |
20:31:10 | FromDiscord | <geekrelief> In reply to @HuskyHacks "I'd appreciate a sanity": You might want to check your dll with Dependencies https://github.com/lucasg/Dependencies to see what it's actually loading. |
20:32:00 | FromDiscord | <dom96> sent a code paste, see https://play.nim-lang.org/#ix=41Z1 |
20:32:37 | FromDiscord | <dom96> so maybe this is an edge case that no GC can prevent mem leaks on |
20:38:43 | FromDiscord | <Mike> Thanks for the `-d:nimTypeNames` trick; that's actually really useful for debugging. Although as you said it's really just `string` in this case.â”(@dom96) |
20:39:36 | FromDiscord | <Mike> I've been playing around with it, and if I switch to `refc` rather than `orc` the heap grows, but eventually stabilizes. Whereas with `orc` it just keeps growing indefinitely and eventually my little $4 droplet server dies |
20:40:36 | * | noeontheend joined #nim |
20:42:57 | FromDiscord | <Mike> I've also been playing around with `--expandArc:cb`, but understanding what's actually happening is a bit beyond me |
21:08:30 | * | noeontheend quit (Ping timeout: 240 seconds) |
21:27:05 | FromDiscord | <Elegantbeef> mattrb#0001 so threads is all it was and i can now make nit picky PRs? \:D |
21:27:19 | FromDiscord | <Elegantbeef> Uh oh this client doesnt like pinging |
21:31:40 | FromDiscord | <byteface> sent a code paste, see https://play.nim-lang.org/#ix=41Zf |
21:31:54 | FromDiscord | <Elegantbeef> varargs are already an array or sequence |
21:32:17 | * | arkanoid quit (Ping timeout: 256 seconds) |
21:32:27 | FromDiscord | <Elegantbeef> Or... not |
21:32:49 | * | arkanoid joined #nim |
21:32:50 | FromDiscord | <Elegantbeef> There you go |
21:32:53 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=41Zg |
21:33:05 | FromDiscord | <byteface> toSeq? there's a util? |
21:33:31 | FromDiscord | <Elegantbeef> Yes it takes anything iterable and makes a sequence |
21:33:48 | FromDiscord | <byteface> so what is system.@ ? |
21:34:02 | FromDiscord | <Elegantbeef> `@` works on arrays |
21:34:09 | FromDiscord | <byteface> ah |
21:34:21 | FromDiscord | <byteface> i think i can't use that as its fixed length |
21:35:05 | FromDiscord | <Elegantbeef> What? |
21:35:20 | FromDiscord | <byteface> the array. i think i need seq |
21:35:26 | FromDiscord | <Elegantbeef> `@` is for converting arrays to sequences, `toSeq` works on anything iterable |
21:35:37 | FromDiscord | <Elegantbeef> did you not read my code? |
21:35:44 | FromDiscord | <byteface> ah ok |
21:36:34 | FromDiscord | <byteface> weird. toSeq makes a sequence of varargs?. is that right? |
21:36:47 | FromDiscord | <Elegantbeef> No |
21:36:56 | FromDiscord | <Elegantbeef> `toSeq` takes anything iterable and makes a sequence of it |
21:37:01 | FromDiscord | <Elegantbeef> Run the code i gave you |
21:37:13 | FromDiscord | <byteface> type mismatch: got <seq[type varargs]> |
21:37:17 | FromDiscord | <byteface> ? |
21:37:45 | FromDiscord | <Elegantbeef> No |
21:37:45 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=41Zh |
21:38:42 | FromDiscord | <byteface> maybe i'll start fro teh top as my varargs are wrong |
21:39:16 | FromDiscord | <byteface> lets say i have 10 fruits. all classes. and i want to pass any number of them to a proc# |
21:39:48 | FromDiscord | <byteface> now i had done something like this |
21:39:58 | FromDiscord | <byteface> sent a code paste, see https://play.nim-lang.org/#ix= |
21:40:12 | FromDiscord | <byteface> which worked but i didn't like as it converts the fruits into strings |
21:40:26 | FromDiscord | <byteface> but untyped and any wasn't working as the vararg |
21:40:39 | FromDiscord | <Elegantbeef> Can you just provide code? |
21:40:46 | FromDiscord | <Elegantbeef> I dont feel like playing a guessing game |
21:41:10 | FromDiscord | <byteface> well that is it . im trying to reduce the problem |
21:41:51 | FromDiscord | <byteface> like is that the correct way to pass a list of mixed classes to a proc? |
21:42:00 | FromDiscord | <byteface> in the first place? |
21:42:32 | FromDiscord | <Elegantbeef> What's a class |
21:42:48 | FromDiscord | <Elegantbeef> Nim doesnt have classes so the answer lies in what are you trying to do |
21:42:50 | FromDiscord | <byteface> i guess a 'type' |
21:43:14 | FromDiscord | <Elegantbeef> Are we talking about ints and floats or subclasses |
21:43:34 | FromDiscord | <byteface> custom types called Apple , Banana, Pear, Orange |
21:43:56 | FromDiscord | <Elegantbeef> Ok so we can use object variants or oop |
21:44:07 | FromDiscord | <byteface> i wanna go basket( Apple(), Banana(), Pear() ) |
21:44:12 | FromDiscord | <byteface> and have teh basket tell me what i got |
21:44:51 | FromDiscord | <byteface> so i read about varargs but that wants a certain type |
21:45:06 | FromDiscord | <byteface> when i try any or untyped it don't work. unless i do that trick that makes them a string. |
21:45:27 | FromDiscord | <byteface> then they do come through but are strings. and as you saw calling toSeq doesn't unpack it |
21:46:54 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=41Zi |
21:47:08 | FromDiscord | <Elegantbeef> Like i said you need to use either oop or object variants |
21:47:14 | FromDiscord | <Elegantbeef> The above is the variant type |
21:50:35 | FromDiscord | <byteface> urg. so you stick references implementations in bases? |
21:51:04 | FromDiscord | <byteface> i hate seeing baseclasses that reference children in oop. like if my child is type x. shudders |
21:51:20 | FromDiscord | <byteface> how would a fruit know a banana existed? |
21:53:43 | FromDiscord | <Elegantbeef> That's the oop method |
21:53:47 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=41Zk |
21:54:05 | FromDiscord | <Elegantbeef> It doesnt |
21:54:15 | FromDiscord | <Elegantbeef> It doesnt need to |
21:54:25 | FromDiscord | <Elegantbeef> Nim has dynamic dispatch if you really need it |
21:54:41 | FromDiscord | <byteface> ye i don't really understand what that means |
21:54:50 | FromDiscord | <Elegantbeef> methods |
21:54:51 | FromDiscord | <byteface> its like telling me its got a dangle berry |
21:56:20 | FromDiscord | <Elegantbeef> You can use methods and override them like in OOP languages |
21:56:57 | FromDiscord | <byteface> well your 2nd example is closer to what i have |
21:57:03 | FromDiscord | <byteface> but im not getting the results you are |
21:57:52 | FromDiscord | <huantian> what's a dangle berry |
21:58:02 | FromDiscord | <byteface> ah i just realised 1 thing. |
21:58:03 | FromDiscord | <huantian> is it like a dangling pointer but for fruits? |
21:58:41 | FromDiscord | <byteface> your varargs says varargs[Fruits] |
21:58:43 | FromDiscord | <huantian> so when you have a dangling pointer to a berry is it a dangle berry |
21:58:51 | FromDiscord | <byteface> but what if sometimes its just a string saying 'No' |
21:59:05 | FromDiscord | <byteface> so basket(Apple(), 'No' , Pear()) |
21:59:09 | FromDiscord | <Elegantbeef> Nim isnt dynamically typed so dont write code like that |
21:59:10 | FromDiscord | <huantian> then static typing doesn't exist and we go use javascript |
21:59:17 | FromDiscord | <byteface> so i need varargs[untyped] but that's not working |
21:59:58 | FromDiscord | <byteface> so varargs can only have things of a given type ? |
22:01:27 | FromDiscord | <Elegantbeef> Nim is static typed yes |
22:02:36 | FromDiscord | <byteface> can i add string to my Fruits |
22:13:50 | FromDiscord | <byteface> maybe a vararg for strings and one for fruits. for me varargs is not converting its wrapping also. just strange |
22:14:23 | * | xet7 joined #nim |
22:14:32 | FromDiscord | <Elegantbeef> Nim is statically typed so varargs are just a fancy wrapping over `openArray[T]` and a automatic conversion call |
22:14:43 | FromDiscord | <Elegantbeef> This is not python so dont expect it to be like python |
22:36:39 | FromDiscord | <vindaar> just to clarify this for people who may be unaware\: `varargs[untyped]` in principle is not a direct wrapper of a specific `openArray[T]`. As long as you're able & willing to deal with an arbitrary `nnkBracket` of heterogeneous types at compile time, it can accept any combination of types. This doesn't really have any applications for things like heterogeneous containers though! |
22:37:07 | FromDiscord | <Elegantbeef> I mean untyped is only valid in templates/macros so if you're using it you best know what it does \:D |
22:37:46 | FromDiscord | <Elegantbeef> If you think `untyped` makes typeless parameters you really need to read the manual |
22:38:12 | FromDiscord | <vindaar> indeed, but maybe someone could be confused by your wording! đ
|
22:38:19 | FromDiscord | <Elegantbeef> Perhaps |
22:38:34 | FromDiscord | <Elegantbeef> I'm not known for having the best words, i'm not orange enough for that |
22:46:18 | FromDiscord | <huantian> @ripluke this is a jank thing that I wrote that might help a bit idk https://play.nim-lang.org/#ix=41ZE |
22:47:59 | FromDiscord | <byteface> sent a code paste, see https://play.nim-lang.org/#ix=41ZF |
22:49:40 | FromDiscord | <byteface> ye i only been doing it a day. so obviosly will have questions. |
22:51:48 | FromDiscord | <vindaar> the syntax for this is\:â”you want a variable number of arguments of type `string`. In order to turn these different typed arguments into `string`, use the `$` proc that should be defined for all input types you will handâ”(@byteface) |
22:53:23 | FromDiscord | <byteface> no its the opposite. i have a variable number of args. some are fruit. one might be a string. that one needs to be converted to a Fruit type called NoFruit i think is where we are getting to |
22:53:40 | FromDiscord | <huantian> I still would recommend against string typing your stuff, is there a reason it can't just take a NoFruit to begin with? |
22:53:44 | FromDiscord | <byteface> varargs[Fruit, myProc] |
22:54:04 | FromDiscord | <byteface> ye i considered that |
22:54:10 | FromDiscord | <byteface> but its just extra |
22:54:10 | FromDiscord | <huantian> ie `doStuff(Apple(), Pear(), NoFruit(), Orange())` |
22:54:30 | FromDiscord | <huantian> well I'd say using your conversion proc is more extra |
22:54:40 | FromDiscord | <huantian> and introuduces extra runtime points of failure |
22:54:47 | FromDiscord | <vindaar> sent a code paste, see https://play.nim-lang.org/#ix=41ZI |
22:56:19 | FromDiscord | <bariali07> Tomorrow is Eid al-Adha for Muslims |
22:57:45 | FromDiscord | <vindaar> I don't understand what you really want to do. From what you write, just define `fruiter` for `string` and define how the string -\@byteface) |
22:57:58 | FromDiscord | <Space Ghost> When compiling nim how can you specify the c compiler to use, for example what if you want to compile with clang vs. gcc |
22:58:58 | FromDiscord | <byteface> In reply to @vindaar "I don't understand what": how would your example handle this?... foo(Apple(), Apple(), Banana(), Fruit(), 'NoFruit') |
22:59:19 | FromDiscord | <byteface> i tried it and get Error: type mismatch: got <string> |
23:00:04 | FromDiscord | <Elegantbeef> `--cc:clang`â”(@Space Ghost) |
23:01:59 | FromDiscord | <Elegantbeef> Byteface it'd really help if you provided what you were doing |
23:02:11 | FromDiscord | <Elegantbeef> "Taking in a string" isnt really pointful |
23:02:25 | FromDiscord | <Elegantbeef> Casuse you can just have `NotFruit` like huan said |
23:02:52 | FromDiscord | <Space Ghost> In reply to @Elegantbeef "`--cc:clang` (<@867520740273029160>)": Thank you Elegantbeef worked beautifully. What is the default C backend, is it gcc or clang? |
23:03:01 | FromDiscord | <Space Ghost> PS on windows 11 x64 OS |
23:03:16 | FromDiscord | <Elegantbeef> Mingw should be default on windows |
23:03:20 | FromDiscord | <vindaar> the question isn't much what to do with a string (you'd just add a `proc fruiter(x: string): Fruit = discard # whatever you want to do` proc), but this is probably not what you really wantâ”(@byteface) |
23:04:35 | FromDiscord | <byteface> sent a code paste, see https://play.nim-lang.org/#ix=41ZN |
23:04:55 | FromDiscord | <Elegantbeef> `when x is string` |
23:05:16 | FromDiscord | <Elegantbeef> Those are compile time checks and need to use `when` |
23:05:41 | FromDiscord | <byteface> so somehow i can then wrap it in teh NoFruit type im hoping |
23:07:10 | FromDiscord | <Space Ghost> In reply to @Elegantbeef "Mingw should be default": Yes, I see that my c:\nim folder has mingw64 subfolder and in the sub-sub bin folder it has g++.exe and gcc.exe and x86_64-w64-mingw32-gcc.exe; but I do not see clang installed. Is it somewhere in the nim folder |
23:08:21 | FromDiscord | <Space Ghost> PS without the -cc:clang switch my exe is 214KB and with it is 194KB so the clang is slightly smaller than the default. I have tested the algorithm with a different platform using tcc, gcc, and clang and clang was fastest. |
23:08:32 | FromDiscord | <vindaar> also this `fruiter` here only accepts a `Node`. So the type name can never be anything aside from `Node`â”(@byteface) |
23:10:00 | FromDiscord | <Elegantbeef> You have to install other compilers yourself |
23:13:14 | FromDiscord | <byteface> In reply to @vindaar "also this `fruiter` here": it doesn't matter anyways as it doesn't get that far if its a string |
23:14:54 | FromDiscord | <huantian> In reply to @Elegantbeef "`when x is string`": No beef you canât just help someone string type their code! |
23:15:00 | FromDiscord | <byteface> but then i don't get why it suggests it can or that it works for $ |
23:15:21 | FromDiscord | <Elegantbeef> You really need to give a proper example of what you're trying to do |
23:15:28 | FromDiscord | <Elegantbeef> Why do you need to be able to provide a string |
23:15:51 | * | bigbyt quit (Read error: Connection reset by peer) |
23:17:35 | * | bigbyt joined #nim |
23:18:09 | FromDiscord | <Space Ghost> In reply to @Elegantbeef "`--cc:clang` (<@867520740273029160>)": Here is a nice post with exactly what you stated and some additionally nice information on compiling and debuging nim. thanks again.â”https://hookrace.net/blog/what-makes-nim-practical/ |
23:18:20 | FromDiscord | <byteface> it just looks like nim doesn't support passing mixed lists around. and there's no way to add string to the fruit types |
23:22:45 | FromDiscord | <huantian> You can get the same mixed list functionality with OOP or object variants |
23:25:23 | FromDiscord | <Elegantbeef> There is also the `union` library which makes object variants easier |
23:25:56 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=41ZV |
23:25:59 | FromDiscord | <Elegantbeef> But like why would you want to |
23:26:09 | FromDiscord | <byteface> sent a code paste, see https://play.nim-lang.org/#ix=41ZW |
23:26:30 | FromDiscord | <byteface> like this didn't work. which is wierd. as then why does it exist?. only for subtypes? |
23:26:41 | FromDiscord | <Elegantbeef> Againt `[T: Fruit]` is forcing it be `Fruit` |
23:26:58 | FromDiscord | <byteface> im fine with that |
23:27:05 | FromDiscord | <Elegantbeef> `x: auto` or `[T](x: T)` will work |
23:27:06 | FromDiscord | <byteface> but it string errors |
23:27:21 | FromDiscord | <byteface> i thought the point of myProc was i could catch the string and return it wrapped |
23:27:24 | FromDiscord | <byteface> but that's not the case |
23:27:34 | FromDiscord | <Elegantbeef> If you write the code properly it is |
23:28:05 | FromDiscord | <aru-hackZ> So you want to, from a string, return a Fruit holding it |
23:28:11 | FromDiscord | <byteface> ye |
23:28:16 | FromDiscord | <byteface> a fruit called NotFruit |
23:29:18 | FromDiscord | <aru-hackZ> sent a code paste, see https://play.nim-lang.org/#ix=41ZX |
23:29:44 | FromDiscord | <aru-hackZ> (edit) "https://play.nim-lang.org/#ix=41ZX" => "https://play.nim-lang.org/#ix=41ZY" |
23:29:49 | FromDiscord | <byteface> an overload? |
23:29:52 | FromDiscord | <byteface> does that work |
23:29:56 | FromDiscord | <aru-hackZ> Yh |
23:30:01 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=41ZZ |
23:30:58 | FromDiscord | <Elegantbeef> The question is still why would you want this |
23:31:02 | FromDiscord | <aru-hackZ> With that overload you can just `let myFruit = fruiter("orange")` |
23:31:30 | FromDiscord | <byteface> gimme 5 ill check this. sounds promising. thanks for examples all |
23:31:35 | FromDiscord | <aru-hackZ> In reply to @Elegantbeef "The question is still": For the time i've been reading, what he wants to do keeps changing lol |
23:31:41 | FromDiscord | <Elegantbeef> Why do you need a string with your fruit and why can you not just represent that with a `nonFruit("hello")` |
23:32:03 | FromDiscord | <Elegantbeef> Exactly they havent explicitly stated their goal once and it makes it harder to help themâ”(@aru-hackZ) |
23:33:14 | FromDiscord | <aru-hackZ> Tho I still dont know why and what he wants to do |
23:33:19 | FromDiscord | <Elegantbeef> We're talking about fruits and string, instead of the actual idea |
23:34:17 | FromDiscord | <byteface> sorry. lol. i've learned a lot. from what discard means to various other things. i did say it was my first day learning nim and i'd have lots of qs |
23:34:56 | FromDiscord | <enthus1ast> i often feel the same when beef talks to meâ”(@byteface) |
23:35:14 | FromDiscord | <Elegantbeef> Well shit i guess i need to use smaller words |
23:35:17 | FromDiscord | <aru-hackZ> `discard` is like a "i dont care what this code returns, just execute it" |
23:35:37 | FromDiscord | <Elegantbeef> Well acktually |
23:35:41 | FromDiscord | <aru-hackZ> (edit) "it"" => "it", or smth like that iirc" |
23:35:59 | FromDiscord | <aru-hackZ> (edit) "`discard` is like a "i dont care what this code returns, just execute it", or smth like that iirc ... " added "(im a newbie too)" |
23:36:11 | FromDiscord | <Elegantbeef> `discard` is just a statement that is a no op or can discard a value you dont care about |
23:36:24 | FromDiscord | <Elegantbeef> In nim you cannot have unhandled values |
23:36:28 | FromDiscord | <aru-hackZ> I wanst that woeng thrn |
23:36:42 | FromDiscord | <Elegantbeef> you have to do `discard `10\` |
23:36:43 | FromDiscord | <aru-hackZ> Thats what I meant, but im.bad expressing myself |
23:36:46 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4205 |
23:36:56 | FromDiscord | <Elegantbeef> Hey i'm just saying! |
23:37:21 | FromDiscord | <Elegantbeef> In the case you dont have a right hand of discard it's just a no op that gives the parser something to chew on |
23:37:37 | FromDiscord | <aru-hackZ> Got it |
23:38:00 | FromDiscord | <Elegantbeef> You can actually use doc comments or anything else that is valid AST |
23:38:12 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4206 |
23:38:34 | FromDiscord | <aru-hackZ> hmm |
23:38:47 | FromDiscord | <tylerlinuxdev> Probably handy for WIP stuff where you want to partially test your implementation that you've made so far and so you don't want to delete the values you are handling, so you just discard it from this one particular instance of compilation. |
23:39:11 | FromDiscord | <Elegantbeef> Well `discard` still runs the right hand |
23:39:21 | FromDiscord | <Elegantbeef> it just throws away the value inside it |
23:39:29 | FromDiscord | <Elegantbeef> Cause nim requires you to handle all values |
23:40:18 | FromDiscord | <aru-hackZ> Like when you use a proc which retruns a bool, but you just care for the side effects and not the return value, so you use discard |
23:40:31 | FromDiscord | <Elegantbeef> correct |
23:40:39 | FromDiscord | <Elegantbeef> Dont know if you were asking or telling but i'll say correct |
23:41:03 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=4207 |
23:41:15 | FromDiscord | <Elegantbeef> I fucking knew someone would mention it |
23:41:31 | FromDiscord | <enthus1ast> let me be that |
23:41:32 | FromDiscord | <Elegantbeef> I'm going to get my axe i'll be at your house in a couple days enthus |
23:41:34 | FromDiscord | <huantian> Time to mark all my `func`s discardable đ |
23:42:03 | FromDiscord | <aru-hackZ> In reply to @Elegantbeef "Dont know if you": Asking if i was right |
23:42:56 | FromDiscord | <enthus1ast> but an explicit `discard` is good, since it avoids bugs |
23:43:49 | FromDiscord | <aru-hackZ> And you explicitly know what's going on, instead of having to know if the proc has the discardable pragma, right? |
23:43:58 | FromDiscord | <Elegantbeef> I hope you lose your ssh keys and can never commit againâ”(@huantian) |
23:44:06 | FromDiscord | <Elegantbeef> Correct againâ”(@aru-hackZ) |
23:44:16 | FromDiscord | <tylerlinuxdev> [Elegantbeef](https://matrix.to/#/@elegantbeef:matrix.org)\: That a bit extreme, lol |
23:44:33 | FromDiscord | <Elegantbeef> `discard` is a great feature in a language that has "all statements as expressions" |
23:44:55 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4208 |
23:46:23 | FromDiscord | <Elegantbeef> It does discard the value, but it's likely one of the two calls is the mistake |
23:49:32 | FromDiscord | <Elegantbeef> is a mistake\ |
23:50:25 | FromDiscord | <Elegantbeef> enthus1ast (@sn0re\:matrix.code0.xyz)so turns out if you shit talk someone enough they follow you? |
23:50:27 | FromDiscord | <Elegantbeef> Ok so fuck cinny's mentioning |
23:50:34 | FromDiscord | <Elegantbeef> good client otherwise |
23:50:43 | FromDiscord | <enthus1ast> want to see if you still work on nimscripter |
23:50:56 | FromDiscord | <Elegantbeef> Havent touched it in forefer |
23:50:58 | FromDiscord | <Elegantbeef> forever |
23:51:07 | FromDiscord | <Elegantbeef> If people make issues i fix them or address them |
23:52:15 | FromDiscord | <enthus1ast> still want to do the nimja dynamic thing, but the type conversion hinders me a bit (and the rest, eg working, wife, etc) |
23:52:38 | FromDiscord | <enthus1ast> ah forgot drinking |
23:53:09 | FromDiscord | <Elegantbeef> Yea i'm very much on board with WASM now, it offers nicer ideas for user facing programs |
23:53:30 | FromDiscord | <Elegantbeef> If it's not userfacing then i think nimscript is fine, but like why force people to use nim when they can use any language they want |
23:58:21 | FromDiscord | <ripluke> In reply to @huantian "<@704106773660827690> this is a": Ok thanks |