<< 19-01-2023 >>

00:00:43FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/H30
00:04:50FromDiscord<Saint> Ohh
00:04:56FromDiscord<Saint> That makes a lot of sense, thanks
00:04:58FromDiscord<Saint> (edit) "thanks" => "thanks!"
01:15:32*jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…)
01:42:40*krux02 quit (Remote host closed the connection)
02:03:19*argonica quit (Remote host closed the connection)
02:04:16FromDiscord<DUO Labs> When trying to turn off case insensitivity, I get this\: \`Warning\: 'cs' is deprecated, now a noop [Deprecated]\`. Is there an agreed way of disabling case insensitivity (so that \`FOO\` and \`foo\` refer to different variables)?
02:04:51FromDiscord<huantian> `FOO` and `foo` should already be different variables↵but I don't think there's a way to turn it off entirely?
02:06:26FromDiscord<amadan> `--styleCheck:error --styleCheck:usages` should do it iirc
02:07:41FromDiscord<DUO Labs> That's what I thought at first, but if I export a variable FOO in filea.nim and a variable foo in fileb.nim, and import them both in filec.nim, then try to use \`foo\`, I get \`ambiguous identifier\: 'foo'\`
02:08:31FromDiscord<DUO Labs> `test`
02:08:49FromDiscord<DUO Labs> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/1065452454940004462): That's what I thought at first, but if I export a variable FOO in filea.nim and a variable foo in fileb.nim, and import them both in filec.nim, then try to use `foo`, I get `ambiguous identifier: 'foo'\`
02:09:00FromDiscord<DUO Labs> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/1065452454940004462): That's what I thought at first, but if I export a variable FOO in filea.nim and a variable foo in fileb.nim, and import them both in filec.nim, then try to use `foo`, I get `ambiguous identifier: 'foo'`
02:09:00FromDiscord<huantian> In reply to @amadan "`--styleCheck:error --styleCheck:usages` should do": that causes an error if you have different cases, but doesn't actually allow you to use different casings
02:09:17FromDiscord<DUO Labs> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/1065451596722475068): When trying to turn off case insensitivity, I get this\: `Warning: 'cs' is deprecated, now a noop [Deprecated\]`. Is there an agreed way of disabling case insensitivity (so that `FOO` and `foo` refer to different variables)?
02:10:46FromDiscord<amadan> Having those three files works for me, you didn't name any of the files foo did you?
02:12:48*argonica joined #nim
02:13:23FromDiscord<DUO Labs> No
02:17:52FromDiscord<DUO Labs> sent a code paste, see https://play.nim-lang.org/#ix=4lCR
02:18:06FromDiscord<Rika> Well that’s counted as the same
02:18:29FromDiscord<Rika> Style insensitivity doesn’t include the first letter case so Foo and foo aren’t the same but Foo and FOO are the same
02:19:31FromDiscord<Rika> No you cannot make them different, best you can do is disallow the different styles or disambiguate the use by prefixing with the module
02:19:52FromDiscord<Rika> So use "utils.LOGGER" or so instead
02:21:20*beholders_eye quit (Ping timeout: 246 seconds)
02:23:44FromDiscord<DUO Labs> I just got around it by just using `debug, info,...` instead (since I only have on logger)
02:36:44FromDiscord<DUO Labs> I&#x27;m trying to save a class `Foo` to variable `bar`, then making an instance with `bar(var1: foo1, var2: foo2,...)`, but this fails with `Error: type expected`.
02:37:22FromDiscord<huantian> sent a code paste, see https://play.nim-lang.org/#ix=4lCU
02:37:29FromDiscord<DUO Labs> sent a code paste, see https://play.nim-lang.org/#ix=4lCV
02:38:08FromDiscord<DUO Labs> Oh, I see.
02:48:53*arkurious quit (Quit: Leaving)
02:59:53FromDiscord<T0lk1en> Yo yo
03:02:07FromDiscord<T0lk1en> I’m working on a reverse shell rn. The shell works fine but my problem is that when run I can only interact with the folder that the program is run in. I was thinking about adding the program to path and then running the command in C folder but this seems overly complicated. I know this isn’t directly related to nim but was hoping someone had some insight
03:02:28FromDiscord<T0lk1en> https://github.com/ko-mill/mill-shell
03:02:38FromDiscord<T0lk1en> Code for those wondering^^
03:07:17FromDiscord<pyolyokh> by "I can only interact with the folder that the program is run in", you mean that since you're spawning a new shell for each command that the working directory of a previous command (like "cd ..") is lost?
03:07:44FromDiscord<T0lk1en> Yeah that sounds correct
03:07:49FromDiscord<pyolyokh> that doesn't actually prevent you from working with the rest of the filesystem. It's just less pleasant.
03:08:39FromDiscord<T0lk1en> How would you have a peristaltic shell without spawning a new shell every time a command is ran
03:08:46FromDiscord<T0lk1en> Persistent
03:09:07FromDiscord<pyolyokh> the two tactics that I see in the wild are (of PHP shells): they never call out to bash or cmd.exe or anything, but just implement a subset of commands and maintain their own state, and (of perl, python, c reverse shells): they spawn a shell once per connection, not once per command, and they just connect the socket and the shell together by pipes. that's just some dup2 calls
03:10:06FromDiscord<T0lk1en> Wdym buy that last part. From they - calls
03:10:52FromDiscord<Elegantbeef> You spawn a shell handler which takes in data from a socket or stdin, and sends it to a persistent shell
03:11:09FromDiscord<T0lk1en> Hmm
03:11:40FromDiscord<T0lk1en> I’ll have to put in some more work. Thanks for the answers guys.
03:11:59FromDiscord<pyolyokh> for BSD sockets, certain syscalls care in some ways if it's actually a socket or not, but most I/O doesn't. Write to a file, write to a socket, it works the same. So you receive a connection, fork, set up stdin/stdout/stderr to point to the socket with dup2(), then exec the shell, which then reads and writes from the socket without knowing there's anything special about it.
03:12:51FromDiscord<T0lk1en> Stderr?
03:13:02FromDiscord<pyolyokh> a search for 'perl reverse shell' brings up `open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S")` pretty quickly. That's Perl's version of what I just said.
03:13:11FromDiscord<T0lk1en> Gotcha
03:13:23FromDiscord<T0lk1en> Ty
03:14:19FromDiscord<T0lk1en> While your here can I get some advice on making a listener. I’m currently using net cat but would like to make my own
03:16:01FromDiscord<pyolyokh> if you're not doing any kind of concurrency, and you're probably not with a reverse shell, there's nothing to it. Just use <https://nim-lang.org/docs/net.html> , maybe read beej's guide if you don't understand the terms
03:17:02FromDiscord<T0lk1en> Gotcha
03:54:32*argonica quit (Quit: Leaving)
03:55:00*argonica joined #nim
04:12:08FromDiscord<T0lk1en> Yo was looking at os library for something that can execute cmd commands but Al those do is return a string of what the executed command would have looked like. Is there a library that actually does cmd commands
04:24:29FromDiscord<pyolyokh> "would have looked like"? it's not speculating, it actually runs the command and collects its output
04:24:47FromDiscord<pyolyokh> and right next to that command are others that spawn the process and let it run independently
04:25:14FromDiscord<pyolyokh> ah actually, maybe os only has simple stuff. I'd always gone directly to <https://nim-lang.org/docs/osproc.html>
04:25:42FromDiscord<pyolyokh> startProcess in that module is good one to start wtih
04:34:38FromDiscord<T0lk1en> How come these have to return something. Why can’t they just be alone. What I mean by this is I always get the error must be used or discarded. Why must I do something
04:35:48FromDiscord<pyolyokh> they don't have to return something. They do because the returns are extremely useful.
04:39:23*argonica quit (Quit: Leaving)
04:40:57FromDiscord<pyolyokh> and the language wanting you to very rarely add an explicit `discard` to throw away a useful return value, that's just a deliberate design choice. It's not common a design, but it's not a big deal either.
04:45:57FromDiscord<pyolyokh> sent a long message, see http://ix.io/4lD8
04:46:25FromDiscord<T0lk1en> So even though I discard something it still runs it?
04:46:41FromDiscord<pyolyokh> yes, you're just not using the return
04:47:21FromDiscord<pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4lD9
04:47:48FromDiscord<T0lk1en> Ab gotcha
04:47:50FromDiscord<T0lk1en> Ah
04:49:36FromDiscord<T0lk1en> Weird
05:23:49*TakinOver quit (Ping timeout: 260 seconds)
05:27:22FromDiscord<pyryrin> Wrapping c libraries to nim is hard
05:28:19FromDiscord<T0lk1en> What’s the purpose of doing that. Additional finctionality?
05:28:29FromDiscord<T0lk1en> Functionality?
05:34:32FromDiscord<Elegantbeef> What?
05:39:39FromDiscord<Leftbones> choosenim automatically installed the amd64 version on my m1 mac, how could I make it install the arm64 version?
05:39:56FromDiscord<Elegantbeef> Nope dont think it works with arm yet
05:40:03FromDiscord<Rika> In reply to @T0lk1en "What’s the purpose of": Catches bugs
05:40:49FromDiscord<Leftbones> In reply to @Elegantbeef "Nope dont think it": A year ago in this thread it was stated that the next major verison would support it, did that never happen? https://forum.nim-lang.org/t/7823
05:41:05FromDiscord<Leftbones> Otherwise I'll just try the method in that thread, I was just hesitant in case it was outdated now.
05:41:10FromDiscord<Elegantbeef> Nim does choosenim doesnt afaik
05:41:10*rockcavera quit (Remote host closed the connection)
05:41:22FromDiscord<Leftbones> Oh gotcha
05:41:29FromDiscord<Leftbones> So I have to build from source
05:47:24FromDiscord<Leftbones> Aaaand that method no longer works. Rip.
05:53:17FromDiscord<Leftbones> Ehhh, just running the build_all.sh doesn't seem to be doing it, is there something else I have to do? (choosenim won't let me remove the installed version if that matters?)
05:56:37*argonica joined #nim
05:58:18FromDiscord<Elegantbeef> what's going wrong?
05:58:29FromDiscord<Elegantbeef> After `./build_all.sh` there should be a `nim` inside `bin`
06:05:27FromDiscord<Leftbones> Hang on I'm deleting both choosenim and Nim and starting over, I think I screwed something up
06:10:03FromDiscord<Leftbones> After running the script, I try to check the version in the bin folder but it is looking for an installation in the choosenim folder, which doesn't exist
06:10:12FromDiscord<Leftbones> `~/.choosenim` doesn't exist, I mean
06:10:35FromDiscord<Leftbones> And I'm not trying to use choosenim anyways because it doesn't support m1
06:15:12FromDiscord<Elegantbeef> I dont know what to tell you after building you need to move it to your path or add it to your path
06:16:07FromDiscord<Leftbones> Installing from --HEAD on brew worked.
06:17:24FromDiscord<Leftbones> In reply to @Elegantbeef "I dont know what": I know that, what I mean is even just running `nim --version` gives an error about how it can't find an installation at `~/.choosnim/whatever` but either way I'm going to bed. Idk if the version I got from brew is up to date but I'll check on that tomorrow.
06:23:40FromDiscord<pyolyokh> that'l be your shell complaining, not nim
06:23:57FromDiscord<pyolyokh> new mac uses zsh, which has odd caching rules by default
06:24:19FromDiscord<pyolyokh> the simplest solution's to open a new terminal
06:45:02*azimut quit (Ping timeout: 255 seconds)
07:17:19FromDiscord<htac> does anyone know what happened to @timotheecour ? He was a vital dev on Nim once, putting an enormous effort in it, and worked on some elaborate ideas to further its development, in my humble opinion
07:23:02FromDiscord<Elegantbeef> Think he got a different job and disappeared
07:25:54FromDiscord<ringabout> I suppose his new job is busy. https://www.linkedin.com/in/timothee-cour-b249378
07:26:29FromDiscord<ringabout> (edit) "I suppose ... hisjob." added "he is busy at" | "job is busy." => "job."
07:26:54FromDiscord<htac> damn you, Amazon! 😊
07:27:22FromDiscord<htac> thank you, @ElegantBeef and @ringabout
07:35:07*om3ga quit (Quit: Bye)
07:42:08FromDiscord<htac> especially for your contributions, the two of you
07:42:23FromDiscord<htac> (edit) "contributions," => "contributions to Nim dev,"
07:50:06*PMunch joined #nim
08:38:14*jjido joined #nim
08:51:09*jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…)
11:28:38*beholders_eye joined #nim
11:42:18*om3ga joined #nim
11:58:38*om3ga quit (Quit: Bye)
12:00:19*om3ga joined #nim
12:23:44*beholders_eye quit (Ping timeout: 246 seconds)
13:05:02*argonica quit (Quit: Leaving)
13:37:35FromDiscord<turbo> What's the recommended way to share static, read-only data between threads? On startup I'd like to allocate a large map (string -> float array) and all threads should be able to read from it at the same time.
13:38:32FromDiscord<turbo> In reply to @Leftbones "choosenim automatically installed the": I wrote up a guide on that here: https://summarity.com/nim-2-m1
13:40:37FromDiscord<mratsim> In reply to @turbo "What's the recommended way": use a barrier
13:41:27FromDiscord<mratsim> lift the implementation here: https://github.com/status-im/nim-taskpools/tree/stable/taskpools/primitives
15:07:42*arkurious joined #nim
15:11:54*PMunch quit (Quit: Leaving)
15:12:00*rockcavera joined #nim
15:18:48*nmz joined #nim
15:22:31nmzHello, I've decided to learn nim, I usually start coding by reimplementing unix tools like cat and so on, has anyone tried done this already (like busybox) in nim?
15:22:37FromDiscord<@thatrandomperson5-6310e3b26da03> How would i make a parent based nodetree, so instead of each parent containg children each child refers to a parent
15:24:25Amun-Ranmz: I usually start writing my own crypto function implementations
15:28:25nmzhmm, closest I've come to that is a rot13, but maybe I should start by doing project euler or advent of code or something
15:55:16FromDiscord<auxym> pretty sure Amun-Ra was being sarcastic (because a s rule of thumb you should pretty much never roll your own crypto).
15:55:48FromDiscord<auxym> Anyways, I'm not aware of Nim implementations of standard unix cli commands, except maybe ttop which is like top/htop
15:56:36FromDiscord<auxym> Write whatever interests you, that's the most important part (aoc is fun though, IMO, and I could never get into PE much, too much mathy)
15:59:37FromDiscord<Leftbones> In reply to @turbo "I wrote up a": Thank you! This installed the same version as brew did, by the way.
15:59:46FromDiscord<Leftbones> So, more steps, but good for those who don't like using package managers.
16:01:14*azimut joined #nim
16:24:49FromDiscord<Require Support> I hope someone with more experience can give me a solution to how to implement this or if it's even possible. I would like to have a main thread running that downloads data from HTTP server periodically and when it gets specific data I would like to pass it to another thread that is also running, the other thread receives the data from the main thread and processes it. No return value from the second thread.
16:25:59FromDiscord<Require Support> (edit) "I hope someone with more experience can give me" => "sent" | "solution to how to implement this or if it's even possible. I would like to have a main thread running that downloads data from HTTP server periodically and when it gets specific data I would like to pass it to another thread that is also running, the other thread receives the data from the main thread and processes it. No return value from the second thread."
16:33:16FromDiscord<turbo> You can create a thread and use channels with (try)recv to communicate. Keep the thread alive with periodic sleeping (or use recv to block until new data is available)
16:34:03FromDiscord<Require Support> In reply to @turbo "You can create a": yeah I was looking at the channels example, would the channel need to be a global variable amongst all threads?
16:36:03FromDiscord<turbo> In reply to @Require Support "yeah I was looking": Yeah, see the example: https://nim-lang.org/docs/channels_builtin.html
16:37:07FromDiscord<turbo> I'm using the same pattern in a server where I have one thread dedicated to SQLite writes to prevent BUSY issues.
16:40:29FromDiscord<Require Support> nice, what if I don't know how many channels I'd need at compile time? The user can generally create as many threads as they need. Is there a way to dynamically spin up these channels when the secondary thread is created? Sorry if these questions seem dumb, im new to this
16:40:55FromDiscord<turbo> Hm, that seems like a better use case for `spawn`
16:41:19FromDiscord<turbo> https://nim-lang.org/docs/manual_experimental.html#parallel-amp-spawn-spawn-statement
16:42:31FromDiscord<turbo> Otherwise you'd have to somehow multiplex that coordination using one persistent channel. There may be other ways I don't know about.
16:43:14FromDiscord<Require Support> that is what im using right now, but im running into problems with SMB pipes when multiple threads try to act on the same pipe, even after checking and waiting. So was looking to see if I can create one thread on user request and let it process data to the pipe until user is done with it.
16:43:29FromDiscord<Require Support> (edit) "that" => "`spawn`"
16:45:12FromDiscord<enthus1ast> @Require Support\: i would use createThread
16:45:27FromDiscord<enthus1ast> i felt spawn was somehow buggy or strange
16:45:35FromDiscord<enthus1ast> https://nim-lang.org/docs/threads.html
16:45:43FromDiscord<turbo> Why are you creating one thread per request? If you need to prepare data before flushing it to the pipe you could use spawn _and_ create one SMB writer thread, the spawned procs put their data into the channel for the writer to flush
16:46:33FromDiscord<turbo> Otherwise all threads will block anyway and you'll run into contention (if I understand your setup correctly)
16:48:31FromDiscord<Require Support> In reply to @turbo "Why are you creating": that's a nice setup, I'll give it a try
16:48:59FromDiscord<Require Support> In reply to @enthus1ast "<@710108871724761128>\: i would use": This might be cause my issues, I'll try createThread
16:52:58FromDiscord<enthus1ast> you could prepare a array with eg 128 threads, and another one with 128 channels, then spawn them accordingly, could work
16:53:32FromDiscord<turbo> aren't you basically implementing the spawn threadpool at that point 😄
16:53:41FromDiscord<enthus1ast> maybe
16:57:44FromDiscord<Dexterdy> sent a code paste, see https://play.nim-lang.org/#ix=4lGa
16:58:01FromDiscord<Dexterdy> (edit)
16:59:46FromDiscord<Array in ∀ Matrix> whats a good way to check or sanitize user input
17:00:15FromDiscord<Array in ∀ Matrix> for example to check if a certain input is actually an int or float
17:04:39FromDiscord<turbo> There's https://planety.github.io/prologue/plugin/validater/validater.html
17:04:40FromDiscord<Phil> In reply to @Dexterdy "Hi there. Could someone": Your type must either be concrete or generic.↵Concrete type declarations must also have concrete types in all their fields.↵Currently it is a concrete type, because GlobalInfo doesn't have a generic "parameter"
17:06:41FromDiscord<Phil> GlobalInfo must be turned into a generic type declaration given how you wrote that code.↵Because while it may not seem like it, "Module" is a generic-type with mostly some restrictions as defined by your concept.
17:06:55FromDiscord<Phil> Now let me look up how generic type declarations worked again because I haven't done that much work with generic types
17:07:33FromDiscord<Dexterdy> So I add a generic parameter T to the GlobalInfo? What's the syntax for specifying-. Yeah that :)
17:09:31FromDiscord<Array in ∀ Matrix> thank you↵(@turbo)
17:10:39FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lGf
17:11:00FromDiscord<Dexterdy> thank you!
17:11:32FromDiscord<Phil> In reply to @Dexterdy "thank you!": Oh! and `GlobalInfo[Module] = object` if you want to export
17:12:16FromDiscord<Phil> It works pretty much identical to how it works in generic procs:↵<name><exportsymbol><genericparams>....other stuff...
17:17:51FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lGh
17:18:55FromDiscord<Dexterdy> aaah, like so. That's why I can't seem to make regular local variables of such a type
17:19:16FromDiscord<Phil> Aye, it's also why you can't ever have a seq that contains both strings and ints
17:19:25FromDiscord<Dexterdy> (edit) "local" => "global"
17:19:37FromDiscord<Phil> You can have a seq that can contain strings or ints, but not both at the same time, unless you use object variants
17:19:49FromDiscord<Dexterdy> hmhm
17:20:23FromDiscord<Phil> (edit) "variants" => "variants, because the second nim gets to the first time you explicitly state which type it uses in the generics place, it'll use that."
17:21:39FromDiscord<Phil> And yeah, one global object that can contain all different types isn't going to work ^^↵If you have a limited amount of types you can try to use an object variant
17:22:40FromDiscord<Phil> Alternatively you could try for OOP and make use of dynamic dispatch, have a base-class that you put in that type thing, then have all child-classes implement the same methods
17:23:26FromDiscord<Dexterdy> yeah, that's what I'll use. That or regular enums. I'm not much of a fan of OOP, tbh
17:23:45FromDiscord<Phil> Me neither, I tend to dislike how it obscures control flow
17:30:33FromDiscord<auxym> In reply to @Require Support "`spawn` is what im": spawn is known to be pretty bad, consider using taskpools or weave from nimble for something like that
17:33:27FromDiscord<Require Support> 😦 why is the standard library like this
17:42:56*azimut quit (Ping timeout: 255 seconds)
17:45:00*azimut joined #nim
17:48:08FromDiscord<@thatrandomperson5-6310e3b26da03> > How would i make a parent based nodetree, so instead of each parent containg children each child refers to a parent↵Anyone know? I tried just using ref objects but kept on getting Attempting to read from nil errors, i think the gc is eating them
17:53:54*jjido joined #nim
18:03:41FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4lGm
18:03:57FromDiscord<jtv> Since the 70's, polymorphism has been broken up into 4 different kinds, ad hoc, coercion, inclusion and parametric. They all have their place to some degree, and most languages have all 4. Template / generic mechanisms are parametric polymorphism, which is all resolvable statically. Inclusion polymorphism is generally inheritance, which is NOT typically resolvable statically. Coercion == casting, and ad hoc are type rules built into and a
18:04:31FromDiscord<jtv> So Nim's not significantly different here from many, many other languages
18:08:19FromDiscord<Phil> I assume this is more directed and me and my statement that OOP obscures control flow?
18:09:31FromDiscord<jtv> Oh, no, more felt that the impression was that Nim's generics were unusual in not being able to declare something to be a type that doesn't have a runtime resolution. That's inclusion polymorphism, whether you use inheritance for it or not. Modeled as sets
18:09:56FromDiscord<jtv> I 100% agree w/ you on OOP obscuring control flow, I came to that conclusion in 1996 or so 🙂
18:10:03FromDiscord<Phil> In reply to @jtv "Oh, no, more felt": Ohhhhh check.
18:10:26FromDiscord<Phil> In reply to @jtv "I 100% agree w/": To be fair, I was a toddler at that time, there's no way I could've had smarter thoughts like this !
18:10:29FromDiscord<Phil> 😄
18:10:42FromDiscord<jtv> I am pretty old, for sure 🙂
18:11:14FromDiscord<Phil> Whenever I want to feel old I just look at when GameBoy Advacned or Lotr came out
18:11:22FromDiscord<Phil> And remember that that was "the new shit"
18:11:31FromDiscord<Phil> (edit) ""the" => ""the"
18:12:04FromDiscord<jtv> I played Pong at my great uncle's house when I was a kid
18:12:24FromDiscord<jtv> 👴
18:12:37FromDiscord<Phil> Ah, so you look up when they released Pong to feel old
18:13:02FromDiscord<jtv> I just watched a documentary on it a few nights ago. Old people watch documentaries
18:13:27FromDiscord<Phil> I wanted to write "That's not true" because I occassionally watch some over various topics
18:14:07FromDiscord<Phil> But then I remembered again that I play Dnd with some folks that are literally barely out of highschool and was forced to shut up
18:15:07FromDiscord<jtv> I remember when my stepmother bought home dungeons and dragons in like 1980... pre-AD&D even.
18:15:17FromDiscord<Phil> `could not load: (libmysqlclient|libmariadbclient).so(|.20|.19|.18|.17|.16|.15)` Yay, hunting packages for who contains this SO file
18:18:55FromDiscord<jtv> I assume there's a way for me to prototype something in one module I implement in another, correct? Can't remember seeing it tho, and not picking it up via google. Would really be useful for cross-module dependencies. Right now, I'm basically having to go through contortions to avoid recursive imports
18:20:35FromDiscord<Phil> prototype as in do a type declaration that states "this type must be able to do X"?
18:20:39FromDiscord<Phil> Because that'd be a concept
18:20:43FromDiscord<Phil> (edit) "concept" => "`concept`"
18:21:07FromDiscord<Phil> If you want something like a module interface, there's nothing built in I don't think
18:21:09FromDiscord<jtv> No, be able to say, "proc f()" without the =, but have f be defined in an external module
18:21:28FromDiscord<jtv> Works in C quite well :).
18:21:32FromDiscord<Phil> There's packages, but they affect how you structure your code
18:22:29FromDiscord<jtv> And most languages don't need it, because they're better about such things. Nim's going to get there soon it looks like, but for now I'm not enjoying organizing my code :/
18:22:30FromDiscord<Phil> https://github.com/planetis-m/protocoled↵https://github.com/itsumura-h/nim-interface-implements↵Would be candidates
18:23:27FromDiscord<jtv> No, I don't want interfaces, I want the prototype just to tell the compiler to do it's work w/o barfing because it can't find the implementation in that module... it'll find it before long!
18:24:32FromDiscord<jtv> From X, I want to be able to call a specific concrete function, exported by Y, but still have Y importing X
18:24:36FromDiscord<Phil> isn't an interface basically just the type/proc/func declaration without the implementation?↵It's "This is what it will be and what it will return", at least the way I use the word
18:25:07FromDiscord<jtv> Yeah but I have a single implementation I need to call, not something generic based on an object type or what have you
18:25:19FromDiscord<jtv> It's more that Nim's about the worst at cyclic dependencies
18:25:32FromDiscord<jtv> C prototypes solve that problem (C is 2nd worst)
18:26:39FromDiscord<Phil> I worked around the issue of cyclic dependencies by having tiny modules 😅 ↵I can't think of anything high level that I used before that would fulfill this, but that could likely just be because I haven't exposed myself that much to the lower-level side of nim
18:27:11FromDiscord<jtv> Tiny modules makes it worse. Monolithic would be better for avoiding cycles 🙂
18:27:33FromDiscord<jtv> That's the thing, I prefer smaller, but sometimes there are interdependencies
18:29:07FromDiscord<Phil> Ah, that might just be a code structure thing then, my cyclic dependency issues typically stemmed from module A needing proc B from module B, but module B needed proc C from module A. Thus I just splitted proc C out and that solved my problem.↵Haven't yet had to deal with true interdependencies
18:29:23FromDiscord<Require Support> i have a point to an object that im passing to the thread. How can I let the thread create a copy of the object to use for its processing? is it as simple as assigning it to a new var?
18:30:06FromDiscord<Require Support> (edit) "point" => "pointer"
18:30:17FromDiscord<Phil> I'd explicitly clone because I don't want to trust implicit copy behaviour, especially if I can't be 100% sure it'll remain in the future
18:31:00FromDiscord<Require Support> In reply to @Isofruit "I'd explicitly clone because": you mean manually create the object and assign everything yourself?
18:31:15FromDiscord<jtv> Well, for instance, imagine you have a huge app w/ a lot of different config options / info. If every module is importing that, it's basically incapable of calling back into the other modules to calculate what needs to change in one part of the system based on what it got from sone other part of the system.
18:31:17FromDiscord<Phil> In reply to @Require Support "you mean manually create": I'd look for a clone or copy proc to do that for you
18:32:24FromDiscord<sOkam!> sent a long message, see http://ix.io/4lGv
18:32:53FromDiscord<jtv> For cases like that, I have modules registering handlers to avoid the dependency, and then even getting them imported confuses Nim... tells me some of my modules aren't used when they definitely are 🙂
18:33:00FromDiscord<jtv> It's super unnatural
18:34:24FromDiscord<sOkam!> i think about modules and submodules like this↵sure, the end result will do the exact same thing... but the dependency hell will be much more manageable https://media.discordapp.net/attachments/371759389889003532/1065700768369356810/image.png
18:35:37FromDiscord<Phil> So sort of kind of like a py file or whatever it was in python
18:35:48FromDiscord<Phil> (edit) "py" => "\_\_py\_\_"
18:35:50FromDiscord<jtv> My code tend to me more like the rack on the right 🙂
18:36:13FromDiscord<Phil> With central access points to the code of a package
18:36:44FromDiscord<jtv> No, in python a cyclic import definitely works
18:40:50FromDiscord<sOkam!> In reply to @jtv "My code tend to": i started learning to code by studying quake engine↵After spending months trying to sort the mess... I realized that you are either the left rack, or the right rack... there's no inbetween 🙈
18:41:02FromDiscord<sOkam!> (edit) "studying" => "studying/coding with"
18:45:20FromDiscord<Phil> Okay, am I dumb? Isn't `mysql-client` the debian package containing libmysqlclient, which nim needs for db_mysql?
18:53:22FromDiscord<Phil> Nope, turns out `default-libmysqlclient-dev` is what I was looking for >_>
18:53:42FromDiscord<Phil> Linux package names are one of those things where you basically have to know what you're looking for, bleh
18:54:01FromDiscord<sOkam!> In reply to @Isofruit "Okay, am I dumb?": https://media.discordapp.net/attachments/371759389889003532/1065705706843545751/image.png
18:54:58FromDiscord<Phil> In reply to @sOkam! "": 🤷 ↵I brute forced my way through the docker image description needed to get my stuff to compile
18:54:59FromDiscord<sOkam!> In reply to @Isofruit "Linux package names are": that's why the package search option is so good. afaik most distros have it
18:55:03FromDiscord<Phil> nothing else worked
18:55:41FromDiscord<Phil> It is at this point that me being on arch but likely using a debian based docker image (nim 1.6.10 is debian based I think, does use apt) screws me
18:57:48FromDiscord<sOkam!> In reply to @Isofruit "It is at this": what do you mean by nim being debian based?
18:58:00FromDiscord<Phil> The nim docker image
18:58:31FromDiscord<sOkam!> why do you use a docker image, instead of choosenim? do you need docker funcionality specifically?
18:59:17FromDiscord<Phil> For CI/CD pipelines
19:00:43FromDiscord<Phil> I start up a nim-docker container with my source code and tests and separate from that I start up mysql/postgres containers, all coordinated via docker-compose.↵The nim-docker-container with my package compiles and executes its tests, as part of which it does calls to mysql/postgres/sqlite databases
19:01:06FromDiscord<Phil> For local development I got choosenim
19:01:16FromDiscord<sOkam!> ic
19:01:41FromDiscord<sOkam!> ci/cd sure sounds messy
19:02:01FromDiscord<Phil> CI/CD in general is a massive pain in my ass, but I'm starting to get better at it, as this is the second time now that I'm properly setting them up
19:02:17FromDiscord<Phil> And the assurance that my source code actually works is nice
19:02:49FromDiscord<Phil> So I can actually tell people that e.g. want to use mysql "hey, if you need connection pooling, you can use tinypool"↵etc.
19:03:33FromDiscord<Phil> Though now I need to rewrite all my SQL statements that I copy pasted from my other tests into sth mysql compatible...gnaaa
19:24:00FromDiscord<Phil> Heck yeah, for nim 1.6.10 the tests run, now to the next step which is make them work on nim 2.0 with all the db_connector stuff
20:22:49FromDiscord<Phil> angry sounds in the distance
20:23:14FromDiscord<Phil> Okay... err... is there no way to install a specific devel version of the compiler?
20:24:08FromDiscord<Phil> Or is it basically `choosenim <stable version or devel>` ?
20:24:33arkanoidis myseq.len * myseq.sizeof the right way to get myseq buffer size (for C?)
20:35:30FromDiscord<hugogranstrom> `myseq[0].sizeof` otherwise O think you get the size of the object with capacity + ptr↵(<@709044657232936960_arkanoid=5b=49=52=43=5d>)
20:35:54FromDiscord<hugogranstrom> Might be wrong, but this should definitely work at least
20:36:11FromDiscord<Elegantbeef> Depends on which MM you're using
20:36:21FromDiscord<Elegantbeef> `sizeof(seq)` on refc is 8, but on orc it's 16
20:36:37FromDiscord<Elegantbeef> But yea you're correct that you do `mySeq.len sizeof(mySeq[0])`
20:38:14*kenran joined #nim
20:42:04FromDiscord<Phil> Today is the first time where I actually ran into trouble with an ubuntu image, who'da thunk
20:42:09FromDiscord<Phil> (edit) "who'da" => "who'dve"
20:42:30FromDiscord<huantian> give up docker join nix gang!
20:42:50FromDiscord<Phil> In reply to @huantian "give up docker join": Write my github CI/CD pipelines for me and I shall contemplate xP
20:44:10FromDiscord<Phil> So far I managed to find ways to do github-served package docs as well as test-runs with docker, that was already painful enough.↵Any alternative would need to be a damn sight easier, which I'm not sure it can due to the very nature of the problem
20:45:58FromDiscord<huantian> lol
20:56:46FromDiscord<jtv> sent a long message, see http://ix.io/4lHd
20:57:34FromDiscord<jtv> I get lovely type incompatibility errors that differ only in lock level 0 vs. unknown
20:58:38FromDiscord<Elegantbeef> Full error?
20:58:40FromDiscord<Elegantbeef> Or code that demonstrates it
21:00:13FromDiscord<Elegantbeef> But yea only nimcall can be converted to closure
21:00:34FromDiscord<jtv> const fptrs = [(304, "writeFile", builtinWriteFile, "f(string, string) -> bool"),↵ (305, "copyFile", builtInCopyFile, "f(string, string) -> bool"),↵ (306, "moveFile", builtinMove, "f(string, string) -> bool"),↵ (307, "rmFile", builtinRm, "f(string)->bool")]
21:00:36FromDiscord<jtv> those all work
21:00:55FromDiscord<jtv> But if I add in say this one: (109, "format", builtInFormat, "f(string) -> string"),
21:01:05FromDiscord<jtv> There's nothing much different about builtinFormat
21:01:09FromDiscord<jtv> Same signature as all the rest
21:01:25FromDiscord<Elegantbeef> What's the error?
21:02:13FromDiscord<jtv> `/ Error: type mismatch: got '(int, (string, BuiltInFn, string))' for '(109, ("format", BuiltInFn(builtInFormat), "f(string) -> string"))' but expected '(int, (string, proc (args: seq[Box], unused1: Con4mScope, unused2: VarStack, unused3: Con4mScope): Option[box.Box]{.locks: 0.}, string))'`
21:02:57FromDiscord<jtv> All these functions have the exact same signature, and there are plenty of them. Only some small number fail
21:03:35FromDiscord<Elegantbeef> Does making your `BuiltInFn` have `{.locks: unknown.}` help?
21:03:41FromDiscord<Elegantbeef> Luckily lock levels are getting removed soon
21:04:01FromDiscord<jtv> Let me check. I tried that in a cast, but I'll put it in a type decl
21:05:31FromDiscord<jtv> Where do I put the pragma if I'm using sugar to declare the type?
21:05:48FromDiscord<jtv> Right now it's ` BuiltInFn = ((seq[Box], Con4mScope, VarStack, Con4mScope) -> Option[Box])`
21:08:22FromDiscord<jtv> I even can't get the syntax if I rewrite it w/o sugar (this doesn't work): ` BuiltInFn = proc(i0: seq[Box], i1: Con4mScope, i2: VarStack, i3: Con4mScope) : Option[Box] {.locks: unknown.}`
21:09:27FromDiscord<Elegantbeef> Hmph one cannot use `unknown` apparently 😄
21:09:42FromDiscord<jtv> Yay. Putting 0 does not work
21:11:35FromDiscord<Elegantbeef> Well without a replication i can run i'm not going to be able to help any
21:12:21FromDiscord<jtv> Let me create a branch and push something broken so you can look at it if you like, one second
21:14:25FromDiscord<jtv> https://github.com/crashappsec/con4m/tree/borked
21:15:11FromDiscord<jtv> nimble build will blow up, but comment out the one line of code, it won't. The functions are all defined above in the file, and the type decl you saw is in types.h
21:16:23FromDiscord<Elegantbeef> Just a quick comment you can just do `VarStack(nil)`
21:17:51FromDiscord<jtv> Cool thanks. I was def playing 'find the syntax' when I wrote those bits. Was probably early Dec.
21:18:32FromDiscord<pyolyokh> `nimble build` doesn't blow up for me with that on stable, and in devel it errors out in nimaws, before getting to con4m itself
21:18:50FromDiscord<jtv> Weird, it does on 3 boxes for me on stable.
21:18:55FromDiscord<pyolyokh> <https://nim-lang.org/docs/manual_experimental.html#guards-and-locks-lock-levels> `{.locks: "unknown".}`
21:19:16FromDiscord<jtv> I guess I should try Linux not my macs
21:19:30FromDiscord<Elegantbeef> It errors on stable with the same thing for me
21:19:38FromDiscord<pyolyokh> ah, no, I naively assumed that the git clone command that github provides would reflect the current branch
21:21:29FromDiscord<pyolyokh> ok, type mismatch:, `got {.gcsafe, locks: <unknown>.}, but expected {.locks: 0.}`
21:22:15FromDiscord<Elegantbeef> do `BuiltInFn myProc` on all of them
21:22:16FromDiscord<jtv> Right, right. But on the function that fails (and a few more you can see down below), there's nothing significantly different in those procs on the surface.
21:22:26FromDiscord<Elegantbeef> This will convert to the proper procedure type
21:23:06FromDiscord<jtv> Ok will give it a shot thanks :). Wish I understood what's going on, I hate when problems seem random
21:23:25FromDiscord<Elegantbeef> The issue is that inside a definition like this the first procedure sets the type
21:23:31FromDiscord<Elegantbeef> So if there isnt a matching procedure later on it errors
21:23:43FromDiscord<Elegantbeef> If you do `BuiltInFn myProc` it converts them all to the same type
21:23:50FromDiscord<jtv> Sure, but what is causing those procs to be incompatable?
21:24:09FromDiscord<jtv> I did cast it and put it first in my attempts to fix, and it didn't work. But I'll try, just a second
21:24:21FromDiscord<Elegantbeef> It worked here doing what i said
21:24:40FromDiscord<jtv> Excellent
21:24:47FromDiscord<pyolyokh> what you probably ran into is that you cast only the first one. The second proc is now incompatible with it
21:25:41FromDiscord<jtv> When it decides to auto-cast a proc and when it doesn't is far from clear. I guess, "not in tuples" is one rule 🙂
21:25:42FromDiscord<Elegantbeef> The issue really seems to be locklevels
21:26:02FromDiscord<Elegantbeef> Well the lock levels differ
21:26:13FromDiscord<Elegantbeef> You had `0` but attempted to add a `unknown`
21:26:24FromDiscord<Elegantbeef> Locklevels are a stupid feature, but they're apart of type resolution
21:26:38FromDiscord<Elegantbeef> A proc with a different lock level is a different type
21:26:46FromDiscord<Elegantbeef> So you need the conversion to strip that information off
21:26:59FromDiscord<jtv> Got it, thanks.
21:27:20FromDiscord<Elegantbeef> You also want to do the conversion to strip `gcsafe` and `noSideEffect`, if Nim inferred that it'd equally say "Type mismatch"
21:28:08FromDiscord<jtv> Sometime soon I'll find time to take the pain of converting to the devel branch, just that I need fine to build my own aws library, the ones out there are no better than the crap one that clearly breaks when you move forward
21:28:49FromDiscord<jtv> Really appreciate it though.
21:32:30FromDiscord<Elegantbeef> perhaps it's just so helpful no one ever needs to write about mismatches now
21:56:06*kenran quit (Remote host closed the connection)
22:39:42*argonica joined #nim