<< 21-02-2016 >>

00:03:22Varriountonionhammer: Be back in a bit, going to eat dinner.
00:12:25*toaoMgeorge quit (Ping timeout: 255 seconds)
00:12:36*toaoMgeorge joined #nim
00:20:11Varriountonionhammer: Could you put in some print statements in nimlime_core/mixins.py , in the is_enabled method of the NimLimeMixin class?
00:30:26onionhammerafter dinner sure
01:04:17*Amrykid quit (Changing host)
01:04:17*Amrykid joined #nim
01:56:51*toaoMgeorge quit (Ping timeout: 248 seconds)
01:57:44*toaoMgeorge joined #nim
02:15:33*askatasuna quit (Ping timeout: 240 seconds)
02:24:16*toaoMgeorge quit (Ping timeout: 255 seconds)
02:29:59*lokien_ quit (Quit: Connection closed for inactivity)
02:38:25ldleworkIt'd be neat if the marhsal lib could accept json objects
02:51:50ldleworkoops
02:51:52ldleworkduh
02:53:29ldleworkwait no that'd still be nice yeah
03:16:02*Demon_Fox joined #nim
03:25:14*Kingsquee quit (Quit: https://i.imgur.com/qicT3GK.gif)
03:25:52*Kingsquee joined #nim
03:37:56*vikaton joined #nim
03:50:17*Kingsquee quit (Read error: Connection reset by peer)
04:02:30*dthrvr quit (Ping timeout: 250 seconds)
04:04:09*dthrvr joined #nim
04:08:30*askatasuna joined #nim
04:23:33*brson quit (Ping timeout: 240 seconds)
04:27:10*mahasamoot quit (Remote host closed the connection)
04:29:44*Kingsquee joined #nim
04:31:58*dthrvr quit (Ping timeout: 250 seconds)
04:34:59*lompik quit (Ping timeout: 240 seconds)
04:44:47*nande quit (Remote host closed the connection)
04:54:18*pleiosaur quit (Ping timeout: 268 seconds)
04:54:36*am0 joined #nim
04:54:37*pleiosaur joined #nim
04:56:01*thotypous quit (Ping timeout: 240 seconds)
04:58:49*vendethiel joined #nim
04:59:25*dthrvr joined #nim
05:00:28*thotypous joined #nim
05:01:18*vikaton left #nim (#nim)
05:16:36*zepolen quit (Remote host closed the connection)
05:21:51*vendethiel quit (Ping timeout: 244 seconds)
05:24:26*dthrvr quit (Ping timeout: 244 seconds)
05:25:33*dthrvr joined #nim
05:32:35*am0 quit (Quit: Page closed)
05:40:36*brson joined #nim
05:46:22*pilne quit (Quit: Quitting!)
06:02:00*dthrvr quit (Ping timeout: 276 seconds)
06:02:54*dthrvr joined #nim
06:15:10*pregressive joined #nim
06:18:15*dthrvr quit (Ping timeout: 276 seconds)
06:19:15*dthrvr joined #nim
06:27:54*pregressive quit (Remote host closed the connection)
06:29:44*pregressive joined #nim
06:34:43*pregressive quit (Ping timeout: 248 seconds)
06:49:12*pregressive joined #nim
06:54:03*pregressive quit (Ping timeout: 240 seconds)
07:01:47*AFedorov joined #nim
07:08:53*alexsystemf quit (Read error: Connection reset by peer)
07:09:16*alexsystemf joined #nim
07:09:55*dthrvr quit (Ping timeout: 248 seconds)
07:10:26*AFedorov quit (Ping timeout: 252 seconds)
07:12:07*dthrvr joined #nim
07:14:43*nc-x joined #nim
07:15:22*nc-x quit (Client Quit)
07:16:45*dthrvr quit (Ping timeout: 276 seconds)
07:19:29*dthrvr joined #nim
07:28:27*zepolen joined #nim
07:33:05*zepolen quit (Ping timeout: 244 seconds)
07:41:04*BitPuffin|osx quit (Ping timeout: 255 seconds)
07:41:05*lokien_ joined #nim
08:08:33*dthrvr quit (Ping timeout: 240 seconds)
08:10:50*dthrvr joined #nim
08:33:27*dthrvr quit (Ping timeout: 276 seconds)
08:37:07*Matthias247 joined #nim
08:39:59*brson quit (Ping timeout: 240 seconds)
08:41:01*dthrvr joined #nim
08:47:13*dthrvr quit (Ping timeout: 255 seconds)
08:47:54*dthrvr joined #nim
08:50:15*pregressive joined #nim
08:55:33*pregressive quit (Ping timeout: 276 seconds)
08:56:40*dthrvr quit (Ping timeout: 255 seconds)
08:59:01*dthrvr joined #nim
09:10:36*toaoMgeorge joined #nim
09:14:30r-kuwasnt there a way to limit what types generic T can take? or maybe even allow multiple types for proc call without generic?
09:15:07ldleworkyes they are called concepts
09:16:58r-kukk will look it up. but i dont think thats what i have in mind. damn memory
09:19:00r-kuoh its like proc test(a: int|float, b: int)
09:37:42*Kingsquee quit (Quit: https://i.imgur.com/qicT3GK.gif)
09:38:17*Kingsquee joined #nim
09:44:56*yglukhov joined #nim
09:48:25*yglukhov quit (Remote host closed the connection)
09:51:39*vendethiel joined #nim
10:03:09*endragor joined #nim
10:13:16*M-max quit (Remote host closed the connection)
10:15:41*tdc quit (Quit: Bye bye)
10:15:59*vendethiel quit (Ping timeout: 240 seconds)
10:16:59*M-max joined #nim
10:17:45*yglukhov joined #nim
10:22:32*arnetheduck quit (Ping timeout: 250 seconds)
10:23:00*arnetheduck joined #nim
10:28:44*lokien joined #nim
10:35:04*yglukhov quit (Remote host closed the connection)
10:41:30*yglukhov joined #nim
10:41:39*filwit joined #nim
10:42:51filwit18:55:50 filcuc said: "is there a way to generate a string at compile time unique for a given type T"
10:43:28filwityes, there is (hope you read the logs). Let me make you as gist showing how to do it..
10:46:34*yglukhov quit (Remote host closed the connection)
10:50:53*pregressive joined #nim
10:55:36*pregressive quit (Ping timeout: 244 seconds)
11:03:04*silven quit (Ping timeout: 240 seconds)
11:03:32*silven joined #nim
11:12:06filwitflicuc: https://gist.github.com/PhilipWitte/dd6c670fca3baf573490
11:14:47filwitfilcuc: Note that it doesn't use a string for each type in the map, but rather an int (which I alias as 'ID' just to be clear)
11:22:35*zepolen joined #nim
11:29:29*Demon_Fox quit (Ping timeout: 240 seconds)
11:29:30*Demon_Fox_ joined #nim
11:37:29*Demon_Fox_ is now known as Demon_Fox
11:39:56*vendethiel joined #nim
11:41:27*Demon_Fox quit (Quit: Leaving)
11:45:52*miko__ joined #nim
11:46:09*filwit quit (Quit: Leaving)
11:47:39miko__Hi. Is there a "slice to the end"? something like Haskell "tail"? Right now I use commandLineParams()[slice..paramCount()-1]
11:48:00miko__with slice 0 or 1
11:55:38*filcuc joined #nim
11:55:46*filcuc quit (Client Quit)
12:01:52*vendethiel quit (Ping timeout: 252 seconds)
12:02:25*filcuc joined #nim
12:05:19dom96miko__: [slice .. ^1]
12:05:40miko__Why is it not ^0 ?
12:09:15miko__[3..^3] is a slice from the forth to the third last elment, isn't it?
12:09:17*zepolen quit (Remote host closed the connection)
12:11:22filcucis there a way to create templated singleton
12:12:11filcucso a singleton object that could be customized with a temlpate argument
12:15:18*vendethiel joined #nim
12:16:31*derka joined #nim
12:19:55avsejhi, is it possible to declare function, which returns arrays but without declaring their sizes?
12:21:10filcucavsej: array[0..0, int] {.unchecked.}
12:21:55*yglukhov joined #nim
12:21:57avsejthank you
12:22:27miko__When compiling I get Error: internal error: getSize: tyEmpty
12:22:46miko__"To create a stacktrace, rerun compilation with ./koch temp c <file>"
12:24:04miko__koch is in the koch.nim is in the nim dir. Ah. got It. I should be run there.
12:24:40miko__Anyway, is there anything i can to about this compiler error?
12:24:48*zepolen joined #nim
12:26:48*yglukhov quit (Ping timeout: 276 seconds)
12:26:49*StarBrilliant joined #nim
12:28:36derkaHi Guys
12:30:34Varriountmiko__: Uh, try changing the unchecked array size to something other than an empty range.
12:30:46Varriountderka: Hi
12:32:26lokienhey, do we have any cheat sheets or something? printable references?
12:33:17Varriountlokien: Not really, no.
12:33:25lokienVarriount: too bad :(
12:33:49VarriountThere's the system.nim documentation... but that would be a rather large cheat sheet.
12:34:25miko__This is what is causing the compile-time error, i can't see what's wrong:
12:34:26miko__while (read = i.readBuffer(buf.addr, size)) > 0:
12:34:26miko__ discard stdout.writeBuffer(buf.addr, read)
12:35:04*filcuc quit (Ping timeout: 240 seconds)
12:35:05dom96miko__: you can't assign a variable inside a while loop condition
12:35:21lokienVarriount: some syntax rules/idioms/basic procs. system.nim is way too large :D
12:36:21*vendethiel quit (Ping timeout: 244 seconds)
12:38:08Varriountlokien: Well, I guess we could make something on the Wiki
12:38:25*zepolen quit (Remote host closed the connection)
12:39:38lokienVarriount: smth like that: http://www.ocamlpro.com/files/ocaml-lang.pdf
12:39:49lokienVarriount: sweet :D
12:39:59*lokien_ quit (Quit: Connection closed for inactivity)
12:42:55miko__dom96, oh i see. Im still thing C.
12:43:48miko__*thinking. I'm missing do-while loops aswell. Does this look like idomatic nim? http://pastebin.com/Z1vrCigg
12:43:49dom96miko__: please report it on github though, an "internal error" is a compiler crash.
12:44:11*zepolen joined #nim
12:44:30*zepolen quit (Remote host closed the connection)
12:44:42dom96miko__: You shouldn't use 'addr' unless you've got a good reason to do so
12:44:50dom96it's not memory safe
12:46:05miko__isn't is aslong as I don't do any aritmetic with it?
12:47:18reactormonkmiko__, the gc has no reign over it.
12:47:55miko__ok.
12:48:16reactormonkaka the object might disappear because addr doesn't count as a reference
12:51:49*pregressive joined #nim
12:52:24derkadom96 how are you doing ? I only have 3 chapters of your book :(
12:53:29dom96derka: Chapter 4 should be ready soon, it's up to my publisher now.
12:53:37derkacoolll
12:56:03*pregressive quit (Ping timeout: 248 seconds)
13:00:51*zepolen joined #nim
13:02:39*Kingsquee quit (Quit: https://i.imgur.com/qicT3GK.gif)
13:08:55r-kui suppose ill be slapped for unorthodox stuff i have done but.. here it is.. https://github.com/r-ku/nim-ustring
13:10:17miko__I'm not noticing a slowdown for readBytes from readBuffer.
13:13:44*filcuc joined #nim
13:27:05federico3any suggestion for a simple way to do some HTML templating? Essentially I need to do a for loop to repeat some lines in a string.
13:30:10*toaoMgeorge quit (Ping timeout: 250 seconds)
13:30:11federico3also, is anybody able to help with https://github.com/nim-lang/Nim/issues/3823 ?
13:30:51*toaoMgeorge joined #nim
13:34:23*bamorim joined #nim
13:36:52federico3http://nim-lang.org/docs/filters.html#available-filters-stdtmpl-filter <--- this answers my question, it seems
13:40:20*vendethiel joined #nim
13:45:46def-federico3: i'm taking a look
13:48:35*endragor quit (Remote host closed the connection)
13:52:57def-federico3: ok, should be fixed on devel now for the next release
13:53:33def-federico3: you can test by creating a release with ./koch csource && ./koch xz
13:53:41federico3def-: thank you!
14:05:51*darkf quit (Quit: Leaving)
14:23:31*vendethiel quit (Ping timeout: 248 seconds)
14:26:08*lokien quit (Quit: Leaving)
14:26:52*lokien_ joined #nim
14:26:58*lompik joined #nim
14:40:23*vendethiel joined #nim
14:41:47*pilne joined #nim
14:52:37*pregressive joined #nim
14:54:00*PMunch joined #nim
14:57:36*pregressive quit (Ping timeout: 276 seconds)
15:01:59*vendethiel quit (Ping timeout: 240 seconds)
15:19:53*vendethiel joined #nim
15:34:27*arnetheduck quit (Ping timeout: 248 seconds)
15:37:18*BitPuffin|osx joined #nim
15:37:29*derka quit (Quit: derka)
15:44:16filcuci'm getting a weird behaviour when passing object or tuples to C
15:44:23filcucbasically i don't get the same values from the C library
15:44:27filcuc:(
15:47:55*yglukhov joined #nim
15:48:49def-filcuc: different types maybe? int is different in C and Nim
15:48:56*derka joined #nim
15:49:39filcucdef-: i'm using cint everywhere :(
15:50:11def-got a minimal example?
15:51:08*derka quit (Client Quit)
15:52:03*yglukhov quit (Ping timeout: 248 seconds)
15:52:46filcuci'm still investigating..howerver could i assume object == C struct
15:52:57filcucand same memory layout?
15:53:14filcucgiven that i use cint, cstring and so on :)
15:53:23def-and it's non-inheritable, i guess
15:53:29def-check the resulting c code
15:55:30def-maybe it's because of how you pass the pointer to it
15:58:52filcucdef-: i'm passing it by value
15:59:10def-i guess that's the reason
15:59:43filcucin the C code i've void myFunc(MyStruct c)
16:00:02filcucshould i pass it by reference?
16:00:05filcuc(pointer)
16:00:09def-try, I guess so
16:03:23filcucdef-: the struct in the generated C code seems right
16:03:54*Trustable joined #nim
16:06:11filcucdef-: ok seems that the generated code pass the struct by reference
16:06:24filcucdef-: even if i didn't told it to do so
16:06:39filcucmy c binding is as follow: proc dos_qdeclarative_qmlregistertype*(value: DosQmlRegisterType) {.cdecl, importc.}
16:07:02filcucand the struct is DosQmlRegisterType* = object .....
16:07:30filcucbut the invokation in the C code is dos_qdeclarative_qmlregistertype((&dosqmlregistertype));
16:08:46filcucdef-: :| do you think i'm doing something wrong here? or am i missing something?
16:10:02def-I would try a ptr
16:11:33filcucdef-: no ok if i change my C library and Nim binding with pointers seems to work
16:11:47filcucdef-: but it's not what i wanted
16:12:00filcucdef-: i mean, i wanted a pass by value
16:14:03def-use {.byval.}
16:14:22def-oh wait, does that even exist?
16:14:30filcuc:)
16:14:32def-I found this thread at least: http://forum.nim-lang.org/t/1908
16:15:44filcucdef-: seems like a propasol though
16:17:53filcucdef-: maybe this http://nim-lang.org/docs/manual.html#foreign-function-interface-bycopy-pragma
16:17:57filcuci'll give it a try
16:21:08filcucdef-: ok now it works
16:21:45filcucdef-: however it's a little weird because that applies it everywhere
16:21:57filcucdef-: and maybe it's not the case
16:22:47filcucdef-: i would like that the compiler respect the semantics i decided in the C binded function
16:25:22filcucdef-: i understand also that this prevent compiler optimizations. In fact i would suggest to force this behaviour only on fuctions marked {.importc.}
16:26:53def-filcuc: from what I understand even in C it's not recommended to pass structs by value usually
16:28:25filcucfilcuc: really? i didn't know that
16:28:28filcucdef-:
16:28:55filcucdef-: i'll try to google about it
16:49:24*toaoMgeorge quit (Ping timeout: 276 seconds)
16:49:44*boopsiesisaway is now known as boopsies
16:49:48*toaoMgeorge joined #nim
16:53:43*derka joined #nim
16:58:19*derka quit (Ping timeout: 252 seconds)
17:01:27*derka joined #nim
17:23:04*derka_ joined #nim
17:24:16*derka quit (Ping timeout: 255 seconds)
17:24:16*derka_ is now known as derka
17:30:14*perturbation joined #nim
17:35:49*yglukhov joined #nim
17:37:53filcucwhat is the better way to map a const * in a nim to c interface
17:38:04filcucright now i'm using just ptr T
17:38:14filcucbut i don't think that there's a const ptr T
17:40:03*yglukhov quit (Ping timeout: 240 seconds)
17:50:38avsejis it possible to write reverse range in for clause?
17:50:54avsejand with custom step
18:01:15*filcuc quit (Quit: Konversation terminated!)
18:04:15Araqavsej: sure look at countdown
18:04:28avsejthanks
18:10:29*vendethiel- joined #nim
18:11:28*vendethiel quit (Ping timeout: 252 seconds)
18:12:01*PMunch quit (Ping timeout: 252 seconds)
18:19:37*Varriount screeches like a harpy and descends on r-ku
18:22:01*r-ku ducks
18:23:29r-kuill make it work in a weird way like nim strings do by default. still gonna have -d:ustringPythonic for normal lazy people though
18:23:47VarriountDarn. I just sharpened my claws too.
18:23:59*PMunch joined #nim
18:24:30*lokien_ quit ()
18:24:41Varriountr-ku: I was going to ask - if you're going to break convention, why not make them immutable as well?
18:25:10r-kumost of funcs are immutable though
18:25:29r-ku[]= is only mutable thing i think
18:30:57*lokien_ joined #nim
18:32:08Varriountr-ku: But assignments will still copy.
18:32:32*lokien_ quit (Client Quit)
18:32:53Varriountr-ku: You know the reasoning behind inclusive slices, right?
18:33:08*lokien joined #nim
18:33:11*brson joined #nim
18:33:21r-kui dont think i know
18:35:30Varriountr-ku: If Nim had Python's indexing, how would you get the last element of an array indexed by an enum?
18:36:04Varriountr-ku: array[char, low(MyEnum)..high(MyEnum)]
18:36:20r-kulen - 1?
18:36:51Varriountr-ku: Doesn't work, as the index must be a member of MyEnum
18:37:30r-kuso this thing has to be fixed. not everything else to accommodate this one case
18:38:43Varriountr-ku: Well, it applies to ints or each size too, just not as obviously.
18:39:16Varriountr-ku: How would you capture the element at high(int) in an array slice?
18:39:50VarriountI can't imagine any workaround that wouldn't be a kludge of some sort.
18:41:05r-kua = "123"; a[1:] results in "23". lack of second slice param means "take rest of the thing" in py. idk what works pretty well.
18:42:47Varriountr-ku: Hm. Perhaps. However that cannot be done with actual slice objects. Remember that 1..2 is actually a constructor for an object.
18:43:54VarriountOf course, you could have that subscript syntax be non-inclusive, and the slice syntax be inclusive, but that brings some complication into the mix with regards to conversion
18:44:44*pregressive joined #nim
18:44:45r-kuyeah.. i know it doesnt quite fit into nim. procs work for slicing though. can make them as perverted as i like. im ok with that for my personal needs heh.
18:52:55*toaoMgeorge quit (Ping timeout: 255 seconds)
19:02:46r-kumaking proc splice*(x: ustring, startPos: int, endPos: int, r: SomeText): ustring use inclusive ranges is problematic though
19:03:25*pregressive quit (Remote host closed the connection)
19:03:37r-kubah head aint working any more, cant put my thoughts into something coherent that would make sense
19:03:52r-kuguess ill check it tomorrow. gn
19:06:06*brson quit (Quit: leaving)
19:09:32avsejcan anybody explain me why this code does not compile? https://gist.github.com/avsej/7f7662862bcdfe857656
19:10:27def-avsej: b.buf[index/8]
19:10:57avsejof course I meant b.buf, but still does not work
19:11:12def-index div 8
19:11:22def-is float division
19:11:34def-but the error message is strange
19:11:53Varriountdef-, avsej: It's because you're trying to subscript a ref type
19:12:16avsejVarriount, def- `div` fixed it
19:12:18avsejthanks
19:12:45Varriountdef-: Darn you, keyboard ninja!
19:14:34avsejyeah, def- would be nice if it also mention resolved types too :) if I saw 'float' I would not ask :)
19:19:28Varriountavsej: The error I got (with just b[index/8]) is confusing partially because the error is being thrown in the part of the compiler that checks dereferences (I think).
19:28:11*toaoMgeorge joined #nim
19:56:57*Matthias247 quit (Quit: Matthias247)
19:58:30*Matthias247 joined #nim
20:00:19avsejfor example I have enum, when Open = 0x01, and Close = 0x02. How I would convert int to this enum values properly?
20:01:23def-avsej: what's the type of the enum?
20:02:27def-avsej: if it's Foo, you can do Foo(2)
20:02:39def-that's a type conversion in Nim
20:03:13avsejthanks work
20:19:49*yglukhov joined #nim
20:20:35*Ryozuki joined #nim
20:24:03*yglukhov quit (Ping timeout: 248 seconds)
20:25:22*awsteele joined #nim
20:27:35*awsteele quit (Client Quit)
20:27:47*Ryozuki quit (Quit: Page closed)
20:35:49*lokien_ joined #nim
20:43:29ldleworkDo people here use einheit over the unittest stdlib?
20:44:07dom96einheit? Never heard of it
20:44:19ldleworkhttps://github.com/jyapayne/einheit/blob/master/test.nim
20:47:28ldleworkdom96: ^
20:48:01dom96Looks pretty similar to unittest
20:48:07avsejis there something like %v from golang or #inspect from ruby, in nim? I just want to dump some internal state of the object
20:48:15dom96avsej: repr()
20:48:22avsejok
20:50:36ldleworkdom96: dunno, the combination of aggregating test suites and the report output.. https://github.com/jyapayne/einheit
20:57:28ldleworkAraq: did you ever figure out what was going on with that VM memory corruption thing?
21:05:41ldleworkI wonder, is anything like python's test coverage possible with Nim?
21:07:47*derka quit (Quit: derka)
21:22:35*nande joined #nim
21:29:19ldleworksometimes I have a Table
21:29:25ldleworkand I try to use the keys proc on it
21:29:41ldleworkError: attempting to call undeclared routine: 'keys'
21:29:45ldleworkI imported the tables module
21:29:55ldleworkecho'ing the type of the thing I'm calling it on, is a Table
21:29:57ldleworkI just don't get it
21:30:38ldleworkI don't even get an error doing "from tables import keys"
21:30:44ldleworkgrrrr
21:31:30ldleworkhow can it be undeclared?1
21:32:18ldleworkhttps://gist.github.com/dustinlacewell/47da8800a04e815376f4
21:32:29ldleworkWhy is keys an undeclared field?!
21:32:51ldleworkor routine if you write it that way
21:33:00*ldlework pokes dom96 any idea?
21:34:26dom96Where do you see a keys proc?
21:34:32dom96ldlework: ^
21:34:54ldleworkimport tables?
21:35:37ldleworkchanging it from `self.pack.keys` to `keys(self.pack)` just hcnages the error to undeclared routine
21:36:33ldleworkdom96: am I crazy?
21:36:57dom96once again
21:37:00dom96where do you see it?
21:37:10dom96Look at the documentation for the tables module
21:37:11ldleworkdom96: its imported
21:37:22dom96`keys` is an iterator
21:37:30dom96there is no `keys` proc
21:37:31ldleworkiterator keys[A, B](t: Table[A, B]): A
21:37:33ldleworkiterates over any key in the table
21:37:35ldleworkugh
21:37:45ldleworkthis is a horrrrrible error
21:38:18dom96agreed. Report it on Github please.
21:38:59ldleworkdom96: what's the proper way to get the keys as a sequence again?
21:39:59dom96ldlework: you can convert the `keys` iterator into a sequence using the `toSeq` proc in sequtils module.
21:40:24ldleworkdom96: it still says undeclared field though
21:40:36ldleworkand routine, I can't seem to produce the iterator..
21:41:00dom96toSeq(...keys) doesn't work?
21:41:32ldleworkoh because its a macro I have to explicitly access the iterator from inside the call expr -.-
21:41:36ldleworkjesus
21:42:00ldleworkwhy the hell don't we have first class iterators that can be passed around?
21:42:10dom96we do
21:42:43ldleworkthen why can't I do `let iter = self.pack.keys`
21:42:49ldlework`toSeq(iter)`
21:42:50dom96but they are less efficient than inline iterators
21:43:06dom96so inline is default
21:43:57ldleworkits a wildly inconsistent experience
21:44:11ldlework self.check(toSeq(self.pack.keys) == expected_keys)
21:44:19ldleworktest_packs.nim(58, 31) Error: undeclared field: 'keys'
21:49:02ldleworkdom96: It doesn't work
21:49:16ldleworkthis thing is definitely a Table according to type()
21:49:22ldleworkso I don't get it
21:49:33dom96toSeq(keys(self.pack)) maybe?
21:50:22ldleworkits like tables isn't being imported for some reason
21:50:34ldleworkI tried to iterate over it and just echo the keys
21:50:42ldleworkhttps://gist.github.com/dustinlacewell/05ba56aa57e804bc4e19
21:50:47ldleworkit can't find tables.items
21:50:51ldleworkwtfff
21:51:23dom96did you `from tables import keys`?
21:51:41ldleworkwhy would I need to
21:51:44ldleworkI just "import tables"
21:51:59ldlework self.check(toSeq(self.pack.keys) == expected_keys)
21:51:59dom96No, I mean if you /only/ did that then that would cause the error.
21:52:00ldlework for key in self.pack.keys:
21:52:02ldlework echo key
21:52:04ldleworkno
21:52:07ldleworkif I comment out the first line
21:52:10ldleworkthe for-loop works
21:52:12ldleworklol
21:52:14ldleworkhow is that possible
21:52:16ldleworkso buggy
21:52:57dom96try moving it out of `testSuite`
21:53:05dom96guessing that is to blame
21:53:47ldleworkso you think it'll work with the normal unit test
21:53:50ldleworklibrary
21:53:58ldleworkthough can't do the same thing
21:54:34dom96no
21:54:43dom96It's likely it will fail too actually
21:54:50ldlework let
21:54:53ldlework expected_keys = @["foo", "bar", "new"]
21:54:54ldlework pack = self.pack
21:54:56ldlework k = toSeq(pack.keys)
21:54:58ldlework self.check(k == expected_keys)
21:55:00ldlework for key in self.pack.keys:
21:55:02ldlework echo key
21:55:04ldleworkthis works
21:55:06ldleworkwhat a shitshow
21:55:09dom96But would be nice if you checked to see if it works outside the testSuite
21:55:10ldleworkuniversal call syntax was a really bad idea :/
21:55:55ldleworkdom96: I can't just magically test it outside the testSuite
21:56:01ldleworkthe table is on self, inside the test suite
21:56:42dom96okay, then testSuite does some pretty interesting stuff.
21:57:10ldleworkwhat?
21:57:18ldleworkIts like
21:57:26ldleworkWe're talking about how something doesn't work inside a method of a class
21:57:28ldleworkand you're like
21:57:34ldlework"Oh forget about the entire state of the program"
21:57:40ldlework"just run that bit of code at module level"
21:57:46ldlework"oh you can't? That class must do something wierd"
21:57:48ldleworkno...
21:58:08ldleworkits called program state. Are you wanting me to just create a table at module level and see if I can access its keys?
21:58:13ldleworkor this table?
21:58:14dom96yes
21:58:48ldleworkyes it works like a charm outside
21:59:39ldleworkbut it looks like it only fails inside of self.check()
22:01:00dom96In that case it might actually work better with unittest
22:01:31dom96But please submit a bug report to the Nim repo.
22:04:10dom96alternatively, if you want reliability: just use when isMainModule + doAssert :)
22:07:14ldleworkI also want nice reporting and such
22:07:40ldleworkbut it looks like this thing is pretty buggy
22:08:43*yglukhov joined #nim
22:08:47ldleworkBut it works okay as long as you don't actually use any expressions in self.check()
22:08:53ldleworkjust compare simple variables
22:11:13*Trustable quit (Remote host closed the connection)
22:12:06ldleworkdom96: it seems you can only test the public interfaces of things in Nim ..
22:12:51*yglukhov quit (Ping timeout: 248 seconds)
22:17:01ldleworkdom96: know what I mean?
22:17:06ldleworknot sure what to do about that
22:17:17dom96not really?
22:17:30ldleworkIf you stick all your test code into each module...
22:17:36ldleworkbut other than that how can you test private interfaces?
22:18:21ldleworkyou can't import them so I dunno why you don't know what I mean
22:22:04def-ldlework: or include the module instead of importing it if you want to access internals
22:22:43def-not sure if that's a good idea though. aren't you supposed to test exactly the public part of a module? who cares how it works internally?
22:26:05ldlework...
22:26:16ldleworkyou want to 100% unit test every thing
22:26:21ldleworkideally
22:26:35ldleworkits not always possible but no I've never heard "only test the public interface" before
22:27:17ldleworkincluding the module seems so hacky
22:28:03ldleworkit basically doesn't work with relative imports
22:28:09ldleworkwhich all my code uses
22:28:17ldleworkso that it can work with the documentation generator probably
22:28:22ldleworkproperly*
22:29:54*ldlework goes and plays video games instead.
22:31:04dom96I heard that. You are meant to only test the public parts of a module.
22:31:35dom96http://stackoverflow.com/questions/105007/should-i-test-private-methods-or-only-public-ones
22:32:08ldleworkThe reasoning makes zero sense at all
22:32:26ldleworkTesting the implementation has nothing to do with "breaking encapsulation" or the contract when someone is actually using the code.
22:32:41ldleworkYou unit test code so that if the impelmentation ever changes it doesn't change the behavior
22:32:54ldleworkYou want to be certain that's true for the entire implementation don't you?
22:33:14dom96So how would you do it in other languages?
22:33:39dom96I've never heard of any language allowing you to break encapsulation just so that you can test everything
22:33:42ldleworkI don't know I come from Python where we test all of our units.
22:35:00dom96Your public procedures use your private ones, by testing them you are indirectly testing the private implementation.
22:35:06dom96That should be enough.
22:35:09ldleworkThe second answer in your link agrees with me, btw.
22:35:30ldleworkand explains why it isn't enough
22:36:00ldleworkYay, I know that the very top-level function of my program no longer produces the right result and I have no idea where in the implementation causes it.
22:36:03ldleworkIs not enough.
22:36:28ldleworkGuess I'll just put tests in every file...
22:36:32def-ldlework: I guess you can add your tests at the bottom of the file, "when isMainModule" style
22:37:00def-yeah, that's probably the most reasonable way. because if you want your tests to depend on the internals, they can also be put into the same file
22:37:05ldlework"reasonable"
22:37:28ldleworkits not well thought out
22:38:02dom96ldlework: You're free to make all your procs public and prefix them with 'private' or something if you want :P
22:38:12ldleworkIn my experience test code is far longer than the code it tests
22:38:12dom96*prefix the "private" ones
22:38:13ldleworkFar longer
22:38:14def-ldlework: another idea is to put the test for each proc right after the proc: https://github.com/petermora/nimLazy/blob/master/lazy.nim
22:38:29ldleworkSo now all my modules are more than 100% larger
22:38:49dom96Python cheats here by not having any real encapsulation
22:39:14dom96In Java you would use reflection to test private methods which sounds horrible.
22:39:33ldleworkI feel like we should be able to use the pragma system for stuff like this
22:39:41def-ldlework: if you want to keep your module small, put the test in a separate file in the same directory. or we could fix that the compiler does relative imports properly with included files
22:39:45ldlework"I'm a testing module. Yes, its fine for me to import this..."
22:40:07ldleworkSeems way more elegant
22:40:14dom96Then `include` sounds like a good solution
22:40:40def-ldlework: I think a testing module should not use any magic. It should use the module it tests in exactly the same way as the user will use it.
22:40:53ldleworkif the compiler understood relative imports for included files I guess I would have nothing concrete to complain about
22:41:22ldleworkdef-: sure that's one way to think about how testing should work, okay
22:41:24*darkf joined #nim
22:42:04dom96yeah, there are many module path related issues that need to be fixed.
22:42:16ldlework"making the compiler understand relative imports for included files" sounds like magic to me, but I guess you prefer a different magic than me :)
22:42:41ldleworkwhen I'm compiling a test binary, I don't care about encapsulation at all.
22:43:04dom96I'm not sure I understand why you need relative includes though
22:43:16ldleworkdom96: for link generation to work properly in the doc gen
22:43:21ldleworkit was Araq's recommendation
22:43:32ldleworkI was flabbergasted but I'm used to comprimising at this point
22:44:20dom96hrm
22:44:29ldleworkif I import my modules like dadren/foo then the link in the docs is "dadren/foo.html"
22:44:43ldleworkso if you go to that link you are now really at dadren/dadren/foo.html which doesn't exist
22:45:08ldleworkbut if you import "import ./foo" then the link is generated as "./foo.html" so you click it and you go to "dadren/foo.html" which exists of course
22:45:11ldlework\o/
22:45:12def-ldlework: sounds more like a workaround for another path bug
22:45:47dom96Sounds like the doc gen should be able to figure out what the correct link is without any extra info
22:46:04*awsteele joined #nim
22:48:15*yglukhov joined #nim
22:51:35*derka joined #nim
22:52:29*yglukhov quit (Ping timeout: 240 seconds)
22:56:03*derka quit (Ping timeout: 240 seconds)
23:02:20*derka joined #nim
23:05:41federico3I'm starting to run some little benchmarks on every commit http://nimbench.firelet.net/
23:06:00federico3please let me know if you have a set of more meaningful benchmarks and I'll add them
23:06:48def-federico3: this and the list at the bottom: https://github.com/def-/nim-benchmarksgame
23:09:05ldleworkI wish I could raise exceptions directly
23:11:05def-ldlework: raise newException(...)?
23:11:44ldleworkraise ValueError(msg) ?
23:12:47ldleworkeven raise newValueError(msg)
23:13:59federico3def-: thanks - ideally benchmarks that measure something more specific
23:20:40gmpreussneris anyone aware of a work-stealing job system implementation using the thread pool in Nim?
23:21:02gmpreussneri guess there's spawn
23:21:36gmpreussnergah... i need to get up to speed with all the latest and greatest
23:22:52dom96federico3: That is awesome. Thank you for creating this!
23:23:12federico3my pleasure
23:24:33*derka quit (Ping timeout: 240 seconds)
23:25:29dom96federico3: is the github repo for this up yet?
23:26:06federico3not right now but I'll publish it shortly
23:26:30dom96ldlework: that's planned
23:26:41ldleworkneat
23:26:45dom96ldlework: will be 'raise ValueError(msg: msg)' hopefully
23:26:53ldleworkcool
23:27:09ldleworkIts too bad that objects don't have ordered fields
23:27:15ldleworkI mean, in memory they are ordered
23:31:51*derka joined #nim
23:51:13*boopsies is now known as boopsiesisaway
23:57:14gmpreussneris there a way to initialize thread-local variables?
23:57:45gmpreussnerit seems like the current pattern is to check on each access whether the variable has been initialized already, and if not, create it
23:58:31*Matthias247 quit (Read error: Connection reset by peer)
23:59:17gmpreussneri mean for threads in the thread pool, not threads that i create myself