<< 09-02-2016 >>

00:01:07*apotheon joined #nim
00:08:36*francisl quit (Quit: francisl)
00:13:47*Matthias247 quit (Read error: Connection reset by peer)
00:17:15*derka quit (Quit: derka)
00:20:45*Demon_Fox joined #nim
00:23:25ephjathe 'guard' pragma seems to accept anything, but it doesn't do anything if the argument is not a Lock
00:24:26*desophos quit (Ping timeout: 256 seconds)
00:27:35ldleworkHow do you get a sequence of a Table's keys?!
00:27:49ldleworkI can't call keys() I can only iterate over it?
00:27:52filwittablet.keys.toSeq
00:29:01filwitsequtils.toSeq(anyIterator)
00:29:35*lompik joined #nim
00:29:39filwitthough I no idea what kind of overhead that has
00:32:27ldleworkits horrible lol
00:32:37filwitwhy?
00:32:50ldleworkI don't know, but when I did it each frame I got like 2 fps
00:32:54ldleworkor rather
00:33:05ldleworkwhen I did it hundreds of times a frame, I got like 2 FPS
00:33:15filwitoh, horrible performance, i thought you meant the design was horrible
00:33:17ldleworkwhen I did it once a frame I got 100s of FPS
00:33:55filwityeah it's probably causing a bunch of small allocations (bad for a GC) cause it's can't predict the length of the seq to return
00:34:15*jaco60 quit (Ping timeout: 240 seconds)
00:34:42filwityou could always make your own more efficient version for tables using the length to pre-alloc the seq, then just fill it in
00:35:30filwit(that should probably be part of the 'tables' lib, i agree... I'm sure the powers that be would accept a PR like that)
01:00:23*desophos joined #nim
01:24:39*brson_ joined #nim
01:26:40*brson quit (Ping timeout: 250 seconds)
01:38:19*francisl joined #nim
01:49:48*francisl quit (Quit: francisl)
02:06:52*gokr quit (Quit: Leaving.)
02:11:32*saml_ joined #nim
02:15:19Varriountldlework: If your keys are strings, try marking them with shallow(), that should help with allocations.
02:24:01*zepolen joined #nim
03:04:09*pregressive joined #nim
03:07:13*darkf quit (Quit: Leaving)
03:14:56*brson_ quit (Ping timeout: 240 seconds)
03:25:39*vendethiel joined #nim
03:31:26*ephja quit (Ping timeout: 256 seconds)
03:32:46*junw_ quit (Ping timeout: 250 seconds)
03:35:25*francisl joined #nim
03:43:03*saml_ quit (Remote host closed the connection)
03:47:51*zepolen quit (Remote host closed the connection)
03:48:20ldleworkWhy am I getting undeclared field: 'keysym' with https://gist.github.com/dustinlacewell/88cda9abd9c344c465c8
03:48:39ldleworkDoesn't using case on the kind allow me to access the fields?
03:52:23Varriountldlework: What's the event type look like?
03:54:01ldleworkhttps://github.com/nim-lang/sdl2/blob/master/src/sdl2.nim#L55
03:55:51ldleworkoh wait I think I remember something about
03:55:58filwityou have to cast SDL events to the specific event type
03:56:01ldleworkthe data being hidden under a kind specific attribute
03:56:08ldleworkno
03:56:20ldleworkthere's some template that does something..
03:57:03ldleworkah here it is, https://github.com/nim-lang/sdl2/blob/master/src/sdl2.nim#L600
03:58:22filwitanyways, g2g
03:58:27*filwit quit (Quit: Leaving)
03:59:46*lompik quit (Ping timeout: 240 seconds)
04:02:40*vendethiel quit (Ping timeout: 250 seconds)
04:06:52*zepolen joined #nim
04:19:01*endragor joined #nim
04:36:50*francisl quit (Quit: francisl)
04:55:40*hh_ joined #nim
04:58:37*pregressive quit (Remote host closed the connection)
05:00:43*hh_ quit (Quit: Page closed)
05:01:05*pregressive joined #nim
05:09:02*vangroan joined #nim
05:12:13*vangroan quit (Client Quit)
05:12:50*pregressive quit (Remote host closed the connection)
05:13:09*pregressive joined #nim
05:15:01*pregressive quit (Remote host closed the connection)
05:38:39*lqdc quit (Ping timeout: 252 seconds)
05:39:09*vendethiel joined #nim
05:42:33*pregressive joined #nim
05:44:51ThePythonicCowSeveral hours ago, fitwit wrote "yeah it's probably causing a bunch of small allocations (bad for a GC)"
05:47:08ThePythonicCowI'm jumping in way over my head here, but if nim knows (can generate code at compile time that can calculate efficiently at runtime) the length of what's free'd, then a custom allocator that pools the most commonly used small sizes can really speed things up. I "saved" a C++ project that was in trouble for unacceptable performance doing this, back in the 1990's.
05:48:51ThePythonicCowPlain old C free() can't do that , because it only has the pointer, not the length, so it has to go back to the primary malloc pool to figure out what it's freeing.
05:49:30ThePythonicCowBut when you're working a level up from plain old C, there's a good chance you have or can get the length, cheaply.
05:52:41ThePythonicCowSo, back then, I had something like 16 pools of memory, for one to sixteen word lengths, and if anyone wanted to buy or sell a short length, I did it off those pools, for just a few inline instructions. If a pool ran out, I malloc'd another page of memory, for more of that particular size.
05:56:07*s4 joined #nim
06:00:47*vendethiel quit (Ping timeout: 264 seconds)
06:02:07*ephja joined #nim
06:08:18*pregressive quit (Remote host closed the connection)
06:10:02*StarBrilliant quit (Ping timeout: 250 seconds)
06:23:48*StarBrilliant joined #nim
06:43:31*endragor quit (Remote host closed the connection)
06:45:32*endragor joined #nim
06:46:28*endragor quit (Read error: Connection reset by peer)
06:46:34*endragor_ joined #nim
06:50:56*Demon_Fox quit (Ping timeout: 240 seconds)
06:57:51*Demon_Fox joined #nim
07:14:18*gour joined #nim
07:18:56*yglukhov joined #nim
07:23:04*vendethiel joined #nim
07:23:16*yglukhov quit (Ping timeout: 245 seconds)
07:26:03*filcuc joined #nim
07:26:27*warkid joined #nim
07:29:04*gokr joined #nim
07:44:58*vendethiel quit (Ping timeout: 250 seconds)
07:50:54*vendethiel joined #nim
07:59:02gokrMorning
08:00:01gokrBattled last night with getting a "blink-the-LED" program running on a Linkit One. So frustrating, now all compiles and links properly but ... nah, won't blink the damn thing.
08:05:44*endragor_ quit (Remote host closed the connection)
08:11:22*vendethiel quit (Ping timeout: 256 seconds)
08:12:26*apotheon quit (Ping timeout: 240 seconds)
08:13:45*yglukhov joined #nim
08:14:51*Demon_Fox_ joined #nim
08:15:56*Demon_Fox quit (Ping timeout: 240 seconds)
08:24:42*apotheon joined #nim
08:28:55*Arrrr joined #nim
08:30:42*Demon_Fox_ quit (Remote host closed the connection)
08:31:08*endragor joined #nim
08:55:34*Sembei quit (Quit: WeeChat 1.5-dev)
08:57:46*zepolen quit (Remote host closed the connection)
08:58:56*Trustable joined #nim
09:00:05*hh_ joined #nim
09:02:41*coffeepot joined #nim
09:03:12VarriountTo anyone listening: A new version of NimLime is out!
09:03:36VarriountThePythonicCow: You'll be interested to know it's written in Python. :D
09:06:02coffeepotgrats Varriount!
09:07:46Varriountcoffeepot: The biggest thing for me was the reworked backend and error reporting system.
09:08:31coffeepotexcellent, does it support code completion?
09:08:50coffeepotjust read, yes it does :)
09:09:18Varriountcoffeepot: Well, Sublime Text supports a kind of code completion out of the box, however the plugin doesn't have that level of integration with Nimsuggest yet.
09:10:23coffeepotnice, looks good :)
09:23:29*derka joined #nim
09:24:26*zepolen joined #nim
09:28:59*toaoMgeorge quit (Ping timeout: 276 seconds)
09:32:06ThePythonicCowI'll check out the new NimLime ... I tried earlier, but failed, to add it to Sublime, my preferred gui editor, when I'm not using my favorite editor of all time, ed.
09:32:39ThePythonicCowI did not bother to figure out why my first attempt to use NimLime failed ... no coherent comments to provide there
09:51:00gokrAraq: How does it work with bool and c2nim? I mean... can one generally pass true/false to C and it ends up correct?
09:52:39endragorNIM_BOOL is defined as `unsigned char` if the compiler doesn't support `bool` type
09:52:42endragortrue/false is 1/0
09:56:37gokrmmm
09:56:59*toaoMgeorge joined #nim
09:57:09gokrAraq: Btw, ended up getting "mod_core_base* {.importc: "mod_core_base".} {.bitsize: 1.}: VMUINT" - bug not merging pragmas?
09:58:19yglukhovisnt getEnv+js+compileTime a solved issue by now?
09:59:47endragorI can't forward-declare a type in Nim, can I? I'm trying to interface with C++ framework with lots of inter-dependencies between classes. Would be nice to declare all the types first, and then provide implementations for them in separate files. Seems the only way to do that is to declare types first and interface fields as zero-arg procedures instead of actual variables. Any other workaround?
10:01:07*yglukhov_ joined #nim
10:02:32*mlitwiniuk quit (Quit: over and out)
10:02:51*mlitwiniuk joined #nim
10:04:00*yglukhov quit (Ping timeout: 260 seconds)
10:04:21*mlitwiniuk quit (Client Quit)
10:04:34*mlitwiniuk joined #nim
10:06:45*zepolen quit (Ping timeout: 245 seconds)
10:08:22*zepolen joined #nim
10:11:42*yglukhov_ quit (Remote host closed the connection)
10:14:08Varriountendragor: Nope. Types can't be forward-declared, however types defined in the same section can reference each other without regards to order.
10:19:38*yglukhov joined #nim
10:23:27*gour_ joined #nim
10:26:14*gour quit (Ping timeout: 256 seconds)
10:30:09*irrequietus joined #nim
10:38:35*zepolen quit (Ping timeout: 240 seconds)
10:41:52*yglukhov quit (Remote host closed the connection)
10:42:17*zepolen joined #nim
10:46:39*warkid quit (Ping timeout: 252 seconds)
10:49:04*junw_ joined #nim
10:53:11def-endragor: one approach is to have a types.nim file and define all types there. if they all interact with each other, it's not a bad idea to define them in the same place
10:54:36endragordef-: they interact with each other via methods, not fields. I'd like to avoid declaring fields and methods related to the same class in separate files
10:55:53endragorthe only way I've found so far is to declare "naked" types in one place, and then declare both vars and methods for one class in one file, but convert `var` declaration into two procedures with a macro
10:56:03endragor(set procedure and get procedure)
11:02:13*yglukhov joined #nim
11:02:32*zepolen quit (Ping timeout: 250 seconds)
11:07:05*zepolen joined #nim
11:17:59*hh_ quit (Quit: Page closed)
11:30:34*zepolen quit (Read error: Connection reset by peer)
11:33:35*zepolen joined #nim
11:38:06*zepolen_ joined #nim
11:38:08*zepolen quit (Read error: Connection reset by peer)
11:44:05ThePythonicCowVarriount: I am still getting failures trying to use NimLime with my Sublime install. I got past the first of the 4 error screens by adding the directory with nimsuggest to my $PATH but now it still cannot find nim or nimble, and an strace shows it is looking for $PATH/nim.exe (the entire $PATH, with its dozen directories, as a single string), rather than looking for x/nim, for each x in $PATH
11:44:29ThePythonicCowThis is on Debian Linux, running zsh, a Bourne Shell extension
11:52:52yglukhovAraq: mind for a conditionalSymbolValue() magic to allow cmdline -d:myConditionalString=someStringValue?
11:57:51*zepolen_ quit (Read error: Connection reset by peer)
11:57:56*filwit joined #nim
11:59:04*wuehlmaus quit (Quit: Lost terminal)
11:59:19ArrrrRelated http://stackoverflow.com/questions/34119841/define-switch-for-key-value
12:00:05*zepolen joined #nim
12:01:25filwitThePythonicCow said: "... Plain old C free() can't do that , because it only has the pointer, not the length, so it has to go back to the primary malloc pool to figure out what it's freeing."
12:02:40yglukhovon the other hand, env + staticExec + echo $MY_VAR should do the trick... although a bit hacky...
12:02:41filwitFYI, Nim does use it's own allocator, not malloc/free.. and (apparently) that does make use of type-size information rather than store size as a header like malloc does
12:03:29ThePythonicCowfilwit: << Nim does use it's own allocator, >> cool
12:04:28filwitThePythonicCow: IDK much about it's details beyond that point.. though I know it allocates by pages (mmap, MapVirtualAddress) and uses bit patterns or something to help the GC understand what is a live reference
12:05:01ThePythonicCowok
12:05:36ThePythonicCowif I stay with Nim long enough ... I'll know the details ... but that's a ways off into the future
12:06:24filwitthat said, the GC still has to do cyclic scans and stuff, so lots of small allocations aren't good (of course, it only needs to do that on potentially cyclic types, which strings aren't so it's probably true that it wasn't a huge performance concern)
12:07:35filwitI was referring to the sequtils.toSeq() function which takes any iterator and converts it into a seq.. which means it can't really predict the size of the seq beforehand, and probably causes a bunch of small alloc/realloc equivalents in the allocator
12:10:31filwitfor something like a Table where you want an seq of keys, it would probably be more efficient to have a special keysSeq() proc which used the size-info
12:10:51filwitanyways.. just commenting on that cause you quoted me about it earlier, cheers :)
12:16:35*exebook joined #nim
12:21:27*zepolen quit (Read error: Connection reset by peer)
12:21:55gokrI am totally confused over how nim decides what C header files it includes.
12:25:21*zepolen joined #nim
12:29:36*desophos quit (Read error: Connection reset by peer)
12:37:00*BitPuffin joined #nim
12:48:47*warkid joined #nim
12:50:30*zepolen quit (Ping timeout: 245 seconds)
12:51:47*Arrrr quit (Ping timeout: 276 seconds)
12:52:42*zepolen joined #nim
12:53:33*Arrrr joined #nim
13:08:28*zepolen quit (Read error: Connection reset by peer)
13:10:53*zepolen joined #nim
13:22:17*gokr quit (Quit: Leaving.)
13:22:38*gokr joined #nim
13:22:49*irrequietus quit ()
13:26:56*zepolen quit (Ping timeout: 240 seconds)
13:27:38*zepolen joined #nim
13:28:52*lompik joined #nim
13:42:42*s4 quit (Quit: Konversation terminated!)
13:44:09*zepolen quit (Read error: Connection reset by peer)
13:46:58*zepolen joined #nim
13:56:20*toaoMgeorge quit (Ping timeout: 252 seconds)
13:56:49*zepolen quit (Read error: No route to host)
13:57:25*zepolen joined #nim
14:00:20*zepolen quit (Read error: Connection reset by peer)
14:04:22*zepolen joined #nim
14:16:31*hh_ joined #nim
14:18:11*lompik quit (Ping timeout: 264 seconds)
14:19:54*zepolen quit (Read error: Connection reset by peer)
14:22:40*zepolen joined #nim
14:29:42ThePythonicCowVarriount: Your nimlime_core/utils/misc.py:def split_semicolons(string) routine (if that's your code) does not work on Linux
14:29:56ThePythonicCowAs described here: http://stackoverflow.com/questions/4528438/classpath-does-not-work-under-linux
14:30:13ThePythonicCowthe PATH component separator on Linux is colon ':', not semicolon ';'
14:31:07ThePythonicCowSo nimlime is not loading for me on Linux, because it cannot find nim or nimble
14:31:44ThePythonicCowIt ends up looking for a file that has a path that is my entire (100 char, multiple dirs) $PATH long
14:34:09ThePythonicCowThe Python char os.pathsep should work reliably, on any OS
14:34:32ThePythonicCow(colon or semicolon, as the case be)
14:34:49*zepolen quit (Read error: Connection reset by peer)
14:36:08*zepolen joined #nim
14:40:30*yglukhov quit (Ping timeout: 245 seconds)
14:43:01*regtools joined #nim
14:45:14ThePythonicCowI filed a nimlime bug on git, as I should have done: "nimline cant load nim or nimble using Linux PATH (colon, not semicolon PATH sep) #59 "
14:49:48onionhammer@Varriount https://www.sublimetext.com/docs/3/syntax.html
14:50:20*gour_ quit (Quit: WeeChat 1.4)
14:50:29*darkf joined #nim
14:53:20*gour joined #nim
14:54:47*arnetheduck joined #nim
14:55:11*hh_ quit (Quit: Page closed)
14:55:30*zepolen quit (Ping timeout: 245 seconds)
14:58:26*zepolen joined #nim
15:06:03*pregressive joined #nim
15:06:12*pregressive quit (Remote host closed the connection)
15:23:49*zepolen quit (Read error: Connection reset by peer)
15:26:11*krux02 joined #nim
15:27:45*zepolen joined #nim
15:45:45*zepolen_ joined #nim
15:46:18*wuehlmaus joined #nim
15:48:10*zepolen quit (Ping timeout: 260 seconds)
15:55:16*zepolen_ quit (Read error: Connection reset by peer)
15:55:51*zepolen joined #nim
16:00:03krux02I have problems creating the `[]` operator for my own type, how is it done properly?
16:00:40coffeepotproc `[]`*(myType: MyType) =
16:00:59coffeepotor you mean dereferencing?
16:01:52*pregressive joined #nim
16:02:08*zepolen_ joined #nim
16:03:01*zepolen quit (Read error: Connection reset by peer)
16:05:11krux02coffeepot: here I made an example https://gist.github.com/krux02/390e68e6e5e6c5cb4e01
16:05:31krux02I always end up getting an error no matter how I implement it
16:05:51krux02the [] operator needs to support read write and update
16:06:53*jaco60 joined #nim
16:07:11krux02read seems to be no problem at all, but += seems to be a problem all the time
16:07:19coffeepotfirst look but there must be an easier way to do this (cast[ptr[T]](cast[int](mb.data) + (index * sizeof(T))))[]
16:08:11coffeepotnot that i have a suggestion atm lol
16:08:11krux02that part is not the problem
16:08:28krux02it is for a c api wrapper
16:08:33coffeepotah right
16:08:53krux02and the cpai thinks that there is pointer arithmetic
16:12:07krux02the problem is, that it is a low level api, and copying everything into a seq is not feasable
16:12:24krux02is there a seqView class somewhere that I can abuse?
16:17:29*zepolen_ quit (Read error: Connection reset by peer)
16:17:57*zepolen joined #nim
16:18:29coffeepoti have no idea :) I heard that seqs are compatible with C arrays though, maybe someone with more knowledge can chip in?
16:20:08coffeepoti suspect you can go var s: newSeq[int](10); s[0].addr to work with C
16:20:18coffeepotthinking about it, pretty sure I did this in my odbc lib
16:20:55*ryu0 joined #nim
16:20:57*ryu0 left #nim ("WeeChat 1.0.1")
16:21:14Araqkrux02: did you try to make it return 'var T' ?
16:21:33coffeepotby the way, you missed off the `[]=` proc for your first type, mappedbufferA
16:21:46coffeepotwhich is the cause of the error at line 17
16:21:48krux02Araq: https://gist.github.com/krux02/390e68e6e5e6c5cb4e01
16:21:54krux02yes it is the first one
16:22:30krux02coffeepot: if I add the `[]=` for the first type, then I get ambiguety
16:23:00coffeepotreally? works for me?
16:23:09coffeepotproc `[]=`*[T](mb : MappedBufferA[T]; index: int; value : T) =
16:24:21coffeepotadding in var T at line 24 seems to fix the 2nd issue
16:24:42coffeepotalthough the code segfaults :)
16:24:59*jaco60 quit (Quit: Leaving)
16:25:18coffeepothttps://gist.github.com/coffeepots/1c8caf3382372dbf21d6
16:25:24*jaco60 joined #nim
16:25:24filwitkrux02: haven't looked at your gist, but just a comment on wrapping C arrays.. I find it's much easier to make an ``type CArray{.unchecked.}[T] = array[1,T]`` and use ``ptr CArray[T]`` than it is to use plain ``ptr T`` + pointer arithmetic to access elements
16:26:05filwitkrux02: with the `CArray` version you can simple use the [] to access elements inside the array
16:26:08coffeepotyes! That's (what filwit said) the way to do it :)
16:26:36krux02sorry I tested it with the `[]=` for the first type now, and now it works
16:26:38coffeepotthat's how i did it in odbc too
16:27:00coffeepothighly recommend using the unchecked arrays, will make your life easier I feel
16:27:04krux02I actually tested it already earlier and got a compile error with ambiguety, but propably there was a typo somewhere
16:27:23krux02what is unchecked arrays?
16:27:31krux02is it doing what I want to do?
16:27:51coffeepotunchecked arrays are basically arrays that don't check length IIRC
16:27:59coffeepotcompatible with C
16:28:06filwitcoffeepot: yep, so much easier.. plus using CArray[T] gives you more information about what's going on with the structure
16:28:29krux02so they are called CArray[T]?
16:28:43coffeepotexcept you can use [] to access them and it automatically does the pointer arith for you based on the type size
16:28:43filwityou have to define it like I showed
16:29:08coffeepotas filwit said, first define the type: type CArray{.unchecked.}[T] = array[1,T]
16:29:20krux02can you give me a link to an example or usage?
16:29:31filwitkrux02: sure, one sec
16:30:34coffeepotthis is how i do it in odbc, where i need to be able to cast to different types for the same data block:
16:30:37coffeepottype UncheckedArray {.unchecked.} [t] = array[0,t]
16:30:47coffeepottype SQLByteArrayUC = ptr UncheckedArray[byte]
16:30:57coffeepottype Utf16ArrayUC = ptr UncheckedArray[Utf16Char]
16:31:17coffeepotthen I can simply cast[SQLByteArrayUC](buffer) for example
16:31:26coffeepotwhere buffer is a plain pointer
16:31:42coffeepotthen it can be used like an array: for idx in 0..<count: result.add(sbuf[idx])
16:32:18*zepolen quit (Read error: Connection reset by peer)
16:32:35krux02coffeepot: thanks a lot, I will introduce it in my codebase
16:32:54krux02even though my code definitively works
16:33:18coffeepotthanks relayed to filwit :)
16:33:57coffeepotit's great you got it working, but it'll be easier to work with using unchecked arrays
16:34:10*junw_ quit (Ping timeout: 240 seconds)
16:34:12filwitoh wasn't paying attention, looks like coffeepot showed you... I'll finish my gist for future reference I support
16:34:54*zepolen joined #nim
16:34:57coffeepotit's probably easier to read in a gist to be fair
16:35:17*junw_ joined #nim
16:36:38filwithttps://gist.github.com/PhilipWitte/b4c8188287175cf99338
16:36:45filwituntested
16:37:29filwitwhoops.. see there's bug in the top version (didn't dereference the 'ptr int').. but it's way harder to catch
16:37:58filwitfixed
16:39:11*arnetheduck quit (Ping timeout: 264 seconds)
16:43:20*endragor_ joined #nim
16:44:54*zepolen quit ()
16:45:30coffeepotHere's my gist too that shows how you can use unchecked arrays to treat the same buffer as different typed (and type checked) arrays: https://gist.github.com/coffeepots/fe582c473aa3c9b64f4f
16:45:59coffeepotreally handy when working with C where you get a pointer and maybe a type id but you want to use Nim's strong typing
16:46:15*endragor quit (Ping timeout: 240 seconds)
16:46:49filwitheh yeah, that's a pretty cool trick too
16:46:51coffeepotuh, where it says utf16 in the comment... ignore that, I meant int :)
16:47:26*endragor_ quit (Ping timeout: 240 seconds)
16:50:11coffeepotyeah it was also really handy when I was fetching widechar strings into a buffer and being able to echo out the array buffer as bytes, chars, ints, or utf16! :D
16:50:19coffeepotfor debugging I mean
16:51:20filwiti just really like the ability to declare a C-Wrapper which is more descriptive than the actual C code, lol
16:52:14coffeepotyes definitely, at first I was in cast hell till I was told about this. Suddenly writing for C becomes pretty much normal Nim :)
16:52:30filwitusing CArray[] tells you what's going on with the memory, and governs how you access it.. using C/C++ directly you have to read the docs to be sure
16:53:25filwityeah same... I was having trouble debugging my Assimp wrapper until I switched over to CArray.. then my life became so much easier
16:53:58coffeepotyeah and as it's type checked you don't have to worry about a lot of common errors that'd happen with pointers. Although still room for errors reading past the end of the buffer, but l'm sure it'd be simple to handle that too with a bit of thought
16:54:51coffeepothandle it as in wrap the length properly. Maybe it'd be worth writing an actual C array wrapper that handles it all in a neat package
16:54:57coffeepotit'd be tiny though!
16:56:16filwityes, about that: in your wrapper you can simply not expose the array directly, and make an access function which asserts bounds checking (against the structures other size property, etc)... which means you can make zero-overhead (in release) C wrappers in Nim which are pretty very safe
16:56:47filwiteh.. you just said pretty much the same thing, whoops
16:56:54*filcuc quit (Read error: Connection reset by peer)
16:57:17filwitbut yeah, that's my plan for the 2 wrappers I have (don't currently do that though)
17:00:18coffeepotmaybe we could have a c interop module with handy stuff like this
17:00:34coffeepoti'd be interested in such a wrapper, just to code prettify!
17:01:08*Varriount quit (Disconnected by services)
17:01:08*Varriount_ joined #nim
17:01:28filwityeah, IMO (and this was brought up the other day on #nim) the unsafe features of system.nim (alloc/free/etc) should be split into an 'unsafe.nim' where you could also add types/utilities like that
17:02:01filwitAraq said nobody liked it when unsigned was split, but I think that's a completely different situation
17:02:07coffeepothmm interesting
17:02:41coffeepotpersonally I wouldn't have a problem with that, as when I'm doing alloc0 et al I'll probably want to use lots of unsafe stuff
17:03:17filwitmoving unsafe features out of system make it more clear what was unsafe, and allow for people to use the 'from unsafe import nil' thing to enforce the use of 'unsafe.whatever' throughout a module
17:03:34krux02Araq also said once, that unsafe in another language that I do not remember resulted in theat basically every module imported unsafe in the beginning and because of that he is not too much of a fan of an unsafe package
17:04:20filwiti don't see how that could possibly be the case.. the majority of your code does not rely on the unsafe features of system.nim... not directly at least.
17:05:24filwitbesides.. the naming stuff with the unsafe features needs to be unified anyways... we have 'createU' for uninitialized memory, but then 'alloc0' instead of 'allocU'
17:05:26krux02by the way, what is the easiest way to share procs between two types, that do not use ref types?
17:05:59coffeepotkrux02: just use a bar to separate them
17:06:08coffeepotproc a(int | bool) =
17:06:24krux02coffeepot, that seems to be fair
17:06:28krux02thanks a lot
17:06:33coffeepotproc a(val: int | bool) =
17:06:38coffeepotnp :)
17:06:56krux02can I also do type Foobar = int | bool?
17:07:04filwityes
17:07:10filwitit creates a type class
17:07:13krux02thanks a lot
17:07:15coffeepotpersonally I think | is just the best thing since sliced bread :3 But I think this is just the simplest form of concept?
17:07:30filwityes
17:07:39krux02it is a very restricted form of concept, but I like it
17:08:28filwitthe A|B syntax existed before the 'concept' allowed for more fine-grained type-class definitions
17:08:30coffeepotlol, one of the access procs I use looks like this:
17:08:32coffeepotproc `[]=`*(params: var SQLParams, index: string, data: int|int64|string|bool|float|Time|SQLBinaryData) =
17:08:46coffeepoto_O
17:08:48filwitnice
17:11:45coffeepotfailed my times PR again :(
17:12:00coffeepotprobably timezone related on the assert checks...
17:12:47coffeepotah well, for tomorrow.
17:12:50coffeepotgoodnight everyone :)
17:13:33filwitlater
17:14:00*jaco60 quit (Remote host closed the connection)
17:15:03Arrrrgood night little pot
17:15:44*coffeepot quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client)
17:16:34*jaco60 joined #nim
17:23:00*Arrrr quit (Ping timeout: 250 seconds)
17:23:02krux02I have a question for the | syntax
17:24:09krux02how does it compile? does it precompile all alternatives, or does it work like c++ templates, with lazy initialization?
17:25:17krux02I fear that it might compile like c++ templates which in the end results in very slow compilations, because all mathods that are generic need to be recompiled in every module
17:32:50def-krux02: in general, you can compile with -d:release and look at the resulting C code, easy way to gain insights into how it's implemented
17:35:56*endragor joined #nim
17:36:00filwitkrux02: it's a generic specialization, so yes it works like C++ templates... but remember, Nim's meta-programming features evaluate much faster than C++'s and it produces pure C code, so the performance impact is not comparable
17:37:59filwitkrux02: to be clear, if you have ``foo(x:int|string)`` and you only use ``foo(123)`` then only a version for `int` is built (and all future use of `int` with `foo` refer to that)..
17:40:10*krux02 quit (Ping timeout: 260 seconds)
17:40:47filwitkrux02: Nim's generics procs probably don't need to re-evaluate for every call if that specific version has already been built.. however Nim's `template` might (IDK about that either).. C++ is slow here because of how it includes code I think
17:42:36filwitC++ can't know what has already been built in some other source file (well.. maybe modern C++ compilers can know, IDK).. so it probably has to do much more work..
17:42:53filwitthat said, I don't know much about how the compiler really works here, so don't take my word for it
17:43:39*endragor quit (Remote host closed the connection)
17:43:50filwitbut even if heavy macro/template use in my code (which very well might need to re-eval for every call) my compile times are still only 1-3 seconds
17:44:02filwiteven with*
17:46:29*endragor joined #nim
17:52:10*toaoMgeorge joined #nim
17:58:23*brson joined #nim
18:01:12*toaoMgeorge quit (Read error: Connection reset by peer)
18:07:35*yglukhov joined #nim
18:11:48*yglukhov quit (Ping timeout: 248 seconds)
18:15:53*yglukhov joined #nim
18:26:32Araqyglukhov: meh, maybe if you give it a better name
18:26:55Araqor even better let's use the existing --define mechanism for it
18:27:19Araqwhen defined(foo, "value1")
18:29:39*Dildosan joined #nim
18:32:43yglukhovAraq: err, how do i get the value if i dont know what to expect?
18:33:37Araqhmm good question
18:34:01yglukhovwell, actually, nevermind really. beavause staticExec("echo $myvar") works smoothly =)
18:34:01*toaoMgeorge joined #nim
18:34:25Araqno, use getEnv in a 'static' block instead
18:34:33yglukhovwhat about js?
18:34:38Araqyour way doesn't work on windows
18:35:03yglukhovyes it does with when defined(windows): staticExec("echo %myvar%")
18:35:04yglukhov=)
18:36:02yglukhovah, but js doesnt define windows...
18:36:21Araqsince I hate environment vars I shall give you system.definedValue
18:36:40yglukhovyay! thats a small victory! :DD
18:37:24Araqnow somebody needs to fix my gc:v2 ...
18:37:51Araqbut oh well, I'll give you guys your "heap dump" tool
18:38:05Araqcannot hurt to find my own bugs, right?
18:38:27Araqany graph format that should be produced?
18:38:36yglukhoverr.. youre not addressing this to me, right?
18:39:07AraqI do
18:39:37Araqproblem is that Graphviz doesn't scale
18:40:07Araqso what else could we use to produce nice output of the heap topology?
18:40:25yglukhovim not sure im following you. i guess i missed some discussion here...
18:41:34Araqwell I'm working on gc:v2 which is the next generation of the GC, fixing the cycle collection and giving it realtime capabilities
18:41:39Araqbut it keeps crashing
18:42:15Araqso I am thinking about a system.visualizeHeap() proc to help me in debugging
18:42:33Araqbut this is generally useful for everybody to find leaks
18:42:46filwitAraq, mind giving me a quick explanation on how you deal with memory mutations on the graph you're checking for cycles incrementally?
18:42:52Araqthe Heap usually has millions of objects though
18:43:00*derka quit (Quit: derka)
18:43:10Araqso I wonder how to output this thing
18:43:31Araqbest would be a tool like graphviz that doesn't fail when the graph is really big
18:43:52Araqfilwit: it's called "tri-color invariant", look it up please
18:43:59filwitk, thanks
18:44:25filwitoh.. i saw some other GC docs (Lua I think) referencing color something and was completely lost..
18:44:40yglukhovdoes the problem occur with cyclic types only? if yes, there should be much less of such..
18:45:24filwityglukhov: it has to be, the ref-counting part of the existing GC is already realtime
18:45:36filwitonly the cyclic scanning is not
18:45:50def-Araq: you can make graphviz worse at layout and get better performance in return
18:46:27def-like here for example: http://stackoverflow.com/questions/10766100/graphviz-dot-very-long-duration-of-generation
18:47:37Araqdef-: it's not just the renderering speed, it also produces images. and image viewers suck, I prefer some tool that can navigate me through the graph
18:48:03ldleworkWhy is my friend getting, c:\users\jon\.nimble\pkgs\perlin-0.3.0\private\simplex.nim(10, 19) Error: cannot 'importc' variable at compile time
18:48:09ldleworkWhen using this module works fine for me?
18:48:24def-Araq: hm, i wrote a tool for that in haskell once, but python is probably more usable: https://github.com/jrfonseca/xdot.py
18:49:16Araqldlework: because his installation misses some files
18:49:18Araqperhaps.
18:49:34Araqwhat about this: https://gephi.org/ ?
18:49:42def-apart from that there are many more interactive viewers, but I've used none of them: http://www.graphviz.org/content/resources
18:50:51Araqok, so .dot seems to be a good format
18:50:56Araqright?
18:51:04Araqgotta go, bbl
18:52:03*mikolalysenko left #nim (#nim)
18:53:09def-it's at least a very common format for graphs. for really big graphs i've seen simple lists of adjacent nodes
18:57:07*Matthias247 joined #nim
19:03:55*jsudlow joined #nim
19:06:33*yglukhov quit (Remote host closed the connection)
19:13:39*derka joined #nim
19:13:53*derka quit (Client Quit)
19:16:10*Senketsu quit (Quit: Leaving)
19:28:42*vendethiel joined #nim
19:31:37*derka joined #nim
19:32:22*Matthias247 quit (Read error: Connection reset by peer)
19:37:11*Senketsu joined #nim
19:42:03jsudlowHey @all... been trying to run the perlin example on .13 for windows and get the following https://gist.github.com/jsudlow/0d18514af15603b4d9ad do you guys think I need some more files that aren't part of the windows build yet?
19:42:42*junw_ quit (Ping timeout: 256 seconds)
19:51:01*endragor quit (Remote host closed the connection)
19:53:27def-jsudlow: looks like the perlin module just has a bug
19:53:44*derka quit (Read error: Connection reset by peer)
19:57:46*derka joined #nim
19:58:00def-jsudlow: ah, try to use the HEAD version of perlin
19:58:31def-jsudlow: it's fixed there: nimble install "perlin@#head"
20:00:16jsudlowdef: ahh I see thx def
20:00:19jsudlowi'll give it a shot!
20:00:36gokrAraq: When you are back I am desperate for some c2nim wisdom - I am so close, but it just doesn't work.
20:00:38def-i also filed an issue at the perlin repo to have a new release, easier that way
20:01:15*saml quit (Ping timeout: 240 seconds)
20:02:38jsudlowdef that worked! I can now get the output from the noise function. You guys are good
20:06:32*nsf quit (Quit: WeeChat 1.4)
20:08:57ldleworkjsudlow: nice!
20:11:31*saml joined #nim
20:12:57*yglukhov joined #nim
20:29:04*tinAndi joined #nim
20:48:19*derka quit (Quit: derka)
21:09:02*BitPuffin quit (Ping timeout: 272 seconds)
21:14:11*irrequietus joined #nim
21:16:11*derka joined #nim
21:18:35*Dildosan quit (Quit: Leaving)
21:20:41*desophos joined #nim
21:21:54*mat4 joined #nim
21:21:58mat4hello
21:24:51*JStoker quit (Quit: JStoker is gone :()
21:25:23*JStoker joined #nim
21:25:36gokrmat4: heya
21:25:45mat4hi gokr
21:26:25gokrI have a blinking nRF52 dev board on my chest here. Not Nim yet though, just the regular blinky.
21:29:23mat4doe you mean the one from Nordic Semiconductor ?
21:29:27gokryeah
21:30:26gokrI gotta say, these companies are not that structured when it comes to SDKs, downloads, instructions etc. So easy to get completely lost.
21:31:01gokrFor example, an SDK ought to be complete IMHO. Having to download 3-4 pieces from different places sucks.
21:33:19mat4I agree, however this is sadly not uncommon
21:35:18*mischa-masha joined #nim
21:36:35mat4the nRF52832 SoC seem to be easy programmable in assembler by the way
21:38:37*JStoker quit (Quit: JStoker is gone :()
21:39:08*JStoker joined #nim
21:42:54*idan_ joined #nim
21:49:22gokrmat4: It looks quite impressive on paper.
21:54:59mat4looks good for auto controlling your home :)
22:02:35*brson quit (Ping timeout: 240 seconds)
22:03:30mat4with a smartfone
22:03:50mat4^smartphone
22:03:54*tinAndi quit (Quit: ChatZilla 0.9.92 [Firefox 43.0.4/20160105164030])
22:10:41*brson joined #nim
22:18:26*nsf joined #nim
22:21:30*mat4 quit (Quit: Verlassend)
22:23:27*BlaXpirit quit (Quit: Bye)
22:23:42*BlaXpirit joined #nim
22:24:48*idan_ quit (Remote host closed the connection)
22:25:14*Trustable quit (Remote host closed the connection)
22:29:17*Matthias247 joined #nim
22:33:21*FreezerburnV joined #nim
22:34:05*mischa-masha quit (Quit: Page closed)
22:41:21*junw joined #nim
22:44:40*allan0 quit (Ping timeout: 245 seconds)
22:45:26*allan0 joined #nim
22:47:05*Demon_Fox joined #nim
22:49:39Araqgokr: I'm here
23:01:14*irrequietus quit ()
23:01:14*yglukhov quit (Read error: Connection reset by peer)
23:01:49*yglukhov joined #nim
23:04:09*yglukhov_ joined #nim
23:04:09*yglukhov quit (Read error: Connection reset by peer)
23:17:46gokrAraq: I kinda ran out of steam with c2nim.
23:20:57Araqyes?
23:21:23gokrI manage to compile and link "blinky" (blinks a led) - it seems to be just fine (nm report no unresolved names etc)
23:21:38gokrBut it just will not run. I am compiling via cpp here, since Arduino libs are cpp.
23:21:59gokrIf I replace the generated blink.cpp with a handwritten original blink.cpp - then it works.
23:22:22gokrAnd staring at these two files doesn't make me wiser.
23:22:23*mnemonikk joined #nim
23:22:23*mnemonikk quit (Changing host)
23:22:23*mnemonikk joined #nim
23:22:29Araqgist them
23:22:35gokrgive me a min
23:24:01*gour quit (Quit: WeeChat 1.4)
23:29:12*ludocode quit (Ping timeout: 250 seconds)
23:31:06*junw_ joined #nim
23:31:58*ludocode joined #nim
23:33:15*derka quit (Quit: derka)
23:34:50*junw quit (Ping timeout: 260 seconds)
23:38:50*vendethiel quit (Ping timeout: 245 seconds)
23:43:10*lompik joined #nim
23:43:23*ludocode quit (Ping timeout: 264 seconds)
23:44:04*derka joined #nim
23:46:41*ludocode joined #nim
23:47:46*vendethiel joined #nim
23:52:30*yglukhov_ quit (Remote host closed the connection)
23:54:25*derka quit (Ping timeout: 240 seconds)
23:57:56*yglukhov joined #nim
23:59:11*derka joined #nim