00:06:05 | FromDiscord | <retkid> sent a code paste, see https://play.nim-lang.org/#ix=3Hju |
00:07:13 | FromDiscord | <retkid> (edit) "https://play.nim-lang.org/#ix=3Hju" => "https://play.nim-lang.org/#ix=3Hjv" |
00:07:33 | FromDiscord | <retkid> this is strange |
00:27:03 | arkanoid | as Rika says, I just stepped on this by accident. I know it's something that has no sense really, but internal error is unexpected anyways |
00:33:15 | FromDiscord | <Elegantbeef> It's a simple bug afaict, sem's the expression `sequtils` which is a module so when it attempts to generate it, it errors with the expr generation error |
00:33:58 | FromDiscord | <Elegantbeef> Any expression returning a module should almost certainly error |
00:35:18 | FromDiscord | <Elegantbeef> error in semantic analysis not in code gen 😀 |
00:36:45 | FromDiscord | <Rika> you did say sem and not codegen |
00:36:51 | FromDiscord | <Rika> who are you correcting |
00:36:56 | arkanoid | sure it is a stupid error, but it is. I've just opened the issue |
00:37:57 | FromDiscord | <Elegantbeef> well it errors in code gen presently |
00:38:01 | FromDiscord | <Elegantbeef> I was just saying where it should error |
00:40:42 | arkanoid | I'm not into compiler internals. I need a good book that can introduce me to the parsing world, better if the one use in nim. Actually I'd be really interested in acquiring this skill |
00:41:03 | FromDiscord | <Elegantbeef> This is actually unrelated to parsing |
00:41:17 | FromDiscord | <Elegantbeef> I spend most my time in semantic analysis, which is basically macros but in the compiler |
00:41:44 | FromDiscord | <Elegantbeef> The issue here is that presently `semExpr` doesnt error when `n.kind == skModule` though it should |
00:43:03 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/Nim/blob/f91867aa31f3ae2c4f28d24547d62603daaa6d0c/compiler/semexprs.nim#L2793-L2810 right here to be accurate |
00:43:23 | FromDiscord | <Elegantbeef> Notice there is no checking of `skModule` |
00:45:44 | FromDiscord | <Elegantbeef> Though i could be wrong with the idea that modules shouldnt be usable in expressions |
00:46:12 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3HjA |
00:47:45 | arkanoid | well, it might be useful for a plugin system |
00:48:28 | FromDiscord | <Elegantbeef> Yep which makes this more complicated 😀 |
00:50:07 | * | src quit (Quit: Leaving) |
00:50:12 | FromDiscord | <Elegantbeef> So now we have to look at the flags that `semExpr` has and see if we can use those to reason out of this problem 😀 |
00:52:09 | arkanoid | would be interesting hear a gentle introduction to nim compiler internals |
00:53:22 | FromDiscord | <Elegantbeef> Well actually that isnt even valid code in the above |
00:53:53 | FromDiscord | <Elegantbeef> `/usercode/in.nim(2, 49) Error: in expression 'math.sum': identifier expected, but found 'sum'` Lol |
00:55:41 | FromDiscord | <Elegantbeef> I'd say you have 3 phases of compilation. Parsing, semantic analysis, and code generation |
00:57:34 | FromDiscord | <Elegantbeef> Parsing is taking the code and turning it into the AST. Semantic analysis is taking that AST and checking it's soundness and generating types, code generation takes that AST then outputs the selected backend's compatible code, changing it as it needs to to fit with the semantics of the selected backend |
00:58:43 | FromDiscord | <Elegantbeef> Semantic analysis is the most complex stage as it's really where the language lives |
01:01:45 | NimEventer | New thread by Treeform: Show Nim: Forematics is a Metamath verifier written in Nim., see https://forum.nim-lang.org/t/8691 |
01:02:15 | arkanoid | does Nim have an advantage over other languages? |
01:02:35 | arkanoid | I mean, talking about compiler structure |
01:02:53 | FromDiscord | <Elegantbeef> Well it's self hosted unlike to Zig/Odin |
01:03:00 | FromDiscord | <Elegantbeef> Zig uses a packed AST which is faster |
01:03:23 | FromDiscord | <Elegantbeef> Nim uses a reference based AST which is slower for obvious reasons but is easier to directly reason about |
01:05:07 | arkanoid | is it a parsing advantage or we're into semantic analysis step? |
01:05:31 | FromDiscord | <Elegantbeef> The performance advantage is in cache locality for the repetitive looping in semantic analysis/code gen |
01:05:44 | FromDiscord | <Elegantbeef> Cause that's all the compiler really is, a tree of data it loops over and reasons on |
01:05:58 | FromDiscord | <Elegantbeef> Take a look at `var a = 300` |
01:06:39 | FromDiscord | <Elegantbeef> It's a simple thing, but the way the compiler sees it is `varsection -> identdefs -> (a: nkEmpty = nkIntLit(300))` |
01:07:38 | FromDiscord | <Elegantbeef> So it first says "Sem this varsection" which then goes through each ident def and checks "Ok so we have type nkEmpty and an nkIntLit, does this fit, yes? Ok so we can type this to nkInt instead of nkEmpty" |
01:07:48 | FromDiscord | <Elegantbeef> well i guess it'd be `tyInt` in reality |
01:09:02 | FromDiscord | <Elegantbeef> After seming that we now have a symbol `a` of type `tyInt`, so in any other statements that come after we will find this symbol and know it's type when we do `a` |
01:09:58 | FromDiscord | <Elegantbeef> That pretty much is all the compiler does in semantic analysis |
01:10:12 | FromDiscord | <Elegantbeef> Hopefully i explained it well enough |
01:11:22 | * | vicfred quit (Quit: Leaving) |
01:11:28 | FromDiscord | <Elegantbeef> Feel free to ask if you have any questions, i'm not the best compiler dev but i know how stuff works 😛 |
01:12:59 | FromDiscord | <Elegantbeef> Personally i've never read anything about compiler development i've just looked at small bugs like this one and face to grindstone until i reasoned why/how to fix it |
01:13:10 | FromDiscord | <Elegantbeef> So if you want to touch the compiler i'd suggest the same |
01:13:28 | FromDiscord | <Elegantbeef> Look for simple bugs and find why they dont work and soon you'll be a better compiler dev than I 🙂 |
01:15:01 | arkanoid | you've my gratitude for this intro and for the confidence booster pill |
01:16:03 | FromDiscord | <Elegantbeef> Given what i've told you you probably can make a PR to the compiler for fixing this module issue |
01:16:43 | FromDiscord | <Elegantbeef> You have the exact line number and a flag for when the error should be emitted, so just need to emit the error and make some tests |
01:18:10 | FromDiscord | <Elegantbeef> One of the harder things is thinking of examples on where this might break or what might break |
01:18:27 | FromDiscord | <Elegantbeef> You want tests that properly attempt to break the code not just tests that show it working |
01:20:14 | FromDiscord | <Elegantbeef> It is a shame there arent more people with knowledge of the Nim compiler actively talking about compiler developing encouraging others though |
01:21:38 | arkanoid | yes, but it feels something hard to grasp |
01:22:02 | FromDiscord | <Elegantbeef> It first seems that way, but if you're in semantic analysis, it's just slightly lower level macros |
01:22:32 | FromDiscord | <Elegantbeef> Like that was the big thing that i needed to understand to really understand to reason how to work with the compiler |
01:31:32 | arkanoid | a visualization like this? :P https://cscircles.cemc.uwaterloo.ca/visualize#mode=display |
01:32:16 | FromDiscord | <Elegantbeef> I do not know |
01:32:27 | FromDiscord | <Professor Actual Factual> Does anyone know if the std/deques implementation is threadsafe? Im looking into the source code and to me it does not look like it is https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/collections/deques.nim#L369 |
01:32:35 | FromDiscord | <Elegantbeef> Ah actually certainly not like that |
01:32:40 | FromDiscord | <Elegantbeef> That's showing a running program |
01:33:08 | FromDiscord | <Elegantbeef> I guess it's like the Global frame alone |
01:33:22 | FromDiscord | <Elegantbeef> Where it looks at the global symbols and says "These exist and take X" |
02:37:03 | nrds | <Prestige99> Has anyone used coz-profiler, or has anyone tried using it with Nim? It looks interesting |
02:50:13 | * | bigmanbird joined #nim |
02:50:21 | bigmanbird | any word on the progress of this PR https://github.com/nim-lang/Nim/pull/16356 ? |
02:51:02 | FromDiscord | <Elegantbeef> Uhh i'm a dumb dumb that doesnt like what i've done |
02:52:26 | bigmanbird | oh, I thought it looked nice |
02:54:01 | nrds | <Prestige99> I was also looking forward to it :P |
02:55:24 | FromDiscord | <Elegantbeef> Well it's going to just turn into anything inside `'a'` is coloured so not overly useful imo |
02:55:42 | nrds | <Prestige99> Agreed |
02:56:15 | FromDiscord | <Elegantbeef> Colouring all the errors is tedious and requires something like nkerror to be used fully |
02:56:42 | nrds | <Prestige99> nkerror not being used everywhere there's an error thrown? |
02:58:02 | FromDiscord | <Elegantbeef> Atleast in my view yes |
02:58:50 | FromDiscord | <Rika> i think in general there should be a nicer internal api for errors in the compiler, it just feels like an afterthought |
02:59:01 | FromDiscord | <Elegantbeef> I think the nk errors give that |
02:59:08 | FromDiscord | <Rika> true |
02:59:38 | FromDiscord | <Rika> i assume also that nkerrors can have nodes in them as well |
03:00:03 | FromDiscord | <Elegantbeef> In saem's nimskull impl nkerrors hold the AST that erroed |
03:00:10 | FromDiscord | <Rika> nice |
03:00:25 | FromDiscord | <Rika> and also structured error text should be a part i feel |
03:01:01 | * | neurocyte0132889 quit (Ping timeout: 240 seconds) |
03:01:10 | FromDiscord | <Elegantbeef> Yep hax is wanting that aswell |
03:17:27 | FromDiscord | <Casey.McMahon> anyone with experience with arraymancer know how I can get a list of coordinates of the neigbourhood around a point? like if I choose the point `[1,1]`, get a list like `[[0,0],[0,1],[0,2],[1,0],[1,2],[2,0],[2,1],[2,2]]` ? |
03:28:49 | * | arkurious quit (Quit: Leaving) |
03:39:21 | * | tiorock joined #nim |
03:39:21 | * | tiorock quit (Changing host) |
03:39:21 | * | tiorock joined #nim |
03:39:21 | * | rockcavera is now known as Guest3185 |
03:39:21 | * | tiorock is now known as rockcavera |
03:42:13 | * | Guest3185 quit (Ping timeout: 240 seconds) |
03:44:14 | * | bigmanbird quit (Read error: Connection reset by peer) |
04:06:01 | * | supakeen quit (Quit: WeeChat 3.3) |
04:06:31 | * | supakeen joined #nim |
04:35:47 | * | xet7 quit (Remote host closed the connection) |
04:36:49 | * | xet7 joined #nim |
05:04:41 | * | u0_a185 joined #nim |
05:54:34 | FromDiscord | <haxscramper> https://github.com/nim-works/nimskull/pull/94↵(@Rika) |
05:56:16 | FromDiscord | <Rika> Maybe I should pull the trigger and start looking deeper |
05:56:22 | FromDiscord | <haxscramper> I doubt main nim ever agrees to a refactor like that, so |
05:56:49 | FromDiscord | <haxscramper> Araq thinks error message are good enough, and he probably wouldn't like changes that aggressive |
05:57:00 | FromDiscord | <haxscramper> Bit this literally is everywhere |
05:57:22 | FromDiscord | <haxscramper> Absolutely every single damn module of the compiler generates ad-hoc copypasta of strings |
05:57:57 | FromDiscord | <haxscramper> https://github.com/nim-works/nimskull/discussions/60#discussioncomment-1674521 |
06:17:40 | FromDiscord | <Sabena Sema> where's the github repo of work on a new os library that had an os string/program string distinction |
06:22:31 | * | vicfred joined #nim |
06:47:39 | FromDiscord | <haxscramper> The only thing that can qualify as a "new os library" is probably this https://github.com/alaviss/nim-sys |
06:47:55 | FromDiscord | <haxscramper> But I'm not sure if it has the distinction you are talking about |
06:48:01 | FromDiscord | <leorize> it doesn't |
06:48:27 | FromDiscord | <leorize> it only has string/nulless distinction |
07:16:25 | * | u0_a185 quit (Read error: Connection reset by peer) |
07:16:42 | * | u0_a185 joined #nim |
07:28:15 | FromDiscord | <konsumlamm> In reply to @Professor Actual Factual "Does anyone know if": i'm pretty sure none of the stdlib collections are thread-safe (except the ones that have "shared" in their name, but those are all deprecated now) |
07:30:01 | * | vicfred quit (Quit: Leaving) |
07:30:20 | * | vicecea quit (Read error: Connection reset by peer) |
07:30:51 | * | vicecea joined #nim |
07:54:47 | FromDiscord | <hieu.nt> guys can i do something like this in nim |
07:55:02 | FromDiscord | <hieu.nt> if define MACOS |
07:55:08 | FromDiscord | <hieu.nt> import A |
07:55:21 | FromDiscord | <hieu.nt> else if define Windows |
07:55:23 | FromDiscord | <hieu.nt> import B |
07:55:29 | FromDiscord | <leorize> yes you can |
07:55:55 | FromDiscord | <leorize> sent a code paste, see https://play.nim-lang.org/#ix=3Hky |
08:00:26 | Amun-Ra | you can have your own defines: https://play.nim-lang.org/#ix=3HkB |
08:09:07 | * | PMunch joined #nim |
08:22:46 | PMunch | Does nimsuggest support go to definition on modules? Ref. https://github.com/PMunch/nimlsp/issues/102 |
08:58:39 | * | pro joined #nim |
09:13:22 | * | xet7 quit (Quit: Leaving) |
09:37:38 | FromDiscord | <valerga> sent a code paste, see https://play.nim-lang.org/#ix=3HkS |
09:37:39 | FromDiscord | <valerga> for some reason that doesn't work |
09:37:50 | FromDiscord | <valerga> "type mismatch: got <void> ... " |
09:38:37 | PMunch | You need else statements I believe |
09:39:27 | PMunch | Oh never mind |
09:56:16 | * | pro quit (Quit: WeeChat 3.3) |
09:57:08 | * | pro joined #nim |
10:12:52 | FromDiscord | <Sabena Sema> In reply to @haxscramper "The only thing that": thank you, that's what I was looking for |
10:13:11 | FromDiscord | <Sabena Sema> also: I note that std/packedsets has a note "Currently the assignment operator = for PackedSet[A] performs some rather meaningless shallow copy. Since Nim currently does not allow the assignment operator to be overloaded, use the assign proc to get a deep copy." |
10:13:45 | FromDiscord | <Sabena Sema> it seems like `=copy` exists in nim 1.6, has nobody gotten around to adding support for it in packedset or is it lacking due to not wanting to break code |
10:15:01 | FromDiscord | <Rika> Likely the former, since you could just leave the assign proc |
10:15:17 | FromDiscord | <Sabena Sema> yeah but it would break anyone relying on the old shallow copy |
10:15:25 | FromDiscord | <Sabena Sema> although most of that code is just buggy 😄 |
10:15:33 | FromDiscord | <Sabena Sema> so really you are probably fixing more bugs than you're creating |
10:16:19 | FromDiscord | <Rika> Every bug fix can be considered as a breaking change but there is a limit to sanity |
10:16:59 | FromDiscord | <MrOkram> Nimble directory down ? https://media.discordapp.net/attachments/371759389889003532/918083728033607730/unknown.png |
10:17:16 | FromDiscord | <Rika> Who was it again who maintained that |
10:17:23 | FromDiscord | <Rika> @federico3 |
10:18:01 | FromDiscord | <Sabena Sema> hmm maybe it's because they are experimental by virtue of being type-bound |
10:18:41 | FromDiscord | <Elegantbeef> The type bound operations are not experimental |
10:19:28 | FromDiscord | <Sabena Sema> just `=deepCopy`? |
10:20:27 | FromDiscord | <Elegantbeef> What do you mean? |
10:31:07 | FromDiscord | <Zoom> What's up with nimble.directory? Gives me 502 |
10:31:47 | FromDiscord | <MrOkram> Looks like it's down |
10:46:15 | NimEventer | New question by Katlyn: Nim: Find index of element in seq based on predicate, see https://stackoverflow.com/questions/70273671/nim-find-index-of-element-in-seq-based-on-predicate |
10:46:35 | FromDiscord | <inv> Anyone has laptop with amd 5800u? |
10:57:39 | FromDiscord | <valerga> what's the nice way to do: |
10:57:47 | FromDiscord | <valerga> sent a code paste, see https://play.nim-lang.org/#ix=3Hla |
10:59:22 | FromDiscord | <Rika> Use either zero functional (3rd party) or sequtils (has overhead) |
10:59:47 | FromDiscord | <valerga> which sequtils method? |
10:59:59 | FromDiscord | <Rika> mapIt |
11:00:06 | FromDiscord | <Rika> Ah wait |
11:00:07 | FromDiscord | <Solitude> foldl |
11:00:08 | FromDiscord | <inv> @valerga foldr(a+a) or import math and sum() |
11:00:11 | FromDiscord | <Rika> Yeah map and folds |
11:00:46 | FromDiscord | <inv> sent a code paste, see https://play.nim-lang.org/#ix=3Hld |
11:00:50 | FromDiscord | <valerga> i thought about those but wouldn't they require an already filled array? |
11:00:56 | FromDiscord | <Rika> lines.mapIt(parseInt(calculate(it)).sum or so |
11:01:05 | FromDiscord | <Rika> Is lines not a filled array |
11:01:19 | FromDiscord | <Solitude> toSeq(lines("1.txt")).foldr(a+b.parseInt, 0) |
11:01:29 | FromDiscord | <Rika> In reply to @Solitude "toSeq(lines("1.txt")).foldr(a+b.parseInt, 0)": True |
11:01:35 | FromDiscord | <valerga> yeah lines is, I thought about the calculate items |
11:01:37 | FromDiscord | <Rika> Do your parse and calculate on b in that case |
11:01:45 | FromDiscord | <valerga> i'll try that |
11:03:07 | FromDiscord | <valerga> sent a code paste, see https://play.nim-lang.org/#ix=3HkS |
11:03:09 | FromDiscord | <valerga> also don't know what's missing there |
11:03:19 | FromDiscord | <valerga> "missing parameter: body" |
11:04:07 | FromDiscord | <Rika> I do not see an issue there |
11:04:31 | FromDiscord | <valerga> "Error: type mismatch: got <void>↵but expected one of: ↵macro collect(ini" |
11:05:13 | FromDiscord | <valerga> i imported std/sugar |
11:05:32 | FromDiscord | <Solitude> can you give selfcontained snippet? |
11:05:36 | FromDiscord | <Rika> Yeah I don’t think there’s an issue |
11:11:58 | FromDiscord | <Solitude> sent a code paste, see https://play.nim-lang.org/#ix=3Hli |
11:12:09 | FromDiscord | <valerga> im working on it, just a moment |
11:14:46 | * | jjido joined #nim |
11:15:15 | FromDiscord | <valerga> ok this weird |
11:15:16 | FromDiscord | <valerga> https://play.nim-lang.org/#ix=3Hll |
11:15:19 | FromDiscord | <valerga> it works there |
11:15:21 | FromDiscord | <valerga> but not locally |
11:15:30 | FromDiscord | <valerga> my compiler is 1.4.8 |
11:16:08 | FromDiscord | <valerga> if you select 1.4.8 in the playground it throws the error |
11:18:06 | FromDiscord | <valerga> so I guess i can just update the compiler |
11:18:15 | FromDiscord | <valerga> though my distro still has 1.4.8 in the repos |
11:41:26 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
11:42:29 | PMunch | Aha, collect on 1.4.8 only had the version with the init and body |
11:44:02 | FromDiscord | <valerga> oh, I checked the docs to see how collect worked, I guess it was updated recently |
11:44:58 | FromDiscord | <valerga> should have used `collect(newSeq):` |
11:57:47 | NimEventer | New thread by Freeflow: More nim newbie woes, this time echo fmt Possible AOC2021 spoiler, see https://forum.nim-lang.org/t/8692 |
12:03:45 | FromDiscord | <valerga> sent a code paste, see https://play.nim-lang.org/#ix=3Hlx |
12:03:53 | FromDiscord | <valerga> how could I do that, break, but return the previous value? |
12:04:06 | FromDiscord | <valerga> add k.intToStr |
12:04:49 | FromDiscord | <valerga> in the collect |
12:04:55 | FromDiscord | <Rika> So you only want one value? |
12:05:03 | FromDiscord | <valerga> no, because there are two fors |
12:05:25 | FromDiscord | <Rika> Don’t think it’s possible no |
12:06:02 | * | supakeen quit (Quit: WeeChat 3.3) |
12:06:32 | * | supakeen joined #nim |
12:16:19 | * | jjido joined #nim |
12:17:14 | PMunch | Updated the logo on the Nim subreddit, Snoo now has a crown! https://www.reddit.com/r/nim/ |
12:25:05 | FromDiscord | <satoro.tadziri> sent a code paste, see https://play.nim-lang.org/#ix=3HlB |
12:25:17 | FromDiscord | <satoro.tadziri> (edit) "https://play.nim-lang.org/#ix=3HlB" => "https://play.nim-lang.org/#ix=3HlC" |
12:31:39 | * | xet7 joined #nim |
12:31:44 | FromDiscord | <narimiran> In reply to @satoro.tadziri "Hi guys I": https://github.com/technicallyagd/unpack |
12:31:53 | FromDiscord | <narimiran> (edit) "https://github.com/technicallyagd/unpack" => "https://github.com/technicallyagd/unpack#rest-operator-for-unpacking-sequences" |
12:47:42 | * | oddish quit (Quit: nyaa~) |
13:01:08 | FromDiscord | <Solitude> sent a code paste, see https://play.nim-lang.org/#ix=3HlO |
13:16:15 | FromDiscord | <Zoom> Anyone uses supersnappy? It's kinda weird it's API is built around strings. How can I construct a `string` or a `seq[byte]` from raw parts? I have an `openArray` |
13:19:50 | * | src joined #nim |
13:25:39 | PMunch | Define raw parts |
13:26:26 | FromDiscord | <Zoom> I dunno, seq is magic \:D. Probably, a ptr, a len and capacity. |
13:27:34 | FromDiscord | <Zoom> I'm used to `from_raw_parts` in Rust, couldn't find anything like this in std. There constructors for openArrays, but not for seqs |
13:31:12 | PMunch | Well seqs are GC'd, which means that the memory they contain must be possible for the GC to free |
13:31:44 | PMunch | This typically means you need to copy data into the seq in order for it to work |
13:40:14 | FromDiscord | <Zoom> Well, that's weird to say the least. It means I can't compress without copying the source? |
13:40:56 | FromDiscord | <Zoom> @guzba\: could you help with this ☝️ |
13:42:54 | FromDiscord | <Rika> you can cast string to seq byte """safely""" |
13:43:22 | FromDiscord | <Solitude> he has openArray |
13:43:30 | FromDiscord | <Zoom> That's irrelevant and actually what supersnappy does for taking seqs (yep, not the other way!) |
13:44:09 | NimEventer | New thread by Archnim: Nim script file extension, see https://forum.nim-lang.org/t/8693 |
13:58:57 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
14:00:09 | * | jjido joined #nim |
14:00:52 | * | jjido quit (Client Quit) |
14:06:14 | * | Schnouki quit (Remote host closed the connection) |
14:06:35 | * | Schnouki joined #nim |
14:17:49 | FromDiscord | <dom96> PMunch: consider updating it for old.reddit.com as well |
14:18:15 | PMunch | I use old reddit and it is updated for me |
14:19:33 | PMunch | In fact it only shows up on old reddit |
14:19:47 | PMunch | New reddit seems to have some styling done to it already |
14:19:53 | FromDiscord | <dom96> huh, I don't see it |
14:20:01 | FromDiscord | <dom96> maybe I have custom reddit styles disabled |
14:20:30 | FromDiscord | <dom96> yeah, I do |
14:20:40 | FromDiscord | <dom96> looks good! Very subtle |
14:21:10 | PMunch | Thanks, that was the goal :) |
14:22:04 | FromDiscord | <valerga> i only use old.reddit |
14:57:04 | * | oddish joined #nim |
15:01:35 | * | PMunch quit (Quit: Leaving) |
15:13:31 | * | pro quit (Quit: WeeChat 3.3) |
15:54:23 | FromDiscord | <ni-max> Hey Nim's forum Mods will you please verify my account (`nimax`) |
16:00:34 | FromDiscord | <Vindaar> @ni-max you should be good now |
16:00:35 | NimEventer | New thread by Archnim: Improve forum, see https://forum.nim-lang.org/t/8694 |
16:19:10 | FromDiscord | <Professor Actual Factual> Currently writing my own allocaters and deallocators for a ptr object, is there a way to check memory safety at compile time? |
16:23:07 | FromDiscord | <dom96> nope, `ptr` is inherently unsafe |
16:29:15 | FromDiscord | <Vindaar> In reply to @dom96 "nope, `ptr` is inherently": well, it's more complicated than that:↵- if you use are willing to wrap the `ptr` thing in an object, you can clean up automatically using `=destroy`↵- you could maybe wrap it in some dummy object that makes use of some `static int` to track certain usages, but that will probably result in not-so-nice to write code in general↵and there's probably other things I'm not thinking of |
16:35:58 | FromDiscord | <Pralkarz> Is there sequence unpacking similar to Python in Nim? |
16:39:33 | FromDiscord | <Vindaar> sent a code paste, see https://play.nim-lang.org/#ix=3Hnl |
16:46:54 | * | arkurious joined #nim |
16:47:23 | FromDiscord | <Professor Actual Factual> Oh i know these things are unsafe, and obviously i dont expect GC.↵I was just wondering if there was a compile flag or something that would spit out warnings about detecting ptr objects that are not deallocated. Just a sanity check really. |
16:49:56 | FromDiscord | <Professor Actual Factual> In reply to @Pralkarz "Is there sequence unpacking": Sequences or arrays cant be unpacked in nim. Try looking into varargs to see if they fit your needs |
16:50:19 | FromDiscord | <Pralkarz> Will do, thanks! |
16:53:46 | * | PMunch joined #nim |
16:54:36 | FromDiscord | <Xzight> Hi so I am trying out Nim today and following the "Nim Basics" tutorial but I'm running into a problem. My terminal is telling me `The term 'nim' is not recognized` but I have double checked and it is in my Windows PATH and I also restarted my PC. Anyone else ran into this or have any ideas to fix it? |
16:56:01 | FromDiscord | <Xzight> It only works if I open Powershell as Administrator but its in my user PATH so I'm confused. |
16:57:21 | FromDiscord | <sdmcallister> How did you install Nim? |
16:58:05 | FromDiscord | <Xzight> I downloaded the zip and ran the `finish.exe` file |
17:00:59 | FromDiscord | <sdmcallister> Assuming 1.6 |
17:01:20 | FromDiscord | <Xzight> Yes |
17:01:58 | FromDiscord | <Xzight> VSC is also saying this https://media.discordapp.net/attachments/371759389889003532/918185643086053466/unknown.png |
17:02:53 | FromDiscord | <Xzight> This is in my PATH though https://media.discordapp.net/attachments/371759389889003532/918185875551174696/unknown.png |
17:03:42 | FromDiscord | <el__maco> do you see that if you open cmd.exe and say "path" |
17:04:46 | FromDiscord | <Xzight> no it's not there... |
17:04:58 | FromDiscord | <el__maco> then maybe its not in the path |
17:05:27 | FromDiscord | <Xzight> weird because the `finish` program is telling me it is...I think i'm going to try restarting again idk what else to do haha |
17:05:39 | FromDiscord | <Xzight> or maybe I will just use powershell as administrator since its working that way |
17:05:41 | FromDiscord | <sdmcallister> https://media.discordapp.net/attachments/371759389889003532/918186581012123668/unknown.png |
17:06:17 | FromDiscord | <Xzight> The yellow `Path` is the one I was clicked on for my screenshot |
17:07:07 | FromDiscord | <el__maco> you should have multiple paths in there 🤔 |
17:07:26 | FromDiscord | <Xzight> yeah I do I just didnt show the full thing because it has my name in it lol |
17:07:55 | FromDiscord | <Xzight> i have these there as well https://media.discordapp.net/attachments/371759389889003532/918187142562328656/unknown.png |
17:09:37 | FromDiscord | <sdmcallister> does it work in cmd.exe as admin? |
17:10:52 | FromDiscord | <Xzight> yeah I just tried it and I typed `path` as admin and it showed up |
17:10:54 | FromDiscord | <Xzight> so weird |
17:12:15 | FromDiscord | <el__maco> there's two panels in the environment variable dialog, you have "user variables" and "system variables". Both have "path" in them |
17:12:31 | FromDiscord | <Xzight> I'm looking at user |
17:12:35 | FromDiscord | <Xzight> Does it need to be in system instead? |
17:12:44 | FromDiscord | <el__maco> I think user should work |
17:13:07 | FromDiscord | <el__maco> ofc you could try the other one too |
17:13:29 | FromDiscord | <el__maco> maybe you have some weird permission thing going, though I don't know what that might be |
17:14:20 | FromDiscord | <sdmcallister> If your pc is a corporate one I could see that. I have some weird issues to from time to time |
17:14:29 | FromDiscord | <dom96> In reply to @Vindaar "well, it's more complicated": Those are ways that you can make `ptr` safer, but it doesn't change the fact that any use of `ptr` should be looked at with suspicion. Similar to how `unsafe` blocks are in Rust |
17:14:56 | FromDiscord | <dom96> Same for `addr` and `cast` and (probably a few others) |
17:15:07 | PMunch | Advent of Code, day 8 streaming live right now: https://www.twitch.tv/pmunche |
17:16:00 | FromDiscord | <Xzight> I guess it took 2 restarts lol problem solved though 😄 |
17:16:34 | FromDiscord | <Xzight> maybe its becaue my PC did some updates the first time so it didn't go through |
17:16:45 | FromDiscord | <Xzight> (edit) "becaue" => "because" |
17:16:48 | FromDiscord | <$(Scott)> Is there a plugin for Nim's syntax & LSP written in lua for neovim? |
17:17:05 | FromDiscord | <$(Scott)> (edit) "Is there a plugin for Nim's syntax ... &" added "hl" |
17:17:58 | FromDiscord | <Vindaar> In reply to @dom96 "Those are ways that": but that's a reductive way of looking at the problem. Every garbage collector uses something like alloc / dealloc under the hood. Does that mean the GC is unsafe? Of course not. So as long as you can build a thin abstraction around `ptr` you might be able to build something CT safe on top of it. One doesn't use raw `ptr` for fun after all |
17:32:16 | FromDiscord | <dom96> In reply to @Vindaar "but that's a reductive": No, it doesn't mean the GC is unsafe. It means its code can be considered "unsafe" though and as such should be audited carefully. |
17:34:50 | FromDiscord | <Vindaar> but that's a statement that's orthogonal to what @Professor Actual Factual asked |
17:38:14 | FromDiscord | <dom96> I interpreted it as "is there any way to check whether a `ptr` is safe at compile-time?" |
17:38:28 | FromDiscord | <dom96> To that I don't think my statement was orthogonal 🙂 |
17:39:58 | FromDiscord | <Vindaar> No, your initial statement wasn't. But it was too strict, because depending on the constraints you can build something around `ptr` that provides the benefits, but gives you CT safety. Of course, the code that implements this will fall under the category you mention, but that's not a useful piece of information if the end result gives you the opposite answer to what you said |
17:43:23 | FromDiscord | <dom96> Okay, well I guess we are misunderstanding each other a bit:↵↵ I thought you were disagreeing with me on `ptr` being inherently unsafe↵ You think that I am disagreeing with you that `ptr` can be wrapped to be made safe |
17:44:05 | arkanoid | PMunch: I've just found out 2 things: only the nim based vscode extension is not reading the .cache/nil folder, the javascript based does (https://github.com/saem/vscode-nim/issues/65). Second: I've found out the compiling two times solves the posix symbol issue (I've updated the issue) |
17:44:13 | FromDiscord | <dom96> If @Professor Actual Factual is looking for a way to wrap their use of `ptr` in an API that is safe then definitely your advice is welcome |
17:45:26 | FromDiscord | <Professor Actual Factual> I just want a flag or warning that pops up when im compiling that says hey you forgot to deallocate this object to avoid shooting myself in the foot. Lol sorry for the confusion |
17:46:26 | FromDiscord | <Vindaar> In reply to @dom96 "Okay, well I guess": yeah, I suppose |
17:46:53 | FromDiscord | <Vindaar> In reply to @Professor Actual Factual "I just want a": so yeah, the answer to that is, no there isn't. But depending on why you use `ptr` you may be able to build your own safety net |
17:47:26 | FromDiscord | <Professor Actual Factual> Ah ok ty everyone |
17:48:02 | FromDiscord | <Professor Actual Factual> Id really love to avoid using ptrs but sharing memory across threads is impossible in nim otherwise. |
17:48:31 | FromDiscord | <Professor Actual Factual> Oh well 🙃 |
17:49:10 | FromDiscord | <Yardanico> In reply to @Professor Actual Factual "Id really love to": but it is possible 🙂 |
17:49:23 | FromDiscord | <Yardanico> with arc/orc |
17:49:49 | FromDiscord | <Professor Actual Factual> What? I thought only boehm allowed for this..? |
17:50:02 | FromDiscord | <Yardanico> arc/orc have a shared heap too |
17:50:14 | FromDiscord | <Professor Actual Factual> Wow, that is good news to me |
17:51:29 | FromDiscord | <Professor Actual Factual> Thank you, i will look into this later tonight. Was banging my ahead against the wall for hours yesterday learning about nims isolated thread memory. I guess orc arc are awesome |
17:51:31 | FromDiscord | <Yardanico> see https://nim-lang.org/blog/2020/10/15/introduction-to-arc-orc-in-nim.html, https://nim-lang.org/blog/2020/12/08/introducing-orc.html, https://nim-lang.org/docs/destructors.html |
17:51:33 | FromDiscord | <dom96> arc/orc's shared heap is still `ptr`-based, no? |
17:51:56 | FromDiscord | <Yardanico> In reply to @dom96 "arc/orc's shared heap is": you can have a global GC'd object with arc/orc, but of course you need to be careful to avoid race conditions so you need to use locks if you want to write to it from multiple threads |
17:52:14 | FromDiscord | <Yardanico> because with --threads:on all memory in arc/orc is shared by default |
17:53:49 | FromDiscord | <dom96> It's way past time I play with this |
17:54:07 | FromDiscord | <dom96> I have a hunch that it's not that simple due to arc/orc not doing atomic ref-counts |
17:54:29 | FromDiscord | <Yardanico> for globals refcounts aren't really a problem |
17:55:01 | FromDiscord | <Yardanico> but you still need to do locks or something similar if you want to mutate the global variable from multiple threads |
17:55:26 | FromDiscord | <dom96> sure, but then you'd also have no problem with allocating shared memory yourself if it's global (since you don't have to worry about deallocating it) |
17:56:13 | FromDiscord | <Yardanico> yes, but using seqs or similar is still a bit better than using manually alloc'd memory :) |
17:56:41 | FromDiscord | <Yardanico> also there's https://github.com/nim-lang/threading |
17:57:08 | FromDiscord | <dom96> maybe a little bit, but then I'd be concerned about Nim's arc/orc decrementing/incrementing the ref count outside my lock implicitly |
17:57:32 | FromDiscord | <dom96> but I dunno, I'm effectively spreading FUD here, I need to try this out finally |
17:59:09 | * | stkrdknmibalz joined #nim |
18:05:32 | FromDiscord | <guzba> sent a long message, see http://ix.io/3HnH |
18:06:09 | FromDiscord | <guzba> (edit) "http://ix.io/3HnH" => "http://ix.io/3HnI" |
18:10:27 | FromDiscord | <Professor Actual Factual> sent a code paste, see https://play.nim-lang.org/#ix=3HnJ |
18:10:42 | FromDiscord | <Yardanico> uhh, i meant a global variable though |
18:10:43 | FromDiscord | <Yardanico> not a local one |
18:11:08 | FromDiscord | <Solitude> In reply to @guzba "currently supersnappy expects to": openarray is ptr + len. the point is with openarray user can pass any of the types mention or even view into them without copying. you literally arent sacrificiing anything. |
18:12:21 | FromDiscord | <Professor Actual Factual> (edit) "https://play.nim-lang.org/#ix=3HnJ" => "https://play.nim-lang.org/#ix=3HnK" |
18:22:32 | FromDiscord | <guzba> In reply to @Solitude "openarray is ptr +": sure, that looks true if im going to add ptr+len anyway. no harm in them wrapping it i guess. i'll still need to turn it back into ptr + len to hold it anywhere (eg bitstream in zippy) but supersnappy is simple enough to avoid that. |
18:28:25 | * | jjido joined #nim |
18:35:10 | * | PMunch quit (Quit: leaving) |
19:00:25 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
19:02:48 | * | u0_a185 quit (Ping timeout: 250 seconds) |
19:22:43 | * | jjido joined #nim |
19:28:30 | * | xet7 quit (Remote host closed the connection) |
19:29:32 | * | xet7 joined #nim |
19:30:23 | * | xet7 quit (Remote host closed the connection) |
19:52:49 | * | krux02 joined #nim |
19:58:22 | FromDiscord | <Michal58> What is the difference between `import math` and `import std/math`? I've always only used the former. |
20:03:40 | FromDiscord | <konsumlamm> they do the same, but the latter is preferred |
20:04:01 | FromDiscord | <konsumlamm> `std/` searches specifically in the stdlib |
20:04:29 | FromDiscord | <konsumlamm> if you had your own local module called `math`, it may conflict otherwise |
20:05:24 | FromDiscord | <konsumlamm> also some stdlib modules require the `std/` prefix (it may actually become mandatory for all stdlib modules in the future) |
20:12:49 | * | pch_ quit (Ping timeout: 265 seconds) |
20:15:48 | FromDiscord | <Michal58> ok, thanks |
20:17:59 | nrds | <Prestige99> PMunch if you're here, #nimdow should be bridged to libera if you want to just talk over the bridge |
20:25:51 | * | u0_a185 joined #nim |
20:27:14 | FromDiscord | <Sabena Sema> can you import std to make it search for all of them? |
20:28:14 | FromDiscord | <Sabena Sema> also: `using` is impossible to implement in the library without using term rewriting macros right? |
20:29:20 | * | pch joined #nim |
20:52:52 | * | u0_a185 quit (Ping timeout: 250 seconds) |
20:54:53 | * | nrds quit (Remote host closed the connection) |
20:56:08 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
21:33:40 | NimEventer | New thread by Kcvinu: What is 'block' in this code, see https://forum.nim-lang.org/t/8696 |
21:38:11 | * | vicfred joined #nim |
22:26:18 | * | u0_a185 joined #nim |
22:34:04 | * | jjido joined #nim |
22:37:43 | * | jjido quit (Client Quit) |
22:38:22 | FromDiscord | <ajusa> Anyone know how I can scrape a website behind Cloudflare? Using halonium but it doesn't seem to let me through to the actual website |
22:50:01 | FromDiscord | <dom96> I assume you're getting captcha challenges from Cloudflare? |
22:50:25 | FromDiscord | <dom96> or is there a different problem you're facing? |
22:56:34 | FromDiscord | <ajusa> Hm, there are a couple. I'm running this in headless chrome, but I still get a 503 error when it tries to do the redirect. I'm also trying to get it to print out the cloudflare challenge page using httpClient, but that doesn't work either (I get a 403 error, without the challenge body). |
22:57:05 | FromDiscord | <ajusa> So with httpclient I can't see the captcha, and with headless chrome via halonium, I think it solves the captcha but it doesn't proceed further. |
23:05:37 | FromDiscord | <ajusa> sent a code paste, see https://play.nim-lang.org/#ix=3Hr3 |
23:06:56 | FromDiscord | <ajusa> Ah I needed `print client.get(url).body()`, so that it wouldn't throw the exception while trying to read the body. Makes sense now |
23:08:22 | FromDiscord | <ajusa> Starting to think that nimpy + cloudscraper might be the best option for dealing with cloudflare, apparently they made a recent change that forced some other selenium solutions to stop working a few months ago. |
23:18:09 | * | nrds joined #nim |
23:53:52 | arkanoid | if I have an object type with just 1 field, is it always true that I can do unsafe cast from outside object type to inner type as basically is a struct with one field? |
23:55:12 | FromDiscord | <Elegantbeef> If it's an inherited object that might not be true due to type information added to the type |
23:56:36 | arkanoid | not inherited |
23:57:00 | FromDiscord | <Elegantbeef> Then yea should be fine |
23:57:10 | FromDiscord | <Elegantbeef> Is there a reason you're using an object here? |
23:58:54 | arkanoid | no, I'm just trying to study python C-API tweaking nimpy, I'm not a C programmer so yeah just hacking around |
23:59:08 | FromDiscord | <Elegantbeef> I mean Nim has distinct types |
23:59:09 | arkanoid | I should really edit nimpy files and export fields |
23:59:15 | FromDiscord | <Elegantbeef> So like `type NotInt = distinct int` |