<< 28-03-2021 >>

00:00:37FromDiscord<Mustache Man> sent a code paste, see https://play.nim-lang.org/#ix=2Uj1
00:02:02FromDiscord<Mustache Man> Note that NetworkNode's "nodes" object is a seq[NetworkNode] and SpecialNode's is a seq[SpecialNode]
00:02:11FromDiscord<Mustache Man> (edit) "Note" => "It's important to note"
00:03:34FromDiscord<Mustache Man> (edit) "NetworkNode's" => "Network's" | "seq[NetworkNode] and SpecialNode's is a seq[SpecialNode]" => "seq[NetworkNode].. here i'll include the types"
00:04:03FromDiscord<Mustache Man> sent a code paste, see https://play.nim-lang.org/#ix=2Uj2
00:04:29FromDiscord<Mustache Man> (edit) "https://play.nim-lang.org/#ix=2Uj2" => "https://play.nim-lang.org/#ix=2Uj3"
00:05:12FromDiscord<Mustache Man> (edit) "https://play.nim-lang.org/#ix=2Uj3" => "https://play.nim-lang.org/#ix=2Uj4"
00:11:14FromDiscord<William> 😦 https://media.discordapp.net/attachments/371759389889003532/825522382268792858/unknown.png
00:15:08*j joined #nim
00:17:10FromDiscord<ElegantBeef> They mean nvim
00:17:41*Vladar quit (Quit: Leaving)
00:20:27*j is now known as jess
00:27:16Prestigelooks like a copy pasta lol
00:28:45FromDiscord<ElegantBeef> But yea prestige clyybber is online so feel free to pester them 😄
00:29:48Prestige@Clyybber be a pal and merge https://github.com/nim-lang/Nim/pull/17425 plz
00:36:15FromDiscord<clyybber> aight, lemme see
00:36:25FromDiscord<clyybber> @ElegantBeef shouldn't the break have the same effect anyways?
00:36:46Prestige<3
00:36:49FromDiscord<clyybber> umm nevermind :D
00:36:58FromDiscord<ElegantBeef> Yea it broke out of the loop but appended the string still
00:37:02FromDiscord<ElegantBeef> Atleast iirc
00:37:31FromDiscord<ElegantBeef> Seems to only cause an issue with using nimscript with many search paths
00:38:00FromDiscord<ElegantBeef> But it seems like it's a non breaking change(always dubious about that claim)
00:43:36FromDiscord<clyybber> Ok, the logic makes sense; merged :D
00:44:08FromDiscord<clyybber> do you think you could come up with a test so that we prevent it from regressing?
01:00:00*njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.)
01:01:02*njoseph joined #nim
01:02:49*drsensor joined #nim
01:03:06FromDiscord<ElegantBeef> Uhh, possibly but it's pretty elaborate to spool up the VM and point it at a stdlib
01:03:56*clyybber quit (Quit: WeeChat 3.1)
01:14:34FromDiscord<ElegantBeef> Well there we go prestige, best get that bot working now to validate the pestering
01:14:46FromDiscord<ElegantBeef> If you dont get it working clyybber will ban you
01:15:52FromDiscord<Mustache Man> I made a nim playground link if anyone wants to help me debug this: https://play.nim-lang.org/#ix=2Ujf
01:16:19*krux02 quit (Remote host closed the connection)
01:18:20*sixtyten joined #nim
01:20:30FromDiscord<ElegantBeef> The compiler tells teh issue
01:20:36FromDiscord<ElegantBeef> (edit) "teh" => "the"
01:21:07FromDiscord<Mustache Man> Yes, I just don't fully understand it or how to fix it
01:21:31FromDiscord<ElegantBeef> reciever is lent from `n.network.nodes` and it shouldnt outlive the scope of the for loop
01:22:36FromDiscord<ElegantBeef> https://play.nim-lang.org/#ix=2Ujh
01:22:37FromDiscord<Mustache Man> oh, so i need another approach to the callback
01:22:38FromDiscord<ElegantBeef> There you go
01:24:38FromDiscord<Mustache Man> oooohhhh, I see! thank you
01:56:44PrestigeThanks beef and clyybber
02:01:49*njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.)
02:02:10*njoseph joined #nim
02:31:11*arecaceae quit (Remote host closed the connection)
02:31:31*arecaceae joined #nim
02:40:14*fredrikhr quit (Read error: Connection reset by peer)
02:45:58saemtime for my computer to go to space. :D
03:01:38*fmaruki joined #nim
03:04:31*fmaruki left #nim ("ERC (IRC client for Emacs 26.3)")
03:11:48*drsensor quit (Quit: Connection closed for inactivity)
03:19:00*fmaruki joined #nim
03:27:29*fmaruki` joined #nim
03:28:14*fmaruki` left #nim ("ERC (IRC client for Emacs 26.3)")
03:35:34FromDiscord<Mustache Man> How would I echo a distinct type?
03:36:17leorizeyou can do so by borrowing the `$` proc
03:36:34FromDiscord<Mustache Man> thank you
03:46:03*spiderstew_ joined #nim
03:47:15*spiderstew quit (Ping timeout: 240 seconds)
03:49:23FromGitter<gogolxdong> How to have jester listen on ipv6?
03:50:09*hsh quit (Quit: Connection closed for inactivity)
04:47:49*xet7 quit (Remote host closed the connection)
04:48:48*xet7 joined #nim
05:30:01*xet7 quit (Remote host closed the connection)
05:40:42*valorzard quit (Ping timeout: 240 seconds)
06:04:52*xet7 joined #nim
07:07:42FromDiscord<Yardanico> i'm trying to make a silly benchmark for different types of runtime dispatch, am I doing it wrong? https://play.nim-lang.org/#ix=2Ulf
07:08:06FromDiscord<Yardanico> for me with refc all types are roughly the same speed, but with arc/orc methods are slower than with refc (that's expected), but all other types are 3x faster than with refc
07:41:37FromGitter<StefanSalewski> 07:07:42 FromDiscord <Yardanico> i'm trying to make a silly benchmark for different types of runtime dispatch,
07:41:58FromGitter<StefanSalewski> Nice: I am very interested in the results!
07:42:47FromGitter<StefanSalewski> Question: Do we have something for C++ DBL_MAX in Nim? I guess it is different from system.inf.
07:44:01FromGitter<StefanSalewski> Well maybe float.high()
07:45:26*haxscramper joined #nim
07:48:30FromGitter<StefanSalewski> Well echo system.Inf, float.high in playground gives infinf. Then I will use my own DBL_MAX* = 1e308 # fix later
07:48:35FromGitter<StefanSalewski> Logout
07:56:48saemYardanico: are you doing release only or danger as well? Does lifting bark out help?
07:58:49*krux02 joined #nim
08:05:55*NimBot joined #nim
08:19:05*lritter joined #nim
08:22:13*sirn quit (Quit: Connection closed for inactivity)
08:31:09*leorize quit (Ping timeout: 240 seconds)
08:31:34*leorize joined #nim
08:39:51FromDiscord<Yardanico> -d:danger
08:40:14FromDiscord<Yardanico> and wdym "lifting bark"? even without having that field the speeds are roughly the same
08:40:25FromDiscord<Yardanico> also arc is known to have slower methods because it uses string comparisons for them
08:41:12FromDiscord<Yardanico> but it's weird for me that all other 3 types of runtime dispatch are much faster with arc
08:41:19FromDiscord<Yardanico> so I wonder if my benchmark is wrong
08:45:27*vicfred quit (Quit: Leaving)
08:48:14saemProfiler gives no hints?
08:49:43FromDiscord<Yardanico> i haven't tried profiling yet :P
08:52:57FromDiscord<Esther> hello, in D when making slices you can write arr[0 .. $-1] where $ is replaced with arr.length for convenience. Is there something similar in nim or do I have to write arr.len every time?
08:53:04FromDiscord<Rika> ^1
08:53:08FromDiscord<Yardanico> arr[0..^1]
08:53:10FromDiscord<Rika> arr[0..^1]
08:53:13FromDiscord<Rika> wow
08:53:15FromDiscord<Rika> how dare you
08:54:03FromDiscord<Esther> oh!
08:54:04FromDiscord<Esther> thank you
08:54:24FromDiscord<Esther> I saw that in the docs but I glanced at it and thought "oh that's not what I want" and ignored it
09:16:41*Q-Master quit (Quit: No Ping reply in 180 seconds.)
09:16:48*Q-Master joined #nim
09:33:57FromDiscord<jtiai> Stupid questions but `while i <=% FOOBAR` what that comparison operation means?
09:36:34FromDiscord<Yardanico> you can always search for operators in the doc search bar
09:36:43FromDiscord<Yardanico> https://media.discordapp.net/attachments/371759389889003532/825664690125930516/unknown.png
09:36:49FromDiscord<Yardanico> "Treats x and y as unsigned and compares them. Returns true if unsigned(x) <= unsigned(y)."
09:37:17FromDiscord<Rika> so something that shouldnt really be used anymore?
09:37:20FromDiscord<Yardanico> why?
09:37:24FromDiscord<Rika> idk its a question
09:37:28FromDiscord<Rika> im asking
09:38:03FromDiscord<Yardanico> it would've been marked with deprecated (or there would be a note in the doc) if it were something that shouldn't be used anymore :)
09:38:11FromDiscord<jtiai> BTW, for me manual page is broken...
09:38:18FromDiscord<Yardanico> how so?
09:38:35FromDiscord<Yardanico> what do you mean by "broken"? https://nim-lang.org/docs/manual.html opens here just fine
09:38:35FromDiscord<jtiai> https://media.discordapp.net/attachments/371759389889003532/825665163654987796/unknown.png
09:39:04FromDiscord<Yardanico> weird, works for me
09:39:06FromDiscord<Yardanico> what's your browser?
09:39:53FromDiscord<jtiai> Firefox ESR: 78.8.0esr (64-bit)
09:41:13FromDiscord<Yardanico> works for me in latest firefox and firefox esr
09:41:27FromDiscord<Yardanico> you're searching from https://nim-lang.org/docs/manual.html, right?
09:41:42FromDiscord<jtiai> Yes.
09:41:51FromDiscord<Yardanico> then it's really weird, probably a browser+OS combination issue
09:42:07FromDiscord<Yardanico> how does https://nim-lang.org/docs/system.html#%3C%3D%25%2Cint%2Cint look for you?
09:43:19FromDiscord<jtiai> It's fine. It was only that search part that doesn't work...
09:47:43FromDiscord<jtiai> Also search response from ajax seems to be fine so must be something magical happening when extracting that info from respnse.
10:00:52FromDiscord<jtiai> More stupid questions. In python you can do `" " 10` which returns a string with 10 spaces. Is there equivalent for nim?
10:02:54FromDiscord<Yardanico> https://nim-lang.org/docs/strutils.html#repeat%2Cchar%2CNatural and https://nim-lang.org/docs/strutils.html#repeat%2Cstring%2CNatural
10:03:27FromDiscord<Yardanico> you can always make your own operator that will call those procs so you have the same behaviour as in Python, but I'd advise against it :P
10:05:40FromDiscord<jtiai> I'm pretty sure that I can't use strutils...
10:05:46FromDiscord<jtiai> Since I don't have standard library.
10:07:22FromDiscord<Yardanico> @jtiai wdym?
10:07:55FromDiscord<jtiai> I writing operating system. So my operating system doesn't yet have standard libraries.
10:08:17FromDiscord<Yardanico> do you have heap in your OS and have you tried ARC/ORC?
10:08:40FromDiscord<Yardanico> with heap and ARC/ORC you can just use the strutils module, otherwise you'll have to implement it yourself
10:08:58FromDiscord<Yardanico> and with `cstring` instead of `string` of course, since string is heap-allocated
10:09:16FromDiscord<jtiai> Nope, I'm at quite beginning since IDT and IRQs gave bunch of headaches for few days,
10:09:24FromDiscord<jtiai> So no memory management yet.
10:09:41FromDiscord<Yardanico> if your string is a static literal you can always repeat it at compile-time
10:09:46FromDiscord<jtiai> just writing the kernel part and basic cosnole IO.
10:10:04FromDiscord<Yardanico> also, do you want to simply write the same string N amount of times?
10:10:14FromDiscord<Yardanico> if so, just use for/while loops and write(text) :P
10:10:35FromDiscord<jtiai> That's what I'm doing. Single liner would have fun though 🙂
10:10:47FromDiscord<Yardanico> you can always write a template that will do this loop for you
10:11:44FromDiscord<Rika> static: "".repeat(10)
10:11:45FromDiscord<Rika> xd
10:11:51FromDiscord<Yardanico> I mentioned that above
10:14:21FromDiscord<jtiai> And most probably that repear relies on some stdlib functionality which I don't yet have for my OS.
10:14:31FromDiscord<Yardanico> @jtiai no, this will run at compile time
10:15:00FromDiscord<Yardanico> as I said, if you have a static literal (string that's know at compile-time), you can repeat it at compile-time
10:15:22FromDiscord<jtiai> Ah so it generates physical string...
10:17:11ForumUpdaterBotNew question by Johannes Hoff: How to construct a `select ... in` SQL query in nim?, see https://stackoverflow.com/questions/66840355/how-to-construct-a-select-in-sql-query-in-nim
10:31:22FromDiscord<jtiai> More stupid questions coming: python has relatively handy no-op syntax `pass` is there similar to nim? If i understood correctly `discard` doesn't just let function to go on but terminates it.
10:32:17liblq-devdiscard is a noop
10:32:18liblq-devjust like pass
10:36:08FromDiscord<jtiai> \o/ my os has keyboard now and basic console io.
11:12:10FromDiscord<Yardanico> is it guaranteed that == nil or .isNil() will be true for a dealloc'd pointer?
11:12:26FromDiscord<Yardanico> !eval echo var a = alloc(1); a.dealloc(); echo cast[uint](a)
11:12:27NimBotCompile failed: /usercode/in.nim(1, 10) Error: undeclared identifier: 'a'
11:12:36FromDiscord<Yardanico> !eval var a = alloc(1); a.dealloc(); echo cast[uint](a)
11:12:38NimBot140430955720784
11:12:50FromDiscord<Yardanico> ah of course not
11:12:54FromDiscord<Yardanico> since its a pointer
11:46:02ozzzafter successful integration of FCGI lib with NIM, I will give a try to create lv2 plugin. What you think, will be created audio DSP plugin fast enough to have low latency?
11:46:33liblq-devyes
11:46:53liblq-devuse --gc:arc if you want to be 100% sure
11:47:51ozzzthis may change many things, I hate c++, and creating such complicated software using C quiet bit difficult
11:48:27ozzzliblq-dev, --gc:arc is similat to -march-native?
11:48:45ozzz*-march=native
11:48:57liblq-devno, it's a different memory management model that's better suited for realtime use
11:49:17liblq-devnim can do -march=native though if you wanna
11:49:22liblq-dev--passC:-march=native
11:49:25ozzzawesome :) thanks for explanation
11:49:38ozzzyeah, it will pass to gcc that flag
11:51:05ozzzbtw here is code for libfcgi, if somebody is interested: https://github.com/Mikoool/NIM_libFCGI
11:52:57FromDiscord<Yardanico> just FYI - Nim is not an acronym so it's Nim and not NIM :)
11:54:07ozzzoh, I will edit it then..
12:00:21*Vladar joined #nim
12:07:37*PMunch joined #nim
12:19:35FromDiscord<clyybber> In reply to @Yardanico "is it guaranteed that": nope
12:20:03FromDiscord<Yardanico> @clyybber I posted https://github.com/nim-lang/Nim/issues/17552 in #internals :)
12:20:09FromDiscord<Yardanico> not sure if we should deprecate global altogether for ARC/ORC
12:20:15FromDiscord<Yardanico> but it can be useful sometimes
12:20:46FromDiscord<clyybber> oh I replied
12:31:23FromDiscord<Yardanico> Is there any reason to have peername in https://github.com/nim-lang/Nim/blob/devel/lib/pure/net.nim#L775 ? It causes a leak and it's not required if we don't need SAN or the CN
12:31:33FromDiscord<Yardanico> from the OpenSSL docs: "When the certificate is matched, and peername is not NULL, a pointer to a copy of the matching SAN or CN from the peer certificate is stored at the address passed in peername. The application is responsible for freeing the peername via OPENSSL_free() when it is no longer needed."
12:33:48FromDiscord<Yardanico> @federico3 around?
12:34:08FromDiscord<Yardanico> from git commits it seems that you added this proc, so I want to confirm with you that it actually causes a leak
12:40:32FromDiscord<Yardanico> https://github.com/nim-lang/Nim/pull/17554
12:45:42federico3looking
12:47:04PMunchHmm, is there a way to have an "interface" like what we have for streams but on compile-time
12:47:53PMunchLike I have my "Pin" abstraction for the Teensy stuff right now, but I'd like to be able to extend that for IO expanders
12:47:56FromDiscord<Yardanico> For what it's worth https://github.com/yglukhov/iface works at compile-time :P
12:52:13federico3Yardanico: looks good, unless we want to return the name as a discardable string
12:52:41federico3also, should we enable this checks on windows as well?
12:52:47FromDiscord<Yardanico> not sure about that :P
12:53:10FromDiscord<Yardanico> it was disabled before because we didn't do certificate checking on windows, right?
12:57:57federico3the original plan was to introduce checking incrementally
12:58:48federico3but later on this issues have been treated as vulnerabilities
13:05:28*tane joined #nim
13:31:20FromDiscord<jtiai> There are quite few docs about interfacing external libs with Nim, but how about otherway around, how I could call for example from C-code some Nim function?
13:31:58PMunchFirst you'd need to attach the `{.exportc.}` pragma to your function
13:32:08PMunchThen you should be able to call them normally
13:32:16Oddmongerso it seems that {.global.} should not be used with arc/orc (forum post https://forum.nim-lang.org/t/7709 ), what can be used instead to have static vars in proc ?
13:32:32PMunchhttps://nim-lang.org/docs/backends.html#backend-code-calling-nim-nim-invocation-example-from-c
13:32:47PMunchSee this for example @jtiai ^
13:34:06FromDiscord<jtiai> Ah, need to tell nim to create header. That was the missing piece from my puzzle.
13:37:39PMunchI mean you can write it yourself
13:37:57PMunchOr if you're interfacing with some already written C code you probably have to match some already known signature
13:51:12*hsh_ joined #nim
13:51:59FromDiscord<jtiai> not really. just trying to interface my own OS kernel with minimalistic libc so I could expand my kernel much more easier.
13:54:23PMunchAah I see
13:54:37PMunchWriting your own OS kernel in Nim?
13:57:05FromGitter<UrKr> If I have Event types that are all subtypes of some BaseEvent, how do I dispatch based on which subtype a function receives? ⏎ I surmise that I'm actually going in the wrong direction though. ⏎ AppEvent = ref object of RootObj ⏎ SpecificEvent1 = ref object of AppEvent ⏎ SpecificEvent2 = ref object of AppEvent [https://gitter.im/nim-lang/Nim?at=60608b3188edaa1eb8e7d7fe]
13:57:58FromGitter<UrKr> I have procs defined that handle SpecificEvent1 and SpecificEvent2 respectively, but how do I get to these two procs from a sequence of AppEvents ?
13:59:37FromDiscord<jtiai> In reply to @PMunch "Writing your own OS": Yes. Fun stuff.
13:59:47PMunchOh indeed
13:59:54ForumUpdaterBotNew question by mkrieger1: What is a simple and safe way to choose a random enum value?, see https://stackoverflow.com/questions/66842219/what-is-a-simple-and-safe-way-to-choose-a-random-enum-value
14:00:08PMunchHaven't tried doing it in Nim, but we had to write a small OS in C back in uni
14:03:26FromGitter<UrKr> I suppose I should do it with a case type... however that would mean all the fields would have to be namespaced because they repeat a lot
14:04:02ozzzwow, own kernel? will it be unix-like?
14:05:29ozzzPMunch, nice, and we ended with stdio.h
14:05:46PMunchozzz, huh?
14:06:50ozzzyeah ) math was priority, and lecturer jumped to c++
14:07:25ozzzseems he not knew C too much, and started to study what he knows better lol
14:09:49PMunchWe went from the bottom up. Started writing our own bootloader that bootstrapped itself into the rest of our OS. By the end of it we had a multi-tasking OS that could run multiple small programs at the same time by doing context switching and such. Actually pretty cool
14:09:53FromDiscord<Goel> @PMunch Hello, i was having a look at your repo of Drawille-nim, i know its old but the examples all works, except the gameofLife. It gave me an error with the identifier "random" The module is imported correctly, i tried to replace `random()` in the code with `rand()` and also added an initialization `randomize()` . Now the example compiles without errors but i don't see anything on screen on my terminal
14:09:58PMunchWritten in Assembly/C
14:10:22PMunch@Goel, hmm, give me a sec
14:12:28PMunchTry hitting `c` after you've started it
14:12:50PMunchThat 'c'reates more life
14:13:56PMunch'q'uit to exit out of the simulation and setting your terminal back correctly
14:14:12ozzzPMunch, but drivers, how you managed to work with hardware
14:14:34PMunch's'ave to save a PNG "output.png"
14:14:45PMunch'l'oad to load the image "input.png"
14:14:55PMunch'p'ause to pause the simulation
14:14:58FromDiscord<Goel> @PMunch Yes now it works perfectly thanks
14:15:18PMunch'f'orward to perform one step while paused
14:15:38PMunchozzo, didn't really have any hardware interaction
14:16:09PMunchIt set the output to terminal mode output, and I don't think you could interact with any of the programs (not 100% sure, might've had keyboard support)
14:16:22ozzzI got, you made it just for understanding concept of os
14:16:38PMunchYup
14:16:46PMunchAnd context switching
14:45:08FromDiscord<jtiai> In reply to @PMunch "Haven't tried doing it": Nim works pretty fine. Irq caller routines I wrote in asm because it was easier that way.
14:45:38PMunchYeah that's the stuff we wrote in assembly when we where doing C as well I believe
14:48:41FromDiscord<jtiai> I now do have basic console working and attempt to write libc for kernel itself so I could expand what I can use from Nim.
14:52:11FromGitter<deech> Is there a way to get the fully qualified name of a type using `getTypeInst()`? eg. if I have a type `MyType` in module `types` and I do `from types as t import nil` I'd like `..getTypeInst().repr` to print `t.MyType` instead of just `MyType`.
14:58:14FromDiscord<mratsim> maybe `owner` can give the module name
14:58:55FromGitter<deech> It does but not the aliased name, so it'll print `types` and not `t`.
15:11:31*abm joined #nim
15:26:45FromDiscord<sealmove> Is there a way to tell testament to put executables in a different directory?
15:29:08FromGitter<Bennyelg> After installing Nim from source - How i define the nimsuggest path in VSCode ? for auto completion ?
15:29:26FromDiscord<Yardanico> you don't need to do that, just add your nim binary folder to $PATH
15:29:35FromDiscord<Yardanico> in your system
15:29:39FromGitter<Bennyelg> I did
15:29:42FromGitter<Bennyelg> didn't work
15:29:45FromDiscord<Yardanico> then it should work
15:29:47FromDiscord<Yardanico> did you relogin or reboot?
15:29:57FromDiscord<Yardanico> and where did you put it? E.g. if you put it in ~/.profile VSCode might not see it
15:30:01FromGitter<Bennyelg> PATH=/Users/ABC/personal_workspace/Nim/bin
15:30:05FromDiscord<Yardanico> the best bet is to put it in /etc/profile or /etc/environment
15:30:06FromGitter<Bennyelg> ~/.zhsrc
15:30:16FromDiscord<Yardanico> yeah, that won't work unless you start `vscode` from the terminal
15:30:17FromGitter<Bennyelg> ~/.zshrc**
15:30:23FromGitter<Bennyelg> oh
15:31:40FromGitter<Bennyelg> didnt work too & the go to also :(
15:31:47FromGitter<Bennyelg> but when I compile and run it it works just fine
15:32:10FromDiscord<Yardanico> yes, because nimsuggest is used for go to definition as well
15:32:22FromDiscord<Yardanico> as I said, you need to add it to system-wide PATH so it works everywhere
15:32:26FromGitter<Bennyelg> donnu why the PATH edition didnt work
15:32:33FromGitter<Bennyelg> how I add system-wide PATH ?
15:32:50FromDiscord<Yardanico> https://apple.stackexchange.com/questions/33232/where-is-the-system-wide-path-shell-variable-set-in-os-x
15:33:19FromDiscord<Yardanico> /etc/environment usually
15:33:30FromDiscord<Yardanico> or rather /etc/profile
15:33:38FromGitter<Bennyelg> yea thanks trying now
15:33:45FromDiscord<Yardanico> and then you'll have to relogin or reboot
15:38:00FromGitter<Bennyelg> thanks that works
15:42:10*xet7 quit (Remote host closed the connection)
15:43:22*xet7 joined #nim
15:45:57*PMunch quit (Quit: leaving)
15:54:15FromDiscord<treeform> In reply to @Yardanico "for me with refc": How do you install `iface`?
15:54:20FromDiscord<Yardanico> github
15:54:33FromDiscord<Yardanico> nimble install https://github.com/yglukhov/iface or the same in the nimble file
15:54:45FromDiscord<treeform> oh I was trying to get this going: https://github.com/zielmicha/collections.nim/blob/master/collections/iface.nim
15:54:49FromDiscord<treeform> name collision!
15:54:52FromDiscord<Yardanico> xd
15:56:45FromDiscord<treeform> wow arc is a lot faster on this benchmark
15:58:51FromDiscord<Yardanico> exactly, that's why I was confused
16:00:58FromDiscord<treeform> Just using if statement appears to be a little faster then case object... but not statistically significant.
16:01:15FromDiscord<treeform> sent a code paste, see https://play.nim-lang.org/#ix=2UnB
16:01:39FromDiscord<Yardanico> yeah so I was wondering if my benchmark is wrong since with arc all types of dispatch except methods are much faster
16:02:30FromDiscord<Yardanico> methods' slowness is actually noticeable when you call a method thousands of times a second
16:02:59FromDiscord<Yardanico> I PR'd to https://github.com/def-/nimes to replace methods with streams-like "interfaces" to make it do 60FPS on ARC as it did with refc
16:03:08FromDiscord<Yardanico> (of course streams-like interfaces are faster than methods even with refc)
16:04:07*Gustavo6046 quit (Quit: ZNC 1.8.2 - https://znc.in)
16:05:03*Gustavo6046 joined #nim
16:06:02saemSeems weird that the dispatch difference would be so high, between ARC and refc
16:06:13FromDiscord<dom96> Sounds like we should get rid of methods from the language
16:06:23FromDiscord<Yardanico> well methods with arc are slower because of string comparisons as I said @saem
16:06:43FromDiscord<Yardanico> they check which method to call by strstr
16:06:50FromDiscord<Yardanico> https://github.com/nim-lang/Nim/blob/devel/lib/system/arc.nim#L232
16:07:40FromDiscord<treeform> oh wow that sounds python kind of slow
16:07:53FromDiscord<treeform> function pointers to closures appear to be the fastest
16:08:00FromDiscord<Yardanico> https://github.com/nim-lang/Nim/blob/devel/compiler/ccgexprs.nim#L1574
16:08:21FromDiscord<treeform> sent a code paste, see https://play.nim-lang.org/#ix=2UnD
16:08:42FromDiscord<Yardanico> how can they be faster than case objects? 🤔
16:09:28FromDiscord<Yardanico> anyway, I'm doing more memory leak debugging for nim's SSL rn
16:09:41FromDiscord<Yardanico> Fixed one in https://github.com/nim-lang/Nim/pull/17554 and checking another one rn
16:09:53FromDiscord<treeform> My hypothesis is that function call always does a pointer indirection. With case/if objects you do a check and then call a function by pointer. With a pointer you just call a function by pointer...
16:09:59FromDiscord<Yardanico> oh
16:10:25FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=2UnF
16:11:01FromDiscord<dom96> @Yardanico amazing that you're doing this, thank you 🙂
16:11:04saemMethods are great when you need them, their utility is likely to increase dramatically over time. The principles themselves are sound, the rest is implementation.
16:12:01FromDiscord<dom96> saem: the reason I said the above is because my assumption is that methods can be relatively easily implemented outside the compiler
16:13:03saemI don't think so, type information and directed dispatch is painful to do outside. The current implementation and sophistication of it in ARC, sure. But otherwise... Ouch
16:15:56saemI gave trying to get CPS moving yesterday and it was a very humbling reminder as to what it's like for the user to do that kinda stuff.
16:16:41FromDiscord<Yardanico> wait lol, I think the leak might be in the same checkCertName proc as the previous one
16:16:55FromDiscord<Yardanico> https://www.openssl.org/docs/man1.1.1/man3/SSL_get_peer_certificate.html
16:16:55FromDiscord<Zachary Carter> gave or gave up? haha
16:17:01FromDiscord<Yardanico> "The X509 object must be explicitly freed using X509_free()."
16:17:06FromDiscord<Yardanico> and we don't do that :P
16:17:24FromDiscord<Yardanico> I don't even see X509_free in our openssl wrapper
16:17:27FromDiscord<Zachary Carter> I don't know how we miss stuff like this - it's probably laziness
16:17:41FromDiscord<Zachary Carter> this is a pattern in like every C library haha
16:18:01saemPast tense, because I gave up on that very specific implementation path, but that implementation has a ton of key lessons.
16:18:11FromDiscord<Zachary Carter> Cool 🙂
16:18:25*FromDiscord quit (Remote host closed the connection)
16:18:42*FromDiscord joined #nim
16:19:00saemNim wrapping C is still C and fraught with all the dangers thereof.
16:19:56FromDiscord<Zachary Carter> No I get that - it's just I know whenever I am writing Nim that relies on some C, if I forget to free some allocation it's because I said to myself "I'll add that later" and I never do ;P
16:20:07FromDiscord<Zachary Carter> but the fact that I need to do it - is very obvious
16:20:20FromDiscord<Zachary Carter> because I had to perform an allocation in the first place \
16:20:22FromDiscord<Zachary Carter> (edit) removed "\"
16:20:34FromDiscord<Zachary Carter> or call some initialization method or something in the library
16:20:49FromDiscord<Zachary Carter> but yeah - it happens
16:21:11FromDiscord<dom96> Not everybody has the same amount of experience as others when it comes to C, it's likely not immediately obvious to most that they need to free something and SSL docs are themselves crap so it adds to the complexity
16:21:14saemHmm
16:21:31FromDiscord<Yardanico> I'm really not sure but the leak only happens under valgrind 🤔
16:21:55FromDiscord<Zachary Carter> what else have you tested with?
16:22:13FromDiscord<Yardanico> if you mean the memory profiling tools, none yet, but I'll test with heaptrack
16:22:33FromDiscord<Zachary Carter> In reply to @dom96 "Not everybody has the": good point
16:22:53FromDiscord<Zachary Carter> In reply to @Yardanico "if you mean the": another useful test might be running asan on macOS
16:23:02FromDiscord<Yardanico> well I can use asan on Linux as well :)
16:23:07FromDiscord<Zachary Carter> oh true
16:24:10federico3also, interactions between Nim's GC and destructors in C libraries can be confusing
16:24:55FromDiscord<Yardanico> I don't see any destructors/finalizers used for PX509 though?
16:25:00FromDiscord<Yardanico> but yeah, it's weird that the leak only happens under valgrind
16:25:25FromDiscord<Yardanico> or maybe it's because without valgrind openssl malloc'd memory is not part of the virt/rss memory in htop?
16:26:36FromDiscord<flywind> hi @Yardanico what's the state of this issue? does my fix work? https://github.com/nim-lang/Nim/issues/17370
16:28:40FromDiscord<Yardanico> @flywind sorry, I havne'
16:28:49FromDiscord<Yardanico> haven't looked into it yet, need to set up an older macOS VM :(
16:28:57FromDiscord<Yardanico> About the leak - after adding X509_free it goes away
16:29:09FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=2UnK
16:29:13FromDiscord<Yardanico> much better than before - nothing indirectly lost
16:29:23FromDiscord<Yardanico> the 610kb is the global SSL context
16:29:31FromDiscord<Rika> nice
16:31:35FromDiscord<Yardanico> that 315 bytes is the leak that I already fixed
16:31:46FromDiscord<Yardanico> so we only have "possibly lost" 56 bytes in a single block
16:31:55FromDiscord<Yardanico> which doesn't grow with more reqs so it's not as bad
16:32:28FromDiscord<flywind> good job! I saw the leaks before but didn't look into it.
16:39:03FromDiscord<Yardanico> well debugging memory leaks like that isn't exactly hard, it just might take some amount of time :P
16:39:10FromDiscord<Yardanico> but it's satisfying when you don't see any leaks in the end
16:41:20FromDiscord<Yardanico> https://github.com/nim-lang/Nim/pull/17558
16:42:52FromDiscord<dom96> I wonder if we should invest in some tests for these
16:43:10FromDiscord<dom96> in fact, it might be good to run valgrind for all tests that run on arc
16:47:01*azed joined #nim
16:49:12FromDiscord<Yardanico> with my PR clang's leak sanitizer (fsanitize=leak) is happy and doesn't error when doing HTTPS requests
16:50:21FromDiscord<Yardanico> but I'm still confused as to why memory usage of the process wasn't growing in htop
16:50:33FromDiscord<Yardanico> I know OpenSSL uses its own memory allocation functions, but they still should count towards RSS, no?
16:55:56*azed quit (Read error: Connection reset by peer)
16:57:07*teasea quit (Quit: teasea)
16:59:12*teasea joined #nim
16:59:53*sixtyten quit (Quit: Leaving)
17:03:14FromDiscord<TurtleP> Hi, so I'm working on a piece of code that converts a png to a special format. I kind of have it working, but the issue is translating the code from C to nim. I'm stuck on line 17 of this pastebin <https://pastebin.com/FCFjSEjN> since the original code is a pointer to a pointer after indexing (iirc). This is the C code: <https://github.com/devkitPro/3dstools/blob/master/src/smdhtool.cpp#L360>. I'm not sure how to go about doing this and a
17:04:56FromDiscord<Yardanico> in this case you'll have to use an UncheckedArray I think
17:05:24FromDiscord<Yardanico> also I've seen someone done the same stuff recently
17:05:32FromDiscord<Yardanico> you need to convert a PNG to a windows icon, right?
17:05:38FromDiscord<TurtleP> no, it's a different format
17:05:52FromDiscord<TurtleP> it's tiling an image for 3DS homebrew
17:09:10*fputs joined #nim
17:10:05*Onionhammer8 joined #nim
17:11:32*Onionhammer quit (Ping timeout: 246 seconds)
17:11:32*Onionhammer8 is now known as Onionhammer
17:27:04FromDiscord<TurtleP> In reply to @Yardanico "in this case you'll": Hm.. tried to look at the docs on how to apply it here, although I'm still lost :/
17:27:17FromDiscord<TurtleP> it wouldn't let me turn it into an UncheckedArray
17:28:10*wasted_youth2 quit (Ping timeout: 258 seconds)
17:28:31*stefantalpalaru quit (Quit: ZNC 1.7.5 - https://znc.in)
17:29:57*wasted_youth2 joined #nim
17:31:44*azed joined #nim
17:35:37*hsh_ quit (Quit: Connection closed for inactivity)
17:37:01*stefantalpalaru joined #nim
17:38:10*lritter quit (Quit: Leaving)
17:42:44FromGitter<Bennyelg> Someone had this before ? ⏎ ERROR: Unable to start debugging. GDB exited unexpectedly with exit code 134 (0x86).
17:43:02*stefantalpalaru quit (Changing host)
17:43:02*stefantalpalaru joined #nim
17:44:23FromDiscord<Yardanico> i think that you should search in google, that error seems to be specific to gdb in vscode on macos
17:48:23*D_ quit (Remote host closed the connection)
17:49:03*D_ joined #nim
17:51:12reversem3anyone programming on arduino using nim ?
17:54:17FromDiscord<dom96> sure, join #nim-embedded if you haven't already 🙂
17:56:05reversem3thanks
17:58:54FromDiscord<Yardanico> no one even in the ##openssl freenode channel replied to me about the memory usage
17:59:07FromDiscord<Yardanico> maybe somehow the leak doesn't occur when not running under valgrind?
18:02:05ForumUpdaterBotNew thread by Chaemon: Strange behavior (Bug?) of member-iterator of object, see https://forum.nim-lang.org/t/7712
18:07:38FromDiscord<Zachary Carter> @TurtleP - does this work? https://play.nim-lang.org/#ix=2Uoe
18:08:18FromDiscord<Zachary Carter> sorry https://play.nim-lang.org/#ix=2Uof
18:08:21FromDiscord<Zachary Carter> just updated it
18:15:05FromDiscord<TurtleP> @Zachary Carter will check soon
18:29:14FromDiscord<TurtleP> @Zachary Carter sorry for the double ping, but I get this now: https://media.discordapp.net/attachments/371759389889003532/825798699833491517/unknown.png
18:37:12FromDiscord<Yardanico> ok apparently I'm still sane
18:37:25FromDiscord<Yardanico> and yes that code leaked even with refc, it's just that it leaks like 5kb per request so it's not easily noticeable
18:38:06FromDiscord<Yardanico> running a while true loop of a request makes memory usage grow
18:41:49FromDiscord<Zachary Carter> @TurtleP did you see my change to where image was declared?
18:41:52FromDiscord<Zachary Carter> you need a `var` not a `let`
18:42:02FromDiscord<TurtleP> ah
18:43:07FromDiscord<Yardanico> @Zachary Carter wouldn't that code be getting an addr of an uint8 though?
18:43:17FromDiscord<Yardanico> sorry, uint16
18:43:21FromDiscord<Yardanico> with image[xxx] you get an uint16 and then try to get addr of it
18:43:47FromDiscord<Zachary Carter> Well I don't think PNGs are 16bpp
18:43:56FromDiscord<Yardanico> I'm talking about the code
18:44:07FromDiscord<Zachary Carter> yeah so the image should probably be a seq of uint8 right?
18:44:19FromDiscord<Yardanico> it's uint16 there, and anyway, my point is - you'll be getting an addr of a local int
18:44:27FromDiscord<Yardanico> not the position from the seq
18:45:19FromDiscord<Zachary Carter> I see what you mean
18:45:21FromDiscord<Yardanico> shouldn't it be something like cast[ptr UncheckedArray[uint8]](addr image[4 (48 (y + yy) + (x + xx))])
18:45:39FromDiscord<Yardanico> ah actually this is the same, yeah, lol
18:45:47FromDiscord<Zachary Carter> it is yeah
18:45:48FromDiscord<Yardanico> i'm still confused though, need actual code to try :P
18:45:58FromDiscord<Zachary Carter> you probably want a slice of the original sequence
18:46:12FromDiscord<Zachary Carter> starting from whatever index `4 (48 (y + yy) + (x + xx))` evaluates to
18:46:19FromDiscord<Zachary Carter> because you're index from there
18:46:57FromDiscord<Yardanico> well then your code is right, and mine too
18:47:26FromDiscord<Zachary Carter> yeah I think it's right
18:54:00*azed quit (Quit: WeeChat 3.1)
19:13:53FromDiscord<Yardanico> ok, after that PR no leaks for simple https requests, only "still reachable" and "possibly reachable" which are a part of the global SSL context
19:14:27ForumUpdaterBotNew thread by Zetashift: Neovim users, how are you setting up Nim?, see https://forum.nim-lang.org/t/7713
19:21:30FromDiscord<Yardanico> damn ssl surely takes time
19:23:13FromDiscord<Yardanico> I know that benchmarks shouldn't really be done on IO because of network latency and stuff, but
19:23:20FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=2UoJ
19:23:28FromDiscord<Yardanico> https request takes ~2.5 more time to complete
19:42:00FromDiscord<Mustache Man> there's a problem with the solution provided to me here: https://play.nim-lang.org/#ix=2Ujh
19:42:21FromDiscord<Mustache Man> sent a code paste, see https://play.nim-lang.org/#ix=2UoN
19:43:15FromDiscord<Mustache Man> the callback is dependent on the index i, but i keeps being incremented, so n.network.nodes[i] is always the last node in the sequence
19:45:04FromDiscord<Yardanico> classical closure issue :)
19:45:05FromDiscord<Yardanico> use closureScope
19:45:18FromDiscord<Yardanico> or rather capture
19:45:18FromDiscord<Yardanico> https://nim-lang.org/docs/sugar.html#capture.m%2Cvarargs%5Btyped%5D%2Cuntyped
19:45:51FromDiscord<Yardanico> something like that I guess
19:45:54FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=2UoO
19:46:01FromDiscord<Yardanico> also not(receiver == n) is the same as receiver != n
19:47:04FromDiscord<Mustache Man> perfect!
19:47:39FromDiscord<Mustache Man> sometimes nim feels so high-level that the low-level gotchas are surprising
19:48:17FromDiscord<Mustache Man> like i was really thrown off by a segfault after i forgot the [type] after a cast
19:48:37FromDiscord<Yardanico> wait why cast?
19:48:43FromDiscord<Yardanico> in most cases a conversion should be fine
19:49:09FromDiscord<Yardanico> e.g. if you want to convert an inherited object to its base type you simply do BaseObj(myobj) not cast[BaseObj](myobj)
19:49:25FromDiscord<Mustache Man> other way around though
19:49:31FromDiscord<Yardanico> it still should work
19:50:36FromDiscord<Mustache Man> oh how does it look to convert a parent into a child object
19:51:32FromDiscord<Mustache Man> oh nvm
19:51:47FromDiscord<Mustache Man> (edit) "nvm" => "nvm, i misread"
19:51:56FromDiscord<Mustache Man> (edit) "misread" => "misread. thank you, that will clean up some code for sure"
19:55:25*xet7 quit (Remote host closed the connection)
20:07:09FromDiscord<Yardanico> any thoughts on https://github.com/nim-lang/RFCs/issues/356 ?
20:09:23FromDiscord<haxscramper> Looks nice, but as you already mentioned in comments it can be done in three different ways already
20:09:50FromDiscord<Yardanico> well that's nim for you :D
20:10:12FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=2Up0
20:10:17FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=2Up1
20:10:21PrestigeIn the case statement example, wouldn't that already return a value without having `return` there?
20:10:25FromDiscord<Yardanico> (edit) "https://play.nim-lang.org/#ix=2Up1" => "https://play.nim-lang.org/#ix=2Up2"
20:10:38FromDiscord<haxscramper> yes, `of <expr>: value` returns
20:10:50FromDiscord<Yardanico> only when the case statement is exhaustive and there's an matching else (for if) with another branch
20:10:53FromDiscord<Yardanico> i mean as of now
20:10:56FromDiscord<haxscramper> If all branches are either expression of the same type or contain `{.noreturn.}`
20:11:20FromDiscord<haxscramper> I can do one branch with `raise/quit/return` and all others into expression
20:11:36FromDiscord<haxscramper> `break/continue` works too I think, but I don't remember correctly
20:12:25FromDiscord<Yardanico> I don't think they work since they are not noreturn
20:12:41FromDiscord<haxscramper> In reply to @Yardanico "It's actually 4 since": I'd much rather vote for `return block:` to work
20:16:18FromDiscord<Yardanico> on an unrelated note, I really like how google's closure-compiler works with Nim's JS output
20:16:34FromDiscord<Yardanico> sadly it breaks sometimes, or throws away all JS code
20:17:48FromDiscord<Yardanico> for dochack.nim with js -d:danger closure compiler makes this file: `Math.trunc||(Math.trunc=function(a){a=+a;return isFinite(a)?a-a%1||(0>a?-0:0===a?a:0):a});` :D
20:18:02FromDiscord<Yardanico> I guess because functions from dochack aren't used anywhere in the file itself
20:18:57FromDiscord<Yardanico> "When you compile functions without compiling the code that calls those functions, the Compiler assumes that the functions are never called and removes them."
20:20:26FromDiscord<Yardanico> well it can be fixed with https://developers.google.com/closure/compiler/docs/api-tutorial3#removal
20:22:53*haxscramper quit (Remote host closed the connection)
20:23:21*haxscramper joined #nim
20:23:22*haxscramper quit (Read error: Connection reset by peer)
20:27:02*vicfred joined #nim
20:36:35ForumUpdaterBotNew thread by JohnAD: Converting a hex string to uint32 in JS context, see https://forum.nim-lang.org/t/7714
20:50:20FromDiscord<dom96> @Yardanico yeah, you need to export the functions you want it to keep
20:50:31FromDiscord<Yardanico> simple `export` didn't work though :)
20:50:44FromDiscord<Yardanico> export function xxx ...
20:51:36FromDiscord<Yardanico> also I don't get why we add stdlib modules which are hidden under defines anyway - https://github.com/nim-lang/Nim/pull/12531
20:51:48FromDiscord<Yardanico> so to use https://nim-lang.github.io/Nim/jsfetch.html you must `import std/jsfetch` and also `-d:nimExperimentalJsfetch`
20:51:50FromDiscord<Yardanico> why?...
20:55:48FromDiscord<Yardanico> I mean I understand that the purpose is to show people that the module is "experimental", but isn't putting a warning when compiling or a warning in the module docs enough?
21:02:25FromDiscord<dom96> I don't get why we're not creating nimble packages first...
21:13:57FromDiscord<Zachary Carter> is it possible to grab a slice from an unchecked array?
21:14:09FromDiscord<Yardanico> I think so
21:14:09FromDiscord<Zachary Carter> or is `toOpenArray` the only way?
21:14:26FromDiscord<Yardanico> toOpenArray works on an unchecked array :)
21:14:28FromDiscord<Yardanico> https://nim-lang.org/docs/system.html#toOpenArray%2Cptr.UncheckedArray%5BT%5D%2Cint%2Cint
21:14:29FromDiscord<Zachary Carter> getting some weird errors regarding out of bounds exceptions
21:14:50FromDiscord<Zachary Carter> I know it does but seq.add with toOpenArray on my unchecked array is producing some out of bounds exception and I don't understand why
21:32:19FromDiscord<Zachary Carter> figured out what I was doing wrong
21:52:53*tane quit (Quit: Leaving)
22:04:48FromDiscord<Zachary Carter> sent a code paste, see https://play.nim-lang.org/#ix=2UpG
22:10:35FromDiscord<ElegantBeef> Yea this seems sensible, if the goal is supporting all the backends where one can
22:11:14*blackpawn quit (Remote host closed the connection)
22:12:45*blackpawn joined #nim
22:13:26FromDiscord<dom96> `when defined(js): import jshttpclient else: import httpclient`
22:14:05FromDiscord<dom96> I don't think it should be in the stdlib yet
22:34:26FromDiscord<Yardanico> i wonder if it's somehow possible to get the instantiationInfo of where a converter was placed by the compiler?
22:34:40FromDiscord<Yardanico> so e.g. I can add a hint/warning which will point to the line where the converter was used
22:36:12FromDiscord<Yardanico> ` jq(".blob-code-inner").each do (idx: int, elem: Element):` oh boy
22:42:08*PMunch joined #nim
22:44:41*Vladar quit (Quit: Leaving)
22:50:46*oz quit (Ping timeout: 245 seconds)
22:58:45*xet7 joined #nim
23:16:05*oz joined #nim
23:25:39*oz quit (Ping timeout: 246 seconds)