<< 12-12-2020 >>

00:00:58voltist@Vindaar All the points are between 0 and 100, and I didn't manually set the range, so it must just be doing it itself
00:01:04voltistI'll make an issue
00:04:32miprihttps://play.nim-lang.org/#ix=2HD0 perhaps
00:07:41miprivery low confidence in that. Is the string's internal data also shared? no idea.
00:07:58FromDiscord<sealmove> guys, does nim differentiate signed and unsigned shift (for example java has `>>` and `>>>`)?
00:08:24FromDiscord<Vindaar> voltist: thanks, I already closed my laptop. I'll take a look at it tomorrow morning!
00:11:33mipri!eval echo (0x80.uint8 shr 1, cast[int8](0x80) shr 1)
00:11:35NimBot(64, -64)
00:21:28*Gustavo6046 quit (Quit: WeeChat 2.9)
00:22:20*Gustavo6046 joined #nim
00:22:33FromDiscord<sealmove> interesting, I got "Error: unhandled exception: errno: 0 `No error`" 😄
00:27:04FromDiscord<Rika> lmao "errno 0 no error" is always fun
00:28:02FromDiscord<shadow.> almost as fun as attempt to read from nil?
00:28:05FromDiscord<shadow.> SIGSEGV
00:28:07FromDiscord<shadow.> lol
00:28:22FromDiscord<shadow.> has anyone seen disruptek today since like 10 hours ago
00:28:41mipri~seen disruptek
00:28:41disbotno footnotes for `seen`. 🙁
00:28:51FromDiscord<shadow.> !seen disruptek
00:28:52disbotdisruptek spoke in 12#nim 19 hours ago 12https://irclogs.nim-lang.org/11-12-2020.html#05:08:46
00:28:55FromDiscord<shadow.> rip
00:29:36FromDiscord<sealmove> is `addr someSeq` similar to `addr someArray`? I remember you had to do something extra for seqs
00:29:39FromDiscord<Rika> at least sigsegv tells you what happened
00:29:55FromDiscord<Rika> errno 0 is just "nothings fine but i say everything is fine"
00:30:16FromDiscord<shadow.> true
00:31:20FromDiscord<Rika> @sealmove addr someSeq[0]?
00:34:04FromDiscord<sealmove> yeah i thanks that's it
00:44:39BeckinghamHoly shit, 19 hours without disruptek
00:44:56BeckinghamCan we go a whole day without him making his testes known?
00:45:44*vicfred quit (Quit: Leaving)
00:46:25FromDiscord<Gibson> mipri: thanks, still getting crashes though (probably something else in my code)
00:46:38FromDiscord<Gibson> using threadpool seems to make the issue go away, so.......
00:47:50FromDiscord<Rika> yeah weve done that before
00:48:11FromDiscord<Rika> disruptek left for a while after that event with bdfl
00:55:24PMunchOh boy
00:55:28PMunchJust finished the soldering
00:55:47BeckinghamMelt any plastic housings?
00:55:54PMunchNope
00:56:02BeckinghamCongrats 🎉
00:56:19PMunchTook me 5½ hours though..
01:00:36*Tanger joined #nim
01:00:52BeckinghamWas it worth it though
01:03:31FromDiscord<Rika> ofc
01:03:37FromDiscord<Rika> anything for the perfect keyboard
01:04:11PMunchI mean it looks pretty swanky https://photos.app.goo.gl/tSNs5USNkw4ii5Vo8
01:04:20PMunchhttps://photos.app.goo.gl/4rjoQ6nsgW34GYS48
01:04:37PMunchMuch neater than the first one
01:07:14BeckinghamThat your first one on the left?
01:07:30BeckinghamVery RTX Off/On
01:07:49Prestigenice PMunch
01:08:01BeckinghamOr it might just be the angle making it look a bit wobblier 😂
01:08:37PMunchBeckingham, yes it is indeed the first one
01:08:42PMunchAnd no, it is that wobbly :P
01:09:09BeckinghamEverything you type with it comes out as Comic Sans
01:09:18PMunchhttps://photos.app.goo.gl/8N8h4pXooB7ywaPA8
01:09:37BeckinghamFactorio: 0 -> 200 hours of play
01:10:09BeckinghamI mean your soldering is way better than mine, I might as well be welding when I do it
01:11:28FromDiscord<sealmove> is it possible to change the mode of an already opened file
01:11:30FromDiscord<sealmove> ?
01:11:54PMunchI mean I was so happy when I finished to first half, but now it just looks kinda shoddy..
01:12:04PMunchsealmove, don't think so
01:13:30FromDiscord<sealmove> when writing to a bitstream you have to do reads on it too 😛
01:14:00FromDiscord<sealmove> so `proc newFileBitStream(f: File): BitStream` won't work
01:14:15PMunchWait what?
01:14:29Beckingham?
01:15:40FromDiscord<sealmove> yeah... it's weird but basically there is a bit buffer and in some cases when writing, you have to fetch bytes from the underlying `Stream`
01:16:05PMunchHmm
01:16:09PMunchOh well, I'm off to bed
01:16:15FromDiscord<sealmove> gn!
01:16:16*PMunch quit (Quit: leaving)
01:16:25BeckinghamNight PMunch
01:19:27disruptekbeckingham: what's this about my testes?
01:19:50BeckinghamAlmost made it 24 hours, dang
01:20:34FromDiscord<sealmove> is there a way to get the mode of already opened file?
01:20:51FromDiscord<sealmove> `File` is defined as `ptr CFile` so...
01:22:44hmmmoh boy disruptek is back :o
01:24:36mipriif there is such an API for fds or C FILE*s I've never noticed it.
01:25:13FromDiscord<sealmove> this's annoying 😐
01:25:36FromDiscord<ElegantBeef> Clearly just wrap all your read/write calls with `try` and when that fails re open the file in the way you want 😄
01:25:59mipriif you're in a position of not knowing, it means you're either pushing File into an API and getting them back, or you have a data structure containing random Files
01:26:04FromDiscord<sealmove> i just want to disallow some modes
01:26:19mipriin the former case try a table of fds to information; in the latter case encode that information alongside the Files
01:27:16FromDiscord<sealmove> just wanted to make `proc newFileBitStream(f: File): BitStream` work, but if I can't even test the mode of `f`, then it won't.
01:27:32mipriok, or in your third case, don't accept a bare File. Only accept something that includes the mode information
01:27:40FromDiscord<sealmove> yeah
01:28:08miprior maybe something like a Stream object that supports the operations you want, without caring about modes
01:29:13FromDiscord<sealmove> i am wrapping `streams.Stream`
01:29:31mipri... anyway, the information might actually be available. /proc/$$/fd has interesting-looking modes on its fake symlinks
01:29:36FromDiscord<sealmove> anyway, not allowing using an opened file is fine I guess
01:31:00mipriyeah I've just never noticed it
01:31:48FromDiscord<ElegantBeef> I'd argue that's for the best as there is really not much reason to support taking in a file
01:31:48mipriok, yeah, fcntl can retrieve what you're looking for.
01:32:01mipriit can't give you all the flags that open() supports, but it can give you the ones you want
01:32:36*hmmm quit (Quit: catching zZz)
01:33:37miprithere's no Nim stdlib support for it though. You'll need to get the fileno of your File and then call some C FFI.
01:37:10stefantalpalaruI need to use "-d:noSignalHandler" in order to get core dumps on Linux?
01:43:28BeckinghamNight folks
01:43:30*Beckingham quit (Quit: WeeChat 1.9.1)
01:58:42*vicfred joined #nim
02:03:38disruptek!last clyybber
02:03:39disbotclyybber spoke in 12#nim-gamedev 8 days ago
02:13:28FromDiscord<Rebel> Sad
02:24:37FromDiscord<Quibono> Why sad?
02:28:09*^Q-Master^ joined #nim
02:28:09*Q-Master quit (Read error: Connection reset by peer)
02:33:46*mbomba quit (Quit: WeeChat 3.0)
02:49:18FromGitter<offbeat-stuff> nimlang how to execute terminal command with it's stdin stdout changed
02:49:38disrupteksee the osproc module.
02:50:19FromGitter<offbeat-stuff> There is'nt much help in there
02:50:33disruptekwhat have you tried?
02:50:47FromGitter<offbeat-stuff> execCmd
02:50:52FromGitter<offbeat-stuff> execCmdEx
02:51:10FromGitter<offbeat-stuff> Can I do it by changing env in startProcess
02:52:52FromDiscord<Quibono> https://play.nim-lang.org/#ix=2HDA Any idea why myURL is reading as a Response type?
02:53:07miprino, process environment has nothing to do with stdin and stdout
02:53:42FromDiscord<shadow.> disruptek is back
02:53:53FromDiscord<shadow.> https://github.com/nim-lang/Nim/pull/16318
02:53:54disbotAdd `rotateLeft` proc to deques.nim.
02:53:56FromDiscord<shadow.> how does pr look
02:54:05FromDiscord<shadow.> i added since notation, changelog entry, and the rotateRight template
02:54:37disruptekoffbeat-stuff: you need a Process so you can fuck with the i/o.
02:54:41FromGitter<offbeat-stuff> So , I want to give my input that comes from either from keyboard shortcuts or my window manager
02:55:11FromGitter<offbeat-stuff> Okay so startProcess then how do access it's stdin
02:55:29disruptekshadow: changelog needs to mention rotateRight, now.
02:55:41disruptekthe module name is `deques`, not `deques.nim`.
02:55:49FromDiscord<shadow.> fixing time
02:55:54miprioffbeat-stuff: the Process object has procs that return the relevant streams
02:56:29disruptekthe comments should read more like, "moves last entry in the deque to become the first entry."
02:56:47FromDiscord<Daniel> @PMunch whats that you are soldering mate?
02:56:50disruptekpeople don't necessarily know what rotation means.
02:56:51FromDiscord<shadow.> ah ok
02:56:54FromDiscord<shadow.> fair enough
02:56:58FromDiscord<shadow.> > - Added `rotateLeft` and `rotateRight` procs to the `deques` module for rotating a Deque.
02:57:00FromDiscord<shadow.> is that ok for changelog
02:57:02FromGitter<offbeat-stuff> @mipri got it
02:57:41FromDiscord<Daniel> deques sounds french, what is it?
02:57:43disruptekyou can explain it using "equivalent (but faster) than deq.pushFirst(deq.popLast)" or similar.
02:57:47FromDiscord<shadow.> double ended queue
02:57:48disruptekdouble-ended queues.
02:57:59FromDiscord<shadow.> O(1) prepend, append, pop first, and pop last
02:58:04FromDiscord<Quibono> Yeah it sounds french.
02:58:06FromDiscord<Daniel> ok, ok, ...thank you
02:58:06FromDiscord<shadow.> lmao
02:58:09FromDiscord<shadow.> it's pronounced deck
02:58:26FromDiscord<shadow.> but to take something off the end is pronounced dee-queue
02:58:31FromDiscord<shadow.> lol
02:59:33disruptekother than that, if it works, i don't care. 😀
03:00:02disruptekError: 'result' is of type <int> which cannot be captured as it would violate memory safety
03:00:04*disruptek sighs.
03:02:05FromDiscord<shadow.> kk i fixed changelog and the doc comments
03:02:39FromDiscord<shadow.> assuming i did everything you said (don't wanna make you look over it again) would that be good?
03:02:47FromDiscord<shadow.> at this point im guessing i should just wait for reviewers
03:02:59disruptekyeah, like i said, i'm happy with it.
03:03:29FromDiscord<shadow.> coming from you that's like winning a lottery, thanks
03:04:06FromDiscord<shadow.> lol
03:04:15FromDiscord<shadow.> its failing checks wtf-
03:04:30FromDiscord<shadow.> lovely
03:04:48FromDiscord<Revenant> hiya
03:05:16FromDiscord<shadow.> nvm fixed
03:05:18FromDiscord<shadow.> hi
03:05:24FromDiscord<Revenant> so what's the deal with Nim not being able to capture var types in closures (e.g. a var argument inside a proc)? is that some limitation that will never be lifted?
03:06:20FromDiscord<shadow.> maybe it doesn't want to
03:06:52FromDiscord<Revenant> talking about this error
03:07:01FromDiscord<Revenant> sent a code paste, see https://play.nim-lang.org/#ix=2HDH
03:07:47disruptekmost uses are solved by cps, but what's the code look like?
03:07:58FromDiscord<Revenant> cps? what's that?
03:08:19disruptekupcoming control-flow magic.
03:08:22disruptek!repo cps
03:08:23disbothttps://github.com/disruptek/cps -- 9cps: 11Continuation-Passing Style for Nim 🔗 15 40⭐ 2🍴
03:08:42FromDiscord<Quibono> Okay I'm losing my mind mildly.
03:09:27FromDiscord<Revenant> cheers, i'll check that out, although "upcoming" sounds too bad... i need it now 🙂
03:09:36FromDiscord<Revenant> this is what the code is roughly doing
03:09:48disruptekcan you paste it?
03:09:49FromDiscord<Revenant> sent a code paste, see https://play.nim-lang.org/#ix=2HDI
03:09:50disruptek~paste
03:09:50disbotpaste: 11a frowned-upon behavior in chat; please use a service such as https://play.nim-lang.org/ or http://ix.io/ or https://gist.github.com/ and supply us a URL instead. -- disruptek
03:11:10disruptekwell, yeah, that's unlikely to work any time soon.
03:11:52*muffindrake quit (Ping timeout: 260 seconds)
03:13:09disrupteki assume you can't use closures and gcsafe and shit?
03:13:12*Cthalupa quit (Ping timeout: 260 seconds)
03:14:04*muffindrake joined #nim
03:14:22*Cthalupa joined #nim
03:14:59FromDiscord<Revenant> yeah i'm not that big of an expert on that stuff
03:15:14FromDiscord<Revenant> anyhow, in my case i just use a global in the callback wrapper closure
03:15:43FromDiscord<Revenant> in other cases i used another workaround, basically copied the var into a non-var inside the function
03:15:58FromDiscord<Revenant> but i was just wondering if this limitation is gonna stay or not, it's pretty annoying
03:16:17FromDiscord<Revenant> (edit) "anyhow, in my case i ... just" added "can"
03:16:40disruptekif you can change the signature, of course that's a solution.
03:17:47FromDiscord<Revenant> well sure i could, but that couples things too much. the closure solution is nice because then you can wrap the callback and do whatever you want.
03:17:50FromDiscord<Revenant> anyhow, thanks
03:19:07FromDiscord<Revenant> btw, this CPS thing reminds me of co-routines/green-threads, but at a quite low-level
03:19:41disruptekyeah, that's the idea. it's a set of primitives for building that stuff (and other stuff besides).
03:19:45disruptekso much stuff.
03:19:51FromDiscord<Revenant> 🙂
03:19:57FromDiscord<Revenant> i'll keep an eye on it
03:20:06disruptek👍
03:20:08FromDiscord<Revenant> coroutines are the future (i think)
03:24:23FromDiscord<Revenant> wow this seems handy
03:24:24FromDiscord<Revenant> https://github.com/disruptek/testes
03:27:28FromDiscord<shadow.> his testes are beautiful
03:32:23FromDiscord<19> sent a code paste, see https://play.nim-lang.org/#ix=2HDP
03:34:27FromDiscord<shadow.> does that compile
03:34:37FromDiscord<shadow.> oh wait
03:34:44FromDiscord<shadow.> no those aren't the same
03:35:06FromDiscord<shadow.> ++ as postfix doesn't return successor
03:35:28FromDiscord<shadow.> and also, one modifies value the other doesn't
03:35:35FromDiscord<19> hm i think this is what's causing my bug
03:35:51FromDiscord<shadow.> are you porting from another language
03:36:08FromDiscord<shadow.> just do `var a = b; inc b`
03:36:12FromDiscord<19> sent a code paste, see https://play.nim-lang.org/#ix=2HDQ
03:36:17FromDiscord<19> yes from C
03:36:24miprino, they're not the same
03:36:38FromDiscord<shadow.> just assign to RunningSampleIndex, then increment it later on
03:38:18FromDiscord<19> ok that fixed it thank you
03:40:43FromDiscord<19> @shadow. you mean assign it and then `inc` it?
03:42:44miprivar a = b; inc b
03:42:54miprithat's the equivalent of a=b++
03:43:05FromDiscord<19> cool
03:44:30FromDiscord<19> `SampleOut++ = SampleValue;` i guess this has also the same idea?
03:47:00mipriit's similar in that you need to change the pointer after making the assignment, not before
03:47:51FromDiscord<19> how should i approach it if im using a seq instead
03:48:25mipriyou make the assignment and then you change whatever you're using as a cursor
03:48:38miprisampleOut[i] = sampleValue; inc i # for example
03:50:19FromDiscord<19> the i is immutable
03:50:36FromDiscord<19> in a for loop
03:50:51mipriI'm not talking about your i
03:51:11mipriwhatever you have, make the assignment and then change your cursor. That's all the C is doing.
03:56:16FromDiscord<19> sorry, i dont understand, can you explain? https://play.nim-lang.org/#ix=2HDT
03:57:37FromDiscord<19> c stuff: https://play.nim-lang.org/#ix=2HDV
03:59:03FromDiscord<Quibono> Audio processing scary
03:59:49FromDiscord<19> very
04:01:31FromDiscord<19> C is scarier lol
04:04:22FromDiscord<Quibono> So you’re setting all the buffers to 600?
04:04:37FromDiscord<19> no its just a stupid example
04:05:16FromDiscord<19> my problem is with the something++
04:06:01*supakeen quit (Quit: WeeChat 2.9)
04:06:34*supakeen joined #nim
04:06:52*spiderstew_ joined #nim
04:06:53FromDiscord<19> i have a working c example im just trying to port it over. maybe i should go read some stuff
04:07:02FromDiscord<19> thanks anyway ❤️
04:07:25FromDiscord<Quibono> Well someone besides me can definitely help, I haven’t had to use pointers yet.
04:07:50FromDiscord<Rika> I understand pointers but have trouble understanding the syntax for them in C
04:08:21*spiderstew quit (Ping timeout: 272 seconds)
04:08:39FromDiscord<19> its just incrementing the pointer and then dereferencing it
04:10:14FromDiscord<Rika> cast[ptr T](cast[int](something)+1)[]
04:10:18FromDiscord<Rika> replace T with the type
04:12:51mipriyou'll probably be much better off just understanding the C and accomplishing the same task, vs. manually compiling it into Nim
04:14:15FromDiscord<19> alright, ill give it a shot
04:15:13FromDiscord<Quibono> What’s the real code do?
04:15:25FromDiscord<19> sends out a sin wave to the buffer
04:16:10*narimiran joined #nim
04:18:46FromDiscord<Rika> A wave full of sins
04:19:00FromDiscord<19> xD
04:22:49FromDiscord<iWonderAboutTuatara> hey, what's the equivalent of &ptr in c in nim?
04:23:08FromDiscord<iWonderAboutTuatara> for example, if I had variable a, what's the nim version of &a?
04:23:11FromDiscord<Rika> addr a
04:23:13FromDiscord<Rika> i assume
04:23:23FromDiscord<19> a.addr
04:23:27FromDiscord<Rika> same thing
04:23:33FromDiscord<19> yes
04:23:46FromDiscord<19> a[] dereferences the points
04:23:51FromDiscord<19> (edit) "points" => "pointer"
04:24:42FromDiscord<iWonderAboutTuatara> yeah addr does the job
04:24:47FromDiscord<iWonderAboutTuatara> actually unsafeaddr does the job
04:24:58FromDiscord<iWonderAboutTuatara> hopefully doesn't cause too many problems for me
04:25:00FromDiscord<iWonderAboutTuatara> addr gives an error
04:25:45FromDiscord<Rika> that means you're getting the pointer to an immutable
04:26:02FromDiscord<Rika> unsafeaddr doesnt care, because its unsafe
04:26:02PrestigeHow should I go about copying an object? I created a new var foo = bar, where bar is an object (not a ref object), but changes to foo seem to also change bar
04:26:25FromDiscord<Rika> prestige that makes no sense, got code?
04:26:59FromDiscord<Rika> changes to a ref object inside an object (a) will reflect in both objects (a and b)
04:27:00PrestigeWell it's convoluted, just wanted to make sure I wasn't making an incorrect assumption. Thanks
04:28:38FromDiscord<InventorMatt> there is a deepcopy proc which may be what you want
04:31:03PrestigeThanks Matt, that did the trick
04:31:59FromDiscord<InventorMatt> no problem
04:32:58Prestigestill confused about how = didn't handle this case
04:34:13PrestigeWas attempting to make a copy of `defaultMonitorSettings` shown here at the bottom: https://i.imgur.com/MFrXZV4.png
04:34:52Prestigesince nothing is a ref object, I thought var foo = defaultMonitorSettings, then making changes, would be fine
04:52:36disruptekassignment is a deep value copy by default, and that includes strings and seqs -- nominal "value types".
05:08:13*a_chou joined #nim
05:09:39Prestigeah, thanks disruptek. That exl
05:09:49Prestigethat explains the table
05:11:41PrestigeWell actually. What would happen in this case, should it just be an empty table? When I create a first copy, modify, then create a second and modify that, the first ends up with the same values as the second.
05:17:32FromDiscord<exelotl> > that means you're getting the pointer to an immutable↵now that `let foo {.importc.}` is a thing I wonder if I should be using that for ROM data in my GBA project
05:18:13FromDiscord<exelotl> It would make my code uglier though cause I'd have to use unsafeAddr in lots of places where I'm currently using addr
05:28:09FromDiscord<ElegantBeef> Is that really uglier? 😄
05:28:36*thomasross quit (Ping timeout: 240 seconds)
05:28:40FromDiscord<ElegantBeef> Just use views, problem solved?
05:30:55FromDiscord<j-james> why doesn't `degToRad()` take ints?
05:32:57FromDiscord<j-james> just because `rationals` exists?
05:34:10FromDiscord<exelotl> The input type would be different to the output type which is rare for math functions I guess
05:35:21FromDiscord<exelotl> That's the main reason I can think of I guess
05:36:19FromDiscord<j-james> !eval import math; echo cos(degToRad(90.0))
05:36:21NimBot6.123233995736766e-17
05:36:34FromDiscord<ElegantBeef> Yea you rarely are going to store degrees as floats
05:36:37FromDiscord<ElegantBeef> What's wrong?
05:36:43FromDiscord<ElegantBeef> cos(1) == 0
05:37:01FromDiscord<Rika> !eval import math; echo cos(degToRad(90.0)) == 0
05:37:02FromDiscord<j-james> !eval import math; echo sin(degToRad(0.0))
05:37:04NimBotfalse
05:37:05NimBot0.0
05:37:14FromDiscord<j-james> no me gusta
05:37:27FromDiscord<Rika> false prolly because its the exact == and not the float epsilon ==
05:37:29FromDiscord<Rika> anyway
05:37:35FromDiscord<Rika> you can make one
05:37:47FromDiscord<Rika> !eval import math;echo degToRad(90.0)
05:37:50NimBot1.570796326794897
05:38:04FromDiscord<Rika> i doubt using an int would make tihs more accurate.
05:38:16FromDiscord<ElegantBeef> `6.12 10 ^-17` is 0
05:38:27FromDiscord<Rika> essentially 0
05:38:28FromDiscord<exelotl> Yes, my code doesn't have any unsafeAddr currently, and I don't wanna have to type so much for it. I also just don't like the name unsafeAddr because addr is already unsafe xD
05:38:39FromDiscord<ElegantBeef> So then views?
05:38:41FromDiscord<Rika> addr isnt really unsafe is it
05:39:01FromDiscord<ElegantBeef> I mean it's an umanaged reference afaik, it's unsafe
05:39:37FromDiscord<exelotl> Oh trust me I can't wait to use views but I don't think they're stable enough yet
05:39:43FromDiscord<j-james> !eval import math; echo cos(PI/2)
05:39:46NimBot6.123233995736766e-17
05:40:03FromDiscord<Rika> dude you wont get any closer because you use ints
05:40:15FromDiscord<ElegantBeef> Unless you make a LUT that uses degrees in ints 😄
05:40:20FromDiscord<Rika> have fun.
05:40:47FromDiscord<j-james> that's just a pain, though
05:41:13FromDiscord<Rika> well you're gonna see this everywhere
05:41:22FromDiscord<Rika> are you the python guy
05:41:25FromDiscord<ElegantBeef> in floats nothing is exact!
05:41:32FromDiscord<j-james> i am not the python guy
05:41:34FromDiscord<Rika> @ElegantBeef 0.2 is exact isnt it
05:41:46FromDiscord<Rika> 0 is exact as well
05:42:00FromDiscord<ElegantBeef> multiple things can be, but the point is you never pretend like it is
05:42:17FromDiscord<Rika> a good amount of integer values in floats are exact as well
05:42:19FromDiscord<ElegantBeef> you assume you never get the exact value and accept within a range
05:42:23FromDiscord<Rika> yeah
05:42:31FromDiscord<Rika> computations in floats are rarely exact
05:42:54FromDiscord<j-james> huh, interesting
05:43:08FromDiscord<Rika> programming languages that have exact computations are either using a slower decimal/rational implementation or hiding the fact from you
05:43:41FromDiscord<Rika> or maybe theyre just using float512s or whatever i dont fucking know
05:44:03FromDiscord<Rika> man, imagine 64 byte floats...
05:51:09disruptekaddr is unsafe, yes. unsafeAddr is silly.
06:01:06disruptekzevv: so i'm finally looking at fixing the bugs blocking cps.
06:02:31disruptekwhat's really weird is, some of this code makes it to codegen without getting sem'd.
06:09:15FromDiscord<Rebel> should work on my bugs instead 😛 well I guess not even bugs just woes
06:13:06*a_chou quit (Remote host closed the connection)
06:35:25*abm quit (Read error: Connection reset by peer)
06:41:58*waleee-cl quit (Quit: Connection closed for inactivity)
07:39:44*habamax joined #nim
07:47:11*letto quit (Quit: Konversation terminated!)
07:47:52*letto joined #nim
07:50:24Zevvhttp://zevv.nl/div/ferry.png
07:50:49FromDiscord<Rika> looks like a road system ngl
07:52:09Zevvdisruptek: so who do you ask when digging into that stuff
07:56:30narimiranZevv: help this sleepy brain: how to do this in one line? `var pos = new Point; pos[] = (0, 0)` (Point is a tuple)
08:13:16*letto quit (Quit: Konversation terminated!)
08:14:59*letto joined #nim
08:16:20Zevvdon't tuple kids, it's baaad for you, mkaaay
08:16:31narimiranyeah yeah yeah
08:16:38Zevvfield1: ?
08:16:40ZevvI don't know
08:16:45Zevv:)
08:30:49*ehmry quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.)
08:32:19*ehmry joined #nim
08:35:41FromDiscord<ElegantBeef> Any thoughts on making the header of the nim modules in docs the import path?
08:36:02FromDiscord<ElegantBeef> so for instance `since` would say `std/private/since` at the very top of the page?
08:36:20narimiranmaybe not as a title, but definitely should be there
08:41:57FromDiscord<ElegantBeef> Yea a subtitle would be fine aswell
08:42:19FromDiscord<ElegantBeef> Especially with modules that have to be imported with `std`
08:48:58cmc[m]<FromDiscord "<mratsim> so it could use FFMpeg"> Thanks!!! As is customary on IRC (whoops) I didn't state my requirements up front. Liberal license, small size (1 decoder), compilable to linux, windows, osx, ios, android and wasm. The only thing I found that fit the bill is a rough take on webm by @yglukhov, but I couldn't get that one to build. hence the AV1 wrapper idea. So what I'm wondering if anyone is working under the
08:48:58cmc[m]radar on anything
08:49:32FromDiscord<mratsim> I really hate getting typed AST in my untyped macro due to generics, ... so annoying.
08:56:14ForumUpdaterBotNew thread by Timothee: How to make openbsd CI work on your nim fork?, see https://forum.nim-lang.org/t/7244
09:03:06FromDiscord<kenran> sent a code paste, see https://play.nim-lang.org/#ix=2HFK
09:03:17FromDiscord<kenran> (edit)
09:03:38*kenran joined #nim
09:04:25FromDiscord<kenran> I don't really want to make the `x` a global to write a `Sighandler` using it.
09:38:09*spiderstew_ quit (Quit: ZNC 1.7.2+deb3 - https://znc.in)
09:38:24*spiderstew joined #nim
09:43:23Zevvnarimiran: I brought the lack of a "new" constructor up a few times.
09:43:35ZevvI always get a cryptic answer from people that does something like that, but not nice
09:46:54Zevvnarimiran: https://play.nim-lang.org/#ix=2HFU
09:47:06ZevvPleasy lobby for putting this new[] in the stdlib
09:48:01FromDiscord<ElegantBeef> I guess it's marginally better than `new Point((3, 4))`
09:48:16FromDiscord<ElegantBeef> or `new (3, 4).Point` 😄
09:48:50narimiranZevv: we'll get the same answer as always: "don't use tuples"
09:49:15FromDiscord<ElegantBeef> Let's be honest though tuples are throwaway object times
09:49:25FromDiscord<ElegantBeef> (edit) "times" => "types"
09:50:31FromDiscord<ElegantBeef> And by that i mean you should throw them away as soon as possible
09:53:23Zevvits not for tuples
09:53:35Zevvits a generic constructor for ref objects
09:53:56Zevvnew Thing(foo: bar, this:that)
09:54:32FromDiscord<ElegantBeef> Yea i was dumb and didnt actually test what i said
09:56:19ForumUpdaterBotNew thread by Spamsalty: A simple DB migration module for Nim, see https://forum.nim-lang.org/t/7245
10:06:55FromDiscord<sealmove> Simple question: I have a unittest (nim module) that needs to open a file from the same folder, so I use a relative path for the file. When I run the test outside of the folder (`nim c -r tests/tester.nim`) the path is relative to current dir so the file doesn't open. What's a common solution?
10:09:35mipriswitch("path", "$projectDir/../src") # in a config.nims file in the tests directory
10:11:15mipriah, do you mean not a module, but a file you're reading?
10:11:22mipriI do that relative to the project dir
10:11:56miprithat means that tests would fail if run from within tests, but the project dir's the right working directory anyway.
10:12:39FromDiscord<sealmove> oh ok I see. so there is no neat way to make it work from any folder?
10:13:11mipri*shrug*, there might be
10:13:46mipriI have some extra tests that require files that aren't necessarily in the repo, so they run with a separate nimble task
10:14:05miprithat sort of thing requires the project dir as the working directory anyway
10:15:38mipriI don't know what the scenario is where this is a problem, but you can do things like ( cd ..; nimble test ) from the tests directory. the parens are part of the command there, it's spawning a subshell to change dirs and run the command
10:20:02FromDiscord<Vindaar> pretty ships: https://github.com/Vindaar/AdventOfCode2020/raw/master/day12/out/ship_movement_part2.png
10:22:21ForumUpdaterBotNew thread by Mantielero: FFI - simplifying, see https://forum.nim-lang.org/t/7246
10:48:33*Vladar joined #nim
10:59:59FromDiscord<sealmove> ehhh, unittest and files don't play well together
11:00:58mipriI don't have a problems using files with unittest, provided that the CWD is set. Which it has to be if you're running tests with nimble, since you have to be in the directory the .nimble file to do that.
11:01:44FromDiscord<sealmove> opening file works file, but for some reason now data are not written to a file
11:02:00FromDiscord<sealmove> i am opening it `setup` and have `close(file)` at teardown
11:02:21FromDiscord<sealmove> and writing data to it within a `test`
11:02:33FromDiscord<sealmove> if i put everything in `test` it works
11:03:01mipriyeah, that makes sense.
11:03:04FromDiscord<sealmove> what am I missing?
11:04:14FromDiscord<sealmove> oh wow lol, teardown runs after every test?
11:04:31FromDiscord<sealmove> my bad...
11:04:35miprithat the test harness breaks what you're trying to do. That might be a fixable feature, but e.g. Rust will try to run tests in parallel for speed, which is a nice thing to have that also would interfere with what you're trying to do.
11:07:32miprianother nice feature that would interfere might be running tests in a subprocess so that crashes won't prevent further testing. Right now the tests will stop with something like segfault
11:07:50FromDiscord<sealmove> yeah, I've made a small tool for this
11:08:10FromDiscord<sealmove> https://github.com/sealmove/testify
11:09:21*hnOsmium0001 quit (Quit: Connection closed for inactivity)
11:22:22*krux02 joined #nim
11:34:14FromDiscord<asie> i tried to grep through the Nim manual but was unsuccessful; what's the difference between the `var` and `out` type modifiers in procedure parameters, if any?
11:36:14FromDiscord<mratsim> `out` is new and i don't know how to use them :p
11:36:33FromDiscord<mratsim> I think it's related to being able to omit them and use those out of place
11:37:46FromDiscord<Rika> Out is also pretty underutilized I believe
11:38:49FromDiscord<mratsim> isn't it from 1.4?
11:41:33FromDiscord<haxscramper> The only place I've seen `out` mentioned is experimental manual for covariance - https://nim-lang.org/docs/manual_experimental.html#covariance
11:41:51FromDiscord<asie> experimenting with porting over a codebase from Pascal to Nim - by hand, as pas2nim doesn't seem to support with-statements and the codebase is pretty much made out of them; also seeking to give the language another go that way, last time was 0.18.x
11:42:00FromDiscord<asie> (edit) "them;" => "them (but it's not a big codebase);"
11:42:29FromDiscord<mratsim> I think the covariance out is different from function parameter out no?
11:42:41FromDiscord<mratsim> or maybe the function parameter out only lives in a RFC
11:43:28FromDiscord<haxscramper> Oh, yeah, I actually missed `out T` in manual, but it doesn't say much about the difference
11:43:38FromDiscord<haxscramper> difference between `var T` and `out T`
11:45:10FromDiscord<mratsim> I think I should use out T for my big int library
11:45:16FromDiscord<mratsim> no idea where it's documented though
11:45:36FromDiscord<sealmove> if I have an uint64, is there an easy way to operate on a specific byte?
11:46:44FromDiscord<sealmove> with some kind of casting and then index the byte?
11:47:03FromDiscord<sealmove> i am thinking casting to array[byte], is it possible?
11:49:19FromDiscord<asie> I assume there's no facility in Nim for fixed-maximum-length strings, and I'll have to handle the trimming side effects myself?
11:50:07FromDiscord<asie> to explain myself - porting a 1992 game engine whose community demands near-100% compatibility with the original DOS source code... including quirks like this
11:51:41*tane joined #nim
11:55:59FromDiscord<haxscramper> Do you know what `out T` does for procs? I searched manual but doesn't seem to find anything besides `"Overloading based on 'var T' / 'out T'"` section. And example from it just segfaults compiler
11:57:54FromDiscord<haxscramper> No, nothing that I know of. But it should be relatively simple (in theory) to do `type FixedString = distinct string` and implement length checking (if maximal size is a global)
12:06:01*supakeen quit (Quit: WeeChat 2.9)
12:06:09*PMunch joined #nim
12:06:35*supakeen joined #nim
12:07:31PMunchFound some time to stream todays AoC
12:07:41PMunchSo will go live shortly :)
12:08:31FromDiscord<mratsim> @haxscramper I think proc foo[T](a: T, result: out T) can be called as either "let r = foo(a)" or "foo(a, r)".
12:10:29PMunchStream should be live now: https://www.twitch.tv/pmunche https://www.youtube.com/watch?v=OiqJaXOrmb8
12:11:49FromDiscord<haxscramper> Looks really useful for C wrappers maybe, though `proc hasOut(a: int, b: out int) = b = a` already crashes compiler, so no chances of testing if this is really how it works
12:13:59*natrys joined #nim
12:19:31FromDiscord<Recruit_main707> fuck, now i need to use this, it is perfect for my usecase
12:21:02FromDiscord<m0nsta> hi all. evening. i want a type to be an array of things. but i'd know the length later at run time. when it's made tho, its length would never change. how do i express this ?
12:21:18mipriseq[T]
12:21:19FromDiscord<m0nsta> one way is make it a seq and assign it to a let variable
12:22:00FromDiscord<m0nsta> mipri: say i know it'll be a seq[float]
12:22:25FromDiscord<m0nsta> but i want say, changeable lengths different times
12:22:40FromDiscord<m0nsta> i can newSeq[float](len)
12:22:54FromDiscord<m0nsta> but now i want that seq cant be added or popped from
12:23:07miprithat's what I'd do. You get length information too late to benefit much from it. At least with this you aren't wasting more space than seq overhead
12:23:33FromDiscord<m0nsta> sure, but how do i kind of lock it?
12:23:45FromDiscord<m0nsta> cant add more elements to it. cant remove elements from it
12:24:10mipri*shrug*, hide that it's a seq.
12:24:27FromDiscord<m0nsta> ~.^
12:24:27disbotno footnotes for `.^`. 🙁
12:24:39FromDiscord<m0nsta> badbot
12:25:30FromDiscord<m0nsta> making it let does the trick
12:25:55FromDiscord<m0nsta> was wondering if there's some other / more semantic way this is done ?
12:26:19*natrys quit (Ping timeout: 246 seconds)
12:26:59mipri'let' is generally how you make something immutable. The other way is information hiding.
12:27:12FromDiscord<m0nsta> how do i do the latter ?
12:27:22miprithat's not a language feature, it's just something you do.
12:27:35miprithat's what I meant by "hide that it's a seq"
12:27:38FromDiscord<Recruit_main707> wasnt there a way to allocate something on the stack? was it alloca?
12:27:39FromDiscord<m0nsta> lol. gotcha
12:27:49FromDiscord<m0nsta> encapsulation and likes
12:27:50mipri'distinct' is a language feature that might help
12:28:15FromDiscord<m0nsta> nah, i need to implement everything for the type after that
12:28:23mipriyou don't though
12:28:41mipriin your code that actually modifies anything, you can have it as a seq
12:29:30FromDiscord<m0nsta> not sure i get it
12:29:34narimiranPMunch: north and south: y, not x
12:29:36mipriwell I was thinking you'd only want `[]` or something. Yeah there are other procs you might want to borrow.
12:29:58FromDiscord<m0nsta> i cant even `$` it without telling it how
12:30:29FromDiscord<m0nsta> i guess let it is then for now ?
12:31:03mipri'let' is how this is done.
12:32:52mipriis what you were wanting something like a .freeze and .thaw for containers, that would throw an exception on mutation when frozen?
12:33:07FromDiscord<lqdev> @m0nsta alternatively you can write your own non-resizable seq using alloc and dealloc
12:33:42FromDiscord<m0nsta> i see
12:36:59*natrys joined #nim
12:41:15FromDiscord<Recruit_main707> @m0nsta maybe this is what you need, but i am not 100% sure https://youtu.be/71BLZwRGUJE?t=958
12:41:33FromDiscord<Recruit_main707> you can ignore the rest of the vid
12:44:26*kenran quit (Quit: leaving)
12:48:55*neutralsecond joined #nim
12:54:07*neutralsecond quit (Remote host closed the connection)
12:57:55FromDiscord<mratsim> @Recruit_main707 yes alloca, need to wrap it yourself: https://github.com/mratsim/weave/blob/master/weave/memory/allocs.nim#L90-L99
12:58:31FromDiscord<Recruit_main707> i know, i have used it before, i just dont know if thats what he is asking for
12:58:31FromDiscord<mratsim> the template is very important or the alloca call will be collected when the proc exit :p
12:58:49FromDiscord<Recruit_main707> ah
12:58:56FromDiscord<Recruit_main707> good to know :)
13:03:03*muffindrake quit (Quit: muffindrake)
13:06:08FromDiscord<m0nsta> not quite, but it was nice to know that can be done
13:10:13FromDiscord<m0nsta> another noob Q
13:10:25FromDiscord<m0nsta> if i want a type that can only take values -1 or 1
13:10:39FromDiscord<m0nsta> normally i do range[0..1]
13:10:43*rockcavera quit (Remote host closed the connection)
13:10:46FromDiscord<m0nsta> doesnt quite work out here
13:11:18mipriwhat do you mean, it doesn't quite work? what doesn't work about it?
13:11:27FromDiscord<m0nsta> it inclues 0
13:11:34mipriit doesn't just include it, it's *only* that or 1
13:12:02FromDiscord<m0nsta> sure, but i am looking now for -1 or 1
13:12:05mipriif you meant range[-1..1], yeah you can't have gaps in it
13:12:13FromDiscord<m0nsta> yea, that
13:12:47FromDiscord<m0nsta> sent a code paste, see https://play.nim-lang.org/#ix=2HHa
13:12:57FromDiscord<m0nsta> but there's gotta be a better way for this
13:13:20miprino, that's what I'd go with.
13:13:47mipriassuming that v1 and v2 are meaningful, and not just you needing names there
13:14:03FromDiscord<m0nsta> i could make them meaningful
13:14:11FromDiscord<m0nsta> but -1 or 1 work just fine
13:15:51FromDiscord<m0nsta> and id rather have numbers than do `ord(value)`
13:16:15FromDiscord<m0nsta> or `char(value)`
13:16:38FromDiscord<m0nsta> which ever one that is that gives me the enum value. i keep forgetting : P
13:17:37mipriLol(-1) vs. v1.int
13:17:46miprior v1.ord, indeed
13:19:45PMunch@m0nsta, sounds like an enum o me
13:25:28FromDiscord<m0nsta> PMunch: ?
13:25:52PMunchA value that can only be one of a set of discreet values, that is an enum
13:26:19FromDiscord<m0nsta> but i need them for their actual int values
13:26:38FromDiscord<m0nsta> they'll be matrix multiplied and stuff
13:26:51PMunchWell it's easy to assign custom values to an enum
13:27:00FromDiscord<m0nsta> sure
13:27:00PMunchAnd convert between them
13:27:16FromDiscord<m0nsta> ord and char right
13:27:29miprijust .typename is a safe option
13:27:56FromDiscord<m0nsta> not sure i understand mipri:
13:28:11mipriv1.int
13:28:16mipri'int' is the name of the type you want
13:28:48mipri!eval echo 500.int8
13:28:50NimBotCompile failed: /usercode/in.nim(1, 9) Error: 500 can't be converted to int8
13:29:02mipri!eval echo cast[int8](500)
13:29:05NimBot-12
13:29:17PMunchhttps://play.nim-lang.org/#ix=2HHe
13:29:47miprito be clear, the error is a feature: it didn't let you make the bad version
13:30:41mipriPMunch: no error if you pass 0 though
13:30:52PMunchReally?
13:31:03miprihttps://play.nim-lang.org/#ix=2HHf
13:31:05PMunchHuh..
13:31:06FromDiscord<Recruit_main707> how can i get the current directory of a file (that is imported by the main file)?
13:31:23PMunchWell that's a shame..
13:34:28mipriwhat it's sounding like I'd actually do, in the code m0nsta's wanting to write, is just: assert oneThing in [-1,1]
13:34:44FromDiscord<m0nsta> yea, came to say what mipri: said
13:34:51FromDiscord<m0nsta> doesnt error with 0
13:35:02FromDiscord<m0nsta> isnt that a bug ?
13:35:37FromDiscord<sealmove> hey PMunch, PR is ready to merge 🙂
13:35:53PMunchYeah I saw you pushed that :)
13:35:58PMunchBut I haven't had time to look at it yet
13:37:30FromDiscord<sealmove> np, one thing, do you mind if I put my name as co-author in the license (might help if I use binaryparse in my thesis)
13:37:51FromDiscord<sealmove> also I am writing proper test suites
13:38:07PMunchOh, not at all!
13:38:12PMunchGo ahead :)
13:38:15FromDiscord<sealmove> oh nice thanks ❤️
13:38:52PMunchI mean its MIT licensed anyways, so the name on the license doesn't really matter much
13:39:23FromDiscord<sealmove> I know, just for the looks, it will be nice if I use it in my thesis and it has my name on it
13:40:29FromDiscord<sealmove> now I am trying to make serialization work with reverse bit-endianness, it's hell >_<
13:40:46FromDiscord<sealmove> the algorithm is nowhere online
13:42:10PMunchHaha, and now you know why it didn't already support that :P
13:42:16PMunchWhat's your thesis about by the way?
13:42:44FromDiscord<sealmove> forensics
13:45:07PMunchOh cool
13:47:21FromDiscord<sealmove> The reason I am motivated to work on DSLs for describing binary formats is that forensics professionals use ad-hoc tools. Each tool vary severely in quality, platform, performance
13:47:52FromDiscord<zetashift> that sounds really cool
13:48:18PMunchYeah my initial reason for writing binaryparse was that I was parsing binary satellite data for work, and it was a massive pain
13:48:44PMunchThen I wrote the generation part of it so that I could generate mock data to test our systems
13:49:11FromDiscord<sealmove> In your case a parser did not even exist. My initial idea was to rewrite existing parser in a easier-to-maintain way.
13:49:44PMunchHaha, binaryparse definitely needs that :P
13:50:28FromDiscord<sealmove> i mean generate parsers instead of hand-writing them 😛
13:50:38PMunchThe great part about binaryparse vs. pretty much every other such format is that it's all just code. If you come across a part of the parsing that is tricky (e.g. when I recently came across the DNS "compression" scheme for names) you can just hook in a little piece of custom code and it all just works
13:51:09FromDiscord<sealmove> that's true, it's really a killer feature, you are right
13:51:35FromDiscord<sealmove> i am not sure if construct can do this
13:51:39PMunchThis means that it can read pretty much whatever binary format you can think of, without having binaryparse being a huge complex behemoth
13:52:00PMunchThat's partially why I've wanted the features you're adding to be pluggable as well
13:52:20PMunchIt's easy to add the features you need right now, without thinking about all the other similar feature that someone else might want in the future
13:52:37FromDiscord<sealmove> yes you are right, good call
13:53:35FromDiscord<mratsim> I have a challenge for you then 😉
13:53:53PMunchFor me?
13:54:55FromDiscord<mratsim> https://github.com/ethereum/eth2.0-specs/blob/dev/ssz/simple-serialize.md
13:55:11FromDiscord<mratsim> The binary serialization format of Ethereum
14:01:04PMunchI mean, it should be doable looking at the spec
14:01:19PMunchBut I don't really have the time to look into that, at least not right now
14:01:25PMunchSpeaking of which, I'm off
14:01:27*PMunch quit (Quit: leaving)
14:02:11*lritter joined #nim
14:19:46FromDiscord<zetashift> `func getRows[R, _](g: Grid[R, _]): array[R, Cell] = discard` is this a smart thing to do to get the all the rows of a Grid that consists of array[R, array[C, T]]
14:27:33*beck joined #nim
14:27:37beckwagwan
14:27:56*waleee-cl joined #nim
14:30:04FromDiscord<zetashift> heya!
14:57:14FromDiscord<hesman> sent a long message, see http://ix.io/2HHG
14:57:27FromDiscord<hesman> (edit) "http://ix.io/2HHG" => "http://ix.io/2HHH"
15:02:25*^Q-Master^ quit (Ping timeout: 240 seconds)
15:06:34miprithe .lines iterator doesn't give you the file, so you've nothing to read from. You have to either use something else entirely, like readFile(reg_file).strip.splitLines, or set variables within the loop that ensure what you want done happens later.
15:11:06ForumUpdaterBotNew thread by Archnim: Create my own language in Nim, see https://forum.nim-lang.org/t/7247
15:13:42FromDiscord<shadow.> hmm
15:13:52FromDiscord<shadow.> > (482, 3) Error: expression '
15:14:00FromDiscord<shadow.> line 482
15:14:01FromDiscord<shadow.> ` template rotateRight(deq: var Deque, n = 1): untyped =`
15:14:05FromDiscord<shadow.> line 481
15:14:05FromDiscord<shadow.> `since: (1, 5, 1):`
15:14:10FromDiscord<shadow.> anything stand out that could be causing that?
15:15:45FromDiscord<shadow.> confused because there isn't an apostrophe in sight
15:17:03miprisince: (1, 5, 1):
15:17:08mipriline 481
15:17:24FromDiscord<shadow.> what's the issue with it?
15:17:58mipriwhy do you think that's correct?
15:18:10mipriwouldn't a reason to think it's correct be, that you've looked at an example of it used elsewhere?
15:18:18FromDiscord<shadow.> reviewer on git said to do that to annotate the template
15:18:21FromDiscord<shadow.> since i couldn't use it as a pragma
15:18:40FromDiscord<shadow.> unless this doesnt mean what i think it means? https://media.discordapp.net/attachments/371759389889003532/787337630806704178/unknown.png
15:18:41FromDiscord<shadow.> im not sure
15:18:52mipriah, right. nevermind that then
15:19:24FromDiscord<shadow.> https://media.discordapp.net/attachments/371759389889003532/787337814655107092/unknown.png
15:19:26FromDiscord<shadow.> there was no message
15:19:36FromDiscord<shadow.> so i wasn't sure if he was telling me to do that or
15:19:36FromDiscord<shadow.> idk
15:20:08mipriit's not a quote in your code that's being complained about though
15:20:18mipriit's the error that's quoting your code
15:20:24FromDiscord<shadow.> ahh i see
15:20:46FromDiscord<shadow.> hm
15:20:52mipriI still don't like that since: thing
15:21:00miprithe two colons are very weird
15:21:04FromDiscord<shadow.> yeah idk
15:21:10FromDiscord<shadow.> but you cant use the pragma on a template
15:21:14FromDiscord<shadow.> and he commented that
15:21:20FromDiscord<shadow.> so im assuming its correct
15:22:12miprihe commented that in IRC?
15:22:26FromDiscord<shadow.> on the pr
15:22:27miprihttps://nim-lang.org/docs/manual.html#pragmas-line-pragma
15:22:38miprithere's an example there of a pragma that's used as a block
15:23:09FromDiscord<shadow.> ahh ok
15:23:16FromDiscord<shadow.> do you think that would work on a template?
15:23:46miprithat's already what you're attempting to do isn't it?
15:23:49FromDiscord<Rika> probably
15:23:50FromDiscord<shadow.> fair enough
15:24:05FromDiscord<shadow.> alr i pushed
15:24:07FromDiscord<Rika> no, its a different syntax, you're still missing the {..} arent you
15:24:52FromDiscord<shadow.> invalid pragma
15:24:58FromDiscord<shadow.> `{.since: (1, 5, 1).}:`
15:25:00FromDiscord<shadow.> i did that?
15:25:51FromDiscord<shadow.> odd
15:25:55FromDiscord<shadow.> ima just ask on the pr lol
15:26:00mipriok, yeah that's wrong too
15:26:06FromDiscord<shadow.> since he suggested it there has to be at least some way to do it
15:26:17miprithere are examples in stdlib, just needed to find them
15:26:22FromDiscord<shadow.> ahh ok
15:26:24beckwtf, scanf, "$w$i" doesn't work with "F10". Am I missing something?
15:26:37FromDiscord<shadow.> code?
15:26:42mipriF10 is one whole $w
15:26:48FromDiscord<shadow.> oh true lol
15:26:56beckAh fuck of course
15:27:10miprihttps://github.com/nim-lang/Nim/blob/devel/lib/pure/times.nim#L872 <- there you go, valid since syntax
15:27:13beckThanks I'll go back to RTFM'ing properly
15:27:25FromDiscord<shadow.> ahh ok
15:27:34FromDiscord<shadow.> and you think that would work on a template lmao?
15:27:53mipriyeah it definitely would
15:28:04FromDiscord<shadow.> kk
15:28:22miprihttps://github.com/nim-lang/Nim/blob/devel/lib/std/private/since.nim <- this is how it's implemented after all
15:29:15FromDiscord<shadow.> fair enough
15:29:20FromDiscord<shadow.> kk pushed
15:29:21FromDiscord<shadow.> thanks
15:29:46FromDiscord<shadow.> https://media.discordapp.net/attachments/371759389889003532/787340428265521152/unknown.png
15:29:47FromDiscord<shadow.> lol
15:30:04FromDiscord<shadow.> local test worked so fingers crossed
15:32:50FromDiscord<tomck> hmm, are there queues in the stdlib? I see a `queues` module, but it doesn't seemt o be in the current version of nim?
15:33:13FromDiscord<lqdev> deques
15:33:57FromDiscord<tomck> ah
15:34:05FromDiscord<tomck> are these implemented as a ring-buffer?
15:34:18Zevvthe implementation is based on seqs
15:34:42FromDiscord<tomck> yeah, but what does that mean
15:34:49FromDiscord<lqdev> who knows
15:34:59Zevvtomck: look in the source of deques.nim
15:35:01Zevvit's pretty trivial
15:35:06FromDiscord<lqdev> https://media.discordapp.net/attachments/371759389889003532/787341766680248330/unknown.png
15:35:09FromDiscord<lqdev> this is what they are.
15:35:50FromDiscord<tomck> ok cool, ty
15:36:28ZevvIt's one block of memory, so realize that growing can cause underlying copying
15:36:48FromDiscord<shadow.> yeah
15:36:52Zevvso if you can, choose your initialSize wisely
15:36:59FromDiscord<shadow.> it has an internal seq that is >= the deque's size
15:37:04FromDiscord<shadow.> and it just has a head and tail index
15:37:24FromDiscord<shadow.> allows it to have O(1) head and tail push / pop
15:37:57FromDiscord<shadow.> mipri still invalid pragma somehow-
15:38:13*Q-Master joined #nim
15:38:14FromDiscord<shadow.> > deques.nim(481, 8) Error: invalid pragma: since: (1, 5, 1)
15:38:25FromDiscord<shadow.> nvm
15:38:27mipriyou have to import it
15:38:34FromDiscord<shadow.> nah nvm it was like
15:38:36FromDiscord<shadow.> not loading the page
15:38:42FromDiscord<shadow.> checks r still undergoing
15:38:46FromDiscord<ajusa> how do I get the name of the logged in user? Does nim have anything for this or do I need to use the Win32 API?
15:38:59FromDiscord<shadow.> ask the machine politely
15:39:35FromDiscord<shadow.> i mean you can take a look in `winim` but there's probably another way to do it
15:39:43FromDiscord<shadow.> i'm going to assume you're talking about windows since yk you mentioned the api
15:40:12FromDiscord<ajusa> well I want to do it in a cross platform manner. wondering if nim already wrapped it or if I need to write the cross platform bit
15:40:18FromDiscord<shadow.> ohh i see
15:40:37FromDiscord<ajusa> sent a code paste, see https://play.nim-lang.org/#ix=2HI8
15:40:50FromDiscord<shadow.> ~ninp
15:40:51disbotninp: 11nim is not python!!
15:41:10FromDiscord<tomck> i'm 99% sure that won't be wrapped in nim, possibly implemented by a 3rd party library, but afaik that functionality is pretty niche
15:41:21FromDiscord<tomck> you're better off looking for a C wrapper & wrapping that
15:41:38FromDiscord<ajusa> alright, just wanted to check I wasn't missing anything. Thanks, I'll wrap something to get that!
15:42:08FromDiscord<shadow.> if you know how to do it on unix/mac then for windows im sure winapi has it
15:42:53FromDiscord<shadow.> sent a code paste, see https://play.nim-lang.org/#ix=2HIc
15:42:54FromDiscord<shadow.> should work
15:45:33FromDiscord<ajusa> https://github.com/tanpero/getUserName/blob/master/src/getUserName.cc↵I think I'll just rewrite this in Nim tbh, seems like it is pretty simple
15:57:47*kenran joined #nim
15:57:55*kenran quit (Client Quit)
15:58:42*kenran joined #nim
16:00:15*kenran quit (Client Quit)
16:00:57*kenran joined #nim
16:12:04FromDiscord<pietroppeter> I was using this workaround based on os.getHomeDir (which has separate linux/windows implementation) but the linked cpp seems more solid: `import os; echo getHomeDir().splitPath.head.splitPath.tail`
16:12:54FromDiscord<pietroppeter> !eval import os; echo getHomeDir().splitPath.head.splitPath.tail
16:12:57NimBot<no output>
16:13:37FromDiscord<pietroppeter> yeah, exactly... works on my local windows though and I kind of expect to work on a desktop linux
16:17:01FromDiscord<pietroppeter> python getpass.getuser https://docs.python.org/3/library/getpass.html : checks a few env variables, then tries to fall back to pwd module if supported, otherwise fails source: https://github.com/python/cpython/blob/3.9/Lib/getpass.py
16:18:32FromDiscord<pietroppeter> (pwd available only on Unix: https://docs.python.org/3/library/pwd.html)
16:21:46*astronavt quit (Quit: ...)
16:23:20*astronavt joined #nim
16:25:09*astronavt quit (Remote host closed the connection)
16:25:41FromDiscord<pietroppeter> this is taken from python.getPass.getUser in nim (with no pwd fallback and no raising error): https://play.nim-lang.org/#ix=2HIA
16:25:49*astronavt joined #nim
16:25:53*mika_ joined #nim
16:25:58FromDiscord<pietroppeter> I guess I like this better than the one I had
16:29:06*Q-Master quit (Ping timeout: 265 seconds)
16:46:59*mika_ quit (Ping timeout: 265 seconds)
16:55:50*hmmm joined #nim
16:56:41*Q-Master joined #nim
16:58:36hmmmmy current project is refactoring nim tutorial (part I) in disruptesque
16:58:37hmmm:o
17:05:32disrupteksay what
17:09:19hmmmwanna see a preview?
17:09:29disruptekis it NSFW?
17:09:40hmmmit's disruptesque
17:09:41hmmmso yes
17:09:48disruptekyes.
17:10:51disruptekdo you wanna show a preview?
17:10:58disruptekor were you just teasing us?
17:12:31*mika_ joined #nim
17:12:32hmmmwait man I'm cleaning it up for pretty print
17:12:43hmmmdisruptesque do not allow for petty grammar misstakes
17:20:26hmmmhttps://github.com/hmmm-the-nimion/A-tutorial-for-a-more-civilized-era/blob/main/README.md
17:21:08FromDiscord<Quibono> Disruptek I see you’ve got a style guide, any chance we can get a linter?
17:21:16disruptek"it's the gentle hand that stirs the dim candle"
17:21:20disrupteklol
17:21:34hmmm:D
17:22:40disruptekquibono: i will retype your code if you pay me money.
17:23:14FromDiscord<Quibono> Hrm, do you take BAT?
17:23:34disruptekwtf is bat?
17:24:05*habamax quit (Read error: No route to host)
17:25:45FromDiscord<Quibono> A weird cryptocurrency you get for watching ads on the Brave browser.
17:26:12disruptekcan it be traded for cash?
17:27:05FromDiscord<Quibono> Uhh yes, 1 USD = 5 BAT
17:27:43disruptekthen do that. USD is more useful around here.
17:27:58FromDiscord<Quibono> Lol
17:28:06*habamax joined #nim
17:28:13FromDiscord<Quibono> I don’t actually want to pay for code rewrites. I want a nice linter
17:28:19*habamax quit (Client Quit)
17:28:37*habamax joined #nim
17:29:02disrupteki don't think people want to read code written in my style.
17:29:12disruptekif they did, more code would be written in my style.
17:29:25FromDiscord<whisperdev> What is the easiest way to cross compile to a different architecture? Something with zig?
17:30:23disruptekzig was accidentally made harder to use with nim via a patch to make arbitrary compilers easier to use.
17:30:52FromDiscord<whisperdev> Excuse me sir I have actually no idea what you have just said
17:31:10disruptektruth is stranger than fiction.
17:33:15FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=2HJ0
17:34:05FromDiscord<Quibono> Sooo, don’t expect anything beyond morepretty for a while?
17:34:16disruptekhere's a shim i hacked up for using zig with nim. maybe it's helpful. http://ix.io/2HJ1/nim
17:35:28disruptekquibono: could be a good project for you.
17:35:33FromDiscord<haxscramper> I have `rfmt`'s algorithm for code layout, but without concrete syntax tree it is not possible to make good pretty-printer
17:35:54FromDiscord<Quibono> Honestly I’d try if I knew where to start.
17:35:54FromDiscord<haxscramper> Since you need to save comments, but comments are not a part of the nim AST
17:36:02FromDiscord<haxscramper> You can write tree-sitter grammar for nim
17:36:22FromDiscord<haxscramper> We have grammar in manual
17:36:51FromDiscord<haxscramper> Like, I've been thinking about this, but I just don't really have time
17:37:59FromDiscord<haxscramper> But if we have concrete syntax tree for nim code, with all punctuation, comments and so on, it should technically be straightforward process of mapping it to layout algorithm
17:39:29FromDiscord<lqdev> >disruptek is angry
17:39:30FromDiscord<lqdev> LOL
17:40:23disruptekneeds more 😠🤬
17:40:57FromDiscord<haxscramper> Just add russian swearing in error messages
17:42:48disrupteki like the idea of unicode curses. maybe we check your native language and pick one geographically foreign so it's unlikely to be comprehensible.
17:43:50*krux02 quit (Remote host closed the connection)
17:44:53FromDiscord<lqdev> i imagine something like
17:45:03FromDiscord<haxscramper> Eͮ̎̚R̍̃̂Rͦ͗ͤ҉̨O̍̃̚҉R̃̀̾
17:45:04FromDiscord<lqdev> "look chucklehead. i'll give you `x.inc`"
17:45:16FromDiscord<lqdev> disfmt™
17:46:17FromDiscord<haxscramper> code linter that attacks your errors
17:46:53disruptekeh, how about i just delete anything not written to spec.
17:47:01disruptekfuck those kids.
17:47:23FromDiscord<lqdev> yes
17:47:43disruptekthe output of the linter is the number of tokens removed from your code.
17:47:56FromDiscord<lqdev> https://github.com/munificent/vigil
17:47:57disruptekthe return code is zero when zero tokens were removed.
17:49:57disruptekZevv: what is this ferry graph?
17:50:54*hnOsmium0001 joined #nim
17:51:12beckWowwww Day 12 can get in the sea
17:51:40beck"Hey here's part 2, literally nothin you just wrote can be used again"
17:53:53*mika_ quit (Ping timeout: 260 seconds)
17:54:31beckAnd then I see Nari's solution and they've managed to reuse 90% of their code, goddamnit nari
17:54:35beckputting me to shame
18:00:04disruptekmiran is a pain in my ass.
18:01:00FromDiscord<m0nsta> hey disruptek: how do i get a type that is just -1 or 1 in value ?
18:01:20FromDiscord<m0nsta> can't be 0 or in-between
18:01:25disruptekuse an enum.
18:02:42FromDiscord<m0nsta> like this ? https://play.nim-lang.org/#ix=2HHe
18:04:46disrupteksure, but prefer ord and Ordinal for handling enums (over int).
18:05:09FromDiscord<m0nsta> try passing a 0 there
18:05:14disruptek~disrupstyle
18:05:14disbotdisrupstyle: 11tips for writing code that won't provoke 😠 rants 🤬 on irc: https://gist.github.com/disruptek/6d0cd6774d05adaa894db4deb646fc1d -- disruptek
18:05:53disruptekit's a bug.
18:06:40FromDiscord<whisperdev> getEnv() returns taintedstring. How does one get an int from it?
18:06:55disruptekparseInt, what else?
18:07:01disruptektainted.string
18:07:46disruptekwhisperdev: is that still broken on devel?
18:07:51disrupteker, m0nsta
18:08:01FromDiscord<m0nsta> disruptek: thought so : |
18:08:33FromDiscord<m0nsta> uhm. i think i just tested on stable
18:08:50disruptekseems to still be broken.
18:08:55disruptekdumb.
18:09:26FromDiscord<m0nsta> that looks like a wide reaching bug
18:10:12disruptekone problem is that you can still instantiate types that are invalid due to holding 0 at instantiation as opposed to a .low value via default().
18:10:27disruptekit's a thorny breaking bug to fix.
18:11:18disruptekyou will need to add a little logic to solve this. i would use a case and not, say, iteration.
18:14:17FromDiscord<m0nsta> what's amusing is this going unnoticed till now
18:14:30FromDiscord<m0nsta> i was just trolling
18:14:38FromDiscord<m0nsta> around
18:15:00disruptekit's not unnoticed; it's just tricky to solve safely.
18:15:07disruptekholy enums are a pita.
18:16:14FromDiscord<lqdev> > Use isNil in preference to == nil because it's less error-prone with respect to ==[T](a, b: ref T): bool.
18:16:15FromDiscord<lqdev> YES
18:16:44FromDiscord<lqdev> using `x == nil` in my game literally prevents my game from compiling
18:16:52FromDiscord<lqdev> because some code that uses generics gets triggered or something
18:17:25disruptekit's a problem that usually crops up in tables.
18:17:53hmmmoh return and result! nice one diruptek
18:18:12hmmmwat
18:18:22hmmmwhy can't I use except with try
18:18:33disruptektry /expressions/
18:18:37hmmmoh
18:18:39hmmm:3
18:21:30FromGitter<deech> Is there an idiomatic way of creating an object which updates a single field of another object? Ideally the old object get `move`d into the new object.
18:21:53disruptekmove it and then update the field?
18:22:36FromGitter<deech> How do I move it? Just assignment?
18:22:46FromDiscord<lqdev> yeah
18:22:53FromDiscord<lqdev> or `x = move y` if you want to be clear
18:22:54FromGitter<deech> Thanks!
18:23:05FromGitter<deech> Ah didn't know I could do that. Neat!
18:23:31*mika_ joined #nim
18:29:27FromDiscord<m0nsta> https://play.nim-lang.org/#ix=2HJj
18:29:55FromDiscord<m0nsta> ^ a little help here ?
18:35:12FromDiscord<zetashift> I know very little about concepts sorry 😦
18:35:59FromDiscord<zetashift> Anybody know why I'm getting an SIGSEV: Illegal storage access error wth this code: https://play.nim-lang.org/#ix=2HJq
18:38:42Zevvnew result
18:38:55*a_chou joined #nim
18:39:28Zevvhttps://play.nim-lang.org/#ix=2HJt
18:40:25*thomasross joined #nim
18:40:58*a_chou quit (Remote host closed the connection)
18:41:06Zevvzetashift ^
18:42:02disruptekm0nsta: you can't base a concept upon a runtime value.
18:42:43FromDiscord<m0nsta> calling a fn with values in the same file is runtime ?
18:43:30FromDiscord<m0nsta> how would i go about it, if i were to use concepts? i remember seeing them in your bloom implementation
18:43:47FromGitter<deech> Oh neat! `dup` from `sugar` just totally automates this.
18:43:56disruptekbloom just uses them to check if the type you want to filter with is `hash`-able.
18:44:18disrupteki think you want to do something similar, but with a proc that accepts a static int.
18:44:23FromDiscord<haxscramper> There is a `x is range[-1 .. 1]`, but it fails compilation still, and I don't really know what is the problem
18:44:42FromDiscord<m0nsta> that includes 0
18:44:45FromDiscord<m0nsta> no 0
18:45:27FromDiscord<haxscramper> Oh, either -1 or 1
18:45:39FromDiscord<m0nsta> disruptek: kinda? i just want to know if its 1 or -1, else give me a type / value error
18:46:01FromDiscord<haxscramper> I think there is no way to express constraints like this in nim type system.
18:46:08disrupteki wonder if you could use a -1, 0, 1 enum and the compiler was smart enough to recognize that default() == static[0].
18:46:15disruptekthat would be interesting.
18:46:20disruptekoh, i'm sure we can do it.
18:46:43FromDiscord<haxscramper> `not nil` and other flow-dependent-types might be close
18:46:43FromDiscord<m0nsta> lmao, im sure too, doesnt seem like too much of an ask : P
18:47:11FromDiscord<m0nsta> do we have ADT's in nim
18:49:20disruptekthat's what concepts are.
18:50:05FromDiscord<m0nsta> they seem more than those actually
18:50:16FromDiscord<m0nsta> more like typeclasses in haskell
18:50:40disruptekwell, we're trying to establish whether you can tighten the values statically.
18:50:48FromDiscord<haxscramper> Yes, you can do `type SomeThing = int | float | PHP`
18:51:22FromDiscord<m0nsta> i just want a is it 1 or is it a -1 or gtfo check
18:51:27FromDiscord<m0nsta> at type level
18:52:08*Q-Master quit (Ping timeout: 260 seconds)
18:52:10disrupteki bet i know a way to cheat.
18:52:57FromDiscord<m0nsta> its only cheating if you get caught ; )
18:53:04FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=2HJB
18:53:14FromDiscord<haxscramper> (edit)
18:53:38FromDiscord<m0nsta> enums have the same bug here
18:53:46FromDiscord<m0nsta> pretty 0 happy
18:54:05FromDiscord<m0nsta> !eval echo "hi"
18:54:07NimBothi
18:54:16*junland quit (Ping timeout: 240 seconds)
18:54:17FromDiscord<m0nsta> !eval type Lol = 1 | -1
18:54:19NimBotCompile failed: /usercode/in.nim(1, 12) Error: type expected, but got: 1
18:54:24FromDiscord<m0nsta> sure
18:54:28FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=2HJC
18:54:33*junland joined #nim
18:54:43FromDiscord<m0nsta> !eval type 1 = range[1..1]
18:54:44NimBotCompile failed: /usercode/in.nim(1, 6) Error: identifier expected, but got '1'
18:54:51FromDiscord<m0nsta> ofc
18:54:53FromDiscord<haxscramper> default-initialized to `enNegativeOne`, use `converter` to `int` to get custom value
18:54:56FromDiscord<haxscramper> Maybe
18:55:41FromDiscord<m0nsta> this @haxscramper ?
18:56:27FromDiscord<zetashift> @Zevv damn how could I overlook that thanks!
18:58:14FromDiscord<m0nsta> awright guys, its late over here
18:58:22disruptekholdon, i'm just testing it.
18:58:34FromDiscord<m0nsta> holding on
18:59:04disruptekit works.
18:59:23disruptekhttps://play.nim-lang.org/#ix=2HJI
18:59:35disruptekthere might be one extra indirection in there that you can remove.
18:59:42disrupteki kinda took the thermonuclear approach.
19:02:49FromDiscord<m0nsta> can you tell me what do, concepts, as a concept, do ?
19:03:14*hmmm quit (Quit: zZz)
19:03:15FromDiscord<m0nsta> i think i am having the mixed up wrt how i understand them
19:03:36disruptekthey are a filter for a generic that is matched according to whether the boolean statements are statically evaluated as true.
19:03:49disruptekuser-defined type-classes.
19:04:29disrupteki think your syntax should work, btw.
19:05:05disruptekconcepts are mostly rewritten, but they need a little more work. hopefully, 1.8 will have the rewrite.
19:05:41disrupteki offered to work on it after ic.
19:06:36FromDiscord<Anuke> Is there a 'safe' way to get a variable that points to an `object` in a `Table`, such that modifying the object will modify it in the table? Code: https://play.nim-lang.org/#ix=2HJR
19:06:59disruptekuse a ref.
19:07:13FromDiscord<Anuke> `ref object`?
19:07:16disruptekyes.
19:07:54disruptekoh, i finally see your code. yeah, no.
19:08:47FromDiscord<Anuke> so it's either `addr` or `ref object`? it just seems strange to me that my code almost works, I just can't assign the result to a temporary variable
19:10:04FromDiscord<lqdev> if you know what you're doing and really want to avoid ref object for perf reasons then taking a temporary ptr to your object is acceptable i think
19:10:24FromDiscord<lqdev> or you can try using https://nim-lang.org/docs/with.html
19:10:31disrupteki can't tell if you don't understand the difference between objects, refs, and ptrs.
19:11:01disruptekrefs are managed; you can't "cheat" the manager between nominal stack and heap domains.
19:11:08FromDiscord<lqdev> @Anuke https://zevv.nl/nim-memory/
19:12:07FromDiscord<m0nsta> disruptek: i want something more like https://play.nim-lang.org/#ix=2HJW
19:12:58FromDiscord<m0nsta> also, concepts seems interesting to work on. if you do end up working on them, maybe we could pair do it together.
19:14:53FromDiscord<Recruit_main707> you need to imagine every expression of a concept as an assertion
19:15:34FromDiscord<m0nsta> yea, sure.
19:15:36FromDiscord<Anuke> "if you know what you're doing" well, I kinda don't↵I just wanted to avoid `ref object` because there isn't any other reason for my type to be a `ref object`, and the type/table in question is fairly important for performance. I don't know the real overhead of using `ref`, but I'd still like to do things the "right" way.
19:15:42disruptekyeah, i would love to do more pair programming.
19:16:02*narimiran quit (Ping timeout: 272 seconds)
19:16:09FromDiscord<m0nsta> sweet, i'll go crash now
19:16:10disruptekoh, i'd use ref.
19:16:22FromDiscord<m0nsta> night people.
19:16:25disruptekpeace.
19:25:23*Q-Master joined #nim
19:30:00FromDiscord<zetashift> gnight
19:41:05*vesper quit (Ping timeout: 240 seconds)
19:48:11*vesper11 joined #nim
19:51:19FromDiscord<lqdev> @Anuke↵> the type/table in question is fairly important for performance↵if you tell us what the type is in a little bit more detail we may be able to help a bit better
19:53:22FromDiscord<Recruit_main707> why is there no `newLit` for `byte` in std/macros?
19:54:25disruptekwhat would such a creature look like?
19:55:56FromDiscord<lqdev> @Recruit_main707 i'll tell you a secret
19:55:57FromDiscord<lqdev> https://nim-lang.org/docs/system.html#byte
19:56:23disruptekdon't tell him.
19:56:25FromDiscord<Recruit_main707> i know, but it is uglier to use uint8
19:56:32disruptekwhat?
19:56:44FromDiscord<Recruit_main707> idk, i just dont like uint8 i guess
19:56:59disruptekPR a const, then.
19:57:44disruptekor, better yet, /don't/ PR it. 😁
19:57:52FromDiscord<lqdev> mate
19:57:57FromDiscord<lqdev> byte is uint8
19:58:04FromDiscord<lqdev> and there is a newLit for uint8
19:58:57disruptekno, he wants a nnkType constant or something.
19:59:05disrupteker, nnkByte.
19:59:24FromDiscord<Recruit_main707> nono
19:59:39FromDiscord<Recruit_main707> its what iqdev said
20:00:33FromDiscord<Recruit_main707> i know its dumb, i have dumb wishes
20:01:06*habamax quit (Quit: leaving)
20:01:27FromDiscord<lqdev> i'm not iqdev i'm lqdev
20:01:29FromDiscord<lqdev> with an L
20:02:37*mika_ quit (Ping timeout: 264 seconds)
20:04:24FromGitter<deech> How does `arc` work with something like `proc p(f: sink proc () {.closure.})`? Does passing a closure also destroy it's environment after the call is completed?
20:06:33FromDiscord<Recruit_main707> pretty sure it does
20:06:39FromDiscord<Recruit_main707> @lqdev ok
20:17:26Zevvdeech: -d:expandArc
20:18:43FromGitter<deech> Zevv, that just gives me `=destroy(f)`, can't find the implementation for that in lib code so I guess destroying a proc is a compiler built in.
20:21:10Zevvgood poijnt
20:21:26disruptekit's generated for you.
20:21:40Zevvsure it is, but I kind of expected it to show up with expand
20:22:13disruptekwhat do you mean? you expected it to output the generated proc ast?
20:24:04ZevvI don't know what I expected, I played with expandArc one time and I saw some stuff getting expanded
20:24:10Zevvbut not sure what is or is not there
20:24:45disruptekah, it's just, like, annotations for when it acted and how.
20:24:52Zevvright
20:25:01*superbia joined #nim
20:25:24disruptekwhat do you make of this proc macro bug?
20:26:11disruptekwhat's annoying is, i got it to dump the ast and then i was able to run the macro for the first time. and it works, of course, which is fun. but i don't want to code it by hand every damned time. 😁
20:26:58Zevvwhat bug is that
20:27:43disrupteki dumped the nodes at the crash in carnac and they weren't typed.
20:27:44disruptekin backend codegen.
20:27:53disruptek!repo carnac
20:27:54disbothttps://github.com/disruptek/carnac -- 9carnac: 11magical function memoization across invocations 15 3⭐ 0🍴
20:28:09Zevvah yeah that is silly stuff
20:28:13Zevvwhat does arq say about that then
20:28:37disruptekhe hasn't read my text yet. 🤪
20:28:50disruptekhe's probably avoiding me.
20:29:16disrupteki also asked him why i can't build nim with orc. that might not have gone over well.
20:29:46Zevvand he asked you why IC doesn't bootstrap
20:29:51Zevvgreat pair of friends we got there
20:29:55disrupteklol
20:30:09disruptekwell, we know why it doesn't bootstrap.
20:30:24disruptekbecause his iterators are broken. 😢
20:30:40Zevvha
20:31:52*superbia quit (Quit: WeeChat 2.9)
20:47:58kenranhttps://play.nim-lang.org/#ix=2HKC is there any way I can create a sighandler as a closure? background: I am getting a pid at some point and want my handler to be a closure around that without having to put the pid into a global var.
20:53:11*NimBot joined #nim
21:07:26*Jesin quit (Quit: Leaving)
21:09:14*Jesin joined #nim
21:24:31leorize[m]kenran: you should use sigaction
21:25:14*jmiven quit (Quit: reboot)
21:26:00*jmiven joined #nim
21:26:53leorize[m]ah nvm, you can't store custom data in struct sigaction
21:27:54leorize[m]I wouldn't say that I recommend using a signal handler though, those stuff requires a lot of tinkering to ensure that they're safe
21:28:58FromDiscord<kenran> Yeah, I know way too little too, but my scenario is this: I start a child process, and I need the signal handler just to get some information about why the child process might have crashed, then crash the main process too.
21:29:19FromDiscord<kenran> (edit) "too," => "about this,"
21:29:44FromDiscord<kenran> So it shouldn't be very unsafe in my case
21:33:37beckdisruptek you around?
21:35:01leorize[m]but if you don't need async, then use sigprocmask() to block sigchld, then call sigsuspend() to wait until sigchld is received
21:35:02leorize[m]kenran: once you got sigchld you can use waitpid() to inspect the child process
21:35:04leorize[m]if it's alive then just call sigsuspend() again
21:36:03leorize[m]though you could've just use waitpid so this might not be the brightest idea :P
21:36:10FromDiscord<kenran> leorize: thanks, I was planning to use `waitpit()` in my handler too. didn't know about `sigsuspend()` yet
21:36:16FromDiscord<kenran> (edit) "`waitpit()`" => "`waitpid()`"
21:37:29FromDiscord<kenran> I was wondering mainly about the closure aspect. Doesn't seem to be possible, but I know way too little about nim yet.
21:37:58FromDiscord<kenran> I mean, not much harm in making the PID a global, but it's just annoying since I only use it in that one place one line further down 😄
21:42:09ForumUpdaterBotNew thread by Haydenb: Update on Nim snap packages, see https://forum.nim-lang.org/t/7248
21:42:39leorize[m]it will only be possible if you can supply custom data into the signal handler :P
21:49:41FromDiscord<kenran> leorize: I tried making the PID a global variable, then I can write a handler that isn't a global. It's annoying but it works
21:50:37FromDiscord<trippleA> I'm confused how I'm supposed to compile a project that is split across multiple files.
21:51:22disruptekimport one file from another.
21:51:30leorize[m]@trippleA compile the main file
21:51:41FromDiscord<trippleA> How do I know which one is the main file?
21:52:18leorize[m]kenran: if it's simple enough I'd say go for it
21:52:55FromDiscord<trippleA> Nevermind. I figured it out 🙂
21:53:40leorize[m]kenran: just make sure you never touch the GC within the signal handler
21:54:03FromDiscord<kenran> what does "touching the gc" mean here?
21:54:10disruptekewww
21:54:21disruptekit means you should wash your hands.
21:55:05leorize[m]kenran: don't use refs, don't even read from them, avoid strings, seqs at all costs
21:57:44*mika_ joined #nim
22:00:00*Vladar quit (Quit: Leaving)
22:01:45*leorize joined #nim
22:02:04*mika_ quit (Ping timeout: 246 seconds)
22:03:31leorize[m]in practice the safest way to use a signal handler is to not use it :P
22:08:32disruptekso rude.
22:09:50FromDiscord<Rebel> Disruptek are you ready to touch some threads later 😉
22:09:52FromDiscord<Rebel> today is the day
22:09:57FromDiscord<Rebel> well maybe 2 am lol
22:10:04FromDiscord<Rebel> but sometime within the next 24 hours
22:10:09FromDiscord<Rebel> top 10 unsolved anime mysteries
22:10:19disruptekresult = (unlikely) today == theDay
22:10:34FromDiscord<Rebel> ouch
22:11:13FromDiscord<Rebel> Have you ever done pipelining in Nim?
22:11:19FromDiscord<Rebel> something like luigi in Python
22:11:21FromDiscord<Rebel> closest I can think is weave
22:11:32*natrys quit (Quit: natrys)
22:11:45FromDiscord<raydan> First attempt at nim (advent of code day11)↵Roast me↵https://github.com/raydan4/adventofcode-2020/blob/master/day11/day11.nim
22:13:02leorizeI'm scared by one-letter parameters
22:13:55leorizealso please make use of the `result` variable
22:14:06FromDiscord<Rebel> is this disruptek's calling? 😛
22:15:13FromDiscord<raydan> fair, one letter parameters are probably a bad idea for most of those
22:15:56leorizebtw we have something similar to in_range, it's `x in a..b`
22:16:39FromDiscord<raydan> Truuue, I read that somewhere in the docs but didn't think to add it
22:19:44beckAnyone savvy with npeg got 2 seconds?
22:21:26beckha nvm solved, massive PEBCAK
22:26:34disruptek~disrupstyle
22:26:35disbotdisrupstyle: 11tips for writing code that won't provoke 😠 rants 🤬 on irc: https://gist.github.com/disruptek/6d0cd6774d05adaa894db4deb646fc1d -- disruptek
22:27:49FromDiscord<lqdev> leorize: why do you hate one letter params dude
22:28:09FromDiscord<lqdev> i'm not gonna type `codegen.chunk.emitOpcode(opcDiscard)` all the time
22:28:51FromDiscord<lqdev> now here comes disruptek roasting me for using parens for a call with one param
22:29:55disruptekDAMNIT
22:30:00leorize@lqdev std/with
22:30:10disruptekhttps://gist.github.com/disruptek/6d0cd6774d05adaa894db4deb646fc1d#super-dominating-conditionals
22:31:27*krux02 joined #nim
22:33:41*kenran quit (Quit: leaving)
22:38:57FromGitter<ynfle> How can I get a pointer to an element in a `seq`? `ref` & `ptr` won't work
22:39:13disruptekwhat have you tried?
22:40:34FromDiscord<lqdev> @ynfle x[0].addr
22:40:49FromGitter<ynfle> Didn't work for me
22:40:49disruptekteach a man to fish.
22:41:01disruptekit's a new feature. are you on head?
22:41:24FromGitter<ynfle> https://play.nim-lang.org/
22:41:35FromGitter<ynfle> https://play.nim-lang.org/#ix=2HLo
22:41:36FromGitter<ynfle> No
22:41:37FromGitter<ynfle> Stable
22:41:56FromDiscord<lqdev> if it's a `let` you need to use `x[0].unsafeAddr`
22:42:05FromDiscord<lqdev> but be careful
22:42:10FromDiscord<lqdev> it's `unsafe` for a reason
22:42:20FromGitter<ynfle> Oh makes sense
22:42:25leorizeit's not like the regular one is safe :P
22:42:37FromGitter<ynfle> What is the difference?
22:42:56FromGitter<ynfle> I'm stupid for thinking I could get a pointer if the data isn't supposed to change
22:43:01leorizeunsafeAddr lets you take address of "immutable" variables
22:43:02FromDiscord<lqdev> unsafeAddr allows you to take the address of anything - including consts and lets
22:43:14FromDiscord<lqdev> and you can mutate them via the pointer
22:43:23FromDiscord<lqdev> which can cause undefined or unexpected behavior
22:43:31FromDiscord<exelotl> it doesn't let you take the address of consts
22:43:32disruptekyeah, great.
22:43:52FromDiscord<exelotl> you need uberUnsafeAddr for that
22:44:03FromDiscord<exelotl> sent a code paste, see https://play.nim-lang.org/#ix=2HLp
22:44:04FromGitter<ynfle> What is meant by "unsafe"?
22:44:24FromGitter<ynfle> Like "I know it's a pointer but I promise I won't change it"?
22:45:27FromDiscord<Quibono> I'm trying to import from another folder down a directory, and the import statement is working fine, but VSCode doesn't seem to recognize my proc
22:45:45FromDiscord<lqdev> @ynfle yes
22:46:28FromGitter<ynfle> Thx @lqdc
22:46:35FromGitter<ynfle> *@lqdev
22:46:43FromDiscord<lqdev> np
22:47:27*stefantalpalaru quit (Ping timeout: 272 seconds)
22:47:36FromDiscord<Quibono> Anyone know why vscode/my nim plugin just refuses to recognize stuff from the imported module?
22:49:27FromDiscord<Quibono> nvm, seems to be a bug on my end
22:50:45*vesper11 quit (Ping timeout: 240 seconds)
22:50:55FromDiscord<raydan> Thanks all for suggestions
22:52:22*Lord_Nightmare quit (Remote host closed the connection)
22:52:45*Lord_Nightmare joined #nim
22:56:17*vesper11 joined #nim
23:00:18*stefantalpalaru joined #nim
23:02:53*lritter quit (Quit: Leaving)
23:04:35beckSay I had a huge HTML string and I wanted to scan for every link and redirect the href to like, poop.com
23:04:44beckWhat would be the best way to go about that?
23:04:55disrupteki have one for scat.com; will that work?
23:05:21*stefantalpalaru quit (Changing host)
23:05:21*stefantalpalaru joined #nim
23:05:32beckNot poop.com sorry, say it's poop.co.uk, then change to poop.com, but not just replace(.com, .co.uk) becasue I only want to do it inside the href attribute
23:05:48FromDiscord<Rebel> Whelp surely Nim has an equivalent to bs4 so just use that or fancy regex + asyncio for speed
23:05:51disruptekwe have a parsehtml module you can use.
23:06:01beckaw lawdy
23:06:13disrupteki don't know of a bs4-analogue.
23:06:20beckbs4?
23:06:30disruptekbeautifulSoup.
23:06:40beckAh of course
23:08:08FromDiscord<Rebel> can't tell you're if being sarcastic but if you're ever done anything to do with web parsing and Python you know what that package is
23:08:47disruptekif you've ever done it without tearing your hair out, you mean.
23:11:31*pbb quit (Ping timeout: 272 seconds)
23:11:47beckI have used Python maybe twice in my life, but I am well aware of beautiful soup
23:12:00*pbb joined #nim
23:12:12FromDiscord<Quibono> Honest question, why does anyone use query strings in HTTP requests rather than sticking that in the body of the request?
23:14:07beckYou can't put the query in the body of the request when you're click a link on a webpage
23:14:15beckWell, unless you start JS'ing around
23:14:31FromDiscord<juliuskiesian> how do require a local package in a .nimble file?
23:14:34beckAlso bookmarking/URL history
23:15:41FromDiscord<Quibono> Okay, but for an API it's weird, right?
23:15:50FromDiscord<juliuskiesian> (edit) "how do ... require" added "you"
23:17:27*xet7_ joined #nim
23:19:16beckQuibono: Not entirely, REST is about describing your resources through URIs, and the body would be the details of state
23:19:33*xet7 quit (Ping timeout: 260 seconds)
23:19:34beckBut it's flexible enough that people just do whatever they want 😂
23:19:37FromDiscord<Quibono> Okay, so I'm just being pissy
23:20:04FromDiscord<Quibono> Writing a SDK for this library and keeping track of what needs to be what is annoying me.
23:20:29beckalso most HTTP caches use the URI as the key
23:20:43beckWhich is why GraphQL is such a bastard to implement effective caching for
23:29:06FromDiscord<ElegantBeef> @shadow. Ehhhh, it's now in devel 😄 https://nim-lang.github.io/Nim/strscans.html#scanTuple.m%2Cuntyped%2Cstatic%5Bstring%5D%2Cvarargs%5Buntyped%5D
23:33:41beckAlright so htmlParser is cool but it appends `<document>` tags to the string, I assume because it becomes an XmlNode?
23:54:05*tane quit (Quit: Leaving)
23:55:35FromDiscord<scott> is there a recommended way to use TLS with asynchttpserver
23:55:37FromDiscord<scott> (edit) "asynchttpserver" => "asynchttpserver?"
23:56:57*beck quit (Quit: WeeChat 1.9.1)