<< 22-06-2022 >>

00:02:29*jmdaemon joined #nim
00:04:33*nmz joined #nim
00:34:41FromDiscord<!Patitotective> is there a way to wrap cpp libraries to nim?
00:38:45FromDiscord<Elegantbeef> You use dear-imgui and you're asking this?
00:39:13FromDiscord<!Patitotective> nimgl/imgui is a wrapper for cimgui not the actual cpp library
00:39:27FromDiscord<Elegantbeef> If you usue the cpp backend it uses dearimgui directly
00:40:35FromDiscord<Elegantbeef> Ah sorry it uses cimgui but it uses the CPP code directly
00:40:41FromDiscord<Elegantbeef> https://github.com/nimgl/nimgl/blob/master/src/nimgl/imgui.nim#L42-L48
00:40:42FromDiscord<!Patitotective> and there isnt any futhark for cpp, right? i need to manually `importCpp`
00:40:58FromDiscord<Elegantbeef> You can use c2nim a bit but yes you need to manually convert most of it
00:41:55FromDiscord<jan0809> so nim habe different build backends right(?)
00:42:03FromDiscord<jan0809> (edit) "habe" => "have"
00:42:13FromDiscord<Elegantbeef> Yes it has different backends
00:43:06FromDiscord<jan0809> how to change them
00:43:34FromDiscord<Elegantbeef> `nim cpp` or `nim js` to compile to c++ and js respectively
00:43:54FromDiscord<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:10FromDiscord<jan0809> is there a beneifit in building cpp?
00:44:15FromDiscord<!Patitotective> iirc there is also `nim cc` that actually means c, right?
00:44:17FromDiscord<Elegantbeef> You can do C++ interop
00:44:33FromDiscord<jan0809> hmm
00:44:48FromDiscord<Elegantbeef> Nim and D are like the only languages that can do C++ interop
00:45:10FromDiscord<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:11FromDiscord<jan0809> i c
00:45:43FromDiscord<jan0809> but what about python? it have quite some cpp based libs
00:45:48FromDiscord<๐Ÿ’๐Ÿง br4n_d0n> My word, this nim compiler code SERIOUSLY needs some decent commenting. I'm struggling to follow
00:45:54FromDiscord<jan0809> but thats something diff i assume
00:46:12FromDiscord<Elegantbeef> Python is going to interop to C++ libraries using the C api
00:46:33FromDiscord<!Patitotective> In reply to @br4n_d0n "My word, this nim": PRs welcome haha
00:46:53FromDiscord<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:27FromDiscord<๐Ÿ’๐Ÿง br4n_d0n> In reply to @Patitotective "PRs welcome haha": If I knew what was going on, I would
00:48:02FromDiscord<Elegantbeef> The way you learn is just to keep at it attempting to do whatever you're doing
00:48:11FromDiscord<Elegantbeef> Eventually you'll learn how to reason what's going on
00:48:19FromDiscord<Elegantbeef> It's a shitty thing to have to do but it's how it's written
00:48:26FromDiscord<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:53FromDiscord<Elegantbeef> I was just explaining what that C++ interop gives you
00:50:48FromDiscord<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:02FromDiscord<Elegantbeef> Ok?
00:51:21FromDiscord<jan0809> jokes aside, would that mean that i could just import lets say opencv and use it?
00:51:38FromDiscord<jan0809> but i saw theres a wrapper too
00:51:38FromDiscord<Elegantbeef> "just import" is a bit of an understatement
00:51:44FromDiscord<Elegantbeef> Nim and C++ have different language semantics
00:51:52FromDiscord<Elegantbeef> So you have to wrap the C++ into Nim
00:52:03FromDiscord<Elegantbeef> But yes you can import code written in C++ and use it
00:52:26FromDiscord<Elegantbeef> Generally though most people just wrap C APIs as it's simpler
00:52:54FromDiscord<jan0809> but when i use the cpp backend, will stuff like nimpy stop working?
00:53:01FromDiscord<Elegantbeef> No
00:53:17FromDiscord<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:03FromDiscord<Elegantbeef> The only real difference between backends is the C++ one gives you the abillity to use C++ interop
00:54:10FromDiscord<Elegantbeef> Other than that they should behave identically for the same input
00:54:59FromDiscord<jan0809> and no notable performance differences (assuming the same input)
00:55:30FromDiscord<Elegantbeef> Should be similar
00:55:44FromDiscord<Elegantbeef> Main difference would be what C/C++ compiler you usued
00:55:56FromDiscord<jan0809> can i use zig?
00:56:15FromDiscord<Elegantbeef> Yes
00:56:17FromDiscord<Elegantbeef> It's not as simple as other C compilers but you can use zig's C compiler
00:56:41FromDiscord<Elegantbeef> There isnt much benefit vs. just using clang but you can if you want
00:57:13FromDiscord<jan0809> besides crosscompiling(?) if thats a thing in that case
00:57:29FromDiscord<Elegantbeef> zigcc is basically clang
00:58:24FromDiscord<Elegantbeef> So aside from cross compiling yea it's pretty much identical
01:05:50FromDiscord<๐Ÿ’๐Ÿง br4n_d0n> "Gotta go fast!" is on hold this week because Andrew is getting married Saturday
01:21:47FromDiscord<๐Ÿ’๐Ÿง br4n_d0n> What's with the skull emoji?
01:22:49FromDiscord<!Patitotective> marriage ๐Ÿ’€
01:24:31FromDiscord<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:35FromDiscord<Elegantbeef> Might depend on your terminal emulator
01:40:33FromDiscord<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:42FromDiscord<j-james> what is the reason behind the `-d:ssl` flag?
03:27:12FromDiscord<Elegantbeef> openssl is used for SSL
03:27:35FromDiscord<Elegantbeef> If you dont need/want openssl you dont need to ship it
03:27:53FromDiscord<Elegantbeef> Bearssl or similar would be a nice replacement
03:27:55FromDiscord<j-james> just because it's a big dependency, then?
03:28:10FromDiscord<Elegantbeef> Also probably the license but idk
03:30:13FromDiscord<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:44FromDiscord<j-james> i hadn't heard of bearssl until recently
03:30:58FromDiscord<j-james> curious how it differs from libressl/boringssl
03:31:08FromDiscord<j-james> i guess not being based on openssl is a big change
03:32:14FromDiscord<j-james> In reply to @Elegantbeef "The benefit of bearssl": interesting ic
03:32:29FromDiscord<Elegantbeef> Status uses bearssl afaik
03:41:24*rockcavera quit (Remote host closed the connection)
03:42:35FromDiscord<Elegantbeef> Also that benefit is indirectly smaller binary sizes if you didnt realize ๐Ÿ˜„
03:59:07FromDiscord<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:26FromDiscord<Elegantbeef> I mean we were talking about the inclusion of SSL
03:59:54*ehmry joined #nim
03:59:54FromDiscord<Elegantbeef> Isnt it used in more places than just http requests
04:00:46FromDiscord<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:37FromDiscord<treeform> In reply to @Elegantbeef "Isnt it used in": 99% of the time its only http requests
04:02:15FromDiscord<treeform> I have used openSSL directly for cryptography for JWT... but its a very niche use.
04:03:20FromDiscord<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:27FromDiscord<treeform> That makes it very interesting
04:03:53FromDiscord<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:09FromDiscord<treeform> we are actually exploring this now
04:04:12FromDiscord<j-james> i've been using windy+boxy+pixie for a project and they're a blast by the way
04:04:21FromDiscord<treeform> puppy was version 1
04:04:38FromDiscord<treeform> but it turns out if you have an OS loop, you can use other methods.
04:04:46FromDiscord<treeform> windy uses os loop method
04:04:57FromDiscord<treeform> we are thinking of maybe combining the two approaches
04:05:37FromDiscord<j-james> In reply to @treeform "but it turns out": other methods?
04:05:45FromDiscord<treeform> to make puppy async you basically need threads
04:06:15FromDiscord<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:53FromDiscord<treeform> In reply to @j-james "other methods?": Yes, OSes have more then two APIs to do things.
04:08:01FromDiscord<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:43FromDiscord<treeform> In reply to @j-james "i've been using windy+boxy+pixie": I am glad that works for you.
04:11:09FromDiscord<j-james> interesting
04:11:35FromDiscord<j-james> from a user perspective, it feels like http support doesn't fit with the rest of windy as well
04:11:48FromDiscord<j-james> but i see how you'd always want async requests and simplifying that is nice
04:13:51FromDiscord<treeform> its just that window's HTTP api is just tied to a window.
04:13:58FromDiscord<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:42FromDiscord<Mike> Hey is there a convenient way of getting the last item in a sequence?
04:53:20FromDiscord<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:39FromDiscord<Mike> Is there something like `s.last`?
04:53:52FromDiscord<Elegantbeef> `s[^1]`
04:53:57FromDiscord<Mike> ahhhhhhhh
04:54:07FromDiscord<Mike> Man I couldn't find that anywhere
04:54:17FromDiscord<Elegantbeef> `[]` takes both `int` and backwards index
04:54:43FromDiscord<Mike> I kept trying stuff like `s[:-1]` or whatever
04:54:59FromDiscord<Yardanico> In reply to @Mike "Man I couldn't find": https://nim-lang.org/docs/system.html#^.t%2Cint
04:55:17FromDiscord<Yardanico> also some info in https://nim-lang.org/docs/tut1.html#advanced-types-slices
04:55:32FromDiscord<Yardanico> and of course https://narimiran.github.io/nim-basics/#_indexing_and_slicing
04:56:15FromDiscord<Mike> Yeah I mean I found it immediately after I knew what to call it \:(
05:21:16FromDiscord<j-james> what does `Error: Table is not a concrete type` mean?
05:21:29FromDiscord<Elegantbeef> You didnt specify generic parameters
05:21:55FromDiscord<j-james> ah, ty
05:50:41FromDiscord<Prestige> Elegantbeef did you try your mocker solution with the code I was trying to use?
05:51:03FromDiscord<Prestige> I'm not sure if I'm using your mock macro correctly, but I'm still seeing errors
05:51:04FromDiscord<Elegantbeef> I mean doesnt really matter if i did or not this is a much much less aggressive solution
05:51:17FromDiscord<Elegantbeef> What?
05:51:59FromDiscord<Elegantbeef> Code or it didnt happen!
05:53:26FromDiscord<Prestige> Looking at your example, I don't know where `doThingMock` is coming from
05:53:41FromDiscord<Elegantbeef> It's injected from the `mock` call
05:53:48FromDiscord<Prestige> hmm
05:53:57FromDiscord<Elegantbeef> I personally prefer `doThingMock` than `mockProcs.doThing`
05:54:28FromDiscord<Elegantbeef> look at the config.nims
05:55:49FromDiscord<Prestige> This is what I'm trying https://play.nim-lang.org/#ix=40Dt
05:56:05FromDiscord<Prestige> But I assume I should be manually invoking `genStringMock` during my test?
05:56:18FromDiscord<Elegantbeef> No
05:56:31FromDiscord<Elegantbeef> you need to write your mocked procs inside `mockProcs`
05:56:36FromDiscord<Elegantbeef> You cannot mock them as you go
05:57:04FromDiscord<Prestige> oh, has to be a separate file? That's not great
05:58:00FromDiscord<Elegantbeef> I mean it's the only ergonomic way i could reason to make the TRM less aggressive
05:58:13FromDiscord<Elegantbeef> The previous version had to have a seperate file aswell
05:58:40FromDiscord<Prestige> Maybe it needs to be more aggressive
05:58:47FromDiscord<Elegantbeef> What?
05:58:53FromDiscord<Elegantbeef> Being aggressive was why the last version didnt work
05:59:28FromDiscord<Elegantbeef> You'll have to declare mocked procedures before any code anyway
05:59:34FromDiscord<Prestige> Idk what was the issue previously that made it not work
05:59:42FromDiscord<Prestige> Yeah I mean that part is fine
05:59:52FromDiscord<Prestige> but I want the mocked procs to be inside the test file
05:59:57FromDiscord<Elegantbeef> It was aggressively grabbing all procedures as such made it invalid
06:00:06FromDiscord<Elegantbeef> Well you cannot do that
06:00:35FromDiscord<Elegantbeef> There is another way to do this mocking but it's a very messy one
06:00:51FromDiscord<Elegantbeef> It's also not automatic
06:01:49FromDiscord<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:21FromDiscord<Elegantbeef> so something like `mock(doThing = myOtherProc, genString = proc(): string = "Hello")`
06:03:03FromDiscord<Prestige> So why can't we just do like `mock(someProc, myMockProc)` and have it change the body of `someProc` ?
06:03:23FromDiscord<Prestige> or just replace it entirely, whichever would be easier
06:03:41FromDiscord<Elegantbeef> Cause you want it to not require annotation
06:03:55FromDiscord<Elegantbeef> You cannot use TRM to capture proc definitions
06:04:52FromDiscord<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:43FromDiscord<Prestige> Could we capture all calls to `someProc` and change it to calls to `myMockProc`?
06:05:57FromDiscord<Elegantbeef> That's literally what we're doing
06:06:18FromDiscord<Prestige> Why does that require a whole other file?
06:06:50FromDiscord<Elegantbeef> cause you have to have the mock proc and patter matching declared before the proc you're attempting to replace
06:07:07FromDiscord<Elegantbeef> You know how Nim compiles files top to bottom in import order, that matters
06:07:16FromDiscord<Prestige> damn that sucks
06:07:32FromDiscord<Prestige> wait
06:07:49FromDiscord<Prestige> Could we just declare the mock proc at the top of the test file before the imports, then?
06:08:04FromDiscord<Elegantbeef> No cause you need to import the TRM macro
06:08:38FromDiscord<Prestige> Couldn't we import the macro, declare mock procs, then import everything else?
06:08:45FromDiscord<Elegantbeef> No
06:08:49FromDiscord<Prestige> D:
06:08:59FromDiscord<Elegantbeef> the TRM needs imported in every file you want it to activate in
06:09:06FromDiscord<Elegantbeef> Which is why we use `--import:mockprocs`
06:09:26FromDiscord<Elegantbeef> TRMs are not magic they abide by importing/exporting
06:09:47FromDiscord<Elegantbeef> The only way you can get away without another file is to use the call approach where you make new procedures
06:09:47FromDiscord<Prestige> I don't see what the problem is
06:10:15FromDiscord<Prestige> like if we have the TRM imported and our mock procs declared before importing the other code
06:10:23FromDiscord<Elegantbeef> the TRM needs to have the variable you're going to call inside of it
06:10:53FromDiscord<Prestige> by that variable you mean the name of the actual proc we're trying to mock?
06:11:06FromDiscord<Elegantbeef> No the name of the variable we want to replace
06:11:13FromDiscord<Elegantbeef> I mean the one we want to call
06:11:17FromDiscord<Elegantbeef> so in our case `doThingMock`
06:11:29FromDiscord<Elegantbeef> We need to have that declared before the TRM so it can call it
06:11:44FromDiscord<Elegantbeef> But if we import the TRM file it cannot know it exists
06:11:53FromDiscord<Prestige> And all of this would still be an issue even if we could match on proc definitions?
06:12:26FromDiscord<Elegantbeef> Well order will always matter you'd need to declare the mocks before importing even without the TRM
06:12:34FromDiscord<Elegantbeef> I mean even if the TRM matched procdefs
06:12:57FromDiscord<Prestige> that's really unfortunate eh
06:13:07FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/LEb
06:15:10FromDiscord<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:59FromDiscord<Elegantbeef> I dont follow
06:16:14FromDiscord<Elegantbeef> You cannot replace all procs as it really fucks with the AST
06:16:22FromDiscord<Elegantbeef> So how do you plan on injecting these clals?
06:16:22FromDiscord<Elegantbeef> calls even
06:16:57FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=40Dy
06:21:34FromDiscord<Prestige> Yeah that'd work
06:21:54FromDiscord<Elegantbeef> Have fun recursing over all AST and replace the calls ๐Ÿ˜„
06:21:56FromDiscord<Prestige> I was thinking we'd just delete the body of `genString` and swap it with the body of a provided proc
06:22:05FromDiscord<Elegantbeef> You cant
06:24:51FromDiscord<Prestige> This is why I was saying I think this feature would require compiler changes
06:27:20FromDiscord<Elegantbeef> Well the top level way was easy to do ๐Ÿ˜› https://play.nim-lang.org/#ix=40Dz
06:27:55FromDiscord<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:45FromDiscord<Elegantbeef> It should be doable but it's not going to be fun ๐Ÿ˜„
06:31:29FromDiscord<Elegantbeef> Even with compiler support it'd be best to be forced to declare them before imports
06:31:38FromDiscord<Elegantbeef> It just makes the code and reasoning easier
06:33:09FromDiscord<Elegantbeef> Cause it means that you have to do the emitted mocked procedures after you sem the code instead of before
06:35:03FromDiscord<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:40FromDiscord<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:08FromDiscord<Prestige> I'm not even sure what you're talking about tbh, I don't know much about the compiler
06:39:27FromDiscord<Elegantbeef> Eh i'm mostly just talking out loud
06:39:46FromDiscord<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:20FromDiscord<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:34FromDiscord<Prestige> ah
06:40:53FromDiscord<Elegantbeef> Then in theory no extra compiler work would be needed and transf/codegen would handle it
06:41:58FromDiscord<Elegantbeef> Atleast i think that might work, but i dont know i'm just a numpty
06:42:14FromDiscord<Prestige> maybe we could ask in #internals
06:42:40FromDiscord<Elegantbeef> The royal we i take it
06:42:51FromDiscord<Prestige> Yeah
06:43:03FromDiscord<Prestige> Well
06:43:07FromDiscord<Prestige> Since I can't articulate what you're talking about
06:43:15FromDiscord<Elegantbeef> If i wanted to see if it'd work i'd just.... you know write the code
06:43:53FromDiscord<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:22FromDiscord<Prestige> Nah I think it'd actually require changing things during the compile step
06:44:39FromDiscord<Prestige> I could make a high level forum post asking about it, but I'll probably get crickets
06:44:51FromDiscord<Prestige> Perhaps I'll do it anyway
06:44:55FromDiscord<Elegantbeef> Why?โ†ต(@Prestige)
06:45:30FromDiscord<Prestige> We need to change the internals of functions that are being invoked throughout the program
06:45:38FromDiscord<Prestige> idk how else we'd do that other than at compile time
06:45:55FromDiscord<Elegantbeef> Oh that's what you meant
06:46:09FromDiscord<Elegantbeef> You could change it at runtime like i said if you wanted to rewrite the assembly ๐Ÿ˜„
06:46:14FromDiscord<Prestige> hehe
06:46:40FromDiscord<Elegantbeef> Find all calls of your proc and insert a call to the proc you want
06:46:44FromDiscord<Elegantbeef> Then carry on ๐Ÿ˜„
06:46:44FromDiscord<Prestige> If I knew how the compiler worked I'd be a lot more helpful in figuring out a solution
06:47:18FromDiscord<Prestige> that actually wouldn't be too bad expect we'd have to type safety I believe
06:47:39FromDiscord<Elegantbeef> What?
06:48:09FromDiscord<Elegantbeef> You can rewrite the assembly to do what ever you want
06:48:43FromDiscord<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:10FromDiscord<Prestige> I mean like you could end up giving it a proc with a different signature that way, right?
06:49:42FromDiscord<Elegantbeef> I mean sure but if you could do it programatically not really
06:59:35FromDiscord<Prestige> https://forum.nim-lang.org/t/9255#60615
06:59:48FromDiscord<Prestige> Hopefully I explained it well enough
07:01:02NimEventerNew 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:53PMunch@Prestige, can't you just patch in a file with a replaced procedure?
07:22:12FromDiscord<Elegantbeef> I already suggested that
07:22:37PMunchAh, I didn't read the chat, just the forum post :P
07:22:38FromDiscord<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:32FromDiscord<Prestige> Basically wanted it just like the example
07:24:53FromDiscord<Prestige> and be able to change it at runtime
07:24:53PMunchHmm, so you want to replace an already declared symbol?
07:25:08PMunchI don't think that's possible in a macro
07:25:58FromDiscord<Elegantbeef> It's indeed not
07:26:09FromDiscord<Elegantbeef> I've given a variety of solutions and prestige no likey
07:26:14FromDiscord<Prestige> Yeah I'd need some way to swap a function pointer or something
07:26:45PMunchGood luck with that if the C compiler inlines your function :P
07:26:58FromDiscord<Elegantbeef> `-d:debug` goes brrr ๐Ÿ˜›
07:27:00PMunchI guess you'd want to perform this mock anywhere in your program as well?
07:27:14PMunchNot just in the module you're running?
07:28:04FromDiscord<Prestige> I want to be able to mock any function, but only need to use `mock` within the current test file
07:28:50PMunchBut 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:05FromDiscord<Elegantbeef> The answer is yes
07:29:11FromDiscord<Prestige> Yep
07:29:45PMunchThen the only option is a modified compiler or a pre-processing tool
07:30:02PMunch(The pre-processing tool could of course take the shape of a macro)
07:30:20FromDiscord<Elegantbeef> `mock` should replace the function with a pointer proc and repeated calls should set that
07:31:06PMunchReplacing 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:46FromDiscord<Elegantbeef> I mean you can recursively look for a call and insert your pointer proc's symbol
07:35:51FromDiscord<Elegantbeef> But it's really complicated
07:40:58*PMunch quit (Remote host closed the connection)
07:41:17*PMunch joined #nim
07:42:48FromDiscord<j-james> can i initialize a Table from two arrays without a for loop?
07:47:40FromDiscord<Elegantbeef> Dont think so
07:49:55PMunchWell, this obviously uses loops under the hood, but your code doesn't have to: https://play.nim-lang.org/#ix=40DP
07:50:29FromDiscord<Elegantbeef> Jeez i hate it
07:50:37FromDiscord<Elegantbeef> A whole new sequence ๐Ÿ˜„
07:51:35PMunchHaha, I didn't say it was great, only that it didn't have for loops :P
07:53:55FromDiscord<j-james> oh, that's not too bad, thanks
07:54:33*ltriant quit (Ping timeout: 248 seconds)
07:55:02FromDiscord<j-james> weird that there's not a `initTable` that takes two openarrays in std/tables
07:55:20FromDiscord<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:56FromDiscord<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:22FromDiscord<that_dude> Not sure if this is seperated enough for you though
09:20:28FromDiscord<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:28FromDiscord<that_dude> The caveat is that you would need to mark procs with a pragma in the source
09:21:44FromDiscord<Elegantbeef> Yea that's not what he wants
09:22:11FromDiscord<that_dude> Kinda figured ๐Ÿ˜„
09:23:35FromDiscord<Rika> I really canโ€™t imagine another way other than the patch file one or the custom compiler addition
09:47:26PMunchHmm, 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:47FromDiscord<Olfactory Hallucinations> @PMunch There's a program that comes with KDE plasma called "Filelight" that does that
09:52:04FromDiscord<Olfactory Hallucinations> https://apps.kde.org/filelight/
09:52:16FromDiscord<Prestige> That's awesome
09:52:40PMunchDoes it take the input from `du -h`?
09:53:03PMunchBecause I already use Baobab which does the graphical part
09:54:10FromDiscord<Olfactory Hallucinations> not sure. I usually start it from the Dolphin file manager
09:54:26PMunchThat's what I use now
09:55:28FromDiscord<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:27NimEventerNew thread by Jasonfi: Any way to determine the GC at runtime?, see https://forum.nim-lang.org/t/9256
09:58:06FromDiscord<Prestige> Baobab looks nice too
09:58:23FromDiscord<Prestige> What is that missing that you want PMunch?
10:01:21PMunchThe ability to build it's display from the output of du -h
10:02:30FromDiscord<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:04FromDiscord<jmgomez> can you forward declare in nim, right?
10:26:15FromDiscord<jmgomez> cant find the way to do it online
10:26:22FromDiscord<Prestige> Yeah
10:26:34FromDiscord<Prestige> https://nim-lang.org/docs/tut1.html#procedures-forward-declarations
10:27:23FromDiscord<jmgomez> ohh, that's nice so for a type it would just be type MyType?
10:31:16FromDiscord<jmgomez> sent a code paste, see https://play.nim-lang.org/#ix=40E4
10:34:27FromDiscord<Rika> You canโ€™t forward declare a type, I donโ€™t get it
10:34:48FromDiscord<Rika> If you want to cyclically refer to a type then they must be in the same type block
10:35:37FromDiscord<jmgomez> really? even if it's a pointer type?
10:36:40Amun-Raeven, if that's a pointer to unknown type
10:37:06FromDiscord<ripluke> In reply to @Olfactory Hallucinations "Did you figure out": I did
10:37:44FromDiscord<jmgomez> okay, that's a bit unfortunate
10:39:03Amun-Rain the example above it's just an (yet) unknown type, that just happens to be a ptr
10:42:27FromDiscord<jmgomez> is there any other syntax or is it just a nim limitation?
10:44:35Amun-Rathe 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:26Amun-Rayou can have a plain pointer type (equivalent of void* ) and do the cast, but that sucks
10:47:35FromDiscord<jmgomez> okay, thanks
10:55:38NimEventerNew thread by Jasonfi: Example code with multithreading and channels is failing, see https://forum.nim-lang.org/t/9257
11:15:58FromDiscord<Prestige> Elegantbeef did you see https://forum.nim-lang.org/t/9255#60617 ? Lol
11:16:00FromDiscord<Prestige> Pretty cool
11:18:20FromDiscord<Rika> Cool but holy shit please do not use it
11:18:49FromDiscord<Prestige> yep lma
11:18:50FromDiscord<Prestige> (edit) "lma" => "lmao"
11:19:12FromDiscord<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:53FromDiscord<Rika> Unfortunately this doesnโ€™t help if youโ€™re mocking a high CPU function instead of a blocking/slow IO function
11:20:10FromDiscord<Prestige> sorta same problem I think
11:20:23FromDiscord<Prestige> I partially want this so I can mock xlib for testing
12:03:43FromDiscord<vindaar> I just put it here https://github.com/Vindaar/hotpatching ๐Ÿ˜…โ†ต(@Prestige)
12:11:46NimEventerNew 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:41FromDiscord<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:20FromDiscord<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:59FromDiscord<Prestige> vindaar: That's really cool haha
12:25:19FromDiscord<vindaar> sent a code paste, see https://play.nim-lang.org/#ix=40Ep
12:25:55FromDiscord<vindaar> (`ord` gives you the ordinal value associated with that enum entry)
12:29:39FromDiscord<AlexG> Yes! that worked. Thanks @Vindaar .
12:47:53*Jjp137 quit (Ping timeout: 255 seconds)
12:53:48FromDiscord<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:52FromDiscord<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:33FromDiscord<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:45FromDiscord<luteva> (edit) "yes that would probably ... the" added "be"
13:24:09FromDiscord<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:31FromDiscord<enthus1ast> the end of the stream would be the current file size i guess
13:28:36*toluene joined #nim
14:13:52FromDiscord<๐Ÿ’๐Ÿง br4n_d0n> In a very basic example, when would you use a `` let `` over a `` const `` ?
14:16:12FromDiscord<!Patitotective> In reply to @br4n_d0n "In a very basic": when the value cannot be evaluated at compile-time lol
14:19:25FromDiscord<๐Ÿ’๐Ÿง 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:12FromDiscord<konsumlamm> well, they have different semantics, so it makes sense to separate them
14:20:23FromDiscord<Rika> And if you want to force something that evaluates in compile time to be evaluated at run time?
14:20:25FromDiscord<๐Ÿ’๐Ÿง br4n_d0n> OMG, I cannot even write coherent messages... I give up
14:20:48FromDiscord<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:23FromDiscord<๐Ÿ’๐Ÿง br4n_d0n> In reply to @konsumlamm "sometimes you may not": Never thought about compile times
14:21:26FromDiscord<konsumlamm> you can also do IO (e.g. print something) at compile time, but you don't necessarily want that
14:21:44FromDiscord<konsumlamm> because what the resulting program would do would be very different
14:22:15FromDiscord<!Patitotective> `let variable {.compileTime.} = 1` lol
14:43:49FromDiscord<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:45FromDiscord<๐Ÿ’๐Ÿง 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:18FromDiscord<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:08FromDiscord<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:20FromDiscord<luteva> letting the dev know what's happening is the way to go (imho).
15:09:21FromDiscord<exelotl> {.compileTime.} vars being accessible at runtime is still crazy to me lol
15:09:45FromDiscord<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:08FromDiscord<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:01FromDiscord<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:48FromDiscord<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:35FromDiscord<Rika> i dont recall expressions like that being evaluated at ct in nim
16:11:41FromDiscord<๐Ÿ’๐Ÿง br4n_d0n> Anyone know of an easy way to search the source files on github for a particular string?
16:12:24FromDiscord<Rika> clone then grep, github search is always fuzzy i believe
16:12:37FromDiscord<Rika> maybe try quotes around the term
16:12:40FromDiscord<Rika> but i dont think thatll work
16:12:42FromDiscord<Rika> might tho
16:13:02FromDiscord<๐Ÿ’๐Ÿง br4n_d0n> I'll give it a shot
16:13:51FromDiscord<๐Ÿ’๐Ÿง br4n_d0n> No shit it worked
16:14:02FromDiscord<Rika> damn thats good
16:14:27FromDiscord<๐Ÿ’๐Ÿง br4n_d0n> Thanks for the suggestion, this is super helpful
16:14:41FromDiscord<!Patitotective> github search has a cheat sheet
16:34:25*fallback joined #nim
17:14:41FromDiscord<huantian> Or use the closed GitHub search beat
17:14:44FromDiscord<huantian> Beta
18:10:21*PMunch quit (Quit: Leaving)
18:28:10FromDiscord<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:23FromDiscord<vestel> How to reopen stdout after `AllocConsole`?
20:17:18FromDiscord<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:00NimEventerNew 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:48FromDiscord<Elegantbeef> I figured it was possible to do, but didnt know the API for it
20:53:42FromDiscord<Elegantbeef> The fact your `hotpatch` isnt `target, replacement: proc` is silly though
20:57:00FromDiscord<vindaar> PRs welcome ๐Ÿ˜œ
20:58:28FromDiscord<Elegantbeef> No you
21:14:42FromDiscord<Yardanico> Bot didn't post here for some reason
21:14:44FromDiscord<Yardanico> New thread by Araq: Mastering Nim: A complete guide to the programming language, see https://forum.nim-lang.org/t/9259
21:15:59NimEventerNew thread by Araq: Mastering Nim: A complete guide to the programming language, see https://forum.nim-lang.org/t/9259
21:19:07FromDiscord<Alea> Interesting to see what the appendix offers vs the existing nimdocs
21:19:23FromDiscord<Alea> But nice to see that he's making an effort like this
21:19:48*wallabra_ joined #nim
21:20:20FromDiscord<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:40FromDiscord<!Patitotective> first programming book without an animal on its cover
21:26:51*Amun-Ra quit (Ping timeout: 276 seconds)
21:31:57FromDiscord<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:08FromDiscord<luteva> (edit) "start:" => "start"
21:32:28FromDiscord<luteva> (edit) "start" => "start/beginning"
21:33:52FromDiscord<huantian> oh huh new book
21:36:20FromDiscord<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:46FromDiscord<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:24FromDiscord<golova> In reply to @luteva "is there a readLine": I think for that case you should use some API provided by system
21:39:38FromDiscord<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:46FromDiscord<๐Ÿ’๐Ÿง br4n_d0n> Man that's a spicy price of a book
21:52:09FromDiscord<๐Ÿ’๐Ÿง 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:55FromDiscord<Elegantbeef> I hope not, cause i cannot read
22:10:45FromDiscord<!Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=40Gj
22:11:20FromDiscord<!Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=40Gk
22:11:47FromDiscord<!Patitotective> `collect(newSeq[int])` doesn't work either
22:13:29FromDiscord<!Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=40Gm
22:13:38FromDiscord<!Patitotective> (edit) "https://play.nim-lang.org/#ix=40Gm" => "https://play.nim-lang.org/#ix=40Gn"
22:14:54FromDiscord<Elegantbeef> `sum toSeq(0..10)` should work but it's dumb to use `toSeq` then sum
22:16:29FromDiscord<!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:01FromDiscord<Elegantbeef> Or you know just sum it like a normal person
22:17:24FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/HPM
22:17:48FromDiscord<!Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=40Gp
22:17:55FromDiscord<Elegantbeef> I've seen your code i know you arent normal
22:18:00FromDiscord<!Patitotective> hahah
22:21:12FromDiscord<Elegantbeef> I mean you made niprefs cause you didnt know yaml or toml existed ๐Ÿ˜›
22:24:22FromDiscord<!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:41FromDiscord<retkid> is there anyway to turn a string into an enum
22:33:46FromDiscord<retkid> of identical spelling
22:34:00FromDiscord<retkid> or does it have to be a number?
22:34:08FromDiscord<Phil> Yeh, is possible
22:34:15FromDiscord<Phil> one sec, copy pasting example from my sideproject
22:34:19FromDiscord<Elegantbeef> from strutils
22:34:19FromDiscord<Elegantbeef> `parseEnum[MyEnumType](myString)`
22:34:37FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=40Gr
22:35:14FromDiscord<Elegantbeef> Are you honestly doing multiline enum fields with commas?
22:35:21FromDiscord<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:21FromDiscord<Elegantbeef> Fucking masochist over here
22:35:43FromDiscord<Elegantbeef> Well when you use parseEnum with the above enum it only parses the string which is tedious
22:35:43FromDiscord<Phil> I started out doing so since it was a java habit
22:35:47FromDiscord<Phil> Then I realized its unnecessary
22:36:05FromDiscord<retkid> In reply to @Elegantbeef "Well when you use": https://media.discordapp.net/attachments/371759389889003532/989297752729059349/unknown.png
22:36:08FromDiscord<Phil> And somewhere halfway through I dropped the habit, so it's applied very inconsistently
22:36:24FromDiscord<Elegantbeef> Retkid one day you'll write normal Nim code
22:36:57FromDiscord<retkid> In reply to @Elegantbeef "Retkid one day you'll": https://media.discordapp.net/attachments/371759389889003532/989297970430214224/unknown.png
22:37:21FromDiscord<retkid> i write normal nim
22:37:35FromDiscord<Elegantbeef> I despise that you use lowercase types still
22:37:40FromDiscord<Elegantbeef> You really dont
22:39:05FromDiscord<Elegantbeef> Like why do you have an `output` isnt that just `result`
22:39:13FromDiscord<Elegantbeef> Why are you dereferencing your `output`
22:39:30FromDiscord<retkid> I had a reason
22:39:35FromDiscord<retkid> i forget
22:39:43FromDiscord<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:59FromDiscord<Elegantbeef> Options are a single bool check
22:40:20FromDiscord<golova> In reply to @Elegantbeef "Like why do you": He dereferences a ref type?
22:40:36FromDiscord<Elegantbeef> Yes but.... you dont need to dereference references to access fields
22:40:47FromDiscord<retkid> i dont know why i did it ok\
22:40:50FromDiscord<Elegantbeef> Nim auto dereferences field access
22:40:58FromDiscord<retkid> i wanted to instanciate the class with defaults
22:41:01FromDiscord<retkid> (edit) "instanciate" => "instantiate"
22:41:19FromDiscord<Elegantbeef> I mean i dont care why you said you write normal nim and you clearly dont
22:41:20FromDiscord<Elegantbeef> ๐Ÿ˜„
22:41:26FromDiscord<retkid> i didn't comment anything
22:41:29FromDiscord<retkid> so i dont know what my brain
22:41:32FromDiscord<retkid> was doing
22:41:56FromDiscord<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:07FromDiscord<Elegantbeef> That's if you have a value you really dislike more than the others
22:42:07*noeontheend joined #nim
22:42:18FromDiscord<retkid> https://media.discordapp.net/attachments/371759389889003532/989299316260737094/unknown.png
22:42:19FromDiscord<huantian> you link seems dead
22:42:20FromDiscord<retkid> NORMAL NI0M
22:42:33FromDiscord<huantian> why are you calling int so many times
22:42:34FromDiscord<Elegantbeef> What's a NIOM?
22:42:44FromDiscord<retkid> nim
22:42:46FromDiscord<huantian> no it's NI0M not NIOM
22:42:50FromDiscord<Elegantbeef> My dude just do `start div 10000`
22:43:11FromDiscord<Elegantbeef> Why `if isMainModule`?
22:43:15FromDiscord<Elegantbeef> if is runtime checked
22:43:23FromDiscord<Elegantbeef> That means you're including that in any code that uses that module
22:43:38FromDiscord<retkid> yes
22:43:42FromDiscord<Elegantbeef> Why is `output` a `ref seq[Person]`?
22:43:44FromDiscord<retkid> wait
22:44:06FromDiscord<Elegantbeef> So much for idiomatic Nim eh? ๐Ÿ˜›
22:44:10FromDiscord<retkid> i dont know
22:44:19FromDiscord<retkid> i had a reason
22:44:21FromDiscord<retkid> no comments
22:44:28FromDiscord<Elegantbeef> `when isMainModule`
22:44:39FromDiscord<Elegantbeef> It's ok to say "I just didnt know"
22:44:50FromDiscord<retkid> if i wrote comments
22:44:54FromDiscord<retkid> i could tell you
22:44:59FromDiscord<Elegantbeef> Works here
22:45:09FromDiscord<huantian> ah works on reload
22:45:11FromDiscord<Phil> In reply to @retkid "if i wrote comments": I wonder what the solution could be
22:45:32FromDiscord<Elegantbeef> Eitherway probably another addition to my wacky random idea package
22:45:36FromDiscord<retkid> oh because i wanted to add to it from a function
22:45:49FromDiscord<retkid> rather than return and add it there
22:45:56FromDiscord<retkid> because my brain decided thats how the code should look
22:45:57FromDiscord<Elegantbeef> What?
22:46:02FromDiscord<huantian> perhaps consider closures
22:46:09FromDiscord<Elegantbeef> You can pass result to functions
22:46:28FromDiscord<retkid> yea
22:46:28FromDiscord<๐Ÿ’๐Ÿง 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:43FromDiscord<Elegantbeef> Nah some people write cleaner code
22:46:53FromDiscord<retkid> my code is clean but nonsensical
22:47:00FromDiscord<huantian> you say it's clean
22:47:02FromDiscord<Elegantbeef> that was a lie
22:47:08FromDiscord<huantian> and then you name your variables `page` and `pagey`
22:47:10FromDiscord<Phil> I look at my code
22:47:13FromDiscord<Phil> It is beautiful
22:47:20FromDiscord<Phil> Rough edges here and there
22:47:21FromDiscord<Elegantbeef> Lol phil i've seen your code
22:47:22FromDiscord<retkid> In reply to @huantian "and then you name": THIS IS A PROGRAMMER TRADITIOBN
22:47:23FromDiscord<Phil> But still beautiful
22:47:32FromDiscord<retkid> Phil I've seen your code
22:47:35FromDiscord<retkid> idk what the fuck is happening
22:47:52FromDiscord<retkid> in my code, you'll have questions, but at least you know whats happening
22:48:03FromDiscord<Elegantbeef> I really dont
22:48:08FromDiscord<retkid> well i do
22:48:11FromDiscord<retkid> sometimes
22:48:26FromDiscord<Elegantbeef> You said like 5 times "i dont know why i did X"
22:48:41FromDiscord<retkid> yea, i have questions
22:48:47FromDiscord<retkid> but i know what is happening
22:48:48FromDiscord<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:05FromDiscord<Phil> For what it does, the overall structure is decently simple
22:49:59*wallabra quit (Ping timeout: 255 seconds)
22:50:26FromDiscord<Elegantbeef> I accept my code is shit! I dont lie to myself
22:50:46FromDiscord<๐Ÿ’๐Ÿง br4n_d0n> sent a code paste, see https://play.nim-lang.org/#ix=40Gt
22:51:06FromDiscord<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:08FromDiscord<Elegantbeef> Is it really too hard to do `1f`?
22:51:27FromDiscord<๐Ÿ’๐Ÿง br4n_d0n> It's the principle at this point
22:51:38FromDiscord<๐Ÿ’๐Ÿง br4n_d0n> I'm going to beat this fucking code
22:51:39FromDiscord<๐Ÿ’๐Ÿง br4n_d0n> llol
22:52:09FromDiscord<Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/989301796583403541/image.png
22:52:11FromDiscord<Elegantbeef> Cmon phil it's totally clean!
22:52:12FromDiscord<Alea> sent a code paste, see https://play.nim-lang.org/#ix=40Gu
22:52:55FromDiscord<Elegantbeef> What's the difference and secondly you know procs exist?
22:54:06FromDiscord<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:26FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=40Gv
22:54:38FromDiscord<Elegantbeef> The proc is named `rewind`
22:54:52FromDiscord<Phil> So you skip the rewinding?
22:54:54FromDiscord<Elegantbeef> Cmon phil you can figure out what's being rewound in a game with a single rewind mechanic
22:55:23FromDiscord<Elegantbeef> `world.history.high` might indicate we're rewinding history
22:55:46FromDiscord<Phil> So while rewinding you might skip a history step?
22:55:52FromDiscord<Elegantbeef> Yes
22:56:07FromDiscord<Elegantbeef> Cause sometimes you're standing on the step you'd want to skip and would not move
22:56:22FromDiscord<Elegantbeef> But you want to skip that in cases like when the player hits the "undo" button
22:56:57FromDiscord<Elegantbeef> Alea really what's the difference i'm blind
22:57:22FromDiscord<Elegantbeef> oh alea it's `notin`
22:57:34FromDiscord<Elegantbeef> `not in` is two operators
22:57:58FromDiscord<Elegantbeef> But please for everyone's sanity use a proc for this
22:59:10FromDiscord<Alea> The constructor is a better idea yes
22:59:44FromDiscord<Alea> what's going on with the proc args though? Don't know _, typedesc, and whether or not selectedElem needs a type
23:00:11FromDiscord<Phil> "_" just means "The value of this element doesn't matter
23:00:17FromDiscord<Elegantbeef> It needs a type i didnt know it
23:00:17FromDiscord<Elegantbeef> `_: typedesc` means you do `Cell.init(selectedElem)`
23:00:31FromDiscord<Phil> typedesc means that "_" will be a type
23:00:34FromDiscord<Alea> gotcha
23:00:56FromDiscord<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:49FromDiscord<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:51FromDiscord<Elegantbeef> Alea regrets asking for help ๐Ÿ˜„
23:04:40FromDiscord<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:00FromDiscord<Elegantbeef> Think you could make it return PNodes though.... hmmm
23:05:02FromDiscord<treeform> that would be a start, can I see it?
23:05:33FromDiscord<Elegantbeef> https://github.com/beef331/nimscripter/tree/master/examples/macrorepl
23:06:56FromDiscord<Elegantbeef> https://streamable.com/c6farb is what it does
23:07:32FromDiscord<Elegantbeef> Basically you can live edit macros and it'll print the AST/Code directly to the terminal depending on your settings
23:09:21FromDiscord<treeform> that's cool
23:09:50FromDiscord<treeform> Hmm I think the lib you use "assume-0.4.0" does not support windows ๐Ÿ˜ฆ
23:10:07FromDiscord<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:27FromDiscord<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:27FromDiscord<Elegantbeef> Assume is just a macro library
23:13:28FromDiscord<Elegantbeef> Linenoise is probably the culprit
23:14:21FromDiscord<Elegantbeef> Or my usage of the `terminal` lib
23:15:44FromDiscord<Alea> hmm https://media.discordapp.net/attachments/371759389889003532/989307731028611082/unknown.png
23:16:02FromDiscord<Elegantbeef> `typedesc[Cell]`
23:16:09FromDiscord<Elegantbeef> `_: Cell` expects an instance of Cell
23:16:34FromDiscord<Alea> ๐Ÿ‘
23:27:45FromDiscord<Alea> sent a code paste, see https://play.nim-lang.org/#ix=40Gy
23:28:27FromDiscord<Elegantbeef> should be `when T is Cell`
23:29:10FromDiscord<Elegantbeef> Dont really get why it's `initOrUpdate`
23:29:14FromDiscord<Elegantbeef> Seems like it's just a constructor
23:29:46FromDiscord<Alea> yeah, I had a bright & lazy idea, but it's not actually what I want in retrospect
23:30:39FromDiscord<luteva> i think i have seen some tools for building TUIs in nim. can anyone point me to the right direction?
23:31:40FromDiscord<Elegantbeef> illwill
23:31:47FromDiscord<Elegantbeef> nimwave
23:32:37FromDiscord<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:15FromDiscord<Elegantbeef> `for name, _ in obj.fieldPairs:`
23:34:10FromDiscord<Alea> Incredibleโ†ตI'm sure this is a valid replacement for good software design ๐Ÿ˜Ž
23:36:37FromDiscord<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:21FromDiscord<๐Ÿ’๐Ÿง br4n_d0n> @Alea FYI, you can add ``nim `` right after the 3 backticks to get color coding