00:03:22 | Varriount | onionhammer: 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:11 | Varriount | onionhammer: Could you put in some print statements in nimlime_core/mixins.py , in the is_enabled method of the NimLimeMixin class? |
00:30:26 | onionhammer | after 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:25 | ldlework | It'd be neat if the marhsal lib could accept json objects |
02:51:50 | ldlework | oops |
02:51:52 | ldlework | duh |
02:53:29 | ldlework | wait 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:30 | r-ku | wasnt there a way to limit what types generic T can take? or maybe even allow multiple types for proc call without generic? |
09:15:07 | ldlework | yes they are called concepts |
09:16:58 | r-ku | kk will look it up. but i dont think thats what i have in mind. damn memory |
09:19:00 | r-ku | oh 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:51 | filwit | 18:55:50 filcuc said: "is there a way to generate a string at compile time unique for a given type T" |
10:43:28 | filwit | yes, 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:06 | filwit | flicuc: https://gist.github.com/PhilipWitte/dd6c670fca3baf573490 |
11:14:47 | filwit | filcuc: 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:39 | miko__ | Hi. Is there a "slice to the end"? something like Haskell "tail"? Right now I use commandLineParams()[slice..paramCount()-1] |
11:48:00 | miko__ | 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:19 | dom96 | miko__: [slice .. ^1] |
12:05:40 | miko__ | Why is it not ^0 ? |
12:09:15 | miko__ | [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:22 | filcuc | is there a way to create templated singleton |
12:12:11 | filcuc | so 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:55 | avsej | hi, is it possible to declare function, which returns arrays but without declaring their sizes? |
12:21:10 | filcuc | avsej: array[0..0, int] {.unchecked.} |
12:21:55 | * | yglukhov joined #nim |
12:21:57 | avsej | thank you |
12:22:27 | miko__ | When compiling I get Error: internal error: getSize: tyEmpty |
12:22:46 | miko__ | "To create a stacktrace, rerun compilation with ./koch temp c <file>" |
12:24:04 | miko__ | koch is in the koch.nim is in the nim dir. Ah. got It. I should be run there. |
12:24:40 | miko__ | 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:36 | derka | Hi Guys |
12:30:34 | Varriount | miko__: Uh, try changing the unchecked array size to something other than an empty range. |
12:30:46 | Varriount | derka: Hi |
12:32:26 | lokien | hey, do we have any cheat sheets or something? printable references? |
12:33:17 | Varriount | lokien: Not really, no. |
12:33:25 | lokien | Varriount: too bad :( |
12:33:49 | Varriount | There's the system.nim documentation... but that would be a rather large cheat sheet. |
12:34:25 | miko__ | This is what is causing the compile-time error, i can't see what's wrong: |
12:34:26 | miko__ | while (read = i.readBuffer(buf.addr, size)) > 0: |
12:34:26 | miko__ | discard stdout.writeBuffer(buf.addr, read) |
12:35:04 | * | filcuc quit (Ping timeout: 240 seconds) |
12:35:05 | dom96 | miko__: you can't assign a variable inside a while loop condition |
12:35:21 | lokien | Varriount: some syntax rules/idioms/basic procs. system.nim is way too large :D |
12:36:21 | * | vendethiel quit (Ping timeout: 244 seconds) |
12:38:08 | Varriount | lokien: Well, I guess we could make something on the Wiki |
12:38:25 | * | zepolen quit (Remote host closed the connection) |
12:39:38 | lokien | Varriount: smth like that: http://www.ocamlpro.com/files/ocaml-lang.pdf |
12:39:49 | lokien | Varriount: sweet :D |
12:39:59 | * | lokien_ quit (Quit: Connection closed for inactivity) |
12:42:55 | miko__ | dom96, oh i see. Im still thing C. |
12:43:48 | miko__ | *thinking. I'm missing do-while loops aswell. Does this look like idomatic nim? http://pastebin.com/Z1vrCigg |
12:43:49 | dom96 | miko__: 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:42 | dom96 | miko__: You shouldn't use 'addr' unless you've got a good reason to do so |
12:44:50 | dom96 | it's not memory safe |
12:46:05 | miko__ | isn't is aslong as I don't do any aritmetic with it? |
12:47:18 | reactormonk | miko__, the gc has no reign over it. |
12:47:55 | miko__ | ok. |
12:48:16 | reactormonk | aka the object might disappear because addr doesn't count as a reference |
12:51:49 | * | pregressive joined #nim |
12:52:24 | derka | dom96 how are you doing ? I only have 3 chapters of your book :( |
12:53:29 | dom96 | derka: Chapter 4 should be ready soon, it's up to my publisher now. |
12:53:37 | derka | coolll |
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:55 | r-ku | i suppose ill be slapped for unorthodox stuff i have done but.. here it is.. https://github.com/r-ku/nim-ustring |
13:10:17 | miko__ | I'm not noticing a slowdown for readBytes from readBuffer. |
13:13:44 | * | filcuc joined #nim |
13:27:05 | federico3 | any 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:11 | federico3 | also, 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:52 | federico3 | http://nim-lang.org/docs/filters.html#available-filters-stdtmpl-filter <--- this answers my question, it seems |
13:40:20 | * | vendethiel joined #nim |
13:45:46 | def- | federico3: i'm taking a look |
13:48:35 | * | endragor quit (Remote host closed the connection) |
13:52:57 | def- | federico3: ok, should be fixed on devel now for the next release |
13:53:33 | def- | federico3: you can test by creating a release with ./koch csource && ./koch xz |
13:53:41 | federico3 | def-: 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:16 | filcuc | i'm getting a weird behaviour when passing object or tuples to C |
15:44:23 | filcuc | basically i don't get the same values from the C library |
15:44:27 | filcuc | :( |
15:47:55 | * | yglukhov joined #nim |
15:48:49 | def- | filcuc: different types maybe? int is different in C and Nim |
15:48:56 | * | derka joined #nim |
15:49:39 | filcuc | def-: i'm using cint everywhere :( |
15:50:11 | def- | got a minimal example? |
15:51:08 | * | derka quit (Client Quit) |
15:52:03 | * | yglukhov quit (Ping timeout: 248 seconds) |
15:52:46 | filcuc | i'm still investigating..howerver could i assume object == C struct |
15:52:57 | filcuc | and same memory layout? |
15:53:14 | filcuc | given that i use cint, cstring and so on :) |
15:53:23 | def- | and it's non-inheritable, i guess |
15:53:29 | def- | check the resulting c code |
15:55:30 | def- | maybe it's because of how you pass the pointer to it |
15:58:52 | filcuc | def-: i'm passing it by value |
15:59:10 | def- | i guess that's the reason |
15:59:43 | filcuc | in the C code i've void myFunc(MyStruct c) |
16:00:02 | filcuc | should i pass it by reference? |
16:00:05 | filcuc | (pointer) |
16:00:09 | def- | try, I guess so |
16:03:23 | filcuc | def-: the struct in the generated C code seems right |
16:03:54 | * | Trustable joined #nim |
16:06:11 | filcuc | def-: ok seems that the generated code pass the struct by reference |
16:06:24 | filcuc | def-: even if i didn't told it to do so |
16:06:39 | filcuc | my c binding is as follow: proc dos_qdeclarative_qmlregistertype*(value: DosQmlRegisterType) {.cdecl, importc.} |
16:07:02 | filcuc | and the struct is DosQmlRegisterType* = object ..... |
16:07:30 | filcuc | but the invokation in the C code is dos_qdeclarative_qmlregistertype((&dosqmlregistertype)); |
16:08:46 | filcuc | def-: :| do you think i'm doing something wrong here? or am i missing something? |
16:10:02 | def- | I would try a ptr |
16:11:33 | filcuc | def-: no ok if i change my C library and Nim binding with pointers seems to work |
16:11:47 | filcuc | def-: but it's not what i wanted |
16:12:00 | filcuc | def-: i mean, i wanted a pass by value |
16:14:03 | def- | use {.byval.} |
16:14:22 | def- | oh wait, does that even exist? |
16:14:30 | filcuc | :) |
16:14:32 | def- | I found this thread at least: http://forum.nim-lang.org/t/1908 |
16:15:44 | filcuc | def-: seems like a propasol though |
16:17:53 | filcuc | def-: maybe this http://nim-lang.org/docs/manual.html#foreign-function-interface-bycopy-pragma |
16:17:57 | filcuc | i'll give it a try |
16:21:08 | filcuc | def-: ok now it works |
16:21:45 | filcuc | def-: however it's a little weird because that applies it everywhere |
16:21:57 | filcuc | def-: and maybe it's not the case |
16:22:47 | filcuc | def-: i would like that the compiler respect the semantics i decided in the C binded function |
16:25:22 | filcuc | def-: i understand also that this prevent compiler optimizations. In fact i would suggest to force this behaviour only on fuctions marked {.importc.} |
16:26:53 | def- | filcuc: from what I understand even in C it's not recommended to pass structs by value usually |
16:28:25 | filcuc | filcuc: really? i didn't know that |
16:28:28 | filcuc | def-: |
16:28:55 | filcuc | def-: 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:53 | filcuc | what is the better way to map a const * in a nim to c interface |
17:38:04 | filcuc | right now i'm using just ptr T |
17:38:14 | filcuc | but i don't think that there's a const ptr T |
17:40:03 | * | yglukhov quit (Ping timeout: 240 seconds) |
17:50:38 | avsej | is it possible to write reverse range in for clause? |
17:50:54 | avsej | and with custom step |
18:01:15 | * | filcuc quit (Quit: Konversation terminated!) |
18:04:15 | Araq | avsej: sure look at countdown |
18:04:28 | avsej | thanks |
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:29 | r-ku | ill 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:47 | Varriount | Darn. I just sharpened my claws too. |
18:23:59 | * | PMunch joined #nim |
18:24:30 | * | lokien_ quit () |
18:24:41 | Varriount | r-ku: I was going to ask - if you're going to break convention, why not make them immutable as well? |
18:25:10 | r-ku | most of funcs are immutable though |
18:25:29 | r-ku | []= is only mutable thing i think |
18:30:57 | * | lokien_ joined #nim |
18:32:08 | Varriount | r-ku: But assignments will still copy. |
18:32:32 | * | lokien_ quit (Client Quit) |
18:32:53 | Varriount | r-ku: You know the reasoning behind inclusive slices, right? |
18:33:08 | * | lokien joined #nim |
18:33:11 | * | brson joined #nim |
18:33:21 | r-ku | i dont think i know |
18:35:30 | Varriount | r-ku: If Nim had Python's indexing, how would you get the last element of an array indexed by an enum? |
18:36:04 | Varriount | r-ku: array[char, low(MyEnum)..high(MyEnum)] |
18:36:20 | r-ku | len - 1? |
18:36:51 | Varriount | r-ku: Doesn't work, as the index must be a member of MyEnum |
18:37:30 | r-ku | so this thing has to be fixed. not everything else to accommodate this one case |
18:38:43 | Varriount | r-ku: Well, it applies to ints or each size too, just not as obviously. |
18:39:16 | Varriount | r-ku: How would you capture the element at high(int) in an array slice? |
18:39:50 | Varriount | I can't imagine any workaround that wouldn't be a kludge of some sort. |
18:41:05 | r-ku | a = "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:47 | Varriount | r-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:54 | Varriount | Of 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:45 | r-ku | yeah.. 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:46 | r-ku | making 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:37 | r-ku | bah head aint working any more, cant put my thoughts into something coherent that would make sense |
19:03:52 | r-ku | guess ill check it tomorrow. gn |
19:06:06 | * | brson quit (Quit: leaving) |
19:09:32 | avsej | can anybody explain me why this code does not compile? https://gist.github.com/avsej/7f7662862bcdfe857656 |
19:10:27 | def- | avsej: b.buf[index/8] |
19:10:57 | avsej | of course I meant b.buf, but still does not work |
19:11:12 | def- | index div 8 |
19:11:22 | def- | is float division |
19:11:34 | def- | but the error message is strange |
19:11:53 | Varriount | def-, avsej: It's because you're trying to subscript a ref type |
19:12:16 | avsej | Varriount, def- `div` fixed it |
19:12:18 | avsej | thanks |
19:12:45 | Varriount | def-: Darn you, keyboard ninja! |
19:14:34 | avsej | yeah, def- would be nice if it also mention resolved types too :) if I saw 'float' I would not ask :) |
19:19:28 | Varriount | avsej: 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:19 | avsej | for example I have enum, when Open = 0x01, and Close = 0x02. How I would convert int to this enum values properly? |
20:01:23 | def- | avsej: what's the type of the enum? |
20:02:27 | def- | avsej: if it's Foo, you can do Foo(2) |
20:02:39 | def- | that's a type conversion in Nim |
20:03:13 | avsej | thanks 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:29 | ldlework | Do people here use einheit over the unittest stdlib? |
20:44:07 | dom96 | einheit? Never heard of it |
20:44:19 | ldlework | https://github.com/jyapayne/einheit/blob/master/test.nim |
20:47:28 | ldlework | dom96: ^ |
20:48:01 | dom96 | Looks pretty similar to unittest |
20:48:07 | avsej | is 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:15 | dom96 | avsej: repr() |
20:48:22 | avsej | ok |
20:50:36 | ldlework | dom96: dunno, the combination of aggregating test suites and the report output.. https://github.com/jyapayne/einheit |
20:57:28 | ldlework | Araq: did you ever figure out what was going on with that VM memory corruption thing? |
21:05:41 | ldlework | I 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:19 | ldlework | sometimes I have a Table |
21:29:25 | ldlework | and I try to use the keys proc on it |
21:29:41 | ldlework | Error: attempting to call undeclared routine: 'keys' |
21:29:45 | ldlework | I imported the tables module |
21:29:55 | ldlework | echo'ing the type of the thing I'm calling it on, is a Table |
21:29:57 | ldlework | I just don't get it |
21:30:38 | ldlework | I don't even get an error doing "from tables import keys" |
21:30:44 | ldlework | grrrr |
21:31:30 | ldlework | how can it be undeclared?1 |
21:32:18 | ldlework | https://gist.github.com/dustinlacewell/47da8800a04e815376f4 |
21:32:29 | ldlework | Why is keys an undeclared field?! |
21:32:51 | ldlework | or routine if you write it that way |
21:33:00 | * | ldlework pokes dom96 any idea? |
21:34:26 | dom96 | Where do you see a keys proc? |
21:34:32 | dom96 | ldlework: ^ |
21:34:54 | ldlework | import tables? |
21:35:37 | ldlework | changing it from `self.pack.keys` to `keys(self.pack)` just hcnages the error to undeclared routine |
21:36:33 | ldlework | dom96: am I crazy? |
21:36:57 | dom96 | once again |
21:37:00 | dom96 | where do you see it? |
21:37:10 | dom96 | Look at the documentation for the tables module |
21:37:11 | ldlework | dom96: its imported |
21:37:22 | dom96 | `keys` is an iterator |
21:37:30 | dom96 | there is no `keys` proc |
21:37:31 | ldlework | iterator keys[A, B](t: Table[A, B]): A |
21:37:33 | ldlework | iterates over any key in the table |
21:37:35 | ldlework | ugh |
21:37:45 | ldlework | this is a horrrrrible error |
21:38:18 | dom96 | agreed. Report it on Github please. |
21:38:59 | ldlework | dom96: what's the proper way to get the keys as a sequence again? |
21:39:59 | dom96 | ldlework: you can convert the `keys` iterator into a sequence using the `toSeq` proc in sequtils module. |
21:40:24 | ldlework | dom96: it still says undeclared field though |
21:40:36 | ldlework | and routine, I can't seem to produce the iterator.. |
21:41:00 | dom96 | toSeq(...keys) doesn't work? |
21:41:32 | ldlework | oh because its a macro I have to explicitly access the iterator from inside the call expr -.- |
21:41:36 | ldlework | jesus |
21:42:00 | ldlework | why the hell don't we have first class iterators that can be passed around? |
21:42:10 | dom96 | we do |
21:42:43 | ldlework | then why can't I do `let iter = self.pack.keys` |
21:42:49 | ldlework | `toSeq(iter)` |
21:42:50 | dom96 | but they are less efficient than inline iterators |
21:43:06 | dom96 | so inline is default |
21:43:57 | ldlework | its a wildly inconsistent experience |
21:44:11 | ldlework | self.check(toSeq(self.pack.keys) == expected_keys) |
21:44:19 | ldlework | test_packs.nim(58, 31) Error: undeclared field: 'keys' |
21:49:02 | ldlework | dom96: It doesn't work |
21:49:16 | ldlework | this thing is definitely a Table according to type() |
21:49:22 | ldlework | so I don't get it |
21:49:33 | dom96 | toSeq(keys(self.pack)) maybe? |
21:50:22 | ldlework | its like tables isn't being imported for some reason |
21:50:34 | ldlework | I tried to iterate over it and just echo the keys |
21:50:42 | ldlework | https://gist.github.com/dustinlacewell/05ba56aa57e804bc4e19 |
21:50:47 | ldlework | it can't find tables.items |
21:50:51 | ldlework | wtfff |
21:51:23 | dom96 | did you `from tables import keys`? |
21:51:41 | ldlework | why would I need to |
21:51:44 | ldlework | I just "import tables" |
21:51:59 | ldlework | self.check(toSeq(self.pack.keys) == expected_keys) |
21:51:59 | dom96 | No, I mean if you /only/ did that then that would cause the error. |
21:52:00 | ldlework | for key in self.pack.keys: |
21:52:02 | ldlework | echo key |
21:52:04 | ldlework | no |
21:52:07 | ldlework | if I comment out the first line |
21:52:10 | ldlework | the for-loop works |
21:52:12 | ldlework | lol |
21:52:14 | ldlework | how is that possible |
21:52:16 | ldlework | so buggy |
21:52:57 | dom96 | try moving it out of `testSuite` |
21:53:05 | dom96 | guessing that is to blame |
21:53:47 | ldlework | so you think it'll work with the normal unit test |
21:53:50 | ldlework | library |
21:53:58 | ldlework | though can't do the same thing |
21:54:34 | dom96 | no |
21:54:43 | dom96 | It's likely it will fail too actually |
21:54:50 | ldlework | let |
21:54:53 | ldlework | expected_keys = @["foo", "bar", "new"] |
21:54:54 | ldlework | pack = self.pack |
21:54:56 | ldlework | k = toSeq(pack.keys) |
21:54:58 | ldlework | self.check(k == expected_keys) |
21:55:00 | ldlework | for key in self.pack.keys: |
21:55:02 | ldlework | echo key |
21:55:04 | ldlework | this works |
21:55:06 | ldlework | what a shitshow |
21:55:09 | dom96 | But would be nice if you checked to see if it works outside the testSuite |
21:55:10 | ldlework | universal call syntax was a really bad idea :/ |
21:55:55 | ldlework | dom96: I can't just magically test it outside the testSuite |
21:56:01 | ldlework | the table is on self, inside the test suite |
21:56:42 | dom96 | okay, then testSuite does some pretty interesting stuff. |
21:57:10 | ldlework | what? |
21:57:18 | ldlework | Its like |
21:57:26 | ldlework | We're talking about how something doesn't work inside a method of a class |
21:57:28 | ldlework | and you're like |
21:57:34 | ldlework | "Oh forget about the entire state of the program" |
21:57:40 | ldlework | "just run that bit of code at module level" |
21:57:46 | ldlework | "oh you can't? That class must do something wierd" |
21:57:48 | ldlework | no... |
21:58:08 | ldlework | its 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:13 | ldlework | or this table? |
21:58:14 | dom96 | yes |
21:58:48 | ldlework | yes it works like a charm outside |
21:59:39 | ldlework | but it looks like it only fails inside of self.check() |
22:01:00 | dom96 | In that case it might actually work better with unittest |
22:01:31 | dom96 | But please submit a bug report to the Nim repo. |
22:04:10 | dom96 | alternatively, if you want reliability: just use when isMainModule + doAssert :) |
22:07:14 | ldlework | I also want nice reporting and such |
22:07:40 | ldlework | but it looks like this thing is pretty buggy |
22:08:43 | * | yglukhov joined #nim |
22:08:47 | ldlework | But it works okay as long as you don't actually use any expressions in self.check() |
22:08:53 | ldlework | just compare simple variables |
22:11:13 | * | Trustable quit (Remote host closed the connection) |
22:12:06 | ldlework | dom96: it seems you can only test the public interfaces of things in Nim .. |
22:12:51 | * | yglukhov quit (Ping timeout: 248 seconds) |
22:17:01 | ldlework | dom96: know what I mean? |
22:17:06 | ldlework | not sure what to do about that |
22:17:17 | dom96 | not really? |
22:17:30 | ldlework | If you stick all your test code into each module... |
22:17:36 | ldlework | but other than that how can you test private interfaces? |
22:18:21 | ldlework | you can't import them so I dunno why you don't know what I mean |
22:22:04 | def- | ldlework: or include the module instead of importing it if you want to access internals |
22:22:43 | def- | 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:05 | ldlework | ... |
22:26:16 | ldlework | you want to 100% unit test every thing |
22:26:21 | ldlework | ideally |
22:26:35 | ldlework | its not always possible but no I've never heard "only test the public interface" before |
22:27:17 | ldlework | including the module seems so hacky |
22:28:03 | ldlework | it basically doesn't work with relative imports |
22:28:09 | ldlework | which all my code uses |
22:28:17 | ldlework | so that it can work with the documentation generator probably |
22:28:22 | ldlework | properly* |
22:29:54 | * | ldlework goes and plays video games instead. |
22:31:04 | dom96 | I heard that. You are meant to only test the public parts of a module. |
22:31:35 | dom96 | http://stackoverflow.com/questions/105007/should-i-test-private-methods-or-only-public-ones |
22:32:08 | ldlework | The reasoning makes zero sense at all |
22:32:26 | ldlework | Testing the implementation has nothing to do with "breaking encapsulation" or the contract when someone is actually using the code. |
22:32:41 | ldlework | You unit test code so that if the impelmentation ever changes it doesn't change the behavior |
22:32:54 | ldlework | You want to be certain that's true for the entire implementation don't you? |
22:33:14 | dom96 | So how would you do it in other languages? |
22:33:39 | dom96 | I've never heard of any language allowing you to break encapsulation just so that you can test everything |
22:33:42 | ldlework | I don't know I come from Python where we test all of our units. |
22:35:00 | dom96 | Your public procedures use your private ones, by testing them you are indirectly testing the private implementation. |
22:35:06 | dom96 | That should be enough. |
22:35:09 | ldlework | The second answer in your link agrees with me, btw. |
22:35:30 | ldlework | and explains why it isn't enough |
22:36:00 | ldlework | Yay, 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:03 | ldlework | Is not enough. |
22:36:28 | ldlework | Guess I'll just put tests in every file... |
22:36:32 | def- | ldlework: I guess you can add your tests at the bottom of the file, "when isMainModule" style |
22:37:00 | def- | 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:05 | ldlework | "reasonable" |
22:37:28 | ldlework | its not well thought out |
22:38:02 | dom96 | ldlework: You're free to make all your procs public and prefix them with 'private' or something if you want :P |
22:38:12 | ldlework | In my experience test code is far longer than the code it tests |
22:38:12 | dom96 | *prefix the "private" ones |
22:38:13 | ldlework | Far longer |
22:38:14 | def- | 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:29 | ldlework | So now all my modules are more than 100% larger |
22:38:49 | dom96 | Python cheats here by not having any real encapsulation |
22:39:14 | dom96 | In Java you would use reflection to test private methods which sounds horrible. |
22:39:33 | ldlework | I feel like we should be able to use the pragma system for stuff like this |
22:39:41 | def- | 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:45 | ldlework | "I'm a testing module. Yes, its fine for me to import this..." |
22:40:07 | ldlework | Seems way more elegant |
22:40:14 | dom96 | Then `include` sounds like a good solution |
22:40:40 | def- | 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:53 | ldlework | if the compiler understood relative imports for included files I guess I would have nothing concrete to complain about |
22:41:22 | ldlework | def-: sure that's one way to think about how testing should work, okay |
22:41:24 | * | darkf joined #nim |
22:42:04 | dom96 | yeah, there are many module path related issues that need to be fixed. |
22:42:16 | ldlework | "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:41 | ldlework | when I'm compiling a test binary, I don't care about encapsulation at all. |
22:43:04 | dom96 | I'm not sure I understand why you need relative includes though |
22:43:16 | ldlework | dom96: for link generation to work properly in the doc gen |
22:43:21 | ldlework | it was Araq's recommendation |
22:43:32 | ldlework | I was flabbergasted but I'm used to comprimising at this point |
22:44:20 | dom96 | hrm |
22:44:29 | ldlework | if I import my modules like dadren/foo then the link in the docs is "dadren/foo.html" |
22:44:43 | ldlework | so if you go to that link you are now really at dadren/dadren/foo.html which doesn't exist |
22:45:08 | ldlework | but 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:11 | ldlework | \o/ |
22:45:12 | def- | ldlework: sounds more like a workaround for another path bug |
22:45:47 | dom96 | Sounds 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:41 | federico3 | I'm starting to run some little benchmarks on every commit http://nimbench.firelet.net/ |
23:06:00 | federico3 | please let me know if you have a set of more meaningful benchmarks and I'll add them |
23:06:48 | def- | federico3: this and the list at the bottom: https://github.com/def-/nim-benchmarksgame |
23:09:05 | ldlework | I wish I could raise exceptions directly |
23:11:05 | def- | ldlework: raise newException(...)? |
23:11:44 | ldlework | raise ValueError(msg) ? |
23:12:47 | ldlework | even raise newValueError(msg) |
23:13:59 | federico3 | def-: thanks - ideally benchmarks that measure something more specific |
23:20:40 | gmpreussner | is anyone aware of a work-stealing job system implementation using the thread pool in Nim? |
23:21:02 | gmpreussner | i guess there's spawn |
23:21:36 | gmpreussner | gah... i need to get up to speed with all the latest and greatest |
23:22:52 | dom96 | federico3: That is awesome. Thank you for creating this! |
23:23:12 | federico3 | my pleasure |
23:24:33 | * | derka quit (Ping timeout: 240 seconds) |
23:25:29 | dom96 | federico3: is the github repo for this up yet? |
23:26:06 | federico3 | not right now but I'll publish it shortly |
23:26:30 | dom96 | ldlework: that's planned |
23:26:41 | ldlework | neat |
23:26:45 | dom96 | ldlework: will be 'raise ValueError(msg: msg)' hopefully |
23:26:53 | ldlework | cool |
23:27:09 | ldlework | Its too bad that objects don't have ordered fields |
23:27:15 | ldlework | I mean, in memory they are ordered |
23:31:51 | * | derka joined #nim |
23:51:13 | * | boopsies is now known as boopsiesisaway |
23:57:14 | gmpreussner | is there a way to initialize thread-local variables? |
23:57:45 | gmpreussner | it 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:17 | gmpreussner | i mean for threads in the thread pool, not threads that i create myself |