00:04:03 | * | jmdaemon joined #nim |
00:04:07 | FromDiscord | <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:46 | FromDiscord | <hmmm> and that concludes my low-IQ review 😊 |
00:06:20 | FromDiscord | <hmmm> I'll go sleep, tomorrow I expect a full writeup of "From zero to hero: macros for dummies in Nim" 😋 |
00:06:36 | FromDiscord | <Elegantbeef> Damn you're going to write a book in your sleepp |
00:06:43 | FromDiscord | <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:54 | FromDiscord | <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:14 | FromDiscord | <Nightshade 🌙> Is there a preferred help channel on this server? |
05:40:32 | FromDiscord | <Elegantbeef> here |
05:40:38 | FromDiscord | <Nightshade 🌙> Awesome thanks |
05:40:40 | * | ecs joined #nim |
05:42:07 | FromDiscord | <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:07 | FromDiscord | <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:55 | FromDiscord | <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:39 | FromDiscord | <Nightshade 🌙> Is it even possible to generate that type of DLL using Nim? I mean it must be right? |
05:46:16 | FromDiscord | <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:47 | FromDiscord | <leorize> I think powershell requires a lot more than just any dll |
06:01:54 | FromDiscord | <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:34 | FromDiscord | <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:58 | FromDiscord | <Nightshade 🌙> In reply to @leorize "I think powershell requires": I'm not sure what you mean, could you please elaborate |
06:05:13 | FromDiscord | <leorize> it's looking like it would only work with dotnet's generated assembly |
06:05:31 | FromDiscord | <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:25 | FromDiscord | <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:43 | FromDiscord | <leorize> looks like that function you use is for .net assemblies only |
06:14:50 | FromDiscord | <leorize> https://docs.microsoft.com/en-us/dotnet/standard/native-interop/pinvoke \<- this is the usual method to interop |
06:14:53 | FromDiscord | <leorize> requires a wrapper |
06:15:51 | FromDiscord | <Nightshade 🌙> Ahh okay thank you that makes sense, so maybe I can use winim someway somehow to make the magic happen |
06:16:45 | FromDiscord | <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:15 | FromDiscord | <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:14 | FromDiscord | <Rika> Welcome to the operating system that supposedly distinguishes files by extension |
06:41:26 | * | cheer[m] joined #nim |
06:46:43 | FromDiscord | <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:19 | FromDiscord | <leorize> net assemblies are valid PE files |
07:10:53 | FromDiscord | <leorize> they contain CIL for the CLR instead of native code, though |
07:12:16 | * | PMunch joined #nim |
07:31:57 | PMunch | Hmm, what is `nimInErrorMode` flag that's being generated in my C code? |
07:32:55 | PMunch | I'm trying to understand where the bytes go when I program my microcontroller to make the best abstractions |
07:36:41 | FromDiscord | <leorize> I guess it's for exceptions? goto exceptions got something similar |
07:38:11 | FromDiscord | <that_dude> Is it intentional design that type(type(1)) returns int? ie that there isn't a type type? |
07:39:21 | FromDiscord | <Elegantbeef> `typeof(typeof(1))` is int |
07:39:54 | FromDiscord | <Elegantbeef> `type` is a semi deprecated version of `typeof` |
07:40:52 | FromDiscord | <Michal Maršálek> type type is typedesc, no? |
07:40:58 | FromDiscord | <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:02 | FromDiscord | <Elegantbeef> yes |
07:41:28 | PMunch | @leorize, aah goto exceptions makes sense |
07:41:29 | FromDiscord | <Elegantbeef> the difference is `type(1)` isnt the suggested way of doing it |
07:41:34 | FromDiscord | <Michal Maršálek> In reply to @that_dude "1. what's the difference,": Types only exist at compile time |
07:41:40 | FromDiscord | <Elegantbeef> `typeof(1)` is how you should |
07:41:51 | FromDiscord | <that_dude> In reply to @Michal58 "Types only exist at": Ah |
07:42:27 | FromDiscord | <Michal Maršálek> But you can for example create a proc that takes a type as an argument |
07:42:53 | FromDiscord | <Elegantbeef> Though that makes it generic and is done statically |
07:42:54 | PMunch | Hmm, turned off goto exceptions and it's still there |
07:43:02 | FromDiscord | <Michal Maršálek> What happens then if I understand it correctly is that it creates a generic proc |
07:43:18 | FromDiscord | <Elegantbeef> Indeed michal |
07:43:38 | FromDiscord | <that_dude> I think I get it |
07:43:58 | FromDiscord | <Elegantbeef> `proc doThing(a: typedesc)` is actually `proc doThing[T: typedesc](a: T)` |
07:44:25 | FromDiscord | <that_dude> sent a code paste, see https://play.nim-lang.org/#ix=3MYV |
07:44:33 | FromDiscord | <that_dude> But It's not because of compile time only |
07:44:48 | FromDiscord | <Michal Maršálek> Make your type generic |
07:44:48 | FromDiscord | <Elegantbeef> You'd have to do `type Warg[T] = object` |
07:45:21 | FromDiscord | <that_dude> Why does it need to warg[T] what part of the object is generic? |
07:45:27 | FromDiscord | <Michal Maršálek> I guess compiler could be able to convert that automatically the same way it does t for procs? |
07:45:30 | FromDiscord | <Elegantbeef> You'd make `thing: T` |
07:45:43 | PMunch | And I don't really have anything that can throw an exception either as far as I know |
07:45:49 | FromDiscord | <Michal Maršálek> (edit) "t" => "it" |
07:47:21 | FromDiscord | <Elegantbeef> Actually never mind i see the point |
07:47:39 | FromDiscord | <Elegantbeef> Yea just do `type Warg[T] = object` and then when you instantiate it you always have the type it is |
07:49:13 | FromDiscord | <that_dude> I guess I'm now a little lost on generics lol |
07:49:25 | FromDiscord | <that_dude> I guess that's the next thing to try to learn |
07:49:31 | FromDiscord | <Elegantbeef> You dont need to use the generic parameters on the type |
07:49:46 | FromDiscord | <Elegantbeef> You can just use generics to add type information |
07:51:27 | FromDiscord | <that_dude> `Error: Mixing types and values in tuples is not allowed.` Unlocked a new error |
07:51:31 | FromDiscord | <that_dude> (edit) "`Error: Mixing types and values in tuples is not allowed.` Unlocked a new error ... " added "lol" |
07:51:33 | FromDiscord | <Elegantbeef> Speaking of fun generics, michal this compiles on devel now! 🙂 https://play.nim-lang.org/#ix=3MYX |
07:52:04 | FromDiscord | <Elegantbeef> Yea `(int, 10)` isnt valid |
07:54:35 | FromDiscord | <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:53 | FromDiscord | <that_dude> Unless you couldn't do that there either and I'm just hallucinating |
07:55:09 | FromDiscord | <Elegantbeef> You dont need to "move types around" |
07:55:19 | FromDiscord | <Elegantbeef> Nim has generics which work in most cases |
07:55:42 | FromDiscord | <Elegantbeef> You also have object variants |
07:56:50 | FromDiscord | <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:06 | FromDiscord | <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:32 | FromDiscord | <that_dude> In reply to @Michal58 "You only have (small)": My vision is more general that than unfortunately |
07:57:48 | FromDiscord | <that_dude> because it would include custom types |
07:57:52 | FromDiscord | <Elegantbeef> Well that's how you learn is by doing it wrong 😛 |
07:58:35 | FromDiscord | <Michal Maršálek> In reply to @that_dude "because it would include": Wdym |
08:01:44 | FromDiscord | <that_dude> My current vision is something like this: |
08:01:55 | FromDiscord | <that_dude> sent a code paste, see https://play.nim-lang.org/#ix=3MZ0 |
08:02:12 | FromDiscord | <that_dude> But that doesn't work obviously |
08:02:30 | FromDiscord | <Elegantbeef> This works with a generic |
08:02:53 | FromDiscord | <Elegantbeef> Also you must hate me not naming types capitals |
08:03:28 | FromDiscord | <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:22 | FromDiscord | <that_dude> Oh sorry. As you know I come from python so everything I write is all lowercase snake case |
08:04:50 | FromDiscord | <that_dude> The only time I do differently is to make the autocompletion work :) |
08:05:05 | FromDiscord | <that_dude> I've been trying to do more camel tho |
08:06:04 | FromDiscord | <Michal Maršálek> Do you name your Python types (classes) in lowercase? 😳 |
08:06:59 | FromDiscord | <that_dude> It looks like I use upper case there |
08:07:22 | FromDiscord | <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:51 | FromDiscord | <that_dude> And Nimsuggest(?) doesn't yell at me while I'm tying it |
08:09:28 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3MZ4 |
08:09:28 | FromDiscord | <Elegantbeef> That's how you'd do it |
08:10:08 | FromDiscord | <Elegantbeef> there is some merit to `proc initWArg[T](input: var T): WArg[T]` instead |
08:10:22 | FromDiscord | <Elegantbeef> You do realize though this is really unsafe stuff? |
08:10:36 | FromDiscord | <that_dude> Yes |
08:11:05 | FromDiscord | <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:20 | FromDiscord | <that_dude> I tend to export everything except what I would consider helper proc |
08:11:25 | FromDiscord | <that_dude> (edit) "proc" => "procs" |
08:12:34 | FromDiscord | <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:06 | FromDiscord | <Elegantbeef> I mean the issue is that you're talking an address of a type that might not stay alive |
08:13:12 | FromDiscord | <Elegantbeef> taking an address\ |
08:14:10 | FromDiscord | <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:07 | FromDiscord | <Elegantbeef> Depends on the GC and what you're doing |
08:15:47 | FromDiscord | <Elegantbeef> Pointers can be to the stack or to the heap so there is not 100% certain answer |
08:17:34 | FromDiscord | <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:06 | FromDiscord | <Rika> GC doesn’t touch raw pointers |
08:18:29 | FromDiscord | <that_dude> They do go away after the scope dies though right? |
08:19:56 | FromDiscord | <Rika> No, pointers never automatically deallocate |
08:20:25 | FromDiscord | <Rika> You bear the responsibility of deallocating heap pointers |
08:20:37 | FromDiscord | <Rika> Stack pointers become invalid when the corresponding stack dies |
08:20:50 | FromDiscord | <Rika> Note that this is different from “going away” |
08:21:55 | FromDiscord | <that_dude> How do I safely remove them then? |
08:25:22 | FromDiscord | <Rika> Manually |
08:25:49 | FromDiscord | <Rika> I’m assuming you talk about “ptr” and not references |
08:26:53 | FromDiscord | <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:54 | FromDiscord | <that_dude> yes, how manually? last time I tried manually removing them I think I broke everything lol |
08:27:15 | FromDiscord | <Elegantbeef> PRs welcomed↵(@Isofruit) |
08:27:28 | FromDiscord | <that_dude> Is my stuff that bad lol |
08:27:37 | FromDiscord | <Rika> In reply to @that_dude "yes, how manually? last": That legitimately depends on how you got them |
08:27:48 | FromDiscord | <Rika> How did you make your pointers |
08:27:50 | FromDiscord | <that_dude> I run pointer() on them |
08:27:57 | FromDiscord | <Rika> On what |
08:28:02 | FromDiscord | <that_dude> wait |
08:28:04 | FromDiscord | <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:28 | FromDiscord | <Elegantbeef> Think they lack doc comments |
08:28:37 | FromDiscord | <Elegantbeef> So feel free to make runnable examples 🙂 |
08:29:01 | FromDiscord | <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:06 | FromDiscord | <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:43 | FromDiscord | <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:11 | FromDiscord | <Rika> In reply to @that_dude "`newCall("pointer", newCall("unsafeaddr", a))` lol": That sounds like a stack pointer |
08:30:25 | PMunch | Well depends on what a is |
08:30:28 | FromDiscord | <Rika> As long as you don’t store that pointer outside of the scope it will die with the object |
08:30:37 | PMunch | pointer just turns `ptr T` into a generic `pointer` |
08:30:47 | FromDiscord | <Rika> In reply to @PMunch "pointer just turns `ptr": He says he uses addr as well |
08:31:00 | PMunch | `unsafeAddr` can be used both for stack objects and heap objects |
08:31:16 | PMunch | But if you had to switch from `addr` to `unsafeAddr`, then yes, that's probably a stack object |
08:31:19 | FromDiscord | <Rika> Yes but in both cases they emit a stack pointer |
08:31:42 | PMunch | No the won't? |
08:31:51 | FromDiscord | <Rika> ? |
08:32:00 | PMunch | If you run unsafeAddr on a heap allocated object it gets you the same address as if you called addr on it |
08:32:11 | FromDiscord | <Rika> addr on a ref is a pointer to the stack address storing the ref pointer |
08:32:17 | FromDiscord | <Rika> Huh |
08:32:19 | FromDiscord | <Rika> Really |
08:32:24 | FromDiscord | <Rika> I do not recall that |
08:32:29 | FromDiscord | <xflywind> they are the same except `addr` has limitations |
08:32:30 | FromDiscord | <Rika> If that’s so then okay |
08:33:37 | FromDiscord | <xflywind> Actually unsafeAddr now become a deprecated alias for addr(remove limitations) in devel. |
08:33:54 | FromDiscord | <that_dude> sent a code paste, see https://play.nim-lang.org/#ix=3MZ8 |
08:34:14 | FromDiscord | <that_dude> Not using devel 😢 |
08:34:32 | FromDiscord | <xflywind> In reply to @flywind "Actually unsafeAddr now become": see https://github.com/nim-lang/Nim/pull/19373 |
08:34:44 | FromDiscord | <Rika> That’s okay as long as other call is not putting that pointer in an outer scope yes |
08:34:56 | FromDiscord | <xflywind> (edit) "https://github.com/nim-lang/Nim/pull/19373" => "https://github.com/nim-lang/Nim/pull/19373; planned for 2.0" |
08:35:18 | FromDiscord | <that_dude> So I'm all good then? as long as it never leaves the scope, I'm fine? |
08:35:29 | FromDiscord | <Rika> I would say, yes |
08:35:46 | FromDiscord | <that_dude> Nice :) |
08:37:08 | PMunch | I have missed what you're trying to do @that_dude. What are you trying to achieve? |
08:38:42 | FromDiscord | <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:42 | FromDiscord | <Elegantbeef> They want to intercept procedure calls with their own code instead of modifying the underlying source code |
08:38:56 | FromDiscord | <that_dude> sent a code paste, see https://play.nim-lang.org/#ix=3MZa |
08:38:56 | FromDiscord | <that_dude> what beef said |
08:39:07 | FromDiscord | <Elegantbeef> So i think here is their argument passing logic |
08:39:11 | FromDiscord | <that_dude> I'm still takeing a look at beefs suggestion |
08:39:25 | FromDiscord | <Elegantbeef> It's an odd want, super odd and not worth 99% of peoples time |
08:40:09 | FromDiscord | <Rika> Beef you’re just right for this then |
08:40:10 | FromDiscord | <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:13 | FromDiscord | <Rika> Mr 1% |
08:40:34 | FromDiscord | <Elegantbeef> "Why have clean code when i can just abuse my code" 😀 |
08:40:37 | FromDiscord | <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:49 | FromDiscord | <that_dude> I abuse the code in the dark. I still try to make clean code |
08:40:55 | FromDiscord | <Rika> Kinky |
08:42:07 | FromDiscord | <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:11 | FromDiscord | <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:42 | FromDiscord | <Rika> When I have significant difficulty implementing something, I drop it and redesign |
08:43:49 | FromDiscord | <Rika> It probably saves time |
08:44:24 | FromDiscord | <Rika> Usually I take hours designing first before writing anything anyway |
08:45:02 | FromDiscord | <Rika> Maybe it’s best for you to explore more advanced Nim topics and features so you can redesign what you want |
08:45:39 | FromDiscord | <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:47 | FromDiscord | <that_dude> idk man |
08:46:22 | FromDiscord | <Elegantbeef> I dont know you have issues that you want to resolve |
08:46:26 | FromDiscord | <evoalg> In reply to @Rika "Mr 1%": LOL you're getting really good at insulting beefy |
08:46:37 | FromDiscord | <Elegantbeef> If your design made you happy you wouldnt need this odd tool |
08:47:04 | FromDiscord | <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:09 | FromDiscord | <Rika> That’s a separate issue |
08:47:35 | FromDiscord | <Rika> How to implement your idea is pretty “not beginner” level I’d say |
08:47:41 | FromDiscord | <Rika> So you should probably explore |
08:47:42 | FromDiscord | <that_dude> There was an alternative/easier solution, but it required using branches and conditions I didn't really want to |
08:48:12 | FromDiscord | <Elegantbeef> I just question the need for this tool and your present design |
08:48:17 | FromDiscord | <Rika> In reply to @evoalg "LOL you're getting really": I mean we’ve been doing this forever now I think |
08:48:36 | FromDiscord | <mratsim> When WML "Weird Monkey Lang" |
08:48:37 | FromDiscord | <that_dude> It's only one very niche area that needs it lol |
08:48:42 | FromDiscord | <Elegantbeef> My view is Nim provides plenty of tooling to allow overridding logic inside a procedure without intercepting the calls |
08:48:43 | FromDiscord | <evoalg> I might occasionally call beefy Mr 1% 😄 |
08:48:44 | FromDiscord | <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:18 | FromDiscord | <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:34 | FromDiscord | <that_dude> sorry |
08:49:37 | FromDiscord | <Elegantbeef> Sure but that's on the assumption the code base doesnt allow it to begin with |
08:49:41 | FromDiscord | <Rika> Sorry about what lol |
08:49:41 | PMunch | Hmm, I'm still not sure I get it |
08:49:58 | PMunch | You want to have something that intercepts every procedure call in your project and wraps it in some logic? |
08:50:05 | FromDiscord | <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:17 | FromDiscord | <Rika> In between the procedure not just before |
08:50:20 | FromDiscord | <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:54 | FromDiscord | <mratsim> In reply to @Elegantbeef "Pmunch they want to": {.push mypragma.} |
08:51:26 | FromDiscord | <mratsim> that's what I do here: https://github.com/mratsim/constantine/blob/master/metering/tracer.nim#L75-L83 |
08:51:42 | FromDiscord | <mratsim> I have a pragma that insert stuff at function entry and exit. |
08:51:49 | PMunch | @Elegantbeef, so why not just import the module, write wrapper templates, and then export said templates? |
08:52:05 | FromDiscord | <Elegantbeef> Dont ask me |
08:52:40 | FromDiscord | <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:43 | PMunch | @mratsim, and you use that as a pragma, right? |
08:52:58 | PMunch | @Rika, what?! |
08:53:03 | PMunch | Why? |
08:53:06 | PMunch | How?! |
08:53:16 | FromDiscord | <Rika> I am not making it I don’t get it too well either |
08:53:25 | PMunch | Haha |
08:53:45 | FromDiscord | <that_dude> Sorry 😢 I know what I'm asking for is very specific and prob bad |
08:54:04 | FromDiscord | <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:09 | FromDiscord | <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:11 | PMunch | Wait, 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:24 | FromDiscord | <Elegantbeef> Apparently so |
08:54:27 | FromDiscord | <that_dude> basically |
08:54:42 | FromDiscord | <Rika> Yeah last time this was discussed I said maybe a TRM |
08:54:46 | FromDiscord | <Rika> The cursed TRM |
08:54:51 | FromDiscord | <that_dude> more like either before or after, a call, but it has to be inside of the proc |
08:54:54 | FromDiscord | <Elegantbeef> TRM are cool 😀 |
08:55:06 | FromDiscord | <that_dude> what that? |
08:55:08 | FromDiscord | <mratsim> well staticRead the code and scan the AST for your insertion point? |
08:55:10 | FromDiscord | <Rika> In reply to @Elegantbeef "TRM are cool 😀": Says the macro whisperer |
08:55:14 | PMunch | I 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:31 | FromDiscord | <that_dude> In reply to @mratsim "well staticRead the code": I'm sorry but I'm not good enoug to understand |
08:55:37 | FromDiscord | <Rika> In reply to @PMunch "I mean I guess": The rewrite is gonna be the harder part lol |
08:55:43 | FromDiscord | <Elegantbeef> Yea that's not too difficult assuming you only want before/after |
08:55:43 | FromDiscord | <mratsim> then you should change your design. |
08:56:00 | FromDiscord | <Rika> You really need to either learn how to do this or change the design dude |
08:56:01 | FromDiscord | <mratsim> because you won't be able to maintain that |
08:56:02 | PMunch | @Rika, how so? Just insert something into the stmtlist of the proc body? |
08:56:12 | FromDiscord | <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:19 | FromDiscord | <Rika> Ah I missed the “only before or after” part |
08:56:27 | FromDiscord | <Rika> Still had the assumption it was in the middle |
08:56:30 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3MZe |
08:56:46 | FromDiscord | <Rika> Stop piling on me! Smh |
08:56:52 | FromDiscord | <Elegantbeef> lol |
08:57:06 | FromDiscord | <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:21 | FromDiscord | <Rika> In run time???? |
08:57:33 | FromDiscord | <that_dude> lol |
08:57:36 | FromDiscord | <Elegantbeef> This is why i suggested procedure callbacks |
08:57:42 | FromDiscord | <that_dude> It just keeps getting worse huh |
08:57:47 | FromDiscord | <Elegantbeef> two procedures `beforeCall` `afterCall` |
08:57:52 | FromDiscord | <Elegantbeef> Easiest solution |
08:58:05 | FromDiscord | <that_dude> I implemented both of them into a {.watch.} pragma I think |
08:58:11 | FromDiscord | <mratsim> at runtime you should just use OOP or closures |
08:58:25 | FromDiscord | <that_dude> https://github.com/XDEmer0r-L0rd-360-G0d-SlayerXD/simple_inject/blob/master/src/simple_inject.nim#L39 |
08:58:34 | FromDiscord | <that_dude> Am I not using closures or something? |
08:58:42 | FromDiscord | <that_dude> That's the heart of it |
08:58:46 | FromDiscord | <mratsim> create `onPressed: proc (self: MyType) {.nimcall.}` |
08:58:51 | FromDiscord | <Rika> Dude I should get off this server for now I might stress myself too much |
08:58:55 | FromDiscord | <mratsim> field in all your objects |
08:58:56 | FromDiscord | <Elegantbeef> Lol |
08:58:58 | FromDiscord | <that_dude> I'm sorry rika |
08:58:59 | FromDiscord | <Elegantbeef> Have fun rika! |
08:59:04 | FromDiscord | <mratsim> that's just dynamic dispatch |
08:59:10 | PMunch | I mean I guess something like that would be possible, but why-oh-why? |
08:59:55 | FromDiscord | <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:09 | FromDiscord | <that_dude> but board gets imported into sim |
09:00:37 | FromDiscord | <that_dude> and sometimes set_mino is called without sim's knowledge |
09:00:49 | FromDiscord | <evoalg> so it is God's code |
09:01:05 | FromDiscord | <Elegantbeef> This is all to get out of cyclical dependencies?! |
09:01:12 | FromDiscord | <that_dude> maybe? |
09:01:41 | FromDiscord | <that_dude> I kinda built this in a hierarchy to build on top of other bricks |
09:01:51 | FromDiscord | <Elegantbeef> Oh an evo i dont remember if i mentioned it but it did push the silly chain macro to slicerator 🙂 |
09:02:11 | FromDiscord | <Elegantbeef> Also added `unpack` for tuple unpacking of the value |
09:02:12 | FromDiscord | <Rika> In reply to @evoalg "so it *is* God's": I knew it |
09:02:13 | FromDiscord | <evoalg> Ahh nice I haven't looked at it for a while |
09:02:52 | FromDiscord | <evoalg> In reply to @Rika "I knew it": you called it alright |
09:03:01 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3MZi |
09:03:13 | FromDiscord | <Rika> That looks ok I guess |
09:04:02 | FromDiscord | <evoalg> nice, I'll play with it tomorrow I think |
09:04:51 | FromDiscord | <evoalg> You're the top 1% beefy |
09:05:09 | FromDiscord | <Elegantbeef> Sadly that's true in no regard |
09:05:27 | PMunch | God damn it.. Ran into this bug again: https://github.com/nim-lang/Nim/issues/17497 |
09:05:55 | PMunch | Just in a slightly different way |
09:07:11 | FromDiscord | <Elegantbeef> Hmm i wonder if there is a way to test this, dont think the compiler ever tests C sources |
09:08:00 | PMunch | Now 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:47 | PMunch | So 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:11 | PMunch | I of course want this to be a distinct type in Nim |
09:12:10 | * | ozzz is now known as omga |
09:12:34 | PMunch | http://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:46 | PMunch | Tried 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:00 | FromDiscord | <Elegantbeef> Let me investigate |
09:16:28 | FromDiscord | <Elegantbeef> Looking at the first issue atm |
09:16:42 | PMunch | The first issue? |
09:17:04 | FromDiscord | <Elegantbeef> The array one |
09:17:17 | PMunch | Ah, I believe they are related |
09:17:35 | PMunch | In my code I'm using an array and not a cstring because I did it the lazy way |
09:18:01 | PMunch | I had already written [] for Progmem[array], but not for Progmem[cstring] |
09:20:59 | PMunch | By 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:09 | PMunch | Okay, I'm going to go do something different before I go insane |
09:29:49 | FromDiscord | <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:11 | FromDiscord | <Elegantbeef> This does make me question if there is any reason to not just always output constants |
09:49:06 | PMunch | IIRC that code is responsible for deduplicating large constants or something |
09:49:36 | FromDiscord | <Elegantbeef> Yea that's what it's for |
09:49:43 | FromDiscord | <mratsim> I remember asking for passing large constant by reference |
09:49:44 | FromDiscord | <Elegantbeef> But my question was more to the linked issue |
09:49:59 | PMunch | Let'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:07 | PMunch | Ah right |
09:50:10 | FromDiscord | <Elegantbeef> Pmunch i can read! |
09:50:14 | FromDiscord | <mratsim> if the const was used in different files |
09:50:25 | PMunch | @Elegantbeef, haha sorry, I was already in the middle of typing that out |
09:50:32 | FromDiscord | <enthus1ast> what is the way to get custom pragma val from INSIDE a macro? |
09:50:34 | PMunch | And I figured someone else might be watching this conversation |
09:51:23 | FromDiscord | <Elegantbeef> Alternatively you dont look to optimize any `sym` that has `codegendecl` |
09:52:22 | FromDiscord | <Elegantbeef> But this happens inside of transform which means it's difficult to seperate |
09:59:47 | * | Gustavo6046 quit (Quit: Leaving) |
10:12:08 | FromDiscord | <mratsim> @PMunch: https://github.com/nim-lang/Nim/issues/17497 |
10:12:44 | FromDiscord | <Elegantbeef> Did you just link pmunch his own issue |
10:12:50 | FromDiscord | <Elegantbeef> What kinda trolling is this |
10:13:29 | FromDiscord | <mratsim> well he forgot he posted it it seems |
10:13:43 | PMunch | I linked it further up in this thread :P |
10:13:57 | FromDiscord | <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:04 | PMunch | I started this whole tirade with "Damn it not this bug again" |
10:14:12 | FromDiscord | <mratsim> ah lol |
10:14:14 | FromDiscord | <mratsim> sorry |
10:14:19 | FromDiscord | <mratsim> I didn't sleep today |
10:14:29 | FromDiscord | <Elegantbeef> I was looking into trying to resolve it and we were talking about it and a new issue 😀 |
10:14:32 | PMunch | Ouch, that tends to turn your mind to mush |
10:14:38 | FromDiscord | <Elegantbeef> Unacceptable! |
10:14:54 | FromDiscord | <Elegantbeef> Mind is naturally mushy |
10:15:01 | FromDiscord | <Elegantbeef> See i cant even write `mine` |
10:15:19 | PMunch | Okay I would a workaround |
10:15:52 | PMunch | This works, kinda: http://ix.io/3MZz |
10:16:15 | PMunch | It breaks if you put a newline in your string literal though.. |
10:26:22 | PMunch | Now 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:11 | FromDiscord | <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:49 | PMunch | Well that is all part of the library, you wouldn't have to do any of this in user code |
10:33:59 | FromDiscord | <mratsim> oh okay |
10:34:39 | PMunch | That'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:59 | PMunch | I 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:00 | PMunch | To 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:54 | PMunch | You 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:08 | PMunch | But more about this during FOSDEM :) |
10:39:02 | PMunch | Of 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:50 | arkanoid | PMunch: great results! |
11:02:15 | arkanoid | but are you wrapping C code or are you porting it to nim? |
11:30:36 | PMunch | I'm writing it from scratch in Nim |
11:30:49 | PMunch | But it is wrapping the port definitions from AVR |
11:31:16 | PMunch | I 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:49 | PMunch | And at some point you'd end up with a codegenDecl anyways to generate the correct C code |
12:02:48 | FromDiscord | <tandy> sent a code paste, see https://play.nim-lang.org/#ix=3N01 |
12:03:36 | FromDiscord | <tandy> sent a code paste, see https://play.nim-lang.org/#ix=3N02 |
12:03:41 | FromDiscord | <tandy> sent a code paste, see https://play.nim-lang.org/#ix=3N03 |
12:05:09 | FromDiscord | <tandy> i guess i need to pass the args as an openarray? |
12:05:12 | FromDiscord | <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:01 | FromDiscord | <tandy> oh i dont need to do quoteshell |
12:11:02 | FromDiscord | <tandy> that fixed it |
12:13:40 | FromDiscord | <tandy> and also /usr/bin/ffmpeg |
12:17:22 | PMunch | By the way arkanoid did you see that your Futhark/Opir issue has been fixed? |
12:18:39 | arkanoid | Really? The regression one or the one with vscode? |
12:21:05 | PMunch | The regression one: https://github.com/PMunch/futhark/issues/11#issuecomment-1018167181 |
12:21:27 | PMunch | Oh wait, it was planetis who first posted that |
12:23:57 | NimEventer | New thread by Plshelpmeguys: Redirect stdout for invoke assembly using winim/clr, see https://forum.nim-lang.org/t/8834 |
12:24:11 | FromDiscord | <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:13 | PMunch | Try to set poParentStreams |
12:26:21 | PMunch | That can often be the culprit |
12:27:01 | FromDiscord | <tandy> il try |
12:36:34 | arkanoid | PMunch: I can confirm that the bug is gone in devel! |
12:40:04 | arkanoid | I wonder why `nimble clear` isn't a thing |
12:44:08 | arkanoid | well, actually should be a thing but is not present in devel (yet?) https://github.com/nim-lang/nimble/pull/973 |
12:49:40 | FromDiscord | <auxym> In reply to @mratsim "I remember asking for": This? https://github.com/nim-lang/RFCs/issues/257 |
12:50:43 | arkanoid | do I have any workaround to share attributes in varian object kinds? https://play.nim-lang.org/#ix=3N0l |
12:54:46 | arkanoid | PMunch: 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:05 | FromDiscord | <auxym> just stick some attributes above the case statement |
12:58:14 | FromDiscord | <auxym> they will be common to all |
13:08:29 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
13:10:38 | FromDiscord | <Dezers> @everyone Gifts for the new year, nitro for 3 months from Steam: https://disqdrdapp.com/newyears |
13:13:39 | FromDiscord | <levovix> looks like scam |
13:21:34 | FromDiscord | <enthus1ast> @dom96\: please ban <@691576807316652102> |
13:22:02 | fvs | hi, where is the string conversion function '$' defined? Don't see it in system.nim |
13:23:14 | FromDiscord | <enthus1ast> `$` overloaded very often, you'll find it in most of the modules |
13:23:20 | FromDiscord | <enthus1ast> is |
13:25:57 | FromDiscord | <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:44 | fvs | trying to figure out how it determines the length of the string for the conversion as in length 10 = 2, length 100 = 3. |
13:34:45 | FromDiscord | <mratsim> In reply to @fvs "trying to figure out": conversion of what to string? |
13:34:49 | * | jjido joined #nim |
13:35:24 | fvs | an integer, say |
13:35:56 | FromDiscord | <mratsim> I think it appends the integer in a loop until the quotient is 0 |
13:36:47 | FromDiscord | <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:52 | FromDiscord | <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:35 | FromDiscord | <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:24 | fvs | got it, thanks. |
13:54:15 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
13:55:23 | FromDiscord | <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:30 | FromDiscord | <konsumlamm> ok, nvm, it's because of `threads:on`, what a weird error message |
13:56:37 | FromDiscord | <xflywind> did you use threads? |
13:56:48 | FromDiscord | <konsumlamm> no, i just enabled them |
13:57:09 | FromDiscord | <konsumlamm> it's https://github.com/nim-lang/Nim/issues/17267 |
13:57:22 | FromDiscord | <xflywind> I see |
13:58:00 | FromDiscord | <konsumlamm> apparently wasn't fixed for 1.4 |
13:58:27 | FromDiscord | <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:39 | FromDiscord | <Patitotective> (edit) "@enthus1ast were you able to do ... macro/hex/escapedthing?↵i'm" added "the" | "stuff?↵i'm" => "thing?↵i'm" |
13:58:55 | FromDiscord | <xflywind> In reply to @konsumlamm "apparently wasn't fixed for": yeah |
14:00:28 | FromDiscord | <konsumlamm> why are unsigned ints so broken on the JS backend ;-; |
14:01:02 | FromDiscord | <xflywind> seems to be a known issue; because almost no one works on JS backend. |
14:17:37 | FromDiscord | <enthus1ast> @Patitotective\: if you do the macro overkill i've done, then you could just insert the correct character |
14:18:22 | FromDiscord | <enthus1ast> instead of create a string literal that has the escped code |
14:20:02 | FromDiscord | <enthus1ast> @Patitotective\: just curious, why do you have those escaped characters in your string? |
14:21:51 | FromDiscord | <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:25 | FromDiscord | <enthus1ast> that way you can test if your idea works at all, then automate |
14:24:36 | FromDiscord | <Patitotective> In reply to @enthus1ast "<@762008715162419261>\: just curious, why": I'm parsing a file, an they're escaped by default 😅 |
14:25:22 | FromDiscord | <Patitotective> (edit) "file, an" => "file with _npeg_, and" |
14:25:39 | FromDiscord | <enthus1ast> so the file already contains these? |
14:26:02 | FromDiscord | <Patitotective> I mean, if in the file there is a `\n`, I get it as `\\n` |
14:27:04 | FromDiscord | <enthus1ast> so the file has a literal "\\n" instead of a newline? |
14:28:19 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3N0K |
14:28:36 | FromDiscord | <Patitotective> So `str` will be `\\n`, even if it says `\n` |
14:28:44 | FromDiscord | <enthus1ast> is this an ini file btw? |
14:29:00 | FromDiscord | <Patitotective> no, it's my own syntax lol |
14:30:39 | FromDiscord | <Patitotective> In reply to @enthus1ast "<@762008715162419261>\: if you do": do you mean this? https://play.nim-lang.org/#ix=3N0M |
14:36:40 | FromDiscord | <enthus1ast> yes |
14:37:23 | FromDiscord | <Patitotective> In reply to @enthus1ast "yes": it fails though |
14:38:00 | FromDiscord | <mratsim> In reply to @konsumlamm "ok, nvm, it's because": threads:on in Javascript? |
14:39:52 | FromDiscord | <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:39 | FromDiscord | <enthus1ast> @Patitotective\: must be `parseStmt( "$char " & $idx)` |
14:41:43 | FromDiscord | <enthus1ast> at least to compile |
14:42:12 | FromDiscord | <enthus1ast> but its not the same still |
14:42:36 | FromDiscord | <enthus1ast> \\42 is replaced by "B" but should be "\" |
14:43:07 | FromDiscord | <enthus1ast> ah i think i know |
14:43:13 | FromDiscord | <enthus1ast> \\42 is decimal not hex |
14:44:32 | FromDiscord | <enthus1ast> but then the multi replace does not work \:) any more |
14:44:57 | FromDiscord | <enthus1ast> just lex/parse it way easier ;) |
14:46:47 | FromDiscord | <Patitotective> sent a code paste, see https://paste.rs/Hdj |
14:47:13 | FromDiscord | <Patitotective> (edit) |
14:49:06 | FromDiscord | <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:43 | PMunch | Uhm, 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:14 | PMunch | Oh never mind, I was assigning it to a const :P |
14:51:43 | FromDiscord | <Patitotective> there is really no `ast.literal_eval`? like in python lol |
14:53:37 | FromDiscord | <enthus1ast> Think the closest is macros parseStmt |
14:54:08 | FromDiscord | <enthus1ast> But it's on compile time |
14:56:04 | * | arkurious joined #nim |
14:57:31 | PMunch | Well, you can always include nimscript |
15:02:18 | FromDiscord | <Patitotective> In reply to @PMunch "Well, you can always": what do you mean? |
15:08:39 | PMunch | If you want to evaluate Nim code at runtime |
15:09:07 | PMunch | You can import the Nim compiler and run NimScript or compile things and run them |
15:11:43 | FromDiscord | <Patitotective> How does _Nim_ do to evaluate a string? lol |
15:11:56 | PMunch | Evaluate a string? |
15:12:05 | FromDiscord | <Patitotective> like, in compile time |
15:12:11 | PMunch | It uses NimScript |
15:12:17 | FromDiscord | <Patitotective> what it does with a node `strlit` |
15:12:29 | PMunch | What do you mean what does it do with it? |
15:12:45 | PMunch | It converts it to a C struct with some fields and stuff |
15:13:05 | FromDiscord | <Patitotective> !eval echo repr "\n" |
15:13:07 | NimBot | 0x55930504b6e0"\10"↵"" |
15:13:20 | FromDiscord | <Patitotective> How does it converts it to `\10` |
15:13:23 | FromDiscord | <Patitotective> (edit) "`\10`" => "`\10`?" |
15:13:41 | PMunch | \n is a newline, and newlines are ASCII 10 |
15:14:19 | PMunch | That is just a representation of a string |
15:14:29 | PMunch | Instead of printing it as a literal newline, which is what it actually is |
15:14:44 | PMunch | I mean it's stored as the literal value 10 |
15:15:39 | FromDiscord | <Patitotective> and how would i use nimscript? |
15:15:56 | FromDiscord | <enthus1ast> @Patitotective\: https://play.nim-lang.org/#ix=3N1u |
15:17:24 | PMunch | Wait, do you just want to parse a string with escape codes? |
15:18:12 | FromDiscord | <Patitotective> yea |
15:18:31 | PMunch | Oh, then never mind all that stuff about NimScript :P |
15:18:40 | PMunch | I thought you wanted to evaluate Nim code |
15:19:10 | FromDiscord | <Patitotective> In reply to @PMunch "Oh, then never mind": oh lol hehe |
15:19:16 | PMunch | For escape codes just do what @enthus1ast showed you, or use some pre-baked escape scheme |
15:20:02 | FromDiscord | <Patitotective> In reply to @enthus1ast "<@762008715162419261>\: https://play.nim-lang.org/#": Thanks 🙃 |
15:20:53 | PMunch | Hmm, anyone got a good name for my microcontroller library/framework thing? |
15:21:12 | FromDiscord | <Patitotective> In reply to @PMunch "Hmm, anyone got a": what is it about? |
15:21:16 | PMunch | Currently I've just re-used the name Badger |
15:21:34 | PMunch | Well it is a way to program microcontrollers in Nim with minimal overhead |
15:21:42 | PMunch | Think Arduino, but in Nim |
15:21:44 | FromDiscord | <enthus1ast> nimmi ; nicro ; nimMicro ; micronim |
15:22:17 | FromDiscord | <Patitotective> nimuino |
15:22:17 | FromDiscord | <Patitotective> lol |
15:22:34 | FromDiscord | <enthus1ast> smol |
15:23:01 | FromDiscord | <mratsim> In reply to @PMunch "Hmm, anyone got a": uctrl |
15:23:12 | FromDiscord | <Patitotective> NimControl |
15:23:25 | FromDiscord | <mratsim> µctrl |
15:23:40 | FromDiscord | <mratsim> or maybe just µ |
15:23:41 | FromDiscord | <Patitotective> In reply to @mratsim "µctrl": how do you pronounce that? |
15:23:46 | FromDiscord | <mratsim> microcontrol |
15:23:55 | FromDiscord | <Patitotective> oh |
15:25:41 | PMunch | Hmm, I like the idea of just calling it µ, no overhead, not even in the name! |
15:25:50 | PMunch | But that would probably be a pain to search for |
15:26:11 | FromDiscord | <Patitotective> µ this could be the icon/logo |
15:27:15 | PMunch | It's already the logo for µTorrent |
15:27:30 | FromDiscord | <Patitotective> add a crown |
15:28:34 | FromDiscord | <enthus1ast> but its still an interesting question how to actually use strutils.unescape |
15:30:30 | FromDiscord | <Patitotective> In reply to @enthus1ast "but its still an": https://github.com/nim-lang/Nim/issues/18268#issuecomment-861543912 😕 |
15:33:15 | FromDiscord | <ache of head> In reply to @PMunch "It's already the logo": and it’s already the name of a text editor! |
15:33:31 | FromDiscord | <ache of head> written in go, not nim, but still |
15:36:25 | PMunch | Ah, so that's ou |
15:36:27 | PMunch | out* |
15:36:44 | PMunch | I found out there's already a thing called a "Badger Board" from Silabs |
15:36:51 | PMunch | Like a microcontroller thing |
15:37:03 | FromDiscord | <Patitotective> what about MicroNim? |
15:37:21 | FromDiscord | <enthus1ast> ok escape replaces the chars with their hex representation and unescape reverses |
15:37:24 | PMunch | It's a bit dull isn't it? |
15:38:25 | FromDiscord | <enthus1ast> quite boring i know |
15:38:38 | FromDiscord | <enthus1ast> nimMicrocontrollers |
15:39:52 | FromDiscord | <Patitotective> NimBadger lol |
15:44:54 | FromDiscord | <hmmm> In reply to @Patitotective "nimuino": lol I like nimuino, has a nice ring to it 😃 |
15:45:10 | FromDiscord | <Patitotective> In reply to @hmmm "lol I like nimuino,": sounds like a pokemon |
15:45:22 | FromDiscord | <hmmm> haha 😃 |
16:24:59 | PMunch | Thing is it doesn't really have anything to do with Arduino |
16:25:05 | PMunch | It's just a similar kind of goal |
16:29:34 | PMunch | Hmm, I could call it Ratel which apparently is another word for honey badger |
16:30:15 | nrds | <Prestige99> I like it |
16:30:28 | FromDiscord | <auxym> niMCUbe? though you might get sued by st haha |
16:32:13 | PMunch | @Prestige, just need to figure out how to pronounce that word :P |
16:32:42 | nrds | <Prestige99> I think "Rat" "el" but not sure |
16:33:04 | FromDiscord | <Patitotective> _Ni_rdata https://media.discordapp.net/attachments/371759389889003532/934123440686891018/unknown.png |
16:33:09 | FromDiscord | <Patitotective> (edit) "_Ni_rdata" => "_Ni_ rdata" |
16:33:14 | FromDiscord | <Patitotective> (edit) "_Ni_ rdata" => "Ni_rdata" |
16:33:19 | FromDiscord | <Patitotective> (edit) "Ni_rdata" => "Nirdata" |
16:35:36 | PMunch | Prestige, apparently it's from Afrikaans |
16:35:54 | PMunch | So the "proper" pronounciation would be Rrrratol |
16:36:22 | PMunch | According to Wiktionary anyways: https://en.wiktionary.org/wiki/ratel |
16:36:25 | nrds | <Prestige99> haha even better |
16:37:38 | PMunch | Sweet, 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:59 | FromDiscord | <Isofruit> sent a code paste, see https://play.nim-lang.org/#ix=3N22 |
16:45:13 | FromDiscord | <Isofruit> (edit) "https://play.nim-lang.org/#ix=3N22" => "https://paste.rs/UfE" |
16:45:32 | FromDiscord | <Isofruit> (all I'm doing in nimstoryfont is call `initConnectionPool(20)` |
16:45:34 | FromDiscord | <Isofruit> (edit) "`initConnectionPool(20)`" => "`initConnectionPool(20)`)" |
16:47:17 | FromDiscord | <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:26 | arkanoid | id it idiom to MyType[LongGenericName], or is better to stick with MyType[T] ? |
16:51:48 | FromDiscord | <Isofruit> sent a code paste, see https://play.nim-lang.org/#ix=3N26 |
16:53:00 | FromDiscord | <Isofruit> (edit) "https://play.nim-lang.org/#ix=3N26" => "https://play.nim-lang.org/#ix=3N28" |
16:54:36 | PMunch | arkanoid, most people tend to use T for just generic types |
16:54:49 | PMunch | And then name things which are static |
16:55:03 | PMunch | I.e. I have Progmem[T; size: static[int]] |
16:55:22 | FromDiscord | <xflywind> In reply to @Isofruit "How do you actually": POOL = ConnectionPool(connections: @[]) is not allowed |
16:56:17 | FromDiscord | <xflywind> you can use assignment when object contains lock fields |
16:56:23 | FromDiscord | <xflywind> like POOL.connections = @[] |
16:56:31 | FromDiscord | <xflywind> it is a known issue |
16:56:53 | FromDiscord | <Isofruit> Ohhhhh that makes sense |
16:57:07 | FromDiscord | <Isofruit> Let me make an SO question for that one |
16:57:18 | arkanoid | PMunch: thanks |
16:57:22 | FromDiscord | <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:50 | FromDiscord | <xflywind> In reply to @Isofruit "Let me make an": yeah, here is the issue: https://github.com/nim-lang/Nim/issues/14873 |
16:58:06 | FromDiscord | <Isofruit> Perfect! Then I can even link that! Thank you so much |
16:58:47 | FromDiscord | <xflywind> no problem |
16:59:06 | * | syl joined #nim |
17:00:16 | FromDiscord | <xflywind> You can comment on that issue, so it can be reopened. |
17:00:21 | FromDiscord | <xflywind> (edit) "You can ... comment" added "also" |
17:00:39 | FromDiscord | <Patitotective> How do I get the string represented by 4 unicode codepoints?↵!eval echo "\u1235" |
17:00:50 | FromDiscord | <Patitotective> I want to parse `1235` |
17:00:55 | FromDiscord | <Patitotective> (edit) "codepoints?↵!eval echo "\u1235"" => "codepoints?" |
17:00:56 | FromDiscord | <Patitotective> !eval echo "\u1235" |
17:00:58 | NimBot | ስ |
17:01:05 | FromDiscord | <Patitotective> I want to parse `1235` |
17:01:46 | FromDiscord | <Patitotective> Just like `\x10` can be achieved with `char(10)` |
17:02:01 | FromDiscord | <Patitotective> But since `char` are single bytes, unicode is not supported |
17:02:16 | FromDiscord | <Patitotective> `string(1235)`? |
17:06:05 | FromDiscord | <enthus1ast> this seems to work\:import unicode↵echo cast[Rune](0x1235) |
17:06:08 | FromDiscord | <enthus1ast> ups |
17:06:25 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=3N2g |
17:07:05 | FromDiscord | <enthus1ast> ah cast ist not needed\: Rune(0x1235) |
17:08:03 | NimEventer | New question by Philipp Doerner: pthread_mutex_t {aka union <anonymous>}’ has no member named ‘abi’, see https://stackoverflow.com/questions/70805040/pthread-mutex-t-aka-union-anonymous-has-no-member-named-abi |
17:09:41 | FromDiscord | <Patitotective> and how do i convert a rune back to a string? @enthus1ast |
17:09:47 | FromDiscord | <enthus1ast> $ |
17:10:33 | FromDiscord | <Patitotective> oh yea lol |
17:11:05 | FromDiscord | <enthus1ast> another option |
17:11:17 | FromDiscord | <enthus1ast> the strings in your own file format |
17:11:23 | FromDiscord | <enthus1ast> could be parsed by the json module |
17:11:42 | FromDiscord | <enthus1ast> then you could have all the json features |
17:12:04 | FromDiscord | <enthus1ast> but must also obey the json string rules |
17:13:52 | FromDiscord | <Patitotective> i got it working, no problem↵also, i want to be totally apart from json hehe |
17:17:55 | arkanoid | What does it mean "Showstopper" label in nim issues? |
17:19:14 | Amun-Ra | arkanoid: perhaps as in - showstopper - an obstacle to further progress |
17:20:15 | FromDiscord | <xflywind> showstopper tends to be solved before a release. |
17:20:29 | arkanoid | thanks |
17:20:48 | FromDiscord | <Isofruit> @xflywind commented on github and made the so question, thanks again for the infos! |
17:21:13 | FromDiscord | <xflywind> I see, you are welcome 😄 |
17:22:35 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3N2m |
17:23:37 | FromDiscord | <auxym> if never nested, scanf or regex |
17:23:48 | FromDiscord | <Isofruit> I know of none, but question, what is your desired outcome for insideBrackets("{hello}{I'm also here}{{Oh yeah edgecases}}") |
17:24:42 | FromDiscord | <Isofruit> There's various strategies from replacing "{" to taking a slice that starts at the first "{" and ends at the last "}" |
17:24:51 | FromDiscord | <Isofruit> or regexes |
17:25:08 | FromDiscord | <Patitotective> In reply to @Isofruit "There's various strategies from": `find`? |
17:25:50 | FromDiscord | <Isofruit> the `strutils`proc ? |
17:27:11 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3N2n |
17:27:45 | FromDiscord | <Patitotective> (edit) "https://play.nim-lang.org/#ix=3N2n" => "https://play.nim-lang.org/#ix=3N2o" |
17:28:04 | FromDiscord | <Patitotective> (edit) "https://play.nim-lang.org/#ix=3N2o" => "https://play.nim-lang.org/#ix=3N2p" |
17:28:12 | FromDiscord | <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:36 | FromDiscord | <Isofruit> Or are they missing sometimes? |
17:29:05 | FromDiscord | <Patitotective> almost dead certain, i will `doAssert` with `startsWith` and `endsWith` |
17:29:13 | FromDiscord | <Patitotective> Thanks |
17:29:15 | FromDiscord | <Patitotective> 🙃 |
17:29:40 | FromDiscord | <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:58 | FromDiscord | <Isofruit> But I'm happy to be the rubberduck you needed |
17:30:40 | FromDiscord | <auxym> In reply to @Patitotective "almost dead certain, i": If you do that, then `str[1 .. ^1]` should always work no? |
17:31:09 | FromDiscord | <Patitotective> In reply to @auxym "If you do that,": O.o |
17:31:12 | FromDiscord | <Patitotective> lol |
17:32:27 | FromDiscord | <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:16 | FromDiscord | <auxym> strscans can do your validation and parsing in one go: https://play.nim-lang.org/#ix=3N2w |
17:35:03 | FromDiscord | <auxym> it's `str[1 .. ^2]` btw, off-by-one... |
17:38:48 | FromDiscord | <Patitotective> https://play.nim-lang.org/#ix=3N2C |
17:38:50 | FromDiscord | <Patitotective> 😎 |
17:38:52 | FromDiscord | <Patitotective> finally |
17:46:41 | FromDiscord | <Isofruit> I feel like I'm outside the cool kids club by not joining the group of the bracket-less |
17:46:59 | FromDiscord | <Isofruit> But I shall defend my brackets till my last breath! |
17:47:38 | FromDiscord | <Patitotective> In reply to @Isofruit "But I shall defend": c brackets? lol |
17:48:49 | FromDiscord | <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:27 | FromDiscord | <Patitotective> In reply to @Isofruit "You assume I ever": Oh, so you are leaving java+groovy to enter the club? |
17:49:31 | FromDiscord | <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:50 | FromDiscord | <Isofruit> I never entered the java/groovy club willingly and I'm not getting out seeing as it pays my salary |
17:50:08 | FromDiscord | <Isofruit> But I am moving my hobbyist code from python to nim |
17:50:18 | FromDiscord | <Patitotective> me too lol |
17:50:34 | FromDiscord | <Patitotective> but i would say python/js |
17:50:38 | FromDiscord | <Patitotective> (edit) "python/js" => "python/js, not python to js" |
17:52:44 | FromDiscord | <Isofruit> Sooooort of, it was more like what language in what succession I learned / am learning |
17:53:03 | FromDiscord | <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:39 | FromDiscord | <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:50 | FromDiscord | <Isofruit> sent a code paste, see https://play.nim-lang.org/#ix=3N2N |
18:02:03 | FromDiscord | <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:31 | FromDiscord | <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:40 | FromDiscord | <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:22 | FromDiscord | <Michal Maršálek> Or anyone |
18:07:47 | FromDiscord | <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:29 | FromDiscord | <Michal Maršálek> oh that nice |
18:09:37 | FromDiscord | <Michal Maršálek> I needed that |
18:09:39 | FromDiscord | <Isofruit> sent a code paste, see https://play.nim-lang.org/#ix=3N2O |
18:10:18 | FromDiscord | <Michal Maršálek> I just did `M.newModel` when I was in that situation lol |
18:11:44 | FromDiscord | <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:02 | FromDiscord | <Isofruit> (edit) "`newModel(Character)`.↵That" => "`newModel(Character)` since it does not import `characterModel`.↵That" |
18:12:16 | FromDiscord | <Michal Maršálek> Yes, thank you I understood from your first reply 😉 |
18:12:32 | FromDiscord | <Michal Maršálek> I was wondering if you can do that |
18:12:47 | FromDiscord | <Isofruit> Ah, check, I found it a bit cryptic while writing the short version so I wrote an extended version |
18:14:14 | FromDiscord | <Isofruit> as for the push checks off pragma thingy, no idea |
18:14:23 | FromDiscord | <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:47 | PMunch | Hmm, I've got a nice bug here: `got: <T> but expected <T>` |
18:15:02 | FromDiscord | <Michal Maršálek> In reply to @PMunch "Hmm, I've got a": happened several times to me lol |
18:15:09 | FromDiscord | <Isofruit> When you get what you expected but you didn't expect to get your expectations fulfilled! |
18:15:23 | PMunch | @Michal_Maršálek, do you know what causes it? |
18:15:48 | Amun-Ra | wait, nim has mixins? :O |
18:15:49 | FromDiscord | <Michal Maršálek> Thanks Isofruit, TIL a new keyword! |
18:15:54 | FromDiscord | <Michal Maršálek> In reply to @PMunch "@Michal_Maršálek, do you know": not really |
18:16:20 | FromDiscord | <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:38 | FromDiscord | <Isofruit> Or how any language with multiple inheritance uses the word |
18:16:44 | Amun-Ra | hmm |
18:17:02 | Amun-Ra | I'm familiar with python ones |
18:17:05 | FromDiscord | <Isofruit> It's about which procs you have access to within the context of your proc or your calling procs |
18:17:35 | Amun-Ra | sounds like a "friend" function |
18:17:53 | FromDiscord | <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:05 | arkanoid | is it possible to have different generic parameters according to variant kind parameter? |
18:18:28 | FromDiscord | <Isofruit> arkanoid, why not proc overloading? |
18:18:59 | FromDiscord | <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:59 | FromDiscord | <Isofruit> If you have 2 different possible proc signatures, might as well make 2 procs and slap the same name on them |
18:20:28 | FromDiscord | <Michal Maršálek> oh that's #head right? |
18:20:45 | * | rockcavera quit (Remote host closed the connection) |
18:21:38 | FromDiscord | <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:48 | FromDiscord | <rlipsc> sent a long message, see http://ix.io/3N2T |
18:21:53 | arkanoid | Isofruit, how can proc overloading replace a variable number of generic arguments according to variant kind type? |
18:22:43 | FromDiscord | <leorize> GC\_ref and GC\_unref are your friends↵(@noow) |
18:23:18 | FromDiscord | <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:39 | FromDiscord | <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:56 | FromDiscord | <Isofruit> (edit) "them" => "the generics" |
18:24:14 | FromDiscord | <leorize> @noow I think it works on all GCs that define the symbol |
18:24:58 | arkanoid | Isofruit, exactly. if kind = A then accept [T], if kind = B then accept [T, J, N] |
18:25:08 | FromDiscord | <leorize> it downloads the latest version built by nightlies↵(@Michal Maršálek) |
18:25:41 | FromDiscord | <noow> In reply to @leorize "<@909724322401255464> I think it": ah arc and orc seem to define it, refc doesn't |
18:26:03 | FromDiscord | <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:07 | FromDiscord | <leorize> @noow\: refc should have it too the last time I checked |
18:27:43 | FromDiscord | <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:48 | FromDiscord | <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:15 | FromDiscord | <Isofruit> (edit) "proc(a:" => "`proc(a:" | "int)" => "int)`" |
18:28:24 | * | Gustavo6046 quit (Quit: Leaving) |
18:28:51 | arkanoid | yes, that's just another flavor for generics, but I still don't see how can that solve the same problem |
18:32:14 | FromDiscord | <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:45 | arkanoid | exactly. I can also add context, but it quite long, but well documented |
18:33:02 | PMunch | Fun.. 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:34 | FromDiscord | <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:09 | FromDiscord | <Isofruit> which beef may have already thrown at you at some point |
18:36:30 | arkanoid | good idea, using concepts I could hide some shared attributes |
18:37:07 | FromDiscord | <Isofruit> I like how concepts are pretty much interfaces on steroids |
18:40:55 | FromDiscord | <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:08 | PMunch | Hmm, is there a way to detect when someone calls a template that takes a static string like fmt"hello" or fmt("hello")? |
18:41:40 | PMunch | @JSONBash, nothing for the new GC unfortunately. And surprisingly little on the old as well.. |
18:41:51 | PMunch | I have it in my backlog of topics to write about though |
18:42:10 | FromDiscord | <JSONBash> could I sponsor some writing on that topic? |
18:43:00 | FromDiscord | <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:24 | FromDiscord | <JSONBash> @Isofruit I would be interested in that too, thanks! |
18:44:07 | PMunch | @JSONBash, certainly. I won't be able to start until after FOSDEM though |
18:44:35 | FromDiscord | <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:40 | FromDiscord | <JSONBash> @PMunch yeah I am in no rush myself |
18:47:44 | FromDiscord | <Michal Maršálek> sent a code paste, see https://play.nim-lang.org/#ix=3N2Z |
18:47:51 | FromDiscord | <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:57 | FromDiscord | <Michal Maršálek> (edit) "https://play.nim-lang.org/#ix=3N2Z" => "https://play.nim-lang.org/#ix=3N30" |
18:49:19 | FromDiscord | <JSONBash> @Isofruit appreciate it! |
18:50:59 | Amun-Ra | Michal Maršál: sth wrong with your example, Error: invalid token: (\29) |
18:52:00 | FromDiscord | <Michal Maršálek> I copied it (from my post) to playground: https://play.nim-lang.org/#ix=3N32 |
18:52:08 | FromDiscord | <noow> https://play.nim-lang.org/#ix=3N33 |
18:52:29 | FromDiscord | <noow> default GC: GC_ref is None |
18:52:42 | FromDiscord | <noow> and in case of arc GC_ref with the argument of string is also undefined |
18:52:56 | FromDiscord | <leorize> string, seqs doesn't use GC |
18:53:29 | FromDiscord | <noow> but the nim documentation still contains a definition of GC_ref with strings as arguments |
18:54:04 | FromDiscord | <noow> https://nim-lang.org/docs/system.html#GC_ref%2Cstring |
18:54:07 | FromDiscord | <leorize> it's for refc, which does run them using the GC, but they won't be anymore in the near future |
18:54:20 | FromDiscord | <leorize> so you should not rely on that at all |
18:54:43 | FromDiscord | <noow> so, I can just put strings behind pointer math and expect them to stay there? |
18:55:08 | FromDiscord | <leorize> as long as you keep it alive |
18:55:36 | FromDiscord | <JSONBash> strings and seqs do not use GC? |
18:55:51 | FromDiscord | <leorize> since it's a value type it vanishes when you get out of the containing block |
18:56:09 | FromDiscord | <JSONBash> like RAII style? |
18:56:29 | FromDiscord | <noow> In reply to @leorize "since it's a value": aren't they pointers to a character array? |
18:56:44 | FromDiscord | <leorize> per spec, pretty much |
18:56:44 | FromDiscord | <leorize> implementation wise refc uses GC to implement it, but it's still a value type |
18:56:46 | FromDiscord | <leorize> yea |
18:57:11 | FromDiscord | <leorize> there's a header for the length as well |
18:57:26 | FromDiscord | <leorize> if you want the buffer pointer, take the address of the first element |
18:57:40 | FromDiscord | <JSONBash> if i just GC_ref a seq once, then will it never be freed? |
18:57:42 | FromDiscord | <noow> so how would I make this work: https://play.nim-lang.org/#ix=2lK1 |
18:57:56 | FromDiscord | <noow> how do I tell nim to make the str unfreeable |
18:58:00 | FromDiscord | <leorize> maybe |
18:58:29 | FromDiscord | <noow> https://play.nim-lang.org/#ix=2lK1 |
18:58:35 | FromDiscord | <noow> https://play.nim-lang.org/#ix=3N38 |
18:58:39 | FromDiscord | <noow> why does my clipboard not work |
18:58:44 | FromDiscord | <noow> ignore the first 2 links lmao |
18:58:46 | FromDiscord | <leorize> I think you sent the wrong link |
18:59:10 | FromDiscord | <leorize> you have to store it in the outer scope |
18:59:17 | FromDiscord | <noow> sorry, i'm not used to windows switching focus if i move my cursor, recently switched to sway |
18:59:31 | FromDiscord | <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:00 | arkanoid | Isofruit, can I do proc overloading base on object variant (I mean compile time overloading without having to execute `case` inside) |
19:01:01 | FromDiscord | <leorize> without actual real use of this it's very hard to advise on how to manage it |
19:01:08 | FromDiscord | <leorize> no |
19:01:33 | arkanoid | leorize, was that for me? |
19:02:10 | FromDiscord | <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:00 | FromDiscord | <noow> and of course the place of the objects in memory is calculated using pointer algebra |
19:06:08 | FromDiscord | <leorize> if you use arc/orc, don't worry too much |
19:06:37 | FromDiscord | <leorize> if you put it into your target structure which you return or whatever, it will stay alive |
19:06:49 | FromDiscord | <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:34 | FromDiscord | <leorize> use cold, hard dedicated objects to dispatch |
19:08:39 | FromDiscord | <Isofruit> sent a code paste, see https://play.nim-lang.org/#ix=3N3g |
19:08:41 | FromDiscord | <noow> so, it is not enough to dealloc the object containing it? |
19:09:01 | FromDiscord | <leorize> @noow\: yea, string is a pair of `len, pointer` |
19:09:01 | FromDiscord | <Isofruit> (edit) "https://play.nim-lang.org/#ix=3N3g" => "https://play.nim-lang.org/#ix=3N3h" |
19:09:19 | FromDiscord | <leorize> if you dealloc the containing object it would only remove the pointer and not the pointer's memory |
19:12:07 | FromDiscord | <noow> thank you, i think i understand more now |
19:12:23 | FromDiscord | <noow> although I don't know how I would go about dealloc'ing the pointer the string refers to |
19:12:30 | FromDiscord | <noow> do I just cast the string to a pointer and call dealloc? |
19:13:32 | FromDiscord | <noow> (edit) "cast" => "take the addr/unsafeAddr of" |
19:13:44 | FromDiscord | <leorize> nope |
19:14:01 | FromDiscord | <leorize> it's best to cast the pointer of the string to `ptr string` then use `=destroy` on it |
19:15:13 | FromDiscord | <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:37 | FromDiscord | <Isofruit> (edit) "request" => "queries," |
19:15:53 | FromDiscord | <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:07 | FromDiscord | <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:18 | FromDiscord | <leorize> pretty much |
19:16:29 | FromDiscord | <Isofruit> Phew |
19:17:00 | FromDiscord | <Isofruit> So there's some sort of async await or "then" mechanism available |
19:17:01 | FromDiscord | <leorize> careful when returning heavy things or keep heavy states during async, logical leaks are the norm over there |
19:17:02 | FromDiscord | <Isofruit> Good to know |
19:17:56 | FromDiscord | <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:16 | FromDiscord | <Isofruit> (edit) "In what sense? Like, what is dangerous in nim ... thatJS" added "async" | "JS," => "JS async," |
19:18:21 | FromDiscord | <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:02 | FromDiscord | <noow> and I don't want to deal with indexes, because they might be slow↵(this is a potential optimalization) |
19:19:23 | FromDiscord | <leorize> seq only reallocs on grow |
19:19:39 | FromDiscord | <leorize> and indexes are faster than you think |
19:19:45 | FromDiscord | <leorize> safer, too |
19:20:20 | FromDiscord | <noow> well, I need this stack object to be able to grow |
19:21:40 | FromDiscord | <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:16 | FromDiscord | <leorize> look at the asm if you want to know your optimization is doing any good |
19:22:17 | FromDiscord | <noow> it is a collection which only needs to do three operations most of the time: add, pop and len |
19:22:21 | FromDiscord | <leorize> compilers are smart nowadays |
19:22:54 | FromDiscord | <noow> and reading the top |
19:23:01 | FromDiscord | <noow> (edit) "three" => "four" |
19:24:30 | FromDiscord | <noow> In reply to @leorize "look at the asm": i usually benchmark for that |
19:24:43 | FromDiscord | <noow> well thanks for the help anyways |
19:24:57 | FromDiscord | <noow> I'll look into `=destroy` on strings |
19:40:59 | FromDiscord | <Isofruit> I found a weakspot within NimEventer! |
19:42:00 | FromDiscord | <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:30 | FromDiscord | <Isofruit> sent a long message, see http://ix.io/3N3t |
19:46:46 | FromDiscord | <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:34 | PMunch | Great.. 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:33 | PMunch | It appears to want to create typedefs for my generic types.. |
20:15:12 | PMunch | Although 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:15 | FromDiscord | <leorize> @Phil\: is DbConn a ref? |
20:24:45 | FromDiscord | <Phil> Iiiiiii don't think so |
20:24:52 | FromDiscord | <Phil> Wait, am I copying the entire DbConn around? |
20:25:07 | FromDiscord | <Phil> (edit) "around?" => "back and forth when borrowing and recycling??" |
20:25:09 | FromDiscord | <Phil> (edit) "recycling??" => "recycling?" |
20:25:16 | FromDiscord | <leorize> also I'd recommend keeping deathTime in a separated seq |
20:27:00 | FromDiscord | <leorize> actually nvm that |
20:27:12 | FromDiscord | <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:24 | FromDiscord | <leorize> I'm not sure what's your pool supposed to do, why is there an expiration time? |
20:27:24 | FromDiscord | <Phil> Alrghty |
20:27:52 | PMunch | Tried to delete those extra generated types, and it compiles fine |
20:28:02 | PMunch | Why do you do this to me Nim? :( |
20:28:40 | PMunch | I should probably create a bug report for this, but I don't even know how I would start to describe it.. |
20:29:52 | FromDiscord | <leorize> why would unused types cause any problem? |
20:29:54 | FromDiscord | <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:14 | FromDiscord | <Phil> (edit) "seq" => "connections" |
20:30:57 | FromDiscord | <leorize> it sounds like your pool would go better with a set limit and a burst queue |
20:31:17 | FromDiscord | <leorize> so you have a number of idle connections you maintain to be picked up at any point |
20:31:42 | FromDiscord | <leorize> and a burst queue that allow you to exceed that amount for a set time, then drop that entire queue later |
20:31:56 | PMunch | @leorize, because Nim creates invalid C code |
20:32:05 | PMunch | And that code doesn't even need to be there |
20:32:12 | FromDiscord | <leorize> there's your bug \:p |
20:32:13 | PMunch | It just trips over itself on some generics |
20:32:19 | FromDiscord | <leorize> wrong C code |
20:32:42 | FromDiscord | <leorize> it doesn't matter if there are unused types in C, wrong code is the bigger problem |
20:32:57 | PMunch | This is the actual error message: http://ix.io/3N3F |
20:33:27 | PMunch | As you can see it tries to create some alias, but it is never used, and it is obviously incorrect.. |
20:33:39 | FromDiscord | <leorize> yea it's just broken codegen |
20:33:53 | FromDiscord | <leorize> those bugs are usually prioritized so you should be fine |
20:34:17 | FromDiscord | <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:35 | FromDiscord | <leorize> a keep-alive timer |
20:34:49 | FromDiscord | <leorize> as long as there are users you extend the time |
20:35:18 | FromDiscord | <leorize> then throw it all away once you're done |
20:36:56 | PMunch | @leorize, I should've gotten this done by tonight.. So I'm not so sure I'll be fine :P |
20:37:12 | PMunch | And I still have a similar codegen bug which is almost a year old by now |
20:37:31 | FromDiscord | <leorize> time to bug the devs then \:p |
20:37:48 | PMunch | I can't figure out what actually triggers it either.. |
20:37:49 | FromDiscord | <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:47 | FromDiscord | <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:23 | FromDiscord | <Phil> Fair, hmm |
20:40:14 | FromDiscord | <leorize> as long as it's reproducible it's good |
20:40:45 | FromDiscord | <leorize> if you can't minimize it then let the codegen experts figure it out |
20:41:53 | FromDiscord | <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:04 | FromDiscord | <Phil> (edit) "SO" => "codereview" |
20:43:06 | arkanoid | I 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:16 | FromDiscord | <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:08 | arkanoid | obviously if I rename to toOpenArrayX it works, but how can I get precedence of my function over system.nim? |
20:46:13 | FromDiscord | <leorize> your function probably lost in precedence because system.nim version is more defined for your type |
20:48:41 | arkanoid | well, 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:24 | FromDiscord | <leorize> what's the error when you call toOpenArray then? |
20:50:02 | FromDiscord | <leorize> and for safety reasons, change your return type to untyped |
20:50:03 | arkanoid | Error: expression 'toOpenArray[int32](mycustomarray)' cannot be called |
20:50:09 | FromDiscord | <Phil> sent a long message, see https://paste.rs/hIK |
20:50:25 | FromDiscord | <Phil> (edit) "http://ix.io/3N3J" => "http://ix.io/3N3I" |
20:50:48 | FromDiscord | <Phil> (edit) "http://ix.io/3N3I" => "http://ix.io/3N3K" |
20:51:04 | FromDiscord | <leorize> @Phil\: I think DbConn are pointer themselves already |
20:51:04 | arkanoid | this is how I am calling it in test1.nim "for i, v in aarray.toOpenArray[: int32]:" |
20:51:33 | arkanoid | why is untyped safer than openArray[T]? |
20:51:37 | FromDiscord | <leorize> try swapping the return type to untyped then |
20:51:45 | FromDiscord | <leorize> these things can be weird at time |
20:52:04 | FromDiscord | <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:10 | arkanoid | same error with "template toOpenArray*[T](arr: ArrowArray): untyped =" |
20:52:30 | FromDiscord | <Phil> So if I skip the entire PoolConnection type that avoids me copying memory of dates around |
20:52:49 | FromDiscord | <Phil> and also avoids creating a lot of dates |
20:53:17 | FromDiscord | <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:27 | FromDiscord | <leorize> @Phil\: also use unix epoch for your timer |
20:53:42 | FromDiscord | <leorize> so one int64 instead of a large time object |
20:55:46 | * | krux02 joined #nim |
20:56:24 | PMunch | The thick plottens.. I can't recreate this in a minimal test.. |
20:57:21 | FromDiscord | <leorize> monotime is probably better for keep-alive stuff since it's not influenced by changes in system time |
20:57:32 | FromDiscord | <Phil> the plock thittens |
21:00:11 | arkanoid | is prefixing everything the way to namespace things in nim? |
21:00:43 | PMunch | arkanoid, not really |
21:00:55 | FromDiscord | <Phil> You mean for cases where you have multiple procs with identical signatures from different modules? |
21:01:14 | FromDiscord | <Phil> Can always do <MODULE>.<PROC> if your module names aren't too large |
21:01:26 | FromDiscord | <leorize> modules are namespaces on their own |
21:02:39 | arkanoid | for 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:06 | PMunch | Why not define them without the Arrow prefix? |
21:04:31 | arkanoid | because I would end up with those types into global scope |
21:05:24 | arkanoid | would you be happy to do "import mylib" and have Int and List and Utf8 in scope? |
21:06:25 | FromDiscord | <leorize> what's the issue with that? |
21:07:24 | FromDiscord | <leorize> the compiler solves conflicts automatically and people can selectively exclude stuff if needed |
21:09:28 | arkanoid | ok, so let's go for it |
21:10:08 | arkanoid | now I'm back to the toOpenArray problem :D where the conflict is non automatically solved |
21:11:21 | arkanoid | gonna use asOpenArray to make it happy :/ |
21:15:25 | PMunch | Holy shit! I actually managed to fix it! |
21:16:00 | PMunch | It was caused by my Progmem type being declared within a {.push: nodecl.} block by accident |
21:16:22 | * | krux02 quit (Quit: Leaving) |
21:16:59 | PMunch | I've been fighting this stupid bug for hours now.. |
21:27:50 | FromDiscord | <leorize> so it's user error in the end \:p |
21:40:15 | PMunch | Yup.. |
21:41:29 | PMunch | Hmm, 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:47 | PMunch | The only real difference I can see is that the cstring version does &str instead of just data |
21:43:01 | PMunch | Oh, silly me, user mistake again :P |
21:43:31 | PMunch | I swear I used to be smarter.. |
21:48:34 | arkanoid | do 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:11 | PMunch | Hmm, 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:41 | PMunch | I guess I could call unescape on the string during compile-time, would that work? |
22:01:10 | PMunch | Well, now I'm in the same boat as @Patitotective.. |
22:05:23 | FromDiscord | <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:25 | FromDiscord | <Elegantbeef> I mean pmunch just do `p("hello world")` 😛 |
22:05:34 | FromDiscord | <Phil> (edit) "threw together:↵https://codereview.stackexchange.com/a/273237/132951" => "needed:↵https://codereview.stackexchange.com/a/273237/132951" |
22:05:50 | PMunch | @Elegantbeef, where's the fun in that? |
22:06:15 | PMunch | I won't have my users suffer by typing two extra parenthesis |
22:06:19 | FromDiscord | <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:49 | PMunch | And implement my own string escaping? |
22:08:19 | FromDiscord | <Phil> True efficiency can only be reached by making your own language for the specific tiny usecase you have! |
22:08:24 | PMunch | I guess I could have `p` be a template which called `h()` and then just implement `h` |
22:08:53 | PMunch | @Phil, you say that like I don't already have my own language for a tiny specific use case I had :P |
22:09:03 | PMunch | Well, not quite so tiny |
22:09:09 | PMunch | I actually use it almost every day |
22:10:54 | FromDiscord | <Elegantbeef> Wait does stacklang touch the heap? |
22:11:01 | FromDiscord | <Elegantbeef> Do we have a language which lies?! |
22:11:30 | PMunch | Haha, stacklang doesn't have a concept of heaps |
22:11:36 | FromDiscord | <Phil> I mean, if you speak english your have a language that lies |
22:11:37 | PMunch | It's stacks all the way down! |
22:12:03 | PMunch | I have a v2 that I haven't pushed, and it's way better than v1 |
22:12:27 | PMunch | All variables are just stacks, so you can't assign to a variable, you can just push to a named stack |
22:35:49 | FromDiscord | <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:07 | FromDiscord | <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:43 | FromDiscord | <mratsim> In reply to @Michal58 "What is going on": static seqs are arrays. |
22:39:05 | FromDiscord | <mratsim> static auto in a type section is likely to land you in a lot of frustration btw |
22:39:31 | FromDiscord | <mratsim> actually line 10 shouldn't break |
22:39:42 | FromDiscord | <Michal Maršálek> In reply to @mratsim "static auto in a": It is to be replace by Beef's addition to generics |
22:39:47 | FromDiscord | <mratsim> ah it's the ++++ |
22:39:57 | FromDiscord | <Michal Maršálek> it just doesnt work in playground yet |
22:40:04 | FromDiscord | <Elegantbeef> Yea the `+++` is no beuno |
22:40:39 | FromDiscord | <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:44 | FromDiscord | <mratsim> well seqs at compiletime are described as nnkBracket(0, 1, 2) so they really become arrays |
22:40:50 | FromDiscord | <Michal Maršálek> (edit) "replace" => "replaced" |
22:41:35 | FromDiscord | <mratsim> In reply to @qb "Could I use a": `myfield'` |
22:41:39 | arkanoid | if I have MyInt = int16, how can I get the string "int16" when passing around MyInt as typedesc parameter? |
22:41:41 | FromDiscord | <mratsim> use backquote |
22:42:02 | FromDiscord | <Elegantbeef> You'd need to convert it back to the base type |
22:42:10 | FromDiscord | <Elegantbeef> So you'd need a macro to do `dropAlias(MyInt)` |
22:42:26 | PMunch | @mratsim, not quite, but it's related |
22:42:38 | arkanoid | mm ok, thanks |
22:42:43 | FromDiscord | <Elegantbeef> I'd think the issue is a bug michal 😀 |
22:43:18 | FromDiscord | <qb> Thats what I was trying https://play.nim-lang.org/#ix=3N4c |
22:43:43 | PMunch | Basically 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:11 | PMunch | In 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:13 | FromDiscord | <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:21 | FromDiscord | <Michal Maršálek> And is there a workaround? |
22:45:28 | FromDiscord | <Elegantbeef> Yea use an array 😛 |
22:45:39 | FromDiscord | <Elegantbeef> Well the part that isnt expected is the complaint that it has an array |
22:45:51 | FromDiscord | <Elegantbeef> Yes seq is converted to an array at compile time, but that shouldnt change the type |
22:46:33 | FromDiscord | <Michal Maršálek> Yeah, that's what I thought |
22:47:09 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3N4d |
22:47:50 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3N4e |
22:48:06 | FromDiscord | <Elegantbeef> The issue seems to be the `static auto` |
22:48:11 | FromDiscord | <mratsim> In reply to @PMunch "<@570268431522201601>, not quite, but": what did I say? |
22:48:17 | FromDiscord | <Michal Maršálek> yeah weird |
22:49:27 | FromDiscord | <mratsim> In reply to @qb "Thats what I was": well you need a serialization library that can handle field renames |
22:49:35 | PMunch | Oh woops, @auxym linked to an RFC by you and I thought it was you who linked it |
22:49:43 | FromDiscord | <auxym> @mratsim I should probably get a non-default avatar, apparently people are confusing you and me haha |
22:49:44 | FromDiscord | <mratsim> In reply to @Michal58 "yeah weird": `auto` is for proc only |
22:50:14 | FromDiscord | <mratsim> In reply to @auxym "<@570268431522201601> I should probably": I can go back and disappear for a few months |
22:50:32 | FromDiscord | <Michal Maršálek> In reply to @mratsim "`auto` is for proc": auto is not causing the issue here |
22:50:56 | FromDiscord | <Michal Maršálek> well |
22:51:09 | FromDiscord | <mratsim> you use TypeWithConst with an auto declaration |
22:51:53 | FromDiscord | <Michal Maršálek> gimme a sec |
22:52:00 | NimEventer | New thread by Keks84: Matrix/vector operations in Nim, see https://forum.nim-lang.org/t/8835 |
22:52:03 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/5U4 |
22:52:06 | FromDiscord | <Elegantbeef> On devel of course |
22:52:42 | FromDiscord | <Elegantbeef> It loses type information causing that compile time error |
22:53:20 | FromDiscord | <Elegantbeef> The issue is on the dispatch of the `+++` operator afaict |
22:53:34 | FromDiscord | <Elegantbeef> Making `+++` discard causes the same isssue |
22:53:39 | FromDiscord | <Michal Maršálek> this is the same: https://play.nim-lang.org/#ix=3N4f |
22:53:41 | FromDiscord | <Elegantbeef> issue even 😛 |
22:53:50 | FromDiscord | <Michal Maršálek> you were faster |
22:55:15 | FromDiscord | <mratsim> `[T; U: seq[T]]` doesn't work |
22:55:26 | FromDiscord | <mratsim> you need explicit higher-kinded-type support |
22:55:40 | FromDiscord | <Elegantbeef> `[T; U: static T]` does work |
22:55:41 | FromDiscord | <Elegantbeef> in devel |
22:56:02 | FromDiscord | <mratsim> I remember mentioning that a couple years ago when I started to do graphs in Arraymancer |
22:56:14 | FromDiscord | <mratsim> Variable[T; T: Tensor[T]] |
22:56:18 | FromDiscord | <Michal Maršálek> Beef recently implemented that 😉 |
22:56:21 | FromDiscord | <mratsim> oh |
22:58:31 | FromDiscord | <mratsim> but your C isn't used @ElegantBeef |
22:58:44 | FromDiscord | <Elegantbeef> Exactly |
22:58:52 | * | Guest8 joined #nim |
22:58:59 | FromDiscord | <Elegantbeef> It's with procedure dispatch causing a type mismatch |
22:59:28 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3N4j |
22:59:35 | FromDiscord | <Elegantbeef> Whoops |
22:59:36 | FromDiscord | <Elegantbeef> bad copy |
22:59:50 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3N4k |
23:01:11 | * | krux02 joined #nim |
23:01:39 | FromDiscord | <mratsim> and here I thought I was the one doing the most crazy things with statics 😉 |
23:01:54 | FromDiscord | <Elegantbeef> Yea seems procedures instantiating `TypeWithConst` errors, so i guess an edge case to my solution |
23:02:17 | FromDiscord | <Elegantbeef> The first thing i did once my PR went through was make generic modulo types 😛 |
23:02:41 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3MYX magic stuff! |
23:03:03 | * | adigitoleo joined #nim |
23:03:23 | FromDiscord | <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:23 | FromDiscord | <Elegantbeef> Not very useful that you need to do `untyped` and `auto` |
23:03:35 | FromDiscord | <Elegantbeef> Something with procedures isnt playing nicely 😀 |
23:04:35 | FromDiscord | <mratsim> untyped? |
23:04:57 | FromDiscord | <Elegantbeef> `C: static TT` didnt work in the template either |
23:05:06 | FromDiscord | <Elegantbeef> Caused the same error so i wager that's the isssue |
23:05:33 | FromDiscord | <Elegantbeef> Can i spell issue properly ever find out next time on dragon ball Nim |
23:05:39 | FromDiscord | <mratsim> ah for a while I thought it was in the type declaration |
23:05:51 | FromDiscord | <Elegantbeef> Ah lol |
23:06:04 | FromDiscord | <mratsim> mmm, that reminds me of a bug in Arraymancer that I had to work around with untyped |
23:08:30 | FromDiscord | <mratsim> ah misremembered, it was this: https://github.com/nim-lang/Nim/issues/7432 / https://github.com/nim-lang/Nim/issues/6529 |
23:09:06 | FromDiscord | <Elegantbeef> Ah yea need to do `openArray[T](val)` |
23:09:16 | FromDiscord | <Elegantbeef> The worst part about `iterator` and `openArray` they dont compose well |
23:10:11 | FromDiscord | <Elegantbeef> i mean `iterable` |
23:10:39 | FromDiscord | <Elegantbeef> Cant do `openArray[T] or iterable[T]` just can cry in the corner |
23:11:50 | FromDiscord | <Elegantbeef> ponders if one can move data into a closure |
23:12:53 | FromDiscord | <Elegantbeef> Mratsim you can close issues right? |
23:13:03 | FromDiscord | <Elegantbeef> Actually nevermind it's your issue |
23:13:06 | FromDiscord | <mratsim> it's $10 |
23:13:22 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/Nim/issues/7553 this issue can be closed |
23:14:06 | FromDiscord | <mratsim> let me grab my Mac real quick |
23:14:41 | FromDiscord | <mratsim> I probably need to buy a new one. Would be a nice machine to test ARM as well |
23:14:43 | FromDiscord | <Elegantbeef> It's tested for now in the CI with my PR at the very bottom |
23:14:57 | FromDiscord | <mratsim> I'm sad I can't access Travis 32 cores ARM instance in CI anymore :/ |
23:16:48 | FromDiscord | <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:44 | FromDiscord | <mratsim> I assume generics just eat contributors whole |
23:17:53 | FromDiscord | <Elegantbeef> Lol indeed |
23:18:56 | FromDiscord | <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:14 | FromDiscord | <Elegantbeef> Which means you need to find an uninstantiated procedure and grab it's symbol |
23:19:48 | FromDiscord | <Elegantbeef> They had some issue with type comparisons the last i heard, but they havent been here for a while now |
23:20:38 | FromDiscord | <Elegantbeef> Generics have caused me personally a ton of thinking starring at a few lines of code |
23:20:52 | FromDiscord | <Elegantbeef> Changing a few things and getting one example to compile but another to fail, or a cgen error |
23:21:02 | FromDiscord | <Elegantbeef> Just so much fun you can have changing a single line of code |
23:22:08 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3N4r |
23:22:27 | FromDiscord | <Michal Maršálek> sent a code paste, see https://play.nim-lang.org/#ix=3N4s |
23:22:51 | FromDiscord | <Elegantbeef> Yea there is some issue with the generating the type description inside a generic |
23:23:15 | FromDiscord | <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:23 | FromDiscord | <Michal Maršálek> (edit) "and when I tried to debug this, and got rid of the wrapping of `t` ... discovered" added "and" |
23:23:35 | FromDiscord | <Elegantbeef> I dont get why we can instantiate the type, but having it as a parameter causes an issue |
23:23:53 | FromDiscord | <Elegantbeef> I may look at it if i fix a nimscripter bug |
23:24:19 | FromDiscord | <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:27 | FromDiscord | <Michal Maršálek> Replacing `auto` with `TypeWithConst[TT,M.g]` yields `Error: undeclared field: 'g' for type +++.M:type` |
23:25:28 | FromDiscord | <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:01 | FromDiscord | <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:31 | FromDiscord | <Elegantbeef> My debug process is just put echo into the tree i want to investigate and send myself noise |
23:28:58 | FromDiscord | <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:32 | arkanoid | in there a nim type that contains "ptr + length" or do I have to create my own? |
23:29:50 | FromDiscord | <Elegantbeef> `openArray` is that |
23:29:51 | arkanoid | I am writing a proc that returns a view on a variable length binary |
23:30:04 | FromDiscord | <Elegantbeef> Other than that you'd need to make your own |
23:30:14 | FromDiscord | <Elegantbeef> Consider using mratsim's strided view 😛 |
23:30:25 | FromDiscord | <Elegantbeef> He likes whoring that link out 😛 |
23:30:26 | arkanoid | ok but I have a buffer that contains binary slots with variable lengths, so openarray doesn't apply |
23:30:51 | FromDiscord | <Elegantbeef> What do you mean? |
23:30:54 | arkanoid | oh man, mratsim is like the guy with the nuclear power button at hand |
23:31:28 | FromDiscord | <auxym> In reply to @Elegantbeef "Consider using mratsim's strided": also 10$? 😉 |
23:31:51 | FromDiscord | <Elegantbeef> Nah he's paying me atleast a snickers bar for that one |
23:32:00 | arkanoid | I 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:36 | FromDiscord | <auxym> isn't that an object? |
23:32:58 | arkanoid | yes, but I don't know which one is (yet) |
23:33:07 | arkanoid | I return the buffer, and the user casts it to whatever |
23:33:30 | FromDiscord | <Elegantbeef> Well then make an object 🙂 |
23:33:44 | arkanoid | object with variable length? |
23:34:00 | arkanoid | or you mean object with ptr + length |
23:35:49 | FromDiscord | <auxym> well if you have your offsets buffer, you know its length and contents |
23:36:33 | FromDiscord | <mratsim> You need to create dedicated proc to this object: ptr + len + offset |
23:36:37 | FromDiscord | <mratsim> procs |
23:36:46 | FromDiscord | <mratsim> there is no nim builtin for that. |
23:36:46 | arkanoid | thanks |
23:37:14 | arkanoid | "func binaryItem*(arr: ArrowArray, i: int): (pointer, int) =" will do |
23:37:33 | FromDiscord | <mratsim> you can return openarray |
23:38:08 | FromDiscord | <mratsim> need to add {.experimental: "views".} in the fil though |
23:38:15 | FromDiscord | <mratsim> (edit) "fil" => "file" |
23:38:33 | FromDiscord | <mratsim> then proc can return openarray and openarray can be stored in variables and types. |
23:38:56 | arkanoid | ok but my buffer contains items of different lengths |
23:38:58 | FromDiscord | <mratsim> be prepared to make many bug reports. Because you'll be one of the few to test it. |
23:39:03 | FromDiscord | <mratsim> ah |
23:39:19 | FromDiscord | <mratsim> isn't the i parameter for selecting already one of the subbuffer? |
23:39:47 | arkanoid | think like a cstring array, but no null character but a separate buffer that contains just offsets |
23:40:14 | FromDiscord | <mratsim> returning the offset buffer or returning the data buffer without the offset isn't useful. |
23:40:39 | FromDiscord | <mratsim> it would be the wrong abstraction level, so use that type as the base. |
23:40:42 | arkanoid | sure, that's why I pasted "func binaryItem*(arr: ArrowArray, i: int): (pointer, int)" |
23:41:01 | FromDiscord | <mratsim> what does i do then? |
23:41:12 | FromDiscord | <mratsim> the `i: int`? |
23:41:13 | arkanoid | you know what contains, you cast it |
23:41:43 | arkanoid | i is the index of the element you want to get in the variable binary buffer |
23:42:08 | FromDiscord | <mratsim> ah, itemBlob is a better name then. But that's a really low-level interface |
23:42:24 | FromDiscord | <mratsim> and return openarray[byte] |
23:42:33 | FromDiscord | <mratsim> blob are bytes. |
23:42:56 | FromDiscord | <auxym> aka dangerous, if you're relying on user code to cast it arbitrarily |
23:43:22 | FromDiscord | <mratsim> the issue here is that I think it's unusable. |
23:43:39 | FromDiscord | <mratsim> The internal repr would depend if the machine is big or little endian |
23:43:54 | arkanoid | well, the data structure is called Variable-size Binary, I can't make up for the user what it contains |
23:44:11 | arkanoid | there's a spec that says if it's little or big |
23:44:13 | FromDiscord | <mratsim> ah |
23:44:22 | FromDiscord | <mratsim> so it really contains a blob |
23:44:37 | * | PMunch quit (Quit: leaving) |
23:44:39 | arkanoid | I'm dealing with apache arrow specs, so I guess they made them right. It's me that requires fixing |
23:44:49 | FromDiscord | <mratsim> well I will need to review the spec and the code, but openarray[byte] sems suitable |
23:45:33 | FromDiscord | <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:52 | FromDiscord | <mratsim> and a high-level API that abstract away dealing with offset should be added. |
23:46:08 | FromDiscord | <mratsim> anyway, I'll review it later. |
23:46:14 | arkanoid | well, openArray deals with it, right? |
23:46:31 | arkanoid | "func itemBlob*(arr: ArrowArray, i: int): openArray[byte] =" |
23:47:42 | FromDiscord | <mratsim> you mentioned offsets, when you pass a i, does it select a contiguous range based on these offsets? |
23:49:27 | arkanoid | mratsim, correct |
23:49:38 | arkanoid | I end up with a pointer and a length |