<< 30-04-2023 >>

00:05:36FromDiscord<rb3.nim> sent a long message, see http://ix.io/4uzb
00:05:54FromDiscord<rb3.nim> (edit) "http://ix.io/4uzb" => "http://ix.io/4uzc"
00:06:26FromDiscord<rb3.nim> (edit) "http://ix.io/4uzc" => "https://paste.rs/vHL"
00:08:24FromDiscord<rb3.nim> The reason I'm using `nim compile` instead of `nim check` is I'm doing a lot of C++ ffi, so I want the diagnostics to display errors from the C++ compiler too
00:09:55*TakinOver quit (Ping timeout: 260 seconds)
00:11:19FromDiscord<Elegantbeef> @rb3.nim\: `nim -r --eval` should work with ffi
00:11:25FromDiscord<Elegantbeef> whoops `nim r`
00:13:18*mal`` joined #nim
00:21:06*xet7 joined #nim
00:36:50*xet7 quit (Remote host closed the connection)
00:44:45FromDiscord<リク> Heya. I'm trying to write some tcp client and server code but ran into an issue. The server accepts data 25 bytes at a time, and that works fine if the client sends data and does nothing else. But if the client sends data and then waits to get a response back, it seems to not fully finish sending the data before moving on to the recv proc. That causes the client and server to both hang.. Is there any way to make sure the client is fully do
00:48:48FromDiscord<Chronos [She/Her]> Could have a variable somewhere?
00:49:17FromDiscord<Chronos [She/Her]> After a recv call set it to true, after data is finished being sent, set it to false
00:50:22FromDiscord<リク> Is there a way to check if the data is fully sent? The receiving is done server-side so the client has no idea about it
00:51:37FromDiscord<Elegantbeef> Send returns how many bytes has been sent↵(@リク)
00:51:53FromDiscord<Elegantbeef> Could this be an issue of buffered vs. unbuffered?
00:52:06FromDiscord<Elegantbeef> By default sockets are buffered
00:52:19*xet7 joined #nim
00:52:22FromDiscord<リク> Oh nooooo the high-level version of send doesn't return anything
00:52:59FromDiscord<Elegantbeef> It has an OsError which would likely be raised if not fully sent
00:53:07FromDiscord<Elegantbeef> https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/net.nim#L1783-L1784 yea
00:53:37FromDiscord<リク> sent a code paste, see https://paste.rs/Pls
00:55:05FromDiscord<Elegantbeef> The client connects and the server accepts it?
00:55:59FromDiscord<リク> Yeah the server immediately accepts it and then receives 50 bytes of data before hanging
00:58:31FromDiscord<Elegantbeef> Is your server equally small?
00:58:50FromDiscord<Elegantbeef> I'd like to reproduce this, hopefully your server is also a single file
00:59:33FromDiscord<リク> Yeah I can post the code in a bit, I had to run to the store really quick
00:59:38FromDiscord<Elegantbeef> ok
01:24:33FromDiscord<リク> sent a code paste, see https://play.nim-lang.org/#ix=4uzp
01:25:57FromDiscord<リク> The server outputs↵25↵25↵before hanging heh
01:29:28FromDiscord<Elegantbeef> You do know `recv` waits until it has read 25 by default right?
01:30:20FromDiscord<リク> It seems like it requires you to specify a size
01:34:36FromDiscord<Elegantbeef> It does
01:34:39FromDiscord<Elegantbeef> but it also has a `timeout`
01:35:35FromDiscord<リク> Would it make sense to not have it at -1?
01:38:42FromDiscord<リク> Huh actually setting it to 500ms fixes the issue without corrupting the data or anything
01:39:31FromDiscord<リク> (I'm sure other timeout periods are fine too but it doesn't matter too much in my case)
01:39:58FromDiscord<Elegantbeef> Yea you may want to wrap it with a try except though for timeout errors
01:40:09FromDiscord<Elegantbeef> Cause you probably are building a buffer 25 bytes at a time eh
01:40:22FromDiscord<リク> Yeah haha
01:40:39FromDiscord<リク> It's still surprising that having unlimited timeout causes issues though
01:40:46FromDiscord<リク> I wonder why heh
01:41:21FromDiscord<Elegantbeef> Cause your logic
01:41:34FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4uzt
01:41:45FromDiscord<Elegantbeef> after the first full read of 25 it stays at `client.recv`
01:41:57FromDiscord<Elegantbeef> Or second i guess
01:43:38FromDiscord<リク> Yeah heh. I'm wondering how it's okay with getting things out of order though. Like it receives 50 bytes of data, then sends data to the client, then gets the rest somehow?
01:44:02FromDiscord<Elegantbeef> Nah it never sends to the client
01:44:08FromDiscord<Elegantbeef> Since it never escapes that loop
01:44:11FromDiscord<Elegantbeef> Atleast without a timeout
01:44:50FromDiscord<リク> Yeah without a timeout it just hangs after 50 bytes, but with a timeout it works as expected, though I'd expect it to actually not work hah
01:46:11FromDiscord<sOkam!> has anyone here dealt with Nim-to-ObjC interop? 🤔
01:48:19FromDiscord<リク> Oh wait, I just realized that the data does get corrupted like I thought it should
01:48:53FromDiscord<リク> sent a code paste, see https://play.nim-lang.org/#ix=4uzv
01:51:29FromDiscord<Elegantbeef> `recvFrom` might be better
01:51:40FromDiscord<Elegantbeef> Wait nvm wrong proc 😄
01:51:55FromDiscord<Elegantbeef> There is a `recv` that takes a `var string` that's likely the better one
01:52:40FromDiscord<リク> Alright I'll try that
01:53:46*derpydoo joined #nim
02:03:37FromDiscord<Elegantbeef> These recv procs are so odd seems like only the lowlevel one is sane
02:04:30FromDiscord<リク> It might also be the send proc since the proc returns before the data is fully sent..
02:05:00FromDiscord<リク> Because of that, it doesn't matter if you put the timeout on the client, server, or both, you get corrupted data on one or both of the sides
02:09:44FromDiscord<リク> sent a code paste, see https://paste.rs/D3r
02:09:58FromDiscord<リク> But the server only gets 50
02:10:18FromDiscord<Elegantbeef> Is send even blocking
02:10:25FromDiscord<Elegantbeef> I guess this is TCP so it should be
02:10:45FromDiscord<リク> It should be, but I have a feeling that it isn't, or linux is doing weird things behind the scenes..
02:11:13FromDiscord<リク> I wonder if the socket on the client side is somehow a udp socket? I think tcp is default though right?
02:11:50*xet7 quit (Ping timeout: 265 seconds)
02:12:29FromDiscord<Elegantbeef> TCP should be default yea
02:13:08FromDiscord<リク> Yeah I checked the docs and tcp is default
02:13:16FromDiscord<リク> That's so weird lmao
02:17:29FromDiscord<Elegantbeef> Yea I do not know what to say
02:18:25FromDiscord<リク> I could try asyncnet instead I guess haha
02:27:27*krydos joined #nim
02:29:50FromDiscord<リク> What would be the best place to report issues? I feel like I should officially report this
02:30:00FromDiscord<Elegantbeef> The github repo
02:30:08FromDiscord<リク> Alright cool
02:31:06FromDiscord<Arathanis> when i checkout the `version-2-0` branch and build nim the resulting exe says its version 1.9.3, is that expected?
02:31:17FromDiscord<Arathanis> (edit) "1.9.3," => "1.9.1,"
02:31:47FromDiscord<Elegantbeef> Afaik, yes
02:31:57FromDiscord<Arathanis> cool, just making sure. thank you.
02:34:20*lucasta quit (Remote host closed the connection)
02:43:19FromDiscord<リク> Submitting issues is scary
02:43:51FromDiscord<Elegantbeef> I disagree
02:43:56FromDiscord<Elegantbeef> Worst case someone calls you an idiot
02:44:01FromDiscord<Elegantbeef> Best case you document a bug
02:44:11FromDiscord<リク> True true
03:01:54FromDiscord<rb3.nim> sent a code paste, see https://play.nim-lang.org/#ix=4uzH
03:04:38FromDiscord<rb3.nim> sent a code paste, see https://play.nim-lang.org/#ix=4uzK
03:05:07FromDiscord<rb3.nim> (edit) "https://play.nim-lang.org/#ix=4uzK" => "https://play.nim-lang.org/#ix=4uzL"
03:07:39arkanoidthis documentation is not clearly saying if it will wait until whole datagram is received, or if it will yield result when `size` bytes are received https://nim-lang.org/docs/asyncnet.html#recvFrom%2CAsyncSocket%2Cint
03:16:29FromDiscord<rb3.nim> In reply to @rb3.nim "But if I run": Ah, I'm just dumb. I was discarding a `void` value.
04:12:16*TakinOver joined #nim
05:21:22*derpydoo quit (Ping timeout: 276 seconds)
06:50:12*azimut joined #nim
07:12:46*Notxor joined #nim
10:31:04*jmdaemon quit (Ping timeout: 252 seconds)
11:40:01*oprypin quit (Quit: Bye)
11:40:19*oprypin joined #nim
14:19:47*lucasta joined #nim
14:39:52*Notxor quit (Remote host closed the connection)
14:51:27*Notxor joined #nim
15:27:20*robertmeta quit (*.net *.split)
15:27:20*koltrast quit (*.net *.split)
15:27:20*acidsys quit (*.net *.split)
15:28:08*robertmeta joined #nim
15:28:40*acidsys joined #nim
15:28:51*robertmeta quit (Changing host)
15:28:51*robertmeta joined #nim
15:30:01*koltrast joined #nim
15:35:21FromDiscord<sOkam!> is there an existing `offsetof()` function/proc in Nim?
16:15:09FromDiscord<Chronos [She/Her]> Offset?
16:15:20FromDiscord<Chronos [She/Her]> There's `sizeof`, I believe
16:15:53FromDiscord<Chronos [She/Her]> Oh, it's literally `offsetof`
16:16:44FromDiscord<Chronos [She/Her]> @sOkam!
16:19:15FromDiscord<sOkam!> oh rly? nice, will check it out
16:19:21FromDiscord<Chronos [She/Her]> Of course aha
16:24:49FromDiscord<jmgomez> I read somwhere that there was a way to build the compiler with importc support at compile time, anyone know how? Reading through koch sources cant see a flag for it
16:31:45*arkurious joined #nim
16:31:49*arkurious quit (Remote host closed the connection)
16:34:58FromDiscord<jmgomez> found it, `-d:nimHasLibFFI`
16:40:32*lucasta quit (Remote host closed the connection)
16:51:34*beholders_eye joined #nim
16:58:11FromDiscord<Chronos [She/Her]> Ah, I think that gives the NimScript VM FFI capabilities
16:59:35NimEventerNew thread by tcheran: Fetching data from many small .txt files, see https://forum.nim-lang.org/t/10146
17:01:31FromDiscord<jmgomez> In reply to @Hourglass, When the Hour Strikes "Ah, I think that": yes, Im exploring it. Not sure how to actually feed in the c/cpp though
17:01:42FromDiscord<Chronos [She/Her]> Interesting
17:02:25FromDiscord<Chronos [She/Her]> In reply to @jmgomez "yes, Im exploring it.": Honestly, considering how the importc and importcpp pragma works, I'm guessing it probably compiles the importc'd code and exposed it to the VM?
17:02:35FromDiscord<Chronos [She/Her]> But I don't know how that works at all since never touched it
17:03:10FromDiscord<jmgomez> I think I need to actually compile Nim with the C/C++ that I want to be available
17:04:13FromDiscord<jmgomez> Or maybe I can just use a dll hmm
17:07:28FromDiscord<Chronos [She/Her]> Oh wait
17:07:30FromDiscord<Chronos [She/Her]> LibFFI
17:07:44FromDiscord<Chronos [She/Her]> Using shared libraries
17:07:51FromDiscord<Chronos [She/Her]> That makes so much more sense
17:21:25FromDiscord<jmgomez> Yeah, it works
17:28:37FromDiscord<Require Support> any implementation of async named pipes using `asyncdispatch` ?
17:28:44FromDiscord<Require Support> (edit) "any implementation of async named pipes using `asyncdispatch` ? ... " added "(for windows)"
18:36:48*TakinOver quit (Ping timeout: 248 seconds)
19:19:26*lucasta joined #nim
19:35:21*junaid_ joined #nim
19:54:29*progranner joined #nim
19:59:50FromDiscord<Require Support> is there a way to specify config file for compiler ?
20:17:22*junaid_ quit (Remote host closed the connection)
20:45:26FromDiscord<sOkam!> In reply to @Require Support "is there a way": multiple. the ones i use are nim.cfg in the root of the project, for nimc config... and config.nims for nimble config
20:45:39FromDiscord<sOkam!> but there are more
20:45:48FromDiscord<sOkam!> (edit) "but there are more ... " added "locations to place them"
20:46:30FromDiscord<sOkam!> they show up for me in the hints everytime i compile. maybe try running with `--verbose` and it might also print them for you
21:01:16*progranner quit (Ping timeout: 276 seconds)
21:10:41*TakinOver joined #nim
21:51:45*jmdaemon joined #nim
22:09:16*Notxor quit (Remote host closed the connection)
22:23:17FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4uDd
22:24:09FromDiscord<voidwalker> if i change to t.sha1.string (not sure why converter wasn't used automatically?) code compiles. But the position where it marks the error is wrong, it should be for the first pair, not the second
22:24:39FromDiscord<voidwalker> (edit) "t.sha1.string" => "`t.sha1.string`"
22:24:42FromDiscord<Elegantbeef> Cause it's the first entry in an array
22:25:15FromDiscord<voidwalker> more explicit please ?
22:25:30FromDiscord<Elegantbeef> What information is there that it should convert?
22:26:01FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4uDe
22:26:06FromDiscord<Elegantbeef> That's not what i asked
22:26:18FromDiscord<Elegantbeef> What information is there inside the array that says "you need to convert to X type"
22:26:37FromDiscord<Elegantbeef> The first element of an array tells the rest of the type of the array
22:26:43FromDiscord<voidwalker> Ohhhhhh
22:27:13FromDiscord<Elegantbeef> And it's even worse than that
22:27:23FromDiscord<Elegantbeef> Cause it's an element of `(string, InfoHash)`
22:27:24FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4uDf
22:27:53FromDiscord<Elegantbeef> Ok cool but that call doesnt happen until after the array is created
22:27:54FromDiscord<Elegantbeef> Nim is locally type inferred
22:28:03FromDiscord<Elegantbeef> First the array is semantically checked, then it semantically checks the call and so forth
22:28:07FromDiscord<voidwalker> so first it checks the array is sane
22:28:08FromDiscord<voidwalker> ok
22:28:14FromDiscord<Elegantbeef> There are a few cases where information is passed from left to right
22:28:26FromDiscord<Elegantbeef> But dispatch is not one of them since dispatch can resolve types
22:28:43FromDiscord<voidwalker> so convert can't work here, got it. no big deal
22:29:27FromDiscord<Elegantbeef> Correct unless you make a converter for `(string, string)` then one for `openarray[(string, InfoHash)]` 😄
22:31:36FromDiscord<voidwalker> I am even questioning if making a separate type with array of char for this is the right thing to do. Since it's needed as a string pretty much everywhere (socket send, message parsing etc)
22:32:04FromDiscord<Elegantbeef> What's the benefit of it being an array
22:32:22FromDiscord<voidwalker> well, it's always of size 20, so strictly logically.. it should be an array : P
22:32:48FromDiscord<voidwalker> But if everything else is a string, there's probably no benefit
22:36:43FromDiscord<ElegantBeef> Well the bridge is really a prick
22:36:53FromDiscord<ElegantBeef> In that case consider an object variant maybe
22:37:16FromDiscord<ElegantBeef> But if it only "should" be an array perhaps assertions is enough
22:37:27FromDiscord<ElegantBeef> Ensure it's always 20 len everywhere it should be
22:37:41FromDiscord<ElegantBeef> There is a minor benefit that you can move ownership of a string, you cannot with an array
22:37:47FromDiscord<voidwalker> come on, object variant for this ? that's overkill
22:39:50FromDiscord<voidwalker> hm interesting, sounds like it should be strings all the way then. Too bad I can't declare string[20] or something
22:40:05FromDiscord<ElegantBeef> You technically can but you'd need to implement the type
22:42:50FromDiscord<ElegantBeef> Paint the rest of the owl
22:42:53FromDiscord<ElegantBeef> sent a code paste, see https://play.nim-lang.org/#ix=4uDh
22:43:37FromDiscord<Nlits (Ping on reply)> Should I just use 1 lock for all my threads or multiple
22:43:59FromDiscord<Elegantbeef> This is not a question that can be answered without actual design in front of anyone
22:44:49FromDiscord<Elegantbeef> Are you locking a single resource, are you locking many resources, are your threads in a producer consumer orientation with a single work pile.....?
22:46:24FromDiscord<voidwalker> Am I the only one that thinks sized strings should be part of nim ? I see it in most languages. Using char arrays has some drawbacks, like not even having a converted included..
22:46:29FromDiscord<voidwalker> (edit) "converted" => "converter"
22:47:03FromDiscord<Elegantbeef> Likely yes
22:47:05FromDiscord<Elegantbeef> We have arrays
22:47:10FromDiscord<Elegantbeef> We have low level operations
22:47:19FromDiscord<Elegantbeef> Write abstractions on top of them and call it a day
22:47:25FromDiscord<Nlits (Ping on reply)> In reply to @Elegantbeef "Are you locking a": i have 2 "shared" vars.
22:48:04FromDiscord<Dudugz> A library for sized strings might work, ``std/sizedstr``
22:48:55FromDiscord<Elegantbeef> It might but there isnt much reason arrays dont work
22:49:16FromDiscord<Elegantbeef> If you are using fixed size strings it's not likely you want most string operations to work
22:49:27FromDiscord<Elegantbeef> Plus more of the stdlib should use `openArray[char]`
22:50:54FromDiscord<Dudugz> Yes I agree, in my pov there is no need for a sized string, I mean it won't help at all and will only overcomplicate basic operations.
22:53:21FromDiscord<cmc> sent a long message, see http://ix.io/4uDj
22:55:20FromDiscord<cmc> sent a code paste, see https://play.nim-lang.org/#ix=4uDk
22:56:23FromDiscord<Elegantbeef> you cannot inject a variable named the same as the template
22:58:26FromDiscord<cmc> sent a code paste, see https://play.nim-lang.org/#ix=4uDl
23:01:16FromDiscord<Elegantbeef> I'd probably do the silly thing and use a macro with `varargs[untyped]`
23:05:49FromDiscord<cmc> sent a code paste, see https://play.nim-lang.org/#ix=4uDo
23:08:17FromDiscord<Elegantbeef> Yea i'd say use a macro instead, might be able to push templates to work, but bleh
23:08:36FromDiscord<cmc> Hahaha yeah
23:10:32*azimut quit (Ping timeout: 240 seconds)
23:16:48FromDiscord<Nlits (Ping on reply)> In reply to @not logged in "i have 2 "shared"": So do i have a lock for each one?
23:17:43FromDiscord<Elegantbeef> You have given 0 insight
23:18:26FromDiscord<Elegantbeef> What you need depends on your multi-threading architecture
23:18:39FromDiscord<Elegantbeef> There is no general solution for all 2 shared resources
23:19:19FromDiscord<Nlits (Ping on reply)> In reply to @Elegantbeef "What you need depends": I am using mummy, idk the architecture
23:19:43FromDiscord<Elegantbeef> Well then look at how it does threading and where deadlocks may appear
23:19:52FromDiscord<Elegantbeef> Also consider how you're using these resources
23:21:11FromDiscord<Nlits (Ping on reply)> In reply to @Elegantbeef "Well then look at": no idea what the means
23:22:04FromDiscord<Elegantbeef> Perhaps it's time to learn why locks exist
23:23:18FromDiscord<Nlits (Ping on reply)> In reply to @Elegantbeef "Perhaps it's time to": to lock a thread so that they can safely access resources so other threads won't interfere?
23:24:18FromDiscord<Elegantbeef> Ok so now you need to wonder if there would be competed access of your resources, and how many locks you need for your design
23:25:01FromDiscord<Elegantbeef> Are the threads accessing these resources at the same time? If you have access to one resource should the other be locked, unlocked, does it matter?
23:25:20FromDiscord<Elegantbeef> How many locks you need depends on what you're doing
23:26:57FromDiscord<Nlits (Ping on reply)> In reply to @Elegantbeef "Are the threads accessing": It would be possible for my program to read and write at the same time without locks
23:27:00*Batzy quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.)
23:27:10FromDiscord<Nlits (Ping on reply)> (edit) "In reply to @Elegantbeef "Are the threads accessing": It would be possible for my program to read and write at the same time ... without" added "as other threads"
23:27:12FromDiscord<Elegantbeef> then there you go you need 0 locks
23:27:22*Batzy joined #nim
23:27:35FromDiscord<Elegantbeef> Oh cmon you cannot edit that after i gave confirmation
23:27:42FromDiscord<Elegantbeef> Well then you need locks
23:27:58FromDiscord<cmc> sent a code paste, see https://play.nim-lang.org/#ix=4uDs
23:28:06FromDiscord<Elegantbeef> Ugh
23:28:09FromDiscord<Elegantbeef> That's not what i meant
23:28:39FromDiscord<cmc> Yeah I know. I wanted to see what it would take to force the templates for educational purposes \:)
23:29:19FromDiscord<Nlits (Ping on reply)> In reply to @Elegantbeef "Well then you need": Your statements are confusing and conflicting...
23:30:28FromDiscord<cmc> Yeah I know. I was looking into macros and found out what it take to force it with templates. It was more an educational accident
23:32:01FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4uDv
23:32:15FromDiscord<Elegantbeef> There you go cmc
23:32:18FromDiscord<Elegantbeef> That's what i meant 😛
23:33:06FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4uDw
23:34:28FromDiscord<cmc> Oh, thank you so much!!
23:36:36FromDiscord<Elegantbeef> No one here knows how your code is written so it's not like anyone can give you a definitive answer, if both resources are being read/written then you need some lock or if it's a primitive an atomic, otherwise you have a race condition↵(@Nlits (Ping on reply))
23:36:50FromDiscord<Elegantbeef> So you'll need to put your thinking cap on
23:39:31FromDiscord<Nlits (Ping on reply)> sent a code paste, see https://play.nim-lang.org/#ix=4uDx
23:41:07FromDiscord<Elegantbeef> Ask yourself should messages be added whilst a connection is excluded/included
23:41:12FromDiscord<Elegantbeef> That's all you need to answer
23:41:29FromDiscord<Elegantbeef> With a singular lock any connection/message operation is blocking all threads
23:42:35FromDiscord<Nlits (Ping on reply)> In reply to @Elegantbeef "Ask yourself should messages": they can be. They should be allowed to. So 2 locks ig
23:44:42FromDiscord<Elegantbeef> Now i have to wonder if spoonfeeding threading logic benefited you
23:47:15FromDiscord<Nlits (Ping on reply)> In reply to @Elegantbeef "Now i have to": I just needed confirmation, I had the idea already.
23:56:28FromDiscord<Nlits (Ping on reply)> Ok, now trying to make a ui for that.↵I can't seem to find out how to use the TUI lib↵https://forum.nim-lang.org/t/9244
23:56:31*TakinOver quit (Ping timeout: 250 seconds)
23:57:58*derpydoo joined #nim
23:58:11FromDiscord<Nlits (Ping on reply)> Or should I just use illwill
23:59:14FromDiscord<Elegantbeef> I mean refer to the examples
23:59:17FromDiscord<Elegantbeef> They're very straight forward