01:00:58 | * | TakinOver quit (Ping timeout: 240 seconds) |
01:10:46 | FromDiscord | <@bracketmaster-5a708063d73408ce4> @elegantbeef\:matrix.org - your link from earlier is empty? |
01:11:11 | FromDiscord | <@bracketmaster-5a708063d73408ce4> Also - is it guaranteed that integer arrays in nim are always initialized to zero? |
01:11:31 | FromDiscord | <Elegantbeef> Nim 0 inits all memory unless overridden |
01:11:37 | FromDiscord | <Elegantbeef> http://ix.io/3u5j here is what i suggested |
01:12:57 | FromDiscord | <@bracketmaster-5a708063d73408ce4> I see it now. That's rather elegant. |
01:13:16 | FromDiscord | <@bracketmaster-5a708063d73408ce4> Also - is there a place in the manual where nim's init behaviors are explicitly mentioned? |
01:14:37 | FromDiscord | <Elegantbeef> Well without `{.noInit.}` or `{.requiresInit.}` in the type the memory is 0'd |
01:15:30 | FromDiscord | <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:16 | FromDiscord | <@bracketmaster-5a708063d73408ce4> ok - I'll take your word for it |
01:28:11 | FromDiscord | <Elegantbeef> Well it is explained in more detail https://nim-lang.org/docs/manual.html#statements-and-expressions-var-statement |
01:47:50 | FromDiscord | <@bracketmaster-5a708063d73408ce4> thx! |
02:00:42 | * | arkurious quit (Quit: Leaving) |
02:49:48 | fn | <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:19 | FromDiscord | <Clonkk> Was "examples" removed from category in testament ? |
09:00:44 | FromDiscord | <Clonkk> WHen I use devel I can't do `testament c examples` |
09:02:33 | fn | <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:48 | FromDiscord | <planetis> if my nim module is a port of another project in say cpp should my license header include the original author? |
10:14:12 | FromDiscord | <haxscramper> that depends on the license |
10:14:37 | FromDiscord | <sealmove> looool Scala 3 changes the syntax to indentation based xD wtf |
10:14:41 | FromDiscord | <haxscramper> See if wrapper qualifies as "derivative work" or something like that |
10:16:08 | FromDiscord | <haxscramper> or port |
10:16:27 | FromDiscord | <haxscramper> But it would make sense to credit the original author |
10:16:31 | FromDiscord | <sealmove> upper code: Scala 2, lower code: Scala 3 https://media.discordapp.net/attachments/371759389889003532/869161250033106954/unknown.png |
10:17:50 | FromDiscord | <haxscramper> it feels like they took all syntaxes at once. I looked at the documentation and it such a mess |
10:18:14 | FromDiscord | <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:38 | FromDiscord | <sealmove> it does, but they want to enforce coding style |
10:20:14 | FromDiscord | <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:30 | FromDiscord | <generic linux user> In reply to @haxscramper "that depends on the": on cc-3.0? |
10:27:08 | FromDiscord | <planetis> its mit licensed |
10:28:22 | FromDiscord | <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:34 | FromDiscord | <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:22 | FromDiscord | <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:24 | fn | <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:48 | FromDiscord | <Schelz> Hi, is there any way to get all the drivers (harddisk/ssd) installed on a computer ? |
12:12:13 | FromDiscord | <Schelz> (edit) "Hi, is there any way to get ... all" added "name of" |
12:15:01 | FromDiscord | <enthus1ast> @Schelz\: https://github.com/johnscillieri/psutil-nim/blob/e94c423b78a5fe1806643926a30a7e02d49124d3/src/psutil/psutil_windows.nim#L48 |
12:16:44 | FromDiscord | <enthus1ast> Ah the Name... not the type |
12:18:09 | FromDiscord | <enthus1ast> https://stackoverflow.com/questions/46548099/how-to-get-drive-name-from-drive-letter |
12:19:19 | FromDiscord | <enthus1ast> Then iterate from a to z and call GetVolumeInformation |
12:35:54 | * | Vladar quit (Ping timeout: 265 seconds) |
12:39:15 | FromDiscord | <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:47 | fn | <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:35 | FromDiscord | <treeform> In reply to @arnetheduck "btw <@107140179025735680>, when `jsony`": It uses it's own parser. What don't you like about JsonNode? |
15:13:14 | FromDiscord | <enthus1ast> @treeform\: i'm trying out jsony json-in-json, but im getting the error "Error\: undeclared identifier\: 'JsonNode'" |
15:14:20 | FromDiscord | <enthus1ast> ah must import stdlibs json for this |
15:14:30 | FromDiscord | <enthus1ast> ic |
15:42:15 | FromDiscord | <treeform> I'll add that do the docs. |
15:43:16 | * | neceve quit (Ping timeout: 268 seconds) |
15:47:18 | FromDiscord | <creonico> How can I trow and error and end my program when a condition is not met? |
15:47:23 | FromDiscord | <creonico> (edit) "trow" => "throw" |
15:48:02 | FromDiscord | <treeform> I usually use `assert`'s will not optimize out variant `doAssert` |
15:48:13 | FromDiscord | <treeform> (edit) "will not optimize out variant" => "will-not-optimize-out-variant" |
15:51:49 | FromDiscord | <Rika> personally i would only do that for sanity checks |
15:51:58 | FromDiscord | <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:21 | FromDiscord | <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:44 | FromDiscord | <carmysilna> sent a code paste, see https://play.nim-lang.org/#ix=3u95 |
17:48:16 | FromDiscord | <Rika> `ValueError` btw lol |
17:58:41 | FromDiscord | <dankrad> sent a code paste, see https://play.nim-lang.org/#ix=3u9a |
17:59:03 | FromDiscord | <dankrad> Only valid values are `SomeStr1`, `SomeStr2`, `SomeStr3` |
18:01:13 | FromDiscord | <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:30 | FromDiscord | <haxscramper> You can validate input using `let intVal = parseInt(<user input>)` and `intVal in low(EnumInt) .. high(EnumInt)` |
18:15:50 | FromDiscord | <haxscramper> If you have holes in your enum then you can implement a macro that lists all possible integer values |
18:15:59 | FromDiscord | <haxscramper> Or there is an iterator that supports holes |
18:16:49 | * | max22- joined #nim |
18:17:04 | FromDiscord | <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:38 | FromDiscord | <haxscramper> but I assume you are not on devel |
18:20:33 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3u9h |
18:20:40 | FromDiscord | <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:43 | FromDiscord | <dankrad> But this won't change anything in my case. intVal = 0 is also in EnumStr |
18:21:29 | FromDiscord | <haxscramper> Then set correct values for `EnumStr` |
18:21:58 | FromDiscord | <haxscramper> If `0` is a valid integer value, there is no way to check whether it is really allowed or not |
18:22:03 | FromDiscord | <dankrad> The problem is that the config file is not mine. I'm operating on a config file of a game |
18:23:38 | FromDiscord | <zetashift> ah damn I keep forgetting `=>` in `sugar` doesn't work for func's |
18:24:00 | FromDiscord | <haxscramper> I don't understand, why do you want to convert `parseInt` to Str enum in the first place then |
18:24:05 | FromDiscord | <dom96> In reply to @zetashift "ah damn I keep": You can add `{.nosideeffect.}` |
18:24:08 | FromDiscord | <dankrad> sent a code paste, see https://play.nim-lang.org/#ix=3u9i |
18:24:33 | FromDiscord | <zetashift> In reply to @dom96 "You can add `{.nosideeffect.}`": oh sweet, thanks! |
18:24:35 | FromDiscord | <haxscramper> You first try to parse int, check if it is a valud value for `EnumInt`. If not you parse as string |
18:24:40 | FromDiscord | <haxscramper> Into `EnumStr` |
18:25:08 | FromDiscord | <haxscramper> And `parseEnum` uses string representation, so it will fail for `0` input |
18:26:06 | FromDiscord | <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:33 | nixfreak_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:33 | nixfreak_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:45 | FromDiscord | <dankrad> I did, but I thought, maybe there's a way to determine it on compile time. |
18:29:13 | FromDiscord | <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:32 | FromDiscord | <dankrad> I think the only working solution is to change 1, 2 and 3 to strings. |
18:30:38 | FromDiscord | <zetashift> maybe this can come in handy https://github.com/Vindaar/shellβ΅(<@709044657232936960_nixfreak_nim=5b=4datrix=5d>) |
18:30:56 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3u9l |
18:31:03 | FromDiscord | <haxscramper> that part is unfixable in that case |
18:31:37 | FromDiscord | <haxscramper> `LowMediumHigh(0)` raises `RangeDefect` which should not be caught, so |
18:33:08 | FromDiscord | <dankrad> What do you mean? Why shouldn't they be caught? |
18:33:23 | FromDiscord | <haxscramper> it is a defect |
18:33:37 | FromDiscord | <haxscramper> Defects can be caught unless you have \`--panics\:on\`\` |
18:33:47 | FromDiscord | <haxscramper> If you do, defect is allowed to abort your program on spot |
18:34:07 | FromDiscord | <dankrad> Ahh .. ok, didn't knew. Then there's one more reason to change it to strings |
18:34:08 | FromDiscord | <haxscramper> which is a bad idea to have something like that IMO, but anyway |
18:35:38 | FromDiscord | <dankrad> got it |
18:35:39 | FromDiscord | <dankrad> thank you |
18:43:28 | FromDiscord | <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:24 | FromDiscord | <treeform> And duplicate keys... |
18:44:49 | FromDiscord | <treeform> For my I just want to read/write json and not dwell on it. |
18:44:57 | FromDiscord | <treeform> I think JsonNode is fine... |
18:45:22 | FromDiscord | <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:46 | FromDiscord | <treeform> but usually protocols are loose themselves |
18:45:54 | FromDiscord | <arnetheduck> not the ones we deal with |
18:46:00 | FromDiscord | <treeform> One time I had to read json that produced unquoted keys.... |
18:46:04 | FromDiscord | <treeform> its not valid json! |
18:46:10 | FromDiscord | <treeform> but you could eval() it in js |
18:46:13 | FromDiscord | <arnetheduck> well, that's a whole different story π |
18:47:01 | FromDiscord | <treeform> My points is basically no one really follows the spec that well, you just do what you got to do π |
18:48:51 | FromDiscord | <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:53 | FromDiscord | <treeform> json is almost like a natural language in that it has dialects, like python's json and go's json. |
18:49:14 | FromDiscord | <treeform> What problems do you run into? |
18:49:36 | FromDiscord | <arnetheduck> initially, crashes and security issues in the parser because numbers are poorly supported |
18:50:19 | FromDiscord | <arnetheduck> later, the lack of control over int vs float which is kind of arbitrary in the impl |
18:50:56 | FromDiscord | <arnetheduck> ie json is used for external data mostly, so under no circumstances whatsoever should it raise a Defect |
18:51:11 | FromDiscord | <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:33 | FromDiscord | <treeform> Defect like a segfault? |
18:52:06 | FromDiscord | <treeform> try: parse(x) catch ... should probably be done for all json parsing π |
18:53:09 | FromDiscord | <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:04 | FromDiscord | <treeform> true you could get json that is very nested and it could crash the stack. |
18:54:18 | FromDiscord | <treeform> should add a depth check to jsony |
18:54:28 | FromDiscord | <arnetheduck> well, the code was previously casting to `int` without doing a range check - stuff like that |
18:54:38 | FromDiscord | <arnetheduck> (edit) "casting" => "converting" |
18:54:50 | FromDiscord | <haxscramper> Defect should be deprecate IMO |
18:55:05 | FromDiscord | <haxscramper> In the several years of using nim I had exactly zero use cases for it |
18:55:10 | FromDiscord | <arnetheduck> this causes crashes which in our code translates to remote exploits which is bad |
18:55:11 | FromDiscord | <haxscramper> And tons of issues like that |
18:55:13 | FromDiscord | <treeform> Is there a good test suite of valid json and invalid json? |
18:55:30 | FromDiscord | <treeform> especially very valid looking json that is invalid? |
18:56:06 | fn | <Prestige99> https://github.com/json-schema-org/JSON-Schema-Test-Suite ? |
18:56:06 | fn | <R2D299> itHub: 7"A language agnostic test suite for the JSON Schema specifications" |
18:56:16 | FromDiscord | <arnetheduck> well, there's also the "valid-but-json-module-doesn't-support-it" category |
18:56:25 | FromDiscord | <arnetheduck> https://github.com/nst/JSONTestSuite comes up in a quick google |
18:56:26 | fn | <R2D299> itHub: 7"A comprehensive test suite for RFC 8259 compliant JSON parsers" |
18:56:56 | FromDiscord | <arnetheduck> In reply to @haxscramper "And tons of issues": don't get me started π |
18:58:46 | FromDiscord | <haxscramper> Maybe there are valid uses for it. Somewhere |
18:58:55 | FromDiscord | <haxscramper> I would be curious if someone could share |
19:26:30 | FromDiscord | <hamidb80> In reply to @Rika "hm i guess, but": {.nanChecks: on, infChecks: on.} |
19:28:47 | FromDiscord | <haxscramper> I mean - why should this have an ability to abort your program |
19:28:57 | FromDiscord | <haxscramper> Why not just exceptoin |
19:30:00 | FromDiscord | <treeform> I am looking at `JSON-Schema-Test-Suite` jsony only crashes on the stack one. |
19:30:09 | FromDiscord | <treeform> I guess I will add a limit then I will crash on none. |
19:38:09 | FromDiscord | <planetis> catching defect produces worse assembly why dont you write proper checks instead |
19:39:54 | FromDiscord | <planetis> where exactly parseJson throws defect any open issue? |
19:44:28 | FromDiscord | <treeform> ^ I don't understand what you mean? |
19:44:49 | FromDiscord | <treeform> Is there a way to check for stack depth or catch the stack overflow error? |
19:45:46 | FromDiscord | <ynfle (ynfle)> You can do it manually either global variable or pass in a parameter |
19:46:11 | FromDiscord | <treeform> I don't want to pass variable manually |
19:46:18 | FromDiscord | <treeform> well I want to bench the 3 approaches: |
19:46:25 | FromDiscord | <treeform> manual var |
19:46:28 | FromDiscord | <planetis> https://github.com/nim-lang/Nim/issues/17383 ? |
19:46:36 | FromDiscord | <treeform> checking allocation pointer |
19:46:43 | FromDiscord | <treeform> and catching exception |
19:50:22 | FromDiscord | <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:12 | FromDiscord | <planetis> actually thenim manual has a section about it https://nim-lang.github.io/Nim/manual.html#definitions |
20:00:59 | FromDiscord | <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:11 | FromDiscord | <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:48 | FromDiscord | <haxscramper> Or some library does what can effectively considered quit(1) on error |
21:44:49 | FromDiscord | <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 |