<< 28-01-2023 >>

00:00:14FromDiscord<sOkam!> can probably modify it further to fit what you need
00:05:17FromDiscord<sOkam!> can I type be declared in multiple spots in some way, even if its only defined once?
00:29:38*lumo_e quit (Quit: Quit)
00:31:04FromDiscord<voidwalker> Didn't know of parseini, will give it a try
00:34:24FromDiscord<Rika> It’s a derivative of parsecfg
00:56:21FromDiscord<voidwalker> yep, it works, puts empty string if no value is found, and does not stop on `,`
01:37:26*ltriant quit (Ping timeout: 246 seconds)
01:43:42FromDiscord<MetuMortis> sent a code paste, see https://paste.rs/ya2
01:48:12FromDiscord<MetuMortis> fixed it, I didn't know mySeq should be mutable
01:49:24FromDiscord<Rika> `sort` sorts the sequence itself, `sorted` returns a copy of the sequence that is sorted
02:09:44FromDiscord<auxym> sent a code paste, see https://play.nim-lang.org/#ix=4mon
02:14:59FromDiscord<MetuMortis> btw solving advent-of-code at 5am with nim is very funny
02:15:11FromDiscord<MetuMortis> (edit) "funny" => "amazin"
02:15:11FromDiscord<MetuMortis> (edit) "amazin" => "amazing"
02:22:13FromDiscord<MetuMortis> Where does "a" and "b" come from here? And is it possible to write a function that takes an operation just like this? https://media.discordapp.net/attachments/371759389889003532/1068717602047795300/image.png
02:22:30FromDiscord<Rika> a and b are injected by the template
02:23:03FromDiscord<Rika> it is possible but i dont know why it isnt already in sequtils
02:23:56FromDiscord<MetuMortis> In reply to @Rika "it is possible but": what isn't already in sequtils
02:25:26FromDiscord<Rika> sent a code paste, see https://play.nim-lang.org/#ix=4moq
02:26:48FromDiscord<Rika> you would pass a function instead of using a and b
02:27:06FromDiscord<Rika> if you wanted to have the same exact syntax as foldl then it is impossible
02:27:12FromDiscord<Rika> (edit) "if you wanted to have the same exact syntax as foldl ... then" added "but as a function"
02:27:56FromDiscord<MetuMortis> In reply to @Rika "if you wanted to": I just wanted to know is it possible to inject variables ("a" and "b" in this example) just like foldl does
02:28:36FromDiscord<Rika> oh
02:28:38FromDiscord<Rika> in a template
02:28:42FromDiscord<Rika> not a function
02:29:56FromDiscord<Rika> sent a code paste, see https://paste.rs/LOA
02:32:52FromDiscord<MetuMortis> thankd
02:32:58FromDiscord<MetuMortis> (edit) "thankd" => "thanks"
02:41:02FromDiscord<Tuatarian> I have this really strange issue
02:41:22FromDiscord<Tuatarian> I ahve a reference, which is not nil, but attempting to `deepCopy` it segfaults (gives a maybe reading from nil error)
02:42:07FromDiscord<MetuMortis> In reply to @Rika "its possible yes, it": it looks like defining things in templates is not a good practice :d https://media.discordapp.net/attachments/371759389889003532/1068722614207520869/image.png
02:46:49FromDiscord<Tuatarian> I actually have no clue why this is happening
02:47:10FromDiscord<Tuatarian> I can confirm my reference is not nil
02:47:13FromDiscord<kots> In reply to @MetuMortis "it looks like defining": Put it inside a `block`
02:47:14FromDiscord<Tuatarian> but nim for some reason doesn't want to copy it
02:53:17FromDiscord<Elegantbeef> Nah kots
02:53:19FromDiscord<Elegantbeef> put it inside of `if true:`
02:53:24FromDiscord<Elegantbeef> Unless it's supposed to make a new scope
02:57:18FromDiscord<MetuMortis> Doesn't putting it into if true block or putting it into "block" basically same things?
02:57:24FromDiscord<kots> We do want each injected `a` to be in its own scope to avoid the redefinition error, isn't it
02:57:31FromDiscord<MetuMortis> (edit) "Doesn't" => "Aren't"
02:57:46FromDiscord<MetuMortis> In reply to @kots "We do want each": Yes
02:57:50FromDiscord<kots> In reply to @MetuMortis "Aren't putting it into": I would have thought so as well
02:59:54FromDiscord<Elegantbeef> The semantics are different
03:00:38FromDiscord<Elegantbeef> `break` works with blocks so if you do `if true: break` you can still exit a for loop
03:00:39FromDiscord<Elegantbeef> if you do `block: break` you cannot
03:01:59FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mov
03:02:17FromDiscord<kots> True enough...
03:08:02*genpaku quit (Read error: Connection reset by peer)
03:08:44*genpaku joined #nim
03:14:50FromDiscord<Tuatarian> does anyone have any idea why nim segfaults trying to `deepCopy` a non-nil ref?
03:16:13FromDiscord<Elegantbeef> Perhaps it's a complex data type that causes an issue with the deepcopy algo
03:31:06*ltriant joined #nim
03:33:08FromDiscord<Tuatarian> it is a complex data type
03:33:23FromDiscord<Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=4moz
03:33:26FromDiscord<Tuatarian> though it copies fine in other places
03:33:32FromDiscord<Tuatarian> not sure why this in particular causes an issue
03:34:34FromDiscord<Elegantbeef> Might be `cursor`?
03:35:06FromDiscord<Tuatarian> probably is
03:35:12FromDiscord<Tuatarian> is there anything I can do about this?
03:35:26FromDiscord<Tuatarian> I guess I just have to write my own deepcopy for `ASTNode`?
03:45:15FromDiscord<Tuatarian> beef can you confirm if that's what needs to happen or if there's a potentially better way
03:45:27FromDiscord<Elegantbeef> I dont know I dont deepcopy
03:46:14*forest joined #nim
03:47:08*forest quit (Client Quit)
03:50:56*genpaku quit (Ping timeout: 248 seconds)
03:53:46*genpaku joined #nim
04:14:51*arkurious quit (Quit: Leaving)
06:04:53om3gapyolyokh: It's strange, while I understand what you mean about cast conversion, the stuff I want to do has type uint8, which is byte, and I got the same results
06:06:19om3gafor example eth.etherType = ((data[12] shl 8) or data[13]), and data is seq[uint8]
06:07:37om3gadata[12] == 8, data[13] == 0, ^--this should assign to eth.etherType value 2048
06:08:05om3gabut it assigns 0...
06:09:22FromDiscord<pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4mp0
06:09:33FromDiscord<pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4mp1
06:12:41om3gapyolyokh: this is numeric conversion?
06:13:15om3gaI mean .int
06:13:24FromDiscord<pyolyokh> yeah, that's a conversion to int
06:14:29om3gathanks. I will try that, but seems it may slow down the pcap parsing. I cannot remember if such conversion was made in C code...
06:17:57om3gapyolyokh! it work
06:18:26om3gathanks!, is that the same as int(data[12]) ?
06:18:38FromDiscord<Elegantbeef> yes it's just UFCS
06:19:36om3gaaha.. where first parameter passes as input to .int(here)
06:19:40om3gathanks!
06:22:32*azimut quit (Ping timeout: 255 seconds)
06:30:09FromDiscord<tfp> running into a very weird issue..
06:30:11FromDiscord<tfp> https://media.discordapp.net/attachments/371759389889003532/1068780004730744852/image.png
06:30:32FromDiscord<tfp> if i make that random allocation on line 3-- all the glyph sizes are w: 9, h: 15
06:30:41FromDiscord<tfp> if i don't make that allocation, no issue. the sizes are correct
06:30:53FromDiscord<tfp> only happens on orc, doesn't happen with --gc:refc
06:31:06FromDiscord<tfp> ..any ideas?
06:31:17FromDiscord<tfp> how can i even debug this
06:33:02FromDiscord<Elegantbeef> Sounds like some type of heap/stack issue
06:33:14FromDiscord<Elegantbeef> Run through valgrind
06:35:49FromDiscord<tfp> hmm, doesn't ORC only collect on allocations?
06:36:17FromDiscord<Elegantbeef> Orc is deterministic, so it's behaviour might just be showcasing an issue with your logic
06:36:21FromDiscord<tfp> let me try leaking the font file memory
06:36:28FromDiscord<tfp> maybe freetype doesn't copy it
06:39:40FromDiscord<tfp> yeah that was it
06:39:53FromDiscord<tfp> mm interesting
06:40:13FromDiscord<tfp> i'm surprised the memory wasn't collected when the string went out of scope
06:40:19FromDiscord<tfp> or maybe it was but just not reclaimed idk
06:40:50FromDiscord<Elegantbeef> It's not 0'd likely
06:40:51FromDiscord<tfp> also surprised that GC_ref doesn't have a method for strings, the docs say it does
06:41:10FromDiscord<Elegantbeef> Orc/Arc strings are different than refc strings
06:41:41FromDiscord<tfp> are they value types or COW or something?
06:42:05FromDiscord<Elegantbeef> They're both value types
06:42:22FromDiscord<Elegantbeef> But there is no ref counter on string now
06:43:59FromDiscord<tfp> oh i always assumed they were ref types
06:44:14FromDiscord<tfp> why is there a ref counter in refc if they're value types in refc?
06:44:51FromDiscord<tfp> wha.. even seqs are value types
06:44:54FromDiscord<tfp> that's so weird
06:44:59FromDiscord<Elegantbeef> Yes
06:44:59FromDiscord<Rika> Value semantics, internally they’re references
06:54:23FromDiscord<tfp> https://media.discordapp.net/attachments/371759389889003532/1068786099138330634/image.png
06:54:33FromDiscord<tfp> coo
06:56:04FromDiscord<Rika> Are you making a font renderer or something
06:56:46FromDiscord<tfp> just using freetype in a game engine i'm building
06:56:55FromDiscord<tfp> those are quads rendered by wgpu-native
07:07:55*ltriant quit (Ping timeout: 260 seconds)
07:45:22om3gatfp: try google sanitizers
07:45:57om3gathat tools help me a lot almost with any type of program
07:48:44om3gause --passC:"-O0 -g3 -fsanitize=address" and --passL:"-O0 -g3 -fsanitize=address" in nim.cfg
07:49:37om3gaor -fsanitize=leak for memory leaks detection
08:50:08FromDiscord<Gennadiy> sent a code paste, see https://play.nim-lang.org/#ix=4mpq
08:51:31FromDiscord<demotomohiro> @Gennadiy https://nim-lang.org/docs/manual.html#statements-and-expressions-case-statement
08:51:34FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mpr
08:51:37FromDiscord<Elegantbeef> Cmon you could've given it a try
08:52:15FromDiscord<Gennadiy> I particularly need the "Breaking out early statement to print"!
08:53:01FromDiscord<Elegantbeef> https://nim-lang.org/docs/manual.html#statements-and-expressions-block-statement
08:54:25FromDiscord<demotomohiro> @Gennadiy https://nim-lang.org/docs/manual.html#statements-and-expressions-block-statement
08:56:16FromDiscord<Gennadiy> sent a code paste, see https://play.nim-lang.org/#ix=4mps
08:56:47FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mpt
08:56:54FromDiscord<Elegantbeef> Shit
08:56:56FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mpu
08:57:08FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mpv
08:57:54FromDiscord<MetuMortis> sent a code paste, see https://play.nim-lang.org/#ix=4mpw
08:58:00FromDiscord<MetuMortis> (edit) "https://play.nim-lang.org/#ix=4mpw" => "https://play.nim-lang.org/#ix=4mpx"
08:58:17FromDiscord<Elegantbeef> `str[str..^1]`
08:58:23FromDiscord<Elegantbeef> whoops `0..^1`
08:58:37FromDiscord<demotomohiro> !eval echo "Hello"[1..^1]
08:58:42NimBotello
09:00:10FromDiscord<Gennadiy> I guess I will have to resort to the `else` but the problem is the code I am porting (from C++) is full of these at different (Nim) indentation levels so it will be quite messy. Hence, my wanting a means to break out of the whole case statement.
09:03:31FromDiscord<demotomohiro> @Gennadiy https://nim-lang.org/docs/manual.html#statements-and-expressions-block-statement↵You can break out from nested loop or case statements using block with label and break.
09:03:45FromDiscord<Elegantbeef> Yea only `for` and `block` are breakable
09:04:10FromDiscord<Elegantbeef> Nim case statements do not have fall though cause it's generally considered unwanted
09:06:12FromDiscord<Gennadiy> Ok, thanks both. I will explore the labelled block.
09:16:11*ltriant joined #nim
09:27:12*Guest87 joined #nim
09:27:30*Guest87 quit (Client Quit)
09:44:23*junaid_ joined #nim
10:02:10*junaid_ quit (Remote host closed the connection)
12:36:08*azimut joined #nim
14:03:24*PMunch joined #nim
15:01:07FromDiscord<mrgaturus> is there any pragma to avoid dead code elimination on it?
15:01:29FromDiscord<mrgaturus> sent a code paste, see https://paste.rs/nPy
15:22:18FromDiscord<Rika> I don’t think constants can be exported in that sense, after all they don’t get put in the c code as a variable
15:22:40FromDiscord<auxym> `let` should work I think
15:23:12FromDiscord<rakgew> @mrgaturus does `{.used.}` pragma have an effect?
15:24:41FromDiscord<Rika> The const will never be in the C code as a variable as I’ve said
15:24:52FromDiscord<Rika> At least to my understanding
15:24:54FromDiscord<mrgaturus> In reply to @rakgew "<@320019095426957323> does `{.used.}` pragma": i tried and still discarding
15:25:33FromDiscord<mrgaturus> sent a code paste, see https://play.nim-lang.org/#ix=4mrn
15:25:45FromDiscord<Rika> Nim const and C const are completely different concepts
15:26:17FromDiscord<Rika> Nim const is roughly equivalent to c preprocessor define
15:26:19FromDiscord<mrgaturus> sent a code paste, see https://play.nim-lang.org/#ix=4mro
15:26:31FromDiscord<Rika> Because ^
15:29:16FromDiscord<Rika> In reply to @auxym "`let` should work I": Use let as said by
15:29:39FromDiscord<Rika> A related answer, Nim DCE is not optional
15:30:07FromDiscord<mrgaturus> i see, is a bug that is not fixed yet:↵https://github.com/nim-lang/Nim/issues/17681
15:30:35FromDiscord<Rika> Huh, I have never heard of this
15:45:17FromDiscord<mrgaturus> sent a code paste, see https://play.nim-lang.org/#ix=4mrw
16:07:13*arkurious joined #nim
18:09:49FromDiscord<Hel> sent a code paste, see https://play.nim-lang.org/#ix=4ms4
18:09:58FromDiscord<Hel> however it works fine if it's not in that function scope
18:10:25FromDiscord<Hel> (`Error: cannot evaluate at compile time: x`)
18:10:34FromDiscord<Hel> is it just a proc limitation?
18:21:04FromDiscord<halc> not sure if I'm missing something, or nico's tilemap loading doesn't work
18:22:12FromDiscord<halc> isn't this just going to turn all "first tiles" into blanks? https://media.discordapp.net/attachments/371759389889003532/1068959189172498555/image.png
18:25:20FromDiscord<halc> oh yeah, just confirmed it does
18:38:22FromDiscord<halc> well I guess it does work, if you leave a blank space at the start of your tilesheet
18:52:06FromDiscord<Ntsékees> How should one import a file from the parent directory (e.g. `../file.nim`)?
18:52:57PMunch@Ntsékees, `import ../file`
18:53:07FromDiscord<Ntsékees> Neato. Thanks.
18:53:12PMunchWell `import "../file"` I think it is
18:53:25FromDiscord<Ntsékees> Much better than the Python `sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(file))))`
18:53:49FromDiscord<Ntsékees> (edit) "`sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(file))))`" => "`sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(file))))↵import file`"
18:53:56PMunchIs that seriously how you do it in Python?
18:55:17FromDiscord<Ntsékees> As far as I know
19:13:25FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4msg
19:13:56FromDiscord<4zv4l> it executes the callback also↵even if the future isn't completed
19:14:18FromDiscord<4zv4l> `yes 'Hello' | socat - TCP-LISTEN:8080,fork,reuseaddr`↵this is the command I use for the server
19:17:13FromDiscord<pyolyokh> what's actually going over the wire is a string like write(6, "llo\nHello\nHello\nHello\nHello\nHello\nHello\nHe↵llo\nHello\nHello\nHello\nHello\nHello\nHello\nHello\nHello\nHello\n"..., 8192)
19:18:40FromDiscord<4zv4l> I was expecting each of the socket to read one line from it
19:19:22FromDiscord<pyolyokh> but, asyncnet.recvLine says it reads as long as the socket's open and discards partial strings, so it should always be a complete line yeah
19:19:58FromDiscord<4zv4l> > Returned future will complete once a full line is read or an error occurs.
19:20:11FromDiscord<4zv4l> the full line is finished after a `\n` right ?
19:20:23FromDiscord<4zv4l> so yeah I don't understand what is wrong
19:20:43FromDiscord<pyolyokh> docs say it's waiting for `\r\n`
19:21:14FromDiscord<4zv4l> can I change the `newLine` terminator ?
19:21:48FromDiscord<4zv4l> because `\r\n` is for Windows iirc
19:21:59FromDiscord<pyolyokh> no, that's for networking protocols in general
19:22:16FromDiscord<pyolyokh> but, <https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/asyncnet.nim#L556> says it should work the same for \n only
19:23:01FromDiscord<4zv4l> indeed
19:23:33FromDiscord<4zv4l> so yeah, I don't get it
19:27:54FromDiscord<4zv4l> In reply to @4zv4l "`yes 'Hello' | socat": this send all to the first one↵and no remains to the ones after it seems
19:29:11FromDiscord<pyolyokh> run `ncat localhost 8083|head -2` a few times
19:29:38FromDiscord<pyolyokh> the worst you get is a partial first line
19:31:29FromDiscord<4zv4l> `socat TCP-LISTEN:8080,fork,reuseaddr EXEC:"echo 'hello'"`
19:31:32FromDiscord<4zv4l> this works great
19:34:39FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mso
19:35:14*koltrast quit (Ping timeout: 268 seconds)
19:35:27FromDiscord<@thatrandomperson5-6310e3b26da03> sent a code paste, see https://play.nim-lang.org/#ix=4msp
19:36:31FromDiscord<pyolyokh> In reply to @4zv4l "`socat TCP-LISTEN:8080,fork,reuseaddr EXEC:"echo 'h": oh, yeah. so the 'partial first line' was the actual problem all along. add a `discard await recvLine(socket)` to drop it
19:39:33FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4msq
19:40:01FromDiscord<4zv4l> In reply to @pyolyokh "oh, yeah. so the": well the command with socat (the new one is much better) the previous one was sending at once a long string↵and because each socket was reading only one line, it was breaking the pipe
19:41:39*xaltsc quit (Quit: WeeChat 3.7.1)
19:46:38*koltrast joined #nim
19:50:00FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mss
20:01:51FromDiscord<Arathanis> Anyone understand this warning? It seems to be erroneous as it does in fact match as false. https://media.discordapp.net/attachments/371759389889003532/1068984270586134598/image.png
20:02:00FromDiscord<Arathanis> (edit) "false." => "false depending on the input."
20:03:39FromDiscord<Arathanis> Perhaps I am just missing something obvious.
20:05:33*xet7 quit (Ping timeout: 256 seconds)
20:18:03*xet7 joined #nim
20:24:55FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4msD
20:54:20FromDiscord<MetuMortis> I have a set with one element only, how can I get that element?
20:56:20FromDiscord<Elegantbeef> `var val: MyType; (for x in mySet: val = x)`
20:57:11FromDiscord<Arathanis> is there a reason you need to use the set data type if you also need to be able to pop values from it?
20:57:45FromDiscord<Arathanis> im guessing you are using set arithmetic to trim the set down?
20:58:10FromDiscord<Arathanis> (edit) "arithmetic" => "~~arithmetic~~ operations"
20:58:42FromDiscord<MetuMortis> sent a code paste, see https://play.nim-lang.org/#ix=4msQ
20:59:28FromDiscord<Elegantbeef> There is no need to use a hashset for characters
20:59:34FromDiscord<Elegantbeef> builtin set works with characters
21:00:01FromDiscord<Arathanis> hashset does support `pop` though, right?
21:00:13FromDiscord<MetuMortis> In reply to @Arathanis "hashset does support `pop`": yes but it is immutable
21:01:06FromDiscord<MetuMortis> oh wait I can assing it to an mutable variable
21:01:12FromDiscord<MetuMortis> (edit) "assing" => "assign"
21:01:24FromDiscord<MetuMortis> sent a code paste, see https://play.nim-lang.org/#ix=4msT
21:02:13FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4msU
21:02:36FromDiscord<MetuMortis> (edit)
21:02:50FromDiscord<Elegantbeef> That only works for ascii, for utf8 you need to use strings and `x[0].runes.toHashSet`
21:06:07FromDiscord<MetuMortis> thanks
21:06:51FromDiscord<Elegantbeef> Nim has a builtin set type which is preferable to hashsets in many cases
21:07:01FromDiscord<Elegantbeef> It's a bitset though so if you have a large range a hashset might be better
21:07:20FromDiscord<MetuMortis> I'm doing advent-of-code, it doesn't really matter I think :d
21:07:36FromDiscord<Elegantbeef> 2022s?
21:07:59FromDiscord<MetuMortis> the last one yes
21:08:05FromDiscord<@thatrandomperson5-6310e3b26da03> sent a code paste, see https://play.nim-lang.org/#ix=4msV
21:09:35FromDiscord<Elegantbeef> if you're returning a future across the thread barrier that'll do it
21:22:19*dv^_^ quit (Quit: dv^_^)
21:22:45*dv^_^ joined #nim
21:31:57FromDiscord<Ntsékees> What is the correct Nim type for a modifiable C buffer of type `char `?
21:32:09*azimut quit (Quit: ZNC - https://znc.in)
21:32:30FromDiscord<Ntsékees> Apparently cstring cannot be modified
21:34:25FromDiscord<@thatrandomperson5-6310e3b26da03> > if you're returning a future across the thread barrier that'll do it↵How would i do this then?
21:34:26*azimut joined #nim
21:41:39FromDiscord<Ntsékees> I guess I should use `ptr UncheckedArray[char]`?
21:45:04FromDiscord<Elegantbeef> `cstring`
21:45:26FromDiscord<auxym> var cstring
21:45:30FromDiscord<Elegantbeef> You wouldnt return a future you'd use a channel or similar from the thread to send the data back
21:45:56FromDiscord<Elegantbeef> Unless you need to change where the cstring points you do not need `var`
21:46:31FromDiscord<Ntsékees> without `var` I got error when trying to edit the buffer, but with `var` it does compile.
21:46:38FromDiscord<Ntsékees> Thanks.
21:46:51FromDiscord<auxym> nim might treat cstring as a value type like string? not sure tbh
21:50:39FromDiscord<Elegantbeef> Odd it does seem that way
21:50:40FromDiscord<Elegantbeef> I guess you can have static cstrings
21:50:40FromDiscord<Elegantbeef> So it makes sense
21:50:40FromDiscord<Elegantbeef> like `proc doThing("Hello")`
21:50:41FromDiscord<Elegantbeef> I'm smart
21:50:42FromDiscord<Elegantbeef> `doThing("hello")`
21:50:42FromDiscord<Elegantbeef> Where do thing takes a `cstring`
22:42:48FromDiscord<voidwalker> Beed wanna do my homework ? : D
22:45:21FromDiscord<voidwalker> Same problem I been spamming for 2 days now. Need to parse an .ini-like file (works well with parseini lib)
22:45:43PMunchSo why don't you just use parseini?
22:45:58FromDiscord<voidwalker> yeah, that's the easy part, parsing works nice
22:46:39FromDiscord<voidwalker> So my questions are.. how do I associate a bunch of strings with another bunch of string (keys in ini settings with [sections] of ini file) ?
22:46:50PMunchA table?
22:47:14PMunch`Table[string, seq[tuple[key, value: string]]`
22:47:28PMunchOr you could do it prettier by having a node hierarchy
22:47:40FromDiscord<voidwalker> yeah but I need to get from key to string
22:47:47FromDiscord<voidwalker> (edit) "yeah but I need to get from key to ... string" added "section"
22:47:59FromDiscord<voidwalker> there's only a few sections, and for each section maybe 10-20 possible keys
22:48:05PMunchYeah, that table holds the name of the section and the data of the section
22:48:43FromDiscord<voidwalker> I don't want to hold the data. My idea is to store all the config structure in an sql database, so it takes up much less space, and is generated on demand
22:48:56FromDiscord<Elegantbeef> I cannot even work on my own projects but people want me to work on theirs
22:49:18PMunch@voidwalker, that makes no sense
22:49:21FromDiscord<voidwalker> so that instead of strings i'd have integers, NULL, etc. Much more compact
22:49:38PMunchA small ini file would probably be way smaller than an SQL database
22:49:47FromDiscord<voidwalker> not for 10.000 entries
22:49:53FromDiscord<Elegantbeef> Faster too
22:50:00PMunchDepends on what your entries are tbh
22:50:14FromDiscord<voidwalker> well there's ~10.000 instances of those configs
22:50:35FromDiscord<voidwalker> with various settings entered, for each entry. a lot of them duplicate as well
22:51:08FromDiscord<voidwalker> there's also ~150MB worth of XML I want to put in the db as well
22:51:21FromDiscord<voidwalker> I believe I can cut size 20x
22:51:30FromDiscord<voidwalker> and sql is faster than xml parsing, or ini parsing 🙂
22:51:53FromDiscord<voidwalker> (edit) "or ini parsing 🙂" => "and I would get rid of 10.000 useless files, only generate them on demand"
22:52:32FromDiscord<voidwalker> step 1 is to convert .ini to sql. then from the sql I need to be able to reconstruct the .ini file
22:53:51FromDiscord<voidwalker> NULL values in sqlite seem to only take 1 bit, as they use a bitmask for them
22:54:20FromDiscord<voidwalker> so I can afford to make a column for each key/setting, even if most are unused most of the time
22:54:38FromDiscord<voidwalker> Makes sense now ?
22:55:56FromDiscord<voidwalker> So I have two design problems:
22:56:37FromDiscord<voidwalker> 1. How to associate each setting (key in .ini) with its section. Nothing better than a table with key: section ? It will duplicate `section` a lot of times
22:57:46FromDiscord<voidwalker> and 2. How to design the association of the key (string) to its respective encode/decode proc
22:58:15PMunchYeah that makes more sense :P
22:58:49PMunchI really depends on the sections
22:59:30FromDiscord<voidwalker> for example
22:59:51PMunchYou can have a table of sections, each with an id, then have you table of section names and the id in the sections table. This way each unique section only occurs once in the section table
22:59:58FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4mti
23:00:14FromDiscord<voidwalker> This will be 1 byte in the database, 0 for default, 1 for surface etc
23:02:40FromDiscord<voidwalker> so I need a `proc encodeEnum(key, value: string): uint8 =`
23:03:34FromDiscord<voidwalker> so if I call `encodeEnum("output", "surface")` I'll get 1
23:04:18FromDiscord<voidwalker> I remember you can assign strings to enum values hmm
23:04:39FromDiscord<voidwalker> does this break getting their ordinal value ?
23:05:03FromDiscord<Elegantbeef> Nope
23:05:49FromDiscord<voidwalker> I'd still need a way to associate the key string with the corresponding enum type though
23:11:45FromDiscord<voidwalker> why you can't work on your projects @ElegantBeef ?
23:11:58FromDiscord<Elegantbeef> -10 motivation
23:12:10FromDiscord<voidwalker> Oh I thought we were asking too many questions here
23:12:23FromDiscord<voidwalker> What does usually motivate you to write code ?
23:14:01FromDiscord<Elegantbeef> If i find out i'll tell you
23:14:50FromDiscord<voidwalker> I am demotivated cause I have lots of ideas, but it's hard to figure even the most "simple" things like the problem above
23:17:05FromDiscord<voidwalker> I need someone motived but without ideas : P
23:21:48FromDiscord<voidwalker> In reply to @PMunch "You can have a": So basically like an index table to not store the whole strings but just a byte ?
23:28:07PMunchWhat?
23:28:36PMunchEither you've done a very poor job of explaining, I've completely misunderstood what you're trying to do, or you have no idea what you're doing yourself :P
23:34:54FromDiscord<voidwalker> So you mean I should make two tables, one with `const secNames: Table[sectionName: string, id: uint8]` and another with `const key2Sections: Table[key: string, id: uint8]` ?
23:35:15PMunchNo?
23:35:23PMunchI was talking SQL tables
23:35:28FromDiscord<voidwalker> Oh lol
23:36:12FromDiscord<voidwalker> I did not even consider storing the "section" separator part of the columns in sqlite
23:37:17FromDiscord<voidwalker> I believe it's best to have it in nim code
23:37:30FromDiscord<voidwalker> as it is structural data
23:37:40PMunchDidn't you just say that you wanted it in SQL?
23:37:46PMunchI mean the S in SQL is for structure
23:38:49FromDiscord<voidwalker> Yeah, I want the data packed in an efficient and flexible sqlite format.. As I imagined it, I would have a column for each possible setting (key) entry. All in one table
23:39:31FromDiscord<voidwalker> And to define in code what section each key belongs to
23:39:41FromDiscord<voidwalker> But now that I think of it, I guess this could work nicely
23:39:53FromDiscord<voidwalker> (edit) "But now that I think of it, I guess this could work nicely ... " added "in SQL as well"
23:51:05*PMunch quit (Quit: leaving)
23:52:54FromDiscord<@thatrandomperson5-6310e3b26da03> I have an httpclient going through a proxy and i would like to know if an error code is caused by the (untested) proxy or the actual website. Any help appricated