<< 05-12-2023 >>

00:14:16FromDiscord<guttural666> i shouldn't have to compile with --threads:on anymore in Nim 2?
00:14:27FromDiscord<guttural666> (edit) "2?" => "2, right??"
00:14:31FromDiscord<guttural666> (edit) "right??" => "right?"
00:14:55*NunavuT quit (Killed (NickServ (GHOST command used by Nunavut_)))
00:14:58*NunavuT joined #nim
00:19:40*NunavuT quit (Killed (NickServ (GHOST command used by Nunavut_)))
00:19:43*NunavuT joined #nim
00:32:22FromDiscord<that_dude.> Is owned a keyword in nim? I see that I used that word as a var and I see some syntax highlighting showing it differently
01:02:20FromDiscord<ravinder387> if anybody know
01:03:03FromDiscord<ravinder387> sent a code paste, see https://paste.rs/v7rB9
01:03:12FromDiscord<ravinder387> why gcc -c not write here
01:03:18FromDiscord<ravinder387> sent a code paste, see https://paste.rs/MQJWA
01:03:43FromDiscord<ravinder387> sent a code paste, see https://paste.rs/VQbuW
01:03:49FromDiscord<guttural666> sent a long message, see https://paste.rs/ssD6H
01:04:23FromDiscord<ravinder387> sent a code paste, see https://paste.rs/0dRPh
01:04:59FromDiscord<ravinder387> sent a code paste, see https://paste.rs/ngKd5
01:08:55FromDiscord<ravinder387> sent a code paste, see https://paste.rs/W6vFe
01:10:17FromDiscord<Elegantbeef> `initDeque[string]` is a proc not a `Deque[string]`
01:10:21FromDiscord<Elegantbeef> you want `initDeque[string]()`
01:15:37FromDiscord<ravinder387> gcc -c not allowed multiple files .c
01:15:50FromDiscord<guttural666> hm okay, and how do I make the queue gc safe, so I can access/write to it from multiple threads?
01:16:03FromDiscord<Elegantbeef> You don't 😄
01:16:10FromDiscord<Elegantbeef> `{.cast(gcSafe).}`
01:18:24FromDiscord<guttural666> if I have a queue and somebody has to write to it and the scheduler has to read from it, that is my problem rn
01:18:34FromDiscord<bostonboston> is it still recommended to use the `{.guard: .}` pragma and `withLock` template
01:18:41FromDiscord<Elegantbeef> Yes
01:18:44FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/o351R
01:19:15FromDiscord<Elegantbeef> Though I'd say a `ptr (Deque[string, Lock)` makes more sense than a global variable
01:19:16FromDiscord<guttural666> (edit) "it," => "it (and pop the queue),"
01:19:27FromDiscord<Elegantbeef> Although I have no clue if deques explode when shared across thread
01:19:52FromDiscord<Elegantbeef> Isn't that global pragma redundant
01:20:04FromDiscord<Elegantbeef> It's not marked `{.threadVar.}`
01:20:24FromDiscord<bostonboston> probably, I copied it from another codebase of mine thats probably wrong
01:20:41FromDiscord<Elegantbeef> Global is for making variables inside of a procedure global
01:21:02FromDiscord<bostonboston> I knew it did that, suppose I thought it did more
01:21:28FromDiscord<bostonboston> sent a code paste, see https://paste.rs/VFIeA
01:22:02FromDiscord<guttural666> thanks, going to investigate that
01:22:20FromDiscord<bostonboston> `{.threadVar.}` makes a copy not a reference yeah?
01:23:25FromDiscord<Elegantbeef> It makes each thread have it's own variable
01:23:28FromDiscord<Elegantbeef> So it's thread local
01:23:33FromDiscord<Elegantbeef> Without it it's global
01:23:58FromDiscord<bostonboston> ah
01:58:31*azimut quit (Ping timeout: 240 seconds)
02:21:47nmzIs the documentation in a pdf?
02:29:16*NunavuT quit (Remote host closed the connection)
02:33:21nmzoh, the html is in the package, sorry
03:10:25FromDiscord<bostonboston> what is `owned` used for, not many docs on it
03:13:08FromDiscord<Elegantbeef> It's a deprecated idea that was meant to indicate ownership
03:13:16FromDiscord<Elegantbeef> move semantics and `isolated` I think mostly replaced it
03:14:36FromDiscord<stoneface86> was wondering what that was, std/streams still uses it
03:18:00FromDiscord<bostonboston> how do `lent` and `sink` fit in to that
03:18:06FromDiscord<bostonboston> if at all
03:20:38FromDiscord<Elegantbeef> Well `owned` was the first pass at ARC really inside of the "newRuntime"
03:20:57FromDiscord<Elegantbeef> https://github.com/nim-lang/RFCs/issues/144
03:21:19FromDiscord<Elegantbeef> Owned has turned into isolated afaik
03:21:23FromDiscord<Elegantbeef> Atleast in some part
03:23:26FromDiscord<Elegantbeef> Actually that's not really true cause `owned` was meant to allow you to share resources across threads but only have one side actually own it
03:30:45*def- quit (Quit: -)
03:35:04*def- joined #nim
05:55:52*sagax joined #nim
06:15:00*rockcavera quit (Remote host closed the connection)
06:15:25*disso_pch quit (Ping timeout: 256 seconds)
06:19:30*azimut joined #nim
06:22:06*disso-peach joined #nim
06:50:33*advesperacit joined #nim
07:16:15*azimut quit (Remote host closed the connection)
07:16:35*azimut joined #nim
07:23:47FromDiscord<JJ> curious as to if anyone sees why this doesn't compile? nim is complaining about a type mismatch at the call of `consumes`
07:24:14FromDiscord<Elegantbeef> `func head: T` is just 100% wrong
07:24:21FromDiscord<Elegantbeef> Ah nvm newstyle concept
07:24:50*kenran joined #nim
07:24:51FromDiscord<Elegantbeef> you do not have a `proc head: char`
07:24:53FromDiscord<JJ> yeah "concepts". i really with they were properly called interfaces
07:25:05FromDiscord<Elegantbeef> They're not interfaces though
07:25:27FromDiscord<JJ> sure they are! in so far as interfaces is a quite underdefined word
07:25:31FromDiscord<Elegantbeef> So why would they be called that
07:25:34FromDiscord<JJ> sent a code paste, see https://paste.rs/e4Pqp
07:25:58FromDiscord<JJ> i mean they've got implicit implementations, but when i think of describing a type by its behavior, i think of the term "interface"
07:26:01FromDiscord<Elegantbeef> When most people here interfaces they will imagine the most popular implementations of them such as Go, C#, Java!
07:26:03FromDiscord<Elegantbeef> hear\
07:26:09FromDiscord<Elegantbeef> Anywho that's neither here nor there
07:26:32FromDiscord<Elegantbeef> Your concept has a `func head: T` but you do not have the corresponding `func head: char`
07:26:48FromDiscord<JJ> In reply to @Elegantbeef "When most people here": simple solution: nim stabilizes them, their raw appeal leads to a meteoric rise in popularity, java is forced to change the name of their interfaces due to confusion
07:27:17FromDiscord<JJ> In reply to @Elegantbeef "Your concept has a": isn't my `func head[T](stream: StreamImpl[T]): T` this?
07:27:23FromDiscord<Elegantbeef> No
07:27:31FromDiscord<Elegantbeef> that'd be `func head(_: Self): Self`
07:27:50FromDiscord<Elegantbeef> It does not intuit the first parameter is `Self` as that's dumb
07:28:20FromDiscord<Elegantbeef> sorry that return type would be `T`
07:28:36FromDiscord<JJ> In reply to @Elegantbeef "that'd be `func head(_:": oh 🤦
07:28:48FromDiscord<Elegantbeef> That still does not resolve it though
07:29:04FromDiscord<Elegantbeef> Probably cause new style concepts are faulty
07:29:06FromDiscord<JJ> hm wait i'm still getting the same error
07:29:08FromDiscord<JJ> yea
07:29:10FromDiscord<JJ> ah rip
07:30:03FromDiscord<Elegantbeef> I dislike new styled concepts, they're quite limited in their present design and have so many issues
07:30:44FromDiscord<JJ> i dunno. i think new style concepts could be really good if the standard library used them extensively
07:30:52FromDiscord<JJ> kind of like rust traits, but implicitly implemented
07:31:09FromDiscord<Elegantbeef> I mean sure, if new style worked
07:31:14FromDiscord<JJ> i do not like that they are broken however 😠
07:31:15FromDiscord<JJ> lmao yeah
07:31:17FromDiscord<Elegantbeef> Old style concepts work better(Somehow that's possible)
07:31:39FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/8Gx5Z
07:33:26FromDiscord<Elegantbeef> You can of course make an issue if you want to
07:33:36FromDiscord<JJ> hmm, what'd you change? i cannot spot the difference
07:33:46FromDiscord<JJ> aside from the Self parameters
07:33:46FromDiscord<Elegantbeef> I removed the generic on the `StreamImpl`
07:33:59FromDiscord<JJ> ah interesting
07:34:12FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/CkMxB
07:34:36FromDiscord<JJ> yeah i might. weird behavior
07:35:24FromDiscord<Elegantbeef> In closing use old style concepts
07:35:28FromDiscord<Elegantbeef> They're more reliable and just better imo
07:35:58FromDiscord<graveflo> did `stmt` used to be a keyword? does it mean `untyped` now?
07:36:06FromDiscord<Elegantbeef> Yes
07:36:09FromDiscord<graveflo> ty
07:36:14FromDiscord<Elegantbeef> Think it was `stmt -> untyped` `expr -> typed`
07:36:23FromDiscord<Elegantbeef> Might be wrong
07:36:31FromDiscord<graveflo> seems to check out
07:38:44FromDiscord<Elegantbeef> Oh shit JJ I know what it is now
07:38:51FromDiscord<Elegantbeef> It's the fucking type alias probably
07:39:15FromDiscord<Elegantbeef> Yea
07:39:25FromDiscord<Elegantbeef> Generic type aliases are awful in the present type graph
07:41:22FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/V1Nni
07:41:46FromDiscord<JJ> In reply to @Elegantbeef "It's the fucking type": wtf?? that's uh
07:41:54FromDiscord<JJ> really terrifying actually
07:42:16FromDiscord<Elegantbeef> You've clearly never looked at how PType works
07:42:18FromDiscord<Elegantbeef> Or supposedly works
07:42:39FromDiscord<Elegantbeef> I'm just hopeful that https://github.com/nim-lang/Nim/pull/23023 makes it work
07:43:19FromDiscord<Elegantbeef> There are quite a lot of generic related things that the present type graph do not correctly handle
07:45:04FromDiscord<Elegantbeef> Luckily if you add a field to `B` that uses the generic parameter this goes away
07:45:18FromDiscord<Elegantbeef> So it's not an issue unless you want to attach type information to a reference
07:46:37FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/aCTif
07:55:07*PMunch joined #nim
07:59:44*disso_pch joined #nim
08:02:34*disso-peach quit (Ping timeout: 256 seconds)
09:33:32FromDiscord<odexine> Type atrocities
09:34:35FromDiscord<Elegantbeef> The `of` checking works on the instantiated bodies, so since they're the same in the first case they're the same type
09:34:37FromDiscord<JJ> oh thank god. this now alleviates all my concerns.
09:34:49FromDiscord<JJ> (it does not)
09:34:58FromDiscord<JJ> sent a code paste, see https://paste.rs/1Ag6T
09:35:26FromDiscord<Elegantbeef> I did look into fixing this and it's quite a annoying thing 😄
09:35:54FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/zNxRE
09:36:17FromDiscord<Elegantbeef> https://github.com/nim-lang/Nim/blob/202e21daba1424762cf330effb52220c6f1d5772/compiler/types.nim#L1364-L1386 the issue resides inside here
09:36:56FromDiscord<Elegantbeef> `skipPtrs` causes it to skip over the type to find the parent type since they have the same bodies they're the same
09:39:28FromDiscord<Elegantbeef> Oh also JJ you should make `std/streams` using concepts, thanks
09:47:24FromDiscord<JJ> ha oh no
09:47:48FromDiscord<JJ> well actually uh, that might be a better implementation than whatever this is?? https://github.com/nim-lang/Nim/blob/version-2-0/lib/pure/streams.nim#L111
09:47:54FromDiscord<JJ> (edit) "https://github.com/nim-lang/Nim/blob/version-2-0/lib/pure/streams.nim#L111" => "↵https://github.com/nim-lang/Nim/blob/version-2-0/lib/pure/streams.nim#L111"
09:48:50FromDiscord<JJ> i see that `StreamObj = ref object of RootObj` pattern a lot and have never liked how it feels on my eyes
09:50:49FromDiscord<nnsee> "feels on the eyes"? isn't that "looks"? lmao
10:10:39FromDiscord<shoujouy> Is there a way to get user input without blocking terminal? getch doesnt satisfy me because of blocking
10:16:55FromDiscord<odexine> Not with windows IIRC
10:17:05FromDiscord<odexine> Rather, not with windows and single threading
10:17:06FromDiscord<shoujouy> I use linux
10:30:05PMunchIn Linux it should be fairly easy
10:30:20PMunchI think there is an asyncpipe module out there somewhere
10:30:24PMunchNimLSP uses it IIRC
10:38:14FromDiscord<shoujouy> working on it
11:20:51FromDiscord<alireza0x0> why it is not possilbe to cast a pointer to uncheckedarray[char] ...?↵did i misunderstand something about unchecked arrays?
11:21:04*disso_pch quit (Quit: Leaving)
11:23:43FromDiscord<nnsee> arrays are not pointers in nim
11:25:22PMunchYou can cast a pointer to `ptr UncheckedArray[char]` or to `UncheckedArray[ptr char]`
11:25:44PMunchUnchecked arrays are the actual memory, not the pointer to it
11:27:14FromDiscord<odexine> You said in internals “yes but, ptr unchecked array is a char
11:27:16FromDiscord<odexine> No it is not
11:27:29FromDiscord<odexine> UncheckedArray does not signify a pointer
11:28:08FromDiscord<odexine> If you think of it this way, unchecked array signifies that there is contiguous memory of type T
11:28:31FromDiscord<odexine> So a pointer to an unchecked array of characters is conceptually what char is
11:30:10FromDiscord<odexine> So an unchecked array is quite literally what it says it is, an unchecked array; just like how arrays in Nim (the one with the size in its type this time) aren’t pointers, they’re whole contiguous portions of memory
11:34:04FromDiscord<Phil> When you write "whole contiguous portions of memory", do you mean "That's memory in stack"?
11:34:15FromDiscord<odexine> No
11:34:22FromDiscord<odexine> I mean nothing about stack heap or whatever
11:34:23FromDiscord<Phil> I doN't do much with arrays so I legit don't know
11:34:40FromDiscord<odexine> It could be in stack or heap
11:40:10FromDiscord<odexine> In reply to @isofruit "When you write "whole": An array is not necessarily stack naturally because anything stored in a containing data type that is heap allocated is automatically also in the heap (with even further exceptions)
11:40:20FromDiscord<Phil> So my underlying understanding so far of ↵array => stack (its members may be in heap but the array itself is stack)↵ref/ptr array => heap↵Is wrong ?
11:40:43FromDiscord<odexine> Where would a global array be stored in memory?
11:41:33FromDiscord<Phil> .... on the stack ? (Like legit question mark, my understanding so far was that stack but now I no longer know)
11:41:38FromDiscord<odexine> In reply to @isofruit "So my underlying understanding": It’s mostly right but again exceptions are difficult
11:41:50FromDiscord<odexine> In reply to @isofruit ".... on the stack": There’s no stack if there’s no function no?
11:42:34FromDiscord<Phil> There isn't? I mean "global scope" is all stuff inside of nim's nim-main function that gets generated, no?
11:42:39FromDiscord<odexine> In the case of globals it’s neither stack nor heap
11:44:03FromDiscord<odexine> In reply to @isofruit "There isn't? I mean": Not necessarily? I’m not too sure about it but I believe in some situations when globals are accessed by all sorts of procedures and statements they’re generated as a C-style global
11:45:12FromDiscord<Phil> So nim codegen implementation details aside, a "true global" would be stored in what, memory for instructions (forgot the name for it) ?
11:46:32FromDiscord<odexine> No there’s a section in the program called a data section and that’s where it gets stored
11:47:18FromDiscord<Phil> So there's stack memory. heap memory. instruction... whatever. And data section... memory (?).
11:47:35FromDiscord<odexine> Pretty much
11:47:58FromDiscord<Phil> Given that 1 year ago the amounts of memory I knew of was half that I'd say, strong learning curve of 100% since then!
11:49:18FromDiscord<Phil> People need to start inventing more memory types for me to keep it up!
11:50:25FromDiscord<odexine> In reply to @isofruit "So my underlying understanding": If you want a more solid rule, basically as long as all container types of the array (or in fact any value type) are stack, then its stack, but as soon as one container type is a reference or a heap allocated pointer, then it’s heap
11:50:47FromDiscord<odexine> In reply to @isofruit "People need to start": GCs have further subdivisions for garbage management
11:51:05FromDiscord<Phil> In reply to @odexine "GCs have further subdivisions": Fuck my life ☠️
11:51:08PMunchDoesn't the data section of the executable get loaded onto the stack or heap before execution begins?
11:51:15FromDiscord<odexine> Does it?
11:51:25FromDiscord<odexine> I was under the impression that it’s its own section
11:52:06FromDiscord<exelotl> In reply to @isofruit "People need to start": u gotta go to specific platforms next :P↵GBA has IWRAM, EWRAM, VRAM, PAL RAM, OAM, SRAM, ROM, ...
11:52:26FromDiscord<Phil> So what I'm learning
11:52:46FromDiscord<Phil> Is that after I just barely crawled out of the rabbit hole that is "threads treated as servers for app development"
11:52:52FromDiscord<Phil> Well, still in the process more like
11:53:03PMunchAh, you appear to be right odexine, the data section is indeed allocated under the heap: https://upload.wikimedia.org/wikipedia/commons/5/50/Program_memory_layout.pdf
11:53:10FromDiscord<Phil> There's yet another rabbit hole waiting called "Memory types" in order to kill me
11:53:39PMunchIn general you don't really have to ever think about it
11:53:51PMunchThe stack/heap distinction is by far the most useful one to keep in mind
11:54:19PMunchtext/data/bss just gets allocated (and potentially populated) when your program starts and will stick around until it quits.
11:54:32FromDiscord<Phil> bss?
11:54:35FromDiscord<odexine> By the way I’m Rika if you’ve forgotten
11:54:41PMunchBullShit Stuff
11:54:50PMunchI remember :)
11:55:44PMunchPhil, have a look here: https://en.wikipedia.org/wiki/Data_segment
11:56:15FromDiscord<odexine> In reply to @PMunch "Ah, you appear to": I assume it depends on the architecture
11:56:29FromDiscord<Phil> I have spent legit like 2 years now exposing myself to lower level concepts, how am I still getting left fielded on fundamental stuff, ahhhhh 🤣
11:56:42FromDiscord<odexine> In reply to @isofruit "I have spent legit": You probably need a good book or something
11:57:35PMunchBasically an executable contains a couple sections. Obviously the code that should be run, but also "initialized globals" which it just copies into memory, then it also has a "uninitialized globals" section which is basically just a way to say that some memory should be allocated, but without having to pad the executable with a bunch of zeros. Then you have your stack and heap which grows towards each other.
11:59:38FromDiscord<odexine> I keep on forgetting what BSS stands for
11:59:49FromDiscord<odexine> bullshit stack
12:02:26PMunchApparently it's block starting symbol
12:03:16PMunchNot sure I understand why though..
12:19:19FromDiscord<9ih> how do you mofos parse an int64 from a string
12:20:23FromDiscord<9ih> nvm the int is 64 bits
12:20:27FromDiscord<9ih> apparently
12:22:36FromDiscord<nnsee> sent a long message, see https://paste.rs/HC7c6
12:22:44FromDiscord<odexine> Darned Fortran
12:31:54PMunch9ih, int is the same size as a pointer
12:32:03PMunchSo on 64-bit machines it's 64 bits
12:32:09PMunchOn 32 bit machines it's 32 bits
12:32:26PMunchAnd on microcontrollers and such it's not uncommon to find it be 16 bits.
12:33:33PMunchYou can use parseBiggestInt which parses the biggest integer Nim supports, which is int64
13:18:00FromDiscord<cy_tek> sent a code paste, see https://paste.rs/OyG4h
13:18:10FromDiscord<nnsee> just to test, does the error go away when you create a git commit?
13:18:39FromDiscord<nnsee> ie `git add -A && git commit -m "initial commit"`
13:19:23FromDiscord<nnsee> it looks like your project might be a git project with no commits and nimble doesn't like that
13:20:06FromDiscord<nnsee> `nimble run` tries to resolve and install dependencies before running and apparently parses the project's own dir during that? no clue why
13:21:06FromDiscord<cy_tek> In reply to @nnsee "just to test, does": Yes, it does go away after I make a git commit, but it did that even without a `.git` directory, so it was before it was even a git project which is what I found so strange. Thank you so much though, I super appreciate the help, and now I'll know why it's failing lol 🙂
13:21:20FromDiscord<nnsee> `/Users` - this is a mac, right?
13:21:27FromDiscord<cy_tek> In reply to @nnsee "`/Users` - this is": Yup 🙂
13:21:33FromDiscord<spotlightkid> the warning from `nimble --version` is probably because nimble itself was not installed from git.
13:22:00FromDiscord<nnsee> In reply to @cy_tek "Yup 🙂": apparently this is a known issue on macs, https://stackoverflow.com/questions/12267912/git-error-fatal-ambiguous-argument-head-unknown-revision-or-path-not-in-the for more context
13:22:46FromDiscord<nnsee> or maybe it's not related to mac at all, and that's just what the OP was using at the time
13:23:17FromDiscord<nnsee> In reply to @cy_tek "Yes, it does go": that is strange
13:24:19FromDiscord<nnsee> although for what it's worth, i just tested on linux and i can't seem to be able to reproduce this
13:24:32FromDiscord<nnsee> either with no `.git` or a `.git` with no commits
13:25:10FromDiscord<nnsee> oh, wait, scractch that
13:25:48FromDiscord<nnsee> it works fine for me with no `.git` directory, but it gives the same error when i init a new `.git` with no commits
13:25:55FromDiscord<nnsee> sorry for the wrong information haha
13:26:34FromDiscord<cy_tek> In reply to @nnsee "sorry for the wrong": No worries haha, I do wonder though what the difference is that causes it to fail like in the message I sent above where I go and remove the `.git` folder and it still errors out 😦
13:26:51FromDiscord<nnsee> hm
13:27:11FromDiscord<nnsee> in `nim_test`, if you've removed the `.git` directory, does `git status` there show anything?
13:27:16FromDiscord<cy_tek> sent a code paste, see https://paste.rs/0dY8v
13:27:26FromDiscord<nnsee> maybe you've accidentally init'd a new repo in one of the upper directories
13:29:02FromDiscord<cy_tek> In reply to @nnsee "maybe you've accidentally init'd": Thank you thank you thank you! Yes... that was exactly what the problem was lol 😅 Somehow I had accidentally inited a git directory into my home dir 😲
13:29:38FromDiscord<cy_tek> I never would have thought of that haha, so yeah, thanks, that completely fixes the issue for me 🙂
13:29:49FromDiscord<nnsee> great! happens to the best of us lol
13:30:38FromDiscord<nnsee> that `status` listing must've been massive
13:31:36FromDiscord<cy_tek> In reply to @nnsee "that `status` listing must've": Yeah....it was insane lol 😂
13:44:42*rockcavera joined #nim
13:48:54*Guest91 joined #nim
13:49:54Guest91Hey guys, is it possible to index into a slice? Say I got let f = 50 .. 100, it seems I can't do f[10] to get the 11th element of the slice?
13:53:08*Guest91 quit (Client Quit)
13:55:53PMunchNot by default, but you can implement the index operator quite easily
13:56:25*Guest91 joined #nim
13:56:42Guest91I got
13:56:43Guest91```
13:56:43Guest91proc nth(slice: HSlice[int, int], needle: int): int =
13:56:44Guest91  for idx, n in enumerate(slice):
13:56:44Guest91    if needle == idx:
13:56:45Guest91      return n
13:56:45Guest91```
13:56:46Guest91but not sure it can be more efficient?
13:56:56PMunchPlease don't paste code into IRC..
13:57:01PMunchUse a paste service of some kind
13:57:16Guest91Sorry!
13:57:26PMunchUhm, that's quite inefficient
13:57:31FromDiscord<nnsee> just add the needle to the hslice's `a` (lower bound)
13:57:49PMunchTry template `[]`(x: HSlice, y: int): untyped = x.a + y
13:58:28Guest91Yup I'm an idiot. Thanks 🙏
13:58:32PMunchAlternatively throw an `assert x.b - x.a >= y` in there to check the range
13:59:00FromDiscord<nnsee> probably _optionally_, not _alternatively_
13:59:13PMunchIndeed!
14:00:52PMunchHmm, ix.io is still down..
14:00:58Guest91Makes sense, thanks guys!
14:01:02*Guest91 quit (Client Quit)
14:40:07*azimut quit (Ping timeout: 240 seconds)
14:40:58*azimut joined #nim
14:42:33*rockcavera quit (Remote host closed the connection)
14:47:24*DimensionalX joined #nim
14:47:31*DimensionalX left #nim (#nim)
14:55:19*azimut quit (Ping timeout: 240 seconds)
15:06:38*azimut joined #nim
15:06:42*kenran quit (Remote host closed the connection)
15:21:22*jmdaemon quit (Ping timeout: 260 seconds)
15:25:14*PMunch quit (Quit: Leaving)
16:08:29*disso-peach joined #nim
16:44:31FromDiscord<ntzeno> Hello folks, if I want everything in one file to be exported, do I have to manually add `` to everything, or is there something that exports everything in file ?
16:44:47FromDiscord<ntzeno> (edit) "Hello folks, if I want everything in one file to be exported, do I have to manually add `` to everything, or is there something that exports everything in file ... ?" added "without me manually adding `` to everything"
16:57:31FromDiscord<nnsee> In reply to @ntzeno "Hello folks, if I": last time I asked this was a few years ago and the answer was "no"
16:57:35FromDiscord<nnsee> but maybe something has changed recently
16:57:46FromDiscord<nnsee> ah, the answer i got was "you can probably write a macro for it"
16:57:55FromDiscord<Chronos [She/Her]> In reply to @ntzeno "Hello folks, if I": Yeah, you have to manually export it all
16:58:04FromDiscord<Chronos [She/Her]> In reply to @nnsee "ah, the answer i": Was about to say that too :p
16:59:40*sagax quit (Quit: Konversation terminated!)
17:00:21FromDiscord<ntzeno> In reply to @nnsee "ah, the answer i": Sad, I don't really want to bother with macros
17:00:28FromDiscord<ntzeno> I'll just export manually anyways, ty @Chronos [She/Her] @nnsee
17:22:29*rockcavera joined #nim
17:53:08*eery joined #nim
18:02:00eerySo std/parsecfg has some behavior I think is a bug - values with embedded quotation marks get triple quoted _and_ escaped, so writing/reading back replace newlines with escaped newline literals, but only for values with quotes inside
18:02:25eeryI have a patch for it but this would change the runtime behavior
18:55:40FromDiscord<apetransaction> sent a code paste, see https://paste.rs/MtEX1
18:57:59FromDiscord<apetransaction> (edit) "https://paste.rs/C6JTM" => "https://paste.rs/f9Tms"
19:18:38FromDiscord<bostonboston> You can write a 'wrapper' function
19:19:20FromDiscord<dissolved.girl> Let's imagine that the proc has a case statement that handles all possible Opcode values (and doesn't have a default case). What should happen when you pass an arbitrary value or modify the enum itself? Suddenly, not all cases are covered.
19:31:58*jkl quit (Quit: Gone.)
19:33:35*jkl joined #nim
19:39:23FromDiscord<srabb> is nim a registered trademark
19:46:53FromDiscord<systemonia> there's nothing on the website, plus no relevant results returned when I searched it in tmsearch.uspto.gov or euipo.europa.eu so I assume no.
19:54:14*jmdaemon joined #nim
20:10:34FromDiscord<kaddkaka> Suddenly my nimlsp says "In orde to get the IDE features working you must either configure nim.p↵rojectMapping or import the module."
20:11:00FromDiscord<kaddkaka> Suddenly as in "I just restarted my editor"
20:15:03FromDiscord<kaddkaka> sent a code paste, see https://paste.rs/qaLxx
20:21:34FromDiscord<JJ> lsp in general is very weird with wanting a "project root" of sorts. try opening the containing folder in your ide, and then opening each of the two files.
20:23:14FromDiscord<kaddkaka> I'm in the folder when I alarm neovim, so the cwd is the folder with the two files
20:23:32FromDiscord<JJ> since nim does not have ex. a cargo.lock the language server has to make a best guess of where the "project" is, and the best guess is occasionally wrong
20:23:48FromDiscord<JJ> hm
20:23:54FromDiscord<kaddkaka> I only get the message when day5_2.nim, but not even opening day5.nim
20:24:17FromDiscord<JJ> if you open day5_2.nim first do you still get the message in it?
20:24:20FromDiscord<kaddkaka> (edit) "I only get the message when ... day5_2.nim,when" added "opening" | "even" => "when"
20:24:24FromDiscord<kaddkaka> Yes
20:24:43FromDiscord<kaddkaka> So I'm guessing some kind of caching ?
20:24:51FromDiscord<JJ> that's very strange. do you have any files related to nimble in the directory?
20:25:00FromDiscord<JJ> maybe? i've got no idea, honestly
20:25:24FromDiscord<kaddkaka> Nope, the 2 nim files are the only files there
20:25:58FromDiscord<JJ> hm yeah that sounds like something weird with caching then
20:26:46FromDiscord<JJ> my only other suggestion would be to kill all nimsuggest/nimlangserver processes, they can get orphaned pretty frequently (though i wouldn't think it would affect the editor??)
20:31:48FromDiscord<kaddkaka> Ooh, I have a lot of nim suggest processes running/sleeping!
20:32:38FromDiscord<kaddkaka> Hmm
20:32:48FromDiscord<kaddkaka> Still same messages after killing all of them
20:33:13FromDiscord<kaddkaka> And nimsuggest is still running after closing neovim 😬
20:33:41FromDiscord<kaddkaka> I guess no shutdown command is sent over lsp protocol
20:37:23FromDiscord<kaddkaka> In reply to @kaddkaka "Still same messages after": so even if neovim is bad at closing down, nimsuggest still seems weak at understanding two separate files in same folder. (there is no relative import or so, they are both standalone scripts)
20:45:14FromDiscord<alireza0x0> guys, i want to write a destructor for my ref obj
20:45:39FromDiscord<alireza0x0> i mean sink not des
20:46:12FromDiscord<alireza0x0> is this the right way?
20:48:11FromDiscord<alireza0x0> sent a code paste, see https://paste.rs/ewqo2
20:49:06FromDiscord<alireza0x0> this was working but now i have a problem that says you cannot get len of a seq elemnt in the myrefobj() because type of b.myseq is typedesc[seq[int]] not a seq[int] ...
20:50:59FromDiscord<alireza0x0> ahh my bad i used = instead of : in object creation 🤣 🤣 sorry
20:53:28FromDiscord<kaddkaka> Hmm, is there a sum type in Nim?
20:54:14FromDiscord<alireza0x0> sum type...? like big int you mean?
20:54:16FromDiscord<kaddkaka> I want a list of values that are either a boolean or an integer (`bool | int`)
20:54:43FromDiscord<fwsgonzo> is there a Nim HTTP client that uses custom DNS? the std client uses glibc NSS which requires dlopen
20:54:56FromDiscord<alireza0x0> i think you should create something like union or in nim they say object variant afaik
20:55:15FromDiscord<fwsgonzo> (edit) "dlopen" => "dlopen. Or is it perhaps possible to override the name resolution?"
20:55:50FromDiscord<kaddkaka> right, found variants, thats it I guess
20:56:32FromDiscord<alireza0x0> In reply to @fwsgonzo "is there a Nim": you should take a look at chronos http client, it had much more abilitys than the std one as far as i know
20:56:51FromDiscord<alireza0x0> and also there is a lib called puppy that dose the http request with 0 dependencys, dlls, etc..
20:58:09FromDiscord<kaddkaka> The example in the manual is extremely short https://nim-lang.org/docs/tut2.html#object-oriented-programming-object-variants↵Is there any more meaty example?
20:58:18FromDiscord<kaddkaka> (edit) "more meaty" => "simpler"
20:58:47FromDiscord<alireza0x0> In reply to @kaddkaka "The example in the": https://ssalewski.de/nimprogramming.html#_object_variants
20:58:47FromDiscord<kaddkaka> (edit) "short" => "frugal"
20:59:10FromDiscord<alireza0x0> also this is a full complete and up to date book, helped me alot to start using nim
21:01:56FromDiscord<fwsgonzo> puppy seems not to be installable, missing dependency: webby >= 0.1.6
21:02:32FromDiscord<alireza0x0> did you run nimble install on it?
21:03:01FromDiscord<fwsgonzo> ah, i needed to update the nimble package cache
21:03:04FromDiscord<fwsgonzo> my bad!
21:05:24FromDiscord<kaddkaka> this object variant seems really hard to use compare to just sumtype T_T
21:05:38FromDiscord<kaddkaka> But I probably just dont get it yet
21:11:51FromDiscord<kaddkaka> sent a code paste, see https://paste.rs/bJvvw
21:22:50FromDiscord<Elegantbeef> It's practically the exact same you just have to be a tinge more explicit @kaddkaka
21:23:01FromDiscord<Elegantbeef> https://github.com/alaviss/union or anonymous unions
21:23:11FromDiscord<Elegantbeef> As an aside depending on definition Object variants are sumtypes
21:23:45FromDiscord<kaddkaka> thanks
21:26:29FromDiscord<kaddkaka> I'm not sure what to call A and B and avoid name conflicts (in the example above) any pointers @ElegantBeef ?
21:26:58FromDiscord<Elegantbeef> What do you mean "avoid name conflicts"?
21:27:42FromDiscord<kaddkaka> I have a type that is the OnOff type, but I would like to call A OnOff as well, perhaps that is OnOffActionKind?
21:28:05FromDiscord<Elegantbeef> `OnOffKind` works
21:28:33FromDiscord<kaddkaka> could I reuse OnOddKine if I make a another object with an OnOff variant?
21:28:44FromDiscord<kaddkaka> (edit) "OnOddKine" => "OnOddKind" | "OnOff" => "OnOffKind"
21:28:54FromDiscord<Elegantbeef> It's just an enum you can use it N number of times
21:29:28FromDiscord<kaddkaka> (Oh, maybe I shouldn't mix `kind` and `variant`?)
21:30:09FromDiscord<Elegantbeef> https://nim-lang.org/docs/manual.html#guards-and-locks
21:31:48FromDiscord<guttural666> sent a long message, see https://paste.rs/kzAKR
21:31:57FromDiscord<Elegantbeef> Sure
21:32:10FromDiscord<Elegantbeef> Though I imagine you mean "FancyActionKind"
21:32:20FromDiscord<kaddkaka> oh, yes
21:32:34FromDiscord<kaddkaka> (edit) "oh, yes ... " added "(fixed)"
21:33:19FromDiscord<kaddkaka> so everytime I create a variant object, I have to explicitly specify what kind it is
21:33:33FromDiscord<kaddkaka> similar to union tagging in C it feels like
21:33:36FromDiscord<kaddkaka> sent a code paste, see https://paste.rs/0Dy7D
21:35:22FromDiscord<Elegantbeef> Right, they're quite clearly tagged unions
21:36:47FromDiscord<kaddkaka> (edit) "https://paste.rs/oIKBc" => "https://paste.rs/OtEIq"
21:36:57FromDiscord<kaddkaka> yes
21:38:08FromDiscord<guttural666> ix on nimplayground seems to be down
21:38:17FromDiscord<kaddkaka> And if I want conciser ways to create these objects I would make "make" functions?↵`func A(): Action = Action(kind: A, A: true)` ?
21:38:39FromDiscord<kaddkaka> (edit) "A():" => "A(value):" | "true)`" => "value)`"
21:38:42FromDiscord<Elegantbeef> Yea though I'd call them "constructors"
21:39:04FromDiscord<kaddkaka> and we don't get them for free I suppose
21:39:39FromDiscord<kaddkaka> is the name `kind` magic in any way?
21:40:03FromDiscord<Elegantbeef> No you can name it `deeblebopGringleSnobTheThird`
21:46:13FromDiscord<kaddkaka> ok, will do!
21:56:21FromDiscord<fwsgonzo> Alright, I've tested "all" of them now. Puppy uses cURL (dlopen) and chronos uses libnss (dlopen), so .. so far there is no HTTP library with built-in DNS
21:56:33FromDiscord<fwsgonzo> (edit) "Alright, I've tested "all" of them now. Puppy uses cURL (dlopen) and chronos uses ... libnss" added "glibc"
22:12:49FromDiscord<guttural666> In reply to @bostonboston "so something like this": thanks so much for this, I am getting this to run, gonna have to write this down, my prototype now works like this: https://media.discordapp.net/attachments/371759389889003532/1181719851539103774/image.png?ex=6582155f&is=656fa05f&hm=c1c2faf007bd2c623ac137d200fa7752a558de902d57f6db988ba2f3610691bc&
22:28:43FromDiscord<Elegantbeef> @guttural666 you do not need that global pragma there
22:29:36FromDiscord<guttural666> okay, gonna try it
22:29:52FromDiscord<guttural666> works no prob, thanks
22:31:23*Lord_Nightmare quit (Quit: ZNC - http://znc.in)
22:31:26FromDiscord<guttural666> is this just a promise to the compiler here? or does this really talk inform the GC not to touch this? https://media.discordapp.net/attachments/371759389889003532/1181724540255076443/image.png?ex=658219bd&is=656fa4bd&hm=dc95abaeadf362c130f7c7ae5b3de2b73076837ca029b2a91449dfbb22bc404c&
22:31:36FromDiscord<guttural666> (edit) removed "talk"
22:31:40FromDiscord<Elegantbeef> It's neither
22:31:52FromDiscord<Elegantbeef> It's saying "I know better"
22:34:21*Lord_Nightmare joined #nim
22:34:27FromDiscord<guttural666> in the past I have implemented multithreading by segmenting an array or work areas of an array and giving them to specific threads to fill them with content, obv. the C++ compiler didn't complain and it worked, because the program logic was correct, so I guess I'm telling the compiler here to not complain, because I am sure I did the right thing?
22:34:56FromDiscord<Elegantbeef> You're disabling the GC safety analysis for the block of code
22:35:12FromDiscord<guttural666> okay, so I guess that is talking to the compiler then
22:36:05FromDiscord<guttural666> do you always have to do this with pragmas? or is there some "right" way to just write code and the compiler sees from the code that no bad things can happen?
22:36:42FromDiscord<Elegantbeef> Pass a pointer to your `Deque[T]` instead of using a global
22:39:04FromDiscord<guttural666> ptrs to stack variables should be inherently safe frorm GC?
22:39:12FromDiscord<guttural666> (edit) "stack" => "heap"
22:40:07FromDiscord<bostonboston> Is there a proper way to convert unchecked arrays to seqs, or just create a new seq of proper length and copyMem?
22:40:09FromDiscord<guttural666> GC makes a lot of things very easy, but obfuscates a lot of things for me
22:47:29FromDiscord<Elegantbeef> No pointers do not have thread analysis and globals are icky
22:49:36FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/GWYbw
23:07:05FromDiscord<guttural666> yeah, figured I want to have the state touched by lots of threads in its own thing and the indepenent scheduler somewhere else
23:25:59FromDiscord<guttural666> to make a typed thread of a scheduler like this doesn't really make any sense, if you want to mutate the scheduler, if I understood the concept correctly↵var queue_thr: Thread[Scheduler]
23:26:46FromDiscord<Elegantbeef> you need to have `ptr Scheduler` and either use an address to the thread local variable or heap allocate using `create`/`alloc`
23:27:05FromDiscord<Elegantbeef> Multi threading in Nim is fairly manual still
23:27:14*advesperacit quit ()
23:27:20FromDiscord<Elegantbeef> Unless you have taks and can use malebolgia/taskpools
23:31:19FromDiscord<guttural666> a scheduler should be a singleton really, accessible by a single memory address
23:32:12FromDiscord<Elegantbeef> Right so then a `ptr T` or a global
23:32:33FromDiscord<guttural666> gonna try that
23:35:38FromDiscord<Elegantbeef> Though a non pointer works aswell
23:35:40FromDiscord<Elegantbeef> Assuming you do not need to mutate it and it's all value types
23:36:24FromDiscord<guttural666> I really want to mutate the Scheduler itself, so it can hold a clock and the queue itself and so on
23:36:34FromDiscord<blind_faith> is there a way I can write↵`for i, elem in mySeq`↵so that `i` is mutable?
23:36:37FromDiscord<guttural666> one thing to hold all the things
23:36:42FromDiscord<blind_faith> (edit) "mySeq`↵so" => "mySeq:`↵so"
23:36:52FromDiscord<Elegantbeef> So then you need `ptr Scheduler` or similar
23:37:15FromDiscord<Elegantbeef> You can write your own iterator
23:37:29FromDiscord<guttural666> yeah, that would be lovely, trying to write that rn, thanks again for your help man, really appreciate it
23:41:11FromDiscord<Elegantbeef> Or make your own macro like `std/enumerate`
23:43:18FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/7VI9s
23:50:47FromDiscord<blind_faith> thanks
23:52:03FromDiscord<guttural666> ptrs just work, I prefer to be fucked at runtime but shit works for a while than being nipped in the bud at compile time, this is a real confidence boost 🥹
23:52:51FromDiscord<Elegantbeef> You prefer stuff to fail at runtime?
23:52:54FromDiscord<Elegantbeef> That's an absurd idea
23:54:00FromDiscord<Elegantbeef> That's akin to saying "I prefer my brakes to fail whilst going 100km/h rather than having an inspection"
23:55:06*lucasta joined #nim