<< 12-07-2021 >>

00:04:28FromDiscord<ElegantBeef> @Bung i know exactly what i need to do just need to implement it
00:05:07FromDiscord<ElegantBeef> A few thugs attacked my dogs, so i have to go break their house apart and kill their children which delayed me
00:05:25FromDiscord<ElegantBeef> talking about killing wasps
00:08:17FromDiscord<geekrelief> What's a reliable to convert a table's keys to a seq? I tried `toSeq(t.keys)` and that worked fine till I imported `dik` now I'm getting an error because `proc keys(self: Dictionary): Array` is defined and nim is complaining about a type mismatch.
00:08:23FromDiscord<ElegantBeef> cynahc you may want to use `GC_Ref` and `GC_Unref` for that
00:09:17FromDiscord<cynahc> @ElegantBeef\: Thanks! I'll look into it.
00:09:40FromDiscord<ElegantBeef> Well the `toSeq` method is right you probably want to do `toSeq(table.keys(t))` to get around that
00:09:52FromDiscord<ElegantBeef> You could also use `sugar.collect`
00:11:08FromDiscord<geekrelief> hmm `toSeq(table.keys(t))` didn't work
00:11:30FromDiscord<geekrelief> I'll try `sugar.collect`
00:11:43FromDiscord<geekrelief> thx
00:13:31FromDiscord<geekrelief> cool collect worked @ElegantBeef thanks!
00:46:02*mjsir911 quit (Quit: Goodbye, World!)
00:46:17*mjsir911 joined #nim
02:02:23FromDiscord<cynahc> Hmm still no luck with GC\_ref or reset. Here's the full code if anyone wants to take a crack at fixing the leak\: https://gist.github.com/chancyk/d5d7f36ab3f1386362d15430347a2de2#file-sdl_leak-nim-L59
02:03:21FromDiscord<cynahc> A pointer to a seq is being stored under a C pointer of SDL2, and it seems to never get properly cleaned up despite my various attempts at properly using dealloc, reset, GC\_ref, destroy (from SDL), etc.
02:10:57FromDiscord<ElegantBeef> Wait why would you have to dealloc that ptr
02:20:03FromDiscord<cynahc> The seq that's stored in `image.data` is coming from Pixie, so it's being attached to the Surface for SDL2, but it seems like it's never being freed and results in a pretty large memory leak.
02:22:47FromDiscord<cynahc> It's kind of bizarre because it's based on an example from Pixie that has a leak because it's lacking a destroy, but once you add it's fine.↵https://github.com/treeform/pixie/blob/master/examples/realtime_sdl.nim
02:23:20FromDiscord<cynahc> However, in my slightly different version it doesn't seem to clean up properly. 🤔
02:29:15*arkurious quit (Quit: Leaving)
02:59:55*rockcavera joined #nim
03:03:23FromDiscord<Quibono> What would be the best way to instrument Nim to measure how long a program loop takes?
03:04:11FromDiscord<cynahc> @Quibono\: You can use the times module\: https://nim-lang.org/docs/times.html
03:04:20FromDiscord<ElegantBeef> monotimes is better for percise timing
03:04:43FromDiscord<Quibono> Monotimes are in ns?
03:05:18FromDiscord<ElegantBeef> > The MonoTime type stores the timestamp in nanosecond resolution, but note that the actual supported time resolution differs for different systems.
03:06:39FromDiscord<treeform> In reply to @cynahc "It's kind of bizarre": Sorry I don't use SDL, I wanted and example for people here because many seem to use it. I made a mistake I'll fix it when I get back. You might not need to create a texture every time, but just copy it. I don't know SDL that well...
03:07:03FromDiscord<ElegantBeef> The best way to use `monotimes` is to import `times` with it and use it's stringification for durations
03:08:37FromDiscord<ElegantBeef> https://play.nim-lang.org/#ix=3sIS to see monotimes in action 😄
03:09:03FromDiscord<cynahc> @treeform\: I'm not sure it's related to the lack of a destroy. I'm just learning SDL also, but some kind of interplay between the Nim GC and SDL is behaving strangely. To my anyway. 😅
03:09:23FromDiscord<Quibono> In reply to @ElegantBeef "https://play.nim-lang.org/#ix=3sIS to see monotimes": Ooh that's nice.
03:09:48FromDiscord<ElegantBeef> You can also of course turn that into a template and then time whatever you want inside a block
04:06:02*supakeen quit (Quit: WeeChat 3.2)
04:06:39*supakeen joined #nim
04:09:07FromDiscord<Jasmine and Don't Forget!~> Hi everyone! What's up?
04:57:24FromDiscord<whyy cant i install choosenim> In reply to @Quibono "Lol so Choosenim doesn't": doesnt support arm anyways
05:06:13*mikko quit (*.net *.split)
05:06:13*Ekho quit (*.net *.split)
05:06:13*systemdsucks quit (*.net *.split)
05:06:13*Onionhammer quit (*.net *.split)
05:06:29*Onionhammer joined #nim
05:06:32*systemds1cks joined #nim
05:06:35*mikko joined #nim
05:11:26*crem quit (*.net *.split)
05:11:26*oprypin quit (*.net *.split)
05:11:27*lain quit (*.net *.split)
05:11:38*oprypin joined #nim
05:11:43*crem joined #nim
05:12:27*lain joined #nim
05:14:58*DrWhax quit (*.net *.split)
05:14:58*euantorano quit (*.net *.split)
05:14:58*robertmeta quit (*.net *.split)
05:15:09*DrWhax joined #nim
05:15:51*euantorano joined #nim
05:16:02*robertmeta joined #nim
05:16:04*robertmeta quit (Changing host)
05:16:04*robertmeta joined #nim
05:16:07*Ekho joined #nim
06:01:16*rockcavera quit (Remote host closed the connection)
06:08:26*Vladar joined #nim
06:23:34fn<ForumUpdaterBot99> New thread by Halloleo: How can I tell Nim that a JsObject has some certain attributes?, see https://forum.nim-lang.org/t/8222
06:25:36fn<ForumUpdaterBot99> New Nimble package! macroplus - a collection of useful macro functionalities, see https://github.com/hamidb80/macroplus
06:25:37fn<R2D299> itHub: 7"<No Description>"
06:26:20FromDiscord<sealmove> Is there a web dev tutorial or something that doesn't treat readers/watchers as complete beginners in programming?
06:27:10FromDiscord<Rika> Web dev starting from where?
06:27:17FromDiscord<Rika> Like rather what are you making
06:27:24FromDiscord<Rika> The server itself or just a website?
06:27:58FromDiscord<Rika> If it’s just a website I feel like the docs for whatever web server should suffice?
06:29:00FromDiscord<sealmove> Ideally I want to build a full stack pet project (as small as possible) to get the big picture.
06:29:39FromDiscord<Rika> Let me try searching as well
06:31:01FromDiscord<Rika> I’m still kinda unsure what you want, do you already have the documents to serve to the user, are you making a single page site (using something like karax)
06:31:39FromDiscord<Rika> Most tutorials for full stack are specific to a certain stack
06:31:46FromDiscord<Rika> Stuff like LAMP MEAN etc
06:31:50*PMunch joined #nim
06:32:07FromDiscord<sealmove> I am fine with picking one stack, just to get my feet wet
06:34:04FromDiscord<Rika> Perhaps https://thinkster.io/tutorials/fullstack ? You will need to adapt it to Nim if you plan on using Nim libraries
06:34:17FromDiscord<Rika> And likely there are components that do not exist yet on Nim
06:34:27FromDiscord<Rika> So you might need to create some stuff from scratch
06:38:21PMunchLAMP can quite easily switch out the P(HP) for Nim
06:38:28PMunchI've done it on my server :)
06:38:54FromDiscord<enthus1ast> with reverse proxy? or with (fast) cgi?
06:39:01FromDiscord<enthus1ast> wsgi
06:39:08PMunchReverse proxy via Apache
06:39:55FromDiscord<Rika> Most people opt for nginx nowadays though heh
06:40:48PMunchYeah I know, but I was already running Apache
06:42:29FromDiscord<sealmove> would be cool to use Nim but I need "marketable" skills :< my github account only has Nim xD
06:43:27FromDiscord<Bung> you can change gitattribute tell github show as python
06:43:44FromDiscord<sealmove> cool idea :>
06:45:00FromDiscord<Bung> think you only need read some framework document and its source code.
06:45:12FromDiscord<enthus1ast> my one stop shop for professional websites\: php bolt cms; for web application\: python flask or nim; but in my opinion it does not really matter, master css, a web framework like bootstrap is more important for a website
06:49:19*max22- joined #nim
06:51:38fn<ForumUpdaterBot99> New Nimble package! isocodes - ISO codes for Nim that allows to embed its data within the executable (or load it automatically at runtime)., see https://github.com/kraptor/isocodes
06:51:39fn<R2D299> itHub: 7"ISO codes for Nim that allows to embed the data within the executable (or load it automatically at runtime)."
06:55:48FromDiscord<planetis> How about https://m.youtube.com/watch?v=KH_-vhsfxjg&list=PLlRFEj9H3Oj5e-EH0t3kXrcdygrL9-u-Z&index=1↵(@sealmove)
06:55:51fn<R2D299> outube: 7"Why Teach Django?"
06:56:27FromDiscord<sealmove> In reply to @planetis "How about https://m.youtube.com/watch?v=KH_-vhsfxjg": looks good
06:56:29fn<R2D299> outube: 7"Why Teach Django?"
07:01:10FromDiscord<planetis> The d is silent
07:12:38PMunch@enthus1ast, hadn't heard of FastCGI before. Interesting concept
07:14:51*max22- quit (Ping timeout: 276 seconds)
07:31:42*beshr quit (Remote host closed the connection)
07:32:59*max22- joined #nim
07:35:06FromDiscord<Bung> https://github.com/mrhdias/fastkiss there one in nim
07:35:08fn<R2D299> itHub: 7"FastKISS - Nim's FastCGI Flexible Web Framework"
07:48:30FromDiscord<Rika> Oh wow nice I’ll use this
07:48:56FromDiscord<enthus1ast> Not sure if fastcgi actually gives a win. Also unsure if websocket works with fastcgi
07:50:02FromDiscord<enthus1ast> And with nginx you also must start your application by yourself (afaik)
07:51:29FromDiscord<Rika> It works for me because I need to use http 2
08:01:34FromDiscord<Bung> you use http2 ? does the backend program handle the stream like http1?
08:35:55fn<ForumUpdaterBot99> New thread by Elcritch: Arena memory support?, see https://forum.nim-lang.org/t/8225
08:42:11*neceve joined #nim
09:28:23*max22- quit (Remote host closed the connection)
09:29:12*max22- joined #nim
09:53:02*Vladar quit (Quit: Leaving)
10:28:43FromDiscord<dom96> fastcgi is pointless
10:28:57FromDiscord<dom96> just another protocol when http can be used instead
10:29:32PMunchI mean it might be nice if you have a language without a HTTP library
10:29:44FromDiscord<dom96> just implement http then lol
10:30:06PMunchAs I understand it FastCGI is easier to implement
10:30:48PMunchAnd if you need to run your HTTP server behind a reverse proxy anyways it's starting to look quite similar architecturally
10:32:58FromDiscord<dom96> I really doubt FastCGI is easier to implement
10:33:23FromDiscord<dom96> You still need to implement all the HTTP concepts for your framework anyway
10:34:59FromDiscord<haxscramper> sent a code paste, see https://paste.rs/gVs
10:35:40FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3sJU
10:35:48FromDiscord<dom96> (there is also simple CGI btw which implies fast cgi isn't simple at all :))
10:36:02FromDiscord<haxscramper> Also `proc toFlatty(str: var string, cstr: cstring) = toFlatty(str, $cstr)` as default implementation for cstring.
10:36:14FromDiscord<haxscramper> I can make a PR that adds this to flatty if you are ok with the idea
10:36:38FromDiscord<haxscramper> and `fromFlatty` implementation as well
10:37:15FromDiscord<haxscramper> btw, I've decided to use flatty/supersnappy for haxdoc database serialization after your post https://forum.nim-lang.org/t/8214
10:37:39FromDiscord<haxscramper> so far works great, though (as usual with any serialization) it is having troubles with `.requiresinit.`
10:39:05FromDiscord<Rika> In reply to @dom96 "just implement http then": Have you implemented http2 yet then?
10:39:32FromDiscord<dom96> no, because I don't need it
10:39:50FromDiscord<dom96> nginx/cloudflare can do http2 for me
10:43:25FromDiscord<Rika> In reply to @dom96 "nginx/cloudflare can do http2": Hm? nginx can do 1.1->2?
10:44:10FromDiscord<dom96> I think so, cloudflare can so I don't see why nginx can't
11:12:01*iortega joined #nim
11:19:56FromDiscord<Aiz> sent a code paste, see https://play.nim-lang.org/#ix=3sK7
11:20:21FromDiscord<Aiz> (edit) "https://paste.rs/AnG" => "https://play.nim-lang.org/#ix=3sK8"
11:20:21FromDiscord<Aiz> (edit) "https://play.nim-lang.org/#ix=3sK8" => "https://play.nim-lang.org/#ix=3sK9"
11:21:12FromDiscord<Rika> you want `ptr AtlasPage` i assume?
11:22:01FromDiscord<Aiz> sent a code paste, see https://play.nim-lang.org/#ix=3sKb
11:22:33FromDiscord<Rika> i assume the issue is in the C side? likely because cstring -> char and not const char
11:24:04FromDiscord<haxscramper> @Aiz\: you can use combination of `.codegendecl: "...".`, `.emit` and `.exportc`
11:24:16FromDiscord<Aiz> sent a code paste, see https://play.nim-lang.org/#ix=3sKd
11:24:27FromDiscord<haxscramper> `.constructor.` to avoid implicit `return` initalization
11:25:41FromDiscord<haxscramper> `.codegendecl.` would allow you to manually overide argument list with required types
11:25:55FromDiscord<haxscramper> so you could do `const char` explicitly
11:26:34FromDiscord<Aiz> let me try
11:41:54FromDiscord<Aiz> it compiled successfully
11:42:25FromDiscord<whyy cant i install choosenim> :nimble3:
12:03:22*jfinkhaeuser quit (Ping timeout: 240 seconds)
12:03:36*jfinkhaeuser joined #nim
12:06:01*supakeen quit (Quit: WeeChat 3.2)
12:06:35*supakeen joined #nim
12:07:00*Vladar joined #nim
12:19:17FromDiscord<System64 ~ Flandre Scarlet> Do you know how can I fix theses errors please? https://media.discordapp.net/attachments/371759389889003532/864118718749474856/unknown.png
12:21:13FromDiscord<Rika> `var time = (↵sample_nr[].float / 96000.float)`
12:21:16FromDiscord<Rika> (edit) "(↵sample_nr[].float" => "(sample_nr[].float"
12:22:10FromDiscord<System64 ~ Flandre Scarlet> ah thanks and for the buf?
12:22:40FromDiscord<Rika> dont use a pointer
12:22:45FromDiscord<Rika> nim pointers are not c pointers
12:22:55PMunchUncheckedArray is probably what you want
12:22:58FromDiscord<Rika> well more accurately nim `[]` is not c `[]`
12:23:22PMunchptr UncheckedArray[cshort]
12:23:47FromDiscord<System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=3sKt
12:30:06*max22- quit (Ping timeout: 276 seconds)
12:37:01FromDiscord<arnetheduck> thoughts on projects that want to support both chronos and asyncdispatch? https://github.com/status-im/nim-chronos/issues/207 - using `async_backend` is nice because it opens the door for other backends as well, in the future, but happy to hear opinions
12:43:29FromDiscord<Aiz> sent a code paste, see https://play.nim-lang.org/#ix=3sKy
12:43:50FromDiscord<dom96> In reply to @arnetheduck "thoughts on projects that": sounds good to me
12:44:40FromDiscord<Aiz> (edit) "https://play.nim-lang.org/#ix=3sKy" => "https://play.nim-lang.org/#ix=3sKz"
12:57:02*TakinOver quit (Ping timeout: 268 seconds)
12:58:57arkanoidwhere I can read state-of-the-art nim code that covers idioms, patterns, defensive programming and nim program architecture?
13:03:13fn<ForumUpdaterBot99> New thread by Rb3: A regex-based linter for Nim in vscode, see https://forum.nim-lang.org/t/8226
13:03:46*TakinOver joined #nim
13:07:34*arkurious joined #nim
13:10:06*rockcavera joined #nim
13:10:06*rockcavera quit (Changing host)
13:10:06*rockcavera joined #nim
13:12:09arkanoidwell, I bet there's none
13:12:26arkanoidnew question: what about tainted strings? what's the point?
13:13:10arkanoidby default tainted strings is off and string == TaintedString, but what's the adventage in turining it on?
13:13:36arkanoidmanual says "If the taint mode is turned on (via the --taintMode:on command line option) it is a distinct string type which helps to detect input validation errors"
13:17:09FromDiscord<arnetheduck> arkanoid, we use nim for a few larger projects and have written some notes down in https://status-im.github.io/nim-style-guide/
13:17:37arkanoidthanks arnetheduck
13:19:50FromDiscord<whyy cant i install choosenim> the nlvm dev
13:19:59FromDiscord<whyy cant i install choosenim> i was like 🤔
13:22:34FromDiscord<Rika> arkanoid arq recently considered removing taint (i believe it already is in devel?)
13:22:40FromDiscord<Rika> but he thinks its not helpful
13:23:02FromDiscord<Rika> so basically its a feature that hasnt been removed yet
13:25:59arkanoidRika: I also don't see the purpose of it, but surely I'm now super sayan 3 like araq is on these topics
13:26:25FromDiscord<Rika> i do not watch dragon ball so i do not understand the reference
13:26:49FromDiscord<Rika> i do not see the use for taint as well so i do not pay notice to it
13:37:03FromDiscord<Aiz> sent a code paste, see https://play.nim-lang.org/#ix=3sKT
13:38:58FromDiscord<Aiz> (edit) "https://play.nim-lang.org/#ix=3sKT" => "https://play.nim-lang.org/#ix=3sKU"
13:46:24FromDiscord<@bracketmaster-5a708063d73408ce4> @kaushalmodi\_gitlab - had you considered hooking up verilator and nim?
13:54:25PMunchCan anyone tell me what the actual type mismatch here is? http://ix.io/3sKX/
13:55:19fn<ForumUpdaterBot99> New thread by FabienPRI: Zip error code, see https://forum.nim-lang.org/t/8227
13:55:34FromDiscord<Rika> pmunch do the two procs match incl. pragmas?
13:56:07FromDiscord<dom96> In reply to @Rika "arkanoid ar*q recently considered": he's on Discord now, you don't need to censor his name anymore
13:56:19FromDiscord<Rika> okay
13:56:25FromDiscord<Rika> nice to know lmao
14:02:39PMunchHmm, they should
14:02:48*PMunch quit (Quit: Leaving)
14:19:46*max22- joined #nim
14:27:28FromDiscord<konsumlamm> In reply to @arkanoid "new question: what about": tainted strings have been deprecated, the point was to force input validation, but that didn't really work out
14:28:21FromDiscord<Rika> I believe it’s because nothing really prevented people from just converting from one to the other
14:32:02FromDiscord<konsumlamm> https://github.com/nim-lang/RFCs/issues/24
14:38:32FromDiscord<Bung> how to prevent compiler ouput `template/generic instantiation` message ?
14:41:36nixfreak_nim[m]Probably a dumb question , related to type , but why do you have to use the actual type name even when you assign a new variable ?
14:41:37FromDiscord<kaushalmodi> In reply to @@bracketmaster-5a708063d73408ce4 "@kaushalmodi\_gitlab - had you": I happened to notice this message, but it didn't ping me as I am on Discord.↵↵No, I haven't used Verilator yet.
14:42:13nixfreak_nim[m]like type User name: string , var user = User
14:42:37nixfreak_nim[m]is it because there is not inheritance ?
14:42:43FromDiscord<Rika> Initialisation
14:42:49nixfreak_nim[m] * is it because there is no inheritance ?
14:43:03FromDiscord<Rika> No, inheritance has nothing to do with that
14:43:21nixfreak_nim[m]oh ok , I didn't know just curious
14:43:47nixfreak_nim[m]so your initializing the type
14:44:14FromDiscord<Rika> The variable
14:46:02FromDiscord<Bung> nim is static type language
14:46:46nixfreak_nim[m]sorry I meant that thanks
14:50:36*xet7 quit (Remote host closed the connection)
15:01:46*pro joined #nim
15:02:35*xet7 joined #nim
15:19:19FromDiscord<dimspith> sent a code paste, see https://play.nim-lang.org/#ix=3sLL
15:32:56FromDiscord<hugogranstrom> First one is more readable and easier to reason about so I'd go with it no matter what (unless `i` is some huge stack-allocated type or crazy stuff like that)↵(@dimspith)
15:33:51FromDiscord<pointystick> You've used 'i' for both variables. If that's intention, I'd suggest trying to avoid changing loop variables as it could get very confusing
15:34:24FromDiscord<pointystick> sent a code paste, see https://paste.rs/e75
15:34:43FromDiscord<pointystick> (edit) "https://play.nim-lang.org/#ix=3sLS" => "https://paste.rs/5TL"
15:35:51FromDiscord<pointystick> Damn, discord mangled that. 😦 There's meant to be an underscore there: https://play.nim-lang.org/#ix=3sLT
15:38:16FromDiscord<dimspith> In reply to @pointystick "You've used 'i' for": oh whoops, i didn't notice. this was just an example though so that wasn't my intention
15:39:35FromDiscord<dimspith> In reply to @hugogranstrom "First one is more": Oh ok thanks a lot!
15:43:28fn<ForumUpdaterBot99> New post on r/nim by Ver0ty: What can I use Nim for?, see https://reddit.com/r/nim/comments/oitvuh/what_can_i_use_nim_for/
15:43:58*pro quit (Ping timeout: 272 seconds)
15:59:51*stkrdknmibalz quit (Quit: WeeChat 3.0.1)
16:18:06*stkrdknmibalz joined #nim
16:25:28*max22- quit (Remote host closed the connection)
16:25:46*max22- joined #nim
16:30:23FromDiscord<dimspith> On another note, is there an equivalent to python's `os.sysconf()` in nim?
16:31:10FromDiscord<aleclarson> sent a code paste, see https://play.nim-lang.org/#ix=3sM8
16:32:19FromDiscord<aleclarson> is there some kind of "opaque type" in nim?
16:33:54FromDiscord<theangryepicbanana> In reply to @aleclarson "is there some kind": `distinct`?
16:34:21FromDiscord<dimspith> yeah distinct is the way i think. https://nim-lang.org/docs/manual.html#types-distinct-type
16:34:46FromDiscord<aleclarson> sweet thx ^^
16:51:48FromDiscord<System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=3sMc
17:13:50fn<ForumUpdaterBot99> New thread by Protium: Newbie: Mock object for assert when field not exported, see https://forum.nim-lang.org/t/8228
17:14:02FromDiscord<aleclarson> is `not nil` reversible?
17:15:04FromDiscord<aleclarson> oh i suppose i can wrap a `not nil` type with a `ref` to make it nilable again
17:27:29FromDiscord<dom96> that sounds like a bad idea
17:28:06FromDiscord<Rika> sounds like a double indirection
17:28:08arkanoidfor an x86_64 pure nim application, is there any difference in using C or C++ backend? C is now default one so I'm sticking with it and it's working, but I'm quite curious about this topic. I though that C++ could bring more advanced features for the compiler
17:29:39FromDiscord<Rika> the C backend is more heavily tested
17:29:55FromDiscord<Rika> afaik the two backends share a lot with each other but not everything
17:30:41arkanoidI'd guess that exceptions are thing where C++ shines
17:31:26FromDiscord<Rika> which goto exceptions beat anyway from what ive heard
17:32:43arkanoidand what about effect tracking?
17:32:58arkanoid(I'm just guessing here)
17:35:16FromDiscord<aleclarson> In reply to @dom96 "that sounds like a": why?
17:35:42FromDiscord<Rika> nim already has effect tracking built in
17:35:55FromDiscord<Rika> i dont understand what you mean about "effect tracking"
17:36:09FromDiscord<dom96> In reply to @aleclarson "why?": because you're working around a limitation in the type system by creating yet another reference
17:36:44FromDiscord<aleclarson> yeah it's not ideal, i'd prefer to negate the `not nil` part with `or nil` or something
17:37:20FromDiscord<dom96> is the `not nil` type one you've defined?
17:38:08FromDiscord<dom96> sent a code paste, see https://play.nim-lang.org/#ix=3sMv
17:39:10FromDiscord<aleclarson> no it's not \:)
17:39:25FromDiscord<Rika> why do you want it to be nilable?
17:40:50arkanoidRika, I though effect tracking was a runtime feature too, not just compile time (you can print effects at point in code)
17:41:33FromDiscord<Rika> what does that have in relation to the C vs C++ backend? i fail to see
17:41:37FromDiscord<konsumlamm> In reply to @aleclarson "is `not nil` reversible?": the point of `not nil` is that it can't be `nil`, it would be dumb if it was "reversible"
17:42:32FromDiscord<konsumlamm> this sounds more like you want an `Option` tbh, see the `std/options` module
17:43:43FromDiscord<Rika> do ref objects not nil work with Option? i thought Option relied on refs being nilabel
17:43:44FromDiscord<Rika> (edit) "nilabel" => "nilable"
17:44:28FromDiscord<konsumlamm> umm, no
17:44:46FromDiscord<konsumlamm> oh wait, hmm
17:44:53FromDiscord<Rika> xd
17:44:56FromDiscord<konsumlamm> ye, the optimization might break that
17:45:09arkanoidI though it was leveraging on backend feature to achive effect tracking. If not, nevermind (I was just wild guessing)
17:45:12FromDiscord<konsumlamm> which is another reason why it's a dumb idea, but muh breaking change
17:46:21FromDiscord<Rika> arkanoid the nim compiler only uses backend features when theyre available; nim does not restrict features to certain backends if it can help it
17:46:44FromDiscord<aleclarson> In reply to @konsumlamm "the point of `not": the library i'm using is abusing `not nil` imo. `not nil` shouldn't be used in a `type` declaration. save it for parameter types
17:47:05FromDiscord<Rika> i think there are valid reasons to use not nil in a type
17:47:07FromDiscord<konsumlamm> imo every `ref` type should be `not nil` tbh
17:47:16FromDiscord<aleclarson> who are they to say what my object types must contain?
17:47:16FromDiscord<konsumlamm> so i wouldn't say there's such a thing as abusing it
17:47:19FromDiscord<Rika> almost the same opinion as kon here
17:47:32FromDiscord<Rika> theyre not your types, theyre theirs
17:48:06FromDiscord<aleclarson> sent a code paste, see https://play.nim-lang.org/#ix=3sMA
17:48:14FromDiscord<aleclarson> they shouldn't have influence over whether `MyType.foo` is nil or not
17:48:22FromDiscord<Rika> why
17:48:32FromDiscord<aleclarson> it doesn't matter to them in my case
17:48:40FromDiscord<Rika> it does
17:48:48arkanoidRika, sure but considering the fact that nim strikes for the performance and not for the "moltitude of backends", it was easier to assume that if a backend feature could be leveraged for better performance, just go for it
17:48:54FromDiscord<aleclarson> i ensure `MyType.foo` is not nil when i pass it into the library procs
17:49:00FromDiscord<Rika> if you use their library and pass that nil'ed not nil type to a proc?
17:49:04FromDiscord<dom96> I think you do want just an Option.
17:49:05FromDiscord<Rika> you ensure it
17:49:08FromDiscord<Rika> but not everyone will
17:49:14FromDiscord<Rika> if given the opportunity
17:49:31FromDiscord<aleclarson> they can protect against that by using `not nil` in the proc type signature
17:50:02FromDiscord<Rika> arkanoid yeah thats what i mean, when the feature is there in the backend (and is the same in behavior) nim would use it i believe
17:51:03FromDiscord<Rika> In reply to @aleclarson "they can protect against": okay ill think about this
17:51:37FromDiscord<Rika> then what's the point of having a nil value then?
17:51:48FromDiscord<aleclarson> optional property
17:51:53FromDiscord<Rika> THEN USE OPTION
17:51:59FromDiscord<aleclarson> that works with `ref` types?
17:52:02FromDiscord<Rika> YES
17:52:07FromDiscord<Rika> well
17:52:10FromDiscord<Rika> actually
17:52:14FromDiscord<Rika> it works with ref types
17:52:19FromDiscord<aleclarson> lol
17:52:24FromDiscord<Rika> In reply to @konsumlamm "ye, the optimization might": but as mentioned here
17:52:38FromDiscord<Rika> ive never checked if the way it's implemented works with ref not nil
17:53:17FromDiscord<konsumlamm> depends on wether or not the `ref` wildcard type includes `not nil` types
17:55:07FromDiscord<Rika> it works it seems
17:55:13FromDiscord<Rika> i just tested it
17:55:16FromDiscord<Rika> seems to work
17:55:18FromDiscord<aleclarson> is there a way to get my `object` type to call `new` for `ref` properties automatically?
17:55:45FromDiscord<Rika> no
17:55:50FromDiscord<Rika> (i wish)
17:55:54FromDiscord<Rika> (edit) "wish)" => "wish it was yes)"
17:56:05FromDiscord<Rika> but not now no
17:57:00*vicfred joined #nim
17:57:13FromDiscord<haxscramper> Maybe they decided to save up time and not insert `assert not isNil()` checks everywher
17:57:31FromDiscord<konsumlamm> ye, the reason it works is actually that `not nil` is broken
17:57:36FromDiscord<haxscramper> Also if argument is guaranteed to be not nil procedure returning things can also always return not nil instead of failing
17:57:44FromDiscord<konsumlamm> because `not nil` types are in fact considered to be `ref`
17:57:55FromDiscord<haxscramper> so `nil` values happen to propagate all over the place or raise things
17:57:57FromDiscord<Rika> In reply to @konsumlamm "ye, the reason it": it's broken??? huhhhhhhhh https://media.discordapp.net/attachments/371759389889003532/864203941990629387/unknown.png
17:58:00FromDiscord<konsumlamm> so what's happening under the hood is that we have a `not nil` type that is `nil`
17:58:23arkanoidwhat's more idiomatic: "proc initMyFoo(...): MyFoo" or "proc init(T: type MyFoo, ...): T"
17:58:30FromDiscord<konsumlamm> In reply to @Rika "it's broken??? huhhhhhhhh": last i checked it didn't complain about uninitialized variables
17:58:32FromDiscord<Rika> i guess i did call "new test"
17:58:42FromDiscord<Rika> lets see with an uninit var
17:58:56*mahlon quit (Ping timeout: 265 seconds)
17:59:06FromDiscord<Rika> huh
17:59:10FromDiscord<Rika> its just an assertion lmao
17:59:16FromDiscord<Rika> ah wait no
17:59:20FromDiscord<Rika> yeah it seems broken lmao
18:00:15FromDiscord<haxscramper> Most commonly used one is `initT`↵(<@709044657232936960_arkanoid=5b=49=52=43=5d>)
18:00:43FromDiscord<Rika> but there are a few people using init(T) nowadays i think
18:00:50FromDiscord<Rika> (i'm about to move to such)
18:00:51FromDiscord<aleclarson> is `Option` cheaper than a `ref`?
18:00:54FromDiscord<konsumlamm> sent a code paste, see https://play.nim-lang.org/#ix=3sMF
18:00:56FromDiscord<Rika> yes
18:01:08FromDiscord<konsumlamm> it doesn't allocate anything
18:01:31FromDiscord<konsumlamm> it's just an extra `bool` flag in the normal case
18:01:39FromDiscord<aleclarson> why are `Option` properties required to be initialized? i'd expect it to default to `none`
18:01:45FromDiscord<konsumlamm> and if you have some pointer type, it's the exact same layout
18:01:56FromDiscord<haxscramper> Yes, it works better with generics↵(@Rika)
18:01:58FromDiscord<konsumlamm> In reply to @aleclarson "why are `Option` properties": wdym?
18:02:05FromDiscord<haxscramper> Poor man's default initalization support
18:02:13FromDiscord<haxscramper> And we also have `default(T)` and `new(T)`
18:02:26FromDiscord<Rika> overridable inserted default calls when
18:02:28FromDiscord<haxscramper> very consitent
18:03:05FromDiscord<haxscramper> 1.5 RFCs about that
18:03:16FromDiscord<konsumlamm> honestly i feel like most uses of `typedesc` are workarounds for Nim's bad type inference
18:03:35FromDiscord<Rika> it pretty much is
18:03:57FromDiscord<Rika> im pretty sure return type inference would solve a lot (but it prolly adds a fucktonne of complexity so...)
18:04:03FromDiscord<haxscramper> I don't think so, or at least I wound't qualify it as 'bad type inference'
18:04:06FromDiscord<aleclarson> In reply to @konsumlamm "wdym?": https://play.nim-lang.org/#ix=3sMH
18:04:21FromDiscord<aleclarson> `Option` with `not nil` type needs to be initialized
18:04:42FromDiscord<aleclarson> which makes `Option` useless in my case, it seems
18:04:44FromDiscord<haxscramper> Though local HM inference would simply some use cases
18:04:47FromDiscord<haxscramper> Just not that global trash
18:04:53FromDiscord<aleclarson> (edit) "seems" => "seems?"
18:05:18FromDiscord<konsumlamm> In reply to @aleclarson "https://play.nim-lang.org/#ix=3sMH": calling a constructor without initializing all fields isn't a thing, is it?
18:05:34FromDiscord<konsumlamm> anyway, what's the problem with setting it to `none()`?
18:05:44FromDiscord<Rika> In reply to @haxscramper "Just not that global": sorry, idk the diff, what is the diff?
18:06:05FromDiscord<Rika> In reply to @konsumlamm "calling a constructor without": but shouldnt it already default to none?
18:06:30FromDiscord<konsumlamm> idk if that's how constructors are supposed to work
18:06:37FromDiscord<konsumlamm> i always initialize everything anyway
18:09:25*xet7 quit (Remote host closed the connection)
18:34:45*max22- quit (Ping timeout: 276 seconds)
18:52:49*lain quit (Quit: kthxbai)
18:53:30*lain joined #nim
19:01:03*xet7 joined #nim
19:06:31*supakeen quit (Remote host closed the connection)
19:06:55*supakeen joined #nim
19:09:09FromDiscord<System64 ~ Flandre Scarlet> is c2nim a good method for interop?
19:10:09*max22- joined #nim
19:10:33FromDiscord<haxscramper> it is a reasonably good start
19:12:09FromDiscord<System64 ~ Flandre Scarlet> interesting↵'cause I try to inspect where does the crash come from, I'm wondering if there isn't an interop problem
19:13:02FromDiscord<System64 ~ Flandre Scarlet> I did the same program in C, no crash
19:15:25FromDiscord<konsumlamm> maybe your C program silently has UB?
19:15:40FromDiscord<System64 ~ Flandre Scarlet> what does it mean UB?
19:16:12FromDiscord<konsumlamm> undefined behaviour
19:16:55FromDiscord<System64 ~ Flandre Scarlet> and what does it do?
19:19:50FromDiscord<konsumlamm> being undefined
19:20:17FromDiscord<haxscramper> welcome to C
19:20:28FromDiscord<konsumlamm> for example dereferencing an invalid pointer is UB
19:20:47FromDiscord<konsumlamm> and the fun thing about UB is, the program can technically do anything
19:20:58FromDiscord<System64 ~ Flandre Scarlet> OOOOF
19:21:13FromDiscord<System64 ~ Flandre Scarlet> so that means I potentially created a malware??
19:21:52FromDiscord<konsumlamm> very unlikely
19:22:18FromDiscord<System64 ~ Flandre Scarlet> yeah I overexagerated a bit↵But my program can corrupt a file for exemple?
19:22:27FromDiscord<System64 ~ Flandre Scarlet> or crashing another process?
19:22:43FromDiscord<konsumlamm> if it has UB, in theory, yes, but in practice it probably won't
19:22:59FromDiscord<System64 ~ Flandre Scarlet> if the OS is secure I think it wont
19:23:37FromDiscord<System64 ~ Flandre Scarlet> but Nim stops the program instead of letting UBs?
19:29:12FromDiscord<System64 ~ Flandre Scarlet> and that's why it doesn't crash when I'm in Danger mode?
19:37:01FromDiscord<konsumlamm> your Nim program crashes in debug mode but not in danger mode?
19:37:17FromDiscord<System64 ~ Flandre Scarlet> exactly
19:38:58FromDiscord<konsumlamm> then the danger version probably has UB
19:40:25FromDiscord<System64 ~ Flandre Scarlet> aaaalright!↵But I dunno if the UB comes from SDL2 or Tilengine
19:41:49FromDiscord<System64 ~ Flandre Scarlet> And I put some try except at suspicious places https://media.discordapp.net/attachments/371759389889003532/864230086932824086/message.nim
19:42:57FromDiscord<System64 ~ Flandre Scarlet> even with that it crashes without stacktrace
19:45:06FromDiscord<haxscramper> Run in debugger
19:45:58FromDiscord<System64 ~ Flandre Scarlet> how can I do that? I think it's debug by default
19:46:26FromDiscord<haxscramper> It is build in debug mode, not the same is running in debugger
19:46:52FromDiscord<haxscramper> On Linux you could do `gdb <options> ./program`
19:47:23FromDiscord<haxscramper> I usually do `gdb -batch -ex "run" -ex "bt" ./program`
19:47:27FromDiscord<System64 ~ Flandre Scarlet> I'm on Windows
19:47:31FromDiscord<haxscramper> well,
19:48:30FromDiscord<haxscramper> Maybe vscode can run nim with debugger
19:50:16FromDiscord<System64 ~ Flandre Scarlet> how can I do that?
19:51:36FromDiscord<jfmonty2> quick q: Is there a way to declare that a proc parameter should get the default value for its type if not explicitly specified?↵Like say I have `proc doSomething(a: array[5, int] = [0, 0, 0, 0, 0]) =`, is there a way to avoid writing out the whole array?
19:52:29FromDiscord<haxscramper> `default(<your type>)`
19:52:38FromDiscord<jfmonty2> ah perfect, thanks
19:52:58FromDiscord<haxscramper> We need to add counter for 'how to default init' things
19:53:14FromDiscord<haxscramper> Questions
19:53:21FromDiscord<System64 ~ Flandre Scarlet> ah I have gdb on Windows
19:54:16FromDiscord<System64 ~ Flandre Scarlet> https://media.discordapp.net/attachments/371759389889003532/864233214658740234/unknown.png
19:59:25*vicfred quit (Quit: Leaving)
19:59:47FromDiscord<haxscramper> You are running debug build?
20:01:12FromDiscord<System64 ~ Flandre Scarlet> I do ``nim compile -r myprogram.nim`` so yeah
20:01:17*iortega left #nim ("")
20:01:34FromDiscord<System64 ~ Flandre Scarlet> Since default is debug https://media.discordapp.net/attachments/371759389889003532/864235049397125200/unknown.png
20:07:23FromDiscord<System64 ~ Flandre Scarlet> the only things I understand are Segfault and corrupt stack
20:23:27FromDiscord<System64 ~ Flandre Scarlet> So I have a segfault but where
20:27:52FromDiscord<dom96> @System64 ~ Flandre Scarlet this might help https://nim-lang.org/blog/2017/10/02/documenting-profiling-and-debugging-nim-code.html
20:28:49FromDiscord<PressF> sent a code paste, see https://play.nim-lang.org/#ix=3sNi
20:29:00FromDiscord<PressF> (edit) "https://play.nim-lang.org/#ix=3sNi" => "https://paste.rs/5q3"
20:37:54*neceve quit (Ping timeout: 256 seconds)
20:39:30*LyndsySimon joined #nim
20:39:39LyndsySimonOh, good. #nim is still alive.
20:40:34FromDiscord<haxscramper> Probably `foldl(1 .. n, a b)`↵(@PressF)
20:41:00FromDiscord<haxscramper> !eval import std/sequtils; echo fold(1 .. 20, a \ b)
20:41:03NimBotCompile failed: /usercode/in.nim(1, 44) Error: invalid token: (\29)
20:41:46FromDiscord<haxscramper> !eval import std/sequtils; echo fold(1 .. 20, a + b)
20:41:50NimBotCompile failed: /usercode/in.nim(1, 27) Error: undeclared identifier: 'fold'
20:41:52FromDiscord<System64 ~ Flandre Scarlet> alright segfault https://media.discordapp.net/attachments/371759389889003532/864245197570703410/unknown.png
20:42:08FromDiscord<System64 ~ Flandre Scarlet> segfault = null pointer right?
20:42:18FromDiscord<haxscramper> Ffs, anyway, we have folds in sequtils
20:47:29FromDiscord<kaushalmodi> !eval import std/sequtils; echo foldl(toSeq(1 .. 20), a b)
20:47:31NimBotCompile failed: /usercode/in.nim(1, 51) Error: invalid token: (\29)
20:48:49FromDiscord<System64 ~ Flandre Scarlet> the only problem I have is it doesn't say where
20:48:51*supakeen quit (Remote host closed the connection)
20:49:15*supakeen joined #nim
20:49:25FromDiscord<kaushalmodi> In reply to @PressF "Is it possible to": well.. in any case `foldl` works on Nim Playground: https://play.nim-lang.org/#ix=3sNv
20:52:42FromDiscord<kaushalmodi> @PressF And here's another approach, without using `sequtils`: https://play.nim-lang.org/#ix=3sNw
20:52:52FromDiscord<haxscramper> Well, time for one true debugging technique then↵(@System64 ~ Flandre Scarlet)
20:53:00FromDiscord<haxscramper> Dump crapload of prints into the code
20:54:51FromDiscord<System64 ~ Flandre Scarlet> In reply to @haxscramper "Dump crapload of prints": so the good old echo method?
20:55:16FromDiscord<haxscramper> https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-injectstmt-pragma
20:55:53FromDiscord<haxscramper> Paired with instantiationInfo().line you can construct a template
20:56:22FromDiscord<System64 ~ Flandre Scarlet> In reply to @haxscramper "Paired with instantiationInfo().line you": for me?
21:00:02FromDiscord<haxscramper> No, seems like this doesn't quite woke as I expected https://play.nim-lang.org/#ix=3sNx
21:00:55FromDiscord<System64 ~ Flandre Scarlet> nothing displayed
21:04:10FromDiscord<haxscramper> https://github.com/nim-lang/Nim/blob/devel/tests/pragmas/tinjectstmt.nim
21:06:47FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=3sNB
21:10:32FromDiscord<Ayy Lmao> If I tag the MSG struct with `{.importc.}` it seems to work, but is that what I should be doing?
21:13:11FromDiscord<System64 ~ Flandre Scarlet> Humm crashed at the 1865th iteration of my callback https://media.discordapp.net/attachments/371759389889003532/864253076163395594/unknown.png
21:21:39FromDiscord<haxscramper> If you don't tag MSG object nim would of course generate definition for it, and this would be a different type from the compiler perspective↵(@Ayy Lmao)
21:21:59FromDiscord<haxscramper> So you need to importc(pp) thigs
21:23:11mstnote also that if in doubt, I've done pretty well via the approach of "make a tiny tiny file that just has the struct and one function and then read the code the nim compiler generates"
21:23:23FromDiscord<haxscramper> Different from the C compiler perspective\
21:23:24mstI'm not particularly good at C/C++ but I can often figure stuff out from there
21:24:07FromDiscord<Ayy Lmao> In reply to @haxscramper "If you don't tag": I noticed in the generated code when you add `importc` it uses the actual type. So I need to make a windows API wrapper that has all structs with `importc` on them.
21:24:32FromDiscord<Ayy Lmao> Since the wrappers I've found seem to just label them with `{.pure.}`
21:27:18FromDiscord<haxscramper> Is that so? We have two windows API wrappers - they don't use importc?
21:29:20FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=3sNC
21:30:31FromDiscord<Ayy Lmao> All I see in the Nim lib is `winlean.nim` which doesn't seem to have MSG defined
21:31:27FromDiscord<Ayy Lmao> I don't know my way around Nim that well though so I might be missing something
21:33:01FromDiscord<System64 ~ Flandre Scarlet> why do I have several errors? https://media.discordapp.net/attachments/371759389889003532/864258068584857651/unknown.png
21:33:07FromDiscord<haxscramper> It is quite strange winim uses pure
21:33:18FromDiscord<haxscramper> But you almost always want to use importc (pp)
21:33:47*Vladar quit (Quit: Leaving)
21:33:47FromDiscord<haxscramper> Maybe there is some extreme edge case where pure is needed, but I'm not aware of it
21:36:13FromDiscord<Ayy Lmao> I don't even know what pure does in the context of an object. It doesn't work in my case though whatever it does
21:54:58FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=3sNI
22:15:25*max22- quit (Quit: Leaving)
22:35:05*mahlon joined #nim
22:56:19FromDiscord<theangryepicbanana> huh, found a thingy for interfaces <https://github.com/zielmicha/collections.nim/blob/master/collections/iface.nim>
23:23:25FromDiscord<Ayy Lmao> How do you link the windows API with `--cc:vcc`? I'm getting linker errors while using it and no errors when I don't
23:33:49FromDiscord<demotomohiro> --passL:"kernel32.lib"?
23:40:11*rockcavera quit (Remote host closed the connection)
23:40:20FromDiscord<Ayy Lmao> --passL:"user32.lib" seems to work for me