<< 26-07-2021 >>

01:00:58*TakinOver quit (Ping timeout: 240 seconds)
01:10:46FromDiscord<@bracketmaster-5a708063d73408ce4> @elegantbeef\:matrix.org - your link from earlier is empty?
01:11:11FromDiscord<@bracketmaster-5a708063d73408ce4> Also - is it guaranteed that integer arrays in nim are always initialized to zero?
01:11:31FromDiscord<Elegantbeef> Nim 0 inits all memory unless overridden
01:11:37FromDiscord<Elegantbeef> http://ix.io/3u5j here is what i suggested
01:12:57FromDiscord<@bracketmaster-5a708063d73408ce4> I see it now. That's rather elegant.
01:13:16FromDiscord<@bracketmaster-5a708063d73408ce4> Also - is there a place in the manual where nim's init behaviors are explicitly mentioned?
01:14:37FromDiscord<Elegantbeef> Well without `{.noInit.}` or `{.requiresInit.}` in the type the memory is 0'd
01:15:30FromDiscord<Elegantbeef> so references/pointers are nil, value types are full of 0's which can be wrong for the data type IE `var a: range[1..2]; echo a`
01:21:16FromDiscord<@bracketmaster-5a708063d73408ce4> ok - I'll take your word for it
01:28:11FromDiscord<Elegantbeef> Well it is explained in more detail https://nim-lang.org/docs/manual.html#statements-and-expressions-var-statement
01:47:50FromDiscord<@bracketmaster-5a708063d73408ce4> thx!
02:00:42*arkurious quit (Quit: Leaving)
02:49:48fn<ForumUpdaterBot99> New thread by AIR: Mac GUI, see https://forum.nim-lang.org/t/8268
02:59:55*rockcavera joined #nim
02:59:55*rockcavera quit (Changing host)
02:59:55*rockcavera joined #nim
04:06:02*supakeen quit (Quit: WeeChat 3.2)
04:06:36*supakeen joined #nim
05:10:32*NimBot joined #nim
05:10:33*icebattle joined #nim
05:11:05*Amun-Ra joined #nim
05:11:26*Lord_Nightmare joined #nim
05:11:47*lucerne joined #nim
05:13:11*koltrast joined #nim
05:13:36*sagax quit (*.net *.split)
05:13:36*blackbeard420 quit (*.net *.split)
05:13:47*blackbeard420 joined #nim
05:15:57*sagax joined #nim
05:22:17*Ekho joined #nim
07:03:45*rockcavera quit (Remote host closed the connection)
07:15:06*max22- joined #nim
07:23:27*Schnouki joined #nim
08:48:15*max22- quit (Ping timeout: 268 seconds)
08:55:10*Vladar joined #nim
08:57:19*pro joined #nim
09:00:19FromDiscord<Clonkk> Was "examples" removed from category in testament ?
09:00:44FromDiscord<Clonkk> WHen I use devel I can't do `testament c examples`
09:02:33fn<ForumUpdaterBot99> New thread by Wag: How I can help fix cross compilation?, see https://forum.nim-lang.org/t/8269
09:06:19*pro quit (Quit: WeeChat 3.2)
09:20:34*aeverr quit (Ping timeout: 258 seconds)
09:51:37*max22- joined #nim
10:08:48FromDiscord<planetis> if my nim module is a port of another project in say cpp should my license header include the original author?
10:14:12FromDiscord<haxscramper> that depends on the license
10:14:37FromDiscord<sealmove> looool Scala 3 changes the syntax to indentation based xD wtf
10:14:41FromDiscord<haxscramper> See if wrapper qualifies as "derivative work" or something like that
10:16:08FromDiscord<haxscramper> or port
10:16:27FromDiscord<haxscramper> But it would make sense to credit the original author
10:16:31FromDiscord<sealmove> upper code: Scala 2, lower code: Scala 3 https://media.discordapp.net/attachments/371759389889003532/869161250033106954/unknown.png
10:17:50FromDiscord<haxscramper> it feels like they took all syntaxes at once. I looked at the documentation and it such a mess
10:18:14FromDiscord<saem> I thought scala's expression based nature allowed it to omit braces in many occasions but that could be my memory playing tricks on me.
10:18:38FromDiscord<sealmove> it does, but they want to enforce coding style
10:20:14FromDiscord<sealmove> I didn't even know it was possible to have both indentation-based and non-indentation-based syntax at the same time :O haven't seen it in other language I think.
10:23:30FromDiscord<generic linux user> In reply to @haxscramper "that depends on the": on cc-3.0?
10:27:08FromDiscord<planetis> its mit licensed
10:28:22FromDiscord<planetis> i just dont know how to do it properly, if someone can make a suggestion its here https://github.com/nim-lang/threading/pull/8
10:28:34FromDiscord<no name fits> I always found the acronym for MIT a little funny, since it means "mine" in danish. Really accentuates the yoink
10:54:22FromDiscord<arnetheduck> btw @treeform, when `jsony` parses to JsonNode, does it use its own parser or that of JsonNode? also, did you consider any different representations of "dynamic" json? JsonNode doesn't implement the json spec, so it's a bit messy to use unfortunately https://github.com/treeform/jsony#full-support-for-json-in-json
10:54:24fn<R2D299> itHub: 7"A loose, direct to object json parser with hooks."
12:06:01*supakeen quit (Quit: WeeChat 3.2)
12:06:34*supakeen joined #nim
12:11:48FromDiscord<Schelz> Hi, is there any way to get all the drivers (harddisk/ssd) installed on a computer ?
12:12:13FromDiscord<Schelz> (edit) "Hi, is there any way to get ... all" added "name of"
12:15:01FromDiscord<enthus1ast> @Schelz\: https://github.com/johnscillieri/psutil-nim/blob/e94c423b78a5fe1806643926a30a7e02d49124d3/src/psutil/psutil_windows.nim#L48
12:16:44FromDiscord<enthus1ast> Ah the Name... not the type
12:18:09FromDiscord<enthus1ast> https://stackoverflow.com/questions/46548099/how-to-get-drive-name-from-drive-letter
12:19:19FromDiscord<enthus1ast> Then iterate from a to z and call GetVolumeInformation
12:35:54*Vladar quit (Ping timeout: 265 seconds)
12:39:15FromDiscord<Schelz> got it sir it was very helpful
12:39:24*arkurious joined #nim
12:43:12*max22- quit (Ping timeout: 268 seconds)
12:44:42*max22- joined #nim
12:47:47fn<ForumUpdaterBot99> New thread by Veksha: Parallel: invalid control flow for 'parallel', see https://forum.nim-lang.org/t/8270
12:58:50*aeverr joined #nim
13:01:59*kayabaNerve quit (Read error: Connection reset by peer)
13:02:03*kayabaNerve_ joined #nim
13:03:40*TechAspirer joined #nim
13:06:22*kayabaNerve_ quit (Ping timeout: 245 seconds)
13:06:43*kayabaNerve_ joined #nim
13:09:43*TechAspirer quit (Ping timeout: 268 seconds)
13:09:43*max22- quit (Ping timeout: 268 seconds)
13:15:58*rockcavera joined #nim
13:15:58*rockcavera quit (Changing host)
13:15:58*rockcavera joined #nim
13:39:19*Guest31 joined #nim
13:48:34*Guest31 quit (Ping timeout: 246 seconds)
14:00:23*Vladar joined #nim
14:01:34*rockcavera quit (Read error: Connection reset by peer)
14:02:50*rockcavera joined #nim
14:02:50*rockcavera quit (Changing host)
14:02:50*rockcavera joined #nim
14:19:11*neceve joined #nim
14:57:30*Riceberry75 joined #nim
14:57:52*Riceberry75 is now known as Riceberry
15:11:22*max22- joined #nim
15:11:35FromDiscord<treeform> In reply to @arnetheduck "btw <@107140179025735680>, when `jsony`": It uses it's own parser. What don't you like about JsonNode?
15:13:14FromDiscord<enthus1ast> @treeform\: i'm trying out jsony json-in-json, but im getting the error "Error\: undeclared identifier\: 'JsonNode'"
15:14:20FromDiscord<enthus1ast> ah must import stdlibs json for this
15:14:30FromDiscord<enthus1ast> ic
15:42:15FromDiscord<treeform> I'll add that do the docs.
15:43:16*neceve quit (Ping timeout: 268 seconds)
15:47:18FromDiscord<creonico> How can I trow and error and end my program when a condition is not met?
15:47:23FromDiscord<creonico> (edit) "trow" => "throw"
15:48:02FromDiscord<treeform> I usually use `assert`'s will not optimize out variant `doAssert`
15:48:13FromDiscord<treeform> (edit) "will not optimize out variant" => "will-not-optimize-out-variant"
15:51:49FromDiscord<Rika> personally i would only do that for sanity checks
15:51:58FromDiscord<Rika> or actually not even, just for debugging i feel
16:03:08*stkrdknmibalz joined #nim
16:09:37*Riceberry quit (Ping timeout: 246 seconds)
16:13:22*Riceberry joined #nim
16:59:07*max22- quit (Ping timeout: 268 seconds)
17:27:21FromDiscord<dankrad> sent a code paste, see https://play.nim-lang.org/#ix=3u91
17:33:43*rockcavera quit (Remote host closed the connection)
17:33:45*neceve joined #nim
17:37:44FromDiscord<carmysilna> sent a code paste, see https://play.nim-lang.org/#ix=3u95
17:48:16FromDiscord<Rika> `ValueError` btw lol
17:58:41FromDiscord<dankrad> sent a code paste, see https://play.nim-lang.org/#ix=3u9a
17:59:03FromDiscord<dankrad> Only valid values are `SomeStr1`, `SomeStr2`, `SomeStr3`
18:01:13FromDiscord<dankrad> The only current solution that came to my mind is to add a custom pragma to the enum, I can check against. But I don't want to do this if there's a way without custom pragmas.
18:15:30FromDiscord<haxscramper> You can validate input using `let intVal = parseInt(<user input>)` and `intVal in low(EnumInt) .. high(EnumInt)`
18:15:50FromDiscord<haxscramper> If you have holes in your enum then you can implement a macro that lists all possible integer values
18:15:59FromDiscord<haxscramper> Or there is an iterator that supports holes
18:16:49*max22- joined #nim
18:17:04FromDiscord<haxscramper> devel has `std/enumutils.items` that can iterate over enum with holes https://github.com/nim-lang/Nim/blob/devel/lib/std/enumutils.nim#L79
18:18:38FromDiscord<haxscramper> but I assume you are not on devel
18:20:33FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3u9h
18:20:40FromDiscord<arnetheduck> In reply to @treeform "It uses it's own": well, it's a low-level type sort of that would ideally correspond to the spec (there's no such thing as an `int` in the spec for example) - instead, it was implemented as a mix between "this seems convenient in nim" and "this seems to work for the json example I'm looking at" compromising correctness - it has grown even more ugly in `devel` - https://github.com/status-im/nimbus-eth2/issues/2
18:20:43FromDiscord<dankrad> But this won't change anything in my case. intVal = 0 is also in EnumStr
18:21:29FromDiscord<haxscramper> Then set correct values for `EnumStr`
18:21:58FromDiscord<haxscramper> If `0` is a valid integer value, there is no way to check whether it is really allowed or not
18:22:03FromDiscord<dankrad> The problem is that the config file is not mine. I'm operating on a config file of a game
18:23:38FromDiscord<zetashift> ah damn I keep forgetting `=>` in `sugar` doesn't work for func's
18:24:00FromDiscord<haxscramper> I don't understand, why do you want to convert `parseInt` to Str enum in the first place then
18:24:05FromDiscord<dom96> In reply to @zetashift "ah damn I keep": You can add `{.nosideeffect.}`
18:24:08FromDiscord<dankrad> sent a code paste, see https://play.nim-lang.org/#ix=3u9i
18:24:33FromDiscord<zetashift> In reply to @dom96 "You can add `{.nosideeffect.}`": oh sweet, thanks!
18:24:35FromDiscord<haxscramper> You first try to parse int, check if it is a valud value for `EnumInt`. If not you parse as string
18:24:40FromDiscord<haxscramper> Into `EnumStr`
18:25:08FromDiscord<haxscramper> And `parseEnum` uses string representation, so it will fail for `0` input
18:26:06FromDiscord<arnetheduck> In reply to @arnetheduck "well, it's a low-level": now, jsony (and nim-json-serialization which btw should be rebenchmarked, it's changed a bit) solve a slightly different problem than "dynamic json" - the mapping-to-objects is sometimes nice and sometimes not, so we're still looking for a sane json implementation that both corresponds to the spec and can deal with the dynamic case well (including roundtripping and stuff like that)
18:26:33nixfreak_nim[m]I would like to create nim program to convert an ascii / txt file into a csv file. The problem is that not all the rows are the same, so I want to remove all the whitespaces in the file and replace with "," instead. I was thinking of read the entire file and scanning line by line for text and how many whitespaces in that row, then using cli commands replace remove all whitespaces and then replace with ",". Right now its a real pain in the
18:26:33nixfreak_nim[m]ass to use awk and bash since the columns are not same either. I guess I'm looking for suggestions how to make this a lot easier since I'm dealing with thousands of entries
18:27:45FromDiscord<dankrad> I did, but I thought, maybe there's a way to determine it on compile time.
18:29:13FromDiscord<dankrad> This don't work when the user has inserted `0`, because then I can do with the example above\:↡`Antialiasing(parseInt("0"))`, which isn't correct.
18:30:32FromDiscord<dankrad> I think the only working solution is to change 1, 2 and 3 to strings.
18:30:38FromDiscord<zetashift> maybe this can come in handy https://github.com/Vindaar/shell↡(<@709044657232936960_nixfreak_nim=5b=4datrix=5d>)
18:30:56FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3u9l
18:31:03FromDiscord<haxscramper> that part is unfixable in that case
18:31:37FromDiscord<haxscramper> `LowMediumHigh(0)` raises `RangeDefect` which should not be caught, so
18:33:08FromDiscord<dankrad> What do you mean? Why shouldn't they be caught?
18:33:23FromDiscord<haxscramper> it is a defect
18:33:37FromDiscord<haxscramper> Defects can be caught unless you have \`--panics\:on\`\`
18:33:47FromDiscord<haxscramper> If you do, defect is allowed to abort your program on spot
18:34:07FromDiscord<dankrad> Ahh .. ok, didn't knew. Then there's one more reason to change it to strings
18:34:08FromDiscord<haxscramper> which is a bad idea to have something like that IMO, but anyway
18:35:38FromDiscord<dankrad> got it
18:35:39FromDiscord<dankrad> thank you
18:43:28FromDiscord<treeform> In reply to @arnetheduck "well, it's a low-level": I agree json spec is a little loose around the edges, especially numbers. Like how you can send a large int64 between some languages but not JS because its only supports 52bit integers. Probably making every JS number a float64 would have fixed this issue.
18:44:24FromDiscord<treeform> And duplicate keys...
18:44:49FromDiscord<treeform> For my I just want to read/write json and not dwell on it.
18:44:57FromDiscord<treeform> I think JsonNode is fine...
18:45:22FromDiscord<arnetheduck> yeah, it's both loose and isn't and the problem is that the nim json module is loose in other places than the spec so that becomes a problem when we want to implement some standard protocols that are ok vs the json spec but not ok vs the json nim module
18:45:46FromDiscord<treeform> but usually protocols are loose themselves
18:45:54FromDiscord<arnetheduck> not the ones we deal with
18:46:00FromDiscord<treeform> One time I had to read json that produced unquoted keys....
18:46:04FromDiscord<treeform> its not valid json!
18:46:10FromDiscord<treeform> but you could eval() it in js
18:46:13FromDiscord<arnetheduck> well, that's a whole different story πŸ™‚
18:47:01FromDiscord<treeform> My points is basically no one really follows the spec that well, you just do what you got to do πŸ™‚
18:48:51FromDiscord<arnetheduck> well, yeah, the world is messy enough though, no need for the json module to mess it up further and we've run into the problem N times too many by now (ie really, the _last_ thing we want to spend time on is writing yet another json module)
18:48:53FromDiscord<treeform> json is almost like a natural language in that it has dialects, like python's json and go's json.
18:49:14FromDiscord<treeform> What problems do you run into?
18:49:36FromDiscord<arnetheduck> initially, crashes and security issues in the parser because numbers are poorly supported
18:50:19FromDiscord<arnetheduck> later, the lack of control over int vs float which is kind of arbitrary in the impl
18:50:56FromDiscord<arnetheduck> ie json is used for external data mostly, so under no circumstances whatsoever should it raise a Defect
18:51:11FromDiscord<arnetheduck> (edit) "ie json is used for external data mostly, so under no circumstances whatsoever should it raise a Defect ... " added "when parsing"
18:51:33FromDiscord<treeform> Defect like a segfault?
18:52:06FromDiscord<treeform> try: parse(x) catch ... should probably be done for all json parsing πŸ™‚
18:53:09FromDiscord<arnetheduck> defect like a defect πŸ™‚ it's messy in Nim, as haxscramper points out, since there are different dialects of the language where `try/except` does different things, it's not covered by the effect system (which we use to enforce error handling) etc
18:54:04FromDiscord<treeform> true you could get json that is very nested and it could crash the stack.
18:54:18FromDiscord<treeform> should add a depth check to jsony
18:54:28FromDiscord<arnetheduck> well, the code was previously casting to `int` without doing a range check - stuff like that
18:54:38FromDiscord<arnetheduck> (edit) "casting" => "converting"
18:54:50FromDiscord<haxscramper> Defect should be deprecate IMO
18:55:05FromDiscord<haxscramper> In the several years of using nim I had exactly zero use cases for it
18:55:10FromDiscord<arnetheduck> this causes crashes which in our code translates to remote exploits which is bad
18:55:11FromDiscord<haxscramper> And tons of issues like that
18:55:13FromDiscord<treeform> Is there a good test suite of valid json and invalid json?
18:55:30FromDiscord<treeform> especially very valid looking json that is invalid?
18:56:06fn<Prestige99> https://github.com/json-schema-org/JSON-Schema-Test-Suite ?
18:56:06fn<R2D299> itHub: 7"A language agnostic test suite for the JSON Schema specifications"
18:56:16FromDiscord<arnetheduck> well, there's also the "valid-but-json-module-doesn't-support-it" category
18:56:25FromDiscord<arnetheduck> https://github.com/nst/JSONTestSuite comes up in a quick google
18:56:26fn<R2D299> itHub: 7"A comprehensive test suite for RFC 8259 compliant JSON parsers"
18:56:56FromDiscord<arnetheduck> In reply to @haxscramper "And tons of issues": don't get me started πŸ™‚
18:58:46FromDiscord<haxscramper> Maybe there are valid uses for it. Somewhere
18:58:55FromDiscord<haxscramper> I would be curious if someone could share
19:26:30FromDiscord<hamidb80> In reply to @Rika "hm i guess, but": {.nanChecks: on, infChecks: on.}
19:28:47FromDiscord<haxscramper> I mean - why should this have an ability to abort your program
19:28:57FromDiscord<haxscramper> Why not just exceptoin
19:30:00FromDiscord<treeform> I am looking at `JSON-Schema-Test-Suite` jsony only crashes on the stack one.
19:30:09FromDiscord<treeform> I guess I will add a limit then I will crash on none.
19:38:09FromDiscord<planetis> catching defect produces worse assembly why dont you write proper checks instead
19:39:54FromDiscord<planetis> where exactly parseJson throws defect any open issue?
19:44:28FromDiscord<treeform> ^ I don't understand what you mean?
19:44:49FromDiscord<treeform> Is there a way to check for stack depth or catch the stack overflow error?
19:45:46FromDiscord<ynfle (ynfle)> You can do it manually either global variable or pass in a parameter
19:46:11FromDiscord<treeform> I don't want to pass variable manually
19:46:18FromDiscord<treeform> well I want to bench the 3 approaches:
19:46:25FromDiscord<treeform> manual var
19:46:28FromDiscord<planetis> https://github.com/nim-lang/Nim/issues/17383 ?
19:46:36FromDiscord<treeform> checking allocation pointer
19:46:43FromDiscord<treeform> and catching exception
19:50:22FromDiscord<dom96> In reply to @haxscramper "Defect should be deprecate": wasn't it added post-1.0? it feels like a relatively new thing, maybe I'm still living in 0.19 land πŸ™‚
19:56:31*max22- quit (Remote host closed the connection)
20:00:12FromDiscord<planetis> actually thenim manual has a section about it https://nim-lang.github.io/Nim/manual.html#definitions
20:00:59FromDiscord<planetis> so the oddballs are the ones catching defects not the other way around
20:06:28*neceve quit (Ping timeout: 256 seconds)
20:13:54*max22- joined #nim
20:30:50*max22- quit (Ping timeout: 256 seconds)
21:01:55*max22- joined #nim
21:19:36*max22- quit (Quit: Leaving)
21:43:11FromDiscord<haxscramper> They also force programmer into a corner where they have only two ways out - catch things, or see how your program aborts itself trying to divide by zero
21:43:48FromDiscord<haxscramper> Or some library does what can effectively considered quit(1) on error
21:44:49FromDiscord<haxscramper> And it is not hard to imagine why people catch defects
23:18:00*Vladar quit (Quit: Leaving)
23:27:19*rockcavera joined #nim
23:27:20*rockcavera quit (Changing host)
23:27:20*rockcavera joined #nim