<< 08-01-2023 >>

00:17:40FromDiscord<jtv> Is there a way to pass a pointer to a function directly, or do I have to assign it to a variable first? Have tried casting and a bunch of other crap
00:18:00FromDiscord<jtv> Not that big a deal, just would be nice
00:18:51FromDiscord<jtv> Particularly, have some data type that takes an Option[SomeFuncPtrType] and having to go through a dummy variable to call some() on it feels ugly
00:19:01FromDiscord<Elegantbeef> you can just do `myProc(myOtherProc)`
00:19:31FromDiscord<jtv> I'm trying to do myProc(some(myOtherProc))
00:20:11FromDiscord<jtv> And if I don't stick myotherProc in a variable first, it gives me an obtuse error about two types being different, when they both are the same, ones just the alias that's the formal
00:20:25FromDiscord<jtv> But if I do x = myOtherProc; myProc(some(x)) it's fine
00:24:03FromDiscord<Elegantbeef> Uncertain what you're doing
00:24:40FromDiscord<Elegantbeef> is `myOtherProc` an overload?
00:25:23FromDiscord<Elegantbeef> Without the actual code it's quite hard to say what's what
00:28:23FromDiscord<jtv> 1 sec
00:28:34FromDiscord<jtv> https://play.nim-lang.org/#ix=4kBH
00:29:39FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4kBI
00:29:54FromDiscord<Elegantbeef> `Option[proc{.nimcall.}]` cannot convert to `Option[proc{.closure.}]`
00:30:16FromDiscord<Elegantbeef> As such you need to explicitly state `TestType` is a closure
00:30:20FromDiscord<Elegantbeef> I mean nimcall
00:32:36FromDiscord<jtv> I see, I suppose {.nimcall.} is just the standard calling convention, yes? But I don't understand why it infers that it's a closure in one context, but a nimcall in the other.
00:32:49FromDiscord<Elegantbeef> You could also do `some(proc(i: int){.closure.}(addFive))`
00:32:56FromDiscord<Elegantbeef> Well Nim's default type for procedures is closures
00:33:04FromDiscord<Elegantbeef> Aside from declarations
00:33:26FromDiscord<jtv> Got it
00:33:28FromDiscord<jtv> Thank you
00:33:30FromDiscord<Elegantbeef> So `proc doThing(p: proc())` expects `closure` as this allows both `nimCall`(through conversion) and also `closure` of course
00:34:59FromDiscord<Elegantbeef> I do have a PR that thunks all procedures to closures, but it's pretty much dead on arriaval by my lack of knowledge in code generators
00:36:08FromDiscord<Elegantbeef> But in theory there is no reason why nimcall -\> closure is special and Nim couldnt convert any procedure into a nimcall or closure
00:36:51FromDiscord<jtv> Yup got it. If your PR works, what's the issue with it really? Too kludgy??
00:36:59FromDiscord<Elegantbeef> It doesnt work
00:37:04FromDiscord<jtv> Ahhhhhh
00:37:21FromDiscord<Elegantbeef> There is an issue with the code generator and I dont know what to do
00:37:32FromDiscord<jtv> That sucks :/
00:37:45FromDiscord<Elegantbeef> It's really not that complicated of a change, just I only have ever touched semantic analysis
00:38:40FromDiscord<jtv> Still, code generation is usually the messiest part of a compiler. I can imagine that's the case here too :/
00:39:20FromDiscord<Elegantbeef> Eh it's not even code gen i need to change
00:39:26FromDiscord<Elegantbeef> It's just a useless error message inside codegen 😄
00:40:52FromDiscord<jtv> 90% of the error messages in nim are close to useless 🙂
00:41:34FromDiscord<jtv> BTW, doThing(TestType(addFive)) worked, which is cool and feels elegant and obvious enough
00:41:48FromDiscord<jtv> Erm, dothing(some(TestType(addFilve)))
00:42:32FromDiscord<Elegantbeef> Meh i find them ok mostly
00:45:09FromDiscord<Elegantbeef> But that's likely stockholm calling
00:45:39FromDiscord<jtv> Yeah, I guess that's not even really true, it's the optimization that's the worst... just that tends to be the peephole optimizations that are often baked into the code generation phase
00:45:57FromDiscord<rlipsc> sent a code paste, see https://paste.rs/Dvi
00:47:13FromDiscord<Elegantbeef> That should work
00:47:17FromDiscord<Elegantbeef> Symbols dont care about scope
00:47:38FromDiscord<rlipsc> oh... today I learned...
00:47:59FromDiscord<rlipsc> that's not what I expected 😅 though does explain some stuff
00:48:06FromDiscord<Elegantbeef> Hell you can copy a procedure that's exported and copy it calling all symbols internally
00:48:54FromDiscord<rlipsc> how have I been using the language for so long and not known this... 😆
00:49:05FromDiscord<Elegantbeef> That is the entire point of a symbol after all to be an identifer that is typed and bound to an implementation
00:49:43FromDiscord<rlipsc> Makes sense, but then again, I still expected scope to work as it's not 'visible', but apparently not.
00:50:13FromDiscord<Elegantbeef> Using the macro cache you can do even funkier shit aswell with symbols
00:51:05FromDiscord<rlipsc> yes, that I have been caught by. Learned my lesson to always `.copy` from macrocache
00:51:32FromDiscord<rlipsc> things get funky, fast
00:53:09FromDiscord<rlipsc> sent a code paste, see https://play.nim-lang.org/#ix=4kBM
00:53:20FromDiscord<rlipsc> 😬
00:54:11FromDiscord<Elegantbeef> `genSym` is fun
00:55:27FromDiscord<rlipsc> I feel like that example should fail when the symbol is redefined, or something.
00:57:13FromDiscord<rlipsc> sent a code paste, see https://paste.rs/jX1
01:04:33FromDiscord<Elegantbeef> Yea gensym + symbols are interesting
01:06:59FromDiscord<rlipsc> Yeah, that was a bit of a gotcha for me. Although, I guess it allows some pretty crazy things in metaprogramming, in theory. Perhaps at the cost of sanity, though.
01:07:40FromDiscord<auxym> In reply to @jtv "https://play.nim-lang.org/#ix=4kBH": this works fyi: ` setMagicFunc(some(addFive.TestType))`
01:07:49FromDiscord<Elegantbeef> The plus side is you can technically rewrite any procedure that exists inside a macro
01:07:50FromDiscord<rlipsc> I was trying to work out why the symbol was being added to multiple times even though the code "clearly" instantiated the variable and updated it once. Well, turns out things aren't that simple with genSym 🙂
01:08:06FromDiscord<Elegantbeef> Say you want to make yourself a tail call optimiser, it's not impossible to do
01:09:47FromDiscord<rlipsc> huh, yeah... actually I can see it being really useful for rewriting things. I guess it's no different from `bindSym` in a way.
01:10:43FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4kBR
01:11:16FromDiscord<Elegantbeef> Yea it's the generative antonym of `bindsym`
01:14:36FromDiscord<rlipsc> In reply to @Elegantbeef "In the above case": Not quite the same, though. I needed to reference `sym` in different code blocks so I needed a generated variable that I could refer to.
01:15:45FromDiscord<rlipsc> Also, I keep meaning to look into `genAst`, is it going to replace `quote`?
01:16:21FromDiscord<Elegantbeef> It kinda does replace quote yes
01:16:28FromDiscord<Elegantbeef> It's a bit nicer imo since it doesnt require backticks
01:18:18FromDiscord<rlipsc> it'd be nice to not need backticks for some of my larger macros, though I'm a bit concerned there'd be some surprise symbol clashing. Probably not, though.
01:18:39FromDiscord<Elegantbeef> You explicitly pass in catched symbols
01:18:42FromDiscord<Elegantbeef> cached symbols rather
01:20:26FromDiscord<rlipsc> I remember being put off by `genAst` for that reason; if you have 30+ idents to reference it might become onerous. It might mean I'd have to, like, write better code or something.
01:22:42FromDiscord<Elegantbeef> Eh i find it better than `let a = x`
01:25:27FromDiscord<rlipsc> sent a code paste, see https://paste.rs/Smg
01:25:48FromDiscord<rlipsc> I know you can change the quote char, but it's still awkward
01:25:48FromDiscord<Elegantbeef> Well in that case you could tell quote to use `@` or similar
01:25:55FromDiscord<Elegantbeef> Lol
01:47:09FromDiscord<ambient> sent a code paste, see https://play.nim-lang.org/#ix=4kBY
01:48:05FromDiscord<ambient> Maybe Nim stack and C stack mean different things
01:54:10FromDiscord<ambient> Ok it talks about seqs separately, nvm
02:00:43FromDiscord<pietroppeter> In reply to @pietroppeter "Yep no problem, will": @ElegantBeef done, but this time is tricky, we have a couple of somewhat big assets and maybe it is better to link to an outside link... see https://github.com/nim-lang/website/pull/356
02:01:09FromDiscord<Elegantbeef> Miran will tell you 😄
02:01:39FromDiscord<pietroppeter> yep, will see
02:06:59FromDiscord<auxym> sent a code paste, see https://play.nim-lang.org/#ix=4kC1
02:07:29FromDiscord<ambient> In reply to @auxym "what? You mean trying": var foo = seq[int](64_000_000_000); or something like that
02:07:39FromDiscord<ambient> but I already got most of my question answered
02:08:07FromDiscord<auxym> seqs are implicitly heap allocated, but use value semantics, so an assignment will copy
02:08:12FromDiscord<ambient> I assume that stack has some limit and is not dynamically changed if it requires more space
02:08:24FromDiscord<auxym> no it's like in C
02:09:01FromDiscord<auxym> by default gcc allocates 1 mb of stack size, or something like that, if you try to create a 64 gb array you'll segfault
02:09:10FromDiscord<ambient> yep
02:31:56FromDiscord<demotomohiro> !eval var ary: array[512 1024 1024]; echo ary[^1]
02:32:00NimBotCompile failed: /usercode/in.nim(1, 20) Error: invalid token: (\29)
02:36:31FromDiscord<demotomohiro> !eval var ary: array[64 1024 1024, int]; echo ary[^1]
02:36:34NimBotCompile failed: /usercode/in.nim(1, 19) Error: invalid token: (\29)
02:54:58*arkurious quit (Quit: Leaving)
03:31:05*azimut quit (Ping timeout: 255 seconds)
04:12:15FromDiscord<pyolyokh> In reply to @demotomohiro "!eval var ary: array[64": that's the right syntax, but outside of a proc that's not going to be stack-allocated.
04:13:37FromDiscord<pyolyokh> it's also not going to be heap-allocated. the heap/stack dichotomy probably confuses more than it enlightens.
04:18:48*ltriant joined #nim
04:26:01FromDiscord<Require Support> how do I decide between using `orc` or `arc`. compiling for windows, using threading, not using async
04:26:19FromDiscord<Elegantbeef> Easy use orc
04:27:39FromDiscord<Require Support> thanks, any quick explanation to why use orc? so I don't ask here everytime I have to make this decision
04:27:58FromDiscord<Elegantbeef> It handles cyclical types and is only used in a type that can be cyclical
04:28:05FromDiscord<Elegantbeef> It has 0 overhead if you dont have cyclical types
04:36:55FromDiscord<NibbleNueva> orc is also the default in nim 2.0 (which looks to be very soon)
05:00:00*oprypin_ quit (Quit: Bye)
05:16:22FromDiscord<albassort> is scanning more efficient when reading from a stream by manually incrementing the pos by 1
05:16:36FromDiscord<albassort> or doing it byte by byte until it matches a buffer
06:15:02FromDiscord<brendo-m> sent a code paste, see https://paste.rs/pXY
06:32:05FromDiscord<demotomohiro> @pyolyokh Variables outside of procs are allocated on a place called "static storage" in C lang.
07:27:51*pro joined #nim
07:27:58*ltriant quit (Ping timeout: 272 seconds)
07:30:18*ltriant joined #nim
07:50:40*ltriant quit (Ping timeout: 252 seconds)
07:51:31*ltriant joined #nim
07:56:44*pro quit (Quit: pro)
08:04:42*Batzy quit (Ping timeout: 272 seconds)
09:00:35FromDiscord<pyryrin> does nim automatically inline some functions
09:01:29FromDiscord<Elegantbeef> C does, Nim doesnt
09:01:53FromDiscord<Elegantbeef> If you want to inline code you use templates/macros
09:02:02*pro joined #nim
09:02:16*pro quit (Client Quit)
09:02:27FromDiscord<pyryrin> wasnt there `{.inline.}` pragma or something
09:02:46FromDiscord<Elegantbeef> There is but that still just tells the C compiler that it should inline it
09:03:03FromDiscord<Elegantbeef> Nim does not have any mechanism to inline code that doesnt rely on the backend compiler
09:03:05FromDiscord<pyryrin> so it makes no difference?
09:03:33FromDiscord<Elegantbeef> It makes a difference but it's up to the C compiler to inline
09:04:17FromDiscord<pyryrin> i think nowdays it doesn't make a difference and the c compiler will decide
09:04:53FromDiscord<Elegantbeef> > Nim does not have any mechanism to inline code that doesnt rely on the backend compiler↵I should say aside from templates which guarantee inlining, but yes inline annotation is the proper thing to do in 99% of cases that you want a procedure inlined
09:05:01FromDiscord<Elegantbeef> Though in most cases the C compiler is smart enough
09:06:30FromDiscord<pyryrin> i trust the c compiler
09:26:01FromDiscord<ShalokShalom> Sounds heroic
09:40:11FromDiscord<albassort> @ElegantBeef
09:40:31FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#ix=4kD0
09:40:33FromDiscord<albassort> how do i optimize
09:40:47FromDiscord<albassort> order is a smol array its not the bottleneck
09:41:55FromDiscord<albassort> im matching for strings in a pool of data
09:42:08FromDiscord<albassort> "0000000OPTXOOOO" eg
09:53:29FromDiscord<albassort> sent a code paste, see https://paste.rs/10C
09:56:21FromDiscord<ElegantBeef> A prefix table or similar likely
09:56:58FromDiscord<ElegantBeef> You havent give much of a explanation of what you're doing
09:57:58FromDiscord<ElegantBeef> doing `data.toOpenArray(y, y + 3) in order[]` will reduce copying which will make it a bit faster aswell but yes need to remove the costly contains check
09:59:18FromDiscord<albassort> what is a prefix table
09:59:37FromDiscord<albassort> im looking for chunk markets in a binary
10:00:01FromDiscord<ElegantBeef> Which means what exactly
10:00:06FromDiscord<ElegantBeef> You have binary data and have a needle?
10:00:21FromDiscord<albassort> In reply to @albassort ""0000000OPTXOOOO" eg": here
10:00:30FromDiscord<albassort> im gonna move it to a hashset and see if thats better
10:00:37FromDiscord<ElegantBeef> You arent making any sense
10:00:46FromDiscord<ElegantBeef> Yes that's the data, but what are you searching for
10:01:27FromDiscord<albassort> the chunk markers in the array
10:01:44FromDiscord<ElegantBeef> Which are?
10:01:57FromDiscord<albassort> im reading the data, and if its a chunk marker, i add its position to the output hashtables
10:02:11FromDiscord<ElegantBeef> And what is a chunk marker
10:02:16FromDiscord<albassort> strings of size 4
10:02:22FromDiscord<ElegantBeef> "It's a marker that marks a chunk"
10:02:38FromDiscord<albassort> my response was worse than your mockery lol
10:02:46FromDiscord<ElegantBeef> Yes
10:03:56FromDiscord<ElegantBeef> So what is order
10:04:10FromDiscord<albassort> order is a hashset of strings which i am looking for
10:04:39FromDiscord<ElegantBeef> Seems `array[4, char]` would be a tinge better
10:06:03FromDiscord<albassort> moving it to a hashset has made it 100% faster alone
10:06:19FromDiscord<ElegantBeef> The hell was it before?
10:06:34FromDiscord<albassort> a seq
10:06:37FromDiscord<ElegantBeef> ...
10:06:44FromDiscord<albassort> i know i should know better
10:06:52FromDiscord<ElegantBeef> Another thing you could do is store the start/end characters you've seen in a set
10:07:18FromDiscord<albassort> they are
10:07:23FromDiscord<ElegantBeef> then you could do something like `if data[y] in startSet and data[y + 3] in endSet` which might be a bit faster
10:07:53FromDiscord<albassort> sent a code paste, see https://play.nim-lang.org/#ix=4kD2
10:07:58FromDiscord<ElegantBeef> A bitset
10:08:00FromDiscord<ElegantBeef> Of characters
10:08:18FromDiscord<ElegantBeef> No hashing required to quickly see if the chunk has been seen
10:08:21FromDiscord<albassort> bitset?
10:08:26FromDiscord<ElegantBeef> `set[char]`
10:08:32FromDiscord<ElegantBeef> For the first and last character of a chunk
10:09:02FromDiscord<ElegantBeef> I imagine it's faster than hashing
10:09:27FromDiscord<ElegantBeef> Basically you filter out impossible chunks with a cheaper set
10:09:37FromDiscord<ElegantBeef> Probably could just do first character
10:10:07FromDiscord<ElegantBeef> Though I again dont know the actual data and variance of it
10:10:26FromDiscord<ElegantBeef> I just assumed that the start/end were not extremely invariant so one could check both to reduce hashing
10:10:51FromDiscord<ElegantBeef> But anyway you can use a `array[4, char]` to make it faster probably
10:11:13FromDiscord<albassort> an array of array[4, char]?
10:11:15FromDiscord<ElegantBeef> since comparison of that could just be a comparison of a 4 byte number
10:11:17FromDiscord<albassort> of set of array[4
10:11:20FromDiscord<albassort> (edit) "array[4" => "array, 4"
10:11:20FromDiscord<ElegantBeef> ....
10:11:30FromDiscord<albassort> sorry brain melting
10:11:54FromDiscord<ElegantBeef> I thought you were using `Hashset[string]`
10:11:59FromDiscord<albassort> i am
10:12:23FromDiscord<ElegantBeef> So instead of that use `HashSet[array[4, char]]`
10:13:06FromDiscord<ElegantBeef> Since your key is really just an array of 4 chars
10:13:16FromDiscord<ElegantBeef> This will likely make it much faster
10:14:01FromDiscord<albassort> is there any... non cbt away to convert my strings to chars
10:14:36FromDiscord<ElegantBeef> sent a code paste, see https://paste.rs/2qM
10:15:35FromDiscord<ElegantBeef> Also removes your useless string copy
10:18:01FromDiscord<albassort> i mean for the declaration
10:18:09FromDiscord<ElegantBeef> What?
10:18:18FromDiscord<albassort> nooo dont what me fuck
10:18:33FromDiscord<albassort> "ABC" => array[3, char[
10:18:34FromDiscord<ElegantBeef> Maybe if you spoke in full sentences that explained the issue we'd be a lot happier
10:18:35FromDiscord<albassort> (edit) "char[" => "char]"
10:18:59FromDiscord<albassort> the strings in the declaration, casting them to arrays of characters
10:19:46FromDiscord<ElegantBeef> sent a code paste, see https://play.nim-lang.org/#ix=4kD7
10:20:03FromDiscord<ElegantBeef> I guess that should be `charArr`
10:20:07FromDiscord<ElegantBeef> but who makes the rules
10:20:16FromDiscord<Rika> chArr xd
10:20:18FromDiscord<Rika> i joke
10:20:26FromDiscord<ElegantBeef> Imagine if you said "But how would i make string literals into an array"
10:20:32FromDiscord<ElegantBeef> We wouldnt have egg on our collective faces
10:20:41FromDiscord<albassort> no its just my face
10:20:42FromDiscord<Rika> inb4 "but my strings arent literals"
10:21:04FromDiscord<ElegantBeef> Luckily i go to sleep soon, so it becomes someone elses problem
10:21:14FromDiscord<Rika> not mine hopefully
10:21:54FromDiscord<albassort> its very hot in my room
10:22:08FromDiscord<albassort> so im probably more insane than usual
10:22:25FromDiscord<ElegantBeef> Dont know if insane is the 'i' word i'd use
10:23:33*oprypin joined #nim
10:24:06FromDiscord<ElegantBeef> Alba here really better type faster if they want to report their code exploding
10:25:07FromDiscord<ElegantBeef> Though to be honest i'm quite surprised `strArr` worked as it's written, didnt require any hacks
10:29:57FromDiscord<ElegantBeef> Well have fun alba
10:30:43FromDiscord<albassort> i wont
10:32:51FromDiscord<albassort> we're down from around 1 minute to 7 seconds
10:33:13FromDiscord<Rika> thats gotrta be good enough
10:33:50FromDiscord<albassort> thats what we tell ourselves before bed but while we try to sleep we think to ourselves "is 6 seconds possible"
10:33:57FromDiscord<albassort> but there are indeed no easy optimizations from here
10:34:02FromDiscord<albassort> that i can think of
10:34:11FromDiscord<albassort> so probably good enough
10:35:09FromDiscord<albassort> if we wanna get technical its 28 seconds because its threaded
10:35:22FromDiscord<albassort> which is unacceptable
10:39:23*azimut joined #nim
11:00:37FromDiscord<pmp-p> need some help with the forum, i did receive confirmation but way too late and it is expired but i can't find a button to resend it
11:01:18FromDiscord<enthus1ast> there (still) is none
11:01:37FromDiscord<enthus1ast> one of the mods must enable you
11:02:10FromDiscord<pmp-p> In reply to @enthus1ast "one of the mods": thx, then my profile is there https://forum.nim-lang.org/profile/pmp-p
11:15:28om3gaHi! const name: int = 3 is equivalent to #define name 3?
11:19:29*pro joined #nim
11:22:18*azimut quit (Remote host closed the connection)
11:22:44*azimut joined #nim
11:22:51FromDiscord<Rika> not exactly, roughly yes
11:24:21om3gaRika, thanks!
11:30:26FromDiscord<Vindaar> In reply to @pmp-p "thx, then my profile": activated
11:41:13*pro quit (Quit: pro)
11:45:37FromDiscord<federico3> any timeline on the release of 2.0?
11:47:44FromDiscord<albassort> choosenim #head #fed
11:47:50FromDiscord<albassort> (edit) removed "#fed"
11:54:50FromDiscord<jmgomez> In reply to @federico3 "any timeline on the": hopefully when all of this is fixed (and not before) https://github.com/nim-lang/Nim/labels/ARC%2FORC%20Memory%20Management
11:58:50FromDiscord<pmp-p> In reply to @Vindaar "activated": thnak you very much
12:29:09*krux02 joined #nim
12:38:26*pro joined #nim
12:38:58*pro quit (Client Quit)
13:33:06*pro joined #nim
13:36:20*pro quit (Client Quit)
13:59:38*jmdaemon quit (Ping timeout: 255 seconds)
13:59:51*pro joined #nim
14:04:19*pro quit (Ping timeout: 260 seconds)
14:04:43*pro joined #nim
14:40:51*pro quit (Quit: pro)
14:54:23*arkurious joined #nim
14:56:18FromDiscord<FullValueRider> I'm getting this error message. Apart from rechecking my code for my errors what else can I do?
14:56:29FromDiscord<FullValueRider> sent a code paste, see https://paste.rs/0hV
15:01:13FromDiscord<4zv4l> sent a code paste, see https://paste.rs/C27
15:01:31FromDiscord<4zv4l> like why I cannot reverse the array in comptime ? ↵it doesn't return the array so I cant' do it for `const`
15:01:53FromDiscord<4zv4l> and the cast doesn't work for `const` also 🥺
15:04:20FromDiscord<Phil> Does it have to be the same array? Can't you just do a transformation?
15:04:39FromDiscord<Phil> Basically create a second array as you desire
15:05:32FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4kEe
15:05:32FromDiscord<4zv4l> In reply to @Isofruit "Basically create a second": how ?
15:05:36FromDiscord<4zv4l> reverse doesn't return the value
15:05:41FromDiscord<4zv4l> it reverse the same array
15:10:28FromDiscord<Phil> I'll need to look into it, worst case scenario you write your own reverse proc for an array, should be like 5 or 6 loc
15:10:51FromDiscord<Phil> It would work at compile time as well, so no performance penalty
15:11:16FromDiscord<Phil> Got to wait till after sport though.
15:15:47FromDiscord<auxym> sent a code paste, see https://play.nim-lang.org/#ix=4kEh
15:16:16FromDiscord<Rika> sent a code paste, see https://play.nim-lang.org/#ix=4kEi
15:16:27FromDiscord<Rika> or use `reversed`
15:17:13FromDiscord<Rika> ah, reversed returns a seq
15:17:14FromDiscord<Rika> lo
15:17:34FromDiscord<Rika> sent a code paste, see https://play.nim-lang.org/#ix=4kEj
15:19:58*PMunch joined #nim
15:25:08FromDiscord<4zv4l> In reply to @auxym "are you aware of:": the purpose is to not use ipaddress lib xD
15:25:21FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4kEn
15:27:17FromDiscord<4zv4l> well just need the const cast xD
15:28:45FromDiscord<auxym> @4zv4l you can also use the stuff in std/endians (or endians2 on nimble) to reverse the bytes
15:29:20FromDiscord<auxym> endians uses pointers though so no go at compile time
15:30:30FromDiscord<4zv4l> oh yeah↵thanks, the purpose is to be at compile time
15:30:39FromDiscord<4zv4l> `var a = [1'u8, 2, 3, 4]`↵how does this work `1'u8` ?
15:31:01FromDiscord<4zv4l> I thought there isn't the type `u8` in nim but `uint8`
15:32:16FromDiscord<auxym> `'u8` is a suffix just used for literals
15:33:25FromDiscord<4zv4l> I was wondering also↵` var arr: array[4, byte] = [byte 127,0,0,1]`↵why do I need to precise byte inside the array ?
15:33:40FromDiscord<4zv4l> with the type info it should know that I want bytes
15:34:40FromDiscord<auxym> something something nim's type inference system is not smart enough
15:35:13FromDiscord<auxym> ` var arr: array[4, byte] = [127'u8,0,0,1]` would also work, byte is an alias for uint8
15:36:00FromDiscord<auxym> you can implement your own `toU32BE` that works at CT using shift + or as explained here (sort of) https://justine.lol/endian.html
15:38:18FromDiscord<auxym> sent a code paste, see https://play.nim-lang.org/#ix=4kEq
15:38:56FromDiscord<4zv4l> In reply to @auxym "` var arr: array[4,": oooh good to know !
15:40:51FromDiscord<auxym> which is what endians2 does if you want to use that instead of rolling your own: https://github.com/status-im/nim-stew/blob/master/stew/endians2.nim#L137
15:41:27FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4kEs
15:41:30FromDiscord<4zv4l> otherwise the or wouldn't always work
15:41:54FromDiscord<auxym> yes, nim zeroes everything always
15:42:22FromDiscord<auxym> but actually I think that might not work, you'll get cpu-native endian instead
15:43:18FromDiscord<auxym> thats why endians2 does swapbytes
15:44:41FromDiscord<auxym> yeah
15:44:41FromDiscord<4zv4l> yeah it doesn't seem to work
15:44:41FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4kEt
15:44:44FromDiscord<4zv4l> it only prints `127`
15:45:04FromDiscord<4zv4l> and I expect `2130706433`
15:52:10FromDiscord<auxym> In reply to @4zv4l "and I expect `2130706433`": here: https://play.nim-lang.org/#ix=4kEu
15:52:59FromDiscord<auxym> the shift was overflowing the uint8, need to convert to uint32 before
15:59:18FromDiscord<4zv4l> seems good
15:59:20FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4kEw
15:59:26FromDiscord<4zv4l> would be nice to be able to cast at comptime tho
16:06:22FromDiscord<Rika> casts arent a runtime thing
16:06:38FromDiscord<auxym> cast means reinterpet memory, and the VM doesn't actually access (real) memory, so yeah
16:06:46FromDiscord<Rika> at least to my knowledge, casts are just an "annotation" of sorts to tell the type system
16:07:48PMunchHmm, is there a way to get every type which inherits from a type?
16:08:32FromDiscord<auxym> sent a code paste, see https://play.nim-lang.org/#ix=4kEB
16:21:35FromDiscord<EyeCon> @PMunch do we expect futhark to be able to install into WSL with `libclang-dev` installed? I assumed so and get a compilation error when installing the HEAD with nimble
16:22:15FromDiscord<scipio> Hello there! 🙂 👋
16:22:51PMunch@EyeCon, honestly I have no idea. Haven't used Windows since before WSL was a thing..
16:23:06PMunchBut it's Linux-like right? So I guess it should work
16:23:11PMunchWhat's the error you get
16:23:18PMunch(by the way, it should also work without WSL)
16:23:20PMunch@scipio, hello
16:23:38FromDiscord<EyeCon> Everything is very linux-like, that's why I was surprised, let me get the error into a pastebin
16:24:22FromDiscord<scipio> I just discovered NIm yesterday 😁, spent all day reading `Dominik Picheta - Nim in Action-Manning Publications (2017)`
16:24:28FromDiscord<scipio> (edit) "NIm" => "Nim"
16:24:35PMunch@scipio, oh nice
16:24:41PMunchWelcome to the community :)
16:25:52FromDiscord<scipio> Well thanks! I am a hardcore Python fan, its syntax at least, so reading about Nim sparked a lot of enthusiasm. ↵However, in all honesty, what would be the preferred current GUI framework if I'd wanted to go fullstack Nim?
16:26:16FromDiscord<scipio> I'm also involved with the Flet project
16:26:27FromDiscord<scipio> https://flet.dev/
16:26:44FromDiscord<EyeCon> sent a code paste, see https://play.nim-lang.org/#ix=4kEG
16:26:51FromDiscord<EyeCon> Do I need to have 11?
16:27:14FromDiscord<Array in ∀ Matrix> for GUI you probably want to look onto using gtk or qt↵(@scipio)
16:27:18PMunchShouldn't require 11
16:27:20PMunchGotta go
16:27:21*PMunch quit (Quit: leaving)
16:27:27FromDiscord<auxym> In reply to @scipio "Well thanks! I am": GUI is not Nim's strong suit, still, unfortunately. There are bindings to many popular C GUI frameworks though: GTK (gintro), QT Quick / QML, wx. There's also the pure-nim nimx
16:27:38FromDiscord<Array in ∀ Matrix> ^ this
16:28:39FromDiscord<Array in ∀ Matrix> using electron or other js based webapp might be another option
16:29:19FromDiscord<scipio> Suppose I'd go with a Nim "local" backend, like Flask (Python), and then a barebones html, css, js frontend, to run on the same device as a macOS `.app`, what would then be the preferred framework stack?
16:29:41FromDiscord<scipio> In reply to @Array in ∀ Matrix "using electron or other": is there something like Tauri for Nim?
16:30:15FromDiscord<Array in ∀ Matrix> not that i know of maybe there is bindings for it?↵(@scipio)
16:33:13FromDiscord<scipio> Interesting: most NIm (ui) repos I come across haven't had updates in a while, some are 6-7 years old. Why is that?
16:34:15FromDiscord<scipio> When I'm reading the Nim language specs and Dominik Picheta's book: Nim seems like a dream come true. Why are these projects "abandoned" to a certain extent / isn't Nim as well-known as Rust lang is now? WHat's the catch?
16:34:22FromDiscord<pmunch> There are some options for building apps with web tech in Nim
16:34:53FromDiscord<ambient> Some people discount Nim because it's compiled into C or C++
16:34:57FromDiscord<pmunch> Otherwise there's the basic ones like WxWidgets, Gtk, Windows whateveritscalled
16:35:19FromDiscord<scipio> In reply to @ambient "Some people discount Nim": isn't that a huge advantage? To me that's a pre.
16:35:43FromDiscord<ambient> It depends on what you want to do
16:38:37FromDiscord<auxym> In reply to @scipio "When I'm reading the": rust has mozilla behind it, which lead to picking up a large community pretty fast. Nim's community is pretty small still, in part because it doesn't have corporate backing, so people are doubtful about investing their time in it (learning it, maintaining libraries, etc)
16:38:43FromDiscord<auxym> that's my take anyways
16:39:10FromDiscord<ambient> Rust had Mozilla behind it
16:39:53FromDiscord<ambient> Plus Rust does offer something new, namely no GC but memory safety.
16:40:38FromDiscord<ambient> Plus the performance is as good as C or C++
16:41:34FromDiscord<ambient> Nim seems to have perf in the same ballpark as C#, which also coincidentally seems to be developing into it's own thing outside .NET
16:42:03*jjido joined #nim
16:42:16FromDiscord<auxym> tbf nim's ORC is also pretty unique, and perf should be just as good as hand-written C if you know what you are doing.
16:42:47FromDiscord<ambient> I will believe it when I see it. The current benchmark give Nim similar results to C#
16:43:23FromDiscord<auxym> "fair" benchmarks are really hard to do though
16:43:43FromDiscord<jmgomez> In reply to @ambient "I will believe it": where is that current benchmark?
16:44:38FromDiscord<pyolyokh> "fair" Nim is also generally going to be slower than "Nim if you know what you're doing". It's natural to make more copies and do more allocation than necessary.
16:45:04FromDiscord<ambient> In reply to @jmgomez "where is that current": https://programming-language-benchmarks.vercel.app/nim-vs-csharp here's one
16:46:12FromDiscord<Gumbercules> In reply to @ambient "https://programming-language-benchmarks.vercel.app/": Benchmarks are dumb
16:46:23FromDiscord<Recruit_main707> c#? 🥴
16:46:34FromDiscord<ambient> In reply to @Gumbercules "Benchmarks are dumb": If you have better data for me to pick programming languages based on performance, I'm happy to receive it
16:46:57FromDiscord<ambient> Given what a mediocre programmer (me) can achieve with it
16:47:05FromDiscord<pyolyokh> numbers are numbers. I'd sell Nim as having very good numbers if you write it like it's a scripting language, and excellent numbers if you write it like it's C. An advantage over other languages is that this is still "writing Nim" and not switching to a different language.
16:47:08FromDiscord<Gumbercules> https://blog.johnnovak.net/2017/04/22/nim-performance-tuning-for-the-uninitiated/
16:47:19FromDiscord<Recruit_main707> nim, c, zig, rust all sit way closer than c# to nim i think
16:47:54FromDiscord<Gumbercules> It's not difficult to get Nim to outperform Rust
16:47:54FromDiscord<ambient> In reply to @Gumbercules "https://blog.johnnovak.net/2017/04/22/nim-performan": Microbenchmarks are worse than benchmarks
16:47:56FromDiscord<jmgomez> In reply to @pyolyokh ""fair" Nim is also": Especially if you dont, Nim can be faster than raw cpp
16:48:09Amun-Raambient: that depends what do you need… I'm writing image viewer atm, speed doesn't matter to me that much
16:48:11FromDiscord<Gumbercules> And it's not difficult to get close to C performance
16:48:41FromDiscord<Gumbercules> I can go write code in any language with no idea wtf I'm doing and write a poorly performing program
16:48:48FromDiscord<Gumbercules> Nim isn't special in this regard
16:49:01FromDiscord<Recruit_main707> In reply to @Gumbercules "I can go write": relatable
16:49:21FromDiscord<ambient> Well Rust makes it easy to write fast code. You have to include the parameter that matters the most: the average programmer
16:49:27FromDiscord<Recruit_main707> not knowing what im doing is programming language agnostic in my case tho
16:49:28FromDiscord<Gumbercules> If you want to remain convinced it has similar performance to C# when everyone and their grandma is telling you you're mistaken, that's on you
16:49:31FromDiscord<jmgomez> In reply to @ambient "https://programming-language-benchmarks.vercel.app/": I wouldnt infer from there that C# and Nim are equally faster. If you want to see them compete in the context of a big application. Compare UnrealCLR with NimForUE
16:49:32FromDiscord<Gumbercules> Go use rust then
16:50:07FromDiscord<ambient> In reply to @Gumbercules "If you want to": Like I said, if you have information I would like to see it
16:50:28FromDiscord<Gumbercules> You don't have information besides some random ass benchmark and your intuition
16:50:39FromDiscord<Gumbercules> Several of us have had this same debate with other people
16:50:44FromDiscord<ambient> In reply to @Gumbercules "You don't have information": Which is why I'm not making claims but asking questions
16:50:53FromDiscord<Gumbercules> You're not asking questions though
16:50:59FromDiscord<Gumbercules> You're telling us the way it is
16:51:03FromDiscord<Recruit_main707> how about other benchmarks?
16:51:06FromDiscord<Gumbercules> And then saying why Rust is better
16:51:21Amun-Ra"rust" and "makes it easy" rarely come in one sentence ;>
16:51:26FromDiscord<Recruit_main707> Ive always seen some weird numbers on that web you shared
16:51:26FromDiscord<Gumbercules> Go use Rust then if you're so convinced
16:51:46FromDiscord<Recruit_main707> Quite different to those in most other benchmarks
16:52:01FromDiscord<Recruit_main707> and i can tell you ive been obsessed with performance quite a lot
16:52:16FromDiscord<Gumbercules> It's a waste of time to sit here and post / compare benchmarka
16:52:26FromDiscord<pyolyokh> In reply to @ambient "Well Rust makes it": what Rust actually does it make it possible, with the borrow checker, for library writers to offer interfaces that are fast while not being too unsafe to be the default interface. I wouldn't say "easy" for either authors or users. But that's possible where the realistic alternatives in Nim are a) a safe not-as-fast interface, b) an as-fast interface that you can cut yourself on
16:52:47FromDiscord<Recruit_main707> wasnt going to, ive got other more important things to waste my time, like studying :/
16:52:47FromDiscord<ambient> Everything is a tradeoff, and we have to make decisions based on insufficient information. I have some experience and based on that experience I try to make good decisions. Sharing what I have as a starting point to figure out where I have to look to understand the situation better doesn't seem to me an unreasonable thing to do.
16:52:55FromDiscord<Gumbercules> I just linked to a blog post explaining optimization techniques commonly used with Nim and you didn't even read it
16:53:40FromDiscord<demotomohiro> Here is another language benchmark: https://github.com/niklas-heer/speed-comparison
16:53:55FromDiscord<ambient> In reply to @Gumbercules "I just linked to": I have read it before and I skimmed it enough to see micro benchmarks and JIT warmup (which is a pointless metric for most my usecases)
16:54:00FromDiscord<pyolyokh> a handy example of that is <https://forum.nim-lang.org/t/9688> , where cligen gives you speed but you now have to care about the lifetime of its slices.
16:54:38FromDiscord<Recruit_main707> In reply to @demotomohiro "Here is another language": first benchmark i see fortran leading for once 🥴
16:55:03FromDiscord<pyolyokh> that should tell you that allocation isn't going to be the issue with the benchmark
16:56:59FromDiscord<Gumbercules> In reply to @ambient "I have read it": But benchmarks are going to make you write faster code in Nim?
16:57:17FromDiscord<Gumbercules> You realize that benchmarks are s** because people can do things to optimize the result right?
16:57:40FromDiscord<Gumbercules> So you're saying you want to language where it's easy to write performant code without knowing what you're doing
16:57:46FromDiscord<Gumbercules> And you want benchmarks to back that up
16:58:14FromDiscord<pyolyokh> even derisively I wouldn't use "easy" with Rust ...
16:58:43FromDiscord<ambient> In reply to @Gumbercules "But benchmarks are going": Benchmarks give an idea of the ceiling what a language can achieve. Also useful information I would like to have is how many hoops I have to jump through to write optimal code.
16:58:45FromDiscord<pyolyokh> you can use a library that won't let your code compile unless it's performant, while you don't know what you're doing. That's pretty good.
16:59:05FromDiscord<Gumbercules> In reply to @ambient "Benchmarks give an idea": You have to jump through as many hoops with name as any other language because you need to know what the f you're doing
16:59:28FromDiscord<Gumbercules> It's easy to write a s** program in C if you don't know what you're doing
16:59:37FromDiscord<Gumbercules> Just like every other language
17:00:25FromDiscord<ambient> Well so far I have failed to phrase my questions in a way that would create any useful response
17:00:30FromDiscord<Gumbercules> Why don't you write a program in Rust
17:00:38FromDiscord<Gumbercules> And write the equivalent in Nim
17:00:46FromDiscord<Gumbercules> And draw your own conclusions?
17:01:00FromDiscord<ambient> I already did write my program in Rust, and I'm going to write it in Nim
17:01:02FromDiscord<Gumbercules> That would probably be 1000 times more effective than staring at benchmarks
17:01:09FromDiscord<pyolyokh> In reply to @ambient "Benchmarks give an idea": well there are two benchmarks just above. Number-heavy stuff: Nim = Rust. Allocation-heavy stuff: Nim = C#. If C# is unacceptably slow for you, that's a thing to consider. You can look at that forum link, and cligen, to see the kind of stuff you might have to do in the second case.
17:01:35FromDiscord<Gumbercules> The you can ask questions about why one program is slower / binary is larger / whatever
17:01:41FromDiscord<Gumbercules> And get actual answers
17:01:41FromDiscord<ambient> but there are many unknowns unknowns that I'm trying to figure out and I assume people here could help with that
17:01:54FromDiscord<Gumbercules> Well we can when we have code to look at
17:02:00FromDiscord<Gumbercules> Until then it's just conjecture
17:02:07FromDiscord<ambient> It's commercial/propertiary atm
17:03:11FromDiscord<Gumbercules> I can't help you there. I think there are a plethora of examples of questions like this on the forums though
17:03:28FromDiscord<Gumbercules> Like why doesn't my program perform as well as this python program?
17:03:42FromDiscord<Gumbercules> And then pages of people replying and explaining why
17:04:25FromDiscord<Gumbercules> Very rarely is the answer because Nim is slow and memory is managed
17:04:44FromDiscord<Gumbercules> And I'd you're still dissatisfied you can always ditch automatic memory management and roll your own
17:04:57FromDiscord<Gumbercules> Just be prepared to not use any strings or sequences
17:05:19FromDiscord<ambient> if seqs are just dynamic arrays, they are plenty fast when pre-allocated
17:05:53FromDiscord<ambient> both C++ and Rust use them as the base data struct
17:06:02FromDiscord<pyolyokh> yeah, just a small bit of care can really benefit like that.
17:06:22FromDiscord<demotomohiro> If you pre-allocate heap of seq: https://nim-lang.org/docs/system.html#newSeqOfCap,Natural
17:10:29FromDiscord<pyolyokh> sent a long message, see https://paste.rs/5BL
17:11:12FromDiscord<ambient> Well why I'm personally trying it out is that it's easy to do exploratory code and easy to write very good abstractions to complex problems, while Rust makes it quite slow to write code and it's a lot of work to re-order the core logic
17:11:21FromDiscord<pyolyokh> with Rust, people could write the easy/unsafe (c) libraries, but for cultural reasons they won't. They'll only write safe libraries, and it's never quite as easy
17:11:40FromDiscord<ambient> Only place I need unsafe in Rust is user input, that's it
17:15:42FromDiscord<Gumbercules> In reply to @ambient "if seqs are just": This wasn't my point
17:16:05FromDiscord<Gumbercules> If you decide to ditch Nims automatic memory management, Nim sequences and strings won't work
17:16:09FromDiscord<ambient> I understood that after I wrote it, but I'm also not going to use a language that doesn't have some form of seq
17:16:18FromDiscord<Gumbercules> You'd need to bring your own stdlib
17:16:33FromDiscord<Gumbercules> Well you can roll your own
17:16:40FromDiscord<Gumbercules> But yeah... It's work
17:16:42FromDiscord<ambient> F that
17:16:55FromDiscord<jmgomez> Or bind one from the cpp std
17:16:57FromDiscord<Gumbercules> Eh in some spaces people don't have much of a choice
17:17:06FromDiscord<ambient> I'm not on embedded
17:17:11FromDiscord<Gumbercules> Yeah or use some C/C++ lib
17:17:27FromDiscord<Gumbercules> Fair, just pointing out that the GC is opt-in
17:17:40FromDiscord<Gumbercules> With some fairly substantial consequences of not doing so
17:18:21FromDiscord<ambient> at some point people are just going to tell me to rewrite the entirety of Nim to suit my usecase
17:18:22FromDiscord<Gumbercules> I've been writing Nim for seven years and others longer than me
17:18:30FromDiscord<jmgomez> I feel like it's under appreciated what I just said. You can have full generic support in a few lines of code binding
17:18:42FromDiscord<Gumbercules> If it had performance characteristics of C# we'd be long gone
17:18:50FromDiscord<ambient> Well that's fair
17:19:20FromDiscord<Gumbercules> Well Nim being hackable and malleable and extensible is one of it's strengths
17:19:23FromDiscord<ambient> C# is fairly fast tho, and stuff like https://github.com/bflattened/bflat do look pretty neat
17:20:11FromDiscord<Gumbercules> If you like writing object oriented code sure
17:20:43FromDiscord<Gumbercules> I'm not a fan of C# or Golang after having used both for work
17:21:00FromDiscord<Gumbercules> Wouldn't touch either for hobby time
17:21:13FromDiscord<ambient> From ergonomics perspective Nim is far ahead, I agree
17:21:16FromDiscord<pyolyokh> and you can 'abandon the GC' in narrow parts of your program where it matters. It's the same argument people use with Python, but it applies much better here. See that csv-parsing thread. The mslice code is using completely different memory management but after you've parsed everything as fast as possible you can go right back to normal Nim.
17:21:51FromDiscord<ambient> In reply to @pyolyokh "and you can 'abandon": Link thread?
17:22:29FromDiscord<pyolyokh> In reply to @pyolyokh "a handy example of": there
17:23:55*pro joined #nim
17:24:12FromDiscord<pyolyokh> cblake's post, specifically
17:24:17*pro quit (Client Quit)
17:24:19FromDiscord<ambient> In reply to @jmgomez "I feel like it's": Is there some example code how to achieve this?
17:25:06FromDiscord<Gumbercules> In reply to @jmgomez "I feel like it's": I appreciate it but most people aren't interoping with cop
17:25:13FromDiscord<Gumbercules> (edit) "cop" => "cpp"
17:25:24FromDiscord<Gumbercules> That's quite the advanced use case
17:25:51FromDiscord<ambient> I have a need to interop with some huge legacy CPP libs that are awful
17:26:09FromDiscord<Ailuros 💖🧡💛💚💙💜🖤> sent a code paste, see https://play.nim-lang.org/#ix=4kF3
17:26:33FromDiscord<Gumbercules> Well Nim can do it, but C++ interop / codegen is probably one of the more frustrating areas of using Nim
17:27:06FromDiscord<jmgomez> In reply to @ambient "Is there some example": https://scripter.co/binding-nim-to-c-plus-plus-std-list/↵There is a std repo that someone started out with a few examples and also NimForUE is full of that stuff
17:27:22FromDiscord<Gumbercules> jmgomez is probably an expert at making the cpp backend behave at this point
17:27:36FromDiscord<ambient> Thanks, I have a lot of reading to do
17:28:30FromDiscord<jmgomez> In reply to @Gumbercules "jmgomez is probably an": let's say it's kinda tamed almost a year later 😛
17:28:47FromDiscord<Gumbercules> In reply to @Ailuros 💖🧡💛💚💙💜🖤 "Hey all, through trial": Address sanitizer or valgrind
17:28:57FromDiscord<Gumbercules> With -d:useMalloc
17:29:11FromDiscord<ambient> is Nim CPP binding platform independent?
17:29:22FromDiscord<ambient> or do I have to include some if else compile time trickery?
17:29:27FromDiscord<demotomohiro> There is Nim bindings for the C++ STL: https://github.com/Clonkk/nim-cppstl
17:29:52FromDiscord<jmgomez> In reply to @demotomohiro "There is Nim bindings": That's the one I was referring too I forgot about the name
17:31:31FromDiscord<jmgomez> In reply to @ambient "is Nim CPP binding": For the most part you should be fine. There a few edge cases, i.e. we have Unreal bindings working in Mac (clang) and Win (msvc) and there arent much bifurcations on the Nim code (OC the cpp code it is platform dep)
17:39:18FromDiscord<Ailuros 💖🧡💛💚💙💜🖤> In reply to @Gumbercules "Address sanitizer or valgrind": am currently developing/testing on Windows, doesn't look like I can easily use valgrind (not sure about address sanitizer 😮 )↵can check if maybe I can easily reproduce under linux
17:39:59FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4kF9
17:44:42FromDiscord<ambient> In reply to @Ailuros 💖🧡💛💚💙💜🖤 "am currently developing/testing on": Yeah I'm also on Windows and am figuring out if I have to write my own debug code generator/objdump parser thing
17:57:14FromDiscord<auxym> In reply to @4zv4l "I don't know if": you should use `byte(u shr xx)` instead of the cast. the fact that the cast works is likely accidental because you are on a LE machine is the LSB is at the lowest address.
17:58:35FromDiscord<@thatrandomperson5-6310e3b26da03> How would i make a modifiable, compile-time and global table?
17:59:25FromDiscord<@thatrandomperson5-6310e3b26da03> with a NimNode arg
17:59:30FromDiscord<auxym> Also https://justine.lol/endian.html recommends masking before the shift, mostly sign extension issues, but it might not be necessary if you're only doing unsigned (the conversion to byte should overflow to the correct result
18:00:48FromDiscord<auxym> In reply to @@thatrandomperson5-6310e3b26da03 "How would i make": you can make a macro that returns a `var ...` definition using table-initialization syntax
18:01:07FromDiscord<auxym> https://nim-lang.org/docs/manual.html#statements-and-expressions-table-constructor
18:01:27FromDiscord<auxym> put that into dumpTree to see the AST, then make a macro that generates that AST
18:01:40*pro joined #nim
18:01:50*pro quit (Client Quit)
18:03:01FromDiscord<auxym> `dumpTree: var myTable = {"key1": "value1", "key2": "value2"}.toTable
18:03:12FromDiscord<auxym> (edit) ""value2"}.toTable" => ""value2"}.toTable`"
18:12:47FromDiscord<Gumbercules> In reply to @Ailuros 💖🧡💛💚💙💜🖤 "am currently developing/testing on": Asan should work
18:13:07FromDiscord<Gumbercules> Not sure which compiler tool chain you're using
18:14:07*pro joined #nim
18:14:47*pro quit (Client Quit)
18:23:57*pro joined #nim
18:25:30*pro left #nim (#nim)
18:27:17FromDiscord<auxym> sent a code paste, see https://play.nim-lang.org/#ix=4kFl
18:29:23FromDiscord<enthus1ast> the kind cannot be changed later, you must put this in the object constructor
18:29:45FromDiscord<enthus1ast> myObj(kind\: rnkRegister)
18:30:49FromDiscord<auxym> ah. is that new in 1.6.10? Never encountered it before, pretty sure I have discriminant assignments littered all over my codebases
18:30:53FromDiscord<Ailuros 💖🧡💛💚💙💜🖤> In reply to @Gumbercules "Asan should work": Just got it running in linux container with valgrind:
18:31:12FromDiscord<enthus1ast> think this is since a few versions
18:31:18FromDiscord<Ailuros 💖🧡💛💚💙💜🖤> Now I have to look at what this means 😄 https://media.discordapp.net/attachments/371759389889003532/1061713725440131082/message.txt
18:32:55FromDiscord<Ailuros 💖🧡💛💚💙💜🖤> Does this mean that the memory at that address was "free'd" by GC, or something else entirely:↵==4815== Address 0x4a24940 is 0 bytes inside a block of size 248 free'd
18:36:43FromDiscord<@thatrandomperson5-6310e3b26da03> @auxym)
18:36:52FromDiscord<ambient> Turns out it wasn't Nim that was broken, it was my profiler after Windows update 🤦‍♂️ https://media.discordapp.net/attachments/371759389889003532/1061715122973851778/sleepy_z5dADHaYgv.png
18:37:06FromDiscord<auxym> In reply to @@thatrandomperson5-6310e3b26da03 "> you can make": if you can the macro from the global scope, yes
18:37:41FromDiscord<auxym> well it will at the module scope, nim doesn't have "true" globals
18:38:13FromDiscord<auxym> (edit) "can" => "call it"
18:38:54FromDiscord<@thatrandomperson5-6310e3b26da03> Ill try, but remember is has to be accessible at compile-time from other macros↵(@auxym)
18:41:15FromDiscord<auxym> hm I'm not sure you'll have access to the table from other macros
18:41:40FromDiscord<auxym> you can write a regular proc that takes NimNode and returns a table though.
18:42:43FromDiscord<4zv4l> In reply to @auxym "you should use `byte(u": But I get an error with that because the number is too big to enter in a uint8
18:43:24FromDiscord<scipio> https://media.discordapp.net/attachments/371759389889003532/1061716770215432353/image.png
18:43:25FromDiscord<auxym> In reply to @4zv4l "But I get an": then mask it, before the shift
18:43:29FromDiscord<scipio> here we go 😉
18:46:42FromDiscord<4zv4l> In reply to @auxym "then mask it, before": Mask ?
18:46:50FromDiscord<jmgomez> In reply to @@thatrandomperson5-6310e3b26da03 "Ill try, but remember": use `macrocache`
18:47:12FromDiscord<auxym> sent a code paste, see https://play.nim-lang.org/#ix=4kFq
18:50:24om3gainternal error: genAssignment: tyUncheckedArray <--- This is bad, right?
18:59:33FromDiscord<4zv4l> sent a code paste, see https://paste.rs/ZHc
19:00:08FromDiscord<4zv4l> sent a code paste, see https://paste.rs/Zrs
19:00:09FromDiscord<4zv4l> this one works then
19:00:17FromDiscord<4zv4l> but having to precise the type is sick
19:00:20FromDiscord<auxym> `'u32` is shorter but yeah
19:01:23FromDiscord<4zv4l> In reply to @auxym "`'u32` is shorter but": this syntax is nice tho
19:01:30FromDiscord<⚶ Zeno> i use `<whatever> shr <24/16/8/0> and 0xFF`, you can use that
19:01:36FromDiscord<⚶ Zeno> (edit) "i use `<whatever> shr <24/16/8/0> and 0xFF`, you can use that ... " added "for your purpose"
19:01:40FromDiscord<⚶ Zeno> i think it seems more
19:01:42FromDiscord<⚶ Zeno> readable
19:01:43FromDiscord<⚶ Zeno> (edit) "readable ... " added "?"
19:01:48FromDiscord<4zv4l> why don't they directly keep that for the type name ?↵`u8` instead of `uint8`↵`i8` instead of `int8`
19:02:34FromDiscord<auxym> you can define them yourself if you want that. `type i8 = int8`
19:03:50FromDiscord<4zv4l> well yeah, extra work xD
19:04:41FromDiscord<4zv4l> sent a long message, see http://ix.io/4kFu
19:05:08FromDiscord<auxym> i guess most people don't feel the need? If you want it it
19:05:32FromDiscord<auxym> it's like 8 lines, publish it on nimble and it's just an import away anytime you want it
19:05:38FromDiscord<ambient> ushort, ulong, uwhatever
19:05:59FromDiscord<ambient> uint seems much more exact and is fast to type
19:06:14FromDiscord<4zv4l> In reply to @auxym "it's like 8 lines,": yeah, I need to understand how nimble do to find a packet github without even knowing it's from github
19:06:27FromDiscord<4zv4l> (edit) "packet" => "package on "
19:06:44FromDiscord<4zv4l> or it doesn't↵idk
19:06:46FromDiscord<4zv4l> I'll check
19:07:46FromDiscord<4zv4l> is nimble like the go package manager ?↵like doesn't rely on any special platform ?
19:07:53FromDiscord<auxym> In reply to @4zv4l "yeah, I need to": nimble has a registry, you have to PR it if you want to get on there
19:08:05FromDiscord<auxym> otherwise you can `nimble install` a github url directly
19:08:07FromDiscord<4zv4l> oh, no way to do it decentralised ?
19:08:14FromDiscord<4zv4l> perfect
19:08:42FromDiscord<auxym> https://github.com/nim-lang/packages
19:10:19FromDiscord<pyryrin> when to use `object` and when `ref object`?
19:12:36FromDiscord<auxym> In reply to @pyryrin "when to use `object`": https://internet-of-tomohiro.netlify.app/nim/faq.en.html#type-when-to-use-ref-object-vs-plain-object-qmark
19:13:26FromDiscord<auxym> usually plain object by default unless you have a specific reason to need ref
19:13:29FromDiscord<jtv> ref essentially means when you pass it around, anyone that can access the fields can set the fields. Without ref, people will get copying semantics, unless passed to a parameter of type var YourObject
19:14:06*arkurious quit (Read error: Connection reset by peer)
19:14:23FromDiscord<jtv> The language is smart enough to not do extra copying unless necessary, so definitely good not to use ref by default
19:15:08FromDiscord<jmgomez> I would empathize that ref is stored on the heap and object is stored on the stack though
19:16:15FromDiscord<jtv> I don't think that's strictly true, is it? The language automatically figures out based on the context. And certainly if you have a non-ref object embedded in a ref object you still get the same semantics
19:17:44FromDiscord<auxym> yes, it is strictly true, to the best of my knowledge
19:18:05FromDiscord<4zv4l> sent a code paste, see https://paste.rs/rap
19:18:05FromDiscord<pyryrin> should it be ref object if the type contains string or some dynamic memory types? because they take long to copy?
19:18:16FromDiscord<4zv4l> is that normal ? or distinct is for when passing to a function ?
19:18:44FromDiscord<jtv> No, that's not a consideration
19:19:37FromDiscord<4zv4l> wdym ?
19:21:00FromDiscord<auxym> I think they were replying to @pyryrin
19:21:24FromDiscord<auxym> @4zv4l I'm not sure how typeof handles aliases.
19:21:25FromDiscord<pyryrin> i dont understand what he mean
19:22:03FromDiscord<auxym> he means that performance should not be a consideration when choosing between ref or plain object
19:22:29FromDiscord<auxym> (IMO: in some cases it could be a consideration, but by default you should still use plain object)
19:22:49FromDiscord<pyryrin> i thought the whole point was performance
19:25:55FromDiscord<jtv> No, it's more about mutability
19:26:29FromDiscord<auxym> the point is many-to-one relationships, heap storage (stack may be size limited), OOP, and sometimes performance
19:26:34FromDiscord<@thatrandomperson5-6310e3b26da03> Can you use the borrow pragma on an iterator?
19:26:41FromDiscord<jtv> It can occasionally make a difference, but objects are not copied if you pass them around, tuntil there's an assignment
19:27:11FromDiscord<auxym> refs can also be slower in some cases, because of allocation and deallocation overhead. hence it should be on a case by case basis
19:27:51FromDiscord<cow> refs can also be faster, for example if you have many of them in a seq
19:28:22FromDiscord<cow> (edit) "refs can also be faster, for example if ... you" added "they hold a lot of data"
19:28:30FromDiscord<cow> (edit) "refs can also be faster, for example if they hold a lot of data ... you" added "and"
19:28:34FromDiscord<jtv> Yeah, lots of small allocations and deallocations can always be an issue, but generally it won't matter in most cases. Good optimization practices are to build the most natural way, and then profile and optimize based on actual data
19:28:48FromDiscord<jtv> Instead of guessing about your bottlenecks 🙂
19:29:16FromDiscord<cow> and with cpu caches, large objects can fill the cache with junk
19:29:42FromDiscord<cow> it's hard to reason about yeah
19:29:47FromDiscord<jtv> Yes, there's so much complexity beneath the abstractions you're using, it's much better to use data
19:30:46FromDiscord<jtv> And "conventional wisdom" on what's faster is often YEARS out of date due to various changes under the various hoods of all the things you're building on top of
19:31:08FromDiscord<auxym> In reply to @jtv "Yeah, lots of small": agreed entirely
19:32:53FromDiscord<cow> In reply to @jtv "No, it's more about": and ownership i guess, if ownership is unclear and GC is needed
19:35:16FromDiscord<@thatrandomperson5-6310e3b26da03> How do i make a compile time var, not const, i keep on getting “Cannot evaluate at compile time”
19:36:07FromDiscord<jtv> Well, depends on the context, like if you're calling a function from a macro, you don't have to do anything. But you can just do a `static:` block and do a var in it
19:37:01FromDiscord<@thatrandomperson5-6310e3b26da03> But then it’s not global context and my procs can’t find it↵(@jtv)
19:37:27FromDiscord<jtv> Yeah, sure, because it's compile-time
19:37:39FromDiscord<jtv> Set at compile time but available at run-time is what const is for
19:38:18FromDiscord<enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=4kFF
19:38:37FromDiscord<jtv> If you do const x = someCode(), someCode() gets run at compile time
19:38:50FromDiscord<jtv> Otherwise, x could never hold a const 🙂
19:39:20FromDiscord<jtv> const variables get put in a section of the binary that is absolutely read-only.
19:40:33FromDiscord<@thatrandomperson5-6310e3b26da03> > ↵> If you do const x = someCode(), someCode() gets run at compile time↵> I need to call some procs on x that require `var x`
19:40:57FromDiscord<jtv> Yeah, have somefunc() declare it as a var.
19:42:12FromDiscord<enthus1ast> thatrandomperson5 (not logged in or am I? )\:↵https://play.nim-lang.org/#ix=4kFH
19:42:17FromDiscord<@thatrandomperson5-6310e3b26da03> sent a code paste, see https://paste.rs/oOR
19:42:38FromDiscord<@thatrandomperson5-6310e3b26da03> How?↵(@jtv)
19:44:14FromDiscord<jtv> https://play.nim-lang.org/#ix=4kFI
19:44:41FromDiscord<jtv> The computeAtCompileTime() function is where your compile time code would go
19:45:13FromDiscord<jtv> And as long as it only calls things that CAN run at compile time, then it will work and be compile time code, even if it looks like 'normal' code
19:45:22FromDiscord<enthus1ast> thatrandomperson5 (not logged in or am I? )\: wanted a compile time global or?
19:45:35FromDiscord<jtv> You will get an obvious error if you do something that cannot be done at compile time
19:50:43FromDiscord<@thatrandomperson5-6310e3b26da03> Just found out the hanging is unrelated to this issue, thanks for the help
20:20:04FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4kFR
20:21:05FromDiscord<enthus1ast> you could overload `=`
20:22:13FromDiscord<4zv4l> it wouldn't use the heap right ?
20:22:24FromDiscord<4zv4l> since the string is hard coded
20:23:04FromDiscord<jtv> https://play.nim-lang.org/#ix=4kFS
20:23:16FromDiscord<jtv> You can skip the const if you make it a macro or template
20:26:18FromDiscord<enthus1ast> sent a code paste, see https://paste.rs/rdw
20:26:27FromDiscord<4zv4l> In reply to @jtv "https://play.nim-lang.org/#ix=4kFS": idk if you checked the result but
20:26:30FromDiscord<4zv4l> doesn't work for me
20:26:30FromDiscord<4zv4l> xD
20:26:44FromDiscord<4zv4l> In reply to @enthus1ast "mh seems that overloading": hmmmmm
20:26:55FromDiscord<4zv4l> well it's alright↵was just for testing
20:28:48FromDiscord<jtv> No I didn't, try this: https://play.nim-lang.org/#ix=4kFW
20:28:52FromDiscord<enthus1ast> = does not work but
20:28:59FromDiscord<enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=4kFY
20:29:20FromDiscord<enthus1ast> maybe there is a way with = but idk
20:30:24FromDiscord<jtv> IDK shouldn't take long to figure out, the library def has a way to go from a string to an array of bytes, just need to look it up
20:30:34FromDiscord<jtv> And then a macro or whatever will work fine
20:31:37FromDiscord<enthus1ast> or a little bit more type explicit\:
20:31:45FromDiscord<enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=4kG0
20:36:32FromDiscord<huantian> Why are you overloading =
20:36:44FromDiscord<huantian> Can’t we just make a proc that converts a static string to an array
20:37:39FromDiscord<enthus1ast> because he asked↵(@4zv4l)
20:38:05FromDiscord<enthus1ast> yeah↵(@huantian)
20:38:07FromDiscord<4zv4l> yeah I wanted something c-like
20:38:11FromDiscord<4zv4l> xD
20:38:41FromDiscord<4zv4l> sorry for bothering 👉 👈 xD
20:39:01FromDiscord<jtv> Uh, just use cstring then?
20:39:45FromDiscord<jtv> I mean, even the string type is just going to be an array of chars w/ an extra field for length. Converting to a cstring just returns a pointer to the start of the array
20:40:04FromDiscord<jtv> So ask yourself why you want to do this 🙂
20:41:42FromDiscord<4zv4l> but cstring in Nim are still on the heap right ?
20:41:58Zevvs[0].addr is your array[char]
20:42:02Zevvon the heap
20:42:27Zevvwell, no guarentees btw about that.
20:42:28FromDiscord<4zv4l> but since the string is hard coded↵would still be on the heap ?
20:42:37Zevvright
20:42:40FromDiscord<4zv4l> not be a pointer to the string in the binary in rodata ?
20:42:43Zevvor even on the stack, if it comes from C
20:42:47Zevvyou can't tell. it's just a pointer
20:42:53FromDiscord<jtv> If you declare it as a local, and there's no chance a reference is leaving the function, nim should stick it on the stack
20:43:00FromDiscord<jtv> If it's a string
20:43:17Zevvcheck the C source for that
20:43:52FromDiscord<jtv> I know there's definitely been work on lifetime analysis to do such things. Might only be ARC/ORC work though, IDK
20:44:24Zevvstrings in nim do not go on the stack
20:44:37Zevvcheck the generated C code
20:44:53Zevvhttps://play.nim-lang.org/#ix=4kG5
20:45:29Zevvglobal: `static const struct {NI cap; NIM_CHAR data[5+1]; } ... = { 5 | NIM_STRLIT_FLAG, "Hello" };
20:45:48Zevvand that "Hello" will be put in .rodata by the C compiler, typically
20:46:08FromDiscord<4zv4l> how can I check the C code↵in `.cache/nim/<folder>/.c` ?
20:46:15Zevvyes
20:46:25Zevvthe file names suck though
20:46:37Zevvfoo.nim will be @mfoo.nim.c
20:47:21Zevvif you've never looked at nim generated C: it's not a fun job
20:47:38FromDiscord<4zv4l> yes I see that
20:47:38FromDiscord<4zv4l> xD
20:47:39Zevvbut it's not ment for reading, right
20:47:40FromDiscord<4zv4l> ahahahah
20:47:52Zevvafter the first few weeks your eys will stop bleeding
20:48:00FromDiscord<4zv4l> I don't find the NimMain
20:48:07FromDiscord<4zv4l> if that's where the code is supposed to be
20:48:10FromDiscord<4zv4l> but↵` STRING_LITERAL(TMPwklBah9a4x1aFG9cTW1Wh5Q_2, "Hello, World !", 14);`
20:48:22Zevvit's there
20:48:23Zevvlook for `N_CDECL(void, NimMain)(void)`
20:49:15FromDiscord<4zv4l> pattern not found
20:49:16FromDiscord<4zv4l> xD
20:49:29FromDiscord<4zv4l> `N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) `
20:49:30FromDiscord<4zv4l> this ?
20:49:33Zevvyou and I are on different nim versions, so you're probably right
20:49:37Zevvjust follow from C main()
20:50:03FromDiscord<4zv4l> `N_CDECL(void, NimMain)(void)`
20:50:04FromDiscord<4zv4l> this
20:50:06FromDiscord<4zv4l> I guess
20:50:22Zevvmain() -> NimMain() -> PreMain() + NimMainInner() -> NimMainModule()
20:50:46FromDiscord<4zv4l> oh my eyes
20:50:47FromDiscord<4zv4l> xD
20:50:53Zevvthe C compiler will throw most of that away. C compilers are amazing
20:50:55FromDiscord<4zv4l> https://tenor.com/view/my-eyes-spongebob-squarepants-spongebob-my-eyes-gif-13564660
20:51:39FromDiscord<4zv4l> In reply to @Zevv "the C compiler will": indeed !
20:53:09FromDiscord<4zv4l> sent a code paste, see https://paste.rs/rWX
20:53:09FromDiscord<4zv4l> and the loop and echo ?
20:53:11FromDiscord<4zv4l> i've no idea
20:53:13FromDiscord<4zv4l> xD
20:53:25FromDiscord<4zv4l> I tried to look for `echo`
20:53:26Zevvall the steps are there for you to inspect
20:53:40Zevv`echoBinSafe()`
20:55:59*jvinet quit (Remote host closed the connection)
20:56:23FromDiscord<4zv4l> that's in another file right ?
20:57:14Zevvthat'll be in ...system.nim.c
20:58:35Zevvit basically collapses to fwrite() of your data followed by fwrite() of a newline, with a lock around it
21:01:28FromDiscord<System64 ~ Flandre Scarlet> Hi↵https://plugins.jetbrains.com/plugin/15128-nim↵Is this plugin good?
21:21:47FromDiscord<ElegantBeef> sent a code paste, see https://paste.rs/RJX
21:43:56FromDiscord<sabrus> Hi, is there an compiler option in Nim to open an interactive console (a.k.a REPL) with the results of compiling the module, as in python -i my_awesome_module.py ?
21:45:03FromDiscord<EyeCon> In reply to @sabrus "Hi, is there an": If you install inim, you can do (IIRC) `inim -s myfile.nim`
21:45:07FromDiscord<jtv> That I don't know, but on nimble there's a package called "inim" which gives you an interactive shell. It's not quite the same because, for instance, once you define a var in the global namespace, you can't redefine the type. And it's got some oddities for entering functions on the command line
21:45:11FromDiscord<jtv> But it's good enough
21:45:52FromDiscord<sabrus> In reply to @EyeCon "If you install inim,": thx !
22:20:01FromDiscord<sOkam!> I heard the statement that if you use gc:none, you "lose access to std libraries"↵How can I know which parts of std/ are going to be out of reach, or which parts would work, in more practical terms?
22:27:48FromDiscord<Elegantbeef> If the module or types use `seq` or `string` or `ref` it's going to be off limits
22:28:01FromDiscord<Elegantbeef> When you use something that isnt freed with `gc:none` the compiler tells you
22:28:14FromDiscord<Elegantbeef> Though yet again i would suggest using `--gc:arc` even if you're learning manual memory management
22:36:00FromDiscord<sOkam!> why arc for mm?
22:36:53FromDiscord<Elegantbeef> Cause it's identical to manually managing memory
22:37:04FromDiscord<Elegantbeef> you can still use the stdlib and `ref`
22:37:15FromDiscord<Elegantbeef> well everything that's not cyclic
22:37:53FromDiscord<sOkam!> but isn't arc automatic memory management in some way?
22:38:09FromDiscord<Elegantbeef> Arc is literally identical to what you'd do with manual memory management
22:39:27FromDiscord<sOkam!> i don't get why, i thought arc was reference counting
22:39:36FromDiscord<Elegantbeef> Arc inserts destructors
22:39:50FromDiscord<Elegantbeef> So you can manual manage memory without having to manually calling `destroy`
22:41:06FromDiscord<sOkam!> im not sure if i understand enough of the topic to grasp the implications of what you mean
22:41:20FromDiscord<Elegantbeef> Arc means you do not need to manually call destructors
22:41:25FromDiscord<Elegantbeef> You can write hooks and handle things sanely
22:45:07FromDiscord<@thatrandomperson5-6310e3b26da03> How to i prevent xmlparser from stripping the text data, i need it un-stripped
22:47:04FromDiscord<Gumbercules> In reply to @sOkam! "im not sure if": Without arc / orc you need to make your own heap allocations with alloc
22:47:09FromDiscord<Gumbercules> And company
22:47:19FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4kGr
22:47:20FromDiscord<Gumbercules> And subsequently free them
22:47:34*adium quit (Ping timeout: 260 seconds)
22:47:39FromDiscord<Elegantbeef> Here is an example of why you'd use arc
22:47:39FromDiscord<Elegantbeef> The above compiles and frees it automatically, but you're still managing manually
22:47:55FromDiscord<Gumbercules> ARC allows you to essentially RAII
22:48:08FromDiscord<Gumbercules> Similar to C++
22:48:34*adium joined #nim
22:50:04FromDiscord<Elegantbeef> The benefit of having arc in the above example is your strings are managed for you
22:50:05FromDiscord<Elegantbeef> There literally is no reason not to use Orc/Arc with manual memory management
22:50:47FromDiscord<Gumbercules> Well
22:50:56FromDiscord<Gumbercules> There are reasons but
22:51:15FromDiscord<Elegantbeef> If your types dont use them then you dont have any overhead
22:51:23FromDiscord<Elegantbeef> Even embedded users use arc
22:52:33FromDiscord<Gumbercules> Sure but there are still certain things you can't do with arc/orc
22:53:00FromDiscord<Gumbercules> Like provide a specific allocator for a specific allocation
22:53:08FromDiscord<Elegantbeef> I mean you can
22:53:33FromDiscord<Elegantbeef> Not apart of arc/orc directly but you can certainly make a type using arc and it's own allocator
22:53:45FromDiscord<Gumbercules> That's not what I mean
22:54:07FromDiscord<Gumbercules> I can't say allocate this Nim string using this specific allocator
22:54:18FromDiscord<Elegantbeef> Yes i dont disagree there
22:54:30FromDiscord<Gumbercules> That would be lovely
22:54:31FromDiscord<Elegantbeef> But for non Nim gc'd types you certainly can
22:54:35FromDiscord<Gumbercules> Yeah
22:54:38FromDiscord<Gumbercules> Fair enough
22:55:57FromDiscord<Elegantbeef> https://github.com/beef331/nimtrest/blob/master/remoterefs.nim#L5-L33 i've tried my damndest to make it work with Nim's gc'd types
22:55:57FromDiscord<scipio> sent a code paste, see https://paste.rs/yL0
22:55:57FromDiscord<Elegantbeef> But yea it's a shame you cannot
22:55:58FromDiscord<Elegantbeef> Nim really needs some mechanism to override the allocator used like `string[AllocProc =..., ReallocProc = ..., DeallocProc = ...]`
22:56:12FromDiscord<Gumbercules> Yup I agree
22:56:16FromDiscord<Elegantbeef> You change your default indent to using `spaces`
22:56:42FromDiscord<Gumbercules> Even just having an optional argument for every allocation would be enough
22:56:51FromDiscord<Elegantbeef> No it wouldnt
22:56:56FromDiscord<Gumbercules> Use them concepts
22:57:09FromDiscord<Gumbercules> Why not? As long as they all fulfill the same contract
22:57:16FromDiscord<Elegantbeef> strings can grow
22:57:21FromDiscord<Elegantbeef> So they'd need to track their allocator
22:57:26FromDiscord<Gumbercules> So have a realloc
22:57:37FromDiscord<Gumbercules> Oh yeah
22:57:46FromDiscord<Elegantbeef> This information is best tied to the type so it works with Arc
22:57:53FromDiscord<Gumbercules> Well I mean you could still pass one and the runtime could track it
22:58:00FromDiscord<Elegantbeef> Nah no reason to runtime track it
22:58:04FromDiscord<Elegantbeef> You can statically track it
22:58:24FromDiscord<Gumbercules> Well however someone wants to do it
22:58:29FromDiscord<Elegantbeef> `RemoteRefs` is proof that the best way to do it is to generalise allocation procedures and allow optional ones
22:58:48FromDiscord<Elegantbeef> Well when you statically track it you can make the allocation procedures `inline` and then the compiler can inline them if it sees fit
22:58:56FromDiscord<Gumbercules> I don't even know what remoterefs is but I'm going to find out now
22:58:59FromDiscord<Elegantbeef> When you runtime track them allocation calls are always a pointer proc away
22:59:21FromDiscord<Elegantbeef> Remote refs is just a Arc managed type that you supply your `alloc` and `dealloc` procedures to
22:59:35FromDiscord<Elegantbeef> It's like Odin/Zig contexts but type attached instead of an argument
22:59:38FromDiscord<Gumbercules> Gotcha
22:59:42FromDiscord<Elegantbeef> It's much more sane imo since it works with RAII
23:00:08FromDiscord<Elegantbeef> Since they're type attached they get all the benefits of a procedure being statically called, which means they can be inlined called
23:00:17FromDiscord<Elegantbeef> They also dont increase the type's size
23:01:13FromDiscord<Elegantbeef> They mostly appeared due to Girvo talking about wanting to have a reference that is allocated using an embeded's SPI allocator
23:01:13FromDiscord<Elegantbeef> Which is a persistent storage
23:01:30FromDiscord<Elegantbeef> So the downside is of course since we cannot provide allocators for string and friends only stack types can be used sensibly
23:02:30FromDiscord<Gumbercules> In reply to @Elegantbeef "So the downside is": Yeah 😢
23:02:32FromDiscord<sOkam!> In reply to @scipio "n00b question (I've installed": you need to configure sublime to not insert tabs. that's an assumption that doesn't work in many cases, and nim is one example of such situation
23:02:48FromDiscord<Elegantbeef> I mean 99% of editors insert spaces by default
23:02:57FromDiscord<sOkam!> (edit) "that's" => ""the user will only need tabs" is" | ""the user will only need tabs" isan ... assumption" added "editor"
23:03:06FromDiscord<Elegantbeef> Very few editors insert tabs by default, i've never used one that has
23:03:19FromDiscord<Elegantbeef> Even VS uses(d) spaces
23:03:33FromDiscord<auxym> notepad.exe
23:04:24FromDiscord<sOkam!> i started with sublime too, and i don't see it as something foreign. but i moved quickly to vscode, and soon after removed tabs of my workflow entirely in every lang, so i don't have a good perspective
23:04:49FromDiscord<scipio> sent a code paste, see https://play.nim-lang.org/#ix=4kGw
23:04:58FromDiscord<scipio> .. seems to work
23:05:02FromDiscord<sOkam!> yep! that's it 🙂
23:05:24FromDiscord<Elegantbeef> But yea gumber if interested in seeing it actually used i do have this test https://github.com/beef331/nimtrest/blob/master/tremoterefs.nim
23:05:48FromDiscord<Elegantbeef> It's a cool idea overall, but just sad about the whole Nim thing 😄
23:09:00FromDiscord<sOkam!> @ElegantBeef @Gumbercules i understand what you mean by using arc, but my goal is to learn C/Zig style of memory management, except with the beauty of Nim code as the main tool instead
23:09:26FromDiscord<jtv> "style"?
23:09:27FromDiscord<sOkam!> If it was any sort of "production" code, I would 100% go arc minimum
23:09:34FromDiscord<Gumbercules> Zig allows for custom allocators
23:09:36FromDiscord<jtv> C++ has a style, RAII
23:10:25FromDiscord<sOkam!> In reply to @jtv ""style"?": John Carmack C code has a style, and Zig allows custom allocators as mentioned. My goal is learning that, to be specific
23:10:26FromDiscord<Gumbercules> Nim isn't as flexible but you can still use Nims manual allocation procs and Nims general purpose allocator
23:10:31FromDiscord<jtv> But C programs are largely handled ad-hoc. Depends on the program, but there's not really a preferred "style"
23:10:55FromDiscord<Gumbercules> There are a lot of C libraries that allow you to provide your own allocation callbacks
23:11:10FromDiscord<Gumbercules> And they will default to using malloc
23:11:13FromDiscord<jtv> 100%, and a wealth of custom allocators too
23:11:14FromDiscord<Gumbercules> Or their own allocator
23:11:17FromDiscord<jtv> Some pretty good ones
23:11:30FromDiscord<Gumbercules> Nim isn't as flexible hete
23:11:33FromDiscord<jtv> Esp for multi-threaded programs
23:11:53FromDiscord<Gumbercules> But you can patch the stdlib and use mimalloc or whatever
23:12:14FromDiscord<Gumbercules> You just can't say, for this specific string allocation use my linear allocator
23:12:24FromDiscord<Gumbercules> And for the next one use Nims
23:12:43FromDiscord<jtv> Yeah, I do crap like that all the time in C, heh
23:12:53FromDiscord<Gumbercules> Of course nothing is stopping you from reserving a bunch of heap space and allocating from there
23:13:13FromDiscord<Gumbercules> It's just a contrived example
23:13:45FromDiscord<jtv> Yeah, and you could definitely hit the lower-level memory management interface to get mapped pages, etc. directly from the OS
23:19:47FromDiscord<Gumbercules> Vale's promising a lot of very interesting memory management facilities
23:21:08FromDiscord<Gumbercules> Honestly if you want to learn about manual memory management, just write some C
23:21:39FromDiscord<jtv> Yeah I agree w/ that. You'll learn a lot more about the system underneath
23:21:40FromDiscord<Gumbercules> Or look at well authored C libraries
23:24:27FromDiscord<sOkam!> In reply to @Gumbercules "Honestly if you want": I've dealt with C nightmare enough for a lifetime. I would choose Nim every single time for every single task, unless I'm forced to (which im not)
23:25:23FromDiscord<sOkam!> Low level doesn't need to mean ugly code. For me, personally, C is super ugly. I like the minimalism a lot, but Nim does have that too, so nothing lost for me personally
23:25:24FromDiscord<jtv> Well, C is definitely hard to write well, and even when you get good at it, bugs can be incredibly subtle and take a very long time to debug. A huge part of that though is the manual memory management 🙂
23:25:26FromDiscord<Elegantbeef> I get you're cloning quake, but that doesnt mean you have to write code like quakes
23:25:41FromDiscord<Elegantbeef> I personally do not get why anyone wouldnt use arc even learning manual memory management
23:25:46FromDiscord<jtv> Agreed
23:26:04FromDiscord<jtv> If you're doing manual memory management well, it'd often look a heck of a lot like arc
23:26:10FromDiscord<Elegantbeef> You can use whatever allocator you want per a type, and you dont need to pretend it's C
23:26:57FromDiscord<Elegantbeef> Though i personally do not get the want to learn manual memory management pass the basics of allocating and freeing and how that works
23:27:05FromDiscord<Elegantbeef> There isnt much there
23:28:16FromDiscord<jtv> The specifics of storage management algorithms can be interesting, but beyond that, 100%
23:28:17FromDiscord<sOkam!> In reply to @Elegantbeef "I get you're cloning": Sometimes you have to understand the intricacies of john's code to even begin understanding the overview of his stuff. He was way way too deep into low level code, and from an artist brain like mine grasping that is extremely hard
23:29:24FromDiscord<sOkam!> It's hard to explain without having experienced it. His stuff is just hard to follow without his level of knowledge, so I'm just trying to lessen the knowledge gap as much as I can
23:32:06*jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…)
23:32:14FromDiscord<jtv> I skimmed through the quake code once, it looked like normal C code. I remember they did have a custom zone malloc, but even that was straightforward
23:34:43FromDiscord<sOkam!> skimming is hella easy. working with it daily is a different story. at least that's the case for q3 stuff, which is what i keep myself with. i rarely open q1, so i have no clue of how different it is. all i know is that q3 is super hard to follow, unless you really know what you are doing (in which case it looks a lot like normal c code, sure... but that's because you already have the knowledge)
23:36:08FromDiscord<jtv> Well, I've been mainly a C developer for about 30 years, but I just spent a few mins again, the C in their gpl'd repos all look like regular well-written C code
23:37:06FromDiscord<sOkam!> i just passed my first year of coding in any lang, and it was all self taught starting with johns code from day1. that probably explains a lot
23:37:31FromDiscord<sOkam!> plus i have an artist brain, low level stuff is not intutive
23:37:43FromDiscord<sOkam!> (edit) "intutive" => "intuitive"
23:38:05FromDiscord<sOkam!> (edit) "plus i have an artist brain, low level stuff is not intuitive ... " added "for me"
23:38:51FromDiscord<jtv> Yeah, even back when C/C++ was often a first language, people who wrote in them every day for a year still didn't have that great a mastery of the language
23:39:04FromDiscord<sOkam!> yeah i figure
23:39:16FromDiscord<jtv> If you want to get good at C, it's worth reading the book, "Deep C Secrets"
23:39:38FromDiscord<sOkam!> i'd rather learn deep nim secrets. it fits my brain much better
23:39:46FromDiscord<sOkam!> 🙂
23:39:54FromDiscord<jtv> Well, it would help you understand id code better 🙂
23:40:13FromDiscord<sOkam!> that's tru. will keep it in mind ✍️
23:51:39FromDiscord<RukkaPlus> Hi there! Do you know a way to download the standard library documentation for offline use?
23:52:55FromDiscord<sOkam!> i've noticed that Nim uses uncheckedArrays for dealing with most low level things↵What's different between having a, lets say, `ptr uint8` vs an `uncheckedArray[uint8]`?
23:53:00FromDiscord<Elegantbeef> https://forum.nim-lang.org/t/9800
23:53:16FromDiscord<Elegantbeef> The difference between `ptr UncheckedArray[T]` and `ptr T` is that Nim is statically typed
23:53:25FromDiscord<Elegantbeef> It says "Not all pointers are an array"
23:55:41FromDiscord<jtv> Yeah, that's one oddity of C that is hard to grok, especially because strings are declared as "char ", leads people to think that pointers are effectively arrays. Semantically, that's mostly (but not entirely) true in C, but it's a horrible habit
23:56:32FromDiscord<sOkam!> i thought that was the case, lol
23:56:44FromDiscord<sOkam!> but yeah, i think i get what you mean
23:57:17FromDiscord<sOkam!> so ptr T could be just a single item, or many. but array would mean more than one by definition?↵or am i missing something
23:57:31FromDiscord<Elegantbeef> Correct
23:57:38FromDiscord<Elegantbeef> In Nim you'd use an unchecked array if the data is a contiguous collection of T
23:57:54FromDiscord<Elegantbeef> In C you'd use `T` regardless if it was one or many
23:58:06FromDiscord<sOkam!> ic
23:58:31FromDiscord<Elegantbeef> Nim is more 'exact' in it's typing