<< 13-12-2021 >>

00:00:09*tk quit (Quit: Well, this is unexpected.)
00:00:35*tk joined #nim
00:01:33FromDiscord<Yardanico> it does move the memory @AmjadHD
00:01:44FromDiscord<Yardanico> if you check the address it's different because that's the seq header
00:02:04FromDiscord<Yardanico> ah right it only moves memory with arc
00:02:11FromDiscord<Yardanico> that's expected though, arc/orc is better with optimizations
00:02:29FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=3HUT
00:02:37FromDiscord<Yardanico> or --gc:orvc
00:02:38FromDiscord<Yardanico> (edit) "--gc:orvc" => "--gc:orc"
00:03:57FromDiscord<Yardanico> the only "overhead" is a stack allocation for the seq header, which isn't much
00:04:24FromDiscord<Elegantbeef> Ah right forgot to check arc/orc
00:05:11FromDiscord<AmjadHD> sent a code paste, see https://play.nim-lang.org/#ix=3HUV
00:05:27FromDiscord<Yardanico> yes, it's just an alias for `int`
00:06:43*krux02 quit (Remote host closed the connection)
00:08:19FromDiscord<AmjadHD> In reply to @Yardanico "or --gc:orc": confirmed, it moves the data with arc/orc and not without it.
00:08:31FromDiscord<Yardanico> that's to be expected, arc/orc has a lot of optimizations
00:08:37FromDiscord<Yardanico> it does data flow analysis too
00:08:51FromDiscord<Yardanico> you might want to give https://nim-lang.org/docs/destructors.html a read
00:09:57*averell quit (Remote host closed the connection)
00:10:25FromDiscord<AmjadHD> In reply to @Yardanico "you might want to": I read that, it's really interresting 🙂
00:12:18FromDiscord<DMI-1407> just a silly question
00:13:09FromDiscord<DMI-1407> if i write `obj.methodName(args)` or `methodName(obj, args)`↔then can i also write `obj.methodName()` instead of `obj.methodName` ?
00:13:28FromDiscord<Yardanico> yes if methodName has an overload with 1 argument
00:13:46FromDiscord<DMI-1407> if methodname has 0 args ?
00:14:02FromDiscord<Yardanico> but then why would you call it with `obj`?
00:14:15FromDiscord<Yardanico> `obj.methodName()` means `methodName(obj)`
00:14:25FromDiscord<Sabena Sema> In reply to @DMI-1407 "if methodname has 0": its not much of a method then
00:14:32FromDiscord<DMI-1407> e.g. i wrote a length() methodto get size of whatever obj stores
00:14:43FromDiscord<DMI-1407> (edit) "methodto" => "method to"
00:14:44FromDiscord<Yardanico> yes, but it still needs the `obj` argument, no?
00:14:44FromDiscord<Sabena Sema> yeah, that would have one arg
00:14:51FromDiscord<DMI-1407> ah ok
00:15:11FromDiscord<DMI-1407> but syntax allows me to write `obj.methodName()` <-- brackets
00:15:15FromDiscord<DMI-1407> ?
00:15:29FromDiscord<Yardanico> yes, you can use parens, that's the usual way
00:15:31FromDiscord<Sabena Sema> in nim “methods” are multimethods (and rarely used) and what other langs call methods are just functions with the “self” type as the first argument
00:15:41FromDiscord<Yardanico> In reply to @Sabena Sema "in nim “methods” are": not quite correct
00:15:55FromDiscord<Yardanico> Nim has normal methods via `method`, multimethods are deprecated since 0.20 and must be enabled with a compiler flag
00:16:07FromDiscord<Sabena Sema> oh, things have changed i guess
00:16:40FromDiscord<DMI-1407> i just try to find a way to differ calls to an attributefrom an obj vs calling a method from an obj without having to know the obj
00:16:48FromDiscord<DMI-1407> (edit) "attributefrom" => "attribute from"
00:16:59FromDiscord<DMI-1407> (in case method has just 1 arg)
00:17:07FromDiscord<DMI-1407> (edit) "arg)" => "arg (which is the obj))"
00:17:47FromDiscord<Sabena Sema> where does the vtable go?
00:17:54FromDiscord<Yardanico> not sure I understand you, but if you want to _differentiate_ between method calls vs dot access, you'll need to use https://nim-lang.github.io/Nim/manual_experimental.html#special-operators-dot-operators quite a lot
00:18:10FromDiscord<Yardanico> you'll have to override both `.()` and `.`
00:18:19FromDiscord<Yardanico> so that you can "treat" field access and calls differently
00:18:31FromDiscord<Sabena Sema> and can i use methods on a normal object if their first parameter is “ref ThatType”
00:18:37FromDiscord<Yardanico> yes
00:18:47FromDiscord<Yardanico> In reply to @Sabena Sema "where does the vtable": nim doesn't use vtables
00:19:06FromDiscord<Sabena Sema> oh, its still table based even for “normal” methods?
00:19:26FromDiscord<Yardanico> not sure what you mean by "normal" methods, but kind of yes
00:19:31FromDiscord<Yardanico> I don't know exactly how method dispatch is implemented
00:19:49FromDiscord<Yardanico> also the implementation of methods is actually much slower for arc/orc but I guess that'll be eventually fixed :D
00:19:49FromDiscord<Yardanico> https://github.com/nim-lang/Nim/issues/18612
00:20:01FromDiscord<Elegantbeef> It's a big elif statement
00:20:05FromDiscord<Yardanico> as an alternative there's https://github.com/yglukhov/iface for interface-like functionality
00:20:13FromDiscord<Yardanico> In reply to @Elegantbeef "It's a big elif": not with arc/orc
00:20:21FromDiscord<Yardanico> ah, right, it still is, but a lil different
00:21:13FromDiscord<Elegantbeef> It's doing a bunch of `isObj` using the `mtype` information
00:21:31FromDiscord<Yardanico> yeah, that's with refc so it uses rtti
00:21:40FromDiscord<Yardanico> but with arc it does string comparisons :)
00:21:53FromDiscord<Sabena Sema> so can you define new methods in one dll then have code in another call them and get correct dispatch?
00:22:16FromDiscord<Yardanico> not sure that'll work, never checked
00:22:48FromDiscord<Yardanico> if i need dynamic dispatch i'll probably use https://github.com/yglukhov/iface instead of nim's `method` :)
00:24:18FromDiscord<DMI-1407> hm
00:24:48FromDiscord<Yardanico> @DMI-1407 do you really need dynamic dispatch though? if you don't use inheritance you don't need `method`
00:24:53FromDiscord<DMI-1407> i mean i have no problem with it as long as i can write `obj.len()` instead of `obj.len` if just 1 arg is passed
00:25:17FromDiscord<Yardanico> In reply to @DMI-1407 "i mean i have": you can write that, yes, but only if `len` is an actual proc/method and not a field
00:25:17FromDiscord<DMI-1407> i would like to use every single language feature if possible
00:25:18FromDiscord<Yardanico> you can't "call" fields
00:25:21FromDiscord<Yardanico> In reply to @DMI-1407 "i would like to": huh?
00:25:33FromDiscord<Yardanico> nim is not a language where you should use every single language features :)
00:25:38FromDiscord<Yardanico> (edit) "features" => "feature"
00:25:40FromDiscord<DMI-1407> why not ?
00:25:58FromDiscord<Yardanico> because some are controversial and not always good
00:26:00FromDiscord<Elegantbeef> Cause every language feature has a purpose
00:26:07FromDiscord<Yardanico> that too
00:26:19FromDiscord<Yardanico> just using every feature because it's possible is not a good idea
00:26:22FromDiscord<Yardanico> just use what you actually need
00:26:29FromDiscord<DMI-1407> yeah ofc
00:26:45FromDiscord<DMI-1407> btw
00:26:46FromDiscord<Elegantbeef> Anyway `obj.len` is just syntax sugar for `len(obj)` assuming `len` is a proc
00:27:02FromDiscord<DMI-1407> is it possible to pass functions as arguments then execute them inside another function ?
00:27:07FromDiscord<Yardanico> yes
00:27:34FromDiscord<Elegantbeef> `proc doThing(p: proc()) = p()`
00:27:36FromDiscord<Yardanico> all proc/func in nim are first class
00:27:45FromDiscord<Yardanico> so you can pass them around, assign to variables, etc
00:28:19FromDiscord<DMI-1407> ok
00:34:20arkanoiddo you know if it is possible to start a zero_functional chain from an iterator?
00:44:51FromDiscord<DMI-1407> sent a code paste, see https://play.nim-lang.org/#ix=3HVc
00:45:27FromDiscord<DMI-1407> (edit) "https://play.nim-lang.org/#ix=3HVc" => "https://play.nim-lang.org/#ix=3HVd"
00:45:32FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=3HVe
00:45:37FromDiscord<Yardanico> routines are not really "tied" to object types
00:45:52FromDiscord<DMI-1407> ah hm
00:47:20*pch quit (Remote host closed the connection)
00:48:31FromDiscord<AmjadHD> I want to use clang as backend compiler (on windows) but when I do so it creates `.ilk` and `.pdb` files which are large, I believe it's related to incremental compilation. Does clang doing IC brings benefit ? and if not how do I disable it ? Thanks.
00:49:11FromDiscord<AmjadHD> (edit) removed "doing" | "brings" => "bring"
00:52:15FromDiscord<Yardanico> In reply to @AmjadHD "I want to use": .pdb is not related to IC, it's debug information
00:52:23FromDiscord<Yardanico> .ilk is for incremental linking, yes, but it's not specific to clang on windows
00:52:30FromDiscord<Yardanico> https://docs.microsoft.com/en-us/cpp/build/reference/dot-ilk-files-as-linker-input?view=msvc-170
00:53:01FromDiscord<AmjadHD> it's only generated when I use clang.
00:53:45FromDiscord<Yardanico> msvc also does the same, but mingw doesn't, yeah
00:54:17FromDiscord<AmjadHD> I tries vcc, it doesn't.
00:54:27FromDiscord<Yardanico> well it does with a flag :)
00:54:34FromDiscord<Yardanico> In reply to @Yardanico "https://docs.microsoft.com/en-us/cpp/build/referenc": did you check this
00:54:42FromDiscord<Yardanico> https://docs.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170
00:55:05FromDiscord<Sabena Sema> note that the C (or other backend) IC is completely unrelated to nim's IC
00:56:51FromDiscord<AmjadHD> In reply to @Sabena Sema "note that the C": yeah, I know, I'm asking whether it brings any speed in compiling the generated c code ?
00:57:05FromDiscord<Sabena Sema> maybe a little, it depends
00:57:26FromDiscord<Sabena Sema> I suspect nim tends to output object files that are easier for the linker to deal with that C++
00:57:29FromDiscord<Sabena Sema> (edit) "that" => "than"
00:57:43FromDiscord<Sabena Sema> it's designed to make linking faster, not compiling
00:57:57FromDiscord<AmjadHD> Okay, how do I disable it ?
00:58:47FromDiscord<Sabena Sema> `--passl:"/INCREMENTAL:NO"` probably
00:59:18FromDiscord<AmjadHD> In reply to @Sabena Sema "`--passl:"/INCREMENTAL:NO"` probably": to clang ?
00:59:53FromDiscord<Sabena Sema> clang probably uses link.exe on windows by default, so yes
01:00:07FromDiscord<Sabena Sema> are you using clang or clang-cl
01:00:18FromDiscord<AmjadHD> In reply to @Sabena Sema "are you using clang": clang.
01:00:28FromDiscord<Sabena Sema> clang may use ld
01:00:38FromDiscord<Sabena Sema> I'm surprised it outputs ilk files to be honest
01:01:40FromDiscord<AmjadHD> In reply to @Sabena Sema "I'm surprised it outputs": yeah and msvc doesn't.
01:02:07FromDiscord<Sabena Sema> there are some things that will cause msvc not to emit them
01:02:32FromDiscord<Sabena Sema> which I can no longer look up because msdn is throwing OSCP errors grrrr
01:03:22FromDiscord<creikey> https://marketplace.visualstudio.com/items?itemName=kosz78.nim&ssr=false#overview is there a way to make this extension recognize nimble packages
01:03:36FromDiscord<Sabena Sema> huh?
01:03:38FromDiscord<Sabena Sema> it should do
01:03:50FromDiscord<Sabena Sema> as long as you install them
01:04:02FromDiscord<creikey> huh it works now
01:04:08FromDiscord<creikey> wasn't working yesterday even after restarting
01:04:30FromDiscord<creikey> side note how does `import` find which file to use I've been trying to find a manual or something that explains it but can't
01:04:53FromDiscord<creikey> is there something like the PATH environment variable for which folders to look in
01:07:39FromDiscord<Elegantbeef> Somewhere a `--nimblePath` is set which lets you import files as packages, but it does `local` -\> `system` -\> `pkg` afaik
01:07:53FromDiscord<Elegantbeef> It might be in your `nim.cfg` or similar
01:08:05FromDiscord<creikey> found it `nim dump` tells you
01:08:20FromDiscord<creikey> In reply to @Elegantbeef "Somewhere a `--nimblePath` is": so nimble is something supported by the compiler it's not like its own thing
01:08:33FromDiscord<Elegantbeef> It's its own thing
01:08:41FromDiscord<Elegantbeef> `nimblePath` is just `libraryPath` really
01:08:51FromDiscord<creikey> I see
01:09:14FromDiscord<Elegantbeef> Like when you do `nimble build` it will clear the nimble path then pass only the packages specified in your nimble file
01:09:33FromDiscord<Elegantbeef> This makes it easier to have reproducible builds
01:09:47FromDiscord<creikey> nimble calls nim with paths only to the libraries specified in the .nimble file?
01:09:58FromDiscord<Elegantbeef> Yes
01:10:15FromDiscord<creikey> which files in srcDir does it compile?
01:10:16FromDiscord<Elegantbeef> So if you use a package not listed in the nimble file it'll error
01:10:32FromDiscord<creikey> In reply to @creikey "which files in srcDir": it's the file with the same name as the package right
01:10:40FromDiscord<Elegantbeef> Depends what you have setup but it looks for the file with the same name as the package
01:10:41FromDiscord<creikey> In reply to @Elegantbeef "So if you use": huh interesting
01:10:50FromDiscord<Elegantbeef> You can have multiple binaries
01:11:03FromDiscord<creikey> it's the bin = @[] just saw it
01:11:24FromDiscord<creikey> thanks for the help
01:12:03FromDiscord<Elegantbeef> No problem
01:29:16*src quit (Quit: Leaving)
01:32:43arkanoidhow can I create a seq of cstrings with size 10 chars each?
01:33:00arkanoidlet's say 100 cstrings of len 10
01:54:33FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=3HVl
01:56:13FromDiscord<Elegantbeef> Well little late arkanoid but that should do you
01:57:44*noeontheend joined #nim
01:59:51arkanoidElegantbeef, wait, what's create, and what's the memory layout here. Damn, I'm confused now. But thanks
01:59:56arkanoidI can explore this example
02:00:07FromDiscord<Elegantbeef> create is just sugar to allocate
02:00:23FromDiscord<Elegantbeef> the memory layout is each cstring is allocated independantly
02:01:35arkanoidok, so there's no difference from string and cstring in seq memory layout for strings
02:01:46arkanoidI was expecting something contiguous for cstrings
02:01:54FromDiscord<Elegantbeef> Well you said a seq
02:02:30arkanoidwell a seq of 1000 int8 is a contiguous buffer of 8k bytes
02:02:30FromDiscord<Elegantbeef> You can have them contiguous if you want it's totally up to you
02:02:48FromDiscord<Elegantbeef> Sure but cstrings are pointers to a character
02:03:07FromDiscord<Elegantbeef> So you could have the same memory layout on the heap and just have the cstrings point to each 12 element
02:03:26arkanoidto have a sequential one? do I need seq[array[10,char]]?
02:04:17FromDiscord<Rika> Pretty much
02:04:27arkanoidthanks
02:08:53*noeontheend quit (Read error: Connection reset by peer)
02:09:41*noeontheend joined #nim
02:13:49arkanoidmmm interesting, repeat(['f','o','o','b','a','r'], 100) allocates 608 bytes on the heap
02:14:08arkanoidI was expecting 8x6x1000
02:14:15arkanoid*8x6x100
02:16:33arkanoidwell, also on website https://play.nim-lang.org/#ix=3HVq
02:17:44FromDiscord<Rika> repeat makes a seq of 100 ptrs to array
02:17:58FromDiscord<Rika> hm
02:18:22arkanoidmy fault, I mixed bit with bytes
02:18:48arkanoid1 chat is 8 bit, it's 1x6x100 = 600, +8 for seq len
02:18:55FromDiscord<leorize> the header of seq takes space, too
02:18:56FromDiscord<Rika> its still 200ish bytes short innit
02:19:21FromDiscord<Rika> or did i get the ptr size wrong
02:19:24FromDiscord<Rika> oh wait
02:19:27FromDiscord<Rika> no ptr since its array
02:19:30arkanoidRika is an array, no ptr
02:19:33arkanoidexactly
02:19:57FromDiscord<Rika> i woke up under an hour ago
02:20:00FromDiscord<Rika> lol
02:30:42*arkurious quit (Quit: Leaving)
02:38:34*pch joined #nim
02:39:27FromDiscord<that_dude> sent a code paste, see https://play.nim-lang.org/#ix=3HVx
02:40:01FromDiscord<Rika> no
02:40:19FromDiscord<Rika> actually "kinda"
02:41:15FromDiscord<that_dude> Could you elaborate please?
02:41:55FromDiscord<Rika> kinda because you can prolly use closure procedures to do this BUT it (if im right) isnt what youre looking for
02:45:05FromDiscord<Elegantbeef> Well this could be done with a macro + template but yea no can do with a proc
02:45:28FromDiscord<that_dude> From what I can see closures are close, but not quite right. I was looking something slightly more independent.
02:45:35FromDiscord<that_dude> What do you mean Elegant?
02:45:40FromDiscord<Rika> beef about to unleash hell
02:45:59FromDiscord<Elegantbeef> Like rika said
02:46:04FromDiscord<Elegantbeef> Time to go balls to the wall
02:46:09FromDiscord<that_dude> I actually was looking into macro stuff recently so this could play well with that
02:46:11FromDiscord<Rika> call would be a macro which expands to code that "analyses the outer scope then passes them into the inner proc"
02:46:19FromDiscord<Rika> but please dont do this
02:46:21FromDiscord<Elegantbeef> Nope
02:46:25FromDiscord<that_dude> >:)
02:46:32FromDiscord<that_dude> That sounds like what I need tho
02:46:43FromDiscord<that_dude> Why is that bad?
02:47:01FromDiscord<Rika> because id say its unneccesary
02:47:12FromDiscord<Rika> what reason do you have for emulating globals like this
02:48:25FromDiscord<that_dude> Well
02:52:52FromDiscord<that_dude> sent a long message, see http://ix.io/3HVy
02:53:47FromDiscord<Elegantbeef> You can wrap module functions
02:53:49FromDiscord<Rika> you can actually abuse generics
02:53:52FromDiscord<Elegantbeef> Though it's in a roundabout way
02:53:56FromDiscord<Rika> to do specificity overrides
02:55:09FromDiscord<that_dude> The thing is that I need to be able to wrap an internal library proc from my main file without causing the library to notice any differences. Is that still possible?
02:55:27FromDiscord<Elegantbeef> You cannot replace logic in a lower module
02:55:33FromDiscord<that_dude> Ah
02:55:34FromDiscord<Elegantbeef> That makes 0 sense
02:55:44FromDiscord<Elegantbeef> You could patch file or make your own fork
02:55:59FromDiscord<Rika> sent a code paste, see https://play.nim-lang.org/#ix=3HVz
02:56:16FromDiscord<Rika> In reply to @that_dude "The thing is that": what?
02:58:41FromDiscord<that_dude> https://forum.nim-lang.org/t/8652 was the example I gave when asking about it. I designed my code with some specific abstractions and rules, but merging the files undoes all of the design I did and reverts it to a previous form
02:58:58FromDiscord<Elegantbeef> I remember the post
02:59:01FromDiscord<Elegantbeef> It's a silly question
02:59:05FromDiscord<that_dude> :|
02:59:19FromDiscord<that_dude> It was just a specific thing I wanted to do
02:59:19FromDiscord<Elegantbeef> You want a proc to run but with your own logic appended
02:59:35FromDiscord<that_dude> Yeah that's one way to describe it
02:59:35FromDiscord<Elegantbeef> So you either need to make a new proc that has that
02:59:41FromDiscord<Rika> its usually called monkeypatching and its a valid idea
02:59:45FromDiscord<Elegantbeef> Or modify the source
02:59:48FromDiscord<Rika> but usually people just modify
02:59:49FromDiscord<Rika> yeah
03:00:00FromDiscord<Rika> nim isnt actor based sadly for you
03:00:41FromDiscord<that_dude> I've been trying to move away from just messing with the source because that makes it harder for me to maintain for other projects that work differently
03:00:54FromDiscord<that_dude> Ig I just want a 1 size fits all type of lib
03:00:54FromDiscord<Elegantbeef> Then shadow the function with your own
03:01:26FromDiscord<Rika> you cannot avoid modifying the source
03:01:30FromDiscord<Rika> in one way or another
03:01:34FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3HVC
03:01:45FromDiscord<that_dude> Can you elaborate? And would that play nicely if my lib is the one to call the proc
03:01:49FromDiscord<that_dude> hmm
03:01:58FromDiscord<Elegantbeef> That code would be defined in `main.nim`
03:02:21FromDiscord<Rika> all other lib fn calls would need to be qualified
03:02:32FromDiscord<Elegantbeef> The simple fact is that you cannot modify procs that you arent declaring, so you need to reroute the logic, modify the source or copy the proc logic into your own proc using a macro
03:03:16FromDiscord<Elegantbeef> The last is doable but relatively complex
03:03:22*rockcavera joined #nim
03:03:22*rockcavera quit (Changing host)
03:03:22*rockcavera joined #nim
03:04:07FromDiscord<that_dude> Which is why I was going to use macros to create an injection table, I just didn't want to use pure globals to do so
03:04:31FromDiscord<Rika> araq said `it looked like you were complexifying things for complexity's sake`
03:04:34FromDiscord<that_dude> Because one of the design choices I made was to move away from globals for better threading support
03:04:37FromDiscord<Rika> and it really does truly seem like it is
03:04:42FromDiscord<that_dude> Kinda
03:04:57FromDiscord<Rika> simulating globals will not help you with threading
03:04:57FromDiscord<Elegantbeef> I mean you can just make the procedure a generic that takes procs/void
03:05:15FromDiscord<that_dude> I have a few constraints, and I'm trying to work around them in a manner I find to be cleaner
03:05:25FromDiscord<Rika> and this will not be clean
03:05:44FromDiscord<that_dude> I think the end result would be if I do it right
03:05:56FromDiscord<Rika> the macro will have a lot of maintenance cost in terms of time and thought
03:06:39FromDiscord<that_dude> I guess I haven't worked enough with macros to find that out, but the design I thought about and from what I've seen would be pretty clean I think
03:08:12FromDiscord<that_dude> Which brings me back to my (current) original question, Is there a way to make pseudo globals? I'm ok trying to figure it out if it requires macros
03:08:14FromDiscord<Rika> there isnt much that you can do without editing the source, the only choice boils down to "create a wrapper proc", either by macro or by hand
03:08:52FromDiscord<Elegantbeef> You might be able to make pseudo globals with macrocache, but it's a really odd thing
03:09:04FromDiscord<that_dude> I guess the reason it has to be a macro is because the wrapper won't always apply
03:09:06FromDiscord<Elegantbeef> There is no way for them to be accessible from all modules unless declared first
03:09:24FromDiscord<Elegantbeef> Modifying source is really the most sane choice
03:09:37FromDiscord<that_dude> I'll look into that, I think that's fine.
03:10:21FromDiscord<Rika> well i at least hope you arent releasing this library or whatever youre making for public use
03:10:43FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3HVF
03:11:08FromDiscord<Rika> else: discard not needed is it
03:11:18FromDiscord<Elegantbeef> Nope
03:11:25FromDiscord<Elegantbeef> Too use to expressions
03:11:39FromDiscord<Rika> lol thats ok
03:12:49FromDiscord<that_dude> In reply to @Rika "well i at least": I'll release it just to spite you >:D
03:13:12FromDiscord<Rika> releasing it is fine, i did say for public use
03:13:51FromDiscord<Elegantbeef> I mean i'd be interested in seeing the API cause i'm super confused how this is desired
03:14:06FromDiscord<that_dude> Yeah sorry I'm bad at conveying things
04:00:58*lumo_e joined #nim
04:06:01*supakeen quit (Quit: WeeChat 3.3)
04:06:30*supakeen joined #nim
04:08:45*pch quit (Remote host closed the connection)
04:22:33*lumo_e quit (Ping timeout: 252 seconds)
04:23:52*noeontheend quit (Quit: noeontheend)
04:24:54*noeontheend joined #nim
04:52:55NimEventerNew thread by Archnim: Nim to lib, see https://forum.nim-lang.org/t/8707
05:35:49*pch joined #nim
05:42:00FromDiscord<planetis> I sound like a broken record but here we go... Does anyone know how to traverse a function chain using a macro and re-write it in nested style?
05:42:41FromDiscord<Elegantbeef> You mean inline it?
05:42:56FromDiscord<impbox [ftsf]> what's a function chain?
05:44:55FromDiscord<planetis> it's the syntax, suppose you have `x.foo().bar().baz` need to transform it into `baz(bar(foo(x)))` and also insert arguments
05:45:50FromDiscord<planetis> sounds fun, right?
05:45:51FromDiscord<impbox [ftsf]> are they not the same in nim?
05:45:59FromDiscord<Rika> They are aren’t they
05:46:07FromDiscord<Rika> Not in syntax I guess
05:46:13FromDiscord<Rika> What’s the use case
05:47:13FromDiscord<planetis> the problem is, I am trying to imitate method chaining syntax, like the `with` macro
05:47:38FromDiscord<impbox [ftsf]> @planetis if you do dumpTree on both and compare them, it shouldn't be too hard
05:48:06FromDiscord<planetis> lol famous last words
05:48:35FromDiscord<impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=3I1H
05:48:46FromDiscord<impbox [ftsf]> you iterate through the first one and generate the second one
05:49:21FromDiscord<planetis> yeah sure but I need to come up a recursive helper proc
05:49:45FromDiscord<impbox [ftsf]> i believe in you!
05:50:15FromDiscord<planetis> alright! I'm on to it
05:53:01FromDiscord<Rika> Dot expression index one goes to call index 0, index 0 goes to index 0, unwrap, traverse into.
05:53:18FromDiscord<Rika> That’s the basic algorithm in a very terse and hard to understand sentence
05:53:55*noeontheend quit (Ping timeout: 250 seconds)
05:55:16FromDiscord<valerga> why is this failing in 1.4.8 ? https://play.nim-lang.org/#ix=3I2f
05:55:45FromDiscord<planetis> makes sense thank you↔(@Rika)
05:56:17FromDiscord<impbox [ftsf]> @valerga you need to define the hash function for Point
05:56:21FromDiscord<Rika> In reply to @valerga "why is this failing": Probably no generic hash function
05:57:06FromDiscord<impbox [ftsf]> https://nim-lang.org/docs/tables.html#basic-usage-hashing
06:03:56FromDiscord<valerga> i don't understand what's going on here
06:03:57FromDiscord<valerga> sent a code paste, see https://play.nim-lang.org/#ix=3I30
06:05:07FromDiscord<valerga> like what is `!&`
06:05:44FromDiscord<impbox [ftsf]> https://nim-lang.org/docs/hashes.html#%21%24%2CHash
06:05:57FromDiscord<impbox [ftsf]> oops, the entry below it
06:09:15*perro quit (Ping timeout: 252 seconds)
06:20:31FromDiscord<valerga> I see, thanks
06:40:11*pch quit (Remote host closed the connection)
06:41:53*pch joined #nim
06:58:54*xet7 quit (Remote host closed the connection)
07:03:27*pch quit (Remote host closed the connection)
07:03:48FromDiscord<evoalg> How would I sort by more than one field? ... like sort by x[1] then by x[0] ?
07:04:09FromDiscord<Rika> Use a stable sort and sort twice
07:04:13FromDiscord<leorize> you can run the sort twice
07:04:20FromDiscord<evoalg> oh ok
07:04:42FromDiscord<impbox [ftsf]> sounds like you want sorted by x[1] and then if x[1] is the same sort by x[0] ?
07:04:53FromDiscord<evoalg> that's right!
07:05:01FromDiscord<Rika> Yeah sort twice
07:05:12FromDiscord<Rika> Sort by 0 first then 1
07:05:19FromDiscord<evoalg> the 2nd sort would stuff up the first sort?
07:05:37FromDiscord<Rika> It is stable aka the order will be preserved if they are the “same” to the sort
07:05:46FromDiscord<impbox [ftsf]> or something
07:05:50FromDiscord<impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=3I6r
07:06:42FromDiscord<evoalg> Thank you!
07:07:05FromDiscord<impbox [ftsf]> i always get the comparison directions wrong so make sure it's the correct direction =)
07:07:14FromDiscord<impbox [ftsf]> might want b - a
07:07:14FromDiscord<evoalg> righty
07:07:19FromDiscord<impbox [ftsf]> i forget
07:07:20FromDiscord<leorize> I'm pretty sure you should use `cmp()` \:p
07:07:23FromDiscord<impbox [ftsf]> or that
07:07:41FromDiscord<impbox [ftsf]> cmp would be much nicer
07:07:47FromDiscord<impbox [ftsf]> but i've never used it, though i should
07:08:03FromDiscord<evoalg> hehe 😉
07:08:44*pch joined #nim
07:08:46FromDiscord<leorize> nim's sort is stable, though, so you can sort twice if that's easier \:p
07:09:54FromDiscord<evoalg> hmmmm I'll have a play around
07:11:01FromDiscord<impbox [ftsf]> https://play.nim-lang.org/#ix=3I6t
07:12:18FromDiscord<evoalg> In reply to @impbox "https://play.nim-lang.org/#ix=3I6t": perfect - thank you!
07:14:11*pch quit (Quit: Leaving)
07:17:05*PMunch joined #nim
07:45:08Amun-Raevoalg: or provide your own '<' and '==' procs
07:52:47FromDiscord<valerga> sent a code paste, see https://play.nim-lang.org/#ix=3I6v
07:52:48FromDiscord<valerga> what's a better way to do this?
07:53:21PMunchYou can always do `max_x = max(max_x, p.x)`
07:53:29PMunchInstead of those ifs
07:53:47PMunchOr you can use foldl
07:54:22FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3I6w
07:55:19FromDiscord<impbox [ftsf]> you should probably initialise it to -Inf if they're floats
07:57:07PMunchSomething like this works: https://play.nim-lang.org/#ix=3I6x
07:57:38PMunchOf course you could define a `max` proc that takes a x/y-tuple as well, just to make the code a bit tidier
07:58:46PMunchLike this: https://play.nim-lang.org/#ix=3I6y
08:03:10FromDiscord<valerga> what if I want the extract x or y? https://play.nim-lang.org/#ix=3I6C
08:06:01*tiorock joined #nim
08:06:01*tiorock quit (Changing host)
08:06:01*tiorock joined #nim
08:06:01*rockcavera is now known as Guest8742
08:06:01*Guest8742 quit (Killed (tungsten.libera.chat (Nickname regained by services)))
08:06:01*tiorock is now known as rockcavera
08:07:15FromDiscord<leorize> provide a reference to fold into\: https://play.nim-lang.org/#ix=3I6D
08:07:54FromDiscord<leorize> it's a bit weird that the "first" parameter is at the end for that template, though
08:09:20FromDiscord<Solitude> In reply to @valerga "what's a better way": this is the best way.
08:10:47FromDiscord<Solitude> reducing line count or adding sugar doesnt mean making it better
08:11:35FromDiscord<impbox [ftsf]> if it's a common thing you do, eg. generating upper,lower bounds it makes sense to make a proc or template
08:11:36FromDiscord<valerga> yeah i can see that. Though that procedure seems frequent enough to maybe warrant some function in the std I think
08:12:37FromDiscord<valerga> I use these when generating 2d boards
08:12:46FromDiscord<valerga> so x and y
08:13:21FromDiscord<valerga> but yeah I can just make my own proc
08:41:41PMunch@Solitude, depends on what you want. More readable code? Harder to produce bugs?
08:56:13*jjido joined #nim
09:01:43*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz
)
09:33:49*tiorock joined #nim
09:33:49*tiorock quit (Changing host)
09:33:49*tiorock joined #nim
09:33:49*rockcavera is now known as Guest915
09:33:50*Guest915 quit (Killed (strontium.libera.chat (Nickname regained by services)))
09:33:50*tiorock is now known as rockcavera
10:03:31FromDiscord<enthus1ast> what is the correct syntax in a nimble require line to install from an url with version? Im going nuts, really
10:03:49FromDiscord<enthus1ast> wasted half an hour on this o.0
10:04:14FromDiscord<Rika> Depends on what the URL is
10:04:31FromDiscord<enthus1ast> that is the issue, it should not depend↔(@Rika)
10:04:39FromDiscord<Rika> But it does
10:04:46FromDiscord<enthus1ast> it should have the same syntax as if i run nimble by hand
10:04:53FromDiscord<Rika> And it does afaik
10:04:53FromDiscord<enthus1ast> sorry im loaded @Rika
10:05:10FromDiscord<enthus1ast> nope it does not
10:08:34PMunch@Elegantbeef, you mean like: https://play.nim-lang.org/#ix=3I6y
10:09:05PMunch@enthus1ast, you mean like: requires "https://github.com/PMunch/nim-dbus#loopfix"
10:09:17PMunchNot sure how I managed to mess up that bad, wrong person, and wrong paste :P
10:09:44FromDiscord<Elegantbeef> It's a skill
10:10:00FromDiscord<enthus1ast> ok this worked\:↔↔requires "https://github.com/enthus1ast/myPkg.git == 7.0.4"
10:10:02FromDiscord<enthus1ast> yes
10:10:26FromDiscord<Elegantbeef> pmunc that PR still exists 😛
10:12:46PMunchWhich PR?
10:12:59FromDiscord<Elegantbeef> For protobuf that fixes empty messages
10:13:19PMunchYeah I know, haven't had time to look at it yet
10:13:41FromDiscord<Elegantbeef> But you have time to wrongly ping me?! 😛
10:13:56PMunchTyping your name is faster than review your PR
10:14:17FromDiscord<Elegantbeef> Not really "sod off" is fewer letters than "Elegant beef"
10:14:30PMunchOtherwise I'd either be the worlds fastest code reviewer or the worst ever typist :P
10:15:19FromDiscord<Rika> Isn't beef already at worst ever typist
10:15:55FromDiscord<Elegantbeef> Programmer\
10:24:40madpropsthis PR never got merged ;[ https://github.com/PMunch/nim-playground-frontend/pull/28
10:25:37madpropsbut I understand if it's just bad, i can close it
10:25:50madpropsthe toggable options might not be a great idea
10:26:30madpropsbut it seems to display nice on mobile
10:35:11FromDiscord<Michal58> sent a code paste, see https://play.nim-lang.org/#ix=3I7j
10:35:47FromDiscord<Michal58> (edit) "https://play.nim-lang.org/#ix=3I7j" => "https://play.nim-lang.org/#ix=3I7k"
10:36:13FromDiscord<Michal58> (edit) "https://play.nim-lang.org/#ix=3I7k" => "https://play.nim-lang.org/#ix=3I7l"
10:37:59FromDiscord<valerga> `Error: undeclared identifier: 'x'`
10:38:30FromDiscord<Solitude> cringe
10:39:42FromDiscord<valerga> `var max_x = points.mapIt(it.x).max`
10:39:47FromDiscord<valerga> this works though
10:49:37*Guest56 joined #nim
10:51:47*Guest56 quit (Client Quit)
11:30:23PMunch@madprops, hmm I remember testing that
11:30:46PMunchFirst off that `Options` toggle definitely needs to be more obvious
11:30:48NimEventerNew Nimble package! asyncredis - Pure Nim asyncronous driver for Redis DB, see https://github.com/Q-Master/redis.nim
11:30:58PMunchRight now it doesn't look like it's even clickable
11:38:01madpropsmaybe an underline?
11:39:38*src joined #nim
11:40:50PMunchNot sure if that is enough..
11:42:57madprops"Click Here For Options" but that takes too much space
11:43:29madpropsbut the idea is that being able to hide the options gives more room to the editor
11:45:41madpropsand that it can fit nicely on mobile
11:48:11PMunchMaybe add a hamburger menu icon?
11:48:38PMunchOr some other iconography that is commonly used for options and clickable links
11:48:54madpropsah good idea
11:49:12PMunchMaybe the Code on GitHub link should also be shown under options, and allow the entire top-right corner to be the options toggle?
11:49:42madpropsdoesn't fit on mobile
11:49:53*lumo_e joined #nim
11:50:24madpropsis the link necessary though?
11:50:53madpropswell it could fit if it uses only an icon
11:50:53PMunchWell it's nice to show people where they can help out :)
11:51:14PMunchAnd there was an issue where people would create issues and PRs in the old repo
12:02:53FromDiscord<planetis> so what do you guys think is a better syntax, between these two\: `with(x, get(JsonNode 9, 1).getInt())` or `%.get(x, JsonNode 9, 1).getInt() == 5` ?
12:03:47FromDiscord<Rika> neither look good
12:04:01FromDiscord<Rika> i dont understand what either do at a glance
12:04:08PMunchSame
12:04:55FromDiscord<Rika> with x get? why not just x.get?
12:05:00FromDiscord<Rika> 9, 1???
12:06:01*supakeen quit (Quit: WeeChat 3.3)
12:06:31*supakeen joined #nim
12:06:47FromDiscord<planetis> first int is an jsonnode index, second is array index
12:07:07FromDiscord<planetis> yea the api sucks https://github.com/planetis-m/packedjson2/issues/2
12:07:34FromDiscord<planetis> that's the best i could come up with
12:08:47FromDiscord<planetis> i though it might be a little easier programming it and more consistent↔(@Rika)
12:10:09FromDiscord<planetis> problem with that lib is, we use a JsonTree that stores the nodes in a sequence and index them with a "JsonNode" type
12:11:57FromDiscord<Rika> this really isnt an intuitive api, i would like to try helping; what limitations are there
12:11:58FromDiscord<Solitude> oh, yeah, its like that . o (wtf)
12:13:21FromDiscord<planetis> I took the %. macro idea from std/wrapnils
12:14:23FromDiscord<planetis> I would have gone with https://github.com/planetis-m/jsonecs/issues/8#issuecomment-921746326 but it does have a performance penalty
12:14:38FromDiscord<planetis> and people complain that std/json is slow
12:19:29FromDiscord<planetis> I might just do another macro, get(int, tree, jroot, "key", 1, "a") and avoid all this mess
12:55:55*perro joined #nim
13:02:11*kayabaNerve quit (Read error: Connection reset by peer)
13:11:50madpropsPMunch, sent PR mod
13:58:20FromDiscord<Michal58> In reply to @valerga "this works though": I mean it depends on the context
14:03:15*Colt joined #nim
14:06:01*jjido joined #nim
14:24:38*arkurious joined #nim
14:38:22FromDiscord<planetis> any better? https://github.com/planetis-m/packedjson2/issues/6
14:45:42*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz
)
15:04:58*PMunch quit (Quit: Leaving)
15:14:54*kayabaNerve joined #nim
15:17:25*lumo_e quit (Ping timeout: 252 seconds)
15:34:37FromDiscord<planetis> i wish fusion/matching could possibly work with this, I dont want to implement that stuff, its super hard
15:38:58FromDiscord<Disciple> Is there any way to ensure procs return the value they have defined explicitly? Example: https://play.nim-lang.org/#ix=3I94
15:41:06nrds<Prestige99> Should probably just use `result` in that case
15:41:46nrds<Prestige99> Do you want to get warnings about unused variables?
15:42:45FromDiscord<reilly> Is there a convenient way of doing essentially the same thing as `toSeq(a..b)` except that works as expected when `a > b`? (i.e. `foo(8, 3) == @[8, 7, 6, 5, 4, 3]`)
15:43:14FromDiscord<reilly> It has to work when `a > b` and when `a < b`.
15:44:28nrds<Prestige99> Related: https://forum.nim-lang.org/t/8689
15:46:26FromDiscord<Disciple> Prestige: my concern is just forgetting a return statement and getting default 0 values when I'm expecting actual values. Seems like it would lead to hard-to-debug issues
15:46:27FromDiscord<reilly> Go figure, I even remember reading this at some point...
15:48:14nrds<Prestige99> Getting warnings about unused variables would probably be helpful in that case, though I don't know if we have editor support for that
15:49:01nrds<Prestige99> Getting in the habit of using result might be a good idea though; I can't think of a time I've forgotten to return a value from a function
15:49:57FromDiscord<Rika> @Disciple use implicit returns
15:50:04FromDiscord<Rika> always
15:50:41FromDiscord<Rika> `proc a: int = if <some condition>: 0 else: 1` or so
15:51:39FromDiscord<Rika> `proc b: bool = var flag: bool; for ...: <work>; flag` or so
15:51:50FromDiscord<Rika> notably the last "statement" is actually an expression
15:51:54FromDiscord<Rika> pretty much is what they are
15:54:29FromDiscord<Disciple> What if you refactor and one of the implicit returns is removed and you don't notice? For example if I define a function that takes two arguments and one is missing I get a compiler error. I want to get one when I define a return for a proc yet forget to return anything instead of getting a default value
15:54:48FromDiscord<Rika> not a thing yet
15:54:54FromDiscord<Rika> afaik
15:55:53FromDiscord<Disciple> Ah darn
15:56:29FromDiscord<Disciple> I'll keep digging in the documentation to see if I find something
16:28:02*jmdaemon joined #nim
16:29:05*jmdaemon quit (Client Quit)
16:29:27*jmdaemon joined #nim
16:33:43*jmdaemon quit (Client Quit)
16:34:20*jmdaemon joined #nim
16:34:51*jmdaemon quit (Client Quit)
16:35:07*jmdaemon joined #nim
16:37:00*jmdaemon quit (Client Quit)
16:41:17*jmdaemon joined #nim
16:45:14*jmdaemon quit (Client Quit)
16:45:32*jmdaemon joined #nim
16:46:06*jmdaemon quit (Changing host)
16:46:06*jmdaemon joined #nim
16:50:01*jmdaemon quit (Client Quit)
16:50:36*jmdaemon joined #nim
16:54:48*jmdaemon quit (Client Quit)
16:55:10*jmdaemon joined #nim
16:55:12*jmdaemon quit (Client Quit)
16:55:39*jmdaemon joined #nim
17:05:07*lumo_e joined #nim
17:06:32FromDiscord<hmmm> hey can I import in A something from B and B something else from A without making a giant mess?
17:09:50*krux02 joined #nim
17:11:07FromDiscord<hmmm> nah I got hit by giant recursive module dependency error
17:11:29FromDiscord<hmmm> I guess I should just clean up the mess with napalm and then import just one module lol
17:37:05*jmdaemon quit (Quit: WeeChat 3.3)
17:37:46FromDiscord<Rika> circular dependencies are hairy even if you did tackle it without an extra file, as it would imply rearranging code and imports-in-between-code
17:39:42*jmdaemon joined #nim
17:40:05*jmdaemon quit (Client Quit)
17:40:43*jmdaemon joined #nim
17:42:35FromDiscord<hmmm> oh, so my ill advised idea of using C to offload some cruft wasn't so bad. Well in the end since it's all spaghettis anyway, before bashing my head against imports I might as well clean up a bit and see what happens. ty Rika anyway
17:43:21*jmdaemon quit (Remote host closed the connection)
17:43:37*jmdaemon joined #nim
17:46:33FromDiscord<enthus1ast> @hmmm\: i often do it "c style" have a header that just defines the type for every big module
18:05:44*jmdaemon quit (Quit: WeeChat 3.3)
18:06:03*jmdaemon joined #nim
18:06:06*jmdaemon quit (Client Quit)
18:06:25*jmdaemon joined #nim
18:19:53*jmdaemon quit (Quit: WeeChat 3.3)
18:20:13*jmdaemon joined #nim
18:20:39*jmdaemon quit (Client Quit)
18:32:51*jmdaemon joined #nim
18:36:34*noeontheend joined #nim
19:10:15*noeontheend quit (Ping timeout: 252 seconds)
19:17:11*stkrdknmibalz joined #nim
19:22:09FromDiscord<Forest> Hi
19:25:10*noeontheend joined #nim
19:26:44FromDiscord<Forest> Does anyone know of any libraries that i could look at to write a dynamic programming language?
19:37:25*SebastianM joined #nim
19:38:23nrds<Prestige99> Anyone know if there's a formal definition or test suite/spec for camelCase? Have a few weird situations, want to see what the correct casing should be
19:48:57*noeontheend quit (Ping timeout: 250 seconds)
19:51:33*noeontheend joined #nim
20:39:57*SebastianM quit (Quit: Bye)
20:42:01*jmdaemon quit (Read error: Connection reset by peer)
20:42:24*jmdaemon joined #nim
21:06:56*jmdaemon quit (Ping timeout: 268 seconds)
21:07:57*noeontheend quit (Ping timeout: 252 seconds)
21:11:05*jmdaemon joined #nim
21:13:00*jmdaemon quit (Read error: Connection reset by peer)
21:13:59*jmdaemon joined #nim
21:14:05*jmdaemon quit (Read error: Connection reset by peer)
21:14:44*jmdaemon joined #nim
21:15:30*noeontheend joined #nim
21:15:53*jmdaemon quit (Client Quit)
21:16:10*jmdaemon joined #nim
21:16:31*jmdaemon quit (Client Quit)
21:16:48*jmdaemon joined #nim
21:19:02*jmdaemon quit (Client Quit)
21:19:18*jmdaemon joined #nim
21:26:46NimEventerNew thread by AmjadBHD: Stop clang from generating ilk and pdb files, see https://forum.nim-lang.org/t/8708
22:01:19*vicfred joined #nim
23:40:31*jmdaemon quit (Quit: WeeChat 3.3)
23:42:43*jmdaemon joined #nim
23:43:29*jmd joined #nim
23:46:01*noeontheend quit (Ping timeout: 268 seconds)
23:53:32*jmdaemon quit (Quit: WeeChat 3.3)
23:54:03*jmd quit (Quit: ZNC 1.8.2 - https://znc.in)