<< 18-03-2019 >>

00:00:07*ftsf joined #nim
00:07:55*endragor joined #nim
00:19:52*endragor quit (Remote host closed the connection)
00:55:03*chimez joined #nim
00:58:28*sealmove joined #nim
01:17:08*MightyJoe quit (Ping timeout: 245 seconds)
01:17:21*cyraxjoe joined #nim
01:18:37*Snircle joined #nim
01:21:14*rnrwashere quit (Remote host closed the connection)
01:22:07*sealmove quit (Quit: WeeChat 2.4)
01:28:25*rnrwashere joined #nim
01:29:13*cyraxjoe quit (Remote host closed the connection)
01:37:11*lritter quit (Ping timeout: 268 seconds)
01:51:50*chimez quit (Quit: chimez)
02:00:29*rnrwashere quit (Read error: Connection reset by peer)
02:01:04*rockcavera quit (Ping timeout: 255 seconds)
02:13:39*theelous3_ joined #nim
02:35:24*dddddd quit (Remote host closed the connection)
02:37:07*theelous3_ quit (Ping timeout: 245 seconds)
02:39:38*vlad1777d quit (Ping timeout: 245 seconds)
02:40:21*rockcavera joined #nim
02:53:29*rnrwashere joined #nim
03:02:34*Snircle quit (Quit: Textual IRC Client: www.textualapp.com)
03:05:54*banc quit (Quit: Bye)
03:26:29*banc joined #nim
04:16:35*noeontheend joined #nim
04:21:17*chemist69 quit (Ping timeout: 250 seconds)
04:21:47*nsf joined #nim
04:23:33*chemist69 joined #nim
05:57:37*narimiran joined #nim
06:11:47*ryukoposting quit (Quit: WeeChat 1.6)
06:12:33*rnrwashere quit (Remote host closed the connection)
06:26:00*rnrwashere joined #nim
06:57:06*solitudesf joined #nim
07:00:00*gmpreussner quit (Quit: kthxbye)
07:00:20*rnrwashere quit (Remote host closed the connection)
07:04:15*PMunch joined #nim
07:05:03*gmpreussner joined #nim
07:08:40*ftsf quit (Ping timeout: 246 seconds)
07:21:58*vlad1777d joined #nim
07:23:11*krux02 joined #nim
07:42:59*jjido joined #nim
07:45:26*Vladar joined #nim
07:59:56*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
09:13:41*JustASlacker joined #nim
09:41:25*ephja joined #nim
09:49:38*ephja quit (Quit: Page closed)
10:07:34*solitudesf quit (Quit: Leaving)
10:10:27*solitudesf joined #nim
10:12:17*ng0 joined #nim
10:29:50*leorize quit (Quit: WeeChat 2.4)
10:33:02*abm joined #nim
10:49:26*neceve joined #nim
10:59:26ZevvI must say I havent had this much fun coding for years - Nim hooray!
10:59:44FromGitter<alehander42> parser generators are pretty fun
10:59:45FromGitter<alehander42> indeed
10:59:49FromGitter<alehander42> how far are you
11:00:01FromGitter<alehander42> i've wanted to write one for a long time but i didnt get to the dsl yet
11:02:08ZevvPEG compilation and parsing is complete and robust. I'm now working on getting stuff out of the parser in a friendly way. I use JsonNodes to collect stuff and return it to the caller, that works pretty well.
11:02:26ZevvPerformance is amazing, I didn't expect to get this far without spending any effort on optimization.
11:03:20Zevvbut the most importan is that it is *really* enjoyable to do this in Nim.
11:03:31ZevvI need to do C++ at daytime, which is getting more cumbersome each day.
11:18:50*stefanos82 joined #nim
11:34:30*solitudesf quit (Quit: Leaving)
11:34:45*solitudesf joined #nim
11:45:48*solitudesf quit (Quit: Leaving)
11:45:56*a_ joined #nim
11:46:06*solitudesf joined #nim
11:51:38*dddddd joined #nim
11:51:46*a_ quit (Quit: Page closed)
12:04:46*Snircle joined #nim
12:11:18FromGitter<alehander42> is it modern c++
12:11:59FromGitter<alehander42> @cooldome hey are you working on renderer as a part of any of your projects?
12:12:25FromGitter<alehander42> i might need to fix some things, but i wanted to see if they are in your issue list or something
12:41:19*solitudesf quit (Quit: Leaving)
12:42:25*solitudesf- joined #nim
12:44:55FromGitter<zacharycarter> Has anyone had a chance to play with hot code reloading for the C backend yet?
12:45:23FromGitter<zacharycarter> I'm going to try to pick back up my game engine project I stalled out on this week
12:52:47*solitudesf- quit (Quit: Leaving)
12:53:15*solitudesf joined #nim
12:59:47*solitudesf- joined #nim
13:00:35*solitudesf quit (Remote host closed the connection)
13:00:51*solitudesf joined #nim
13:01:04*solitudesf quit (Remote host closed the connection)
13:01:06*zahary joined #nim
13:01:06*solitudesf- quit (Client Quit)
13:01:30*solitudesf joined #nim
13:04:37*solitudesf- joined #nim
13:04:45*solitudesf quit (Remote host closed the connection)
13:04:46*solitudesf- quit (Client Quit)
13:05:01*solitudesf joined #nim
13:27:02*leorize joined #nim
13:30:29avanderneutIs there some way to use choosenim with local clone of my nim-lang/Nim fork? I cloned to ~/.choosenim/toolchains (next to to the nim-#devel clone choosenim creates) and then did `choosenim update "nim-#mydevelop". But that crashes.
13:34:28FromGitter<SolitudeSF> you can just `choosenim path/to/your/nim`, but i dont think that you can use `choosenim update` with that
13:39:06*neceve quit (Ping timeout: 258 seconds)
13:47:56*vlad1777d quit (Ping timeout: 268 seconds)
13:52:01avanderneutBut then I probably need to compile that by hand first, other wise it complains about nim not found. Going to try...
14:00:38Araqzacharycarter: try it, I broke its tests and then fixed them
14:00:47Araqso ... it should work, it's tested :P
14:04:13shashlickavanderneut - maintain your clone per usual with koch
14:04:49shashlickChoosenim will simply allow you to switch between devel and stable
14:06:39avanderneutshashlick: Yes I noticed and putting things under ~/.choosenim/toolchains/nim-#mydevelop doesn't really help it doesn't get recognised when you do choosenim "nim-#mydevelop", I have to specify the path ..
14:07:45shashlickYa we could extend choosenim to manage an existing repo, interesting idea
14:10:18FromGitter<zacharycarter> Araq: sounds good, will do.
14:14:18*cgfuh joined #nim
14:16:18*tefter quit (Ping timeout: 245 seconds)
14:25:49*aguspiza joined #nim
14:30:51*bmaxa joined #nim
14:30:53*theelous3_ joined #nim
14:31:22*bmaxa quit (Client Quit)
14:42:43shashlickI'm getting a nilaccesserror on alloc, any ideas
14:51:16Araqshashlick, go up in the stack trace
14:52:32shashlickwell, it randomly occurs so i have some memory corruption somewhere
14:52:50shashlicklikely suspect is where i'm casting and playing with pointers
14:52:56shashlickbut the fact that it is random isn't helping
15:04:20FromGitter<liquid600pgm> compiling Nim on a raspberry pi is slow -_-
15:04:33FromGitter<liquid600pgm> I can't blame it on the language tho
15:04:44*clyybber joined #nim
15:05:06Zevvi
15:05:09FromGitter<liquid600pgm> the slow performance is due to the slow CPU and storage of a Raspberry Pi
15:05:21FromGitter<liquid600pgm> so I'll just have to be patient
15:05:27narimiranliquid600pgm: is it some toy hello-world or are you doing something more serious/interesting?
15:05:29Zevvcompiling c is just slow on the pi
15:05:55Zevvavoid "nim cpp" if you can
15:06:30*lritter joined #nim
15:06:34FromGitter<liquid600pgm> narimiran: I was going to play around with the Linux framebuffer, mainly because I have an NVIDIA card on my main PC and it only allows for 640x480 ttys
15:06:51shashlick`len(a) == L` seq modified while iterating over it [AssertionError] <= how do I find out which seq? stack doesn't tell me
15:07:09FromGitter<liquid600pgm> I couldn't find a way to change that, unfortunately, and the Pi displays the tty in full 1080p properly
15:07:35FromGitter<mratsim> I don't think nim cpp is slower than nim c
15:07:46FromGitter<mratsim> Nim C++ doesn't produce the slow headers
15:08:23FromGitter<liquid600pgm> oh wait it's already finished
15:08:31FromGitter<liquid600pgm> that was fast for a Pi
15:08:48FromGitter<liquid600pgm> it took maybe a minute or two
15:25:46*Trustable joined #nim
15:32:20*PMunch quit (Remote host closed the connection)
15:34:49*JustASlacker quit (Remote host closed the connection)
15:34:59*neceve joined #nim
15:37:20FromGitter<liquid600pgm> how do you `importc` a constant?
15:39:47leorizevar CONSTNAME {.importc.}: type
15:40:32leorizeor tbh just add it as a `const` to whatever use it
15:43:09shashlick#define or const char * type
15:45:15Araqthe var .importc hack doesn't work with NLVM and in general doesn't play well
15:46:48*rnrwashere joined #nim
15:51:44shashlickAraq: will emit work to pull in dmalloc?
15:54:20*natrys joined #nim
15:54:35Araqwho knows
15:57:54shashlicknarimiran - nightlies are failing on Windows devel 32/64
15:58:11shashlickhtmlparser_snippet_101.nim(1, 13) Error: expected a hex digit, but found: s; maybe prepend with 0
15:59:05*nsf quit (Quit: WeeChat 2.4)
15:59:45narimiranshashlick: when did that start failing?
16:00:05narimiranthe last change in htmlparser.nim was 2 weeks ago
16:00:53shashlickyep since then looks like
16:08:46*sealmove joined #nim
16:09:38*abm quit (Ping timeout: 245 seconds)
16:13:41*rnrwashere quit (Remote host closed the connection)
16:15:55*rnrwashere joined #nim
16:21:39Araqsorry about it, tried to reproduce but couldn't
16:27:29Araqcan't we just revert this commit to fix nightlies?
16:31:13sealmoveSorry for bringing this up again (not looking for long discussion), but how do you really go about modeling something similar to an interface in Nim, that is, types depending on behavior?
16:35:12FromGitter<Varriount> sealmove: Do you need compile-time polymorphism, or runtime?
16:37:59FromGitter<Varriount> If you need runtime polymorphism, using either methods, or structures containing procedural types is what you want
16:38:30FromGitter<Varriount> Otherwise, you can use generics and concepts for compile-time interfaces
16:39:28*elrood joined #nim
16:41:07sealmoveI understand Nim methods. What I can't seem to figure out is how to associate procs with types in Nim. Concepts seems to be the answer but I don't really understand them..
16:42:42FromGitter<Varriount> sealmove: By "associate", do you mean storing procedures in types
16:44:00sealmoveSorry no, I mean having a type that can hold values of different types, but requires these types to "implement" some specific proc
16:46:57*rnrwashere quit (Remote host closed the connection)
16:49:23sealmoveRephrasing: make a constrained generic type, with the constrain being a specific proc (or more). Can't figure out the syntax..
16:51:35clyybberYeah concepts are the answer
16:51:37FromGitter<Varriount> sealmove: I assume you've tried the first example from the manual? https://nim-lang.org/docs/manual.html#generics-concepts
16:52:14sealmoveyes, I am reading the manual and feel dumb :( this is the second time I revisit this topic too.
16:53:09clyybberYou just write:
16:53:12clyybbertype
16:53:48clyybber ImplementingSomeProc = concept s
16:53:58clyybber s.someproc()
16:54:42clyybberwhere someproc is the proc that the type has to implement
16:55:21FromGitter<Varriount> And if you then want a type to contain That concept as a member, you do
16:55:49FromGitter<Varriount> type ContainingConcept = object
16:56:19FromGitter<Varriount> fieldName: ImplementingSomeProc
16:57:40FromGitter<mratsim> concepts are pretty new anyway
16:58:07FromGitter<mratsim> they are coming in C++20 and I don't think any language has concepts.
16:58:53sealmoveyeah but the lack of "classical" interfaces and classes make them more important
16:59:54FromGitter<mratsim> yes, that has been pending for 1.5 years unfortunately :/
17:00:06FromGitter<mratsim> Nim does have classes though.
17:00:37FromGitter<mratsim> what has been pending is heterogenous collections of types implementing the same concept.
17:00:39sealmovenot with the "common" sense I think
17:00:55FromGitter<Varriount> But no multiple inheritance
17:01:15FromGitter<mratsim> what is multiple inheritance?
17:01:28FromGitter<mratsim> inherits from 2 different classes?
17:01:32FromGitter<Varriount> Yes
17:01:43sealmoveIn the example... is `ImplementingSomeProc` a type that I can assign values to?
17:02:03FromGitter<mratsim> No, it's not a concrete type
17:02:27FromGitter<Varriount> It can be a parameter type or a field type
17:02:31FromGitter<mratsim> proc defined on a specific concept will work on all types that implements the concept API
17:04:28FromGitter<Varriount> sealmove: perhaps you can post a link to what you have so far? That might be more enlightening.
17:06:23sealmoveokay. though I suspect Nim doesn't work like I had in mind. I'm too used to Go's structural typing :/
17:06:55Araqnot really, it's just that you think you want concepts when you truely wanted interfaces
17:07:13Araqand in Nim the replacement is a proc with a closure
17:07:22Araqor a tuple of procs with closures
17:07:50Araqit's not hard to do in Nim but most people have surprising struggles with the idea
17:12:33*Jesin quit (Quit: Leaving)
17:17:57FromGitter<mratsim> Well, to be fair it's very hard to change ingrained behavior. Studies have showned that if a cat was always exposed to the same vertical striped wall, they cannot adapt to horizontal stripes after a couple of years: https://www.psychologytoday.com/us/blog/brain-food/201404/the-cat-nobel-prize-part-ii
17:19:16FromGitter<mratsim> and I think interfaces would be quite useful (even if it's just macros, pragmas or concept maggic behind)
17:20:33sealmoveI don't care for interfaces as long as I can model similarly with what Nim provides, just struggling to figure it out.
17:20:47sealmovemaybe just better tutorials
17:21:07FromGitter<mratsim> sounds good cc @narimiran
17:21:14FromGitter<mratsim> "tutorial needed" :p
17:22:59FromGitter<samdmarshall> @dom96 hey are you around?
17:26:17sealmove@Araq: Can you give a tiny bit more info on this idea of modeling interfaces?
17:26:41sealmove"tuple of procs with closures" not enough to figure it out
17:27:31*Jesin joined #nim
17:28:41clyybberbbl cya
17:28:44*clyybber quit (Quit: WeeChat 2.4)
17:31:23Araqsealmove, https://github.com/nim-lang/Nim/blob/devel/tests/closure/tclosure.nim#L573
17:31:30*rnrwashere joined #nim
17:31:37Araq(unfortunately the relevant test was merged into a bigger one)
17:32:03Araqnote that this seems more cumbersome than it usually is in practice, ymmv
17:33:38*stefanos82 quit (Remote host closed the connection)
17:34:33FromGitter<liquid600pgm> is it possible to modify a pointer like an array? `point[2] = 3`
17:35:34*stefanos82 joined #nim
17:36:35*abm joined #nim
17:38:05shashlickcast it to an array of something
17:38:55shashlickcheckout UncheckedArray as well
17:42:56shashlickright now, my alloc crash is always string related
17:43:19sealmove@Araq: wow! okay this is totally unconvential but solves my problem
17:43:42shashlickeither in strip() which calls substr() which creates a newString or in split() which also does string allocs
17:44:01shashlickalloc.nim - rawAlloc
17:44:17shashlickreturns a NilAccessError with segfaults
17:44:20Araqshashlick, try valgrind on it
17:44:28Araqor clang's sanitizers
17:44:31shashlickstuck on Windows
17:44:47shashlickwith mingw
17:46:21shashlicki've commented out all my pointer shenanigans, save for windows SendMessage
17:47:22*neceve quit (Remote host closed the connection)
17:54:41FromGitter<liquid600pgm> shashlick: I can't cast it to an array, as I don't know its size at compile time
17:54:55FromGitter<liquid600pgm> what's an UncheckedArray?
17:58:12shashlickUncheckedArray* {.unchecked.}[T] = array[0, T]
17:59:22*theelous3_ quit (Ping timeout: 250 seconds)
17:59:56shashlickhere's an example - https://github.com/genotrance/nim7z/blob/master/nim7z.nim#L6
18:01:26Araqliquid600pgm: cast[ptr UncheckedArray[ElemTypeHere]]
18:01:49Araqkeep in mind that arrays are not pointers, not even "unchecked" arrays are pointers, in Nim pointers are pointers
18:02:06*pacujo joined #nim
18:02:48shashlickAraq - there's no reference to malloc/free in any of the generated C code - how do you do memory allocs?
18:03:21FromGitter<mratsim> mmap
18:04:24Araqshashlick, proc `=destroy`(svnz: var SvnzFileObj) = ... your destructor is so dangerous that's likely wrong
18:04:49Araqit doesn't protect against double destroys, there are no =sink and = operators either
18:05:52shashlickI'm not surprised, that whole file was leftfield for me
18:06:00shashlickany recommendation on how to do that right?
18:06:51Araqfor now your best option is 'proc close' as this feature is still in heavy development and we only figured out missing parts of the spec last week or so
18:07:33shashlickmakes sense - will fix that
18:09:11pacujoHello. I ran into nim accidentally some days back and got excited. You may be onto something big here. I definitely want to find out.
18:11:25*Snircle quit (Quit: Textual IRC Client: www.textualapp.com)
18:11:49pacujoFirst, it seems like nim modules are released in source code format. There's no analogue for C's .o or .a files, is there?
18:12:05shashlickwelcome pacujo
18:12:26shashlicknim => .c/.cpp => .o
18:13:21pacujoYes, but if I build a nim module package and want to hand it to you, would the package contain .nim files or some "bytecode" equivalent?
18:13:46pacujoI don't suppose the .o files contain the full module ABI spec, do they?
18:13:48shashlickjust nim files - they will get compiled on the target machine
18:14:26pacujoOk, just like I thought. It's good news and bad news.
18:14:51shashlickbad in what way
18:15:45*noeontheend quit (Ping timeout: 252 seconds)
18:16:25pacujoBad news: (1) difficulty making proprietary software and (2) having to compile everything Gentoo-style. (1) is the lesser issue for me right now, but (2) could become a problem if you had to build huge applications ultimately from the sources.
18:17:05shashlickyou can always distribute .o files and pull them in with passL
18:17:14pacujoGood news: Modules don't have to worry about ABI compatibility in the face of implementation changes.
18:17:55shashlickbut you are talking about making a library/module so you can always just build a dll/so file
18:18:40pacujoAre you saying the .o/.so/.a file contains everything the application needs to build? Methods, templates, types etc?
18:20:34shashlickit will be the compiled executable
18:20:42shashlickyou can distribute a header file and your binary
18:20:48shashlickstandard C/C++ stuff
18:21:05rayman22201The Nim ABI == the C ABI
18:21:27Araqproprietary software on Linux? is that what you do?
18:21:51pacujoYes, that's my profession.
18:21:57Araqbecause it surely is uncommon I regard Linux as source-only OS.
18:22:38Araqand that's when I'm having a good day and regard it as an OS at all.
18:23:20Araqanyhow, I heard good things about linking Nim code with 'musl'
18:23:36pacujoSo I got these two .nim files: an app ("project") and a module. I know how to compile it. My .cache/nim directory contains some generated files.
18:23:44Araqto provide binaries that are dependency free
18:24:19pacujoIf I deleted the module .nim file, what command would I use to build my app?
18:24:52Araqnim jsonbuild $nimcache/$project.json iirc
18:25:13pacujoLet's try it...
18:25:21Araqbut don't quote me on that :P
18:25:52shashlicki think it is worth asking what exactly you want to do here - who is writing the app/project and who is doing the module - which is closed source and which is open
18:26:34pacujoThe module is "closed".
18:27:19pacujo(I'm simplifying the picture here a bit to keep my questions focused.)
18:28:14Araqwell Nim doesn't do much, you can build a lib*.so file and distribute it. And it works quite like C, which is not very well at all.
18:28:38shashlickjust build your module as a library using --app:lib and publish a header
18:28:55shashlickthen any C/C++/Nim/XYZ language can use your module assuming they have a FFI
18:29:26shashlickclosed source == compiled so that's your option
18:30:09sealmoveAfter studying the tinterf example, I realized this is a way to make "classic" classes in Nim ;O
18:30:42Araqsealmove, hardly, there is no nominal typing involved
18:31:45*banc quit (Ping timeout: 246 seconds)
18:32:44Araqit's very much like Go's interfaces with a very different memory layout (the closure is duplicated)
18:34:13pacujoMy direct attack failed. First I had "test.nim" as my app and "nimlib/xyz.nim" as my module. Everything worked. Then, I compiled xyz.nim with "nim c --app:lib xyz.nim" and deleted xyz.nim. I got libxyz.so but now compiling "test.nim" failed with "test.nim(1, 8) Error: cannot open file: xyz"
18:34:58shashlickyes - you need to change all that out
18:35:14shashlickyou need to first off export the procs that the app should use using exportc and dynlib
18:35:33shashlicknext, you write a nim wrapper to import those procs
18:37:02shashlickso you will have a small xyz.nim which just has the proc prototypes so to speak
18:37:07shashlicksimilar to an h file
18:37:29shashlickyou will use the importc pragma for that
18:37:39pacujoHm, interesting.
18:37:53shashlickand you will need to either link that so file using passC or load it using loadLib
18:38:15Araqno, you import it via .dynlib
18:39:23shashlickoh ya good point
18:40:01pacujoThat'll require some experimentation, but I'm seeing a writing on the wall: just keep it in .nim.
18:40:09shashlickhere's an sqlite wrapper which is a good example - https://github.com/nim-lang/Nim/blob/master/lib/wrappers/sqlite3.nim
18:40:50shashlickoh it is quite common - you can pull all sorts of C/C++ code in - source or binary
18:41:48pacujoStill, interesting that you first convert nim sources to binary only to wrap it again in nim.
18:41:54Araqthe writing on the wall is much more like "how are you able to sell native code libs on Linux and survive?"
18:43:26Araqand the process your describe is exactly what C and C++ also do. You can actually extract the interface Nim code automatically with a macro but I don't want to confuse you too much
18:44:48shashlickin a nutshell, you can do what you want 🙂
18:44:53*tensortom joined #nim
18:45:23pacujoThe proprietary issue is not a biggie since our systems consist of full executables. However, we have a large component infrastructure where the component artifacts (= modules) are stored in a compiled form primarily for speed or compilation.
18:45:25shashlickthe plus is that you will learn how to consume any C/C++ lib
18:45:30rayman22201to be fair, wouldn't it be the same problem on Windows?
18:45:53pacujos/or/of/
18:46:53Araqrayman22201, there are not many DLLs you can/have to buy. True.
18:47:06pacujoOur C components are stored as .h/.a files.
18:47:13shashlickAraq: I ran my test case with --gc:none and don't see the crash anymore, is that useful info in any sense?
18:48:01Araqshashlick, unfortunately not, the dealloc()s always introduce the memory safety problems and with --gc:none you don't have any deallocs
18:48:23Araqyou might as well call GC_disable() at program start and then your crashes may disappear too. Or not.
18:48:35AraqGC_disable() is more useful information
18:48:42shashlickok i'll try that
18:48:55shashlickmeanwhile, here's my crash https://pastebin.com/GBuQYA7x if it provides any useful info
18:49:00Araqalso what is this code doing:
18:49:01Araqvar
18:49:01Araq g_Alloc = ISzAlloc(Alloc: SzAlloc, Free: SzFree)
18:49:02Araq allocImp = g_Alloc
18:49:02Araq allocTempImp = g_Alloc
18:49:27shashlickoh I'm not debugging that, i'm working on my editor
18:49:48shashlickbut ya, it has its own allocator that you have to initialize
18:49:53shashlickthat's the nim7z wrapper
18:52:49shashlickok probable elephant in the room - feud.exe has a gc and all plugins also have their own gc - I'm not using nimrtl - it is probably why i'm crashing
18:53:06tensortomneed fully automated c2nim. let's make that happen
18:53:09pacujoThen there's this slight pitfall: ~/.cache/nim/<project> assumes you only have a single <project>.nim file you need to work on.
18:53:45pacujoEasy to overcome, though: --nimcache:someotherdir
18:54:11shashlickcache is a cache, you will have a binary to distribute
18:54:25shashlicktensortom - what are you missing?
18:54:43sealmove@Araq: I see the potential of the pattern shown in tinterf, but can't see how it is similar to this https://tour.golang.org/methods/9
18:55:09shashlicktensortom - have you seen nimgen and nimterop
18:55:32tensortomshashlick, just trolling based on experience from like a year ago. will check those out thx
18:56:24tensortomlol "Nimgen is a helper for c2nim to simplify and automate the wrapping of C libraries" well then...
18:56:40pacujoIf I'm working on two versions of the same project in parallel, files with identical names get compiled all the time. Better keep the caches apart.
18:56:58Araqshashlick, compile with -d:useGcAssert -d:useSysAssert
18:57:09Araqthat works on Windows and adds tons of sanity checks
18:57:13tensortomshashlick, how would you contrast the two?
18:57:22Araqso it will quickly detect where your pointers cross DLL boundaries
18:57:31shashlickAraq - will do, thanks!
18:57:40shashlicktensortom: depends what you want to wrap
18:58:22shashlicknimterop automates everything but is limited to C
18:58:42shashlickc2nim is far more capable as you know and can do c++
18:59:07shashlicknimgen is a precursor to nimterop
18:59:22tensortomah
18:59:35shashlickso what do you want to wrap
19:00:43*tensortom quit (Remote host closed the connection)
19:01:41*tensortom joined #nim
19:05:09tensortomshashlick, probably several things now that I'm less likely to have to root around through C code
19:05:17tensortomnothing in particular though
19:05:29shashlickAraq: didn't get very far - https://pastebin.com/UHP7WRSW - I'm not even in plugin land yet
19:06:07shashlicklet me push my latest code and give a link to the line
19:06:09tensortomI was going to wrap blake2 but I see someone has done it ahead of me
19:06:28tensortomwe could use some torrent code wrapped
19:07:18tensortomlibtorrent is one
19:07:51tensortomor yabtorrent
19:07:54shashlicki've had https://github.com/willemt/yabtorrent on my backlog for a while, never got around to it
19:08:38tensortomi will have a go at it and ping you here if trouble
19:10:18tensortommore nimbles brings more ppl to nim. Most programmers I mention Nim to have never heard of it but admire Go. Then they see the light
19:12:17shashlickawesome, let me know if you need any help
19:14:21shashlickthere's also a gitter channel for nimterop if its too noisy for here - https://gitter.im/nimterop/Lobby
19:15:26tensortomthx
19:18:20shashlickAraq: with gcAssert, I'm dying right here - https://github.com/genotrance/feud/blob/master/src/plugin.nim#L283
19:18:54Araqclassic Nim gotcha
19:19:18Araqlocks don't make threadsafe Nim code
19:21:21AraqI have good news and bad news for you.
19:21:57shashlickall news is good
19:22:14Araqgood news: it's not hard to make your code correct
19:22:31Araqbad news: you need to rewrite it quite a bit
19:22:57shashlickthat's okay, not getting paid for this hobby 😉
19:23:48Araqit is not that easy to explain but
19:23:52Araqstart with
19:23:53Araqvar
19:23:53Araq gThread: Thread[ptr PluginMonitor]
19:23:57Araqand instead use
19:24:07Araqvar gThread: Thread[void]
19:25:06Araqand then you have something like
19:25:27Araqvar requests: Channel[PluginMessage]
19:25:44Araqvar responses: Channel[PluginResponse] # maybe not required though?
19:25:58shashlickso basically no more shared mem, use channels instead?
19:26:03tensortomI wonder if I could put together something in tensorflow using nimterop to learn to approximate wrapping
19:26:29Araqand then instead of lock: obj.foo() you do requests.send(Foo(...))
19:26:51tensortomrather, I know I could. I wonder if it would succeed
19:27:21shashlickI was using channels and threadpool before but didn't like inventing a bogus exchange language
19:27:44Araqthere is also --gc:boehm if you can find a boehm.dll (I cannot)
19:27:48shashlicki can move back to that system, but main question is why shared mem with locks doesn't work
19:28:11Araqbecause the memory is not shared, it's threadlocal for strings/seqs and refs and closures
19:28:42Araqand you cannot make threadlocal heaps safe with locks which is we have not much multi-threaded Nim code out there
19:29:07shashlickeven though I used allocShared0()?
19:29:20Araqyou didn't use it for @[] did you
19:29:47shashlickoh I see what you are saying
19:30:11shashlickPluginMonitor* = object is shared, but the random stuff i'm throwing in there isn't shared
19:30:48Araqthere is more good news though: I'm removing thread local heaps
19:31:04*kapil____ quit (Quit: Connection closed for inactivity)
19:31:15shashlickso let me ask this - https://github.com/genotrance/feud/blob/master/src/globals.nim#L23
19:31:35shashlickif I make PluginMonitor and allocShared every element in it, will it avoid this issue?
19:31:47Araqwell look at it
19:32:15Araqit requires SharedHashSet[SharedString] and sharedSeq[SharedString]
19:32:29Araqwhich we don't have in the stdlib
19:32:45shashlickya, i'll have to change all that
19:33:02shashlickbut if I utilize shared memory correctly, the lock should work right
19:33:17Araqright. you should try to use --gc:boehm
19:33:40Araqand then switch to --newruntime in 0.20
19:33:47shashlickwould the current code work with gc:boehm?
19:33:56shashlickit still looks fundamentally wrong now that you pointed it out
19:34:28Araqyeah, gc:boehm just works with all of this
19:34:36Araqif you can find a DLL on windows
19:35:31Araqand in the longer run this also will work, we figured it out, memory safety without a GC, with shared heaps and much easier to use than Rust
19:36:52*nsf joined #nim
19:37:01shashlickok so sounds like I should get it working with shared mem for now
19:37:06shashlickrather than moving to channels
19:37:39Araqyeah
19:37:48Araqespecially since you also want to avoid nimrlt.dll
19:37:56shashlickok i'll work on this
19:38:15*natrys quit (Quit: natrys)
19:38:18shashlickwhile you are in here, can you also review pluginapi.nim - https://github.com/genotrance/feud/blob/master/src/pluginapi.nim
19:38:52shashlickall plugins have a global pointer where they can save stuff - i'm concerned if that is done right
19:39:11shashlickbasically getCtxData() and getPlgData()
19:40:33*cgfuh quit (Quit: WeeChat 2.3)
19:40:48shashlickthanks for the insights, really appreciated
19:41:45*aguspiza quit (Ping timeout: 246 seconds)
19:42:37sealmoveokay I managed to make something similar in Nim: https://termbin.com/j64i
19:46:10sealmoveit uses generics but still it looks quite nice
19:52:31*rnrwashere quit (Remote host closed the connection)
19:53:25Araqsealmove, there are also libraries that use macros to do these things
19:54:01Araqshashlick, GC_ref/unref can have problems with shared heaps too but boehm's GC will work
19:54:07sealmoveyeah well, just playing around basically
19:54:21sealmoveso hyped about newruntime :))
19:54:57shashlickAraq: no cross-thread sharing going on with plugins
19:55:02Araqand you should, I'm too. Also spent months researching this and just when it seemed impossible a nice solution turned up
19:55:04shashlickall in the same thread
19:55:28Araqshashlick, ok
19:55:30shashlicki'm trying to replace my seq and hashset with sharedlist
19:55:43shashlicki think even the string field will have to be shared right
19:55:44Araqno, try to compile boehm.dll on Windows
19:56:02shashlickhttps://github.com/ivmai/bdwgc
19:56:07Araqyeah, even the strings should be and then you're fighting the language moreso than working with it
19:57:27Araqalso, Boehm GC wins on some benchmarks over Nim's GC. Sad but true
19:58:08shashlickOk will try that first
19:58:57Araqif you manage, please share this .dll with me
19:59:27AraqI'd like to ship it with Nim
20:00:05Araqcurrently we disabled the Boehm tests on Windows
20:00:14Araqbecause we don't have the DLL
20:01:32shashlickSeems it should build with mingw
20:01:36shashlickhttps://github.com/ivmai/bdwgc/blob/master/doc/README.win32
20:01:44shashlickI'll try it out and let you know
20:16:03*rnrwashere joined #nim
20:19:18*Vladar quit (Remote host closed the connection)
20:21:03shashlickok I have libgc-1.dll
20:22:58shashlickmy word it just works
20:23:01shashlickno more crash
20:27:03shashlickAraq: I can send you a 32-bit and 64-bit boehmgc.dll
20:27:23shashlickbut the code just looks for same filename - do we need a code change for boehmgc64.dll
20:27:49*ptdel joined #nim
20:30:56*nsf quit (Quit: WeeChat 2.4)
20:35:20*jjido joined #nim
20:38:55Araqshashlick, yeah a small mmdisp.nim patch is required
20:41:34sealmoveVarriount: I tried your original example of Concepts and it fails with "Error: 'ImplementingSomeProc' is not a concrete type". https://termbin.com/tioe
20:41:35shashlickokay cool
20:45:26sealmoveAre Concepts only for matching proc/template parameters?
20:45:40shashlickAraq: is it possible to compile boehm in as a static lib - do we need code changes for that
20:46:12Araqwhy would we want to do that?
20:46:24Araqas a DLL is also solves the DLL problems
20:46:43shashlicksingle binary
20:47:20Araqbut who cares about that on Windows, you put the .dll next to the .exe, done
20:48:56*Trustable quit (Remote host closed the connection)
20:49:02shashlicki typically did since I can ship one exe with everything in it, but ya
20:49:32ptdelI had a question about concepts would the be considered analogous or similar to haskell typeclasses?
20:49:37ptdelthey*
20:51:01sealmoveptdel: I think they are pretty similar
20:51:16Araqthey are constraints for generics
20:51:24ptdelperfect :D
20:51:48ptdelI was talking to my coworkers about trying to use concepts to implement a "policy as code" framework for resources we deploy
20:52:00ptdelthe idea we could use concepts as policies in a sense was very attractive
20:52:15AraqI doubt it works out
20:52:18ptdel:-p
20:52:40ptdelAraq: any reason for thinking it might be a bad idea?
20:53:08ptdelwe would be attempting to typify things like a Virtual Machine (for amazon)
20:53:10sealmoveAraq doesn't like Concepts :P
20:53:24ptdelah lol
20:53:44ptdelfwiw i think they are a cool idea
20:53:53ptdelbut i come from a place that has things like them
20:53:57Araqyears of experience. People think they could use concepts for this and that and then they cannot even write 'myObjectField: MyConcept' and begin to understand what "constraints for generics" means
20:54:16sealmovethey are, but rarely needed/useful, and they scare away or confuse less experienced ppl
20:54:35sealmove(like me :P)
20:54:42ptdelso if I'm trying to apply constraints to just types in general, try another approach eh?
20:55:42*noeontheend joined #nim
20:55:43Araqusually Nim is better at codegen-like abstractions than at type based abstractions
20:55:58*cyraxjoe joined #nim
20:56:35Araqthat means: macros!
20:56:57ptdelI've liked macros and templates quite a bit. somebody that lurks here often and myself have been using macros to automate API operations from a very nasty IDL
20:57:19ptdel(a java idl) Nim has been reliably making procedures from the IDL thus far best i can tell
20:59:00Araqthanks
21:00:36*rnrwashe_ joined #nim
21:01:24*vlad1777d joined #nim
21:01:28sealmoverandom thought I had recently: I trully think Nim is the best scripting language. Scripting languages have been associated with interpreters and dynamic typing, but this is totally false imo. What you actually need is a shebang, top-level execution, and nice syntax. Being statically typed is actually a plus since we have type inference, and the compilation speed is not an issue for small scripts.
21:02:28sealmovePretty much a better Python for that matter if you ask me.
21:03:00AraqI would go further than that and claim that static typing in a scripting setting is more important than for production code that has a test suite anyway
21:03:23AraqI mean, ok, static typing is great, it also helps readability and performance
21:03:39*rnrwashere quit (Ping timeout: 264 seconds)
21:03:53ptdelmy work is primarily Python, you (probably have some) idea of how refreshing Nim is to me x_x
21:04:31Araqbut this idea to run *stringly typed* code that accesses my filesystem nilly willy is idiotic
21:05:03*narimiran quit (Ping timeout: 245 seconds)
21:05:57ptdelsimply having a compiler between operations and deployments is a huge plus. otherwise easy errors proliferate all over the place
21:06:04sealmoveI think dynamic typing is rarely useful, if at all today.
21:08:39*elrood quit (Remote host closed the connection)
21:16:42xaceoh wow, termux finally included nim in their packagemanager :)
21:17:26xaceanyone know if the termux-api has a interface or something that can be used to have nim utilize ?
21:23:50ptdelnot sure what to make of this: if I have array[18, char] it shows up in errors as array[0..17, char] but if i have array[20, char] it shows up as array[0..27, char] is it using a different base or anything?
21:24:26BaldEagleX02@shashlick Could you join ##nim-iot? We are discussing about using nimterop
21:24:31Araqnever seen anything like it
21:24:47BaldEagleX02me neither
21:29:31*rnrwashe_ quit (Read error: Connection reset by peer)
21:30:13*rnrwashe_ joined #nim
21:32:30ptdelnevermind, I need to refresh myself on pointers :-p
21:34:04shashlick@BaldEagleX02 - is that on irc
21:37:44shashlickAraq: https://www.dropbox.com/sh/g77an3wvuarvl7o/AACodadNdWPovrNeMd0nuOQWa?dl=0
21:39:01ptdelgiven that openArray is only suitable for parameters, whats the ideal type to refer to in inferences when returning arrays of variable length? dealing with some cryptographic hashing of strings
21:39:56*pacujo left #nim ("Killed buffer")
21:44:47Araqptdel, either you let the caller deal with it by a parameter result: var openArray[]
21:45:16Araqor you return a seq. or you return a fixed size array and use static T to compute the array sizes at compile-time
21:45:27Araqshashlick, ah excellent
21:45:29BaldEagleX02@shashlick Yes
21:46:11ptdelAraq: thank you that works, I needed var openArray[]
21:48:57*arecacea1 quit (Remote host closed the connection)
21:49:15*arecacea1 joined #nim
21:50:02sealmoveAraq: After literally hours of staring at the screen I finally understand how that closure pattern works exactly like Go interfaces \o/
21:51:11*ptdel quit (Remote host closed the connection)
22:02:00sealmovehttps://termbin.com/75cw
22:03:02Araqshashlick, you have Nim repo commit rights, can you undo the change that made nightlies fail?
22:03:04sealmoveIt's a little weird because you write `proc` but really what you are defining is a type. And the return type of that `proc` is actually the interface that you are implementing
22:03:41Araqsealmove, told ya most people struggle with it.
22:03:42FromDiscord<moerm> Hello
22:04:07shashlickAraq: busy evening, will look into it tomorrow
22:04:08FromDiscord<moerm> Anyone from the Nim team here? I have a very weird Nim bug/problem(?)
22:04:25sealmoveyeah it's unintuitive, but u're right, once understood it's nothing special
22:04:42FromDiscord<moerm> details are here -> https://forum.nim-lang.org/t/4726#29491
22:07:36sealmove19.9 is out??
22:08:07FromDiscord<moerm> Nope. It's a nightly. The current release is 19.4 iirc
22:10:11*tensortom quit (Remote host closed the connection)
22:10:39*tensortom joined #nim
22:12:43Araqmoerm: 0 .. -1 is the empty range and 0 is not in it
22:14:13FromDiscord<moerm> Araq Oops. I supoosed -1 means last element. But still, why does Nim throw ?
22:15:07Araqvar somebuf: array[MEG64, char] is array[0..MEG64-1, char] and so passing MEG64 to 'start' seems to be wrong
22:16:04FromDiscord<moerm> The array contains valid data
22:16:06*shashlick quit (Remote host closed the connection)
22:16:27*shashlick joined #nim
22:16:39FromDiscord<moerm> (btw: First: Thanks for looking into it!) Uhm, I don't pass MEG64 to start.
22:16:59BaldEagleX02@shashlick How do I import multiple libraries at once with Nimterop?
22:17:00FromDiscord<moerm> The problem happens in the first call whith start being 0
22:18:34FromDiscord<moerm> Nim throws when k == 0 (so when I try to assign bufx[0] to c (a char)
22:19:54Araqbtw instead of .. code-block:: nim
22:20:05sealmovemoerm: it runs fine on my machine
22:20:07Araquse ```nim ``` on the forum
22:20:20Araqso avoid the indentation hell
22:21:05FromDiscord<moerm> Just "nim" on a line by itself? Great! Thanks a lot for that tip
22:22:10Araqno, with the triple backticks
22:22:17sealmoveyou need the three backquotes before and after "nim"
22:22:23Araqmarkdown style
22:22:48FromDiscord<moerm> Ah, OK.
22:25:17*rnrwashere joined #nim
22:25:59dom96hey shashlick, you around?
22:27:40*rnrwashe_ quit (Ping timeout: 264 seconds)
22:27:50FromDiscord<moerm> (dom96 Hello, and: saw him just some minutes ago)
22:28:11dom96yeah, I see he was around 20 minutes ago
22:29:13Araqmoerm: don't allocate your large buffer on the stack
22:29:48Araqapart from that, I don't know why you would get a crash, never seen Nim getting basic index checks wrong
22:30:37FromDiscord<moerm> Araq Me neither. I have learned to trust Nim. But here it throws with a simple index 0 op
22:31:19*bobby quit (Ping timeout: 244 seconds)
22:31:38FromDiscord<moerm> I'll try to alloc it one the heap, but: I have a very similar proc that works with bytes (instead of char) and does work flawlessly. Really, really strange
22:32:30ZevvAraq, I'm trying the assign the result of a a macro with code block to a const, but Nim says "invalid indentation". Is that a bug or a feature?
22:34:56Zevvhttp://paste.debian.net/1073678/
22:35:16shashlickI'm here kind of
22:35:56dom96shashlick: Since you'll be working on this `nim e` Nimble integration, would you like write access to the repo? :)
22:36:02*bobby joined #nim
22:40:12dom96I have so little time these days that it would be helpful to have someone taking a more active role in maintaining Nimble (that includes reviewing PRs and merging them)
22:41:13FromDiscord<moerm> @Araq Sorry, but it throws with a (heap alloc'd) ref too 😦
22:41:25FromDiscord<moerm> (same exception)
22:43:38*bobby quit (Ping timeout: 252 seconds)
22:43:53*Bob- joined #nim
22:44:33FromDiscord<moerm> I also made the array smaller (just 1024 bytes) - and it still throws
22:45:50shashlickSure @dom96 that will be great
22:47:28dom96Done!
22:48:56*bobby joined #nim
22:49:52*Bob- quit (Ping timeout: 252 seconds)
22:55:03*solitudesf quit (Ping timeout: 245 seconds)
22:55:10shashlickAwesome! Now to live up to it :D
22:57:53FromGitter<deech> @dom96: Out of curiosity are you working full time on Nim?
22:58:07dom96Sadly no
22:58:21*bobby quit (Remote host closed the connection)
22:59:56*lf-araujo joined #nim
23:01:19*bobby joined #nim
23:01:43FromGitter<deech> Ah, ok. I thought you were part of that core team that was hired by Status (?, I forget now).
23:04:54*ftsf joined #nim
23:06:11Araqmoerm: well the compiler tells you there is no 0th element in your openarray
23:06:49Araqso recheck your logic once again and if you think the compiler is wrong reproduce the problem in a smaller test program that we can run
23:07:03Araqthat's all I can say, sorry
23:07:42AraqZevv, how strange, bug report please
23:10:51*bobby quit (Remote host closed the connection)
23:11:34dom96deech: AFAIK Status hasn't hired anyone to work on Nim directly. They, along with others, are contributing money to the Nim project and that allows Araq to hire people to help with the development
23:11:48*lf-araujo quit (Ping timeout: 250 seconds)
23:13:01FromDiscord<moerm> Araq I'll try
23:13:37FromDiscord<moerm> But I'm absolutely certain (and verified that) that there *is* a 0'th element
23:16:07FromGitter<deech> @dom96: Ah, didn't know that. Thanks, appreciate the info!
23:16:11Araqwell ignore the exact error message but assume an index is off
23:17:43FromGitter<kayabaNerve> dom96: I thought you were part of the team hired by Araq with Status money :thinking:
23:20:44dom96I've got another full-time job :)
23:21:32FromGitter<kayabaNerve> I thought Nim was your full time job, :thinking:
23:21:44FromGitter<kayabaNerve> Joking :p I understand it all now.
23:22:26FromDiscord<moerm> @Araq, sorry, nope. I've checked it and checked it again and debugEcho'ed. The index is *not* off. It's 0 and there *is* an elem[0]
23:23:54sealmovehow do you test for type equality?
23:27:10Araqmoerm: how do you know there is elem[0]? what does len say? what does high say?
23:27:46Araqwhat if you disable index checking ( {.push checks: off.}proc ... {.pop.} )
23:28:57*bobby joined #nim
23:29:10FromDiscord<moerm> I expressly tested for low, in fact I set my index via low. len says the true length.
23:29:26FromDiscord<moerm> I'll try your tip to turn off index checking
23:30:06sealmoveis doAssert type(x) == type(y) possible atm?
23:34:30*rnrwashere quit (Read error: Connection reset by peer)
23:35:02*rnrwashere joined #nim
23:35:10*Bob- joined #nim
23:36:20*bobby quit (Ping timeout: 258 seconds)
23:37:40FromDiscord<moerm> I guess I'll have to look at the generated C code
23:38:46*vlad1777d quit (Remote host closed the connection)
23:40:41*ng0 quit (Quit: Alexa, when is the end of world?)
23:41:13*vlad1777d joined #nim
23:42:04*Bob- quit (Ping timeout: 264 seconds)
23:42:41*bobby joined #nim
23:52:22FromDiscord<moerm> @Araq I closed in. After de-inlining a (unrelated) proc that gets called elsewhere my code works with index checking disabled. Well, that's a start
23:53:25FromDiscord<moerm> (And I completely forgive the Nim compiler to throw up with heavily inlined (albeit unrelated) code in the module. After all, Nim isn't yet 1.0. All in all I'm very happy and find Nim quite reliable)