<< 27-06-2019 >>

00:06:27*cfv[m] quit (*.net *.split)
00:06:29*surma quit (*.net *.split)
00:06:31*nuxdie quit (*.net *.split)
00:06:31*JStoker quit (*.net *.split)
00:06:31*kaliy quit (*.net *.split)
00:06:57*surma joined #nim
00:07:01*nuxdie joined #nim
00:07:04*JStoker joined #nim
00:08:01*cfv[m] joined #nim
00:34:32*stefanos82 quit (Quit: Quitting for now...)
00:51:08*sz0 quit (Ping timeout: 252 seconds)
00:54:40*sz0 joined #nim
01:03:39*PrimHelios joined #nim
01:06:26*Voltist joined #nim
01:13:59*Voltist quit (Quit: Quit)
01:32:27FromGitter<zetashift> IIRC in Python you can append to a list during iteration
01:42:47*dddddd quit (Remote host closed the connection)
01:49:19theelous3you can yeah
01:49:25theelous3ill advised usually :D
01:49:59*lritter quit (Ping timeout: 258 seconds)
01:52:14*lritter joined #nim
02:04:56*lritter quit (Ping timeout: 258 seconds)
02:06:56*theelous3 quit (Ping timeout: 244 seconds)
02:25:40*theelous3 joined #nim
03:08:07FromGitter<kaushalmodi> how can I print the field names and their types in an object?
03:08:27FromGitter<kaushalmodi> I know of `fieldPairs`, but that accepts a variable of an object type
03:09:11FromGitter<kaushalmodi> I am trying this.. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5d143357850b87037c68b054]
03:10:00FromGitter<kaushalmodi> inside that macro, I need to loop through all fields of input typeDesc `typ` and get the field names and types
03:11:28FromGitter<kaushalmodi> this is step 0 of what actually I need to do (I need to take in an object type and create a new object type which would be mostly identical to the input type, but with the types of some fields changed)
03:15:33*Snircle quit (Quit: Textual IRC Client: www.textualapp.com)
03:47:52FromGitter<JasperJenkins> @kaushalmodi As you may have noticed, the type of the typedesc is typedesc[Foo] not Foo. So to get the actual type you call getType again on Foo. `echo treeRepr getType(getType(typ)[1])`.
03:49:18*deech quit (Ping timeout: 252 seconds)
04:06:49*laaron joined #nim
04:35:49*nsf joined #nim
04:45:25*brakmic joined #nim
04:49:00*brakmic quit (Remote host closed the connection)
04:49:21*brakmic joined #nim
05:13:58*narimiran joined #nim
05:22:30*leorize quit (Quit: WeeChat 2.3)
05:52:34*leorize joined #nim
06:03:17*solitudesf joined #nim
06:29:45*hoijui joined #nim
06:47:55FromGitter<rokups> can we do any kind of debugging of karax webapp when it runs in the browser?
06:48:57leorizeI typically `echo` and hope for the best
06:49:08leorizeif you understand js then the generated code is kinda readable
06:49:27leorizeso a js debugger in browser should be able to handle those
06:49:41FromGitter<rokups> this is what i feared
06:49:51FromGitter<rokups> but it must be possible using js maps i think
06:50:14FromGitter<rokups> possible in theory that is
06:50:35leorizejs have a map to source function?
06:50:49leorizethen probably the compiler can be made to generate the needed directives, if it haven't
06:51:34FromGitter<rokups> js debuggers support reading file.js.map or something like that. its like a json (i think) that maps source locations in js to actual source files
06:51:45FromGitter<rokups> so compiler should generate extra file with that info
06:52:08FromGitter<rokups> i know little of it, just saw it when working with typescript in one game engine
06:53:45*dwdv joined #nim
06:57:46Araqthere is a PR to give us source-maps
06:57:59Araqbut getStackTrace() etc works out of the box
06:58:06Araqlike it does for the C backend
06:58:39AraqI had no problems debugging Karax itself
06:58:49FromGitter<rokups> i see just one PR and its adding a new example. https://github.com/pragmagic/karax isnt main repo?
06:59:32*krux02 joined #nim
07:00:00*gmpreussner quit (Quit: kthxbye)
07:01:14leorizethat's the main repo
07:01:56Araqrokups: the sourcemap PR was for Nim's JS codegen
07:02:06FromGitter<rokups> ohh
07:04:40*gmpreussner joined #nim
07:06:16*Voltist joined #nim
07:08:12*gmpreussner quit (Read error: Connection timed out)
07:08:30*gmpreussner joined #nim
07:09:35VoltistIs there a way to define a method that runs on the initialisation of an object in Nim, like the __init__ function in python?
07:10:16leorizenope
07:10:32leorizethe typical notion in Nim is to write a initializer proc
07:10:43VoltistOk
07:10:45leorizesomething like this: `proc initObj(): Obj`
07:10:53VoltistThat makes sense, it is own way
07:11:29FromGitter<rokups> one of my biggest issues with nim. someone will eventually write `proc initFoo(): Bar`. intializers should really be tied to a type somehow
07:11:29leorizethere were requests for constructors in the past, but IIRC Araq dislikes them
07:12:20VoltistFair enough
07:12:41leorize@rokups: so far no one messed up, so we're good :)
07:13:45FromGitter<rokups> come on.. we are humans. if we do not restrain ourselves we will let all hell loose
07:13:54FromGitter<rokups> besides it would be cleaner as well
07:15:21Araqproc initFoo(): Bar is a feature. It's the factory pattern.
07:15:45FromGitter<rokups> someone will surely forget themselves and do `proc initFoo(): ref Bar` as well
07:16:02FromGitter<rokups> didnt even stdlib even have this discrepancy between new/init and ref/value types?
07:16:45Araqit still does, it's a feature
07:17:21FromGitter<rokups> like all those windows bugs that by now cant be fixed because that would break stuff? :p
07:30:21*Trustable joined #nim
07:31:21VoltistCould anyone please recommend a desktop IRC client?
07:31:30VoltistThe web can be a drag
07:31:41*brakmic_ joined #nim
07:31:43leorizeHexChat seems to be popular around here
07:32:16VoltistI'll give it a go
07:32:16*brakmic quit (Read error: Connection reset by peer)
07:32:22*Voltist left #nim (#nim)
07:32:40*brakmic joined #nim
07:35:54*Voltist joined #nim
07:36:12VoltistHooray, it works!
07:36:16*brakmic_ quit (Ping timeout: 252 seconds)
07:40:31*hoijui quit (Quit: Leaving)
07:42:18*Voltist quit (Remote host closed the connection)
07:46:31Araqno like: "the distinction between value and ref semantics is important and will remain important"
07:49:20*steshaw quit (Quit: Connection closed for inactivity)
07:49:53FromGitter<rokups> noone is suggesting to erase this distinction though
07:50:15FromGitter<rokups> but it would be way clearer if we knew that `new` produces ref and `init` produces a value
07:50:39FromGitter<rokups> even better - if compiler somehow enforced this distinction so we cant do weird and confusing things
07:54:04*PrimHelios quit (Ping timeout: 264 seconds)
07:56:29*floppydh joined #nim
07:56:43*PrimHelios joined #nim
08:16:05leorizeAraq: how can there still be stacktrace with --stacktrace:off?
08:17:20*couven92 joined #nim
08:17:24FromGitter<mratsim> I think there was a PR to add minimal stacktraces even in release mode
08:18:00leorizemaybe that should be moved to --stacktrace:minimal?
08:18:27Araqmeh
08:18:57Araqlet's please not add even more stacktrace related switches, it's already pretty bad
08:20:20leorizeit's weird when you have --stacktrace:off and still have stacktrace...
08:22:10Araqsounds like a real bug
08:24:25leorizethe --stacktrace switch only have on and off
08:25:02leorizeso when you implement a minimal stacktrace for release mode, your only option is to implement it when the switch is off
08:25:10leorizehttps://github.com/nim-lang/Nim/pull/9480
08:25:42FromGitter<mratsim> we can have on/off/minimal
08:25:52*theelous3 quit (Ping timeout: 245 seconds)
08:26:55*abm joined #nim
08:32:36FromGitter<rokups> is `--nimcache` supposed to work for js?
08:32:46leorizeit should?
08:32:57FromGitter<rokups> hmm does not appear to
08:33:19leorizewell, to be more precise, does the compiler even produce any cache files while compiling to js?
08:33:40leorizeeverything is in a project.js file already
08:33:43FromGitter<rokups> yes, next to source file
08:33:58leorizejust use -o: if you want it to produce files elsewhere
08:34:59FromGitter<rokups> ok that works, thanks
08:42:08*tjmac joined #nim
08:44:27FromGitter<mratsim> don't we have the builddir flag now?
08:44:38leorize--outdir iirc
09:02:26*leorize quit (Quit: WeeChat 2.3)
09:58:05*cyraxjoe quit (Read error: Connection reset by peer)
09:59:14*cyraxjoe joined #nim
10:05:45FromGitter<rokups> writing html in nim is awesome experience. suddenly webdev is cool again
10:20:31*theelous3 joined #nim
10:21:58FromGitter<mohamedmoussa89> trying to understand generics better, could someone have a look at this and let me know the precise reason why it doesnt compile, and if there is a better way? ⏎ https://nim.ide.judge0.com/?ANrC-J5yh1SmNPec9_jHKKYkNoey
10:22:27FromGitter<mohamedmoussa89> I have a workaround where I use t: T (in the argument list) and manually do a static assert in the body to check the type T really is A.T
10:33:36leorize[m]the better way is ```proc `+`[N, T](a: Vec[N, T], b: T): string```
10:35:58*stefanos82 joined #nim
10:39:53*lf-araujo joined #nim
10:40:39FromGitter<mohamedmoussa89> What if (for example) you wanted the procedure to work with Matrix[R,C,T] and Vector[N,T]?
10:42:50narimiranyou would have `+`[R, C, N], and just use floats? :P
10:46:38FromGitter<mohamedmoussa89> I mean something like `proc +A: VM (a: A, t: A.T): A` where `VM = Vector | Matrix`
10:47:25*lf-araujo quit (Ping timeout: 258 seconds)
10:48:10FromGitter<mohamedmoussa89> that will work, until I switch `a` and `t`
10:48:26leorize[m]I doubt `+` can be handled in the same way for that case...
10:48:47leorize[m]didn't know you could access the generic parameters
10:49:02leorize[m]try switching to template
10:49:10FromGitter<mohamedmoussa89> hmm
10:53:09narimiranbrowse `neo` repo, maybe you'll find some inspiration. e.g. https://github.com/unicredit/neo/blob/master/neo/statics.nim
10:53:40FromGitter<mohamedmoussa89> good idea
10:53:49*lritter joined #nim
10:57:14leorize[m]there's also @mratsim's arraymancer, which has more active development
10:57:35*dddddd joined #nim
10:57:39*deech joined #nim
11:00:25*gangstacat quit (Ping timeout: 268 seconds)
11:00:34FromGitter<mohamedmoussa89> I had a look, but it looks like the size is not part of the tensor type
11:00:52FromGitter<mohamedmoussa89> anyway, its not too important, just something i got side tracked on
11:01:51*gangstacat joined #nim
11:05:05*laaron quit (Remote host closed the connection)
11:06:36*laaron joined #nim
11:12:57FromGitter<kaushalmodi> @JasperJenkins Thanks! So I should use `treeRepr()` instead of `repr()` :), and what you suggested helps
11:13:40FromGitter<kaushalmodi> now I get ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ as output of that treeRepr [https://gitter.im/nim-lang/Nim?at=5d14a4e46e07c20470704aee]
11:14:17FromGitter<kaushalmodi> but it doesn't list of the types of those fields
11:14:29leorize[m]getImpl them
11:14:38leorize[m]or getType
11:15:28FromGitter<kaushalmodi> hmm .. let me try..
11:17:27FromGitter<mratsim> probably getTypeInst if you want to know the instantiated type of a generic type
11:18:29FromGitter<kaushalmodi> ended up with this: http://ix.io/1MUp
11:18:52FromGitter<kaushalmodi> does that look right? If I visit that nested index reference in a week, I'll get scared of the code :P
11:18:53FromGitter<mratsim> @mohamedmoussa89 you can use Neo's StaticMatrix if you want the size to be part of the tensor type: https://github.com/unicredit/neo/blob/master/neo/statics.nim#L17-L19
11:19:34leorize[m]@kaushalmodi try getTypeImpl instead of getType
11:20:01FromGitter<mratsim> It used to be the main way in @andreaferretti previous library: https://github.com/unicredit/linear-algebra/blob/master/linalg/private/types.nim#L15-L35 but we both felt too restricted.
11:20:14*nsf quit (Quit: WeeChat 2.4)
11:21:27FromGitter<kaushalmodi> leorize: ooh! That is nice
11:21:29FromGitter<kaushalmodi> thanks
11:22:35FromGitter<mohamedmoussa89> @mratsim thanks for that
11:22:35FromGitter<mratsim> This is basically why I started Arraymancer: https://github.com/mratsim/nim-rmad/issues/4#issuecomment-294281199, I needed vectors, matrices and tensors to have the same type
11:23:53FromGitter<kaushalmodi> leorize: just for reference, here's what I have now: http://ix.io/1MUr
11:24:49FromGitter<kaushalmodi> need to sign off, but now I need step is to look through the getTypeImpl interrogate the types of fields
11:24:50leorize[m]looks nice. Probably there should be a getTypeImpl for typedesc in stdlib :p
11:24:50FromGitter<kaushalmodi> thanks again
11:25:13leorize[m]PMunch: have you fixed the playground?
11:28:03*xet7 quit (Remote host closed the connection)
11:30:14*xet7 joined #nim
11:30:15*Trustable quit (Remote host closed the connection)
11:31:18*Vladar joined #nim
11:31:23FromGitter<mohamedmoussa89> how do I raise a static error i.e. at compile time?
11:32:03*lf-araujo joined #nim
11:32:32FromGitter<rokups> `macros.error("foo")`
11:33:34FromGitter<mohamedmoussa89> cheers
11:38:15leorize[m]or `{.error: "foo".}`
11:38:27leorize[m]^ use that if not writing macros
11:42:34FromGitter<mohamedmoussa89> ah, i was using `static: eror("foo")`
11:47:28*lf-araujo quit (Remote host closed the connection)
11:47:43*lf-araujo joined #nim
11:52:13*deech quit (Ping timeout: 268 seconds)
11:59:52FromGitter<mohamedmoussa89> time for bed. thank you for your help today
12:04:36*deech joined #nim
12:07:41FromGitter<alehander42> @rokups Araq i wondered if it makes sense to finish the early version of sourcemaps PR
12:08:08FromGitter<rokups> why would it not make sense? its only a good thing
12:08:12FromGitter<alehander42> i just dont have so much time to finish the ast->ast rewrite (maybe 40-50% of ready)
12:08:44FromGitter<alehander42> @rokups first i did a simpler post-pass
12:09:26FromGitter<alehander42> which made a sourcemap from the raw output of jsgen
12:09:26FromGitter<rokups> i have no clue how sourcemaps work. do they embed ast of actual source file or what?
12:09:26FromGitter<alehander42> which kinda worked
12:09:36FromGitter<alehander42> but it is a good idea to have a more structured approach
12:10:14FromGitter<alehander42> so i started a new rewrite of the jsgen to js-like AST and then a renderer for it, but it's not finished(it's kinda half-finished and a bit coderot maybe)
12:11:10FromGitter<alehander42> but maybe its ok to just keep the postprocessing pass : its simple, it should work and it usually doesnt give a serious perf problem(after all we just compile to javascript in debug mode)
12:11:22FromGitter<alehander42> so we can have sourcemaps now
12:11:50FromGitter<alehander42> and eventually remove it when a ast->ast rewrite is actually ready
12:12:15FromGitter<alehander42> they contain a mapping of source locations iirc
12:12:41FromGitter<alehander42> (the sourcemaps) @rokups which is kinda base64-ed , i mostly ported an existing implementation
12:12:51FromGitter<alehander42> iirc
12:13:54FromGitter<rokups> all you talked about i totally dont understand ^_^ i would have expected something like .js line -> .nim line mapping. no clue what ast has to do with this
12:14:01FromGitter<rokups> sounds complicated
12:14:25*Snircle joined #nim
12:20:16*clyybber joined #nim
12:20:24*ng0 joined #nim
12:22:08clyybberHi Araq, I'm trying to fix all the remaining issues for =move, and tbintree2 is failing with a sigsev in nimRawDispose
12:22:27clyybberdoes it have to do something with the {.nodestroy.} pragma? What does it do?
12:30:18Araqclyybber: .nodestroy prevents destruction/=/=move injections
12:30:53*envoyt joined #nim
12:31:34Araqas for the crash, use -d:useMalloc and run it under valgrind
12:31:48Araqit detects the bug when it happens
12:31:54Araqnot when it materializes
12:36:12*brakmic quit (Ping timeout: 252 seconds)
12:38:16*brakmic joined #nim
12:39:40*envoyt quit (Read error: Connection reset by peer)
12:41:24*envoyt joined #nim
12:57:35FromGitter<juancarlospaco> Hi
13:00:16FromGitter<mratsim> btw @juancarlospaco I said it on reddit (though not with a mratsim username) but cool work and explanations on your tensor article, really appreciated
13:02:35*envoyt quit (Read error: Connection reset by peer)
13:03:55*envoyt joined #nim
13:04:43FromGitter<juancarlospaco> Hi, honestly 1st time with playing with Tensors, glad I didnt make a disaster then. :) But other explanations seems over-complicated.
13:06:21FromGitter<mratsim> The only scary thing of tensors is the name :p
13:07:09FromGitter<juancarlospaco> I mean other explanations on other programming languages. :P
13:07:49FromGitter<mratsim> Oh? what explanations did you find?
13:13:23FromGitter<juancarlospaco> I was expecting an error when installed, because I didnt config anything, I just blindly installed with nimble and it works on cpu backend on first try.
13:16:55lf-araujoHi all, is it possible to build a project with nimble and run the resulting binary in one command?
13:17:36lqdev[m]You can define a task for that
13:17:42clyybberI just use "nimble build && ./thebinary"
13:18:35solitudesfnimble build -r
13:18:48FromGitter<juancarlospaco> https://nim-lang.org/docs/nims.html > "NimScript as a build tool" @lf-araujo
13:19:08lf-araujothanks!
13:22:09*envoyt quit (Ping timeout: 248 seconds)
13:24:49*deech quit (Ping timeout: 248 seconds)
13:27:31*PMunch_ joined #nim
13:27:49lf-araujoAll nim and nimble command line interface is well designed and clear, which module devs uses for pretty printing on the terminal?
13:30:16Araqcustom code on top of terminal.nim
13:30:23FromGitter<juancarlospaco> terminal, json.pretty
13:35:13FromGitter<juancarlospaco> I think marshal can represent stuff as json, then json.pretty for pretty-print it, then terminal for hipster colors.
13:37:48*lf-araujo_ joined #nim
13:38:40*lf-araujo_ quit (Remote host closed the connection)
13:41:21leorize[m]the failing tests here seems to be irrelevant :/ https://github.com/nim-lang/Nim/pull/11605
13:42:03*lf-araujo quit (Ping timeout: 264 seconds)
13:45:21Araqhttps://www.codingnow.com/2000/download/pentopt.htm#1 ah the memories, optimizing for the old Pentiums. U and V pipelines, shifts that cannot be paired, compilers that produce bad code and cannot keep up with CPU improvements. Those were the days
13:48:00*lf-araujo joined #nim
13:52:47*deech joined #nim
13:59:23*ng0 quit (Quit: Alexa, when is the end of world?)
14:01:37FromGitter<mratsim> of the infamous Pentium 4 IDIV bug
14:01:40FromGitter<mratsim> or*
14:10:56PMunch_!eval import osproc; echo execProcess("""echo "Hello world from user \"$(whoami)\""""")
14:11:01NimBotHello world from user "nobody"↵
14:11:27PMunch_Playground is back up!
14:11:40PMunch_And the docker container now executes code as user "nobody"
14:11:44Araqyay
14:11:45PMunch_Instead of root
14:11:55Araqaww
14:12:23PMunch_aww? Did you have nefarious plans for the playground Araq?
14:12:57Araqeverything and everybody should be root
14:13:21PMunch_Tell that to the security flaw list of docker :P
14:14:37FromGitter<rokups> is there some tutorial on `async`?
14:14:51Araqcapabilities should be attached to processes/applications, not to users
14:15:08*laaron quit (Remote host closed the connection)
14:15:16lf-araujoWhere is the standard place for config/nim.cfg, when choosenim is used for installation?
14:15:32Araqdunno, /etc ?
14:15:35*laaron joined #nim
14:15:53FromGitter<rokups> PMunch_ using docker as a security measure for playground? well good luck with that :trollface:
14:16:24*jchev joined #nim
14:17:13FromGitter<kaushalmodi> lf-araujo: $XDG_CONFIG_HOME
14:17:22lf-araujothank you
14:17:24FromGitter<kaushalmodi> on most linux based OSes, that defaults to $HOME/.config
14:17:33FromGitter<kaushalmodi> nim respects XDG_CONFIG_HOME
14:17:46PMunch_rokups, it's fairly common with playgrounds
14:18:19FromGitter<rokups> PMunch_ its a terrible idea. it is very unsafe
14:18:33PMunch_Well it's more safe than just running it as a user
14:19:06FromGitter<rokups> tiny bit. but for the best effect you should use actual VM and burn it quite often
14:19:37PMunch_The docker container has no network, limited memory, limited CPU, and a limited runtime. And a new one is spun up for every snippet of code
14:19:53PMunch_And now it's not even allowed root access within the container
14:21:42*Vladar quit (Remote host closed the connection)
14:21:44FromGitter<rokups> but that doesnt do much. kernel vulnerabilities that elevate access arent that uncommon. new one will be found soon enough and it will be usable on playground because you didnt update in time. then its a matter of breaking out of container which depends on many factors, but its a thing
14:22:27FromGitter<rokups> there were docker vulnerabilities allowing breakout, but it could be possible if you misconfigure docker in some way
14:23:44PMunch_Yes, but that's still a lot of ifs and buts. Besides, the entire playground is running on a virtual machine, so worst case scenario an attacker takes down that or turns it into a spam-machine, in which case it can simply be nuked.
14:24:05FromGitter<kaushalmodi> PMunch: feature request for playground.. can we have separate buttons for compilation out and run time out?
14:24:30PMunch_kaushalmodi, what do you mean? You can already switch between the two
14:24:42FromGitter<rokups> ah nice, i wasnt aware that docker containers run inside a VM :]
14:25:51PMunch_Well it's the same VM as the webserver, but yes they do run under a VM
14:26:24FromGitter<kaushalmodi> PMunch: just separate buttons instead of a toggle button
14:26:41FromGitter<kaushalmodi> I didn't know that "Showing: output" was a button :/
14:26:52PMunch_Why? What would the "Switch to output" button do when you're already on output?
14:27:07clyybberAraq: setting up SELinux is kind of complicated, so I can't blame anyone for *not* using it..
14:27:08PMunch_Oh yeah, I've been thinking of ways to make that more obvious..
14:29:25FromGitter<kaushalmodi> PMunch: e.g. go to https://play.nim-lang.org/#ix=1MUr and hit Run
14:29:29Araqhuh? why highlight me?
14:29:39FromGitter<kaushalmodi> when I did that, I was like.. "hmm, nothing happened?"
14:30:19PMunch_kaushalmodi, ah, that's a bug. It's supposed to switch over to debug if there is no input
14:30:22PMunch_output*
14:30:25FromGitter<kaushalmodi> PMunch: may be have separate buttons for compilation log and simulation log?
14:30:36FromGitter<kaushalmodi> compilation log button becaomes red if compilation fails?
14:30:52FromGitter<kaushalmodi> if it becomes red, focus auto switches to that log
14:31:05FromGitter<kaushalmodi> if it becomes green, focus switches to runlog
14:31:14FromGitter<kaushalmodi> if run log is empty, focus remains on compilation log
14:31:20clyybberAraq: You were saying that capabilites should be attached to processes, and thats what SELinux is accomplishing
14:31:22FromGitter<kaushalmodi> (too much to ask? sorry)
14:31:35Araqah ok
14:31:45Araqto be honest, I wasn't aware
14:31:56FromGitter<kaushalmodi> PMunch: I know that I am just making feature requests.. I don't know the underlying complexity
14:32:57PMunch_Hmm, I'd have to implement some changes to the output of curl -X POST https://play.nim-lang.org/compile -d '{"compilationTarget": "c", "code": "echo \"hello world\""}' for that to work
14:33:34PMunch_The output of that command is what I have to work with currently
14:33:44PMunch_As you can see it's only compilationLog and log
14:33:53FromGitter<kaushalmodi> woh! I can curl code to the playground.. that's neat
14:34:06PMunch_I would need status codes of the compiler and the program as well to implement those features. Completely doable though
14:34:26PMunch_kaushalmodi, yes it's just a REST API in the background :)
14:34:28FromGitter<kaushalmodi> PMunch: I see "log" as one of the returned fields
14:34:41FromGitter<kaushalmodi> should you have "compile_log" and "run_log"?
14:34:47PMunch_Yes, "log" is the log from running the program
14:34:58PMunch_Yeah, the names there are a bit confusing..
14:35:12PMunch_This was "borrowed" from the old playground
14:35:18FromGitter<kaushalmodi> got it
14:35:30FromGitter<kaushalmodi> ok, I see there's "compileLog" already
14:35:38FromGitter<kaushalmodi> so we need "log" -> "runLog"
14:35:44AraqPMunch_, narimiran can we add the new playground to important_packages please?
14:35:54*deech quit (Ping timeout: 272 seconds)
14:36:47FromGitter<kaushalmodi> PMunch_: there could be a quick small CLI to run code on playground
14:37:14FromGitter<kaushalmodi> call it "nimplay" and "nimplay foo.nim" :)
14:37:28FromGitter<kaushalmodi> I am adding that to my list of pet projects
14:37:49*lf-araujo_ joined #nim
14:38:57PMunch_Definitely could, but why not just install Nim then? :P
14:39:37FromGitter<kaushalmodi> to tease people into installing nim
14:39:59FromGitter<kaushalmodi> "hey, try out this small statically compiled binary to remotely run and execute the nim code"
14:40:10solitudesfhow is that better than just using playground?
14:40:16FromGitter<kaushalmodi> i know i know ..
14:40:19FromGitter<kaushalmodi> still :)
14:40:36PMunch_I agree it would be cool, but it's completely pointless :P
14:41:20*smitop joined #nim
14:41:39FromGitter<kaushalmodi> yeah, one of those projects
14:41:45jchevhi all, is this a place to get a little nim guidance?
14:41:47*lf-araujo quit (Ping timeout: 244 seconds)
14:41:48*lf-araujo_ is now known as lf-araujo
14:42:00lqdev[m]sure
14:42:00PMunch_jchev, yup :)
14:42:08FromGitter<kaushalmodi> jchev: the quantity of guidance can be limited by you
14:43:41jchevi've been exploring nim the past few weeks and been enjoying it. i've been working through some project euler questions and using nim in a fairly functional manner
14:43:53jchev(loads of iterators)
14:44:12jchevi am currently on problem 12 on project euler, https://projecteuler.net/problem=12
14:44:37jchevhere is the code i thought would work for it, but i am getting a compile error https://gist.github.com/jchevertonwynne/51fe02ca70e660699fb1b91639a49d46
14:45:16FromGitter<mratsim> This is my code for problem 12: https://github.com/mratsim/nim-project-euler/blob/master/src/pe012_highly_divisible_triangular_number.nim for reference
14:46:09jchevi found yours online already :)
14:46:48*lf-araujo quit (Ping timeout: 250 seconds)
14:47:15*NimBot joined #nim
14:47:24jchevi'm not quite understanding why it's complaining about types here, at least from what i can tell it *should* work
14:48:50FromGitter<mratsim> I think your firstValid[T] has T being seq int
14:49:47FromGitter<mratsim> makeDivisor creates a seq
14:50:15FromGitter<mratsim> and mapIterators will create an iterator of seq
14:50:26jchevso we begin with a iter[int], we turn that into an iter[seq[int]]
14:50:57FromGitter<mratsim> and then you take the first valid seq[int] of your iter[seq[int]]
14:51:24jchevoh wait
14:51:29jchevrubber duck
14:51:42jchevwhat a silly error
14:52:09jchevi forgot to get the last divisor from the firstValid result
14:52:19PMunch_Thanks jchev, found another bug in the playground :)
14:52:45PMunch_Apparently <seq[int]> was misunderstood as a HTML tag in the output -_-
14:53:28FromGitter<mratsim> Nice!
14:54:39AraqPMunch_, if that's a karax issue/flaw/gotcha please report it
14:55:09*lf-araujo joined #nim
14:55:50FromGitter<rokups> is it possible to call async proc from karax's `createDom()`?
14:55:54*nsf joined #nim
14:56:01PMunch_Araq, it's not really. I add things with verbatim, because I add HTML tags to colour the output like the output you get in your terminal
14:56:20PMunch_(I do a search and replace on some keywoards, it's not very robust..)
14:56:27leorize[m]clyybber: linux have a separated capabilities system independent from SELinux, and programs can actually drop their own capabilities with it
14:57:20PMunch_But I should HTML-escape the output before I do this
14:58:09Araqrokups: sure
14:58:21PMunch_Hmm, this also means you can HTML style output. Try for example 'echo "<strong>hello world</strong>"' in the playground, it will be bold..
14:58:30leorize[m]PMunch_: can't you emit <span> for highlighting then normal text after?
14:58:54PMunch_leorize[m], what do you mean?
15:01:20jchevthanks for talking me through my error, is so hard to realise when you've been looking at it for over an hour :)
15:01:24FromGitter<mratsim> Seems like the playground is vulnerable to "echo injection" attacks then :P
15:01:37jchevand i'm glad to be of service with helping finding that bug :)
15:01:42FromGitter<mratsim> @jchev, you're welcome
15:06:46*lf-araujo quit (Ping timeout: 276 seconds)
15:06:56leorize[m]PMunch_: http://ix.io/1MVk/nim
15:07:50*leorize joined #nim
15:10:09PMunch_Well yes, but that's not really how it's done here: https://github.com/PMunch/nim-playground-frontend/blob/master/frontend.nim#L123-L128 and then that gets inserted into the page here: https://github.com/PMunch/nim-playground-frontend/blob/master/frontend.nim#L239
15:10:55PMunch_The problem is that before the replacing this should've been HTML escaped
15:11:07leorize[m]you should probably change your outputText array into a VNode array so you can build them up line-by-line
15:11:56leorize[m]and the outputText array type looks odd
15:12:38PMunch_Yeah it could've been simplified as array[OutputKind, string]
15:13:16PMunch_Hmm wait, how does that even work? It's using Output and not OutputKind..
15:15:06*Tyresc joined #nim
15:15:08leorizePMunch_: you could have built the output up via a VNode :p
15:15:21PMunch_But why?
15:15:55leorizebecause escaping requires iteration and idk how fast it is in JS
15:16:05leorize'sides using a VNode is much cooler :p
15:16:14leorizeoh wait building VNode needs iterating as well, nvm
15:18:43leorizemaybe I'll try to play with the playground frontend
15:19:01PMunch_Yeah, to build it up as VNode I would have to first split the string into lines. Then iterate over the lines, then search for occurrences of stuff to replace, then replace them and build a VNode tree. Seems like a lot more work than just doing search and replace
15:19:06PMunch_leorize, oh please do :)
15:20:05leorizetbh it's just 3 loops
15:20:23leorizecertainly faster than the 5 loops of replace I'm seeing here :)
15:21:16PMunch_Yeah, not really sure why I'm not using multiReplace there..
15:21:58PMunch_Then it would be a single loop
15:25:00*abm quit (Read error: Connection reset by peer)
15:29:29*deech joined #nim
15:32:13AraqmultiReplace ftw
15:43:06*tjmac quit (Quit: -bye)
15:43:47*laaron quit (Quit: ZNC 1.7.1 - https://znc.in)
15:45:40*laaron joined #nim
15:54:10*gangstacat quit (Quit: Ĝis!)
15:57:00FromGitter<AmberSaber> leorize?
15:57:13leorizeAmberSaber: yes?
15:57:49FromGitter<AmberSaber> I don't know the word
15:58:23leorizeit's meaningless :p
15:59:07FromGitter<AmberSaber> well
16:01:24*jokul quit (Ping timeout: 272 seconds)
16:02:00FromGitter<AmberSaber> Time is too late, goodbye
16:06:47PMunch_Hmm, this is strange. I'm trying to set up the playground locally so I can develop on it, but I can't get the permissions right..
16:09:00FromGitter<alehander42> PMunch_, you can lex the tokens
16:09:07PMunch_Huh?
16:09:13FromGitter<alehander42> the source*
16:09:20FromGitter<alehander42> and generate highlight spans for each token
16:09:32FromGitter<alehander42> if i am understanding the problem correctly
16:11:03PMunch_Oh, you're talking about the highlighting stuff :P
16:11:09PMunch_Yes, that would be possible
16:11:50*enthus1ast86 joined #nim
16:12:08*enthus1ast86 is now known as enthus1ast_w
16:12:36enthus1ast_wis there any (complete) code example of the hotCodeReload feature?
16:12:41shashlick_@narimiran - nimterop is still not in important packages right?
16:13:16narimiranshashlick_: i think there was some problem with it on windows (that's what appveyor runs on) so it is not included
16:13:46solitudesfenthus1ast_w, https://github.com/zah/nim-hcr-astronauts/
16:16:47enthus1ast_wthank you solitudesf but it seems that i 1. lacks the params nim needs 2. sdl does not build :)
16:17:01enthus1ast_w(on windows)
16:17:11*jchev quit (Quit: WeeChat 2.5)
16:18:04solitudesffor me the app was crashing after 1-3 reloads. not this example tho.
16:18:14enthus1ast_wi guess if have to build the main with --hotCodeReloading:on ?
16:18:50enthus1ast_wbut what must i do with the module (space.nim in this case) build it with --app:lib ?
16:19:14solitudesfno, you build entire app with this flag
16:19:21solitudesfand rebuild it after modifications
16:19:34enthus1ast_wwhile its running?
16:19:39solitudesfyes
16:19:51solitudesfthat would be the point?
16:20:04FromGitter<alehander42> @rokups sorry i just was lazy and didnt finish the more complicated sourcemap-related code :(
16:20:47FromGitter<alehander42> it does map javascript locations to the original nim locations indeed, and i had a simpler patch that also did it
16:20:51FromGitter<alehander42> thats what i meant
16:21:40enthus1ast_wah nice, thank you solitudesf for clearing this up
16:21:57leorizeI thought the app rebuilds itself?
16:22:18enthus1ast_whow could you know leorize its not documented ;)
16:22:23leorizehttps://nim-lang.github.io/Nim/hcr
16:22:45leorizeit is kinda documented, just not in stable
16:22:58enthus1ast_wok it is documented...
16:23:36FromGitter<alehander42> there are even some talks e.g. https://slides.com/onqtam/nim_hot_code_reloading
16:24:12enthus1ast_whttps://nim-lang.github.io/Nim/hcr did not show up in my google foo
16:26:27FromGitter<alehander42> but not sure if up to daate
16:26:37leorizeAraq wrote it recently
16:29:32FromGitter<alehander42> oooh right
16:29:35FromGitter<alehander42> but the slides not sure
16:29:48FromGitter<alehander42> the docs are good indeed!
16:30:22leorizenow we just need someone to step up and write a proper repl for nim :)
16:32:43enthus1ast_wand a crossplatform "inotifywait"
16:42:47PMunch_leorize, what's wrong with "nim secret"
16:43:37leorizeimport times
16:44:26PMunch_Aah, you want one that runs on the C backend
16:44:40leorizenim secret becomes nim secret for a reason :p
16:45:02PMunch_I remember there was one that used TinyCC to compile faster
16:45:18PMunch_But it suffered from some issues with "poisoning"
16:45:47*nsf quit (Quit: WeeChat 2.4)
16:45:48PMunch_If you wrote something that had an error in it, that could get stuck in the temporary file it was actually compiling, which would make it always fail after that..
16:46:09leorizewell, the beauty of a repl comes from it's ability to preserve state
16:47:04leorizeyou wouldn't want to have your connection redone n times because of the n lines you typed after
16:47:29PMunch_Yeah, that also wouldn't work :P
16:47:38enthus1ast_wthe good think with nim is that you usually know what kind of data/object you operate on. So coming from python a few years ago, i had to learn that you do not really need repl for programming :)
16:47:58PMunch_Yeah that's true
16:48:30PMunch_But I still find myself sometimes running something in nim secret or a small file, just to test some slicing behaviour or something like that
16:48:34leorizeyea, but a repl is nice for prototyping
16:49:09leorizeback when I was writing pascal I have a folder called "behavior test" just to test small code snippets
16:49:31enthus1ast_wmine is called nimPlayground and is cluttered with hunderes of files :D
16:50:49shashlick_what's wrong with this: `proc freeShared(ss: var sharedString|sharedSeq) =`
16:51:03shashlick_it shows ss.ssptr cannot be assigned to
16:51:50leorizea full code snippet would be appreciated
16:52:33shashlick_had to do this: `proc freeShared(ss: var (sharedString|sharedSeq)) =`
16:53:02*CcxWrk joined #nim
16:53:06leorizeI think the `|` has lower precedence than `var`
16:53:46shashlick_| doesn't work for `=destroy()` though
16:53:59shashlick_```proc `=destroy`*(ss: var (sharedString|sharedSeq)) =```
16:54:04leorizeyea, `=destroy` must be concrete from what I've seen
16:56:37*jokul joined #nim
16:58:49PMunch_Hmm, with asyncfile how do you know when you reach the end with readLine?
16:59:58PMunch_Basically I want to read the entire file into a sequence of strings
17:02:55*enthus1ast_w quit (Ping timeout: 260 seconds)
17:03:37leorizeit'll return an empty string at EOF
17:03:54PMunch_And what if I have a file with empty lines?
17:04:00PMunch_Does it include the \n?
17:04:37leorizefrom the code, no
17:05:17leorizeyou can try to check for EOF by reading 1 byte from the stream
17:05:22PMunch_Hmm..
17:05:30leorizeif an empty string is returned then it's EOF
17:06:24leorizealthough an isEof api might be needed
17:06:53leorizeor something along the lines of `readLine(f: AsyncFile, s: var string): Future[bool]` like the one for File
17:07:30PMunch_Aha, `while file.getFilePos < file.getFileSize` seems to work fine
17:08:26leorizeseeing how that's done, I don't recommend doing so
17:08:50leorizeon *nix this will seek to the end, then get the position as the size, then return to the current position
17:09:51PMunch_Ooof
17:10:09PMunch_So at least store the position and not do it every iteration..
17:11:14*lf-araujo joined #nim
17:12:24leorizelet's hope TOCTOU won't hit you :p
17:12:52lqdev[m]suggestion for the do notation: infer the types, so you don't have to specify them every time. like, `x do (a, b, c):` instead of `x do (a: float, b: int, c: bool)`
17:13:27PMunch_Shouldn't be an issue, I'm reading the log files from the docker container, and the container is already dead
17:13:57leorizelqdev[m]: sugar.`=>`
17:14:40*laaron quit (Quit: ZNC 1.7.1 - https://znc.in)
17:15:04*laaron joined #nim
17:15:55leorizePMunch_: just check it once you hit it
17:16:13PMunch_Huh?
17:16:34leorizewhile true: if readLine(f) == "" and read(f, 1) == "": break
17:16:42lqdev[m]leorize: what if I want multiple statements?
17:17:29*lf-araujo quit (Ping timeout: 250 seconds)
17:17:45*smitop quit (Quit: Connection closed for inactivity)
17:18:02leorize`=>`(x, y): # body here
17:18:37*lqdev[m] sent a long message: < https://matrix.org/_matrix/media/v1/download/matrix.org/KHJcairJZfqyHaQjcsyIGtkQ >
17:19:30leorizeinferring is never easy :p
17:20:25lqdev[m]I think I'm going to stick with `do` for the time being
17:21:25PMunch_kaushalmodi, I think this output will make things easier when implementing a playground: http://ix.io/1MVY
17:22:19leorizeoutput the raw thing, with ANSI escape code :)
17:22:26leorizethen do the coloring as post-processing
17:22:32leorizein the frontend
17:22:43PMunch_Yeah I'm considering adding that as on option in the request
17:23:08PMunch_So you could do something like: {"compilationTarget":"c", "code":"echo \"hello world\"", "colours": "ansi"}
17:23:26PMunch_With colours being ansi, none, or html for example
17:23:55leorizeyea, you could do post processing on the server instead of the client
17:28:22FromGitter<alehander42> afaik it wouldnt be too hard to write a hcr-based basic repl
17:28:45FromGitter<alehander42> i think @onqtam already had an example with how the arch would look
17:29:01PMunch_Anyone feeling up for creating a Nim ANSI->HTML converter like this https://github.com/uu59/ansi-to-html?
17:29:03FromGitter<alehander42> the problems are adding support for nim rtl to most of stdlib / libs afaik
17:29:17FromGitter<alehander42> btw PMunch i think i did something like that
17:29:30FromGitter<alehander42> for showing terminal output in electron
17:29:36FromGitter<alehander42> but i think i stopped using it
17:29:45FromGitter<alehander42> othe roption is
17:29:52FromGitter<alehander42> using a js lib: i used one as well
17:30:30leorizeansi codes are simple :)
17:30:51PMunch_So you want to write the library then? :P
17:31:00leorizenope :p
17:31:05PMunch_Aaaw
17:31:40PMunch_I was hoping to offload that to someone else, so I could add more interesting features to the playground
17:32:13leorizeoffload it to some external js library then :)
17:35:18FromGitter<alehander42> PMunch it was something like https://gist.github.com/alehander42/7b9d40e89f94979a3226364940f86155
17:35:40FromGitter<alehander42> cut off from my codebase with some non-important code removed to demonstrate the logic
17:35:47FromGitter<alehander42> but that's probably too convoluted
17:36:03FromGitter<alehander42> it was written just to get it working somehow
17:36:16*narimiran quit (Ping timeout: 246 seconds)
17:36:28*narimiran joined #nim
17:36:33FromGitter<alehander42> a library i used was https://github.com/drudru/ansi_up
17:36:44FromGitter<alehander42> (in another case )
17:36:55PMunch_leorize, well that won't work if I want to do this on the back-end
17:37:30leorizeyou can write one with karax
17:37:38leorizeit would work on backend and frontend :)
17:37:45FromGitter<alehander42> my code used karax as well
17:38:04FromGitter<alehander42> but i guess a cleaned up version would be best
17:47:26PMunch_Hmm, echoing out a table looks kinda weird..
17:49:39*krux02 quit (Remote host closed the connection)
18:34:22*jjido joined #nim
18:45:16*PMunch quit (Disconnected by services)
18:45:21*PMunch_ is now known as PMunch
18:45:45*PMunch_ joined #nim
18:47:08FromGitter<kaushalmodi> PMunch_: The new json fields look great!
18:47:22FromGitter<kaushalmodi> *I need to install `jq`.. have heard good things about it*
18:47:36FromGitter<kaushalmodi> btw is runCode and compileCode quite obvious?
18:47:46FromGitter<kaushalmodi> or should they be runExitCode and compileExitCode
18:50:41PMunchHmm, that could be a good idea
18:52:43PMunchAnd yeah, jq is nice if you work a lot with JSON
18:52:55PMunchOr if you just work a bit with JSON :P
19:04:20*elrood joined #nim
19:07:20*natrys joined #nim
19:20:20*theelous3_ joined #nim
19:25:07*sentreen quit (Quit: sentreen)
19:26:36*theelous3_ quit (Ping timeout: 272 seconds)
19:27:32FromDiscord_<djazz> I'm using nim to modify the texture atlases in the game Celeste, so it runs on the Raspberry Pi! come have a look! https://www.twitch.tv/daniel_hede/
19:31:23*sentreen joined #nim
19:32:22*Araq joined
19:32:27Araqcome on, join the party
19:32:29FromGitter<kaushalmodi> How do you generate Linux compatible .so on Windows?
19:32:55FromGitter<kaushalmodi> what cross compiler do people use?
19:33:08Araqmingw. I think
19:34:14*lf-araujo joined #nim
19:35:53PMunchCan cofirm, mingw works to create dlls for Windows
19:36:08FromGitter<kaushalmodi> I need to create .so
19:36:23FromGitter<kaushalmodi> i.e. generate the linux compatible .so on windows machine
19:37:01FromGitter<juancarlospaco> is there a way to force a template to be run on the body of a proc/func only?.
19:37:19leorize[m]@kaushalmodi you'd need a cross compiler
19:37:44leorize[m]@juancarlospaco: no
19:37:53Araqjuancarlospaco: proc foobar() {.macroHere.} notation
19:38:01FromGitter<kaushalmodi> *I am googling* .. is MSYS2 a cross compiler?
19:38:07Araqin the macro you can enforce the nnkProcDef kind
19:38:42leorize[m]@kaushalmodi no :p it's a posix env on windows
19:38:53FromGitter<juancarlospaco> Thanks.
19:39:11FromGitter<kaushalmodi> leorize: ok .. :)
19:39:24leorize[m]well creating a linux cross compiler shouldn't be hard
19:39:37leorize[m]but I'm not sure if anyone attempted that on windows
19:39:45FromGitter<kaushalmodi> I have started googling about this stuff just 1/2 hr back
19:40:02leorize[m]check if msys2 have linux cross compiler
19:40:42leorize[m]if they don't, use WSL instead of wasting time trying to create a cross compiler.
19:41:31FromGitter<kaushalmodi> ok, let me check with the team that needs this
19:41:32*lf-araujo quit (Ping timeout: 252 seconds)
19:41:36PMunchkaushalmodi, oh the other way round :P
19:41:47shashlick_i've not found a win => lin cross compiler
19:42:04shashlick_didn't search too hard but ya
19:44:11PMunchApparently this should work: http://metamod-p.sourceforge.net/cross-compiling.on.windows.for.linux.html
19:44:26*nsf joined #nim
19:44:26FromDiscord_<treeform> kaushalmodi, I found it easier to have a linux build server for 5$ on digital ocean.
19:44:55FromGitter<kaushalmodi> PMunch: thanks, I also landed up on that while searching.. will ask the Windows team to try that out
19:45:04FromGitter<kaushalmodi> *all of this is linked to my work on Nim*
19:45:47FromGitter<kaushalmodi> C++ source code is developed in Windows.. Windows team compiles Windows .exe (and are now looking to compile .so for Linux side team).. and I dynlink to that .so via Nim
19:46:05FromGitter<kaushalmodi> treeform: all this devel is inhouse.. nothing goes to clouds
19:48:46PMunchdjazz, are you swedish?
19:48:49*lf-araujo joined #nim
19:49:19leorize[m]crosstools-ng can generate linux cross compiler on windows
19:50:01leorize[m]clang can target linux from windows if you have all the headers and libs built
19:50:06*floppydh quit (Quit: WeeChat 2.5)
19:56:51FromGitter<kaushalmodi> thanks all, the Windows team is trying out the cygwin route
19:59:39*lf-araujo quit (Remote host closed the connection)
20:02:23*hzot joined #nim
20:02:59*hzot quit (Remote host closed the connection)
20:07:22PMunchHmm, doesn't ANSI escape codes have a proper ending?
20:07:23FromDiscord_<djazz> PMunch, yes
20:08:00PMunchCool, I'm from Norway myself. Could tell from your accent :P
20:11:28FromGitter<kaushalmodi> PMunch: the ANSI escapes do have endings
20:12:12FromGitter<kaushalmodi> the `\033[0m` mark ends
20:12:25PMunchAh yes, that marks the end of styling
20:13:28PMunchThe escape sequence starts with ESC and a character in the range 0x40–0x5F
20:13:40PMunch(Normally for styling this would be ESC[)
20:13:49PMunchOr \033[ if you like
20:13:55PMunchBut where does it stop?
20:14:57PMunchI can't just parse until I find an `m` because what happens if you run the escape sequence \033[5A which is supposed to move the character 5 lines up?
20:15:46FromGitter<kaushalmodi> hmm, I have used ansi escapes only for styling
20:16:28PMunchYeah, but a library would have to at least not lock up if you pass it something else
20:16:41PMunch(especially since this will be handling user-generated output)
20:16:56*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
20:17:05FromGitter<kaushalmodi> I am reading (quickly) the wiki page on this..
20:17:15FromGitter<kaushalmodi> looks like ESC[0m is the ending
20:17:30FromGitter<kaushalmodi> I cannot tell is that is style specific or not
20:18:17PMunchESC[0m is reset all styling
20:18:28PMunchI'm talking about how I stop parsing a single code
20:19:07PMunchCurrently I check if a character is ESC, then if the next is [. But I need to stop at some point
20:19:18PMunchI guess I could just be really picky with what I parse
20:19:27FromGitter<kaushalmodi> I see ..
20:19:28PMunchSo I parse only up to 3 numeric characters
20:19:55PMunchAnd only ; separated
20:20:07PMunchEnding with `m`
20:21:35FromGitter<kaushalmodi> PMunch: here's a (non)answer: https://stackoverflow.com/a/36561805/1219634
20:26:28FromGitter<kaushalmodi> looks like you "just" have a case statement of all ansi escapes that can be expected: http://ascii-table.com/ansi-escape-sequences-vt-100.php
20:26:30*jjido joined #nim
20:27:08PMunchUgh
20:27:13PMunchI'll just do it my way
20:30:31*nsf quit (Quit: WeeChat 2.4)
20:32:27PMunchHmm, what does `reset` actually do?
20:33:45PMunchBy the way, for the twitch stream (can't be arsed to log in), he could use a converter to avoid the uint32 casts
20:33:59FromGitter<kaushalmodi> I'd guess.. reset the terminal fonts, cursor position, colors, etc
20:34:12PMunchkaushalmodi, I meant in Nim :P
20:34:24FromGitter<kaushalmodi> I have used `reset` command in terminal few times when for some reason, it would start printing out text in gibberish
20:34:35PMunchResets an object obj to its initial (binary zero) value.
20:34:57*NimBot joined #nim
20:35:00FromGitter<kaushalmodi> oh OK :)
20:35:22PMunchI kinda like the semantics of "reset myVar" when I'm doing loops (instead of assigning them to 0, "", or something like that)
20:35:44PMunchAlthough it does do a bit more work than necessary..
20:35:56PMunchFor string for example setLen 0 would be faster than reset
20:36:12FromGitter<kaushalmodi> TIL about `reset`: https://nim-lang.github.io/Nim/system.html#reset%2CT
20:36:33FromGitter<kaushalmodi> hmm, it's *magic*
20:36:55PMunchYeah I learnt about it from the whole variant objects can't be changed thing :P
20:37:13*pvn joined #nim
20:37:33PMunchWouldn't really call it magic, it probably just calls memset(ptr, 0, sizeof(theType)) or something like that
20:37:59FromGitter<kaushalmodi> as in, I cannot see its implementation
20:38:14FromGitter<kaushalmodi> I don't know where to look if it is implemented using the `magic` pragma
20:39:00PMunchOh right, for that you need to go into the compiler and dig around
20:39:10PMunchThere is a nice case statement with all the magics in them IIRC
20:41:01*brakmic_ joined #nim
20:41:53*brakmic quit (Read error: Connection reset by peer)
20:41:55*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
20:42:45Araqit's like asking where C's '+' is "implemented"
20:43:07Araqthe question is completely misguided.
20:45:33clyybberkind of related, I think the failing test cases with the =move thing are due to missing to reset temporaries in loops.
20:49:52Araqhuh? but after the =move they should have been reseted.
20:50:18Araqbecause that's what =move does. =move is a complete operation, =sink is half
20:55:36*sagax quit (Ping timeout: 252 seconds)
20:59:16clyybberyeah, ikr. The temporary doesn't even get moved anywhere in the generated code tho
20:59:37*deech_ joined #nim
21:01:12clyybberThat temporary is generated due to "a.add(a)" in a loop.
21:01:32*deech quit (Ping timeout: 244 seconds)
21:02:20clyybbernvrmind, I must have fucked somewhere
21:02:32clyybber*fucked up
21:06:07*natrys quit (Quit: natrys)
21:08:16FromGitter<arnetheduck> on this topic, `add` was changed to `addInt` to avoid overloads for string+int.. turns out `addInt` already exists as well and thus there are now other overloads..
21:10:03PMunchHmm, can I make a set that contains all the values in an enum?
21:10:28AraqaddInt is only a compilerproc, not exported
21:10:29PMunchBasically I have two enums, and I want to say something like "if myval in {EnumOne, EnumTwo}"
21:10:53Araq{low(E)..high(E)}
21:11:47PMunchYeah, but that creates a set[E], so I can't join it to a second non-overlapping enum
21:12:16FromGitter<arnetheduck> yeah, but in `nlvm` I have to override it (like a magic, but detected by function signature) and I was expecting it would have a return type
21:13:08FromGitter<arnetheduck> so I hit a funny bug when the other overload was added
21:13:56PMunchHmm, I don't think enum is the right tool for what I'm trying to do :P
21:14:05Araqyup.
21:14:30PMunchA table mapping from int to string seems a bit heavy though..
21:14:49Araqarnetheduck: .compilerprocs without a 'nim' prefix are bad but it's hard to change because of bootstrapping reasons
21:15:36FromGitter<arnetheduck> well there's a bunch of them I have to overload.. what I don't quite understand is why compilerproc is needed to begin with.. ie why can't the compiler look in the full symbol table?
21:16:33FromGitter<arnetheduck> I wouldn't be surprised if there were compilerproc's around that aren't used any more as well
21:17:00PMunchUgh, I need to get some air
21:17:06*PMunch quit (Remote host closed the connection)
21:17:12FromGitter<arnetheduck> overload, as in override.. non-compiler-proc stuff.. atomics, bit set ops, memcpy etc.. anything that llvm has a builtin for basically
21:17:16*dwdv quit (Quit: quit)
21:17:36Araqwell the codegen shouldn't access the symbol table
21:17:53FromGitter<arnetheduck> has to, in `nlvm`'s case :)
21:17:59Araqand secondly it supresses "unused symbol X" warnings
21:18:18Araqit's a reasonably clean design IMO.
21:21:29*brakmic_ quit ()
21:21:56FromGitter<arnetheduck> I guess the issue I see is that compilerproc means "maybe used by the compiler", and then in nlvm, I need to detect other non-compiler-proc things anyway so there's not too much value for that particular backend.. mainly because I don't want to maintain the patchset on top of the std lib as of yet (that might change if it gets too hacky..)..
21:22:32*sagax joined #nim
21:23:08*solitudesf quit (Ping timeout: 272 seconds)
21:24:45AraqI am not following.
21:24:56Araqwhich compilerproc-like procs do you use in nlvm?
21:26:22*narimiran quit (Remote host closed the connection)
21:27:44clyybberAraq: It's because the copy-to-sink rule generates a temporary and previously we would generate a wasMoved here: https://github.com/nim-lang/Nim/blob/devel/compiler/injectdestructors.nim#L440
21:27:54clyybberSo I need a replacement for that wasMoved
21:28:03clyybberA magic for resetLoc essentially
21:30:34FromGitter<arnetheduck> actually I confused things, it's the other direction.. there are things that I would want to be magic that are not: https://github.com/arnetheduck/nlvm/blob/master/nlvm/llgen.nim#L2555
21:31:20FromGitter<arnetheduck> compilerprocs, I call them but nice and regular through `getCompilerProc`: https://github.com/arnetheduck/nlvm/blob/master/nlvm/llgen.nim#L2279
21:33:24Araqarnetheduck: ah, so we shouldn't call .compilerprocs from system.nim
21:33:36Araqthen you wouldn't have to patch addInt the way you do
21:34:35Araqclyybber: huh? pass copy to sink, but also call the destructor for the copy
21:34:38FromGitter<arnetheduck> no, I have to patch addint regardless.. it behaves like a magic
21:35:05Araqno.
21:35:46Araqyou could savely ignore it if only the codegen would use it. your codegen would map '+' to something else.
21:36:24FromGitter<arnetheduck> oh, but that's where the overflow check is implemented, and I want to override that to use the carry bit stuff that llvm exposes
21:37:39clyybberAraq: Right, gotta get sleep haha
21:37:53clyybberThank you for always being helpful :)
21:38:17FromGitter<arnetheduck> there's a bunch more of them here as well: https://github.com/arnetheduck/nlvm/blob/master/nlvm/llgen.nim#L2752
21:38:19*theelous3 quit (Read error: Connection reset by peer)
21:38:26FromGitter<arnetheduck> though there, instead of overriding the implementation, I replace the function call so that an inlined llvm instruction is used instead and the "original" implementation in the std lib is never touched thus never generated
21:42:13*pvn quit (Quit: Leaving.)
21:54:21clyybbergn8
21:54:22*clyybber quit (Quit: WeeChat 2.5)
22:14:47*Snircle quit (Read error: Connection reset by peer)
22:15:40*Snircle joined #nim
22:17:42FromGitter<Varriount> Araq: Will the new runtime change behavior with regards to non-var argument aliasing (for example, with ref objects)?
22:18:56Araqgood question. the aliasing changes for the seq/string implementation in rare cases because it's a (len, ptr) pair now and the len is copied around, previously it was part of the seq
22:20:05FromGitter<Varriount> Hm. I don't like corner cases. :/
22:25:47*lritter quit (Quit: Leaving)
22:26:53*jjido joined #nim
22:30:05Araqwell, don't alias then :-)
22:30:46*jjido quit (Client Quit)
22:31:29FromDiscord_<djazz> YAS, i got the texture thing working!
22:31:35FromDiscord_<djazz> 😃
22:43:42FromGitter<mratsim> FYI, I'm creating a new Hot Code Reloading label on the tracker, I expect we will have more and more related issues
23:01:02FromDiscord_<djazz> Next step is the .meta file format...
23:05:34Araqbah, add labels when we need them, not because you anticipate problems
23:08:22FromDiscord_<djazz> Gnight, thanks for watching the stream ^^
23:08:39FromGitter<mratsim> well I needed it
23:12:03FromGitter<kayabaNerve> Is shifting an array or adding to a seq and then deleting [0] faster?
23:12:41FromGitter<kayabaNerve> Example size of 5; a linked list would be perfect tbh. Just not bothering right now.
23:14:31FromGitter<mratsim> del is faster
23:14:37FromGitter<mratsim> delete is slow
23:15:56FromGitter<mratsim> delete(a, n) needs to copy all items between n+1..<a.len to n..<a.len-1
23:16:28FromGitter<mratsim> del just move the last item to the deleted item place and then reduce the collection size
23:16:42FromGitter<mratsim> but it doesn't preserve order
23:55:05*elrood quit (Remote host closed the connection)