<< 21-01-2022 >>

00:04:03*jmdaemon joined #nim
00:04:07FromDiscord<hmmm> yea and this was pretty hard too, I didn't understand what was the flow of the conditional https://media.discordapp.net/attachments/371759389889003532/933874561173319700/Capture.JPG
00:04:46FromDiscord<hmmm> and that concludes my low-IQ review 😊
00:06:20FromDiscord<hmmm> I'll go sleep, tomorrow I expect a full writeup of "From zero to hero: macros for dummies in Nim" 😋
00:06:36FromDiscord<Elegantbeef> Damn you're going to write a book in your sleepp
00:06:43FromDiscord<hmmm> haha
00:11:10*tk quit (Quit: Well, this is unexpected.)
00:12:27*tk joined #nim
00:24:02*jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in)
00:45:26*joshbaptiste joined #nim
01:36:53*jmdaemon joined #nim
01:43:56*krux02 quit (Remote host closed the connection)
02:23:57*neurocyte0917090 quit (Ping timeout: 240 seconds)
02:44:10*jmdaemon quit (Ping timeout: 256 seconds)
03:07:33*jmdaemon joined #nim
03:14:37*noeontheend quit (Ping timeout: 240 seconds)
03:29:20*jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in)
03:37:59*jmdaemon joined #nim
03:42:48*arkurious quit (Quit: Leaving)
03:49:48*vicfred quit (Quit: Leaving)
03:49:54FromDiscord<reilly> I'm working on something where it appears as though the last two characters of my `httpclient.patch()` request are being trimmed... Any ideas?
04:41:40*jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in)
05:16:07*Guest1163 joined #nim
05:21:32*Guest1163 quit (Quit: Client closed)
05:33:01*rockcavera quit (Remote host closed the connection)
05:37:54*ecs quit (Ping timeout: 260 seconds)
05:40:14FromDiscord<Nightshade 🌙> Is there a preferred help channel on this server?
05:40:32FromDiscord<Elegantbeef> here
05:40:38FromDiscord<Nightshade 🌙> Awesome thanks
05:40:40*ecs joined #nim
05:42:07FromDiscord<Nightshade 🌙> Well here goes, the crux of the matter is I would like to generate a Windows DLL that can be reflectivity loaded at runtime from either Powershell or the .NET API that it raps System.Management.Automation.DLL
05:43:07FromDiscord<Nightshade 🌙> Now I've tried a lot of things these past few days, making sure the correct pragmas are in place, ensuring I'm compiling with the right flags, but at this point I don't even know if it's possible.
05:44:55FromDiscord<Nightshade 🌙> When I generate my DLL and read it into memory as bytes and attempt to call Powershell's [System.Reflection.Assembly]::Load($bytes) nothing I try works
05:45:39FromDiscord<Nightshade 🌙> Is it even possible to generate that type of DLL using Nim? I mean it must be right?
05:46:16FromDiscord<Elegantbeef> Isnt it just a dynamic library?
05:46:37*ecs quit (Ping timeout: 240 seconds)
05:48:38*ecs joined #nim
05:48:43*blackbeard420 quit (Ping timeout: 250 seconds)
05:49:03*blackbeard420 joined #nim
05:58:47FromDiscord<leorize> I think powershell requires a lot more than just any dll
06:01:54FromDiscord<Nightshade 🌙> Yeah thats the confusion I have seen that the System.Reflection method I described above can pull and run DLLs on the fly idk why it doesn't work for Nim
06:03:34FromDiscord<Nightshade 🌙> In reply to @Elegantbeef "Isnt it just a": Referring to Powershell? Yes it is a wrapper over the System.Management.Automation.dll I mentioned above
06:03:58FromDiscord<Nightshade 🌙> In reply to @leorize "I think powershell requires": I'm not sure what you mean, could you please elaborate
06:05:13FromDiscord<leorize> it's looking like it would only work with dotnet's generated assembly
06:05:31FromDiscord<leorize> though the docs does mention how to fix a C++ assembly not loading, but not saying anything about how to create them
06:10:25FromDiscord<Nightshade 🌙> Yeah thats where I was confused, I mean there must be a way to call exported C functions in the .NET runtime and since Nim compiles to C it must be possible
06:14:43FromDiscord<leorize> looks like that function you use is for .net assemblies only
06:14:50FromDiscord<leorize> https://docs.microsoft.com/en-us/dotnet/standard/native-interop/pinvoke \<- this is the usual method to interop
06:14:53FromDiscord<leorize> requires a wrapper
06:15:51FromDiscord<Nightshade 🌙> Ahh okay thank you that makes sense, so maybe I can use winim someway somehow to make the magic happen
06:16:45FromDiscord<Nightshade 🌙> In reply to @leorize "requires a wrapper": You're a hero
06:17:28*xiamx[m] quit (Quit: Client limit exceeded: 20000)
06:38:15FromDiscord<Elegantbeef> Ah yes the needless confusion between `.dll` and `.dll`
06:38:15*xiamx[m] joined #nim
06:40:34*cheer[m] quit (Quit: Client limit exceeded: 20000)
06:41:14FromDiscord<Rika> Welcome to the operating system that supposedly distinguishes files by extension
06:41:26*cheer[m] joined #nim
06:46:43FromDiscord<demotomohiro> You might find out the difference between C's .dll and .net .dll by learning fileformat of .dll.
07:06:06*[R] quit (Ping timeout: 260 seconds)
07:06:22*[R] joined #nim
07:10:19FromDiscord<leorize> net assemblies are valid PE files
07:10:53FromDiscord<leorize> they contain CIL for the CLR instead of native code, though
07:12:16*PMunch joined #nim
07:31:57PMunchHmm, what is `nimInErrorMode` flag that's being generated in my C code?
07:32:55PMunchI'm trying to understand where the bytes go when I program my microcontroller to make the best abstractions
07:36:41FromDiscord<leorize> I guess it's for exceptions? goto exceptions got something similar
07:38:11FromDiscord<that_dude> Is it intentional design that type(type(1)) returns int? ie that there isn't a type type?
07:39:21FromDiscord<Elegantbeef> `typeof(typeof(1))` is int
07:39:54FromDiscord<Elegantbeef> `type` is a semi deprecated version of `typeof`
07:40:52FromDiscord<Michal Maršálek> type type is typedesc, no?
07:40:58FromDiscord<that_dude> 1. what's the difference, 2. but there isn't a type type, right? I'd love to be able to make that an object field
07:41:02FromDiscord<Elegantbeef> yes
07:41:28PMunch@leorize, aah goto exceptions makes sense
07:41:29FromDiscord<Elegantbeef> the difference is `type(1)` isnt the suggested way of doing it
07:41:34FromDiscord<Michal Maršálek> In reply to @that_dude "1. what's the difference,": Types only exist at compile time
07:41:40FromDiscord<Elegantbeef> `typeof(1)` is how you should
07:41:51FromDiscord<that_dude> In reply to @Michal58 "Types only exist at": Ah
07:42:27FromDiscord<Michal Maršálek> But you can for example create a proc that takes a type as an argument
07:42:53FromDiscord<Elegantbeef> Though that makes it generic and is done statically
07:42:54PMunchHmm, turned off goto exceptions and it's still there
07:43:02FromDiscord<Michal Maršálek> What happens then if I understand it correctly is that it creates a generic proc
07:43:18FromDiscord<Elegantbeef> Indeed michal
07:43:38FromDiscord<that_dude> I think I get it
07:43:58FromDiscord<Elegantbeef> `proc doThing(a: typedesc)` is actually `proc doThing[T: typedesc](a: T)`
07:44:25FromDiscord<that_dude> sent a code paste, see https://play.nim-lang.org/#ix=3MYV
07:44:33FromDiscord<that_dude> But It's not because of compile time only
07:44:48FromDiscord<Michal Maršálek> Make your type generic
07:44:48FromDiscord<Elegantbeef> You'd have to do `type Warg[T] = object`
07:45:21FromDiscord<that_dude> Why does it need to warg[T] what part of the object is generic?
07:45:27FromDiscord<Michal Maršálek> I guess compiler could be able to convert that automatically the same way it does t for procs?
07:45:30FromDiscord<Elegantbeef> You'd make `thing: T`
07:45:43PMunchAnd I don't really have anything that can throw an exception either as far as I know
07:45:49FromDiscord<Michal Maršálek> (edit) "t" => "it"
07:47:21FromDiscord<Elegantbeef> Actually never mind i see the point
07:47:39FromDiscord<Elegantbeef> Yea just do `type Warg[T] = object` and then when you instantiate it you always have the type it is
07:49:13FromDiscord<that_dude> I guess I'm now a little lost on generics lol
07:49:25FromDiscord<that_dude> I guess that's the next thing to try to learn
07:49:31FromDiscord<Elegantbeef> You dont need to use the generic parameters on the type
07:49:46FromDiscord<Elegantbeef> You can just use generics to add type information
07:51:27FromDiscord<that_dude> `Error: Mixing types and values in tuples is not allowed.` Unlocked a new error
07:51:31FromDiscord<that_dude> (edit) "`Error: Mixing types and values in tuples is not allowed.` Unlocked a new error ... " added "lol"
07:51:33FromDiscord<Elegantbeef> Speaking of fun generics, michal this compiles on devel now! 🙂 https://play.nim-lang.org/#ix=3MYX
07:52:04FromDiscord<Elegantbeef> Yea `(int, 10)` isnt valid
07:54:35FromDiscord<that_dude> It really feels a bit hard to not be allowed to move types around. Ig that's the python stuck in me
07:54:53FromDiscord<that_dude> Unless you couldn't do that there either and I'm just hallucinating
07:55:09FromDiscord<Elegantbeef> You dont need to "move types around"
07:55:19FromDiscord<Elegantbeef> Nim has generics which work in most cases
07:55:42FromDiscord<Elegantbeef> You also have object variants
07:56:50FromDiscord<Michal Maršálek> You only have (small) finite amount of different types, you can just copy your logic for each o the types. And Nim allows you to do that automatically.
07:57:06FromDiscord<that_dude> I'm sorry I don't want to just throw broken code at you guys and ask you to fix things for me :/
07:57:32FromDiscord<that_dude> In reply to @Michal58 "You only have (small)": My vision is more general that than unfortunately
07:57:48FromDiscord<that_dude> because it would include custom types
07:57:52FromDiscord<Elegantbeef> Well that's how you learn is by doing it wrong 😛
07:58:35FromDiscord<Michal Maršálek> In reply to @that_dude "because it would include": Wdym
08:01:44FromDiscord<that_dude> My current vision is something like this:
08:01:55FromDiscord<that_dude> sent a code paste, see https://play.nim-lang.org/#ix=3MZ0
08:02:12FromDiscord<that_dude> But that doesn't work obviously
08:02:30FromDiscord<Elegantbeef> This works with a generic
08:02:53FromDiscord<Elegantbeef> Also you must hate me not naming types capitals
08:03:28FromDiscord<that_dude> But I don't understand generics lol. I get that the compiler got happier when I changed the `warg` to `warg[T]` on the gen proc, but I don't understand why
08:04:22FromDiscord<that_dude> Oh sorry. As you know I come from python so everything I write is all lowercase snake case
08:04:50FromDiscord<that_dude> The only time I do differently is to make the autocompletion work :)
08:05:05FromDiscord<that_dude> I've been trying to do more camel tho
08:06:04FromDiscord<Michal Maršálek> Do you name your Python types (classes) in lowercase? 😳
08:06:59FromDiscord<that_dude> It looks like I use upper case there
08:07:22FromDiscord<that_dude> I just follow whatever the ide suggests because my priority is getting the idea down first and cleaning it up later
08:07:51FromDiscord<that_dude> And Nimsuggest(?) doesn't yell at me while I'm tying it
08:09:28FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3MZ4
08:09:28FromDiscord<Elegantbeef> That's how you'd do it
08:10:08FromDiscord<Elegantbeef> there is some merit to `proc initWArg[T](input: var T): WArg[T]` instead
08:10:22FromDiscord<Elegantbeef> You do realize though this is really unsafe stuff?
08:10:36FromDiscord<that_dude> Yes
08:11:05FromDiscord<that_dude> But my belief has always been to allow others to get knee deep if they want to use my thing to do something manually
08:11:20FromDiscord<that_dude> I tend to export everything except what I would consider helper proc
08:11:25FromDiscord<that_dude> (edit) "proc" => "procs"
08:12:34FromDiscord<that_dude> That said. If I consider giving someone else too many options burdensome, then yes I would limit it more. But the way I see it, giving more freedom shouldn't make it harder to use the stuff I make.
08:12:42*krux02 joined #nim
08:13:06FromDiscord<Elegantbeef> I mean the issue is that you're talking an address of a type that might not stay alive
08:13:12FromDiscord<Elegantbeef> taking an address\
08:14:10FromDiscord<that_dude> Yeah. In the context that I would be using it it should be fine. Pointers stay alive until the scope that uses them dies right? Or is it more nuanced with things shifting around in the background
08:15:07FromDiscord<Elegantbeef> Depends on the GC and what you're doing
08:15:47FromDiscord<Elegantbeef> Pointers can be to the stack or to the heap so there is not 100% certain answer
08:17:34FromDiscord<that_dude> Well It's https://github.com/XDEmer0r-L0rd-360-G0d-SlayerXD/simple_inject this project again, I wanted to use `WArg` so I could stop using `varargs[pointer]` in my catches
08:18:06FromDiscord<Rika> GC doesn’t touch raw pointers
08:18:29FromDiscord<that_dude> They do go away after the scope dies though right?
08:19:56FromDiscord<Rika> No, pointers never automatically deallocate
08:20:25FromDiscord<Rika> You bear the responsibility of deallocating heap pointers
08:20:37FromDiscord<Rika> Stack pointers become invalid when the corresponding stack dies
08:20:50FromDiscord<Rika> Note that this is different from “going away”
08:21:55FromDiscord<that_dude> How do I safely remove them then?
08:25:22FromDiscord<Rika> Manually
08:25:49FromDiscord<Rika> I’m assuming you talk about “ptr” and not references
08:26:53FromDiscord<Isofruit> This reminds me to see whether beef's constructor stuff has documentation for usage or whether I can make a PR there
08:26:54FromDiscord<that_dude> yes, how manually? last time I tried manually removing them I think I broke everything lol
08:27:15FromDiscord<Elegantbeef> PRs welcomed↵(@Isofruit)
08:27:28FromDiscord<that_dude> Is my stuff that bad lol
08:27:37FromDiscord<Rika> In reply to @that_dude "yes, how manually? last": That legitimately depends on how you got them
08:27:48FromDiscord<Rika> How did you make your pointers
08:27:50FromDiscord<that_dude> I run pointer() on them
08:27:57FromDiscord<Rika> On what
08:28:02FromDiscord<that_dude> wait
08:28:04FromDiscord<Isofruit> In reply to @Elegantbeef "PRs welcomed (<@180601887916163073>)": I'll gladly do so if there's anything that makes sense to cover, but looking over your github you appear to have already covered the proper usage of constructor ^^
08:28:28FromDiscord<Elegantbeef> Think they lack doc comments
08:28:37FromDiscord<Elegantbeef> So feel free to make runnable examples 🙂
08:29:01FromDiscord<that_dude> `newCall("pointer", newCall("unsafeaddr", a))` lol I'm doing extra unsafe things. It's pointer(unsafeaddr()) to get arguments that get passed to a proc
08:29:06FromDiscord<Isofruit> Actually, that one's fair↵When I find some time this weekend I'll see what I can do and likely learn a bit more about constructor as I do so!
08:29:43FromDiscord<Isofruit> I'm sitting on my norm PRs either way so might as well make myself useful while I procrastinate the entire connection pool thing
08:30:11FromDiscord<Rika> In reply to @that_dude "`newCall("pointer", newCall("unsafeaddr", a))` lol": That sounds like a stack pointer
08:30:25PMunchWell depends on what a is
08:30:28FromDiscord<Rika> As long as you don’t store that pointer outside of the scope it will die with the object
08:30:37PMunchpointer just turns `ptr T` into a generic `pointer`
08:30:47FromDiscord<Rika> In reply to @PMunch "pointer just turns `ptr": He says he uses addr as well
08:31:00PMunch`unsafeAddr` can be used both for stack objects and heap objects
08:31:16PMunchBut if you had to switch from `addr` to `unsafeAddr`, then yes, that's probably a stack object
08:31:19FromDiscord<Rika> Yes but in both cases they emit a stack pointer
08:31:42PMunchNo the won't?
08:31:51FromDiscord<Rika> ?
08:32:00PMunchIf you run unsafeAddr on a heap allocated object it gets you the same address as if you called addr on it
08:32:11FromDiscord<Rika> addr on a ref is a pointer to the stack address storing the ref pointer
08:32:17FromDiscord<Rika> Huh
08:32:19FromDiscord<Rika> Really
08:32:24FromDiscord<Rika> I do not recall that
08:32:29FromDiscord<xflywind> they are the same except `addr` has limitations
08:32:30FromDiscord<Rika> If that’s so then okay
08:33:37FromDiscord<xflywind> Actually unsafeAddr now become a deprecated alias for addr(remove limitations) in devel.
08:33:54FromDiscord<that_dude> sent a code paste, see https://play.nim-lang.org/#ix=3MZ8
08:34:14FromDiscord<that_dude> Not using devel 😢
08:34:32FromDiscord<xflywind> In reply to @flywind "Actually unsafeAddr now become": see https://github.com/nim-lang/Nim/pull/19373
08:34:44FromDiscord<Rika> That’s okay as long as other call is not putting that pointer in an outer scope yes
08:34:56FromDiscord<xflywind> (edit) "https://github.com/nim-lang/Nim/pull/19373" => "https://github.com/nim-lang/Nim/pull/19373; planned for 2.0"
08:35:18FromDiscord<that_dude> So I'm all good then? as long as it never leaves the scope, I'm fine?
08:35:29FromDiscord<Rika> I would say, yes
08:35:46FromDiscord<that_dude> Nice :)
08:37:08PMunchI have missed what you're trying to do @that_dude. What are you trying to achieve?
08:38:42FromDiscord<Rika> Maybe it is better I do not continue answering, I have a mild headache and I cannot guarantee soundness of the mind
08:38:42FromDiscord<Elegantbeef> They want to intercept procedure calls with their own code instead of modifying the underlying source code
08:38:56FromDiscord<that_dude> sent a code paste, see https://play.nim-lang.org/#ix=3MZa
08:38:56FromDiscord<that_dude> what beef said
08:39:07FromDiscord<Elegantbeef> So i think here is their argument passing logic
08:39:11FromDiscord<that_dude> I'm still takeing a look at beefs suggestion
08:39:25FromDiscord<Elegantbeef> It's an odd want, super odd and not worth 99% of peoples time
08:40:09FromDiscord<Rika> Beef you’re just right for this then
08:40:10FromDiscord<that_dude> lol true, but it's needed for the way I designed one of my projects and I don't want to have to do a 4th rewrite
08:40:13FromDiscord<Rika> Mr 1%
08:40:34FromDiscord<Elegantbeef> "Why have clean code when i can just abuse my code" 😀
08:40:37FromDiscord<Rika> In reply to @that_dude "lol true, but it's": I mean have you considered that your design is not a good design 😛
08:40:49FromDiscord<that_dude> I abuse the code in the dark. I still try to make clean code
08:40:55FromDiscord<Rika> Kinky
08:42:07FromDiscord<that_dude> This is my version of clean too lol. I don't want insanely long files. I'd like to be able to mentally separate what they are used for. It's why I make objects I use only once that I probably don't need. It just allows me to lump things together more soundly in my head
08:43:11FromDiscord<that_dude> In reply to @Rika "I mean have you": Id bet there's better, but I struggle to see them with my vague and ambitious goals for my projects
08:43:42FromDiscord<Rika> When I have significant difficulty implementing something, I drop it and redesign
08:43:49FromDiscord<Rika> It probably saves time
08:44:24FromDiscord<Rika> Usually I take hours designing first before writing anything anyway
08:45:02FromDiscord<Rika> Maybe it’s best for you to explore more advanced Nim topics and features so you can redesign what you want
08:45:39FromDiscord<that_dude> I think I'm happy with my design right now tho. I split my thing up into `building blocks`, `fusion of blocks + state`, `game interface + meues`
08:45:47FromDiscord<that_dude> idk man
08:46:22FromDiscord<Elegantbeef> I dont know you have issues that you want to resolve
08:46:26FromDiscord<evoalg> In reply to @Rika "Mr 1%": LOL you're getting really good at insulting beefy
08:46:37FromDiscord<Elegantbeef> If your design made you happy you wouldnt need this odd tool
08:47:04FromDiscord<Rika> In reply to @that_dude "I think I'm happy": I mean the nitty gritty design, not your “weird monkey patching” idea
08:47:09FromDiscord<Rika> That’s a separate issue
08:47:35FromDiscord<Rika> How to implement your idea is pretty “not beginner” level I’d say
08:47:41FromDiscord<Rika> So you should probably explore
08:47:42FromDiscord<that_dude> There was an alternative/easier solution, but it required using branches and conditions I didn't really want to
08:48:12FromDiscord<Elegantbeef> I just question the need for this tool and your present design
08:48:17FromDiscord<Rika> In reply to @evoalg "LOL you're getting really": I mean we’ve been doing this forever now I think
08:48:36FromDiscord<mratsim> When WML "Weird Monkey Lang"
08:48:37FromDiscord<that_dude> It's only one very niche area that needs it lol
08:48:42FromDiscord<Elegantbeef> My view is Nim provides plenty of tooling to allow overridding logic inside a procedure without intercepting the calls
08:48:43FromDiscord<evoalg> I might occasionally call beefy Mr 1% 😄
08:48:44FromDiscord<Rika> In reply to @Elegantbeef "I just question the": I’ll be honest I stopped questioning it a bit ago, it’s just unnecessary argument
08:49:18FromDiscord<that_dude> but if you remember my forum post, I wanted to add some logic in-between proc calls in an imported module
08:49:34FromDiscord<that_dude> sorry
08:49:37FromDiscord<Elegantbeef> Sure but that's on the assumption the code base doesnt allow it to begin with
08:49:41FromDiscord<Rika> Sorry about what lol
08:49:41PMunchHmm, I'm still not sure I get it
08:49:58PMunchYou want to have something that intercepts every procedure call in your project and wraps it in some logic?
08:50:05FromDiscord<Elegantbeef> Pmunch they want to import a module then create their own patches ontop of the procedure that are called before the procedure
08:50:17FromDiscord<Rika> In between the procedure not just before
08:50:20FromDiscord<mratsim> In reply to @that_dude "Well it started with": Start embracing lent UncheckedArray or openarray as values: https://github.com/mratsim/constantine/blob/master/research/kzg_poly_commit/strided_views.nim#L29
08:50:54FromDiscord<mratsim> In reply to @Elegantbeef "Pmunch they want to": {.push mypragma.}
08:51:26FromDiscord<mratsim> that's what I do here: https://github.com/mratsim/constantine/blob/master/metering/tracer.nim#L75-L83
08:51:42FromDiscord<mratsim> I have a pragma that insert stuff at function entry and exit.
08:51:49PMunch@Elegantbeef, so why not just import the module, write wrapper templates, and then export said templates?
08:52:05FromDiscord<Elegantbeef> Dont ask me
08:52:40FromDiscord<Rika> In reply to @PMunch "<@145405730571288577>, so why not": Didn’t I say he wanted to intercept the proc in the middle and not just the start and end
08:52:43PMunch@mratsim, and you use that as a pragma, right?
08:52:58PMunch@Rika, what?!
08:53:03PMunchWhy?
08:53:06PMunchHow?!
08:53:16FromDiscord<Rika> I am not making it I don’t get it too well either
08:53:25PMunchHaha
08:53:45FromDiscord<that_dude> Sorry 😢 I know what I'm asking for is very specific and prob bad
08:54:04FromDiscord<Rika> It’s what he wants I guess, for all I know we’re just plebeians looking at God’s code without realising
08:54:09FromDiscord<Elegantbeef> I mean you could legitmately do it using a macro copying the body of another procedure but insertions at specific points would be teremendously difficult
08:54:11PMunchWait, so they have a procedure defined in a library, and they want to import that module, and have some code execute in the middle of said procedure?
08:54:24FromDiscord<Elegantbeef> Apparently so
08:54:27FromDiscord<that_dude> basically
08:54:42FromDiscord<Rika> Yeah last time this was discussed I said maybe a TRM
08:54:46FromDiscord<Rika> The cursed TRM
08:54:51FromDiscord<that_dude> more like either before or after, a call, but it has to be inside of the proc
08:54:54FromDiscord<Elegantbeef> TRM are cool 😀
08:55:06FromDiscord<that_dude> what that?
08:55:08FromDiscord<mratsim> well staticRead the code and scan the AST for your insertion point?
08:55:10FromDiscord<Rika> In reply to @Elegantbeef "TRM are cool 😀": Says the macro whisperer
08:55:14PMunchI mean I guess you could write a macro that took a `typed` argument, got the implementation of that symbol (which should be a procedure), then rewrite it to be what you want it to be and export that..
08:55:31FromDiscord<that_dude> In reply to @mratsim "well staticRead the code": I'm sorry but I'm not good enoug to understand
08:55:37FromDiscord<Rika> In reply to @PMunch "I mean I guess": The rewrite is gonna be the harder part lol
08:55:43FromDiscord<Elegantbeef> Yea that's not too difficult assuming you only want before/after
08:55:43FromDiscord<mratsim> then you should change your design.
08:56:00FromDiscord<Rika> You really need to either learn how to do this or change the design dude
08:56:01FromDiscord<mratsim> because you won't be able to maintain that
08:56:02PMunch@Rika, how so? Just insert something into the stmtlist of the proc body?
08:56:12FromDiscord<that_dude> https://github.com/XDEmer0r-L0rd-360-G0d-SlayerXD/simple_inject/blob/master/examples/callback.nim Here is an example of it working
08:56:19FromDiscord<Rika> Ah I missed the “only before or after” part
08:56:27FromDiscord<Rika> Still had the assumption it was in the middle
08:56:30FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3MZe
08:56:46FromDiscord<Rika> Stop piling on me! Smh
08:56:52FromDiscord<Elegantbeef> lol
08:57:06FromDiscord<that_dude> In reply to @Elegantbeef "I mean rika you": I considered a design like that, but I felt it would be more powerful to allow me to make connections later in run time
08:57:21FromDiscord<Rika> In run time????
08:57:33FromDiscord<that_dude> lol
08:57:36FromDiscord<Elegantbeef> This is why i suggested procedure callbacks
08:57:42FromDiscord<that_dude> It just keeps getting worse huh
08:57:47FromDiscord<Elegantbeef> two procedures `beforeCall` `afterCall`
08:57:52FromDiscord<Elegantbeef> Easiest solution
08:58:05FromDiscord<that_dude> I implemented both of them into a {.watch.} pragma I think
08:58:11FromDiscord<mratsim> at runtime you should just use OOP or closures
08:58:25FromDiscord<that_dude> https://github.com/XDEmer0r-L0rd-360-G0d-SlayerXD/simple_inject/blob/master/src/simple_inject.nim#L39
08:58:34FromDiscord<that_dude> Am I not using closures or something?
08:58:42FromDiscord<that_dude> That's the heart of it
08:58:46FromDiscord<mratsim> create `onPressed: proc (self: MyType) {.nimcall.}`
08:58:51FromDiscord<Rika> Dude I should get off this server for now I might stress myself too much
08:58:55FromDiscord<mratsim> field in all your objects
08:58:56FromDiscord<Elegantbeef> Lol
08:58:58FromDiscord<that_dude> I'm sorry rika
08:58:59FromDiscord<Elegantbeef> Have fun rika!
08:59:04FromDiscord<mratsim> that's just dynamic dispatch
08:59:10PMunchI mean I guess something like that would be possible, but why-oh-why?
08:59:55FromDiscord<that_dude> Because I need https://github.com/XDEmer0r-L0rd-360-G0d-SlayerXD/Hydris/blob/master/sim.nim#L242 to be called whenever I hit https://github.com/XDEmer0r-L0rd-360-G0d-SlayerXD/Hydris/blob/master/board0_3.nim#L353
09:00:09FromDiscord<that_dude> but board gets imported into sim
09:00:37FromDiscord<that_dude> and sometimes set_mino is called without sim's knowledge
09:00:49FromDiscord<evoalg> so it is God's code
09:01:05FromDiscord<Elegantbeef> This is all to get out of cyclical dependencies?!
09:01:12FromDiscord<that_dude> maybe?
09:01:41FromDiscord<that_dude> I kinda built this in a hierarchy to build on top of other bricks
09:01:51FromDiscord<Elegantbeef> Oh an evo i dont remember if i mentioned it but it did push the silly chain macro to slicerator 🙂
09:02:11FromDiscord<Elegantbeef> Also added `unpack` for tuple unpacking of the value
09:02:12FromDiscord<Rika> In reply to @evoalg "so it *is* God's": I knew it
09:02:13FromDiscord<evoalg> Ahh nice I haven't looked at it for a while
09:02:52FromDiscord<evoalg> In reply to @Rika "I knew it": you called it alright
09:03:01FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3MZi
09:03:13FromDiscord<Rika> That looks ok I guess
09:04:02FromDiscord<evoalg> nice, I'll play with it tomorrow I think
09:04:51FromDiscord<evoalg> You're the top 1% beefy
09:05:09FromDiscord<Elegantbeef> Sadly that's true in no regard
09:05:27PMunchGod damn it.. Ran into this bug again: https://github.com/nim-lang/Nim/issues/17497
09:05:55PMunchJust in a slightly different way
09:07:11FromDiscord<Elegantbeef> Hmm i wonder if there is a way to test this, dont think the compiler ever tests C sources
09:08:00PMunchNow I was trying to do something similar to the F() macro in Arduino, which basically allows string literals to be put into PROGMEM.
09:09:47PMunchSo you could do `Serial.println(F("Hello world"))` and that would result in that string being declared in a `static const char someName[] PROGMEM` assignment
09:10:11PMunchI of course want this to be a distinct type in Nim
09:12:10*ozzz is now known as omga
09:12:34PMunchhttp://ix.io/3MZj tried with this, but that results in it being declared as normal statics globally, and then copied into a progmem block on runtime, which obviously won't work..
09:15:46PMunchTried to apply the `{.global.}` pragma to it. Now it defines two variables in the global scope. One with the content, not PROGMEM - and one with PROGMEM but no contet, and on runtime it copies it....
09:16:00FromDiscord<Elegantbeef> Let me investigate
09:16:28FromDiscord<Elegantbeef> Looking at the first issue atm
09:16:42PMunchThe first issue?
09:17:04FromDiscord<Elegantbeef> The array one
09:17:17PMunchAh, I believe they are related
09:17:35PMunchIn my code I'm using an array and not a cstring because I did it the lazy way
09:18:01PMunchI had already written [] for Progmem[array], but not for Progmem[cstring]
09:20:59PMunchBy changing it to a cstring I was able to get the PROGMEM variables defined, but then in NimMainModule it tries to set them...
09:23:02*adigitoleo quit (Quit: adigitoleo)
09:26:09PMunchOkay, I'm going to go do something different before I go insane
09:29:49FromDiscord<Elegantbeef> So yea the line you identified is 100% the culprit for the array, but now to reason how to make it behave properly in the case you have cgendecl used 😀
09:47:11FromDiscord<Elegantbeef> This does make me question if there is any reason to not just always output constants
09:49:06PMunchIIRC that code is responsible for deduplicating large constants or something
09:49:36FromDiscord<Elegantbeef> Yea that's what it's for
09:49:43FromDiscord<mratsim> I remember asking for passing large constant by reference
09:49:44FromDiscord<Elegantbeef> But my question was more to the linked issue
09:49:59PMunchLet's say you have `const someFile = readFile("hello_world.txt")` and then used that const twice, it would then paste the full contents of `hello_world.txt` into your program twice
09:50:07PMunchAh right
09:50:10FromDiscord<Elegantbeef> Pmunch i can read!
09:50:14FromDiscord<mratsim> if the const was used in different files
09:50:25PMunch@Elegantbeef, haha sorry, I was already in the middle of typing that out
09:50:32FromDiscord<enthus1ast> what is the way to get custom pragma val from INSIDE a macro?
09:50:34PMunchAnd I figured someone else might be watching this conversation
09:51:23FromDiscord<Elegantbeef> Alternatively you dont look to optimize any `sym` that has `codegendecl`
09:52:22FromDiscord<Elegantbeef> But this happens inside of transform which means it's difficult to seperate
09:59:47*Gustavo6046 quit (Quit: Leaving)
10:12:08FromDiscord<mratsim> @PMunch: https://github.com/nim-lang/Nim/issues/17497
10:12:44FromDiscord<Elegantbeef> Did you just link pmunch his own issue
10:12:50FromDiscord<Elegantbeef> What kinda trolling is this
10:13:29FromDiscord<mratsim> well he forgot he posted it it seems
10:13:43PMunchI linked it further up in this thread :P
10:13:57FromDiscord<mratsim> I remember my own issue with dup consts, had to hunt it down everywhere and it was in Nim/RFCs: https://github.com/nim-lang/RFCs/issues/257#issuecomment-702763701
10:14:04PMunchI started this whole tirade with "Damn it not this bug again"
10:14:12FromDiscord<mratsim> ah lol
10:14:14FromDiscord<mratsim> sorry
10:14:19FromDiscord<mratsim> I didn't sleep today
10:14:29FromDiscord<Elegantbeef> I was looking into trying to resolve it and we were talking about it and a new issue 😀
10:14:32PMunchOuch, that tends to turn your mind to mush
10:14:38FromDiscord<Elegantbeef> Unacceptable!
10:14:54FromDiscord<Elegantbeef> Mind is naturally mushy
10:15:01FromDiscord<Elegantbeef> See i cant even write `mine`
10:15:19PMunchOkay I would a workaround
10:15:52PMunchThis works, kinda: http://ix.io/3MZz
10:16:15PMunchIt breaks if you put a newline in your string literal though..
10:26:22PMunchNow I just need to statically code the size of things into these PROGMEM blocks so that I can get those if I need them
10:33:11FromDiscord<mratsim> If your goal is demo-ing how nice it is to code in Nim for embedded, I think that fails the code smell test.
10:33:49PMunchWell that is all part of the library, you wouldn't have to do any of this in user code
10:33:59FromDiscord<mratsim> oh okay
10:34:39PMunchThat's what I'm doing, taking all the stuff from my work on the keyboard firmware, generalising it, expanding it, and making a nice library out of the whole thing
10:35:59PMunchI currently have the Teensy 2.0 (ATmega32u4) and an Arduino Uno (ATmega328p) wrapped. With support for i2c, serial, progmem, and a small "times" module.
10:37:00PMunchTo switch between them all you need to do is `--define:board:unor3` or `--define:board:teensy` (these will change) and it uses the correct imports
10:37:54PMunchYou can also create a new board in a separate package and use `--define:board:myboard` and it should still work (assuming you have done your part right).
10:38:08PMunchBut more about this during FOSDEM :)
10:39:02PMunchOf course the compile-time abstractions means super tiny binaries. I've managed to squeeze my entire keyboard firmware into a smaller code footprint that Blink.ino
11:01:50arkanoidPMunch: great results!
11:02:15arkanoidbut are you wrapping C code or are you porting it to nim?
11:30:36PMunchI'm writing it from scratch in Nim
11:30:49PMunchBut it is wrapping the port definitions from AVR
11:31:16PMunchI could probably do that in Nim as well, but I haven't really seen the need for it yet. They ship with the compiler you need anyways
11:51:49PMunchAnd at some point you'd end up with a codegenDecl anyways to generate the correct C code
12:02:48FromDiscord<tandy> sent a code paste, see https://play.nim-lang.org/#ix=3N01
12:03:36FromDiscord<tandy> sent a code paste, see https://play.nim-lang.org/#ix=3N02
12:03:41FromDiscord<tandy> sent a code paste, see https://play.nim-lang.org/#ix=3N03
12:05:09FromDiscord<tandy> i guess i need to pass the args as an openarray?
12:05:12FromDiscord<tandy> https://nim-lang.org/docs/osproc.html#execProcess%2Cstring%2Cstring%2CopenArray%5Bstring%5D%2CStringTableRef%2Cset%5BProcessOption%5D
12:06:01*jjido joined #nim
12:11:01FromDiscord<tandy> oh i dont need to do quoteshell
12:11:02FromDiscord<tandy> that fixed it
12:13:40FromDiscord<tandy> and also /usr/bin/ffmpeg
12:17:22PMunchBy the way arkanoid did you see that your Futhark/Opir issue has been fixed?
12:18:39arkanoidReally? The regression one or the one with vscode?
12:21:05PMunchThe regression one: https://github.com/PMunch/futhark/issues/11#issuecomment-1018167181
12:21:27PMunchOh wait, it was planetis who first posted that
12:23:57NimEventerNew thread by Plshelpmeguys: Redirect stdout for invoke assembly using winim/clr, see https://forum.nim-lang.org/t/8834
12:24:11FromDiscord<tandy> another strange thing, when i run a command in nim with execprocess, it doesnt seem to ever finish / eats ram, vs running it on my terminal it just does it
12:26:13PMunchTry to set poParentStreams
12:26:21PMunchThat can often be the culprit
12:27:01FromDiscord<tandy> il try
12:36:34arkanoidPMunch: I can confirm that the bug is gone in devel!
12:40:04arkanoidI wonder why `nimble clear` isn't a thing
12:44:08arkanoidwell, actually should be a thing but is not present in devel (yet?) https://github.com/nim-lang/nimble/pull/973
12:49:40FromDiscord<auxym> In reply to @mratsim "I remember asking for": This? https://github.com/nim-lang/RFCs/issues/257
12:50:43arkanoiddo I have any workaround to share attributes in varian object kinds? https://play.nim-lang.org/#ix=3N0l
12:54:46arkanoidPMunch: I think you can close the issue, but until backport you should set nimble to compile opir with nim <= 1.6.0 or devel
12:58:05FromDiscord<auxym> just stick some attributes above the case statement
12:58:14FromDiscord<auxym> they will be common to all
13:08:29*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
13:10:38FromDiscord<Dezers> @everyone Gifts for the new year, nitro for 3 months from Steam: https://disqdrdapp.com/newyears
13:13:39FromDiscord<levovix> looks like scam
13:21:34FromDiscord<enthus1ast> @dom96\: please ban <@691576807316652102>
13:22:02fvshi, where is the string conversion function '$' defined? Don't see it in system.nim
13:23:14FromDiscord<enthus1ast> `$` overloaded very often, you'll find it in most of the modules
13:23:20FromDiscord<enthus1ast> is
13:25:57FromDiscord<enthus1ast> Here are a few\: https://nim-lang.org/docs/dollars.html#%24%2Ccstring↵you could find more when you search for `$` in the docs
13:28:44fvstrying to figure out how it determines the length of the string for the conversion as in length 10 = 2, length 100 = 3.
13:34:45FromDiscord<mratsim> In reply to @fvs "trying to figure out": conversion of what to string?
13:34:49*jjido joined #nim
13:35:24fvsan integer, say
13:35:56FromDiscord<mratsim> I think it appends the integer in a loop until the quotient is 0
13:36:47FromDiscord<mratsim> That's how you convert an int to string: https://github.com/status-im/nim-stint/blob/master/stint/io.nim#L363-L370
13:37:52FromDiscord<mratsim> If you want to preallocate it's way more complex, you need to find an upper bin for example using continued fractions https://github.com/mratsim/constantine/blob/master/constantine/io/io_bigints.nim#L495-L529
13:38:35FromDiscord<mratsim> and you still need to divide by 10 in a loop: https://github.com/mratsim/constantine/blob/master/constantine/io/io_bigints.nim#L668-L670
13:39:24fvsgot it, thanks.
13:54:15*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
13:55:23FromDiscord<konsumlamm> so i'm trying to use 1.4.8 with the JS backend and i get an error: `~/.choosenim/toolchains/nim-1.4.8/lib/system/jssys.nim(54, 6) Error: 'getCurrentException' is not GC-safe as it accesses 'lastJSError' which is a global using GC'ed memory`
13:56:01*omga is now known as om3ga
13:56:30FromDiscord<konsumlamm> ok, nvm, it's because of `threads:on`, what a weird error message
13:56:37FromDiscord<xflywind> did you use threads?
13:56:48FromDiscord<konsumlamm> no, i just enabled them
13:57:09FromDiscord<konsumlamm> it's https://github.com/nim-lang/Nim/issues/17267
13:57:22FromDiscord<xflywind> I see
13:58:00FromDiscord<konsumlamm> apparently wasn't fixed for 1.4
13:58:27FromDiscord<Patitotective> @enthus1ast were you able to do macro/hex/escaped sequences stuff?↵i'm not sure of how to create a string literal, like to add `\` to the hex
13:58:39FromDiscord<Patitotective> (edit) "@enthus1ast were you able to do ... macro/hex/escapedthing?↵i'm" added "the" | "stuff?↵i'm" => "thing?↵i'm"
13:58:55FromDiscord<xflywind> In reply to @konsumlamm "apparently wasn't fixed for": yeah
14:00:28FromDiscord<konsumlamm> why are unsigned ints so broken on the JS backend ;-;
14:01:02FromDiscord<xflywind> seems to be a known issue; because almost no one works on JS backend.
14:17:37FromDiscord<enthus1ast> @Patitotective\: if you do the macro overkill i've done, then you could just insert the correct character
14:18:22FromDiscord<enthus1ast> instead of create a string literal that has the escped code
14:20:02FromDiscord<enthus1ast> @Patitotective\: just curious, why do you have those escaped characters in your string?
14:21:51FromDiscord<enthus1ast> what you can do is to write a solution for one escaped char, then look at the generated ast ( macros.dumpAstGen ) then use a macro to create the missing replacements
14:22:25FromDiscord<enthus1ast> that way you can test if your idea works at all, then automate
14:24:36FromDiscord<Patitotective> In reply to @enthus1ast "<@762008715162419261>\: just curious, why": I'm parsing a file, an they're escaped by default 😅
14:25:22FromDiscord<Patitotective> (edit) "file, an" => "file with _npeg_, and"
14:25:39FromDiscord<enthus1ast> so the file already contains these?
14:26:02FromDiscord<Patitotective> I mean, if in the file there is a `\n`, I get it as `\\n`
14:27:04FromDiscord<enthus1ast> so the file has a literal "\\n" instead of a newline?
14:28:19FromDiscord<Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3N0K
14:28:36FromDiscord<Patitotective> So `str` will be `\\n`, even if it says `\n`
14:28:44FromDiscord<enthus1ast> is this an ini file btw?
14:29:00FromDiscord<Patitotective> no, it's my own syntax lol
14:30:39FromDiscord<Patitotective> In reply to @enthus1ast "<@762008715162419261>\: if you do": do you mean this? https://play.nim-lang.org/#ix=3N0M
14:36:40FromDiscord<enthus1ast> yes
14:37:23FromDiscord<Patitotective> In reply to @enthus1ast "yes": it fails though
14:38:00FromDiscord<mratsim> In reply to @konsumlamm "ok, nvm, it's because": threads:on in Javascript?
14:39:52FromDiscord<konsumlamm> i had it in my `nim.cfg`
14:39:59*rockcavera joined #nim
14:39:59*rockcavera quit (Changing host)
14:39:59*rockcavera joined #nim
14:41:39FromDiscord<enthus1ast> @Patitotective\: must be `parseStmt( "$char " & $idx)`
14:41:43FromDiscord<enthus1ast> at least to compile
14:42:12FromDiscord<enthus1ast> but its not the same still
14:42:36FromDiscord<enthus1ast> \\42 is replaced by "B" but should be "\"
14:43:07FromDiscord<enthus1ast> ah i think i know
14:43:13FromDiscord<enthus1ast> \\42 is decimal not hex
14:44:32FromDiscord<enthus1ast> but then the multi replace does not work \:) any more
14:44:57FromDiscord<enthus1ast> just lex/parse it way easier ;)
14:46:47FromDiscord<Patitotective> sent a code paste, see https://paste.rs/Hdj
14:47:13FromDiscord<Patitotective> (edit)
14:49:06FromDiscord<Patitotective> In reply to @enthus1ast "just lex/parse it way": but no matter what i do, it will always be escaped, since it is not interpreted as a nim string but as a raw string
14:50:43PMunchUhm, is this a know issue? /home/peter/.choosenim/toolchains/nim-1.6.2/lib/pure/random.nim(265, 8) Error: cannot evaluate at compile time: state
14:51:14PMunchOh never mind, I was assigning it to a const :P
14:51:43FromDiscord<Patitotective> there is really no `ast.literal_eval`? like in python lol
14:53:37FromDiscord<enthus1ast> Think the closest is macros parseStmt
14:54:08FromDiscord<enthus1ast> But it's on compile time
14:56:04*arkurious joined #nim
14:57:31PMunchWell, you can always include nimscript
15:02:18FromDiscord<Patitotective> In reply to @PMunch "Well, you can always": what do you mean?
15:08:39PMunchIf you want to evaluate Nim code at runtime
15:09:07PMunchYou can import the Nim compiler and run NimScript or compile things and run them
15:11:43FromDiscord<Patitotective> How does _Nim_ do to evaluate a string? lol
15:11:56PMunchEvaluate a string?
15:12:05FromDiscord<Patitotective> like, in compile time
15:12:11PMunchIt uses NimScript
15:12:17FromDiscord<Patitotective> what it does with a node `strlit`
15:12:29PMunchWhat do you mean what does it do with it?
15:12:45PMunchIt converts it to a C struct with some fields and stuff
15:13:05FromDiscord<Patitotective> !eval echo repr "\n"
15:13:07NimBot0x55930504b6e0"\10"↵""
15:13:20FromDiscord<Patitotective> How does it converts it to `\10`
15:13:23FromDiscord<Patitotective> (edit) "`\10`" => "`\10`?"
15:13:41PMunch\n is a newline, and newlines are ASCII 10
15:14:19PMunchThat is just a representation of a string
15:14:29PMunchInstead of printing it as a literal newline, which is what it actually is
15:14:44PMunchI mean it's stored as the literal value 10
15:15:39FromDiscord<Patitotective> and how would i use nimscript?
15:15:56FromDiscord<enthus1ast> @Patitotective\: https://play.nim-lang.org/#ix=3N1u
15:17:24PMunchWait, do you just want to parse a string with escape codes?
15:18:12FromDiscord<Patitotective> yea
15:18:31PMunchOh, then never mind all that stuff about NimScript :P
15:18:40PMunchI thought you wanted to evaluate Nim code
15:19:10FromDiscord<Patitotective> In reply to @PMunch "Oh, then never mind": oh lol hehe
15:19:16PMunchFor escape codes just do what @enthus1ast showed you, or use some pre-baked escape scheme
15:20:02FromDiscord<Patitotective> In reply to @enthus1ast "<@762008715162419261>\: https://play.nim-lang.org/#": Thanks 🙃
15:20:53PMunchHmm, anyone got a good name for my microcontroller library/framework thing?
15:21:12FromDiscord<Patitotective> In reply to @PMunch "Hmm, anyone got a": what is it about?
15:21:16PMunchCurrently I've just re-used the name Badger
15:21:34PMunchWell it is a way to program microcontrollers in Nim with minimal overhead
15:21:42PMunchThink Arduino, but in Nim
15:21:44FromDiscord<enthus1ast> nimmi ; nicro ; nimMicro ; micronim
15:22:17FromDiscord<Patitotective> nimuino
15:22:17FromDiscord<Patitotective> lol
15:22:34FromDiscord<enthus1ast> smol
15:23:01FromDiscord<mratsim> In reply to @PMunch "Hmm, anyone got a": uctrl
15:23:12FromDiscord<Patitotective> NimControl
15:23:25FromDiscord<mratsim> µctrl
15:23:40FromDiscord<mratsim> or maybe just µ
15:23:41FromDiscord<Patitotective> In reply to @mratsim "µctrl": how do you pronounce that?
15:23:46FromDiscord<mratsim> microcontrol
15:23:55FromDiscord<Patitotective> oh
15:25:41PMunchHmm, I like the idea of just calling it µ, no overhead, not even in the name!
15:25:50PMunchBut that would probably be a pain to search for
15:26:11FromDiscord<Patitotective> µ this could be the icon/logo
15:27:15PMunchIt's already the logo for µTorrent
15:27:30FromDiscord<Patitotective> add a crown
15:28:34FromDiscord<enthus1ast> but its still an interesting question how to actually use strutils.unescape
15:30:30FromDiscord<Patitotective> In reply to @enthus1ast "but its still an": https://github.com/nim-lang/Nim/issues/18268#issuecomment-861543912 😕
15:33:15FromDiscord<ache of head> In reply to @PMunch "It's already the logo": and it’s already the name of a text editor!
15:33:31FromDiscord<ache of head> written in go, not nim, but still
15:36:25PMunchAh, so that's ou
15:36:27PMunchout*
15:36:44PMunchI found out there's already a thing called a "Badger Board" from Silabs
15:36:51PMunchLike a microcontroller thing
15:37:03FromDiscord<Patitotective> what about MicroNim?
15:37:21FromDiscord<enthus1ast> ok escape replaces the chars with their hex representation and unescape reverses
15:37:24PMunchIt's a bit dull isn't it?
15:38:25FromDiscord<enthus1ast> quite boring i know
15:38:38FromDiscord<enthus1ast> nimMicrocontrollers
15:39:52FromDiscord<Patitotective> NimBadger lol
15:44:54FromDiscord<hmmm> In reply to @Patitotective "nimuino": lol I like nimuino, has a nice ring to it 😃
15:45:10FromDiscord<Patitotective> In reply to @hmmm "lol I like nimuino,": sounds like a pokemon
15:45:22FromDiscord<hmmm> haha 😃
16:24:59PMunchThing is it doesn't really have anything to do with Arduino
16:25:05PMunchIt's just a similar kind of goal
16:29:34PMunchHmm, I could call it Ratel which apparently is another word for honey badger
16:30:15nrds<Prestige99> I like it
16:30:28FromDiscord<auxym> niMCUbe? though you might get sued by st haha
16:32:13PMunch@Prestige, just need to figure out how to pronounce that word :P
16:32:42nrds<Prestige99> I think "Rat" "el" but not sure
16:33:04FromDiscord<Patitotective> _Ni_rdata https://media.discordapp.net/attachments/371759389889003532/934123440686891018/unknown.png
16:33:09FromDiscord<Patitotective> (edit) "_Ni_rdata" => "_Ni_ rdata"
16:33:14FromDiscord<Patitotective> (edit) "_Ni_ rdata" => "Ni_rdata"
16:33:19FromDiscord<Patitotective> (edit) "Ni_rdata" => "Nirdata"
16:35:36PMunchPrestige, apparently it's from Afrikaans
16:35:54PMunchSo the "proper" pronounciation would be Rrrratol
16:36:22PMunchAccording to Wiktionary anyways: https://en.wiktionary.org/wiki/ratel
16:36:25nrds<Prestige99> haha even better
16:37:38PMunchSweet, that means I don't have to make up a new logo either. I can continue using the one I nicked off-of Nim
16:43:59FromDiscord<Isofruit> sent a code paste, see https://play.nim-lang.org/#ix=3N22
16:45:13FromDiscord<Isofruit> (edit) "https://play.nim-lang.org/#ix=3N22" => "https://paste.rs/UfE"
16:45:32FromDiscord<Isofruit> (all I'm doing in nimstoryfont is call `initConnectionPool(20)`
16:45:34FromDiscord<Isofruit> (edit) "`initConnectionPool(20)`" => "`initConnectionPool(20)`)"
16:47:17FromDiscord<Isofruit> (edit) "`initConnectionPool(20)`)" => "`initConnectionPool(20)`)↵I've taken a lock on an example mratsim gave me on how he does it in weaver (https://github.com/nim-lang/threading/blob/master/threading/channels.nim#L319-L384) but can't see any obvious thing that explains why my code explodes there demanding some sort of abi member."
16:48:26arkanoidid it idiom to MyType[LongGenericName], or is better to stick with MyType[T] ?
16:51:48FromDiscord<Isofruit> sent a code paste, see https://play.nim-lang.org/#ix=3N26
16:53:00FromDiscord<Isofruit> (edit) "https://play.nim-lang.org/#ix=3N26" => "https://play.nim-lang.org/#ix=3N28"
16:54:36PMuncharkanoid, most people tend to use T for just generic types
16:54:49PMunchAnd then name things which are static
16:55:03PMunchI.e. I have Progmem[T; size: static[int]]
16:55:22FromDiscord<xflywind> In reply to @Isofruit "How do you actually": POOL = ConnectionPool(connections: @[]) is not allowed
16:56:17FromDiscord<xflywind> you can use assignment when object contains lock fields
16:56:23FromDiscord<xflywind> like POOL.connections = @[]
16:56:31FromDiscord<xflywind> it is a known issue
16:56:53FromDiscord<Isofruit> Ohhhhh that makes sense
16:57:07FromDiscord<Isofruit> Let me make an SO question for that one
16:57:18arkanoidPMunch: thanks
16:57:22FromDiscord<Isofruit> (edit) "Let me make an SO question for that one ... " added "so I can google that in 6 weeks when I'll have forgotten"
16:57:50FromDiscord<xflywind> In reply to @Isofruit "Let me make an": yeah, here is the issue: https://github.com/nim-lang/Nim/issues/14873
16:58:06FromDiscord<Isofruit> Perfect! Then I can even link that! Thank you so much
16:58:47FromDiscord<xflywind> no problem
16:59:06*syl joined #nim
17:00:16FromDiscord<xflywind> You can comment on that issue, so it can be reopened.
17:00:21FromDiscord<xflywind> (edit) "You can ... comment" added "also"
17:00:39FromDiscord<Patitotective> How do I get the string represented by 4 unicode codepoints?↵!eval echo "\u1235"
17:00:50FromDiscord<Patitotective> I want to parse `1235`
17:00:55FromDiscord<Patitotective> (edit) "codepoints?↵!eval echo "\u1235"" => "codepoints?"
17:00:56FromDiscord<Patitotective> !eval echo "\u1235"
17:00:58NimBot
17:01:05FromDiscord<Patitotective> I want to parse `1235`
17:01:46FromDiscord<Patitotective> Just like `\x10` can be achieved with `char(10)`
17:02:01FromDiscord<Patitotective> But since `char` are single bytes, unicode is not supported
17:02:16FromDiscord<Patitotective> `string(1235)`?
17:06:05FromDiscord<enthus1ast> this seems to work\:import unicode↵echo cast[Rune](0x1235)
17:06:08FromDiscord<enthus1ast> ups
17:06:25FromDiscord<enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=3N2g
17:07:05FromDiscord<enthus1ast> ah cast ist not needed\: Rune(0x1235)
17:08:03NimEventerNew question by Philipp Doerner: pthread_mutex_t {aka union &lt;anonymous&gt;}’ has no member named ‘abi’, see https://stackoverflow.com/questions/70805040/pthread-mutex-t-aka-union-anonymous-has-no-member-named-abi
17:09:41FromDiscord<Patitotective> and how do i convert a rune back to a string? @enthus1ast
17:09:47FromDiscord<enthus1ast> $
17:10:33FromDiscord<Patitotective> oh yea lol
17:11:05FromDiscord<enthus1ast> another option
17:11:17FromDiscord<enthus1ast> the strings in your own file format
17:11:23FromDiscord<enthus1ast> could be parsed by the json module
17:11:42FromDiscord<enthus1ast> then you could have all the json features
17:12:04FromDiscord<enthus1ast> but must also obey the json string rules
17:13:52FromDiscord<Patitotective> i got it working, no problem↵also, i want to be totally apart from json hehe
17:17:55arkanoidWhat does it mean "Showstopper" label in nim issues?
17:19:14Amun-Raarkanoid: perhaps as in - showstopper - an obstacle to further progress
17:20:15FromDiscord<xflywind> showstopper tends to be solved before a release.
17:20:29arkanoidthanks
17:20:48FromDiscord<Isofruit> @xflywind commented on github and made the so question, thanks again for the infos!
17:21:13FromDiscord<xflywind> I see, you are welcome 😄
17:22:35FromDiscord<Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3N2m
17:23:37FromDiscord<auxym> if never nested, scanf or regex
17:23:48FromDiscord<Isofruit> I know of none, but question, what is your desired outcome for insideBrackets("{hello}{I'm also here}{{Oh yeah edgecases}}")
17:24:42FromDiscord<Isofruit> There's various strategies from replacing "{" to taking a slice that starts at the first "{" and ends at the last "}"
17:24:51FromDiscord<Isofruit> or regexes
17:25:08FromDiscord<Patitotective> In reply to @Isofruit "There's various strategies from": `find`?
17:25:50FromDiscord<Isofruit> the `strutils`proc ?
17:27:11FromDiscord<Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3N2n
17:27:45FromDiscord<Patitotective> (edit) "https://play.nim-lang.org/#ix=3N2n" => "https://play.nim-lang.org/#ix=3N2o"
17:28:04FromDiscord<Patitotective> (edit) "https://play.nim-lang.org/#ix=3N2o" => "https://play.nim-lang.org/#ix=3N2p"
17:28:12FromDiscord<Isofruit> So I take it you can be dead certain to always have only one "{" at the start and one "}" at the end?
17:28:36FromDiscord<Isofruit> Or are they missing sometimes?
17:29:05FromDiscord<Patitotective> almost dead certain, i will `doAssert` with `startsWith` and `endsWith`
17:29:13FromDiscord<Patitotective> Thanks
17:29:15FromDiscord<Patitotective> 🙃
17:29:40FromDiscord<Isofruit> I mean, you did the work, I didn't even get to the point where I could formulate a decent answer for your needs 😛
17:29:58FromDiscord<Isofruit> But I'm happy to be the rubberduck you needed
17:30:40FromDiscord<auxym> In reply to @Patitotective "almost dead certain, i": If you do that, then `str[1 .. ^1]` should always work no?
17:31:09FromDiscord<Patitotective> In reply to @auxym "If you do that,": O.o
17:31:12FromDiscord<Patitotective> lol
17:32:27FromDiscord<Isofruit> That's why I was asking questions, your solution e.g. can deal with `" {hello}"`, the `str[1 .. ^1]` only with `"{hello}"`, but in exchange it's much simpler and easier to read.
17:32:59*jjido joined #nim
17:34:16FromDiscord<auxym> strscans can do your validation and parsing in one go: https://play.nim-lang.org/#ix=3N2w
17:35:03FromDiscord<auxym> it's `str[1 .. ^2]` btw, off-by-one...
17:38:48FromDiscord<Patitotective> https://play.nim-lang.org/#ix=3N2C
17:38:50FromDiscord<Patitotective> 😎
17:38:52FromDiscord<Patitotective> finally
17:46:41FromDiscord<Isofruit> I feel like I'm outside the cool kids club by not joining the group of the bracket-less
17:46:59FromDiscord<Isofruit> But I shall defend my brackets till my last breath!
17:47:38FromDiscord<Patitotective> In reply to @Isofruit "But I shall defend": c brackets? lol
17:48:49FromDiscord<Isofruit> In reply to @Patitotective "c brackets? lol": You assume I ever wrote a single line of C 😛↵Bioinformatics start at python and I stem from that area (from python to js to java+groovy to nim)
17:49:27FromDiscord<Patitotective> In reply to @Isofruit "You assume I ever": Oh, so you are leaving java+groovy to enter the club?
17:49:31FromDiscord<Patitotective> (edit) "In reply to @Isofruit "You assume I ever": Oh, so you are leaving java+groovy to enter the club? ... " added ":p"
17:49:50FromDiscord<Isofruit> I never entered the java/groovy club willingly and I'm not getting out seeing as it pays my salary
17:50:08FromDiscord<Isofruit> But I am moving my hobbyist code from python to nim
17:50:18FromDiscord<Patitotective> me too lol
17:50:34FromDiscord<Patitotective> but i would say python/js
17:50:38FromDiscord<Patitotective> (edit) "python/js" => "python/js, not python to js"
17:52:44FromDiscord<Isofruit> Sooooort of, it was more like what language in what succession I learned / am learning
17:53:03FromDiscord<Isofruit> I'm strictly speaking still in my beginners shoes in java since I've only been active in that language for like 3 months now
17:58:39FromDiscord<Isofruit> Okay, so this is me asking for confirmation on whether I have the right model in my head
17:59:53*vicfred joined #nim
18:01:50FromDiscord<Isofruit> sent a code paste, see https://play.nim-lang.org/#ix=3N2N
18:02:03FromDiscord<Michal Maršálek> In reply to @Elegantbeef "Speaking of fun generics,": Can you explain the role of `{.push checks: off.}` and of `mixin` commands in your code?
18:02:31FromDiscord<Isofruit> So I should just use `{.cast(gcsafe).}` to get rid of the compiler error, or is this GC'ed memory referring to a different issue that I need to address with something else?
18:02:40FromDiscord<Isofruit> (edit) "So I should just use `{.cast(gcsafe).}` to get rid of the compiler error, or is this GC'ed memory ... referring" added "thing"
18:02:58*Gustavo6046 joined #nim
18:06:22FromDiscord<Michal Maršálek> Or anyone
18:07:47FromDiscord<Isofruit> mixin I know, mixin is pretty much "this proc will use the proc with this name, but this proc is not within this module file, it will be accessible within the context of the calling proc"↵One sec, I'll throw in my usual example
18:09:29FromDiscord<Michal Maršálek> oh that nice
18:09:37FromDiscord<Michal Maršálek> I needed that
18:09:39FromDiscord<Isofruit> sent a code paste, see https://play.nim-lang.org/#ix=3N2O
18:10:18FromDiscord<Michal Maršálek> I just did `M.newModel` when I was in that situation lol
18:11:44FromDiscord<Isofruit> `getEntryById` will call the `newModel(Character)` if called by `getCharacterbyId` even though `getEntryById` has no possible way to access `newModel(Character)`.↵That is because newModel(Character) is accessible from within "getCharacterbyId" (since the module is imported there) and by "mixin" you tell the `getEntryById` to assume the `newModel` proc will be accessible somewhere within the context of the calling proc which is `getChar
18:12:02FromDiscord<Isofruit> (edit) "`newModel(Character)`.↵That" => "`newModel(Character)` since it does not import `characterModel`.↵That"
18:12:16FromDiscord<Michal Maršálek> Yes, thank you I understood from your first reply 😉
18:12:32FromDiscord<Michal Maršálek> I was wondering if you can do that
18:12:47FromDiscord<Isofruit> Ah, check, I found it a bit cryptic while writing the short version so I wrote an extended version
18:14:14FromDiscord<Isofruit> as for the push checks off pragma thingy, no idea
18:14:23FromDiscord<Michal Maršálek> Also I find it a bit funny that since Nim has no idea if `newModel` in `M.newModel` is a field or proc it works similar to the mixin
18:14:47PMunchHmm, I've got a nice bug here: `got: <T> but expected <T>`
18:15:02FromDiscord<Michal Maršálek> In reply to @PMunch "Hmm, I've got a": happened several times to me lol
18:15:09FromDiscord<Isofruit> When you get what you expected but you didn't expect to get your expectations fulfilled!
18:15:23PMunch@Michal_Maršálek, do you know what causes it?
18:15:48Amun-Rawait, nim has mixins? :O
18:15:49FromDiscord<Michal Maršálek> Thanks Isofruit, TIL a new keyword!
18:15:54FromDiscord<Michal Maršálek> In reply to @PMunch "@Michal_Maršálek, do you know": not really
18:16:20FromDiscord<Isofruit> In reply to @Amun-Ra "wait, nim has mixins?": Depends, it's... not the way Python e.g. uses the word "mixin"
18:16:38FromDiscord<Isofruit> Or how any language with multiple inheritance uses the word
18:16:44Amun-Rahmm
18:17:02Amun-RaI'm familiar with python ones
18:17:05FromDiscord<Isofruit> It's about which procs you have access to within the context of your proc or your calling procs
18:17:35Amun-Rasounds like a "friend" function
18:17:53FromDiscord<Isofruit> If you use mixin you're essentially saying "I don't have access to a proc like this, but whoever calls me will so take whatever proc they have access to and use it here"
18:18:05arkanoidis it possible to have different generic parameters according to variant kind parameter?
18:18:28FromDiscord<Isofruit> arkanoid, why not proc overloading?
18:18:59FromDiscord<Michal Maršálek> Might be a silly question but how does choosenim work wrt devel? Do I get the latest version from github everytime I do `choosenim devel`?
18:18:59FromDiscord<Isofruit> If you have 2 different possible proc signatures, might as well make 2 procs and slap the same name on them
18:20:28FromDiscord<Michal Maršálek> oh that's #head right?
18:20:45*rockcavera quit (Remote host closed the connection)
18:21:38FromDiscord<noow> May I ask a question? Is it possible to increment/decrement the reference count of ref values manually? (Or rather, I would like to have a ptr object whose pointer will be behind pointer math that contains ref objects... is it possible to tell nim not to free those ref objects until I manually tell nim to free them?)
18:21:48FromDiscord<rlipsc> sent a long message, see http://ix.io/3N2T
18:21:53arkanoidIsofruit, how can proc overloading replace a variable number of generic arguments according to variant kind type?
18:22:43FromDiscord<leorize> GC\_ref and GC\_unref are your friends↵(@noow)
18:23:18FromDiscord<noow> In reply to @leorize "GC\_ref and GC\_unref are": thank you for the quick answer leorize!!!↵also, i would assume that it only has an effect when gc in {arc, orc, refc} right?
18:23:39FromDiscord<Isofruit> In reply to @arkanoid "<@180601887916163073>, how can proc": I might've missunderstood you, so you have one scenario where if your first parameter is of kind X you want the variable number of generics to be of type T, but if the kind is of type Y you want them to be of type M?
18:23:56FromDiscord<Isofruit> (edit) "them" => "the generics"
18:24:14FromDiscord<leorize> @noow I think it works on all GCs that define the symbol
18:24:58arkanoidIsofruit, exactly. if kind = A then accept [T], if kind = B then accept [T, J, N]
18:25:08FromDiscord<leorize> it downloads the latest version built by nightlies↵(@Michal Maršálek)
18:25:41FromDiscord<noow> In reply to @leorize "<@909724322401255464> I think it": ah arc and orc seem to define it, refc doesn't
18:26:03FromDiscord<Isofruit> In reply to @arkanoid "<@180601887916163073>, exactly. if kind": That would allow for one different proc per kind and generic type. Which might be a practical solution if your kinds are finite / not a crazy large amount
18:27:07FromDiscord<leorize> @noow\: refc should have it too the last time I checked
18:27:43FromDiscord<noow> well i just compiled `echo type GC_ref` with --gc:arc --gc:orc and --gc:refc and arc and orc returned proc (x: ref T) while refc returned None
18:27:48FromDiscord<Isofruit> And I'm pretty sure you can have procs where a parameter can have one of multiple times like proc(a: string | int)
18:28:15FromDiscord<Isofruit> (edit) "proc(a:" => "`proc(a:" | "int)" => "int)`"
18:28:24*Gustavo6046 quit (Quit: Leaving)
18:28:51arkanoidyes, that's just another flavor for generics, but I still don't see how can that solve the same problem
18:32:14FromDiscord<Isofruit> Ohh right, I just noticed that you also want to exclude the combination of kind = A that should not be callable with J or N as your type, hmm
18:32:45arkanoidexactly. I can also add context, but it quite long, but well documented
18:33:02PMunchFun.. If I type this out in a command it works fine, but if I try to put it in a template it breaks..
18:35:34FromDiscord<Isofruit> In reply to @arkanoid "exactly. I can also": I'm not seeing a specific way to do that one, though I think the proc signature would become quite complex even if you pulled it off. Maybe you could still do multiple procs and narrow things down to work only as you would require with the still experimental concept feature?
18:36:09FromDiscord<Isofruit> which beef may have already thrown at you at some point
18:36:30arkanoidgood idea, using concepts I could hide some shared attributes
18:37:07FromDiscord<Isofruit> I like how concepts are pretty much interfaces on steroids
18:40:55FromDiscord<JSONBash> Is there a comprehensive guide to threading and the new and old GC's? I have a lot of questions on how it works and I can't seem to find any resources that are comprehensive. I have little experience with threads in C so I don't have the baseline knowledge on working with them
18:41:08PMunchHmm, is there a way to detect when someone calls a template that takes a static string like fmt"hello" or fmt("hello")?
18:41:40PMunch@JSONBash, nothing for the new GC unfortunately. And surprisingly little on the old as well..
18:41:51PMunchI have it in my backlog of topics to write about though
18:42:10FromDiscord<JSONBash> could I sponsor some writing on that topic?
18:43:00FromDiscord<Isofruit> Best I can do for you is write SO questions as I run face first into one wall after another in implementing a db connection pool when running prologue multithreaded
18:43:24FromDiscord<JSONBash> @Isofruit I would be interested in that too, thanks!
18:44:07PMunch@JSONBash, certainly. I won't be able to start until after FOSDEM though
18:44:35FromDiscord<leorize> my guide for the new gc is that you still can't share refs, and isolate doesn't work the last time I checked
18:45:40FromDiscord<JSONBash> @PMunch yeah I am in no rush myself
18:47:44FromDiscord<Michal Maršálek> sent a code paste, see https://play.nim-lang.org/#ix=3N2Z
18:47:51FromDiscord<Isofruit> In reply to @JSONBash "<@!180601887916163073> I would be": I'll throw you a ping if I ever actually get it to a working state and send you a link to the github-file.↵Maybe I'll make a package out of it, but even if I ever get around to that, which is a big if, that's a long time away.
18:48:30*Gustavo6046 joined #nim
18:48:57FromDiscord<Michal Maršálek> (edit) "https://play.nim-lang.org/#ix=3N2Z" => "https://play.nim-lang.org/#ix=3N30"
18:49:19FromDiscord<JSONBash> @Isofruit appreciate it!
18:50:59Amun-RaMichal Maršál: sth wrong with your example, Error: invalid token: (\29)
18:52:00FromDiscord<Michal Maršálek> I copied it (from my post) to playground: https://play.nim-lang.org/#ix=3N32
18:52:08FromDiscord<noow> https://play.nim-lang.org/#ix=3N33
18:52:29FromDiscord<noow> default GC: GC_ref is None
18:52:42FromDiscord<noow> and in case of arc GC_ref with the argument of string is also undefined
18:52:56FromDiscord<leorize> string, seqs doesn't use GC
18:53:29FromDiscord<noow> but the nim documentation still contains a definition of GC_ref with strings as arguments
18:54:04FromDiscord<noow> https://nim-lang.org/docs/system.html#GC_ref%2Cstring
18:54:07FromDiscord<leorize> it's for refc, which does run them using the GC, but they won't be anymore in the near future
18:54:20FromDiscord<leorize> so you should not rely on that at all
18:54:43FromDiscord<noow> so, I can just put strings behind pointer math and expect them to stay there?
18:55:08FromDiscord<leorize> as long as you keep it alive
18:55:36FromDiscord<JSONBash> strings and seqs do not use GC?
18:55:51FromDiscord<leorize> since it's a value type it vanishes when you get out of the containing block
18:56:09FromDiscord<JSONBash> like RAII style?
18:56:29FromDiscord<noow> In reply to @leorize "since it's a value": aren't they pointers to a character array?
18:56:44FromDiscord<leorize> per spec, pretty much
18:56:44FromDiscord<leorize> implementation wise refc uses GC to implement it, but it's still a value type
18:56:46FromDiscord<leorize> yea
18:57:11FromDiscord<leorize> there's a header for the length as well
18:57:26FromDiscord<leorize> if you want the buffer pointer, take the address of the first element
18:57:40FromDiscord<JSONBash> if i just GC_ref a seq once, then will it never be freed?
18:57:42FromDiscord<noow> so how would I make this work: https://play.nim-lang.org/#ix=2lK1
18:57:56FromDiscord<noow> how do I tell nim to make the str unfreeable
18:58:00FromDiscord<leorize> maybe
18:58:29FromDiscord<noow> https://play.nim-lang.org/#ix=2lK1
18:58:35FromDiscord<noow> https://play.nim-lang.org/#ix=3N38
18:58:39FromDiscord<noow> why does my clipboard not work
18:58:44FromDiscord<noow> ignore the first 2 links lmao
18:58:46FromDiscord<leorize> I think you sent the wrong link
18:59:10FromDiscord<leorize> you have to store it in the outer scope
18:59:17FromDiscord<noow> sorry, i'm not used to windows switching focus if i move my cursor, recently switched to sway
18:59:31FromDiscord<leorize> or allocate a cstring and take memory management to your own hands
19:00:42*Gustavo6046 quit (Read error: Connection reset by peer)
19:01:00arkanoidIsofruit, can I do proc overloading base on object variant (I mean compile time overloading without having to execute `case` inside)
19:01:01FromDiscord<leorize> without actual real use of this it's very hard to advise on how to manage it
19:01:08FromDiscord<leorize> no
19:01:33arkanoidleorize, was that for me?
19:02:10FromDiscord<noow> In reply to @leorize "without actual real use": the acutal use is creating a custom data structure using alloc/dealloc which can contain objects that can contain strings
19:03:00FromDiscord<noow> and of course the place of the objects in memory is calculated using pointer algebra
19:06:08FromDiscord<leorize> if you use arc/orc, don't worry too much
19:06:37FromDiscord<leorize> if you put it into your target structure which you return or whatever, it will stay alive
19:06:49FromDiscord<leorize> but you have to define a destructor or it will stay alive forever
19:08:20*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
19:08:34FromDiscord<leorize> use cold, hard dedicated objects to dispatch
19:08:39FromDiscord<Isofruit> sent a code paste, see https://play.nim-lang.org/#ix=3N3g
19:08:41FromDiscord<noow> so, it is not enough to dealloc the object containing it?
19:09:01FromDiscord<leorize> @noow\: yea, string is a pair of `len, pointer`
19:09:01FromDiscord<Isofruit> (edit) "https://play.nim-lang.org/#ix=3N3g" => "https://play.nim-lang.org/#ix=3N3h"
19:09:19FromDiscord<leorize> if you dealloc the containing object it would only remove the pointer and not the pointer's memory
19:12:07FromDiscord<noow> thank you, i think i understand more now
19:12:23FromDiscord<noow> although I don't know how I would go about dealloc'ing the pointer the string refers to
19:12:30FromDiscord<noow> do I just cast the string to a pointer and call dealloc?
19:13:32FromDiscord<noow> (edit) "cast" => "take the addr/unsafeAddr of"
19:13:44FromDiscord<leorize> nope
19:14:01FromDiscord<leorize> it's best to cast the pointer of the string to `ptr string` then use `=destroy` on it
19:15:13FromDiscord<Isofruit> Sounds of dawning realization that, in order to not waste CPU cycles waiting for the database to respond to my request I have to make my database-querying procs async↵... damnit
19:15:37FromDiscord<Isofruit> (edit) "request" => "queries,"
19:15:53FromDiscord<leorize> @noow\: I'm curious, why do you have to do pointer math? can't you just reinterpret your structure into an object and work with fields directly?
19:16:07FromDiscord<Isofruit> Is... is dealing with futures or whatever they're called in nim similar to how promises work in JS? That's the only language I did async in so far
19:16:18FromDiscord<leorize> pretty much
19:16:29FromDiscord<Isofruit> Phew
19:17:00FromDiscord<Isofruit> So there's some sort of async await or "then" mechanism available
19:17:01FromDiscord<leorize> careful when returning heavy things or keep heavy states during async, logical leaks are the norm over there
19:17:02FromDiscord<Isofruit> Good to know
19:17:56FromDiscord<Isofruit> In what sense? Like, what is dangerous in nim that isn't in JS, that's my only available reference point here
19:18:16FromDiscord<Isofruit> (edit) "In what sense? Like, what is dangerous in nim ... thatJS" added "async" | "JS," => "JS async,"
19:18:21FromDiscord<noow> In reply to @leorize "<@909724322401255464>\: I'm curious, why": I want to implement a stack-like object, where I can keep a pointer to the top of the stack and manipulate it directly↵I don't want to use seq's because the stack can grow/shrink anytime and I want to know if a realloc happens to reset all such pointers
19:19:02FromDiscord<noow> and I don't want to deal with indexes, because they might be slow↵(this is a potential optimalization)
19:19:23FromDiscord<leorize> seq only reallocs on grow
19:19:39FromDiscord<leorize> and indexes are faster than you think
19:19:45FromDiscord<leorize> safer, too
19:20:20FromDiscord<noow> well, I need this stack object to be able to grow
19:21:40FromDiscord<noow> well I don't want bounds checking and I don't want to do the arithmetic of base + element size index everytime I index
19:22:16FromDiscord<leorize> look at the asm if you want to know your optimization is doing any good
19:22:17FromDiscord<noow> it is a collection which only needs to do three operations most of the time: add, pop and len
19:22:21FromDiscord<leorize> compilers are smart nowadays
19:22:54FromDiscord<noow> and reading the top
19:23:01FromDiscord<noow> (edit) "three" => "four"
19:24:30FromDiscord<noow> In reply to @leorize "look at the asm": i usually benchmark for that
19:24:43FromDiscord<noow> well thanks for the help anyways
19:24:57FromDiscord<noow> I'll look into `=destroy` on strings
19:40:59FromDiscord<Isofruit> I found a weakspot within NimEventer!
19:42:00FromDiscord<Isofruit> It does not listen for new posts on CodeReview.stackexchange.com! Which imo is a shame as I really like that particular stackexchange site
19:45:30FromDiscord<Isofruit> sent a long message, see http://ix.io/3N3t
19:46:46FromDiscord<Isofruit> Alternatively, if you do not wish to touch stackexchange sites: https://play.nim-lang.org/#ix=3N3m
19:50:03*rockcavera joined #nim
19:50:03*rockcavera quit (Changing host)
19:50:03*rockcavera joined #nim
19:55:08*oprypin joined #nim
19:57:34PMunchGreat.. Now my Progmem type generates a type in C code that is never used for anything and causes issues
20:01:48*mal`` quit (Read error: Connection reset by peer)
20:03:01*tiorock joined #nim
20:03:01*tiorock quit (Changing host)
20:03:01*tiorock joined #nim
20:03:01*rockcavera is now known as Guest3885
20:03:01*tiorock is now known as rockcavera
20:06:05*Guest3885 quit (Ping timeout: 256 seconds)
20:14:33PMunchIt appears to want to create typedefs for my generic types..
20:15:12PMunchAlthough the generics are obviously not supposed to go to the C code..
20:20:50*mal`` joined #nim
20:23:35*fvs left #nim (WeeChat 3.4)
20:24:15FromDiscord<leorize> @Phil\: is DbConn a ref?
20:24:45FromDiscord<Phil> Iiiiiii don't think so
20:24:52FromDiscord<Phil> Wait, am I copying the entire DbConn around?
20:25:07FromDiscord<Phil> (edit) "around?" => "back and forth when borrowing and recycling??"
20:25:09FromDiscord<Phil> (edit) "recycling??" => "recycling?"
20:25:16FromDiscord<leorize> also I'd recommend keeping deathTime in a separated seq
20:27:00FromDiscord<leorize> actually nvm that
20:27:12FromDiscord<Phil> For my understanding, is the idea here for convenience so that the one receiving the connection can get an actual DbConn and not the wrapped object?
20:27:24FromDiscord<leorize> I'm not sure what's your pool supposed to do, why is there an expiration time?
20:27:24FromDiscord<Phil> Alrghty
20:27:52PMunchTried to delete those extra generated types, and it compiles fine
20:28:02PMunchWhy do you do this to me Nim? :(
20:28:40PMunchI should probably create a bug report for this, but I don't even know how I would start to describe it..
20:29:52FromDiscord<leorize> why would unused types cause any problem?
20:29:54FromDiscord<Phil> In reply to @leorize "I'm not sure what's": I thought it might be useful to have the number of seq grow and shrink as needed. If I run out of connections, I make more. If I need a lot of connections at one point I'll create a lot, but I know that'll shrink back down eventually so the memory isn't going to be hogged constantly.↵That unnecessary?
20:30:14FromDiscord<Phil> (edit) "seq" => "connections"
20:30:57FromDiscord<leorize> it sounds like your pool would go better with a set limit and a burst queue
20:31:17FromDiscord<leorize> so you have a number of idle connections you maintain to be picked up at any point
20:31:42FromDiscord<leorize> and a burst queue that allow you to exceed that amount for a set time, then drop that entire queue later
20:31:56PMunch@leorize, because Nim creates invalid C code
20:32:05PMunchAnd that code doesn't even need to be there
20:32:12FromDiscord<leorize> there's your bug \:p
20:32:13PMunchIt just trips over itself on some generics
20:32:19FromDiscord<leorize> wrong C code
20:32:42FromDiscord<leorize> it doesn't matter if there are unused types in C, wrong code is the bigger problem
20:32:57PMunchThis is the actual error message: http://ix.io/3N3F
20:33:27PMunchAs you can see it tries to create some alias, but it is never used, and it is obviously incorrect..
20:33:39FromDiscord<leorize> yea it's just broken codegen
20:33:53FromDiscord<leorize> those bugs are usually prioritized so you should be fine
20:34:17FromDiscord<Phil> In reply to @leorize "and a burst queue": That sounds complicated to implement. So I have a pool with my iddle connections on the one hand and if that goes empty I initialize a separate queue (basically a second pool, so just a seq[DbConn] with a lock attached) that has a life-time timer on it?
20:34:35FromDiscord<leorize> a keep-alive timer
20:34:49FromDiscord<leorize> as long as there are users you extend the time
20:35:18FromDiscord<leorize> then throw it all away once you're done
20:36:56PMunch@leorize, I should've gotten this done by tonight.. So I'm not so sure I'll be fine :P
20:37:12PMunchAnd I still have a similar codegen bug which is almost a year old by now
20:37:31FromDiscord<leorize> time to bug the devs then \:p
20:37:48PMunchI can't figure out what actually triggers it either..
20:37:49FromDiscord<Phil> Why the two-pool approach as opposed to one that can grow and shrink?↵Is the main goal to keep the number of connection instantiations down?
20:38:47FromDiscord<leorize> isn't that what you want? you only use a small amount, but you want to accommodate bursts when that is required
20:39:23FromDiscord<Phil> Fair, hmm
20:40:14FromDiscord<leorize> as long as it's reproducible it's good
20:40:45FromDiscord<leorize> if you can't minimize it then let the codegen experts figure it out
20:41:53FromDiscord<Phil> In reply to @leorize "isn't that what you": I'll definitely make that an answer on the SO question, thanks for the feedback and the alternative approach!
20:42:04FromDiscord<Phil> (edit) "SO" => "codereview"
20:43:06arkanoidI am writing a package with the idiomatic import/export dance on main module. One module in this package defines "template toOpenArray*[T](arr: CustomArray): openArray[T] =". Inside test I import the main module (the one with import/export everything) but if I try to use that function it tries to call the one defined in system.nim instead. If I copypaste that template in test code it works
20:43:16FromDiscord<leorize> you're welcome, just remember that the best pool is one that is tuned to your exact requirements
20:44:29*krux02 quit (Remote host closed the connection)
20:45:08arkanoidobviously if I rename to toOpenArrayX it works, but how can I get precedence of my function over system.nim?
20:46:13FromDiscord<leorize> your function probably lost in precedence because system.nim version is more defined for your type
20:48:41arkanoidwell, no. Object is "CustomArray = object", and proc is "template toOpenArray*[T](arr: CustomArray): openArray[T] =", system.nim doesn't even know my CustomArray type
20:49:24FromDiscord<leorize> what's the error when you call toOpenArray then?
20:50:02FromDiscord<leorize> and for safety reasons, change your return type to untyped
20:50:03arkanoidError: expression 'toOpenArray[int32](mycustomarray)' cannot be called
20:50:09FromDiscord<Phil> sent a long message, see https://paste.rs/hIK
20:50:25FromDiscord<Phil> (edit) "http://ix.io/3N3J" => "http://ix.io/3N3I"
20:50:48FromDiscord<Phil> (edit) "http://ix.io/3N3I" => "http://ix.io/3N3K"
20:51:04FromDiscord<leorize> @Phil\: I think DbConn are pointer themselves already
20:51:04arkanoidthis is how I am calling it in test1.nim "for i, v in aarray.toOpenArray[: int32]:"
20:51:33arkanoidwhy is untyped safer than openArray[T]?
20:51:37FromDiscord<leorize> try swapping the return type to untyped then
20:51:45FromDiscord<leorize> these things can be weird at time
20:52:04FromDiscord<Phil> In reply to @leorize "<@180601887916163073>\: I think DbConn": Huh, they are indeed. DbConn is an alias for PSqlite3, which is `ptr Sqlite3`
20:52:10arkanoidsame error with "template toOpenArray*[T](arr: ArrowArray): untyped ="
20:52:30FromDiscord<Phil> So if I skip the entire PoolConnection type that avoids me copying memory of dates around
20:52:49FromDiscord<Phil> and also avoids creating a lot of dates
20:53:17FromDiscord<Phil> Ohhhh that is also why it's more efficient, 1 date on the second pool as opposed to 20+ dates on the individual connections
20:53:27FromDiscord<leorize> @Phil\: also use unix epoch for your timer
20:53:42FromDiscord<leorize> so one int64 instead of a large time object
20:55:46*krux02 joined #nim
20:56:24PMunchThe thick plottens.. I can't recreate this in a minimal test..
20:57:21FromDiscord<leorize> monotime is probably better for keep-alive stuff since it's not influenced by changes in system time
20:57:32FromDiscord<Phil> the plock thittens
21:00:11arkanoidis prefixing everything the way to namespace things in nim?
21:00:43PMuncharkanoid, not really
21:00:55FromDiscord<Phil> You mean for cases where you have multiple procs with identical signatures from different modules?
21:01:14FromDiscord<Phil> Can always do <MODULE>.<PROC> if your module names aren't too large
21:01:26FromDiscord<leorize> modules are namespaces on their own
21:02:39arkanoidfor example, I'm binding a lib that declares Type, Int, FloatingPoint, List, and so on. I have to use them and also expose them to the user. I see no other choices than replace then with ArrowInt, ArrowFloatingPoint, ArrowList and so on
21:04:06PMunchWhy not define them without the Arrow prefix?
21:04:31arkanoidbecause I would end up with those types into global scope
21:05:24arkanoidwould you be happy to do "import mylib" and have Int and List and Utf8 in scope?
21:06:25FromDiscord<leorize> what's the issue with that?
21:07:24FromDiscord<leorize> the compiler solves conflicts automatically and people can selectively exclude stuff if needed
21:09:28arkanoidok, so let's go for it
21:10:08arkanoidnow I'm back to the toOpenArray problem :D where the conflict is non automatically solved
21:11:21arkanoidgonna use asOpenArray to make it happy :/
21:15:25PMunchHoly shit! I actually managed to fix it!
21:16:00PMunchIt was caused by my Progmem type being declared within a {.push: nodecl.} block by accident
21:16:22*krux02 quit (Quit: Leaving)
21:16:59PMunchI've been fighting this stupid bug for hours now..
21:27:50FromDiscord<leorize> so it's user error in the end \:p
21:40:15PMunchYup..
21:41:29PMunchHmm, this is weird, I played around with casting to a pointer vs to a cstring. And it made a 16 byte difference in the output, but the diffs looks deceptively similar: http://ix.io/3N3X
21:41:47PMunchThe only real difference I can see is that the cstring version does &str instead of just data
21:43:01PMunchOh, silly me, user mistake again :P
21:43:31PMunchI swear I used to be smarter..
21:48:34arkanoiddo you know how to generate a python list witn nulls in one line with nimpy? I'm using a loop with "l.append X" now. but I'd like to "import nimpy; py = pyBuiltinModule(); l = py.List([1,2,3,py.None])"
21:57:11PMunchHmm, I have defined a template that allows you to do `p"Hello world"` to put "Hello world" in PROGMEM. The problem is that calling `p` that way gives me a raw string literal. Currently I'm just putting that raw string literal directly into C code, and rely on C to parse escape sequences and such. Problem is that I need to get the size of the string on compile-time in Nim. Thoughts?
21:57:41PMunchI guess I could call unescape on the string during compile-time, would that work?
22:01:10PMunchWell, now I'm in the same boat as @Patitotective..
22:05:23FromDiscord<Phil> In reply to @leorize "<@180601887916163073>\: also use unix": I managed to throw some code together, surprisingly it doubled the lines of code I threw together:↵https://codereview.stackexchange.com/a/273237/132951
22:05:25FromDiscord<Elegantbeef> I mean pmunch just do `p("hello world")` 😛
22:05:34FromDiscord<Phil> (edit) "threw together:↵https://codereview.stackexchange.com/a/273237/132951" => "needed:↵https://codereview.stackexchange.com/a/273237/132951"
22:05:50PMunch@Elegantbeef, where's the fun in that?
22:06:15PMunchI won't have my users suffer by typing two extra parenthesis
22:06:19FromDiscord<Elegantbeef> The real solution is to turn `p` into a macro then grab the str value and do what you need to with it
22:07:49PMunchAnd implement my own string escaping?
22:08:19FromDiscord<Phil> True efficiency can only be reached by making your own language for the specific tiny usecase you have!
22:08:24PMunchI guess I could have `p` be a template which called `h()` and then just implement `h`
22:08:53PMunch@Phil, you say that like I don't already have my own language for a tiny specific use case I had :P
22:09:03PMunchWell, not quite so tiny
22:09:09PMunchI actually use it almost every day
22:10:54FromDiscord<Elegantbeef> Wait does stacklang touch the heap?
22:11:01FromDiscord<Elegantbeef> Do we have a language which lies?!
22:11:30PMunchHaha, stacklang doesn't have a concept of heaps
22:11:36FromDiscord<Phil> I mean, if you speak english your have a language that lies
22:11:37PMunchIt's stacks all the way down!
22:12:03PMunchI have a v2 that I haven't pushed, and it's way better than v1
22:12:27PMunchAll variables are just stacks, so you can't assign to a variable, you can just push to a named stack
22:35:49FromDiscord<Michal Maršálek> What is going on here?↵https://play.nim-lang.org/#ix=3N32↵gives `Error: type mismatch: got 'array[0..2, int]' for '[0, 1, 2]' but expected 'seq[int]'`
22:37:07FromDiscord<auxym> @PMunch did you see this RFC? https://github.com/nim-lang/RFCs/issues/257 Is that what you're trying to do?
22:37:43FromDiscord<mratsim> In reply to @Michal58 "What is going on": static seqs are arrays.
22:39:05FromDiscord<mratsim> static auto in a type section is likely to land you in a lot of frustration btw
22:39:31FromDiscord<mratsim> actually line 10 shouldn't break
22:39:42FromDiscord<Michal Maršálek> In reply to @mratsim "static auto in a": It is to be replace by Beef's addition to generics
22:39:47FromDiscord<mratsim> ah it's the ++++
22:39:57FromDiscord<Michal Maršálek> it just doesnt work in playground yet
22:40:04FromDiscord<Elegantbeef> Yea the `+++` is no beuno
22:40:39FromDiscord<qb> Could I use a special char in a object field? I'm trying to serialize a json response and a some key has a `'` in it
22:40:44FromDiscord<mratsim> well seqs at compiletime are described as nnkBracket(0, 1, 2) so they really become arrays
22:40:50FromDiscord<Michal Maršálek> (edit) "replace" => "replaced"
22:41:35FromDiscord<mratsim> In reply to @qb "Could I use a": `myfield'`
22:41:39arkanoidif I have MyInt = int16, how can I get the string "int16" when passing around MyInt as typedesc parameter?
22:41:41FromDiscord<mratsim> use backquote
22:42:02FromDiscord<Elegantbeef> You'd need to convert it back to the base type
22:42:10FromDiscord<Elegantbeef> So you'd need a macro to do `dropAlias(MyInt)`
22:42:26PMunch@mratsim, not quite, but it's related
22:42:38arkanoidmm ok, thanks
22:42:43FromDiscord<Elegantbeef> I'd think the issue is a bug michal 😀
22:43:18FromDiscord<qb> Thats what I was trying https://play.nim-lang.org/#ix=3N4c
22:43:43PMunchBasically I'm trying to wrap a custom attribute in C (PROGMEM, to put things into the program memory section of a microcontroller) to a Nim type. In C you need to use pgmReadByte and similar to read this data back out, but with a custom type in Nim I'm able to have it "just work".
22:45:11PMunchIn C they are just treated as pointers to data, and it's up to the programmer to remember which pointers are normal and which needs pgmReadByte. And switching between the two is a massive pain because you have to go through your code and change everything. With custom types in Nim I'm able to create a distinct type and use pgmReadByte automatically. But I keep running into issues where I and the Nim C code generator disagree on what should actually be generated.
22:45:13FromDiscord<Michal Maršálek> In reply to @Elegantbeef "I'd think the issue": I don't understand... what part is expected and what part is not?
22:45:21FromDiscord<Michal Maršálek> And is there a workaround?
22:45:28FromDiscord<Elegantbeef> Yea use an array 😛
22:45:39FromDiscord<Elegantbeef> Well the part that isnt expected is the complaint that it has an array
22:45:51FromDiscord<Elegantbeef> Yes seq is converted to an array at compile time, but that shouldnt change the type
22:46:33FromDiscord<Michal Maršálek> Yeah, that's what I thought
22:47:09FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3N4d
22:47:50FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3N4e
22:48:06FromDiscord<Elegantbeef> The issue seems to be the `static auto`
22:48:11FromDiscord<mratsim> In reply to @PMunch "<@570268431522201601>, not quite, but": what did I say?
22:48:17FromDiscord<Michal Maršálek> yeah weird
22:49:27FromDiscord<mratsim> In reply to @qb "Thats what I was": well you need a serialization library that can handle field renames
22:49:35PMunchOh woops, @auxym linked to an RFC by you and I thought it was you who linked it
22:49:43FromDiscord<auxym> @mratsim I should probably get a non-default avatar, apparently people are confusing you and me haha
22:49:44FromDiscord<mratsim> In reply to @Michal58 "yeah weird": `auto` is for proc only
22:50:14FromDiscord<mratsim> In reply to @auxym "<@570268431522201601> I should probably": I can go back and disappear for a few months
22:50:32FromDiscord<Michal Maršálek> In reply to @mratsim "`auto` is for proc": auto is not causing the issue here
22:50:56FromDiscord<Michal Maršálek> well
22:51:09FromDiscord<mratsim> you use TypeWithConst with an auto declaration
22:51:53FromDiscord<Michal Maršálek> gimme a sec
22:52:00NimEventerNew thread by Keks84: Matrix/vector operations in Nim, see https://forum.nim-lang.org/t/8835
22:52:03FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/5U4
22:52:06FromDiscord<Elegantbeef> On devel of course
22:52:42FromDiscord<Elegantbeef> It loses type information causing that compile time error
22:53:20FromDiscord<Elegantbeef> The issue is on the dispatch of the `+++` operator afaict
22:53:34FromDiscord<Elegantbeef> Making `+++` discard causes the same isssue
22:53:39FromDiscord<Michal Maršálek> this is the same: https://play.nim-lang.org/#ix=3N4f
22:53:41FromDiscord<Elegantbeef> issue even 😛
22:53:50FromDiscord<Michal Maršálek> you were faster
22:55:15FromDiscord<mratsim> `[T; U: seq[T]]` doesn't work
22:55:26FromDiscord<mratsim> you need explicit higher-kinded-type support
22:55:40FromDiscord<Elegantbeef> `[T; U: static T]` does work
22:55:41FromDiscord<Elegantbeef> in devel
22:56:02FromDiscord<mratsim> I remember mentioning that a couple years ago when I started to do graphs in Arraymancer
22:56:14FromDiscord<mratsim> Variable[T; T: Tensor[T]]
22:56:18FromDiscord<Michal Maršálek> Beef recently implemented that 😉
22:56:21FromDiscord<mratsim> oh
22:58:31FromDiscord<mratsim> but your C isn't used @ElegantBeef
22:58:44FromDiscord<Elegantbeef> Exactly
22:58:52*Guest8 joined #nim
22:58:59FromDiscord<Elegantbeef> It's with procedure dispatch causing a type mismatch
22:59:28FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3N4j
22:59:35FromDiscord<Elegantbeef> Whoops
22:59:36FromDiscord<Elegantbeef> bad copy
22:59:50FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3N4k
23:01:11*krux02 joined #nim
23:01:39FromDiscord<mratsim> and here I thought I was the one doing the most crazy things with statics 😉
23:01:54FromDiscord<Elegantbeef> Yea seems procedures instantiating `TypeWithConst` errors, so i guess an edge case to my solution
23:02:17FromDiscord<Elegantbeef> The first thing i did once my PR went through was make generic modulo types 😛
23:02:41FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=3MYX magic stuff!
23:03:03*adigitoleo joined #nim
23:03:23FromDiscord<Elegantbeef> Michal I guess as long as you dont specialize this is the only real way to do it presently https://play.nim-lang.org/#ix=3N4l
23:03:23FromDiscord<Elegantbeef> Not very useful that you need to do `untyped` and `auto`
23:03:35FromDiscord<Elegantbeef> Something with procedures isnt playing nicely 😀
23:04:35FromDiscord<mratsim> untyped?
23:04:57FromDiscord<Elegantbeef> `C: static TT` didnt work in the template either
23:05:06FromDiscord<Elegantbeef> Caused the same error so i wager that's the isssue
23:05:33FromDiscord<Elegantbeef> Can i spell issue properly ever find out next time on dragon ball Nim
23:05:39FromDiscord<mratsim> ah for a while I thought it was in the type declaration
23:05:51FromDiscord<Elegantbeef> Ah lol
23:06:04FromDiscord<mratsim> mmm, that reminds me of a bug in Arraymancer that I had to work around with untyped
23:08:30FromDiscord<mratsim> ah misremembered, it was this: https://github.com/nim-lang/Nim/issues/7432 / https://github.com/nim-lang/Nim/issues/6529
23:09:06FromDiscord<Elegantbeef> Ah yea need to do `openArray[T](val)`
23:09:16FromDiscord<Elegantbeef> The worst part about `iterator` and `openArray` they dont compose well
23:10:11FromDiscord<Elegantbeef> i mean `iterable`
23:10:39FromDiscord<Elegantbeef> Cant do `openArray[T] or iterable[T]` just can cry in the corner
23:11:50FromDiscord<Elegantbeef> ponders if one can move data into a closure
23:12:53FromDiscord<Elegantbeef> Mratsim you can close issues right?
23:13:03FromDiscord<Elegantbeef> Actually nevermind it's your issue
23:13:06FromDiscord<mratsim> it's $10
23:13:22FromDiscord<Elegantbeef> https://github.com/nim-lang/Nim/issues/7553 this issue can be closed
23:14:06FromDiscord<mratsim> let me grab my Mac real quick
23:14:41FromDiscord<mratsim> I probably need to buy a new one. Would be a nice machine to test ARM as well
23:14:43FromDiscord<Elegantbeef> It's tested for now in the CI with my PR at the very bottom
23:14:57FromDiscord<mratsim> I'm sad I can't access Travis 32 cores ARM instance in CI anymore :/
23:16:48FromDiscord<Elegantbeef> I think the last major borrow issue is with generics and someone was working on it, but dont know what happened to that
23:17:44FromDiscord<mratsim> I assume generics just eat contributors whole
23:17:53FromDiscord<Elegantbeef> Lol indeed
23:18:56FromDiscord<Elegantbeef> Well in the case of the borrow it's like `proc mgetOrPut[K, V](a: DistinctTable[K, V], key: K, val: V): var V {.borrow.}`
23:19:14FromDiscord<Elegantbeef> Which means you need to find an uninstantiated procedure and grab it's symbol
23:19:48FromDiscord<Elegantbeef> They had some issue with type comparisons the last i heard, but they havent been here for a while now
23:20:38FromDiscord<Elegantbeef> Generics have caused me personally a ton of thinking starring at a few lines of code
23:20:52FromDiscord<Elegantbeef> Changing a few things and getting one example to compile but another to fail, or a cgen error
23:21:02FromDiscord<Elegantbeef> Just so much fun you can have changing a single line of code
23:22:08FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3N4r
23:22:27FromDiscord<Michal Maršálek> sent a code paste, see https://play.nim-lang.org/#ix=3N4s
23:22:51FromDiscord<Elegantbeef> Yea there is some issue with the generating the type description inside a generic
23:23:15FromDiscord<Michal Maršálek> and when I tried to debug this, and got rid of the wrapping of `t` discovered the issue we were talking about
23:23:21*sagax joined #nim
23:23:23FromDiscord<Michal Maršálek> (edit) "and when I tried to debug this, and got rid of the wrapping of `t` ... discovered" added "and"
23:23:35FromDiscord<Elegantbeef> I dont get why we can instantiate the type, but having it as a parameter causes an issue
23:23:53FromDiscord<Elegantbeef> I may look at it if i fix a nimscripter bug
23:24:19FromDiscord<Elegantbeef> My changes to the type system are meant to cause a better life but generally just reveal something that was not handled
23:25:27FromDiscord<Michal Maršálek> Replacing `auto` with `TypeWithConst[TT,M.g]` yields `Error: undeclared field: 'g' for type +++.M:type`
23:25:28FromDiscord<mratsim> I once try to fix a generic type mismatch. I looked into sigmatch, turned on the yaml output, bombed my CLI and noped out as soon as I made the bug report.
23:26:01FromDiscord<Elegantbeef> After talking about it with saem i really think Nim's `PType` needs to be rewritten to be less tedious using a more structured type using a table instead of the tree we have
23:26:31FromDiscord<Elegantbeef> My debug process is just put echo into the tree i want to investigate and send myself noise
23:28:58FromDiscord<Elegantbeef> Yea mratsim i took like 10 different attempts at allowing implicit + explicit generics, finally got to the point of just doing it super lazy and it worked
23:29:32arkanoidin there a nim type that contains "ptr + length" or do I have to create my own?
23:29:50FromDiscord<Elegantbeef> `openArray` is that
23:29:51arkanoidI am writing a proc that returns a view on a variable length binary
23:30:04FromDiscord<Elegantbeef> Other than that you'd need to make your own
23:30:14FromDiscord<Elegantbeef> Consider using mratsim's strided view 😛
23:30:25FromDiscord<Elegantbeef> He likes whoring that link out 😛
23:30:26arkanoidok but I have a buffer that contains binary slots with variable lengths, so openarray doesn't apply
23:30:51FromDiscord<Elegantbeef> What do you mean?
23:30:54arkanoidoh man, mratsim is like the guy with the nuclear power button at hand
23:31:28FromDiscord<auxym> In reply to @Elegantbeef "Consider using mratsim's strided": also 10$? 😉
23:31:51FromDiscord<Elegantbeef> Nah he's paying me atleast a snickers bar for that one
23:32:00arkanoidI mean that I have a continuous buffer that contains N items, each with different length. I have a separate "offsets" buffer that tells me where one end and the next begin
23:32:36FromDiscord<auxym> isn't that an object?
23:32:58arkanoidyes, but I don't know which one is (yet)
23:33:07arkanoidI return the buffer, and the user casts it to whatever
23:33:30FromDiscord<Elegantbeef> Well then make an object 🙂
23:33:44arkanoidobject with variable length?
23:34:00arkanoidor you mean object with ptr + length
23:35:49FromDiscord<auxym> well if you have your offsets buffer, you know its length and contents
23:36:33FromDiscord<mratsim> You need to create dedicated proc to this object: ptr + len + offset
23:36:37FromDiscord<mratsim> procs
23:36:46FromDiscord<mratsim> there is no nim builtin for that.
23:36:46arkanoidthanks
23:37:14arkanoid"func binaryItem*(arr: ArrowArray, i: int): (pointer, int) =" will do
23:37:33FromDiscord<mratsim> you can return openarray
23:38:08FromDiscord<mratsim> need to add {.experimental: "views".} in the fil though
23:38:15FromDiscord<mratsim> (edit) "fil" => "file"
23:38:33FromDiscord<mratsim> then proc can return openarray and openarray can be stored in variables and types.
23:38:56arkanoidok but my buffer contains items of different lengths
23:38:58FromDiscord<mratsim> be prepared to make many bug reports. Because you'll be one of the few to test it.
23:39:03FromDiscord<mratsim> ah
23:39:19FromDiscord<mratsim> isn't the i parameter for selecting already one of the subbuffer?
23:39:47arkanoidthink like a cstring array, but no null character but a separate buffer that contains just offsets
23:40:14FromDiscord<mratsim> returning the offset buffer or returning the data buffer without the offset isn't useful.
23:40:39FromDiscord<mratsim> it would be the wrong abstraction level, so use that type as the base.
23:40:42arkanoidsure, that's why I pasted "func binaryItem*(arr: ArrowArray, i: int): (pointer, int)"
23:41:01FromDiscord<mratsim> what does i do then?
23:41:12FromDiscord<mratsim> the `i: int`?
23:41:13arkanoidyou know what contains, you cast it
23:41:43arkanoidi is the index of the element you want to get in the variable binary buffer
23:42:08FromDiscord<mratsim> ah, itemBlob is a better name then. But that's a really low-level interface
23:42:24FromDiscord<mratsim> and return openarray[byte]
23:42:33FromDiscord<mratsim> blob are bytes.
23:42:56FromDiscord<auxym> aka dangerous, if you're relying on user code to cast it arbitrarily
23:43:22FromDiscord<mratsim> the issue here is that I think it's unusable.
23:43:39FromDiscord<mratsim> The internal repr would depend if the machine is big or little endian
23:43:54arkanoidwell, the data structure is called Variable-size Binary, I can't make up for the user what it contains
23:44:11arkanoidthere's a spec that says if it's little or big
23:44:13FromDiscord<mratsim> ah
23:44:22FromDiscord<mratsim> so it really contains a blob
23:44:37*PMunch quit (Quit: leaving)
23:44:39arkanoidI'm dealing with apache arrow specs, so I guess they made them right. It's me that requires fixing
23:44:49FromDiscord<mratsim> well I will need to review the spec and the code, but openarray[byte] sems suitable
23:45:33FromDiscord<mratsim> it's just that if there are added offsets, openarray[byte] is the wrong level of abstraction, the ArrowArray is the right one.
23:45:52FromDiscord<mratsim> and a high-level API that abstract away dealing with offset should be added.
23:46:08FromDiscord<mratsim> anyway, I'll review it later.
23:46:14arkanoidwell, openArray deals with it, right?
23:46:31arkanoid"func itemBlob*(arr: ArrowArray, i: int): openArray[byte] ="
23:47:42FromDiscord<mratsim> you mentioned offsets, when you pass a i, does it select a contiguous range based on these offsets?
23:49:27arkanoidmratsim, correct
23:49:38arkanoidI end up with a pointer and a length