<< 25-01-2019 >>

00:01:17rayman22201sooo.... If I copy the string by doing `let msg = $message` at the top of the function, It works fine for me.
00:02:00FromGitter<timotheecour> well ya, but his followup qq was how to do zero-copy, which is a legitimate qq
00:02:32rayman22201He told me about an hour ago, that he was ok with copying
00:03:04FromGitter<timotheecour> Lol, i know; and then he said this: https://gitter.im/nim-lang/Nim?at=5c4a4d8920b78635b679b701
00:03:14FromGitter<timotheecour> either way, it’s a legitimate qq
00:05:04*ng0 quit (Quit: Alexa, when is the end of world?)
00:05:12FromGitter<timotheecour> in past 1 thing that worked for me for some application was to provide a callback to C: `callForeignFun(myAllocate, args)` which would allocate a nim string on nim’s GC and pass `s[0].addr` when the C function needed to allocate
00:05:15rayman22201lol. wat. @iffy, you are giving us mixed messages. What do you want? copies or no?
00:05:17rayman22201https://irclogs.nim-lang.org/24-01-2019.html#22:22:56
00:06:28FromGitter<iffy> rayman22201: I want that repo to run without error; if I have to use copies, great. If I don't, great. I have tried all kinds of things -- some of which involved making copies, some which didn't.
00:07:00FromGitter<iffy> In the end, I don't care *how* it's done, I just want that Javascript code to send a string to nim, have nim append something and send it back.
00:07:17FromGitter<timotheecour> its trivial if u’re ok w copies.
00:07:36rayman22201@timotheecour, will s[0].addr still work? I thought nim strings no longer have null terminator. I guess I am unsure of the nim string memory layout.
00:07:43FromGitter<deech> With the latest Nim pulled from `devel` when I have the following in `nim.cfg`: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c4a534f8ce4bb25b805e085]
00:08:07FromGitter<iffy> @timotheecour how do you do it with copies?
00:08:41FromGitter<timotheecour> if u receive a cstring from a foreign call, just call `$mycstring`
00:08:51FromGitter<iffy> And then how do I return a string?
00:08:51rayman22201@iffy let msg = $message
00:09:35FromGitter<timotheecour> in the other direction: if u send a cstring from nim to foreign, just make sure the nim string outlives the use of it by the foreign code, and u’ll be fine
00:09:42rayman22201@iffy see my post above: sooo.... If I copy the string by doing `let msg = $message` at the top of the function, It works fine for me.
00:10:17FromGitter<iffy> So you'd change this: https://github.com/iffy/node-nim-memory-bug/blob/master/clib.nim
00:10:19FromGitter<iffy> to
00:10:22rayman22201just do result = &"{msg} bla blah"
00:10:29FromGitter<iffy> like ^
00:10:48rayman22201yup
00:10:56FromGitter<iffy> That's the code that doesn't work :)
00:11:11FromGitter<iffy> It has a memory leak or some other memory problem
00:11:23FromGitter<timotheecour> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c4a542b7a0f4d5b190233c3]
00:11:25rayman22201yeah, you are missing the $message
00:11:48FromGitter<iffy> @timotheecour I want to return the string, not call another function
00:12:27FromGitter<timotheecour> return from nim to foreign code?
00:12:31FromGitter<iffy> yes
00:12:45FromGitter<iffy> @timotheecour here's what I have right now: https://github.com/iffy/node-nim-memory-bug/blob/master/clib.nim
00:12:46FromGitter<timotheecour> how is that not a call
00:13:10rayman22201ah, the echo makes it crash for me.
00:13:20FromGitter<timotheecour> like i said : u need to make sure it outlives its use in foreign code
00:13:36FromGitter<iffy> That's what I'm asking how to do
00:13:37FromGitter<timotheecour> just keep a global variable that holds a ref to it to avoid GC collecting it
00:13:58rayman22201This works for me: https://pastebin.com/raw/dBkJ3YZu
00:14:07rayman22201when I uncomment the echo, it breaks.
00:14:20FromGitter<iffy> breaks with a gcAssert?
00:14:27rayman22201yup
00:15:04FromGitter<kaushalmodi> This looks similar to the issue I had the other day.
00:15:19FromGitter<kaushalmodi> The solution was to use gc:none or regions
00:16:14FromGitter<kaushalmodi> There too, the echo caused the crash
00:16:25FromGitter<timotheecour> many ways to do it ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c4a5559cb47ec3000994657]
00:16:37FromGitter<timotheecour> i dont’ think u need gc:none
00:16:51FromGitter<timotheecour> *var s = “”`
00:16:53FromGitter<kaushalmodi> Search for `withScratch` in irc logs 2 days back.
00:17:29rayman22201@timotheecour, you are missing the issue here. Which I think is that something is interacting strangely with echo + gc when called from foreign code
00:17:38FromGitter<iffy> rayman22201: okay, I'm seeing the same thing as you (commenting out echo, program runs to completion). But GC_getStatistics makes me think that there's still a memory leak
00:18:05rayman22201or that the gc is just broken somehow in this context.
00:18:09FromGitter<iffy> [GC] total memory: 17305600 ⏎ [GC] occupied memory: 1365608
00:18:19rayman22201in general, the GC does not work well when called as a library
00:18:35FromGitter<iffy> okay, so regions might be a better option as @kaushalmodi suggests?
00:18:39FromGitter<timotheecour> @iffy im very happy to help if u can reduce to a tiny case involving 1 nim file + 1 C file
00:19:01FromGitter<iffy> @timotheecour I can't figure out the g++ incantation, but this is what I have so far:
00:19:49FromGitter<timotheecour> (use github gists maybe :) )
00:20:04FromGitter<iffy> @timotheecour https://gist.github.com/iffy/c0e5e962bf3f14acf41dc6969f322747
00:21:20*leorize joined #nim
00:21:48FromGitter<iffy> I'm sure I've got something wrong with references/pointers, but maybe you get the gist of it
00:25:21FromGitter<timotheecour> Thx for reducing it; indeed it had nothign to do w node :)
00:25:38FromGitter<iffy> That's good to hear!
00:27:04rayman22201please enlighten use @timotheecour?
00:27:10FromGitter<iffy> just my luck, you're going to get hit by a bus right now
00:28:10FromGitter<timotheecour> lol no i meant: since u’ve reduced it to just nim+C, it proves my gut feeling that it had nothing to do w node :)
00:28:24FromGitter<iffy> well, I haven't been able to run it yet
00:28:30rayman22201He didn't though. He isn't able to compile it, so he doesn't know it that is the issue
00:28:32FromGitter<iffy> so I don't know if it has the same problem
00:28:38FromGitter<timotheecour> oh
00:28:55FromGitter<iffy> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c4a58471cb70a372a319ec3]
00:29:02FromGitter<kaushalmodi> That was an emotional roller coaster :P
00:29:31FromGitter<timotheecour> btw do u care whether the main driver is C ? can it be nim?
00:29:54FromGitter<iffy> ummm... as long as it helps me eventually fix the problem when I run it with Node, no :)
00:30:31rayman22201If I change it to not use the `result` in the echo it works, but it still shows an uncomfortable amount of memory growth: https://pastebin.com/raw/TKzmrVL8
00:30:33FromGitter<iffy> so maybe, as a first step "no" but as a second step "yes"
00:30:46FromGitter<iffy> rayman22201: that's what I'm seeing, too
00:30:54FromGitter<iffy> I feel like there should be almost no memory growth
00:31:13rayman22201I'm guessing there is something inside of echo that is causing the gc to be unable to free some memory
00:31:36FromGitter<iffy> but the memory goes up even without echo, no?
00:32:17rayman22201I haven't checked.
00:32:33FromGitter<iffy> it does for me
00:32:49leorizehave you tried to call the GC collector manually?
00:32:51FromGitter<iffy> although I guess I'm echoing GC_getStatistics
00:33:15FromGitter<iffy> leorize: I tried in some attempt and I think it still had the gcAssert problem. I'll try again
00:33:22rayman22201@leorize, i was thinking the same thing
00:33:32FromGitter<iffy> leorize: GC_fullCollect()?
00:33:51leorizeyep
00:33:59*FromGitter * iffy tries it
00:34:42rayman22201as interesting as this is, I wonder if gc:regions will just be way easier to deal with
00:35:13FromGitter<iffy> I'm willing to try it; but I need to go soon so I'll try it tomorrow
00:35:55rayman22201I'm trying it now
00:36:41leorizegc:regions docs is really bad atm
00:36:51rayman22201true unfortunately
00:36:57rayman22201Araq keeps promising a blog post
00:37:03FromGitter<iffy> Do they exist?
00:37:10rayman22201not really
00:40:09FromGitter<iffy> Calling `GC_fullCollect()` at the end of each `hello_echo` and not echoing result allows the program to finish. The memory growth seems excessive, but I guess it works:
00:40:13FromGitter<iffy> [GC] total memory: 3674112 ⏎ [GC] occupied memory: 61528
00:40:16FromGitter<iffy> leorize: ^
00:40:47leorizehave you tried the different GCs?
00:41:20FromGitter<iffy> I tried --gc:stack I think? but it complained about something undefined
00:41:42leorizeHave you tried --gc:markAndSweep?
00:41:45FromGitter<iffy> Araq also suggested I try regions, but I don't know how to do that. @kaushalmodi pointed me toward something from a day or two ago, though
00:41:53FromGitter<iffy> lemme try that
00:41:58leorizestack is an alias for regions
00:42:07rayman22201I'm trying to find some example for regions
00:42:34rayman22201Testing with gc_fullcollect, has better memory growth, but still bad
00:42:59FromGitter<iffy> rayman22201: I confirm; mine got to 3MB total (though occupied was low)
00:43:09leorizeiirc the GC only collects when you allocate
00:43:16FromGitter<iffy> But in an Electron app, what's 3MB :)
00:43:29skellockshots fired
00:43:29rayman22201I get 5.7 MB
00:43:34rayman22201it's bad
00:44:03rayman22201especially when I started with half a meg. no good at all
00:44:05FromGitter<iffy> leorize: markAndSweep finishes but with a lot of growth:
00:44:06FromGitter<iffy> [GC] total memory: 24055808 ⏎ [GC] occupied memory: 2552280
00:44:34FromGitter<iffy> (that was without echoing result)
00:44:53rayman22201https://github.com/nim-lang/Nim/blob/devel/tests/gc/thavlak.nim
00:45:10rayman22201example from the source
00:45:27rayman22201search for `withScratchRegion`
00:45:45FromGitter<iffy> okay, sadly I have to go; Thank you everyone for your help! I'll keep plugging away (next is regions)
00:46:02rayman22201👍 gn
00:49:48leorizeAraq: how do you think about adding token length to LineInfo?
00:51:25leorizeI get the idea from prettybase, but it'd be more efficient to implement it directly into the parser
00:54:44FromGitter<timotheecour> @iffy
00:54:56FromGitter<timotheecour> i just managed to compile the standalone C++ + nim code
00:55:07FromGitter<timotheecour> there is no mem leak it seems
00:55:24FromGitter<timotheecour> running for 1000 iterations shows mem usage going up and down, not up
00:58:48FromGitter<timotheecour> using the simplest options: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c4a5f488ce4bb25b8062c52]
01:03:58rayman22201there is a mem leak, it's just not there
01:04:13rayman22201the node example obviously leaks.
01:09:36rayman22201with gc:regions it grows to 732Kb and stays there. that's pretty decent.
01:12:13rayman22201also side note, this thing is compiling nim in debug mode, so super not optimized code.
01:17:25leorizehow about --gc:destructors?
01:17:57rayman22201I don't think destructor strings have been merged yet, so idk if it will work
01:18:08leorizeit's merged and hello world is working
01:18:19rayman22201oh, ok. Then I will try it
01:18:26leorizeit won't work when threads is involved though
01:19:01rayman22201The regions output is interesting, because the memory stays at 16k for a long time and suddenly jumps. I'm trying to figure out why
01:20:36rayman22201Is cross thread destructors still wip?
01:25:09*leorize quit (Ping timeout: 256 seconds)
01:27:09*leorize joined #nim
01:29:31rayman22201`gc:destructors` won't even compile. `../lib/system/excpt.nim(224, 5) Error: internal error: '=sink' operator is generic`
01:30:07rayman22201that's using #head. I pulled and rebuilt just to make sure.
01:30:42leorizedoes "hello, world!" work?
01:31:48rayman22201no
01:32:11rayman22201all programs I try fail
01:32:23rayman22201do I need new c sources?
01:32:30rayman22201I wouldn't think so...
01:32:59leorizeI guess it has a regression
01:33:12leorizeyou should open a new issue
01:33:19leorizeuse the Hello, world example
01:33:38rayman22201bleh. ok
01:34:04rayman22201way off from where we started lol
01:37:54leorizelol
01:38:21rayman22201bah. pulling the latest seems to break gc:regions as well
01:38:29rayman22201everything has gone to hell
01:39:05rayman22201https://www.irccloud.com/pastebin/eul9AZot/
01:48:41rayman22201How is this happening... /me runs the gc test suite... gc:regions and gc:destructors is never tested.... :/
01:49:14leorizethose are fairly experimental features
01:50:37rayman22201fair enough. But how are you supposed to know if they regress if they aren't regularly tested?
01:51:04*abm quit (Ping timeout: 272 seconds)
01:52:15*zachk quit (Quit: Leaving)
01:52:42rayman22201weird. Thavlak.nim runs fine with gc:regions...
01:55:03*zachcarter quit (Ping timeout: 245 seconds)
01:58:44*skellock quit (Quit: WeeChat 2.3)
02:01:49*darithorn quit (Quit: Leaving)
02:06:59*darithorn joined #nim
02:11:00*Tyresc quit (Quit: WeeChat 2.4-dev)
02:17:15rayman22201the node thing works fine when I define a region explicitly, but `withScratchRegion` gives an illegal storage access. the default tlRegion is a threadLocal var, so I wonder if it has something to do with @iffy's node-gyp thing passing the wrong flags to the C compiler (since that is what appears to be driving the compilation in his case.)
02:18:47rayman22201anyway. I have to take off. I will brb later. I will push my changes to your code as a pr @iffy to show you how it works with regions. I will make a bug report for gc:destructors as well I guess... ttyl
02:19:35rayman22201There is still memory growth in there that I'm not sure where is coming from, but anyway. bye...
02:30:53*Geezus42 quit (Quit: WeeChat 2.3)
02:47:57*zachcarter joined #nim
02:52:25*zachcarter quit (Ping timeout: 246 seconds)
02:53:16*darithorn quit (Ping timeout: 250 seconds)
02:56:48*darithorn joined #nim
03:02:07*banc quit (Quit: Bye)
03:12:21*Marumto joined #nim
03:14:47*Marumoto quit (Ping timeout: 240 seconds)
03:17:24*dddddd quit (Remote host closed the connection)
03:22:59*banc joined #nim
03:40:40*oculux joined #nim
03:49:21*zachcarter joined #nim
03:53:48*zachcarter quit (Ping timeout: 245 seconds)
04:07:21*nsf joined #nim
04:39:05FromGitter<iffy> @timotheecour I'll have to try using --app:lib, but I'm seeing memory growth with this version: https://gist.github.com/iffy/7ad0755869240ebe295b1306179b7042 (And thanks for the clang++ example)
04:43:11FromGitter<iffy> @rayman22201 thanks for all your debugging
05:03:41FromGitter<iffy> @timotheecour I think I might be too tired to figure out why this compilation doesn't work (when attempting --app:lib): https://gist.github.com/iffy/789a2788b0e585f8c380867616847555
05:11:03*leorize quit (Remote host closed the connection)
05:23:15FromGitter<iffy> @leorize markAndSweep works on all my stuff (all the way into the Electron app) even though it still seems to leak
05:50:13*zachcarter joined #nim
05:52:41*narimiran joined #nim
05:57:26*zachcarter quit (Ping timeout: 250 seconds)
06:03:34*Snircle quit (Quit: Textual IRC Client: www.textualapp.com)
06:05:19*darithorn quit (Quit: Leaving)
06:48:28*zachcarter joined #nim
06:53:10*lritter joined #nim
06:58:58*krux02 joined #nim
07:25:15FromGitter<gogolxdong> import karax / [jstrutils, kajax, vdom, karaxdsl, karax, kdom, kbase, jjson] ⏎ ⏎ proc navigateTo*(e:Event, n:VNode) = ⏎ ⏎ ```result = buildHtml(tdiv()): ⏎ button(onclick = navigateTo): text "submit"``` ... [https://gitter.im/nim-lang/Nim?at=5c4ab9dbdab15872ceec0f45]
07:25:39FromGitter<gogolxdong> Uncaught DOMException: Failed to execute 'pushState' on 'History': A history state object with URL 'file:///D:/lxd/nimtest/karax/navigateTo.html' cannot be created in a document with origin 'null' and URL 'file:///D:/lxd/nimtest/karax/hello.html'. ⏎ ⏎ ```at file:///D:/lxd/nimtest/karax/nimcache/hello.js:715:16``` [https://gitter.im/nim-lang/Nim?at=5c4ab9f2c45b986d11b75c6d]
07:32:44FromGitter<gogolxdong> sorry, should run with http server.
07:38:24*leorize joined #nim
07:53:12*powerbit quit (Read error: Connection reset by peer)
08:14:09FromGitter<bung87> anyone can review my code ?https://github.com/bung87/proxy/blob/master/src/proxy.nim#L19
08:14:17FromGitter<bung87> I got
08:14:22FromGitter<bung87> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c4ac55eba355012a494c5ab]
08:14:59FromGitter<bung87> when I refresh the browser quickly
08:26:46*vonHabsi joined #nim
08:26:57FromGitter<2vg> > `Too many open files` ⏎ maybe, file descriptor limit. ⏎ ref: https://docs.oracle.com/cd/E19623-01/820-6168/file-descriptor-requirements.html
08:28:29FromGitter<bung87> I just checked it right now ,it’s unlimited
08:30:03FromGitter<bung87> even per request a socket ,almost 100 request one page load
08:31:22FromGitter<gogolxdong> cat /proc/sys/fs/file-max ⏎ sysctl -w fs.nr_open=`cat /proc/sys/fs/nr_open` ⏎ vim /etc/security/limits.conf ⏎ *soft nofile your value ⏎ *hard nofile your value [https://gitter.im/nim-lang/Nim?at=5c4ac95ac45b986d11b7c020]
08:31:45FromGitter<gogolxdong> you cannot set it to unlimited
08:32:39FromGitter<gogolxdong> it's ambiguous and harmful
08:32:51FromGitter<bung87> I dont think problem is there.
08:33:01FromGitter<gogolxdong> ```vim /etc/security/limits.conf ⏎ *soft nofile 1048576 ⏎ *hard nofile 1048576``` [https://gitter.im/nim-lang/Nim?at=5c4ac9bd0721b912a5d64afa]
08:33:33FromGitter<gogolxdong> have you restart your machine with `unlimited` value?
08:34:12FromGitter<bung87> it’s just a proxy server, I just refresh a page, can not be that much
08:37:17FromGitter<gogolxdong> you probably cannot login if you set it to unlimited after restarting.
08:37:23*floppydh joined #nim
08:38:36FromGitter<bung87> no ,I ‘m on my MBP,it’s unlimited when I check it
08:40:26*absolutejam joined #nim
08:41:41FromGitter<gogolxdong> What's MBP
08:41:52FromGitter<bung87> mac book pro
08:42:04FromGitter<gogolxdong> cool
08:43:14FromGitter<gogolxdong> I encountered this problem once on Linux server, then I reinstalled the system.
08:45:31FromGitter<bung87> it happens when you server runs on public
08:46:04absolutejamanyone know if there's a way to pass arbitrary data with an argparse parser/subparser?
08:46:09absolutejamWrong channel, mb
08:47:31FromGitter<gogolxdong> true.
08:52:11FromGitter<gogolxdong> BTW, the API of Tencent isn't consistent with IETF RFC 2616, which says Http header field name is case-insensitive, I have feedback to them, they committed the fault and will fix this issue.
08:52:52FromGitter<bung87> sounds cool!
08:54:32FromGitter<gogolxdong> haha, Tencent brought many issues, more than others.
09:05:26*abm joined #nim
09:13:58*ng0 joined #nim
09:15:37*krux02 quit (Remote host closed the connection)
09:18:43*ng0 quit (Client Quit)
09:35:56*PMunch joined #nim
09:40:36*zachcarter quit (Ping timeout: 250 seconds)
09:40:51*JustASlacker joined #nim
09:40:54JustASlackerhello
09:41:02JustASlackersorry for the newbie question
09:41:15JustASlackerbut I get fatal error: limits.h: No such file or directory
09:42:01JustASlackerwhen trying to compile a helloworld.nim
09:42:18PMunchYou probably need to install linux-headers
09:42:28PMunchShould be in your package manager :)
09:42:57JustASlackerdpkg -l | grep linux-headers
09:42:57JustASlackerii linux-headers-4.15.0-20
09:43:13Zevvif you're ubuntu/debian based, try 'apt-get install build-essential'
09:43:49JustASlackerah, that was it
09:43:51JustASlackerthanks
09:44:28PMunchYeah, it various a bit from distro to distro where they pack these things :P
09:44:34*JustASlacker nods
09:44:57PMunchI held my "Metaprogramming in Nim" talk yesterday at the university. As sort of a test run for FOSDEM
09:44:58JustASlackerI did that probably hundreds of times already but I still get confused
09:45:06PMunchIt went well, and I think I got some people interested
09:46:35narimiranPMunch: give us more info :) did you manage to do it in that limited time? what background did audience have? etc
09:47:30PMunchYeah it was 15 minutes and some odd seconds :) The audience was our student group for computer science studies, but they range from 1st year to doctorates
09:48:26*vonHabsi quit (Ping timeout: 240 seconds)
09:49:04PMunchIt's a fairly general overview, I just talk a bit about how it works and they show some examples. I plan on writing a companion blog post if people wants to get deeper into it :)
09:49:20narimirangood idea about blog post!
09:50:42PMunchYeah I thought that would be nice if people wanted some more information, and it's a nice way to expand the talk :)
09:54:34PMunchI'm a bit afraid however that it will be very similar to this: hookrace.net/blog/introduction-to-metaprogramming-in-nim/
09:55:10narimiranPMunch: and now you have to compete with this too :) https://nim-lang.github.io/Nim/tut3.html
09:55:40PMunchOoh, there's a part III now?
09:55:50narimiran:)
10:24:57*Vladar joined #nim
10:28:28*nsf quit (Quit: WeeChat 2.3)
10:30:27*Perkol joined #nim
10:30:43PerkolWhy do I get an error:https://bpaste.net/show/74c28554c000
10:31:02narimiranPerkol: because of `@[int]`
10:31:22PerkolHow do iproperly declare seq of ints?
10:31:37PMunchvar temp: seq[int]
10:31:38narimiranin line 4 do `...): seq[int] =`
10:31:46narimiranand you don't have to use `temp`
10:32:03PMunchAs of 0.19.0 you don't have to initialize sequences, just declare them :)
10:32:12narimiranPMunch: and he can use `result`
10:32:15PMunchBut yeah, you should use result
10:32:54PMunchChange your procedure definition to this: `proc stringToIntArray(input_string: string): seq[int]`
10:33:14PerkolI did same error
10:33:22PMunchThen drop the temp variable and the return statement and do `result.add(ord(i))`
10:33:27narimiranPerkol: ok, wait i'll make a whole example
10:34:15narimiranPerkol: here you go: v
10:34:16narimiranhttp://ix.io/1zbX/
10:34:55PMunchhttp://ix.io/1zbY/
10:35:01narimiranbut it would be nicer to do `for c in input_string: result.add(ord(c))`
10:35:20narimiran...as PMunch just showed :)
10:35:25PMunch:)
10:36:12narimiranand you can just do: `echo "test".mapIt(ord(it))` :)
10:36:44ZevvTIL mapIt, thanks
10:38:10narimiranZevv: sequtils has more of those, take a look (especially now that somebody improved its docs :P) https://nim-lang.github.io/Nim/sequtils.html#18
10:38:19PerkolResut supported in nim 0.18?
10:38:45Zevvyeah, I think I read all the manuals top to bottom at least once, but there's always stuff you just forget after reading because it doesn't properly sink in when you read it
10:38:55narimiranPerkol: you need to do `result = newSeq[int]()` at the beginning of your function in 0.18. but switch to 0.19, for your own sake ;)
10:39:14narimiranPerkol: read this https://narimiran.github.io/nim-basics/#_result_variable
10:39:23ZevvThe docs should be flipped inside out in a way, I want to search all things doing 'something with seq[T]' for example
10:39:28PMunchYeah pre 0.19.0 you needed to initialize sequences, otherwise they would be a nil ref
10:39:55PerkolYeah, thanks
10:39:58PMunchZevv, I was looking into creating a more dynamic docs system
10:40:02narimiranZevv: https://nim-lang.github.io/Nim/theindex.html ;)
10:40:38PMunchBasically use jsondoc and ingest that into a database. Then create some proper search things, add a comment section (similar to Clojure documentation), etc.
10:41:47FromGitter<timotheecour> @iffy @rayman22201 regarding memory growth problem (or lack thereof ) see https://github.com/timotheecour/vitanim/commit/e5c8de5e218771f59f66a4afc306ddc1a902093f#commitcomment-32064117 with a test case showing no memory growth
10:42:04ZevvHow/where is 'theindex' generated? Would it make sense to include the first sentence (up to the first ., or the first n characters) after each item in that list?
10:42:33Zevvfirst sentence of the ## doc, that is
10:42:55PMunchRather grab the first N characters and add an ellipse
10:43:04PMunchMakes more sense IMO
10:43:06FromGitter<timotheecour> u can do a quick search for it right? it’s easy to find where it’s generated
10:43:22narimiranZevv: eh, now suddenly "I want to search all things doing 'something with seq[T]'" is not enough? :P :D
10:43:28ZevvIt's never enough
10:46:55AraqI still think jsondoc is wrong, it's a document in a tree structure. you know what captures this tree structure? HTML.
10:48:52PMunchAraq, benefit of jsondoc is that it's easier to ingest into tooling
10:49:00PMunchHTML is more painful to parse
10:51:55PMunchPlus someone might want to change the HTML for visual purposes, the jsondoc should in theory be more stable
10:54:54ZevvWhat are the highest-level memory management primitives, preferrably portable, that I can use to make sure memory is returned to the OS when I no longer use it?
10:55:27ZevvI have a long living process that occasionally needs to handle large chunks of tens of mbs
10:55:27FromGitter<timotheecour> Yup, jsondoc is definitely the right approach, makes tooling easier, html can just load it (i’ve explained somewhere else how u can do it serverless)
10:55:58FromGitter<timotheecour> (side benefit, would make theindex.html faster to load since json is more compact than the expanded html)
10:56:05ZevvI make sure to prealloc the string large enough so that there is one mmap() happening under the hood, but nim will not munmap() the block by default if I later lose references to the new string
10:56:44FromGitter<timotheecour> would also enable dynamically adjusting content more easily (eg hiding/showing private docs (cf —docInternal) etc
10:57:45FromGitter<timotheecour> but tooling is the main argument here
10:58:09PMunchZevv, if you use a string it should be GCed whenever you loose references to it..
10:58:20ZevvYeah, but GC'ing is done at the nim-level
10:58:43Zevvnim aquires more memory from the os when needed, for example using brk() or mmap() on linux
10:59:08PMunchtimotheecour, my idea was to ingest the JSON into a database on the server. This would mean that it would serve up HTML just like it does now.
10:59:10Zevvand I see that in the memory management there are ways to return it to the OS, but I don't see this happening in my tests
11:00:15PMunchTry to put a gc full collect in your test
11:01:15ZevvI did
11:01:27PMunchCan I see the test?
11:01:42Zevvhttp://paste.debian.net/1062432/
11:01:49Zevvrun with nim c t.nim && strace -emmap,brk,munmap ./t
11:02:03Zevvtype '1' to trigger an alloc. string of 10M goes in to local var 'a'
11:02:13Zevvtype '0' to leave scope of the proc and force a GC
11:02:39Zevvobserve the mmap() reported by strace, and the lack of unmap() which I hoped for
11:03:47PerkolWhy is result preferable to return?
11:04:19*krux02 joined #nim
11:04:26Zevvit's likely that nim has other stuff in that mmap()ed block which is still in use of course
11:04:36narimiranPerkol: because it is already there, and it is idiomatic in nim, compared to your `var temp` which can be anything
11:05:11FromGitter<timotheecour> @pmunch so long there’s an intermediate jsondoc file the rest is implementation detail (although implementation i would prefer would generate the html via js as i described, enabling dynamic docs, eg filters)
11:06:30FromGitter<timotheecour> @perkol : @araq also mentioned RVO as a speed benefit of `result` over `return` although i never saw the proof of that claim :)
11:06:41FromGitter<timotheecour> 1) NRVO
11:07:28ZevvNamed Return Value Optimization (yes, I had to look that up)
11:07:36PMunchZevv, I only see one mmap for the first 1 I type
11:07:38narimiran@timotheecour do you think those acronyms are useful for somebody who has problems with declaring an empty seq? (even i don't know what you mean)
11:07:41PMunchSo there is some more going on here
11:08:07FromGitter<timotheecour> Its a google click away :)
11:08:26narimiranit's noise
11:08:43ZevvPMunch: yes, that is expected. The first alloc needs mem, so Nim goes to the OS to ask for memory. When you leave 'flop()', the var is collected but the memory arena is still kept by Nim. The next type you enter flop(), a new alloc is not needed because the arena is already big enough
11:09:02FromGitter<timotheecour> no it’’s not. It actually may be the biggest benefit of `result` over `return`, if true.
11:09:36PMunchPerkol, basically when you use result it will write it directly into the memory region of your calling procedure, saving you a memory copy
11:09:38narimiranTDMASFABIN
11:09:42*dom96_w joined #nim
11:09:53narimiranAEFUME
11:10:10narimiranJGI
11:10:14PMunchPerkol, plus it looks nice
11:10:54narimiranDYGMP?
11:16:56Araqtimotheecour: The biggest benefit is that 'return' is unstructured control flow and to be avoided
11:17:38Araqif n != nil: echo n[] # easy to prove safe, the condition dominates the subtree
11:17:44Araqif n == nil: return
11:17:59Araqecho n[] # much harder algorithms required to prove the same
11:20:27FromGitter<timotheecour> araq there’s 1 type of scenario where `result` is being abused in nim repo and return would lead invariably to cleaner code: the cases where using `return` would keep nesting to a minimum whereas `result` would lead to deep nested code (aka hard to prove/reason about , for humans)
11:20:32*Perkol quit (Remote host closed the connection)
11:21:03FromGitter<timotheecour> typically a pipeline of early returns
11:21:18Araqno, that's wrong
11:21:36Araq"keep nesting to a minimum" is exactly unstructured programming
11:22:00Zevv-> "for humans"
11:22:48Araqif you dislike "nesting" then it's not clear why we ever tried to minimize the number of gotos
11:22:53FromGitter<timotheecour> @araq i’m talking about this: https://softwareengineering.stackexchange.com/a/18473/257920
11:23:08Araqyeah, it's all wrong.
11:23:49FromGitter<timotheecour> Ok can u elaborate or, preferably, give a link where i can read more about this?
11:25:12Araqhttps://www.cs.cmu.edu/~aldrich/courses/654-sp07/slides/7-hoare.pdf
11:27:02FromGitter<timotheecour> thx for the link, will read; when u say `easy to prove` and reason about, do u mean the reader of the code or for static analysis by the compiler
11:27:32Zevvyou are talking different things - human stack size for understanding is severly limited
11:28:10Araqif you have the tooling and the tooling only works with nesting then you're better off with the nesting, whether it suits your "human stack" or not
11:28:47ZevvI'd always trust the tooling ;)
11:29:28Araqbtw I've seen human being argue for the non-nesting because they reason about the code like a compiler does it.
11:30:12Araqer, typo
11:30:18Araqargue for the *nesting*
11:30:34FromGitter<timotheecour> i mean if it’s provably better for tooling I’d accept that as an argument, but objectively most normally constituted humans would prefer the small nesting
11:30:48Zevv"normally constituted" :)
11:31:06Araqwhile cond: body # after the loop 'not cond' holds
11:31:21Araqwhile cond: body with a break in it # after the loop who knows what holds.
11:34:04FromGitter<timotheecour> not convinced; early return means: u can guarantee the returned value won’t change after it’s returned; whereas with `result`, who knows whether value may change down the line.
11:35:12FromGitter<timotheecour> and you’re talking about a different thing here: `break`in a while loop, whereas i’m talking about return vs result
11:36:26Araqit's the same thing, both cause a "divergence" in control flow
11:37:07Araqit's so bad that you love a 'defer' statement to fix the mess you created
11:37:36Araqbecause without it, you cannot do 'echo result' at the proc end reliably
11:37:48FromGitter<timotheecour> I have to disagree. And I think you’re a small minority here regarding `defer`
11:37:52Araqor add some profiling code
11:38:15Araqor if you like to add acquire/release for locking
11:39:45FromGitter<timotheecour> defer leads to safer code/less bugs ; this: `open(foo); bar(); close(foo)` is potentially incorrect; the correct alternative to defer (try/finally) is quickly unreadable after a few levels of nesting, causing ppl to just not even use it and use the incorrect version.
11:40:18FromGitter<timotheecour> that’s one of the things D got right.
11:41:08Araqyou can disagree all you want but I'm not reading a single argument beyond "I dislike nesting"
11:41:54FromGitter<timotheecour> I did: ⏎ ⏎ > u can guarantee the returned value won’t change after it’s returned; whereas with result, who knows whether value may change down the line.
11:42:48Araqthat argues for 'result should have 'let' semantics', totally different topic IMO
11:43:10FromGitter<timotheecour> `result.add` is a pattern, widely used
11:43:32FromGitter<timotheecour> can’t have the cake and eat it to
11:43:34FromGitter<timotheecour> *too
11:44:32Araqstill no arguments for return.
11:44:48Araqproc foo(): int = 4 # no return, no result, best of all worlds?
11:45:46FromGitter<timotheecour> We’re talkign about this: https://softwareengineering.stackexchange.com/questions/18454/should-i-return-from-a-function-early-or-use-an-if-statement/18473#18473
11:46:13FromGitter<timotheecour> not this `proc foo(): int = 4` (no-one complains about that)
11:47:04FromGitter<kaushalmodi> +1 on the jsondoc!
11:47:07Araqyeah, I know, software engineers are not engineers, do not know anything about math and dislike nesting.
11:47:28Araq:P
11:47:45FromGitter<timotheecour> Wot! noone said anything about not liking math and such :)
11:47:46FromGitter<kaushalmodi> Editors can then easily take that json and present the docs in-editor however they want.
11:48:21PMunchHuh, TIL the parenthesis in procedure definition are optional if you don't need any arguments
11:50:45Zevvcode is data, data is code: ``proc myconst = 42``
11:50:49FromGitter<kaushalmodi> It's optional for many cases with arguments too
11:51:46FromGitter<kaushalmodi> PMunch: Command Invocation Syntax
11:52:14PMunchYeah for calling, this is the declaration
11:52:18FromGitter<kaushalmodi> Oh nevermind, you said "definition", sorry
11:52:31PMunchproc test = echo "Hello"
11:52:34PMunchThat's valid
11:52:36FromGitter<kaushalmodi> I was wondering why this was new
11:52:50FromGitter<kaushalmodi> PMunch: TIL too! :)
11:53:40*stefanos82 joined #nim
11:57:35*rockcavera quit (Ping timeout: 246 seconds)
11:57:48Araqin open; write; close why is the 'close' so special here that we need to put it in a finally/defer? because the ';' sequencing is a lie, it got corrupted by return/raise/break
11:59:25narimiranPMunch, @kaushalmodi: you never used `proc main = ...`?
11:59:56PMunchI've always done proc main() =
12:02:24FromGitter<kaushalmodi> narimiran: nope, because consistency :)
12:02:54FromGitter<kaushalmodi> So I never discovered this
12:08:58*dddddd joined #nim
12:09:16FromGitter<timotheecour> @araq ⏎ ⏎ > why is the 'close' so special here that we need to put it in a finally/defer? because the ';' sequencing is a lie, it got corrupted by return/raise/break ⏎ ⏎ I really don’t understand this argument; `result` pattern (as opposed to early return pattern) has exact same thing to worry about: raised exceptions can break the control flow even if you don’t have a single `return`.
12:09:16FromGitter... [https://gitter.im/nim-lang/Nim?at=5c4afc6c0721b912a5d79d5d]
12:13:45*seni joined #nim
12:17:05FromGitter<bung87> anyone can help me with this? https://forum.nim-lang.org/t/4589
12:18:51leorizeare you on devel?
12:19:08FromGitter<bung87> yeah level 19.9
12:19:21FromGitter<bung87> devel
12:20:00leorizeare you on linux?
12:20:29FromGitter<bung87> I developing on osx and runs on it
12:21:18leorizewhat's the output of `ulimit -n` on your system? (run this in a shell)
12:21:49FromGitter<bung87> 256
12:22:07leorizethat's the number of available fds
12:22:58leorizetry `ulimit -n hard`
12:23:17leorizethen `ulimit -n` again to see the number of available fds
12:25:47FromGitter<bung87> ulimit -Hn ⏎ unlimited ⏎ ulimit -Sn ⏎ 256 [https://gitter.im/nim-lang/Nim?at=5c4b004bc45b986d11b929c1]
12:26:22leorizeyea, set the fd limit to unlimited and try to run your server in that exact shell
12:26:22FromGitter<bung87> I need change the soft limit?
12:26:31leorizechange the current limit
12:26:37leorize`ulimit -n unlimited`
12:28:03livcdalthough i think that's not a persistent change
12:28:31leorizeyea, the correct one is to call setrlimit from your program
12:28:33FromGitter<bung87> https://coderwall.com/p/lfjoaq/persist-ulimit-settings-in-mac-os-x
12:28:37leorizebut for testing this is alright :)
12:28:44FromGitter<bung87> I follow this article
12:29:54livcdhey bung87 you are chinese right ?
12:30:28FromGitter<bung87> why ulimit -aH shows diffrient
12:30:38FromGitter<bung87> @livecd yes
12:30:55*Snircle joined #nim
12:32:08leorizebecause that's the hard limit
12:32:13livcdand you have QQ right ?
12:32:27FromGitter<bung87> @leorize do you know where the problem is if I hold individual AsyncHttpClient per server
12:33:15FromGitter<bung87> livcd I have but use wechat usually
12:34:16FromGitter<bung87> I will reboot my mac, comming back soon
12:40:52*xace quit (Ping timeout: 272 seconds)
12:43:26shashlickPMunch : how about dash, docset and dashl
12:43:37PMunchHuh?
12:44:29FromGitter<bung87> @leorize works as expected.thank you!
12:44:37shashlickFor doc format
12:45:21PMunchNever heard of either of those :P
12:45:31*nsf joined #nim
12:46:09shashlickhttps://kapeli.com/dash
12:46:51shashlickhttps://github.com/Kapeli/feeds
12:47:46*xace joined #nim
12:47:53*dom96_w quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
12:48:22livcdbung87:do you mind asking @xcgui QQ room if they could make an english release ?
12:50:04FromGitter<bung87> um..I dont understand what you are asking for
12:50:42*Perkol joined #nim
12:51:16livcdbung87: the only care about the chinese users afaik. All of it is in chinese and you cant even get in touch without QQ. So I am asking if the author could make it available for english speakers
12:53:55FromGitter<gogolxdong> wechat has Enlish version.
12:55:49FromGitter<kaushalmodi> shashlick: I believe those are the user interfaces for docs
12:56:03FromGitter<kaushalmodi> They would need a json doc or something to render those
12:56:33FromGitter<kaushalmodi> Devdocs at least does that
12:56:55FromGitter<kaushalmodi> That actually parses the HTML docs to JSON, and then generates its own HTML
12:58:23FromGitter<bung87> livcd I see it’s a commercial project
13:00:01Araqer ... did DeepMind win SC2?
13:00:42FromGitter<bung87> yeah I see the news
13:01:15Araqwtf, I predicted it would fail until maybe 2025
13:01:19Araq:-(
13:03:02FromGitter<bung87> haha,I see there’s a lot papers about AI gaming on https://arxiv.org/
13:04:31livcdwas not the alphazero vs stockfish a bigger deal than this ?
13:05:30*dom96_w joined #nim
13:11:19*ng0 joined #nim
13:17:32*vlad1777d joined #nim
13:20:02Araqdunno its "APM" is so high that I consider it cheating
13:20:04FromGitter<arnetheduck> er.. `result` variable and nvro have nothing to do with each other - compiler can do nrvo without the language randomly exposing a mutable variable called `result`.. using `result` however encourages you to write code where you forget to assign a value in some of the paths, specially when you're using nesting / structure ie : ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ this semantically enforces both that all
13:20:04FromGitter... paths have a value and that the value is used for something at the end of the if block - bonus point: you don't need to build an extra control flow prover [https://gitter.im/nim-lang/Nim?at=5c4b0d0395e17b4525aa5e35]
13:20:38Araqit's help NRVO is you lack an "optimizer"
13:21:41FromGitter<arnetheduck> not really - the transformation you're doing now for `return` is exactly the same, regardless if `result` is exposed to the language or not
13:22:59*BigEpsilon joined #nim
13:23:17shashlick@kaushalmodi actually they use sqlite
13:23:25shashlickAnd there are open source versions
13:23:29FromGitter<arnetheduck> I'm a bit curious though.. was looking at it the other day, and it looks like the callee is responsible for clearing the `result` .. why not the caller?
13:23:42shashlickThe docs can be html too
13:24:50shashlickAnd there are open source versions too like zeal
13:28:42FromGitter<kaushalmodi> shashlick: JSON will come to more uses than just viewing the docs in browser
13:29:06AraqNRVO is not the same as "you can move in a return statement"
13:30:33AraqNRVO does not apply when there are different return paths with different named objects.
13:31:02Araqwhich doesn't happen in Nim, because it's not "differently named objects", it's result, always.
13:31:37Araqbut ever since I figured out the "It's the last read of the location that can be optimized" it became a very moot point.
13:32:03Araqso yeah, in today's Nim 'result' has no performance benefits.
13:32:45FromGitter<arnetheduck> yeah, that's my point :) it can happen behind the scenes and you're already doing it :)
13:34:09FromGitter<arnetheduck> from a developer perspective however, when I see result being used I tend trust the code a little less because there are more things that can go wrong, in terms of control flow
13:36:49Araqas for your question, I think zero'ing in the callee produces less code
13:37:12Araqas there are usually more callsites than entry points
13:37:41Araqbut it changed a couple of times so I don't even know what we currently do
13:45:36*smitop joined #nim
13:46:18smitopIs it possible to compile the Nim compiler into javascript?
13:50:44*natrys joined #nim
14:01:24FromGitter<arnetheduck> well, right now it resets in both caller and callee: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c4b16b49bfa375aab5a8640]
14:01:32FromGitter<arnetheduck> ```proc f(): X = ⏎ result.x = "test" ⏎ ⏎ proc y() = ⏎ echo f().x``` [https://gitter.im/nim-lang/Nim?at=5c4b16bcc45b986d11b9c3b5]
14:12:28JustASlackercan anybody shed some light on https://nim-by-example.github.io/for_iterators/
14:13:03*stefanos82 quit (Remote host closed the connection)
14:13:23narimiranJustASlacker: what is the problem?
14:13:36JustASlackerIm unsure how the connection is made between that type (is that an object) and the for loop
14:14:03narimiranyeah, it is not the best/clearest example
14:14:14JustASlackerpairs is used because it returns a tuple?
14:14:23narimiranwhat would you like to do with your iterator? or are you just following that tutorial?
14:14:31JustASlackerjust following
14:14:56JustASlackerIve used python for years and I stumple upon nim while checking out nimpy
14:15:02JustASlackeror is it pynim
14:15:10narimirannimpy, probably :)
14:15:12JustASlackerhttps://github.com/yglukhov/nimpy
14:15:13JustASlackeryeah
14:15:35FromGitter<arnetheduck> > as there are usually more callsites than entry points ⏎ ⏎ good point.. though the caller knows more about the state of the variable at call site.. reminds me of.. what was it.. pascal vs c calling convention :)
14:16:15narimiranJustASlacker: so, nim has several built-in iterators, such as `items` and `pairs`, and that example tries to show what they do behind the scenes. and you're right about pairs returning (index, element) tuple
14:18:49JustASlackeryeah, it literally the first line on that page
14:18:57JustASlackerit read the code but not the text
14:19:02JustASlackerthanks tho
14:21:02narimiranJustASlacker: haha, no problem. i'm also coming from python background, btw. and my advise for you is to just start using nim for some simple problems (i started by translating some of my python scripts, so i could easily compare them), and soon enough you'll be hooked :)
14:21:30FromGitter<kaushalmodi> JustASlacker: Check out https://scripter.co/notes/nim/#for-loops-and-iterators
14:22:06FromGitter<kaushalmodi> They are my notes on Nim; that section is me interpreting that exact section from Nim by Example
14:22:08JustASlackernarimiran: yeah, I doodling a bit as wel
14:22:34FromGitter<kaushalmodi> Let me know where I need to clear up things in those notes.
14:22:44JustASlackerthe only think I kinda dislike for now is that its unclear where a function comes from
14:22:52JustASlackerlike from foo import bar
14:23:00JustASlackeror just import foo
14:23:03JustASlackerand do foo.bar
14:23:21FromGitter<kaushalmodi> That import bit is subjective
14:23:27JustASlackerthat seems to be kinda hidden in nim versus python
14:23:37JustASlackerkaushalmodi: thx
14:23:37narimiranJustASlacker: yeah, that bothered me (and lots of others) when i first tried nim. but you get used to it and kinda appreciate :)
14:23:45JustASlackerwe shall see :P
14:24:40FromGitter<kaushalmodi> If you like python style, there's an option to import nothing too
14:24:41narimiranJustASlacker: in python that would be a mess (and `from foo import *` is discouraged), but in nim you have types, so `foo(int)` and `foo(string)` are two completely different functions
14:24:46*gangstacat quit (Quit: Ĝis!)
14:24:58FromGitter<kaushalmodi> Then you have to do moduleName.proc each time.
14:25:00leorizewhen I first saw that I thought it would be like pascal. luckily it doesn't
14:25:47JustASlackerso, I can do module.proc ?
14:25:52narimiranleorize: it is 15 years or so since i used pascal :D what is pascal's way?
14:26:41narimiranJustASlacker: you can, and you'll be happy at first, until you won't be able to do `a + b`, because you'll need `module.+(module.a, module.b)` :D
14:26:42leorizethe pascal import is basically: the module "use"-ed later will override the earlier one symbol
14:27:21FromGitter<kaushalmodi> See https://nim-lang.github.io/Nim/tut1.html#modules-from-statement
14:27:42FromGitter<kaushalmodi> The `from foo import nil`
14:27:54FromGitter<kaushalmodi> But note that that's not canonical Nim
14:28:14FromGitter<kaushalmodi> You are unnecessarily making your code verbose with that
14:28:49FromGitter<kaushalmodi> Nim is a compiled language so you don't need extra code to prevent user errors
14:29:05JustASlackerkay
14:29:15JustASlackerany documentation on the async part of nim somewhere?
14:29:25JustASlackerI see it has some async enabled libraries
14:29:35leorizesee asyncdispatch module
14:30:06JustASlackerah, so its a module
14:30:51FromGitter<kaushalmodi> I'd recommend bookmarking https://nim-lang.github.io/Nim/theindex.html
14:31:25FromGitter<kaushalmodi> Just use the browser Ctrl+F to search anything on that page
14:32:42JustASlackerthx
14:45:02*PMunch quit (Remote host closed the connection)
14:52:22*Perkol quit (Remote host closed the connection)
14:58:11*gangstacat joined #nim
15:04:31*elrood joined #nim
15:12:27*Marumoto joined #nim
15:12:46*skellock joined #nim
15:13:44*JustASlacker quit (Remote host closed the connection)
15:15:24*Marumto quit (Ping timeout: 272 seconds)
15:36:08*narimiran quit (Remote host closed the connection)
15:36:45*noonien quit (Ping timeout: 252 seconds)
15:37:11*darithorn joined #nim
15:39:11*noonien joined #nim
15:41:10*Sembei joined #nim
15:43:16*Pisuke quit (Ping timeout: 268 seconds)
15:48:52*absolutejam quit (Quit: WeeChat 1.9.1)
15:51:29*salewski joined #nim
15:52:29salewskiRelated to recent forum post of oister I wonder why conversion of int/cint to pointer is not allowed:
15:52:43salewskivar x: int
15:53:00salewskivar p: pointer = pointer(x)
15:53:22salewskit.nim(20, 25) Error: type mismatch: got <int> but expected 'pointer'
15:53:39salewskiBye.
15:54:54*rockcavera joined #nim
15:58:56*abm quit (Ping timeout: 240 seconds)
16:11:43dom96_wBecause it's an unsafe cast
16:12:02dom96_wThere is absolutely no guarantee this is memory safe
16:12:13dom96_wAnd so you need to use cast[pointer](x)
16:13:52smitopHow do you append to a `seq`?
16:14:05dom96_wadd
16:18:33salewskiYes it is unsafe, I think I will never use it myself. But I thougth a conversion is better for 4 byte cint to 8 byte pointer
16:19:15salewskithan a cast. I am never sure what cast does for different data sizes. Will do some test eventually.
16:19:40salewskiBye.
16:19:42*salewski quit (Quit: WeeChat 2.3)
16:21:52*floppydh quit (Quit: WeeChat 2.3)
16:22:22*salewski joined #nim
16:23:20salewskismitop, we use add() for that, I think it is from system module.
16:23:28*salewski quit (Client Quit)
16:24:29*stefanos82 joined #nim
16:46:16*gangstacat quit (Remote host closed the connection)
16:49:13jxywhat exactly is cast supposed to do in Nim?
16:50:16jxywhat happens if I cast a cint to a pointer? What happens if I cast a pointer to a cint?
16:50:53jxywhat if it is a int32, but not a cint?
16:58:59shashlickcast is unsafe, so totally depends on you doing the right thing
16:59:39shashlickif you case from pointer to wrong size, you could lose info
16:59:52shashlickif you cast to pointer from the wrong data type, you are pointing to random memory spot
17:00:02shashlickcrashes will become your friend
17:10:03*skellock quit (Ping timeout: 245 seconds)
17:12:02*lritter quit (Quit: Leaving)
17:21:36*narimiran joined #nim
17:24:38*skellock joined #nim
17:29:02*skellock quit (Ping timeout: 250 seconds)
17:32:37*skellock joined #nim
17:33:32*narimiran quit (Remote host closed the connection)
17:34:29*narimiran joined #nim
17:37:21*skellock quit (Ping timeout: 268 seconds)
17:42:50*narimiran quit (Remote host closed the connection)
17:43:27*narimiran joined #nim
17:54:41*nsf quit (Quit: WeeChat 2.3)
18:01:35*wildlander joined #nim
18:06:51*krux02 quit (Remote host closed the connection)
18:12:06*banc quit (Ping timeout: 272 seconds)
18:14:40*Trustable joined #nim
18:15:14*banc joined #nim
18:18:34*skellock joined #nim
18:29:12*zachk joined #nim
18:30:03*zachk quit (Read error: Connection reset by peer)
18:30:27*zachk joined #nim
18:35:33*zachk quit (Changing host)
18:35:33*zachk joined #nim
18:36:56*skellock quit (Ping timeout: 246 seconds)
18:43:12*narimiran quit (Remote host closed the connection)
18:43:17shashlick@kaushalmodi - any idea why version-0-19 build is fast on Linux/OSX (due to caching) but Windows still takes full time?
18:43:51*narimiran joined #nim
18:43:54*narimiran quit (Remote host closed the connection)
18:46:31*Perkol joined #nim
18:47:12PerkolDoes jester framework have any sort of template system?
18:48:36*gangstacat joined #nim
18:48:39*narimiran joined #nim
18:57:33FromGitter<Varriount> Perkol: I think so.
18:58:23FromGitter<Varriount> shashlick: Embrace crashes. Let them into your life. 😜
18:58:34*Trustable quit (Remote host closed the connection)
18:59:42*Trustable joined #nim
19:02:36*dom96_w quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
19:02:55shashlicknow that Araq and krux02 posted that gdb video, perhaps I can!
19:02:56FromGitter<iffy> How do I print a pointer address?
19:03:44FromGitter<Varriount> echo repr(addr variable)
19:04:04smitopHow can I read a config file at compile time?
19:04:09FromGitter<Varriount> Or cat the variable to a pointer
19:04:23FromGitter<Varriount> smitop: What's the config format?
19:04:54smitopA file that can be read by `parsecfg`
19:06:06FromGitter<iffy> @Varriount that prints the whole cstring... any way to get just the address?
19:09:18*xet7 joined #nim
19:19:46*Trustable quit (Remote host closed the connection)
19:21:33*Trustable joined #nim
19:21:43FromGitter<timotheecour> ya
19:22:09FromGitter<timotheecour> toHex
19:22:48FromGitter<iffy> mycstring.unsafeAddr.toHex?
19:23:10FromGitter<iffy> hmm.. compiler doesn't like that. Do I need to import something?
19:23:52FromGitter<timotheecour> `toHex(cast[int]foo.addr) ` ; in strutils
19:24:55FromGitter<iffy> Had to do: `toHex(castint (mycstring.unsafeAddr))`
19:25:04FromGitter<timotheecour> ya
19:25:13FromGitter<iffy> awesome, that works great!
19:32:45*Perkol quit (Quit: Leaving)
19:34:49FromGitter<iffy> Going from C++ -> Nim, if I have `const char* somestring = ...; mylib_echo((char *)(somestring));` from Nim's perspective, did I just call `mylib_echo` with a `cstring` or a `ptr cstring`?
19:36:03FromGitter<timotheecour> my 97% bet: a cstring
19:36:17*Tyresc joined #nim
19:36:21FromGitter<timotheecour> but u can verify by printing address; let me know when u check!
19:36:56FromGitter<timotheecour> Ptr cstring would be double pointer
19:37:27FromGitter<iffy> the `toHex(...)` value is 00007FFF5FBF9210 and the `repr(x.unsafeAddr)` value is: `ref 0x7fff5fbf9210 --> 0x1028178b0"SELECT * ..."`
19:38:44*BigEpsilon quit (Quit: WeeChat 2.3)
19:38:45FromGitter<iffy> @timotheecour ^
19:39:33FromGitter<timotheecour> with x : cstring = arg_passed_from_c. and c passing `char*`?
19:39:44FromGitter<iffy> yep
19:39:52FromGitter<iffy> C++ if that makes a difference
19:40:53FromGitter<timotheecour> maybe easiest would be add complete minimal code in ur repo and i can look? (Easier than in a gist if i need to run it; so i can just git clone and run :) )
19:41:33FromGitter<iffy> Do you have node installed? If not, I can see if it's the same with just the C++ + Nim version
19:45:10*Yardanico quit (Quit: No Ping reply in 180 seconds.)
19:46:29*Yardanico joined #nim
19:52:59FromGitter<iffy> @timotheecour https://github.com/iffy/vitanim/blob/address-stuff/testcases/tests/t0126/test.cpp
19:54:01*gangstacat quit (Quit: Ĝis!)
19:54:13*zyklon joined #nim
19:56:09FromGitter<iffy> ok, it's a cstring, not a ptr cstring
19:59:27FromGitter<timotheecour> ok thx for confirming :)
20:00:50FromGitter<timotheecour> i do have node; but i couldnt’ run ur code other day because of node-gyp
20:00:52FromGitter<timotheecour> (not sure how/where to get it)
20:00:59FromGitter<timotheecour> added plotting , say it?
20:01:08FromGitter<timotheecour> *saw
20:01:17FromGitter<iffy> oh hrm... I thought npm i would get node-gyp
20:01:36FromGitter<timotheecour> btw what’s `hrm` again?
20:01:43FromGitter<timotheecour> (on osx)
20:02:02FromGitter<iffy> hrm == confounded humming
20:03:00FromGitter<iffy> Yep, I see the plotting. So the program just take a lot of memory
20:05:08FromGitter<timotheecour> > I see that memory goes up and down ⏎ ⏎ what metric ?
20:05:25shashlickhave we deleted older nim tar.gz from http://nim-lang.org?
20:05:39shashlicktrying to install 0.15.0 and its not there
20:06:53FromGitter<iffy> @timotheecour occupied memory from GC_getStatistics
20:18:02Araqshashlick: we never delete any older Nims
20:24:45FromGitter<genotrance> ya the .xz is there but there's no gz
20:24:54FromGitter<genotrance> did you release gz files back then?
20:27:12FromGitter<timotheecour> @iffy PTAL https://github.com/timotheecour/vitanim/commit/e5c8de5e218771f59f66a4afc306ddc1a902093f
20:27:47FromGitter<timotheecour> can u send me a PR so i can repro what u’re observing here: `If I change the iterations to 10000 memory usage still goes up and down, but ends up at ~1.5MB` ?
20:33:44*skellock joined #nim
20:38:02*skellock quit (Ping timeout: 246 seconds)
20:38:10*nsf joined #nim
20:43:52*skellock joined #nim
20:47:34Araqprobably no .gz, why does it matter
20:57:07*vonHabsi joined #nim
21:01:21*gangstacat joined #nim
21:02:47dom96shashlick: you've asked this before I think
21:03:08dom960.15.0 is before choosenim so I didn't bother rearchiving those past versions in .gz
21:03:11dom96I doubt they even wor
21:03:13dom96*work
21:03:25dom96well, I guess they might
21:03:36dom96but I don't think there is much point in getting them
21:05:17FromGitter<Vindaar> @timotheecour "TOOD: convert to nimpy or something :)" FTFY: https://github.com/timotheecour/vitanim/pull/5 :P
21:05:55dom96nimpy really is cool
21:06:07*gangstacat quit (Client Quit)
21:06:08dom96Can someone write a blog post about it on nim-lang.org? :)
21:10:52narimiran+1
21:11:49FromGitter<Vindaar> It really is! Although for plotting I prefer plotly by now. :) And I've been meaning to write stuff :(
21:12:37*ng0 quit (Quit: Alexa, when is the end of world?)
21:12:47narimiran@Vindaar ploty used from nim or?
21:13:02FromGitter<Vindaar> yes
21:13:27narimirani briefly tried plotly back when i was doing python, but i just scratched the surface, never properly tested it
21:15:02narimiranbut yeah, somebody else can write about nimpy, and you @Vindaar can write about nim+plotly :)
21:15:02*rockcavera quit (Read error: Connection reset by peer)
21:15:15*rockcavera joined #nim
21:15:26*skellock quit (Quit: WeeChat 2.3)
21:16:47FromGitter<Vindaar> Will try to do that
21:18:17*zyklon quit (Ping timeout: 246 seconds)
21:18:36*rockcavera quit (Remote host closed the connection)
21:20:17shashlickdom96: ya i was working on a csources PR but doesn't seem worth it
21:20:21shashlickwill rather work on xz support
21:28:44FromGitter<kaushalmodi> @Vindaar This might be a stupid question, but does plotly work based of an API?
21:28:51FromGitter<kaushalmodi> or can it work completely offline?
21:31:33FromGitter<Vindaar> What it currently does is convert Nim's plotly commands to JsonNodes, which are then dumped to an Html file. The file loads the latest plotly.js release: https://github.com/brentp/nim-plotly/blob/master/src/plotly/tmpl_html.nim#L7
21:31:53FromGitter<Vindaar> In principle nim plotly could ship a version of plotly.js to use it completely offline of course
21:33:16*zyklon joined #nim
21:43:50*narimiran quit (Ping timeout: 250 seconds)
21:50:28*shpx joined #nim
21:59:26federico3https://ci.appveyor.com/project/FedericoCeratto/nim/ any idea on why the appveyor VM is unable to find an ssl symbol?
21:59:46*abm joined #nim
22:03:03*Trustable quit (Remote host closed the connection)
22:10:23FromGitter<timotheecour> @shashlick @dom96 maybe it was me who had asked about prior nim (see https://github.com/dom96/choosenim/issues/66)
22:11:06FromGitter<timotheecour> @vindaar thx again for that PR! much much appreciated
22:11:07*a_b_m joined #nim
22:14:25*abm quit (Ping timeout: 246 seconds)
22:19:38*zyklon quit (Read error: Connection reset by peer)
22:19:59FromGitter<Vindaar> Glad to help!
22:20:09FromGitter<kaushalmodi> @Vindaar thanks .. now I am looking if nim-plotly can plot FFT plots
22:20:50FromGitter<kaushalmodi> going down a rabbit hole now .. need to figure out how to calc fft etc in Nim
22:22:22*nsf quit (Quit: WeeChat 2.3)
22:23:14FromGitter<kaushalmodi> I am going through https://plot.ly/python/fft-filters/, but cannot see where the fft calculation is happening
22:24:22FromGitter<iffy> If I do `var x:string = "something"; p:pointer = ...; moveMem(p, x[0].addr, x.len)` will a null byte be written at the end?
22:24:45FromGitter<iffy> Actually... now I'm wondering if moveMem works when the source is a string
22:28:10FromGitter<timotheecour> > will a null byte be written at the end? ⏎ ⏎ why would it? last byte written shd be ‘g’ no?
22:28:23FromGitter<timotheecour> (u’re moving x.len bytes only)
22:28:46FromGitter<timotheecour> (also… u can just try and see!)
22:30:14FromGitter<timotheecour> @iffy u said `If I change the iterations to 10000 memory usage still goes up and down, but ends up at ~1.5MB` but i’m not observing this at all; do u mind sending a PR so i can reproduce?
22:30:28FromGitter<iffy> @timotheecour yeah, I sent one
22:30:44FromGitter<tweenietomatoes> timothee dont forget that im your biggest fan !
22:31:11FromGitter<iffy> @timotheecour How do I see that? I'm not very good with nim and looking at what's in memory. How do I print out X bytes of memory?
22:31:20FromGitter<timotheecour> lol thx
22:33:02FromGitter<Vindaar> @kaushalmodi Sure, why not. To calculate FFTs I only know about these two wrappers: https://github.com/ziotom78/nimfftw3 and https://github.com/m13253/nim-kissfft. Well, the first is officially archived and the second hasn't been updated in 3 years. Played around with the latter about a year ago
22:33:33FromGitter<kaushalmodi> yep, my search got me to nim-kissfft
22:33:46FromGitter<kaushalmodi> good news is that kissfft C library is actively maintained
22:34:05FromGitter<kaushalmodi> If I go down that path, I might try using nimterop + kissfft directly
22:38:01FromGitter<Vindaar> If nimterop doesn't work well, updating nim-kissfft shouldn't be a problem either
22:41:13*Jesin quit (Quit: Leaving)
22:42:54*shpx quit (Quit: shpx)
22:44:14*shpx joined #nim
22:49:10FromGitter<kaushalmodi> @Vindaar I got nim-kissfft to compile
22:49:23FromGitter<kaushalmodi> after these fixes ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c4b9273975714406b4089e9]
22:49:30FromGitter<kaushalmodi> I was surprised that that's all it took
22:49:43FromGitter<kaushalmodi> though .. not sure what to do with the example it has in its readme ..
22:49:57FromGitter<kaushalmodi> Do you happen to have the code when you played with nim-kissfft?
22:53:41FromGitter<kaushalmodi> hmm, turns out this `Complex` type change was not released in 0.19.2
22:54:22FromGitter<kaushalmodi> in 0.19.2 (https://nim-lang.org/docs/complex.html#Complex) -> in devel (https://nim-lang.github.io/Nim/complex.html#Complex)
22:55:08FromGitter<timotheecour> @iffy > @timotheecour How do I see that? I'm not very good with nim and looking at what's in memory. How do I print out X bytes of memory? ⏎ ⏎ many ways: hex dump, using gdb/lldb; or simply casting to a string and printing it; ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/nim-lang/Nim?at=5c4b93ccceb5a2264f3f35f5]
22:55:13*smitop quit (Quit: Connection closed for inactivity)
22:56:13FromGitter<timotheecour> @kaushalmodi cool can u send a PR against nim-kissFFT since u already did the work ;-) ?
22:56:36FromGitter<kaushalmodi> @timotheecour I cannot .. the change is applicable only for nim devel atm
22:56:44FromGitter<kaushalmodi> will send a PR though and let it sit there
22:59:06FromGitter<Vindaar> @kaushalmodi I'll see if I still have that code somewhere
23:00:07shashlick@timotheecour ya I can enable older Nim versions of there's interest
23:01:04shashlickIf
23:01:13FromGitter<timotheecour> @kaushalmodi yes u can: see https://github.com/nitely/nim-regex/pull/34/files
23:01:16*Jesin joined #nim
23:02:30FromGitter<kaushalmodi> wow, the nim-kissfft dev already merged my PR's
23:02:46FromGitter<kaushalmodi> even the one that was nim devel specific .. oh well
23:03:18FromGitter<kaushalmodi> @timotheecour good idea, will do that
23:06:28*zachcarter joined #nim
23:07:38FromGitter<timotheecour> @kaushalmodi @Vindaar regarding FFT performance: according to https://kfrlib.com/storage/app/media/fft.png KFR seems top-notch, beating fftw, IPP and kissfft, AND is open source: https://github.com/kfrlib/kfr
23:08:09FromGitter<timotheecour> it has a C API, maybe nimterop could do wonders?
23:08:46FromGitter<kaushalmodi> @timotheecour Thanks, I will try that out later. I was just looking into a way to plot stuff ..
23:09:07FromGitter<kaushalmodi> and then I thought that I should look into plotting ffts as that would be useful at work ..
23:09:15FromGitter<kaushalmodi> and then nim-kissfft ..
23:09:26FromGitter<kaushalmodi> (rabbithole is getting deeper)
23:09:27FromGitter<kaushalmodi> :P
23:09:27FromGitter<timotheecour> yaya makes sense; although i think @mratsim may be interested in high performance FFT for arraymancer (cpu based convnets)
23:10:08FromGitter<timotheecour> ya very familiar w the rabbit :) guilty as charged too
23:10:27FromGitter<kaushalmodi> oh may be shashlick if he's maintaining a list of tests for nimterop :P
23:10:44FromGitter<kaushalmodi> Hint: the kfr project ^
23:13:00*natrys quit (Quit: natrys)
23:14:33shashlickI can take a look but neck deep in nimterop dev and maintenance
23:16:11FromDiscord_<exelotl> uhh does anyone have experience with getting nim to output header files?
23:19:10FromGitter<kaushalmodi> shashlick: certainly! this is a reaaaaly low priority request
23:19:14FromGitter<kaushalmodi> don't burn yourself out
23:21:08FromGitter<Vindaar> @kaushalmodi ehm, as a matter of fact I still have some kissfft code lying around *cough*. Guess 2017 me had some plans with it: https://github.com/Vindaar/TimepixAnalysis/blob/master/Analysis/ingrid/fadc_helpers.nim#L470-L513
23:21:40FromGitter<Vindaar> to be honest, I don't know whether this code really worked or if I modified it somewhere else back then
23:21:58shashlickWhat does toast say for kfr? Are there any issues?
23:22:09shashlickPlugin system is at 70%
23:22:23FromGitter<kaushalmodi> shashlick: honestly, I haven't tried
23:22:57FromGitter<kaushalmodi> Just going through its readme made it feel too out of reach for me
23:23:36FromGitter<kaushalmodi> @Vindaar what I don't understand is that the example has fin and fout
23:24:28FromGitter<kaushalmodi> the kind of FFT I am looking at is where input is a series of samples in *time* domain, the sampling frequency and I get an (x,y) response of frequency/power
23:24:42FromGitter<kaushalmodi> .. in output
23:24:47FromGitter<kaushalmodi> which I can then plot in plotly
23:26:18FromGitter<kaushalmodi> I am looking for an example equivalent to https://www.mathworks.com/help/matlab/ref/fft.html
23:26:56*banc quit (Ping timeout: 240 seconds)
23:35:17*banc joined #nim
23:39:19FromGitter<Vindaar> Yeah, that was what I originally wanted back then too
23:39:51*elrood quit (Remote host closed the connection)
23:40:02*shpx quit (Quit: shpx)
23:40:23FromGitter<Vindaar> I hardly have to do any FFTs, so I'm always a little confused about it
23:43:58*gangstacat joined #nim
23:49:48*a_b_m quit (Quit: Leaving)
23:59:31*darithorn quit (Quit: Leaving)