00:02:29 | * | jmdaemon joined #nim |
00:04:33 | * | nmz joined #nim |
00:34:41 | FromDiscord | <!Patitotective> is there a way to wrap cpp libraries to nim? |
00:38:45 | FromDiscord | <Elegantbeef> You use dear-imgui and you're asking this? |
00:39:13 | FromDiscord | <!Patitotective> nimgl/imgui is a wrapper for cimgui not the actual cpp library |
00:39:27 | FromDiscord | <Elegantbeef> If you usue the cpp backend it uses dearimgui directly |
00:40:35 | FromDiscord | <Elegantbeef> Ah sorry it uses cimgui but it uses the CPP code directly |
00:40:41 | FromDiscord | <Elegantbeef> https://github.com/nimgl/nimgl/blob/master/src/nimgl/imgui.nim#L42-L48 |
00:40:42 | FromDiscord | <!Patitotective> and there isnt any futhark for cpp, right? i need to manually `importCpp` |
00:40:58 | FromDiscord | <Elegantbeef> You can use c2nim a bit but yes you need to manually convert most of it |
00:41:55 | FromDiscord | <jan0809> so nim habe different build backends right(?) |
00:42:03 | FromDiscord | <jan0809> (edit) "habe" => "have" |
00:42:13 | FromDiscord | <Elegantbeef> Yes it has different backends |
00:43:06 | FromDiscord | <jan0809> how to change them |
00:43:34 | FromDiscord | <Elegantbeef> `nim cpp` or `nim js` to compile to c++ and js respectively |
00:43:54 | FromDiscord | <Elegantbeef> `nim c` is technically "nim compile" but no one changes their default backend that i know of so we can pretend it means "c" |
00:44:10 | FromDiscord | <jan0809> is there a beneifit in building cpp? |
00:44:15 | FromDiscord | <!Patitotective> iirc there is also `nim cc` that actually means c, right? |
00:44:17 | FromDiscord | <Elegantbeef> You can do C++ interop |
00:44:33 | FromDiscord | <jan0809> hmm |
00:44:48 | FromDiscord | <Elegantbeef> Nim and D are like the only languages that can do C++ interop |
00:45:10 | FromDiscord | <Elegantbeef> Every other language since it uses either just a C backend or it's own compiler is pretty much stuck in using system library interop |
00:45:11 | FromDiscord | <jan0809> i c |
00:45:43 | FromDiscord | <jan0809> but what about python? it have quite some cpp based libs |
00:45:48 | FromDiscord | <๐๐ง br4n_d0n> My word, this nim compiler code SERIOUSLY needs some decent commenting. I'm struggling to follow |
00:45:54 | FromDiscord | <jan0809> but thats something diff i assume |
00:46:12 | FromDiscord | <Elegantbeef> Python is going to interop to C++ libraries using the C api |
00:46:33 | FromDiscord | <!Patitotective> In reply to @br4n_d0n "My word, this nim": PRs welcome haha |
00:46:53 | FromDiscord | <Elegantbeef> Since Nim actually can output C++ you can use things like templated classes in your Nim code, you cannot really do that in other languages |
00:47:27 | FromDiscord | <๐๐ง br4n_d0n> In reply to @Patitotective "PRs welcome haha": If I knew what was going on, I would |
00:48:02 | FromDiscord | <Elegantbeef> The way you learn is just to keep at it attempting to do whatever you're doing |
00:48:11 | FromDiscord | <Elegantbeef> Eventually you'll learn how to reason what's going on |
00:48:19 | FromDiscord | <Elegantbeef> It's a shitty thing to have to do but it's how it's written |
00:48:26 | FromDiscord | <jan0809> In reply to @Elegantbeef "Since Nim actually can": look i totally understood nim is amazing, im just trying to understand its place in the big ecosystem |
00:48:53 | FromDiscord | <Elegantbeef> I was just explaining what that C++ interop gives you |
00:50:48 | FromDiscord | <jan0809> look, im mainly a python person, means the last time i were confronted with the term `interop` was when i tried to root my nokia lumia lol |
00:51:02 | FromDiscord | <Elegantbeef> Ok? |
00:51:21 | FromDiscord | <jan0809> jokes aside, would that mean that i could just import lets say opencv and use it? |
00:51:38 | FromDiscord | <jan0809> but i saw theres a wrapper too |
00:51:38 | FromDiscord | <Elegantbeef> "just import" is a bit of an understatement |
00:51:44 | FromDiscord | <Elegantbeef> Nim and C++ have different language semantics |
00:51:52 | FromDiscord | <Elegantbeef> So you have to wrap the C++ into Nim |
00:52:03 | FromDiscord | <Elegantbeef> But yes you can import code written in C++ and use it |
00:52:26 | FromDiscord | <Elegantbeef> Generally though most people just wrap C APIs as it's simpler |
00:52:54 | FromDiscord | <jan0809> but when i use the cpp backend, will stuff like nimpy stop working? |
00:53:01 | FromDiscord | <Elegantbeef> No |
00:53:17 | FromDiscord | <Elegantbeef> The C++ backend is less tested but it should work identical to the C backend |
00:53:20 | * | nmz left #nim (Ploop) |
00:54:03 | FromDiscord | <Elegantbeef> The only real difference between backends is the C++ one gives you the abillity to use C++ interop |
00:54:10 | FromDiscord | <Elegantbeef> Other than that they should behave identically for the same input |
00:54:59 | FromDiscord | <jan0809> and no notable performance differences (assuming the same input) |
00:55:30 | FromDiscord | <Elegantbeef> Should be similar |
00:55:44 | FromDiscord | <Elegantbeef> Main difference would be what C/C++ compiler you usued |
00:55:56 | FromDiscord | <jan0809> can i use zig? |
00:56:15 | FromDiscord | <Elegantbeef> Yes |
00:56:17 | FromDiscord | <Elegantbeef> It's not as simple as other C compilers but you can use zig's C compiler |
00:56:41 | FromDiscord | <Elegantbeef> There isnt much benefit vs. just using clang but you can if you want |
00:57:13 | FromDiscord | <jan0809> besides crosscompiling(?) if thats a thing in that case |
00:57:29 | FromDiscord | <Elegantbeef> zigcc is basically clang |
00:58:24 | FromDiscord | <Elegantbeef> So aside from cross compiling yea it's pretty much identical |
01:05:50 | FromDiscord | <๐๐ง br4n_d0n> "Gotta go fast!" is on hold this week because Andrew is getting married Saturday |
01:21:47 | FromDiscord | <๐๐ง br4n_d0n> What's with the skull emoji? |
01:22:49 | FromDiscord | <!Patitotective> marriage ๐ |
01:24:31 | FromDiscord | <CrEpE> Has anyone run into strangeness with the terminal module and eraseline on windows? It doesn't appear to be fully erasing what i tell it to. If I write a line shorter than what was previously there I can still see the old line peeking through |
01:39:35 | FromDiscord | <Elegantbeef> Might depend on your terminal emulator |
01:40:33 | FromDiscord | <CrEpE> I'm just using normal powershell. Not sure I've tried cmd ill give that a shot though |
01:47:16 | * | arkurious quit (Quit: Leaving) |
01:50:45 | * | wallabra joined #nim |
02:02:26 | * | emery quit (Ping timeout: 246 seconds) |
03:26:42 | FromDiscord | <j-james> what is the reason behind the `-d:ssl` flag? |
03:27:12 | FromDiscord | <Elegantbeef> openssl is used for SSL |
03:27:35 | FromDiscord | <Elegantbeef> If you dont need/want openssl you dont need to ship it |
03:27:53 | FromDiscord | <Elegantbeef> Bearssl or similar would be a nice replacement |
03:27:55 | FromDiscord | <j-james> just because it's a big dependency, then? |
03:28:10 | FromDiscord | <Elegantbeef> Also probably the license but idk |
03:30:13 | FromDiscord | <Elegantbeef> The benefit of bearssl is it's MIT licensed so you can have the source code and not rely on a DLL for if you want self contained binaries |
03:30:44 | FromDiscord | <j-james> i hadn't heard of bearssl until recently |
03:30:58 | FromDiscord | <j-james> curious how it differs from libressl/boringssl |
03:31:08 | FromDiscord | <j-james> i guess not being based on openssl is a big change |
03:32:14 | FromDiscord | <j-james> In reply to @Elegantbeef "The benefit of bearssl": interesting ic |
03:32:29 | FromDiscord | <Elegantbeef> Status uses bearssl afaik |
03:41:24 | * | rockcavera quit (Remote host closed the connection) |
03:42:35 | FromDiscord | <Elegantbeef> Also that benefit is indirectly smaller binary sizes if you didnt realize ๐ |
03:59:07 | FromDiscord | <treeform> In reply to @Elegantbeef "Bearssl or similar would": you can also use the OS APIs like we do in `puppy`. No need for `-d:ssl`. |
03:59:26 | FromDiscord | <Elegantbeef> I mean we were talking about the inclusion of SSL |
03:59:54 | * | ehmry joined #nim |
03:59:54 | FromDiscord | <Elegantbeef> Isnt it used in more places than just http requests |
04:00:46 | FromDiscord | <treeform> In reply to @j-james "curious how it differs": libressl is a fork of openSSL used by some linux distros, boringssl is also a fork of openSSL but only really used by Google. |
04:01:37 | FromDiscord | <treeform> In reply to @Elegantbeef "Isnt it used in": 99% of the time its only http requests |
04:02:15 | FromDiscord | <treeform> I have used openSSL directly for cryptography for JWT... but its a very niche use. |
04:03:20 | FromDiscord | <treeform> In reply to @j-james "i hadn't heard of": bearssl is not a fork, its has its own API and code. |
04:03:27 | FromDiscord | <treeform> That makes it very interesting |
04:03:53 | FromDiscord | <j-james> In reply to @treeform "you can also use": oh yeah, i meant to ask a while back: since puppy exists, what's the reason windy ships with an http stack? |
04:04:09 | FromDiscord | <treeform> we are actually exploring this now |
04:04:12 | FromDiscord | <j-james> i've been using windy+boxy+pixie for a project and they're a blast by the way |
04:04:21 | FromDiscord | <treeform> puppy was version 1 |
04:04:38 | FromDiscord | <treeform> but it turns out if you have an OS loop, you can use other methods. |
04:04:46 | FromDiscord | <treeform> windy uses os loop method |
04:04:57 | FromDiscord | <treeform> we are thinking of maybe combining the two approaches |
04:05:37 | FromDiscord | <j-james> In reply to @treeform "but it turns out": other methods? |
04:05:45 | FromDiscord | <treeform> to make puppy async you basically need threads |
04:06:15 | FromDiscord | <treeform> to make windy-http async is very easy, you just ask OS and it calls you back on the window event loop. |
04:06:53 | FromDiscord | <treeform> In reply to @j-james "other methods?": Yes, OSes have more then two APIs to do things. |
04:08:01 | FromDiscord | <treeform> you can see here using windy http requires to have a window open: https://github.com/treeform/windy/blob/master/examples/httprequest.nim |
04:09:43 | FromDiscord | <treeform> In reply to @j-james "i've been using windy+boxy+pixie": I am glad that works for you. |
04:11:09 | FromDiscord | <j-james> interesting |
04:11:35 | FromDiscord | <j-james> from a user perspective, it feels like http support doesn't fit with the rest of windy as well |
04:11:48 | FromDiscord | <j-james> but i see how you'd always want async requests and simplifying that is nice |
04:13:51 | FromDiscord | <treeform> its just that window's HTTP api is just tied to a window. |
04:13:58 | FromDiscord | <treeform> or one of them is |
04:16:50 | * | ehmry quit (Ping timeout: 246 seconds) |
04:16:50 | * | mahlon quit (Ping timeout: 246 seconds) |
04:16:50 | * | madprog quit (Ping timeout: 246 seconds) |
04:16:50 | * | drewr quit (Ping timeout: 246 seconds) |
04:17:30 | * | ehmry joined #nim |
04:18:43 | * | mahlon joined #nim |
04:18:45 | * | madprog joined #nim |
04:30:15 | * | cyraxjoe joined #nim |
04:31:17 | * | drewr joined #nim |
04:52:42 | FromDiscord | <Mike> Hey is there a convenient way of getting the last item in a sequence? |
04:53:20 | FromDiscord | <Mike> I can get the highest index with `s.high`, and I can get the last value with `s.pop`, but that removed the last value |
04:53:39 | FromDiscord | <Mike> Is there something like `s.last`? |
04:53:52 | FromDiscord | <Elegantbeef> `s[^1]` |
04:53:57 | FromDiscord | <Mike> ahhhhhhhh |
04:54:07 | FromDiscord | <Mike> Man I couldn't find that anywhere |
04:54:17 | FromDiscord | <Elegantbeef> `[]` takes both `int` and backwards index |
04:54:43 | FromDiscord | <Mike> I kept trying stuff like `s[:-1]` or whatever |
04:54:59 | FromDiscord | <Yardanico> In reply to @Mike "Man I couldn't find": https://nim-lang.org/docs/system.html#^.t%2Cint |
04:55:17 | FromDiscord | <Yardanico> also some info in https://nim-lang.org/docs/tut1.html#advanced-types-slices |
04:55:32 | FromDiscord | <Yardanico> and of course https://narimiran.github.io/nim-basics/#_indexing_and_slicing |
04:56:15 | FromDiscord | <Mike> Yeah I mean I found it immediately after I knew what to call it \:( |
05:21:16 | FromDiscord | <j-james> what does `Error: Table is not a concrete type` mean? |
05:21:29 | FromDiscord | <Elegantbeef> You didnt specify generic parameters |
05:21:55 | FromDiscord | <j-james> ah, ty |
05:50:41 | FromDiscord | <Prestige> Elegantbeef did you try your mocker solution with the code I was trying to use? |
05:51:03 | FromDiscord | <Prestige> I'm not sure if I'm using your mock macro correctly, but I'm still seeing errors |
05:51:04 | FromDiscord | <Elegantbeef> I mean doesnt really matter if i did or not this is a much much less aggressive solution |
05:51:17 | FromDiscord | <Elegantbeef> What? |
05:51:59 | FromDiscord | <Elegantbeef> Code or it didnt happen! |
05:53:26 | FromDiscord | <Prestige> Looking at your example, I don't know where `doThingMock` is coming from |
05:53:41 | FromDiscord | <Elegantbeef> It's injected from the `mock` call |
05:53:48 | FromDiscord | <Prestige> hmm |
05:53:57 | FromDiscord | <Elegantbeef> I personally prefer `doThingMock` than `mockProcs.doThing` |
05:54:28 | FromDiscord | <Elegantbeef> look at the config.nims |
05:55:49 | FromDiscord | <Prestige> This is what I'm trying https://play.nim-lang.org/#ix=40Dt |
05:56:05 | FromDiscord | <Prestige> But I assume I should be manually invoking `genStringMock` during my test? |
05:56:18 | FromDiscord | <Elegantbeef> No |
05:56:31 | FromDiscord | <Elegantbeef> you need to write your mocked procs inside `mockProcs` |
05:56:36 | FromDiscord | <Elegantbeef> You cannot mock them as you go |
05:57:04 | FromDiscord | <Prestige> oh, has to be a separate file? That's not great |
05:58:00 | FromDiscord | <Elegantbeef> I mean it's the only ergonomic way i could reason to make the TRM less aggressive |
05:58:13 | FromDiscord | <Elegantbeef> The previous version had to have a seperate file aswell |
05:58:40 | FromDiscord | <Prestige> Maybe it needs to be more aggressive |
05:58:47 | FromDiscord | <Elegantbeef> What? |
05:58:53 | FromDiscord | <Elegantbeef> Being aggressive was why the last version didnt work |
05:59:28 | FromDiscord | <Elegantbeef> You'll have to declare mocked procedures before any code anyway |
05:59:34 | FromDiscord | <Prestige> Idk what was the issue previously that made it not work |
05:59:42 | FromDiscord | <Prestige> Yeah I mean that part is fine |
05:59:52 | FromDiscord | <Prestige> but I want the mocked procs to be inside the test file |
05:59:57 | FromDiscord | <Elegantbeef> It was aggressively grabbing all procedures as such made it invalid |
06:00:06 | FromDiscord | <Elegantbeef> Well you cannot do that |
06:00:35 | FromDiscord | <Elegantbeef> There is another way to do this mocking but it's a very messy one |
06:00:51 | FromDiscord | <Elegantbeef> It's also not automatic |
06:01:49 | FromDiscord | <Elegantbeef> You'd have a `mock:` block syntax which would propagate down all the calls looking for any usage that matches your symbol `genString` in this case and emit a new procedure which calls your internally mocked procedure |
06:02:21 | FromDiscord | <Elegantbeef> so something like `mock(doThing = myOtherProc, genString = proc(): string = "Hello")` |
06:03:03 | FromDiscord | <Prestige> So why can't we just do like `mock(someProc, myMockProc)` and have it change the body of `someProc` ? |
06:03:23 | FromDiscord | <Prestige> or just replace it entirely, whichever would be easier |
06:03:41 | FromDiscord | <Elegantbeef> Cause you want it to not require annotation |
06:03:55 | FromDiscord | <Elegantbeef> You cannot use TRM to capture proc definitions |
06:04:52 | FromDiscord | <Elegantbeef> Unless you fight the pattern matching syntax to figure out how to capture a proc def, i can only say you can certainly capture calls |
06:05:43 | FromDiscord | <Prestige> Could we capture all calls to `someProc` and change it to calls to `myMockProc`? |
06:05:57 | FromDiscord | <Elegantbeef> That's literally what we're doing |
06:06:18 | FromDiscord | <Prestige> Why does that require a whole other file? |
06:06:50 | FromDiscord | <Elegantbeef> cause you have to have the mock proc and patter matching declared before the proc you're attempting to replace |
06:07:07 | FromDiscord | <Elegantbeef> You know how Nim compiles files top to bottom in import order, that matters |
06:07:16 | FromDiscord | <Prestige> damn that sucks |
06:07:32 | FromDiscord | <Prestige> wait |
06:07:49 | FromDiscord | <Prestige> Could we just declare the mock proc at the top of the test file before the imports, then? |
06:08:04 | FromDiscord | <Elegantbeef> No cause you need to import the TRM macro |
06:08:38 | FromDiscord | <Prestige> Couldn't we import the macro, declare mock procs, then import everything else? |
06:08:45 | FromDiscord | <Elegantbeef> No |
06:08:49 | FromDiscord | <Prestige> D: |
06:08:59 | FromDiscord | <Elegantbeef> the TRM needs imported in every file you want it to activate in |
06:09:06 | FromDiscord | <Elegantbeef> Which is why we use `--import:mockprocs` |
06:09:26 | FromDiscord | <Elegantbeef> TRMs are not magic they abide by importing/exporting |
06:09:47 | FromDiscord | <Elegantbeef> The only way you can get away without another file is to use the call approach where you make new procedures |
06:09:47 | FromDiscord | <Prestige> I don't see what the problem is |
06:10:15 | FromDiscord | <Prestige> like if we have the TRM imported and our mock procs declared before importing the other code |
06:10:23 | FromDiscord | <Elegantbeef> the TRM needs to have the variable you're going to call inside of it |
06:10:53 | FromDiscord | <Prestige> by that variable you mean the name of the actual proc we're trying to mock? |
06:11:06 | FromDiscord | <Elegantbeef> No the name of the variable we want to replace |
06:11:13 | FromDiscord | <Elegantbeef> I mean the one we want to call |
06:11:17 | FromDiscord | <Elegantbeef> so in our case `doThingMock` |
06:11:29 | FromDiscord | <Elegantbeef> We need to have that declared before the TRM so it can call it |
06:11:44 | FromDiscord | <Elegantbeef> But if we import the TRM file it cannot know it exists |
06:11:53 | FromDiscord | <Prestige> And all of this would still be an issue even if we could match on proc definitions? |
06:12:26 | FromDiscord | <Elegantbeef> Well order will always matter you'd need to declare the mocks before importing even without the TRM |
06:12:34 | FromDiscord | <Elegantbeef> I mean even if the TRM matched procdefs |
06:12:57 | FromDiscord | <Prestige> that's really unfortunate eh |
06:13:07 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/LEb |
06:15:10 | FromDiscord | <Prestige> I have a question about an overkill solution. What if we had `mocker` create a mock for every proc, then (even at runtime) we could sub out the internal proc it would call? Could do like a Table where you could look up "strgen.genString" or something |
06:15:59 | FromDiscord | <Elegantbeef> I dont follow |
06:16:14 | FromDiscord | <Elegantbeef> You cannot replace all procs as it really fucks with the AST |
06:16:22 | FromDiscord | <Elegantbeef> So how do you plan on injecting these clals? |
06:16:22 | FromDiscord | <Elegantbeef> calls even |
06:16:57 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=40Dy |
06:21:34 | FromDiscord | <Prestige> Yeah that'd work |
06:21:54 | FromDiscord | <Elegantbeef> Have fun recursing over all AST and replace the calls ๐ |
06:21:56 | FromDiscord | <Prestige> I was thinking we'd just delete the body of `genString` and swap it with the body of a provided proc |
06:22:05 | FromDiscord | <Elegantbeef> You cant |
06:24:51 | FromDiscord | <Prestige> This is why I was saying I think this feature would require compiler changes |
06:27:20 | FromDiscord | <Elegantbeef> Well the top level way was easy to do ๐ https://play.nim-lang.org/#ix=40Dz |
06:27:55 | FromDiscord | <Elegantbeef> But the fun part is the recursion through each call to find if there is a usage of `doThing` and if so replace all the procs up to that point with new ones |
06:28:45 | FromDiscord | <Elegantbeef> It should be doable but it's not going to be fun ๐ |
06:31:29 | FromDiscord | <Elegantbeef> Even with compiler support it'd be best to be forced to declare them before imports |
06:31:38 | FromDiscord | <Elegantbeef> It just makes the code and reasoning easier |
06:33:09 | FromDiscord | <Elegantbeef> Cause it means that you have to do the emitted mocked procedures after you sem the code instead of before |
06:35:03 | FromDiscord | <Elegantbeef> I guess you could make it so mock replaces the AST of the proc you're mocking to be a symbol of the new proc and let the transformation pass remove that, so it might not be too bad |
06:35:40 | FromDiscord | <Elegantbeef> Make an RFC if you want it badly enough, the implementation isnt too difficult now that I'm thinking about it, it'd be 1\:1 with borrowing logic |
06:39:08 | FromDiscord | <Prestige> I'm not even sure what you're talking about tbh, I don't know much about the compiler |
06:39:27 | FromDiscord | <Elegantbeef> Eh i'm mostly just talking out loud |
06:39:46 | FromDiscord | <Elegantbeef> Basically the way borrowing works is it emits a new procedure where the body is just the symbol of the original proc |
06:40:20 | FromDiscord | <Elegantbeef> You could abuse the same mechanism where if you compile with `-d:nimMock` and do `mock(doThing, myOtherProc)` it places `myOtherProc`'s symbol into `doThing`'s body |
06:40:34 | FromDiscord | <Prestige> ah |
06:40:53 | FromDiscord | <Elegantbeef> Then in theory no extra compiler work would be needed and transf/codegen would handle it |
06:41:58 | FromDiscord | <Elegantbeef> Atleast i think that might work, but i dont know i'm just a numpty |
06:42:14 | FromDiscord | <Prestige> maybe we could ask in #internals |
06:42:40 | FromDiscord | <Elegantbeef> The royal we i take it |
06:42:51 | FromDiscord | <Prestige> Yeah |
06:43:03 | FromDiscord | <Prestige> Well |
06:43:07 | FromDiscord | <Prestige> Since I can't articulate what you're talking about |
06:43:15 | FromDiscord | <Elegantbeef> If i wanted to see if it'd work i'd just.... you know write the code |
06:43:53 | FromDiscord | <Elegantbeef> I mean you could ask about mocking in general in there or on the forums, i might be missing something that's clear |
06:44:22 | FromDiscord | <Prestige> Nah I think it'd actually require changing things during the compile step |
06:44:39 | FromDiscord | <Prestige> I could make a high level forum post asking about it, but I'll probably get crickets |
06:44:51 | FromDiscord | <Prestige> Perhaps I'll do it anyway |
06:44:55 | FromDiscord | <Elegantbeef> Why?โต(@Prestige) |
06:45:30 | FromDiscord | <Prestige> We need to change the internals of functions that are being invoked throughout the program |
06:45:38 | FromDiscord | <Prestige> idk how else we'd do that other than at compile time |
06:45:55 | FromDiscord | <Elegantbeef> Oh that's what you meant |
06:46:09 | FromDiscord | <Elegantbeef> You could change it at runtime like i said if you wanted to rewrite the assembly ๐ |
06:46:14 | FromDiscord | <Prestige> hehe |
06:46:40 | FromDiscord | <Elegantbeef> Find all calls of your proc and insert a call to the proc you want |
06:46:44 | FromDiscord | <Elegantbeef> Then carry on ๐ |
06:46:44 | FromDiscord | <Prestige> If I knew how the compiler worked I'd be a lot more helpful in figuring out a solution |
06:47:18 | FromDiscord | <Prestige> that actually wouldn't be too bad expect we'd have to type safety I believe |
06:47:39 | FromDiscord | <Elegantbeef> What? |
06:48:09 | FromDiscord | <Elegantbeef> You can rewrite the assembly to do what ever you want |
06:48:43 | FromDiscord | <Elegantbeef> No clue if you could do it programatically but i know you can do it manually, that is find the calls to your proc and call another proc |
06:49:10 | FromDiscord | <Prestige> I mean like you could end up giving it a proc with a different signature that way, right? |
06:49:42 | FromDiscord | <Elegantbeef> I mean sure but if you could do it programatically not really |
06:59:35 | FromDiscord | <Prestige> https://forum.nim-lang.org/t/9255#60615 |
06:59:48 | FromDiscord | <Prestige> Hopefully I explained it well enough |
07:01:02 | NimEventer | New thread by Prestige: Is it possible to "mock" function calls? (For testing purposes), see https://forum.nim-lang.org/t/9255 |
07:07:17 | * | fallback quit (Ping timeout: 260 seconds) |
07:14:13 | * | gsalazar_ joined #nim |
07:14:14 | * | gsalazar_ quit (Remote host closed the connection) |
07:14:29 | * | gsalazar joined #nim |
07:21:53 | PMunch | @Prestige, can't you just patch in a file with a replaced procedure? |
07:22:12 | FromDiscord | <Elegantbeef> I already suggested that |
07:22:37 | PMunch | Ah, I didn't read the chat, just the forum post :P |
07:22:38 | FromDiscord | <Elegantbeef> He wants it a specific way and if it's not like that he hisses like a cat getting it's tail stepped on |
07:23:32 | FromDiscord | <Prestige> Basically wanted it just like the example |
07:24:53 | FromDiscord | <Prestige> and be able to change it at runtime |
07:24:53 | PMunch | Hmm, so you want to replace an already declared symbol? |
07:25:08 | PMunch | I don't think that's possible in a macro |
07:25:58 | FromDiscord | <Elegantbeef> It's indeed not |
07:26:09 | FromDiscord | <Elegantbeef> I've given a variety of solutions and prestige no likey |
07:26:14 | FromDiscord | <Prestige> Yeah I'd need some way to swap a function pointer or something |
07:26:45 | PMunch | Good luck with that if the C compiler inlines your function :P |
07:26:58 | FromDiscord | <Elegantbeef> `-d:debug` goes brrr ๐ |
07:27:00 | PMunch | I guess you'd want to perform this mock anywhere in your program as well? |
07:27:14 | PMunch | Not just in the module you're running? |
07:28:04 | FromDiscord | <Prestige> I want to be able to mock any function, but only need to use `mock` within the current test file |
07:28:50 | PMunch | But what if you call `mySuperProc` from a module which calls `strgen` behind the scenes, do you want that to be mocked as well? |
07:29:05 | FromDiscord | <Elegantbeef> The answer is yes |
07:29:11 | FromDiscord | <Prestige> Yep |
07:29:45 | PMunch | Then the only option is a modified compiler or a pre-processing tool |
07:30:02 | PMunch | (The pre-processing tool could of course take the shape of a macro) |
07:30:20 | FromDiscord | <Elegantbeef> `mock` should replace the function with a pointer proc and repeated calls should set that |
07:31:06 | PMunch | Replacing functions isn't easy though. I'm trying to think of a clean way of doing it, but nothing really comes to mind |
07:35:46 | FromDiscord | <Elegantbeef> I mean you can recursively look for a call and insert your pointer proc's symbol |
07:35:51 | FromDiscord | <Elegantbeef> But it's really complicated |
07:40:58 | * | PMunch quit (Remote host closed the connection) |
07:41:17 | * | PMunch joined #nim |
07:42:48 | FromDiscord | <j-james> can i initialize a Table from two arrays without a for loop? |
07:47:40 | FromDiscord | <Elegantbeef> Dont think so |
07:49:55 | PMunch | Well, this obviously uses loops under the hood, but your code doesn't have to: https://play.nim-lang.org/#ix=40DP |
07:50:29 | FromDiscord | <Elegantbeef> Jeez i hate it |
07:50:37 | FromDiscord | <Elegantbeef> A whole new sequence ๐ |
07:51:35 | PMunch | Haha, I didn't say it was great, only that it didn't have for loops :P |
07:53:55 | FromDiscord | <j-james> oh, that's not too bad, thanks |
07:54:33 | * | ltriant quit (Ping timeout: 248 seconds) |
07:55:02 | FromDiscord | <j-james> weird that there's not a `initTable` that takes two openarrays in std/tables |
07:55:20 | FromDiscord | <j-james> maybe i've just got an unusual use case |
09:12:30 | * | jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in) |
09:18:56 | FromDiscord | <that_dude> In reply to @Avahe "and be able to": Just a very basic skim of what you were talking about and I saw change at run time. What about something like this that I made when I wanted something simmilar? https://github.com/Nmerryman/simple_inject |
09:19:22 | FromDiscord | <that_dude> Not sure if this is seperated enough for you though |
09:20:28 | FromDiscord | <that_dude> The point of this project was that you could mark procs, and in doing so inject some runtime checks to inject custom code before, after, and also choose if you want the called proc to even run |
09:21:28 | FromDiscord | <that_dude> The caveat is that you would need to mark procs with a pragma in the source |
09:21:44 | FromDiscord | <Elegantbeef> Yea that's not what he wants |
09:22:11 | FromDiscord | <that_dude> Kinda figured ๐ |
09:23:35 | FromDiscord | <Rika> I really canโt imagine another way other than the patch file one or the custom compiler addition |
09:47:26 | PMunch | Hmm, if someone is bored and wants to play around with generating a UI/graph I'd really like a program that takes the output from `du -h` and generates a nice pie-chart or something |
09:51:47 | FromDiscord | <Olfactory Hallucinations> @PMunch There's a program that comes with KDE plasma called "Filelight" that does that |
09:52:04 | FromDiscord | <Olfactory Hallucinations> https://apps.kde.org/filelight/ |
09:52:16 | FromDiscord | <Prestige> That's awesome |
09:52:40 | PMunch | Does it take the input from `du -h`? |
09:53:03 | PMunch | Because I already use Baobab which does the graphical part |
09:54:10 | FromDiscord | <Olfactory Hallucinations> not sure. I usually start it from the Dolphin file manager |
09:54:22 | PMunch | https://wiki.gnome.org/action/show/Apps/DiskUsageAnalyzer?action=show&redirect=Apps%2FBaobab |
09:54:26 | PMunch | That's what I use now |
09:55:28 | FromDiscord | <Olfactory Hallucinations> It doesn't seem like it does. You can start it from the command line and give it a directory as an argument |
09:57:27 | NimEventer | New thread by Jasonfi: Any way to determine the GC at runtime?, see https://forum.nim-lang.org/t/9256 |
09:58:06 | FromDiscord | <Prestige> Baobab looks nice too |
09:58:23 | FromDiscord | <Prestige> What is that missing that you want PMunch? |
10:01:21 | PMunch | The ability to build it's display from the output of du -h |
10:01:35 | PMunch | its* |
10:02:30 | FromDiscord | <Olfactory Hallucinations> In reply to @ripluke "Trying to use zig": Did you figure out how to use the Zig compiler? If not, have you tried wrapping it in a bash script as described here? https://forum.nim-lang.org/t/6362#39232 |
10:26:04 | FromDiscord | <jmgomez> can you forward declare in nim, right? |
10:26:15 | FromDiscord | <jmgomez> cant find the way to do it online |
10:26:22 | FromDiscord | <Prestige> Yeah |
10:26:34 | FromDiscord | <Prestige> https://nim-lang.org/docs/tut1.html#procedures-forward-declarations |
10:27:23 | FromDiscord | <jmgomez> ohh, that's nice so for a type it would just be type MyType? |
10:31:16 | FromDiscord | <jmgomez> sent a code paste, see https://play.nim-lang.org/#ix=40E4 |
10:34:27 | FromDiscord | <Rika> You canโt forward declare a type, I donโt get it |
10:34:48 | FromDiscord | <Rika> If you want to cyclically refer to a type then they must be in the same type block |
10:35:37 | FromDiscord | <jmgomez> really? even if it's a pointer type? |
10:36:40 | Amun-Ra | even, if that's a pointer to unknown type |
10:37:06 | FromDiscord | <ripluke> In reply to @Olfactory Hallucinations "Did you figure out": I did |
10:37:44 | FromDiscord | <jmgomez> okay, that's a bit unfortunate |
10:39:03 | Amun-Ra | in the example above it's just an (yet) unknown type, that just happens to be a ptr |
10:42:27 | FromDiscord | <jmgomez> is there any other syntax or is it just a nim limitation? |
10:44:35 | Amun-Ra | the only way is to have all the cyclically referred types in the same type block and it has to be defined before the use |
10:45:26 | Amun-Ra | you can have a plain pointer type (equivalent of void* ) and do the cast, but that sucks |
10:47:35 | FromDiscord | <jmgomez> okay, thanks |
10:55:38 | NimEventer | New thread by Jasonfi: Example code with multithreading and channels is failing, see https://forum.nim-lang.org/t/9257 |
11:15:58 | FromDiscord | <Prestige> Elegantbeef did you see https://forum.nim-lang.org/t/9255#60617 ? Lol |
11:16:00 | FromDiscord | <Prestige> Pretty cool |
11:18:20 | FromDiscord | <Rika> Cool but holy shit please do not use it |
11:18:49 | FromDiscord | <Prestige> yep lma |
11:18:50 | FromDiscord | <Prestige> (edit) "lma" => "lmao" |
11:19:12 | FromDiscord | <Rika> Instead of mocking code what about mocking the API you call? Usually you use mocking because whatever youโre calling takes time or costs money, usually from external APIs |
11:19:53 | FromDiscord | <Rika> Unfortunately this doesnโt help if youโre mocking a high CPU function instead of a blocking/slow IO function |
11:20:10 | FromDiscord | <Prestige> sorta same problem I think |
11:20:23 | FromDiscord | <Prestige> I partially want this so I can mock xlib for testing |
12:03:43 | FromDiscord | <vindaar> I just put it here https://github.com/Vindaar/hotpatching ๐
โต(@Prestige) |
12:11:46 | NimEventer | New question by Alex Gustafson: enums in nim for wrapper of c library, see https://stackoverflow.com/questions/72715226/enums-in-nim-for-wrapper-of-c-library |
12:13:41 | FromDiscord | <AlexG> Hi, I am trying to put write a nim wrapper for CLAP ( clever audio plugin library ). I am having trouble getting enums working right. CLAP is using ... oh wow, I just notice my Stack Overflow issue was just posted above. |
12:15:20 | FromDiscord | <AlexG> I wanted to write a forum post but having trouble verifiying my email:โตโตIf anyone could look at my stackoverflow issue above and give me a tip, that would be a great help. I will be releasing the wrapper once I have some minimal functionality working. |
12:24:59 | FromDiscord | <Prestige> vindaar: That's really cool haha |
12:25:19 | FromDiscord | <vindaar> sent a code paste, see https://play.nim-lang.org/#ix=40Ep |
12:25:55 | FromDiscord | <vindaar> (`ord` gives you the ordinal value associated with that enum entry) |
12:29:39 | FromDiscord | <AlexG> Yes! that worked. Thanks @Vindaar . |
12:47:53 | * | Jjp137 quit (Ping timeout: 255 seconds) |
12:53:48 | FromDiscord | <luteva> Hi! I would like to continously read a (log) file (in which, lines are added while running). Best would be to start at current end. Just as "tail -f". Is there anything in (the std lib of) nim, i could use? |
13:06:52 | FromDiscord | <Prestige> Maybe you could use streams, setPosition to the end of the file, then read it line by line? |
13:10:00 | * | xet7 joined #nim |
13:11:38 | * | wallabra quit (Ping timeout: 240 seconds) |
13:19:20 | * | arkurious joined #nim |
13:19:33 | FromDiscord | <luteva> yes that would probably the "DIY" solution ๐โตand... yes.... as that's not quite complicated, why not just do it this way... ๐ |
13:19:45 | FromDiscord | <luteva> (edit) "yes that would probably ... the" added "be" |
13:24:09 | FromDiscord | <Rika> In reply to @Avahe "Maybe you could use": Youโre gonna have to figure out the index of the end of the file then no? |
13:25:31 | FromDiscord | <enthus1ast> the end of the stream would be the current file size i guess |
13:28:36 | * | toluene joined #nim |
14:13:52 | FromDiscord | <๐๐ง br4n_d0n> In a very basic example, when would you use a `` let `` over a `` const `` ? |
14:16:12 | FromDiscord | <!Patitotective> In reply to @br4n_d0n "In a very basic": when the value cannot be evaluated at compile-time lol |
14:19:25 | FromDiscord | <๐๐ง br4n_d0n> Seems strange that in the instances where a `` const `` cannot be evaluated at compile time should default to the `` let `` functionality eliminating the need for `` let `` |
14:20:12 | FromDiscord | <konsumlamm> well, they have different semantics, so it makes sense to separate them |
14:20:23 | FromDiscord | <Rika> And if you want to force something that evaluates in compile time to be evaluated at run time? |
14:20:25 | FromDiscord | <๐๐ง br4n_d0n> OMG, I cannot even write coherent messages... I give up |
14:20:48 | FromDiscord | <konsumlamm> sometimes you may not want to evaluate soemthing at compile-time, even if you could, because it would increase the compilation time |
14:21:23 | FromDiscord | <๐๐ง br4n_d0n> In reply to @konsumlamm "sometimes you may not": Never thought about compile times |
14:21:26 | FromDiscord | <konsumlamm> you can also do IO (e.g. print something) at compile time, but you don't necessarily want that |
14:21:44 | FromDiscord | <konsumlamm> because what the resulting program would do would be very different |
14:22:15 | FromDiscord | <!Patitotective> `let variable {.compileTime.} = 1` lol |
14:43:49 | FromDiscord | <demotomohiro> Some macros/templates/procs/etc requires compile time value. If `const` was automatically converted to `let`, how can we safely pass `const` to them? |
14:49:45 | FromDiscord | <๐๐ง br4n_d0n> I'm not saying all `` const `` values would be converted, but only those that the compiler was unable to determine at compile time. Kind of moot though as others have chimed in trying to give examples as to when this would not be desired |
14:56:35 | * | Jjp137 joined #nim |
15:02:18 | FromDiscord | <luteva> nim is kind of "strict" on that. Meaning when you (as a dev) say you want that to be evaluated at compile time, this has to be done at compile time! When this is not possible, it is an error. So you really always know, that a const is being evaluated at compiletime. There's no "hidden magic" which makes you think it is evaluated at compile time, while in reality it is not! |
15:05:08 | FromDiscord | <luteva> like in c++ (or rust) a const expression is not (always) evaluated at compiletime. It is _maybe_ evaluated at compile time, but you never know! This is a bad idea (imo)! |
15:06:20 | FromDiscord | <luteva> letting the dev know what's happening is the way to go (imho). |
15:09:21 | FromDiscord | <exelotl> {.compileTime.} vars being accessible at runtime is still crazy to me lol |
15:09:45 | FromDiscord | <exelotl> not sure if that feature is any more stable now but it was completely busted when I tried it a couple years ago ๐
|
15:15:08 | FromDiscord | <luteva> so you may choose let when you are not sure if it could be evaluated at compile time but use const when you want to force compiletime evaluation.โตYou can also try const and see which part is not possible at compiletime. maybe you can use a compile time expression instead of a runtime expression and make it a const?!? Like "if" -> runtime; "when" -> compiletime |
15:57:04 | * | LuxuryMode quit (Quit: Connection closed for inactivity) |
16:00:01 | FromDiscord | <demotomohiro> In reply to @luteva "nim is kind of": `const` in C++ is similar to `let` in Nim and `constexpr` in C++ is similar to `const` in Nim. |
16:09:48 | FromDiscord | <demotomohiro> When an expression can be evaluated at compile, it is usually evaluated at compile time. So when you write `var a = 1 + 2 + 3`, `1 + 2 + 3` expression is calculated at compile time. Why do you still needs `const` that can also takes runtime value? |
16:10:35 | FromDiscord | <Rika> i dont recall expressions like that being evaluated at ct in nim |
16:11:41 | FromDiscord | <๐๐ง br4n_d0n> Anyone know of an easy way to search the source files on github for a particular string? |
16:12:24 | FromDiscord | <Rika> clone then grep, github search is always fuzzy i believe |
16:12:37 | FromDiscord | <Rika> maybe try quotes around the term |
16:12:40 | FromDiscord | <Rika> but i dont think thatll work |
16:12:42 | FromDiscord | <Rika> might tho |
16:13:02 | FromDiscord | <๐๐ง br4n_d0n> I'll give it a shot |
16:13:51 | FromDiscord | <๐๐ง br4n_d0n> No shit it worked |
16:14:02 | FromDiscord | <Rika> damn thats good |
16:14:27 | FromDiscord | <๐๐ง br4n_d0n> Thanks for the suggestion, this is super helpful |
16:14:41 | FromDiscord | <!Patitotective> github search has a cheat sheet |
16:34:25 | * | fallback joined #nim |
17:14:41 | FromDiscord | <huantian> Or use the closed GitHub search beat |
17:14:44 | FromDiscord | <huantian> Beta |
18:10:21 | * | PMunch quit (Quit: Leaving) |
18:28:10 | FromDiscord | <j-james> cs.github.com is very good |
19:07:00 | * | xet7 quit (Quit: Leaving) |
19:22:19 | * | LuxuryMode joined #nim |
19:48:49 | * | ltriant joined #nim |
19:53:54 | * | ltriant quit (Ping timeout: 276 seconds) |
19:54:11 | * | wallabra joined #nim |
20:05:05 | * | wallabra quit (Quit: ZNC 1.8.2 - https://znc.in) |
20:05:22 | * | wallabra joined #nim |
20:16:23 | FromDiscord | <vestel> How to reopen stdout after `AllocConsole`? |
20:17:18 | FromDiscord | <vestel> Because when using std `open` with FileHandle as argument codegen results with `&stdout` which is a error |
20:26:25 | * | jmdaemon joined #nim |
20:38:00 | NimEventer | New thread by Nepeckman: Threading error: calling procs off objects (httpbeast), see https://forum.nim-lang.org/t/9258 |
20:49:14 | * | smvg joined #nim |
20:51:48 | FromDiscord | <Elegantbeef> I figured it was possible to do, but didnt know the API for it |
20:53:42 | FromDiscord | <Elegantbeef> The fact your `hotpatch` isnt `target, replacement: proc` is silly though |
20:57:00 | FromDiscord | <vindaar> PRs welcome ๐ |
20:58:28 | FromDiscord | <Elegantbeef> No you |
21:14:42 | FromDiscord | <Yardanico> Bot didn't post here for some reason |
21:14:44 | FromDiscord | <Yardanico> New thread by Araq: Mastering Nim: A complete guide to the programming language, see https://forum.nim-lang.org/t/9259 |
21:15:59 | NimEventer | New thread by Araq: Mastering Nim: A complete guide to the programming language, see https://forum.nim-lang.org/t/9259 |
21:19:07 | FromDiscord | <Alea> Interesting to see what the appendix offers vs the existing nimdocs |
21:19:23 | FromDiscord | <Alea> But nice to see that he's making an effort like this |
21:19:48 | * | wallabra_ joined #nim |
21:20:20 | FromDiscord | <Ace Emerald> Really cool! Hope we can get an ebook version at somepoint |
21:21:06 | * | wallabra quit (Ping timeout: 264 seconds) |
21:21:11 | * | wallabra_ is now known as wallabra |
21:24:40 | FromDiscord | <!Patitotective> first programming book without an animal on its cover |
21:26:51 | * | Amun-Ra quit (Ping timeout: 276 seconds) |
21:31:57 | FromDiscord | <luteva> is there a readLine proc in nim that reads the file in reverse order? I mean start: at the end of the file and read it line by line until the start of the file? |
21:32:08 | FromDiscord | <luteva> (edit) "start:" => "start" |
21:32:28 | FromDiscord | <luteva> (edit) "start" => "start/beginning" |
21:33:52 | FromDiscord | <huantian> oh huh new book |
21:36:20 | FromDiscord | <Ace Emerald> In reply to @luteva "is there a readLine": Don't think I've seen anything like that. If the file isn't huge the best bet is probably read it all into a string, split on line end, and iterate using a reverse range |
21:36:46 | FromDiscord | <ynfle> In reply to @luteva "is there a readLine": Are there other languages that offer such a capability? |
21:38:19 | * | Amun-Ra joined #nim |
21:39:24 | FromDiscord | <golova> In reply to @luteva "is there a readLine": I think for that case you should use some API provided by system |
21:39:38 | FromDiscord | <golova> (edit) "In reply to @luteva "is there a readLine": I think for that case you should use some API provided by ... system" added "operating" |
21:51:46 | FromDiscord | <๐๐ง br4n_d0n> Man that's a spicy price of a book |
21:52:09 | FromDiscord | <๐๐ง br4n_d0n> Is this the secret thing that was being worked on? |
21:57:02 | * | smvg quit (Quit: smvg) |
21:57:56 | * | smvg joined #nim |
22:01:55 | FromDiscord | <Elegantbeef> I hope not, cause i cannot read |
22:10:45 | FromDiscord | <!Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=40Gj |
22:11:20 | FromDiscord | <!Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=40Gk |
22:11:47 | FromDiscord | <!Patitotective> `collect(newSeq[int])` doesn't work either |
22:13:29 | FromDiscord | <!Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=40Gm |
22:13:38 | FromDiscord | <!Patitotective> (edit) "https://play.nim-lang.org/#ix=40Gm" => "https://play.nim-lang.org/#ix=40Gn" |
22:14:54 | FromDiscord | <Elegantbeef> `sum toSeq(0..10)` should work but it's dumb to use `toSeq` then sum |
22:16:29 | FromDiscord | <!Patitotective> i can't use `toSeq` because i need `collect` to calculate some more stuff, i guess ill have to set `collect` to a variable before summing it |
22:17:01 | FromDiscord | <Elegantbeef> Or you know just sum it like a normal person |
22:17:24 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/HPM |
22:17:48 | FromDiscord | <!Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=40Gp |
22:17:55 | FromDiscord | <Elegantbeef> I've seen your code i know you arent normal |
22:18:00 | FromDiscord | <!Patitotective> hahah |
22:21:12 | FromDiscord | <Elegantbeef> I mean you made niprefs cause you didnt know yaml or toml existed ๐ |
22:24:22 | FromDiscord | <!Patitotective> In reply to @Elegantbeef "I mean you made": hmmm yes but noโตniprefs does read and save a file that before was using my own format but now uses toml |
22:33:41 | FromDiscord | <retkid> is there anyway to turn a string into an enum |
22:33:46 | FromDiscord | <retkid> of identical spelling |
22:34:00 | FromDiscord | <retkid> or does it have to be a number? |
22:34:08 | FromDiscord | <Phil> Yeh, is possible |
22:34:15 | FromDiscord | <Phil> one sec, copy pasting example from my sideproject |
22:34:19 | FromDiscord | <Elegantbeef> from strutils |
22:34:19 | FromDiscord | <Elegantbeef> `parseEnum[MyEnumType](myString)` |
22:34:37 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=40Gr |
22:35:14 | FromDiscord | <Elegantbeef> Are you honestly doing multiline enum fields with commas? |
22:35:21 | FromDiscord | <Phil> Thus the enum does not have to be a number. As for parsing it, once you've defined your enum this way, you can use parseEnum as beef suggested |
22:35:21 | FromDiscord | <Elegantbeef> Fucking masochist over here |
22:35:43 | FromDiscord | <Elegantbeef> Well when you use parseEnum with the above enum it only parses the string which is tedious |
22:35:43 | FromDiscord | <Phil> I started out doing so since it was a java habit |
22:35:47 | FromDiscord | <Phil> Then I realized its unnecessary |
22:36:05 | FromDiscord | <retkid> In reply to @Elegantbeef "Well when you use": https://media.discordapp.net/attachments/371759389889003532/989297752729059349/unknown.png |
22:36:08 | FromDiscord | <Phil> And somewhere halfway through I dropped the habit, so it's applied very inconsistently |
22:36:24 | FromDiscord | <Elegantbeef> Retkid one day you'll write normal Nim code |
22:36:57 | FromDiscord | <retkid> In reply to @Elegantbeef "Retkid one day you'll": https://media.discordapp.net/attachments/371759389889003532/989297970430214224/unknown.png |
22:37:21 | FromDiscord | <retkid> i write normal nim |
22:37:35 | FromDiscord | <Elegantbeef> I despise that you use lowercase types still |
22:37:40 | FromDiscord | <Elegantbeef> You really dont |
22:39:05 | FromDiscord | <Elegantbeef> Like why do you have an `output` isnt that just `result` |
22:39:13 | FromDiscord | <Elegantbeef> Why are you dereferencing your `output` |
22:39:30 | FromDiscord | <retkid> I had a reason |
22:39:35 | FromDiscord | <retkid> i forget |
22:39:43 | FromDiscord | <Alea> how are Options for speed? I have an object that's going to be used a lot and every field is optionalโตIs there maybe some faster way using `nil` and manual checks? |
22:39:59 | FromDiscord | <Elegantbeef> Options are a single bool check |
22:40:20 | FromDiscord | <golova> In reply to @Elegantbeef "Like why do you": He dereferences a ref type? |
22:40:36 | FromDiscord | <Elegantbeef> Yes but.... you dont need to dereference references to access fields |
22:40:47 | FromDiscord | <retkid> i dont know why i did it ok\ |
22:40:50 | FromDiscord | <Elegantbeef> Nim auto dereferences field access |
22:40:58 | FromDiscord | <retkid> i wanted to instanciate the class with defaults |
22:41:01 | FromDiscord | <retkid> (edit) "instanciate" => "instantiate" |
22:41:19 | FromDiscord | <Elegantbeef> I mean i dont care why you said you write normal nim and you clearly dont |
22:41:20 | FromDiscord | <Elegantbeef> ๐ |
22:41:26 | FromDiscord | <retkid> i didn't comment anything |
22:41:29 | FromDiscord | <retkid> so i dont know what my brain |
22:41:32 | FromDiscord | <retkid> was doing |
22:41:56 | FromDiscord | <Elegantbeef> @Alea\: if concerned about memory like i said you can use a `Sentinel` like so https://play.nim-lang.org/#ix=3YBt |
22:42:07 | FromDiscord | <Elegantbeef> That's if you have a value you really dislike more than the others |
22:42:07 | * | noeontheend joined #nim |
22:42:18 | FromDiscord | <retkid> https://media.discordapp.net/attachments/371759389889003532/989299316260737094/unknown.png |
22:42:19 | FromDiscord | <huantian> you link seems dead |
22:42:20 | FromDiscord | <retkid> NORMAL NI0M |
22:42:33 | FromDiscord | <huantian> why are you calling int so many times |
22:42:34 | FromDiscord | <Elegantbeef> What's a NIOM? |
22:42:44 | FromDiscord | <retkid> nim |
22:42:46 | FromDiscord | <huantian> no it's NI0M not NIOM |
22:42:50 | FromDiscord | <Elegantbeef> My dude just do `start div 10000` |
22:43:11 | FromDiscord | <Elegantbeef> Why `if isMainModule`? |
22:43:15 | FromDiscord | <Elegantbeef> if is runtime checked |
22:43:23 | FromDiscord | <Elegantbeef> That means you're including that in any code that uses that module |
22:43:38 | FromDiscord | <retkid> yes |
22:43:42 | FromDiscord | <Elegantbeef> Why is `output` a `ref seq[Person]`? |
22:43:44 | FromDiscord | <retkid> wait |
22:44:06 | FromDiscord | <Elegantbeef> So much for idiomatic Nim eh? ๐ |
22:44:10 | FromDiscord | <retkid> i dont know |
22:44:19 | FromDiscord | <retkid> i had a reason |
22:44:21 | FromDiscord | <retkid> no comments |
22:44:28 | FromDiscord | <Elegantbeef> `when isMainModule` |
22:44:39 | FromDiscord | <Elegantbeef> It's ok to say "I just didnt know" |
22:44:50 | FromDiscord | <retkid> if i wrote comments |
22:44:54 | FromDiscord | <retkid> i could tell you |
22:44:59 | FromDiscord | <Elegantbeef> Works here |
22:45:09 | FromDiscord | <huantian> ah works on reload |
22:45:11 | FromDiscord | <Phil> In reply to @retkid "if i wrote comments": I wonder what the solution could be |
22:45:32 | FromDiscord | <Elegantbeef> Eitherway probably another addition to my wacky random idea package |
22:45:36 | FromDiscord | <retkid> oh because i wanted to add to it from a function |
22:45:49 | FromDiscord | <retkid> rather than return and add it there |
22:45:56 | FromDiscord | <retkid> because my brain decided thats how the code should look |
22:45:57 | FromDiscord | <Elegantbeef> What? |
22:46:02 | FromDiscord | <huantian> perhaps consider closures |
22:46:09 | FromDiscord | <Elegantbeef> You can pass result to functions |
22:46:28 | FromDiscord | <retkid> yea |
22:46:28 | FromDiscord | <๐๐ง br4n_d0n> In reply to @Elegantbeef "Retkid one day you'll": I'm starting to believe there is no "normal" Nim code and the norm is the chaotic |
22:46:43 | FromDiscord | <Elegantbeef> Nah some people write cleaner code |
22:46:53 | FromDiscord | <retkid> my code is clean but nonsensical |
22:47:00 | FromDiscord | <huantian> you say it's clean |
22:47:02 | FromDiscord | <Elegantbeef> that was a lie |
22:47:08 | FromDiscord | <huantian> and then you name your variables `page` and `pagey` |
22:47:10 | FromDiscord | <Phil> I look at my code |
22:47:13 | FromDiscord | <Phil> It is beautiful |
22:47:20 | FromDiscord | <Phil> Rough edges here and there |
22:47:21 | FromDiscord | <Elegantbeef> Lol phil i've seen your code |
22:47:22 | FromDiscord | <retkid> In reply to @huantian "and then you name": THIS IS A PROGRAMMER TRADITIOBN |
22:47:23 | FromDiscord | <Phil> But still beautiful |
22:47:32 | FromDiscord | <retkid> Phil I've seen your code |
22:47:35 | FromDiscord | <retkid> idk what the fuck is happening |
22:47:52 | FromDiscord | <retkid> in my code, you'll have questions, but at least you know whats happening |
22:48:03 | FromDiscord | <Elegantbeef> I really dont |
22:48:08 | FromDiscord | <retkid> well i do |
22:48:11 | FromDiscord | <retkid> sometimes |
22:48:26 | FromDiscord | <Elegantbeef> You said like 5 times "i dont know why i did X" |
22:48:41 | FromDiscord | <retkid> yea, i have questions |
22:48:47 | FromDiscord | <retkid> but i know what is happening |
22:48:48 | FromDiscord | <Phil> In reply to @retkid "idk what the fuck": I mean, I believe the times you saw was when I was building out my generic controllers, there is literally no way to make that simple |
22:49:05 | FromDiscord | <Phil> For what it does, the overall structure is decently simple |
22:49:59 | * | wallabra quit (Ping timeout: 255 seconds) |
22:50:26 | FromDiscord | <Elegantbeef> I accept my code is shit! I dont lie to myself |
22:50:46 | FromDiscord | <๐๐ง br4n_d0n> sent a code paste, see https://play.nim-lang.org/#ix=40Gt |
22:51:06 | FromDiscord | <Phil> In reply to @Elegantbeef "I accept my code": I just look at code written by colleagues ~~or my past self from 1 year ago~~ and my current code looks immediately beautiful |
22:51:08 | FromDiscord | <Elegantbeef> Is it really too hard to do `1f`? |
22:51:27 | FromDiscord | <๐๐ง br4n_d0n> It's the principle at this point |
22:51:38 | FromDiscord | <๐๐ง br4n_d0n> I'm going to beat this fucking code |
22:51:39 | FromDiscord | <๐๐ง br4n_d0n> llol |
22:52:09 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/989301796583403541/image.png |
22:52:11 | FromDiscord | <Elegantbeef> Cmon phil it's totally clean! |
22:52:12 | FromDiscord | <Alea> sent a code paste, see https://play.nim-lang.org/#ix=40Gu |
22:52:55 | FromDiscord | <Elegantbeef> What's the difference and secondly you know procs exist? |
22:54:06 | FromDiscord | <Phil> In reply to @Elegantbeef "image.png": I like the first proc. โตThe second one lacks some contextual hints as to what's being skipped |
22:54:26 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=40Gv |
22:54:38 | FromDiscord | <Elegantbeef> The proc is named `rewind` |
22:54:52 | FromDiscord | <Phil> So you skip the rewinding? |
22:54:54 | FromDiscord | <Elegantbeef> Cmon phil you can figure out what's being rewound in a game with a single rewind mechanic |
22:55:23 | FromDiscord | <Elegantbeef> `world.history.high` might indicate we're rewinding history |
22:55:46 | FromDiscord | <Phil> So while rewinding you might skip a history step? |
22:55:52 | FromDiscord | <Elegantbeef> Yes |
22:56:07 | FromDiscord | <Elegantbeef> Cause sometimes you're standing on the step you'd want to skip and would not move |
22:56:22 | FromDiscord | <Elegantbeef> But you want to skip that in cases like when the player hits the "undo" button |
22:56:57 | FromDiscord | <Elegantbeef> Alea really what's the difference i'm blind |
22:57:22 | FromDiscord | <Elegantbeef> oh alea it's `notin` |
22:57:34 | FromDiscord | <Elegantbeef> `not in` is two operators |
22:57:58 | FromDiscord | <Elegantbeef> But please for everyone's sanity use a proc for this |
22:59:10 | FromDiscord | <Alea> The constructor is a better idea yes |
22:59:44 | FromDiscord | <Alea> what's going on with the proc args though? Don't know _, typedesc, and whether or not selectedElem needs a type |
23:00:11 | FromDiscord | <Phil> "_" just means "The value of this element doesn't matter |
23:00:17 | FromDiscord | <Elegantbeef> It needs a type i didnt know it |
23:00:17 | FromDiscord | <Elegantbeef> `_: typedesc` means you do `Cell.init(selectedElem)` |
23:00:31 | FromDiscord | <Phil> typedesc means that "_" will be a type |
23:00:34 | FromDiscord | <Alea> gotcha |
23:00:56 | FromDiscord | <Phil> (edit) "type" => "type, as in `type A = object` throwing in that A, not an object instantiated from A" |
23:02:38 | * | noeontheend quit (Ping timeout: 240 seconds) |
23:03:10 | * | smvg quit (Quit: smvg) |
23:03:29 | * | ltriant joined #nim |
23:03:49 | FromDiscord | <treeform> Any one know of an example which imports the nim compiler and parses nim code string and returns some thing like AST node tree from a macro? |
23:03:51 | FromDiscord | <Elegantbeef> Alea regrets asking for help ๐ |
23:04:40 | FromDiscord | <Elegantbeef> I have an example that uses the NimVM to do something similar, though doesnt return AST returns a stringified version of the AST |
23:05:00 | FromDiscord | <Elegantbeef> Think you could make it return PNodes though.... hmmm |
23:05:02 | FromDiscord | <treeform> that would be a start, can I see it? |
23:05:33 | FromDiscord | <Elegantbeef> https://github.com/beef331/nimscripter/tree/master/examples/macrorepl |
23:06:56 | FromDiscord | <Elegantbeef> https://streamable.com/c6farb is what it does |
23:07:32 | FromDiscord | <Elegantbeef> Basically you can live edit macros and it'll print the AST/Code directly to the terminal depending on your settings |
23:09:21 | FromDiscord | <treeform> that's cool |
23:09:50 | FromDiscord | <treeform> Hmm I think the lib you use "assume-0.4.0" does not support windows ๐ฆ |
23:10:07 | FromDiscord | <treeform> `termios.h: No such file or directory` |
23:10:09 | * | noeontheend joined #nim |
23:12:04 | * | LuxuryMode quit (Quit: Connection closed for inactivity) |
23:12:27 | FromDiscord | <Alea> In reply to @Elegantbeef "*Alea regrets asking for": no, never! Nim makes it a little easy to forget best practice since things tend to work no matter how shitty they actually are. ya'll are a good reminder ๐ |
23:12:27 | FromDiscord | <Elegantbeef> Assume is just a macro library |
23:13:28 | FromDiscord | <Elegantbeef> Linenoise is probably the culprit |
23:14:21 | FromDiscord | <Elegantbeef> Or my usage of the `terminal` lib |
23:15:44 | FromDiscord | <Alea> hmm https://media.discordapp.net/attachments/371759389889003532/989307731028611082/unknown.png |
23:16:02 | FromDiscord | <Elegantbeef> `typedesc[Cell]` |
23:16:09 | FromDiscord | <Elegantbeef> `_: Cell` expects an instance of Cell |
23:16:34 | FromDiscord | <Alea> ๐ |
23:27:45 | FromDiscord | <Alea> sent a code paste, see https://play.nim-lang.org/#ix=40Gy |
23:28:27 | FromDiscord | <Elegantbeef> should be `when T is Cell` |
23:29:10 | FromDiscord | <Elegantbeef> Dont really get why it's `initOrUpdate` |
23:29:14 | FromDiscord | <Elegantbeef> Seems like it's just a constructor |
23:29:46 | FromDiscord | <Alea> yeah, I had a bright & lazy idea, but it's not actually what I want in retrospect |
23:30:39 | FromDiscord | <luteva> i think i have seen some tools for building TUIs in nim. can anyone point me to the right direction? |
23:31:40 | FromDiscord | <Elegantbeef> illwill |
23:31:47 | FromDiscord | <Elegantbeef> nimwave |
23:32:37 | FromDiscord | <Alea> truly stupid idea nowโตcan I store the names of object members for use at compile time?โตLike let mems = [memA, memB] -> object.mems[1] |
23:33:15 | FromDiscord | <Elegantbeef> `for name, _ in obj.fieldPairs:` |
23:34:10 | FromDiscord | <Alea> IncredibleโตI'm sure this is a valid replacement for good software design ๐ |
23:36:37 | FromDiscord | <Elegantbeef> I mean good software does everything it can before it has to run |
23:51:18 | * | noeontheend quit (Ping timeout: 240 seconds) |
23:52:21 | FromDiscord | <๐๐ง br4n_d0n> @Alea FYI, you can add ``nim `` right after the 3 backticks to get color coding |