00:01:36 | * | CaptainRant joined #nim |
00:08:00 | * | brson quit (Quit: leaving) |
00:11:19 | * | boydgreenfield quit (Quit: boydgreenfield) |
00:12:02 | * | Jesin joined #nim |
00:14:22 | * | BlaXpirit quit (Quit: Quit Konversation) |
00:17:46 | * | CaptainRant quit (Ping timeout: 246 seconds) |
00:20:52 | Mat4 | ciao |
00:20:56 | * | Mat4 left #nim (#nim) |
00:26:40 | * | StefanSalewski quit (Quit: Page closed) |
00:30:24 | * | z1y quit (Ping timeout: 265 seconds) |
01:21:57 | * | repax quit (Quit: repax) |
01:23:25 | * | Trustable quit (Quit: Leaving) |
01:32:21 | * | z1y joined #nim |
01:41:01 | * | z1y quit (Ping timeout: 252 seconds) |
01:55:21 | * | rpag joined #nim |
01:58:31 | * | darkf joined #nim |
02:04:09 | * | z1y joined #nim |
02:18:39 | * | willwillson quit (Ping timeout: 272 seconds) |
02:18:43 | * | BitPuffin quit (Ping timeout: 255 seconds) |
02:21:01 | * | rpag quit (Quit: Leaving) |
02:29:10 | gmpreussner | is there a way to do duck typing in nim? |
02:35:38 | gmpreussner | i guess generic procs would do the trick |
02:41:25 | * | kapil__ joined #nim |
02:58:00 | flaviu | Yep, and tuples are for structural typing |
03:01:41 | * | vendethiel quit (Ping timeout: 252 seconds) |
03:13:36 | * | Jesin quit (Quit: Leaving) |
03:15:40 | * | vendethiel joined #nim |
03:40:54 | * | Jesin joined #nim |
03:40:59 | * | vendethiel quit (Ping timeout: 272 seconds) |
03:44:23 | * | Jesin quit (Max SendQ exceeded) |
03:45:07 | * | Jesin joined #nim |
03:46:44 | * | vendethiel joined #nim |
03:48:58 | * | boydgreenfield joined #nim |
03:52:12 | * | brson joined #nim |
03:52:41 | * | boydgreenfield quit (Client Quit) |
04:12:49 | gmpreussner | flaviu, when generic parameters are of type 'range', is there a way to extract the range bounds in the type declaration? |
04:13:44 | flaviu | I'm certain it's possible with macros, but let me check the manual to see if there's another way to do it. |
04:17:33 | gmpreussner | i couldn't find anything in the docs. there are also aren't any related macros in the core libs, it seems (i looked at system.nim and a few others). |
04:17:41 | flaviu | gmpreussner: If you're referring to something like `range[0..10]`, not any arrays, then min(range), max(range) should work |
04:17:54 | gmpreussner | ok, let me try that... |
04:18:01 | flaviu | http://nim-lang.org/manual.html#subrange-types |
04:18:36 | gmpreussner | yeah, i saw those, but i thought they only apply to instances of ranges |
04:19:13 | flaviu | Well, you could create a dummy instance. |
04:19:37 | gmpreussner | within the type declaration? what would that look like? |
04:19:42 | flaviu | max, min should be calculated at compiletime and the C compiler should optimize the dummy value. |
04:19:49 | flaviu | gmpreussner: I'm not sure what you mean. |
04:20:13 | gmpreussner | like where would the dummy be? it would be an unused member of the type, yes? |
04:20:53 | gmpreussner | i think in that case it might be better to write a macro that has a local dummy variable |
04:20:58 | flaviu | I think I understand what you mean, but can you post a short snippet of what you want the result to be? |
04:21:38 | gmpreussner | consider something like this: Matrix*[T; R, C] = array[R, array[C, T]] where R and C are ranges. i'd like to turn that into a 1D array using the lower and upper bounds of R and C. |
04:22:27 | flaviu | Oh, you want to do calculations on ranges? Yeah, I think you need a macro for that. |
04:23:06 | gmpreussner | ok, i figured. i'll give that a shot, thanks :) |
04:27:13 | notfowl | no |
04:27:20 | notfowl | gmpreussner, i'll give you an example |
04:27:25 | notfowl | 1 sec |
04:28:38 | notfowl | wait i dont understand |
04:29:52 | notfowl | when you say 'turn that into a 1d array' you want a function that takes Matrix[t,r,c] and returns an array[r*c, t] ? |
04:34:37 | * | brson quit (Quit: leaving) |
04:42:34 | gmpreussner | notfowl: yes, sort of |
04:42:49 | gmpreussner | except the math will be a little more complex |
04:44:55 | gmpreussner | i know i can easily do this with static[int]: Matrix[R, C: static[int], T] = array[R * C, T] |
04:45:28 | notfowl | gmpreussner, that doesnt actually right now |
04:45:55 | notfowl | gmpreussner, problems show up when you try to define two diff matrix types iirc |
04:46:07 | gmpreussner | well, yeah |
04:46:17 | notfowl | see this https://gist.github.com/fowlmouth/e9e99a427e56b427b34e |
04:46:28 | notfowl | you can use 'auto' return type to do what you want i think |
04:46:53 | gmpreussner | it would be more like Matrix[R, C: static[int], T] = object, and then an array[R * C, T] field. that compiled for me. |
04:47:18 | notfowl | gmpreussner, yes but matrix[2,3] and matrix[3,2] become the same type |
04:47:20 | gmpreussner | the problem doesn't go away though, because eventually you still have to resolve R and C when accessing elements |
04:47:40 | gmpreussner | oh i see |
04:47:51 | notfowl | well |
04:47:58 | notfowl | wrapping it in an object may work |
04:48:30 | gmpreussner | my unit tests sure went through, but maybe it was a lie :) |
04:49:17 | gmpreussner | i'm exploring various options right now. i know several others have tried as well. spent the past two days learning about all the limitations |
04:49:47 | gmpreussner | i like the idea of R and C being ranges, because it allows users to control the indexing, i.e. 0- or 1-based |
04:50:15 | notfowl | i cant test anything because im on windows atm but see if the expression "Matrix[1,2,int] is Matrix[2,1,int]" is true or false |
04:50:59 | gmpreussner | ok |
04:53:17 | gmpreussner | notfowl: you are right, it comes out as the same type. that's bad :) |
04:54:19 | gmpreussner | well, that's not the end of the world as i kind of favor ranges anyway |
04:54:36 | notfowl | you know its likely that the c compiler turns 2d arrays into 1d arrays anyways |
04:56:49 | gmpreussner | im actually not concerned about the storage, but the nested for-loops needed to iterate the elements |
04:57:21 | gmpreussner | matrices are a rather simple case. what i'm really interested in is tensors. |
04:57:32 | gmpreussner | matrices being a special case of tensors |
04:58:17 | gmpreussner | im investigating the possibility of having something like Tensor[3, 4, 5, 6, float] to create a tensor of rank 4 with dimensions 3, 4, 5 and 6 |
04:58:46 | notfowl | you could implement items() for your matrix type |
04:58:50 | flaviu | .eval type Matrix[R, C: static[int], T] = object; f: array[R * C, T];echo(Matrix[1,2,int] == Matrix[2,1,int]) |
04:58:51 | Mimbus | flaviu: eval.nim(3, 21) Error: type mismatch: got (typedesc[Matrix[static[int literal(1)](1), static[int literal(2)](2), int]], typedesc[Matrix[static[int literal(2)](2), static[int literal(1)](1), int]]) |
04:59:21 | gmpreussner | flaviu: oh, that's cool. didn't know we had that :) |
04:59:59 | flaviu | gmpreussner: Officially, we don't. It's dts|pokeball's, but I'm temporary running it while he figures out sandboxing. |
05:00:23 | * | jefus__ joined #nim |
05:00:27 | notfowl | .eval type Matrix[R, C: static[int], T] = object; f: array[R * C, T];echo(Matrix[1,2,int] is Matrix[2,1,int]) |
05:00:29 | Mimbus | notfowl: true |
05:01:17 | flaviu | I had no idea that it's possible to perform operations on static[T] in types. |
05:01:46 | flaviu | .eval type Matrix[R, C: static[int], T] = distinct array[R * C, T];echo(Matrix[1,2,int] is Matrix[2,1,int]) |
05:01:47 | Mimbus | flaviu: true |
05:03:08 | gmpreussner | it probably tracks R and C as "static[int]" instead of "1" and "2", which is why it comes out as the same type |
05:03:32 | gmpreussner | i need to start diving into the compiler so i can debug stuff like that |
05:03:38 | gmpreussner | now if only i had more time |
05:04:02 | * | jefus_ quit (Ping timeout: 245 seconds) |
05:06:25 | notfowl | gmpreussner, do you have any vacation days? |
05:06:55 | gmpreussner | yeah, i got this week and next week off. after that it's back to the salt mine. |
05:11:39 | notfowl | lucky |
05:11:44 | notfowl | i dont even get xmas eve off |
05:13:42 | gmpreussner | aw that sucks |
05:13:42 | * | bjz joined #nim |
05:14:20 | gmpreussner | are you going to celebrate Santa's birthday at the office? |
05:15:34 | notfowl | ha |
05:15:48 | * | BitPuffin joined #nim |
05:19:57 | * | BitPuffin quit (Ping timeout: 240 seconds) |
05:28:01 | * | bjz quit (Ping timeout: 272 seconds) |
05:32:50 | * | nimnoob joined #nim |
05:52:52 | * | bjz joined #nim |
05:54:35 | * | bjz quit (Remote host closed the connection) |
05:55:11 | * | bjz joined #nim |
05:56:04 | * | nimnoob quit (Ping timeout: 245 seconds) |
06:04:00 | * | dyu joined #nim |
06:21:01 | Varriount | gmpreussner: If you want to start out with the compiler, start small, like with the parser. |
06:21:21 | Varriount | Also, document anything you find, for future explorers. |
06:22:56 | Varriount | .eval import os;echo(findExe("nim")) |
06:22:58 | Mimbus | Varriount: /home/sandbox/nim-lang/bin/nim |
06:26:09 | Varriount | .eval echo(1+1 / 2) |
06:26:11 | Mimbus | Varriount: 1.5 |
06:34:01 | * | bjz quit (Read error: Connection reset by peer) |
06:42:13 | gmpreussner | Varriount: will do, thanks |
06:47:35 | gmpreussner | is this expected? http://pastebin.com/4CSxBtRj |
06:47:48 | gmpreussner | i don't know if it's a bug, or if i'm doing things wrong |
06:51:53 | gmpreussner | i forgot to paste one line at the bottom. X is a range, i.e.: var a: Foo[range[0..2], float] |
07:01:35 | * | AMorpork is now known as ZzZMorpork |
07:03:45 | * | gour joined #nim |
07:07:01 | dts|pokeball | <flaviu> gmpreussner: Officially, we don't. It's dts|pokeball's, but I'm temporary running it while he figures out sandboxing. |
07:07:04 | dts|pokeball | ty :) |
07:07:11 | dts|pokeball | should be up soon |
07:07:24 | dts|pokeball | MOE is just more of a bitch to configure than i thought it would be |
07:10:07 | * | bjz joined #nim |
07:13:46 | dts|pokeball | also, i had an idea at work |
07:15:08 | notfowl | what were you doing thinking when you should be working |
07:15:26 | dts|pokeball | oops. i forgot i had to write out the idea :} |
07:15:45 | dts|pokeball | notfowl, i work hard at pretending im working hard |
07:15:52 | dts|pokeball | so i dont actually have to work |
07:17:16 | dts|pokeball | anyways, what if i split input by ';', erase leading ws, then run the code through a formatter? |
07:22:01 | * | bjz quit (Ping timeout: 272 seconds) |
07:23:52 | * | khmm joined #nim |
07:28:15 | * | khmm quit (Ping timeout: 252 seconds) |
07:32:52 | * | khmm joined #nim |
07:43:37 | * | z1y quit (Ping timeout: 255 seconds) |
08:04:29 | * | z1y joined #nim |
08:12:25 | * | vendethiel quit (Ping timeout: 255 seconds) |
08:22:16 | * | vendethiel joined #nim |
08:23:48 | * | darkf_ joined #nim |
08:24:00 | * | Varriount_ joined #nim |
08:26:56 | * | darkf quit (Ping timeout: 258 seconds) |
08:27:19 | * | Varriount quit (Ping timeout: 258 seconds) |
08:33:21 | * | yglukhov joined #nim |
08:52:21 | * | BlaXpirit joined #nim |
09:20:03 | * | darkf_ is now known as darkf |
09:38:58 | * | kniteli quit (Ping timeout: 250 seconds) |
09:47:53 | * | milosn joined #nim |
10:17:35 | * | Matthias247 joined #nim |
10:18:55 | * | zahary joined #nim |
10:18:56 | * | zahary quit (Read error: Connection reset by peer) |
10:19:41 | * | zahary joined #nim |
10:19:48 | * | zahary quit (Read error: Connection reset by peer) |
10:22:53 | * | zahary_ joined #nim |
10:23:18 | * | zahary_ is now known as zahary |
10:28:09 | Araq_ | hi zahary welcome back :-) |
10:35:43 | ekarlso- | Araq_: is there a Rest framework for nim ? |
10:36:14 | Araq_ | ekarlso-: I continue to not know what that even means |
10:39:46 | zahary | jester is a rest framework |
10:49:21 | ekarlso- | Araq_: REST api ish ;PÅ |
11:01:16 | * | BitPuffin joined #nim |
11:05:44 | * | bjz joined #nim |
11:20:14 | * | z1y quit (Ping timeout: 256 seconds) |
11:32:58 | gokr | gmpreussner: About "duck typing", you might want to read my OO articles. |
11:33:16 | gokr | Although I should write a "summary" article too. |
11:34:03 | gokr | Regarding "duck typing" its useful to understand how procs/methods and generics "play together", and those articles explore that. |
11:37:42 | ekarlso- | is there sometihng like match in nim ? |
11:39:30 | * | vendethiel quit (Ping timeout: 256 seconds) |
11:41:35 | * | vendethiel joined #nim |
11:41:52 | * | milosn quit (Ping timeout: 240 seconds) |
11:43:55 | * | milosn joined #nim |
11:50:02 | * | willwillson joined #nim |
11:50:33 | * | milosn quit (Ping timeout: 272 seconds) |
11:50:55 | * | milosn joined #nim |
12:06:52 | * | bjz quit (Ping timeout: 255 seconds) |
12:24:28 | * | Varriount_ quit (*.net *.split) |
12:24:28 | * | Jesin quit (*.net *.split) |
12:24:28 | * | dom96_ quit (*.net *.split) |
12:24:28 | * | darkf quit (*.net *.split) |
12:24:28 | * | TylerE quit (*.net *.split) |
12:24:28 | * | CARAM__ quit (*.net *.split) |
12:24:29 | * | gokr_ quit (*.net *.split) |
12:24:29 | * | flaviu quit (*.net *.split) |
12:24:29 | * | Araq_ quit (*.net *.split) |
12:24:29 | * | milosn quit (*.net *.split) |
12:24:29 | * | Matthias247 quit (*.net *.split) |
12:24:29 | * | jefus__ quit (*.net *.split) |
12:24:29 | * | [CBR]Unspoken quit (*.net *.split) |
12:24:29 | * | notfowl quit (*.net *.split) |
12:24:30 | * | NimBot_ quit (*.net *.split) |
12:24:30 | * | onionhammer quit (*.net *.split) |
12:24:30 | * | rektide quit (*.net *.split) |
12:24:30 | * | Roin quit (*.net *.split) |
12:24:30 | * | gmpreussner quit (*.net *.split) |
12:24:30 | * | phI||Ip quit (*.net *.split) |
12:25:15 | * | Varriount_ joined #nim |
12:25:15 | * | Jesin joined #nim |
12:25:15 | * | dom96_ joined #nim |
12:26:19 | * | darkf joined #nim |
12:26:19 | * | TylerE joined #nim |
12:26:19 | * | CARAM__ joined #nim |
12:26:39 | * | gokr_ joined #nim |
12:26:39 | * | flaviu joined #nim |
12:26:39 | * | Araq_ joined #nim |
12:26:54 | * | milosn joined #nim |
12:26:54 | * | Matthias247 joined #nim |
12:26:54 | * | jefus__ joined #nim |
12:26:54 | * | [CBR]Unspoken joined #nim |
12:26:54 | * | notfowl joined #nim |
12:26:54 | * | rektide joined #nim |
12:26:54 | * | NimBot_ joined #nim |
12:26:54 | * | onionhammer joined #nim |
12:26:54 | * | Roin joined #nim |
12:27:05 | * | TylerE quit (Max SendQ exceeded) |
12:27:05 | * | CARAM__ quit (Max SendQ exceeded) |
12:27:05 | * | CARAM__ joined #nim |
12:28:11 | * | CARAM__ quit (Changing host) |
12:28:11 | * | CARAM__ joined #nim |
12:28:25 | * | TylerE joined #nim |
12:28:52 | * | gmpreussner joined #nim |
12:28:52 | * | phI||Ip joined #nim |
12:37:04 | * | Banjomaster joined #nim |
12:38:03 | Banjomaster | Can i access tkinter through the python interface, say write the application in nim and gui in nim? |
12:38:30 | Banjomaster | Gui in tkinter i meant |
12:52:42 | * | TylerE is now known as TylerE_ |
12:55:08 | Araq_ | ekarlso-: not sure what you're after but there is a 're' module |
12:55:16 | Araq_ | Banjomaster: I can't see why not |
12:56:05 | ekarlso- | Araq_: would it be bad to write a packages.nim.org ish in python ? |
12:57:17 | Araq_ | ekarlso-: yes, write it in Nim instead |
12:57:23 | ekarlso- | :'( |
12:57:25 | ekarlso- | booo |
12:57:39 | ekarlso- | Araq_: wondering to use a db backend maybe.. |
12:57:50 | Araq_ | db_sqlite exists and works |
12:58:01 | Araq_ | so does db_mysql and db_postgre |
12:58:32 | ekarlso- | Araq_: any migrations tools ? |
12:59:24 | Araq_ | there is no py2nim but it would make an awesome project |
12:59:31 | Araq_ | *hint, hint+ |
12:59:38 | ekarlso- | hah :p |
12:59:43 | ekarlso- | dont have time for stuff like that :| |
13:08:15 | Banjomaster | Thats encouraging, just call the tkinter metods from nim then? |
13:10:33 | Araq_ | yeah but we also have a TK interface |
13:11:12 | Araq_ | it's low level wrapper though and I don't know of anybody who uses it :P |
13:12:57 | Banjomaster | Ok thanks ill check it out |
13:14:59 | * | khmm quit (Ping timeout: 244 seconds) |
13:27:35 | * | dom96_ quit (Ping timeout: 244 seconds) |
13:37:23 | Banjomaster | just curious what do people use for gui, is support of tk not so good in nim? |
13:40:56 | * | dom96_ joined #nim |
13:43:02 | * | bjz joined #nim |
13:46:59 | * | jefus__ is now known as jefus |
14:02:32 | flaviu | Banjomaster: Well, there's only been one GUI project that I know of in Nim so far, Aporia |
14:02:39 | flaviu | That uses gtk2 |
14:07:50 | * | zeta_ joined #nim |
14:09:11 | gmpreussner | Araq, flaviu: is this is a bug or did i not understand ranges? http://pastebin.com/4CSxBtRj |
14:09:12 | gmpreussner | X is a range, i.e.: var a: Foo[range[0..2], float] |
14:10:47 | flaviu | Sorry, but I've never touched this part of the language. Araq is your only hope ;) |
14:15:25 | dom96_ | ekarlso-: How dare you prefer Python over Nim :P |
14:18:49 | flaviu | Why would we need python2nim? There is a compiler that transforms python into C, we can just use c2nim on that. |
14:20:24 | * | Matthias247 quit (Read error: Connection reset by peer) |
14:30:07 | Araq_ | gmpreussner: looks like a bug |
14:30:10 | * | dom96_ quit (Read error: Connection reset by peer) |
14:32:48 | gmpreussner | Araq_: ok, i couldn't find any existing issues related to this. i can add a new one. |
14:33:05 | * | yeye123 joined #nim |
14:34:50 | Araq_ | yeah please do so |
14:39:00 | * | yeye123 quit (Quit: Leaving) |
14:41:44 | * | milosn quit (Remote host closed the connection) |
14:47:18 | * | dom96_ joined #nim |
14:49:03 | ekarlso- | dom96_: my work does that hah: P |
14:49:05 | ekarlso- | openstack |
14:52:16 | * | willwillson quit (Ping timeout: 250 seconds) |
14:53:22 | * | zeta_ quit (Ping timeout: 255 seconds) |
14:57:22 | * | dom96_ quit (Ping timeout: 245 seconds) |
14:57:50 | * | Sembei quit (Read error: Connection reset by peer) |
14:58:25 | * | MyMind joined #nim |
15:03:11 | * | z1y joined #nim |
15:23:24 | Varriount|Busy | flaviu: Uh, there might be some concerns with efficiency, translating python to c to nim |
15:23:37 | flaviu | Varriount|Busy: So? :P |
15:27:53 | * | darkf quit (Quit: Leaving) |
15:28:28 | Varriount|Busy | .eval echo(repr([for i in countUp(0, 5): i])) |
15:28:29 | Mimbus | Varriount|Busy: eval.nim(1, 14) Error: expression expected, but found 'keyword for' |
15:28:56 | Varriount|Busy | .eval echo(repr([(for i in countUp(0, 5): i)])) |
15:28:57 | Mimbus | Varriount|Busy: eval.nim(1, 36) Error: value of type 'int' has to be discarded |
15:29:08 | Varriount|Busy | :< |
15:29:19 | flaviu | Varriount|Busy: Nim doesn't have for comprehensions. |
15:29:36 | Varriount|Busy | Aww... |
15:31:29 | * | kapil__ quit (Quit: Connection closed for inactivity) |
15:37:10 | gmpreussner | Araq_: i looked into using macros to emulate variadic generics this morning. i hear it's supposed to be possible, but nobody can show an actual example. this is what i came up with: |
15:37:12 | gmpreussner | it looks like type definitions cannot be overloaded based on generic parameters, which means that the macro to create the generic type/parameter combinations has to generate a unique name for each. one also has to generate every desired variadic type combination ahead of time before it can be used. |
15:37:20 | gmpreussner | so in case of a multidimensional array of arbitrary rank, i end up with something like "type defineMultiArray(2)", "type defineMultiArray(3)" and so on, which will generate MultiArrayX type defs. then to use the generated types i have "type Foo = MultiArray2[5, 6]" and "type Bar = MultiArray3[5, 6, 7]", |
15:37:26 | gmpreussner | is this as good as it gets right now? what i really want is "type Foo = MultiArray[5, 6]", and ideally i wouldn't have to hard code a list of desired combinations ahead of time :) |
15:37:36 | * | z1y quit (Remote host closed the connection) |
15:37:52 | * | z1y joined #nim |
15:38:59 | flaviu | gmpreussner: try using typedescs. |
15:39:18 | flaviu | macro foo(types: varargs[typedesc]) |
15:40:12 | Varriount|Busy | Araq_: Are procedures passed to macros via pragmas supposed to have a 'Do' node root? |
15:43:52 | gmpreussner | flaviu: well, it's not that easy. that would work i was generating concrete types, but in my case i'm actually generating generic types |
15:44:53 | flaviu | Ah, I see what you mean. |
15:44:57 | gmpreussner | for example, defineMultiArray(2, T) would generate: MultiArray[D1, D2; T] = object... |
15:45:46 | * | milosn joined #nim |
15:46:52 | flaviu | .eval type; MultiArray[D1, D2; T] = object; MultiArray[D1, D2, D3; T] = object |
15:46:54 | Mimbus | flaviu: eval.nim(3, 2) Error: invalid indentation |
15:47:14 | flaviu | .eval type; MultiArray[D1, D2; T] = object; v:int; MultiArray[D1, D2, D3; T] = object; v:int |
15:47:15 | Mimbus | flaviu: eval.nim(3, 2) Error: invalid indentation |
15:47:59 | flaviu | .eval type; MultiArray[D1, D2, T] = object; MultiArray[D1, D2, D3, T] = object |
15:48:00 | Mimbus | flaviu: eval.nim(3, 2) Error: redefinition of 'MultiArray' |
15:48:05 | gmpreussner | :) |
15:51:06 | * | matkuki joined #nim |
15:53:28 | * | nimnoob joined #nim |
15:58:24 | matkuki | flaviu: Can I ask you something about your OOP macro and macros in general? |
15:58:35 | flaviu | Sure. |
15:59:54 | matkuki | The last line "result[0][0][0][2][0][2] = recList", what does it do? |
16:01:16 | flaviu | It digs through the AST to that point and replaces it with all the fields |
16:01:32 | flaviu | See the comment above it, it helps visualize what all those [][][]s are doing |
16:01:53 | flaviu | recList is a bunch of object field nodes. |
16:03:27 | matkuki | Do objects always have this kind of structure? |
16:04:07 | flaviu | Yes, they do. |
16:04:54 | flaviu | If you want to see the structure of a particular bit of code, you can do |
16:04:54 | flaviu | .eval import macros;dumpTree:; type Test = object; a: int |
16:04:56 | Mimbus | flaviu: StmtList |
16:05:25 | flaviu | Well, only the first line showed up. |
16:07:18 | matkuki | Thanks, things are clearer to me now. |
16:09:10 | matkuki | When a macro is declared as in your example "macro class*(head: expr, body: stmt): stmt {.immediate.} =", |
16:09:37 | matkuki | ... what part of it is the head and what part is the body? |
16:10:37 | flaviu | The head is the part before the `:` in the invocation, and the body is the part after the `:` |
16:11:04 | flaviu | `class Animal of TObject: ...` could be rewritten as `class(Animal of TObject): ...`, if that's clearer. |
16:12:18 | * | EXetoC joined #nim |
16:12:49 | matkuki | Ok, got it. I'm a Nim begginner, so sorry if I ask something that makes no sense. |
16:13:31 | flaviu | No need to apologize about that :) |
16:20:39 | * | nimnoob quit (Remote host closed the connection) |
16:23:09 | * | z1y quit (Ping timeout: 245 seconds) |
16:24:15 | * | khmm joined #nim |
16:27:29 | matkuki | Another thing about types/classes, why is that when declaring an object, it's usually done with "ref object of" instead of "object of"? |
16:28:28 | * | khmm quit (Ping timeout: 250 seconds) |
16:30:03 | flaviu | matkuki: Because `object of ...` means the object is like a struct. If you extend from it, you'll have problems. |
16:30:52 | flaviu | for example, if you have `TestObject = object of RootObj; a: int`, storing that into a seq[RootObj] will cause the `a` field to be truncated. |
16:31:58 | flaviu | If you don't want to use inheritance, you don't have to bother with the `object of` business, and you can use either `ref object` or `object`, whichever you'd like. |
16:33:14 | * | khmm joined #nim |
16:36:19 | * | nimnoob joined #nim |
16:38:25 | Araq_ | gmpreussner: I think you can do significantly better right now when you use a tuple instead of faking varargs generics |
16:38:43 | * | dom96_ joined #nim |
16:40:07 | Araq_ | that said, my motivation could be greater to dig into this whole mess again when I had ever seen a matrix/tensor that doesn't end up being a poor reinvention of what the language itself already offers under the name 'array' |
16:40:40 | matkuki | flaviu: thanks |
16:41:33 | Araq_ | I mean ... you start with a glorified type alias for 'array', reinvent [] and []= access ("encapsulation") and then it goes downhill when you realize you also want [[0, 2, 3], [...]] literals for initialization |
16:43:34 | Araq_ | and then you get quite close to what array already offers, but damn ... your encapsulated matrix cannot easily be a 'const' |
16:45:20 | Araq_ | and once we get the OpenCL backend we need to be able to map your matrix to the native OpenCL stuff ... |
16:45:44 | Araq_ | it never stops generating complexity |
16:50:02 | * | Araq_ is now known as Araq |
16:53:30 | * | BlaXpirit-UA joined #nim |
16:55:08 | Araq | bbl |
16:55:37 | gmpreussner | Araq: yeah, those are all great points, and i agree with you |
16:55:42 | * | khmm quit (Ping timeout: 256 seconds) |
16:56:38 | * | BlaXpirit quit (Ping timeout: 250 seconds) |
16:57:39 | * | dyu quit (Quit: Leaving) |
17:04:18 | * | Trustable joined #nim |
17:05:56 | * | nimnoob_ joined #nim |
17:05:56 | * | nimnoob quit (Read error: Connection reset by peer) |
17:24:09 | * | Trustable quit (Remote host closed the connection) |
17:32:07 | * | nimnoob__ joined #nim |
17:32:33 | * | kniteli joined #nim |
17:32:51 | * | nimnoob_ quit (Read error: Connection reset by peer) |
17:33:52 | matkuki | What was the reason for the name change form Nimrod to Nim? |
17:34:19 | def- | matkuki: http://forum.nimrod-lang.org/t/561 |
17:34:54 | * | askatasuna joined #nim |
17:45:34 | * | nimnoob__ quit (Ping timeout: 256 seconds) |
17:46:26 | * | nimnoob__ joined #nim |
17:50:14 | * | yglukhov quit (Ping timeout: 245 seconds) |
17:57:25 | * | xtagon joined #nim |
17:57:52 | * | BlaXpirit-UA quit (Quit: Quit Konversation) |
17:58:11 | * | BlaXpirit joined #nim |
18:29:34 | * | xtagon quit (Read error: Connection reset by peer) |
18:32:13 | * | Hakaslak joined #nim |
19:04:54 | * | Hakaslak_ joined #nim |
19:05:29 | * | yeye123 joined #nim |
19:08:15 | * | Hakaslak quit (Ping timeout: 258 seconds) |
19:09:40 | * | yeye123 quit (Client Quit) |
19:12:49 | * | yeye123 joined #nim |
19:13:08 | * | ZzZMorpork is now known as AMorpork |
19:24:47 | * | rpag joined #nim |
19:28:58 | * | dts|pokeball quit (Read error: Connection reset by peer) |
19:29:17 | * | Hakaslak_ quit (Quit: TODO: Generate 'Computer Sleep Quit Message') |
19:29:39 | * | dts|pokeball joined #nim |
19:38:11 | * | Hakaslak joined #nim |
19:43:05 | * | rpag quit (Quit: Leaving) |
19:43:07 | * | Hakaslak quit (Ping timeout: 264 seconds) |
19:46:47 | * | yeye123 left #nim ("Konversation terminated!") |
19:46:56 | * | yeye123 joined #nim |
19:52:22 | matkuki | flaviu: What would I have to change in the 'class' macro, so it would produce only 'ref object' instead of 'ref object of ...'? |
19:54:16 | matkuki | If I remove the change the definition in my code from 'class MyClass of TObject:' to 'class MyClass' it gives me an error: |
19:54:43 | matkuki | "Error: expression expected, but found ':'"? |
19:54:53 | dts|pokeball | code plz |
19:55:39 | matkuki | flaviu's nim-by-example OOP macro: http://nim-by-example.github.io/oop_macro/ |
19:55:52 | flaviu | huh, it works for me. |
19:57:00 | flaviu | matkuki: Did you forget to remove the `of` too? |
19:57:48 | matkuki | no removed 'of', wait a sec... |
20:00:31 | matkuki | flaviu: just remembered another thing, I changed your original code, so that the class can be used in other modules! |
20:00:47 | matkuki | If I use your original macro it works. |
20:01:17 | matkuki | flaviu: Is there a simple way to make the class exportable to other modules? |
20:03:15 | flaviu | matkuki: Yep. Just add `*` after the type names around `type `typeName` = ref object` |
20:09:34 | * | yeye123 quit (Quit: Konversation terminated!) |
20:10:52 | * | loz1 joined #nim |
20:14:45 | dts|pokeball | so im looking at the fsmonitor module, and am trying to decide which event i want, and found ( MonitorAttrib, ## Metadata changed.) does this mean stuff like the date it was created? |
20:16:21 | matkuki | flaviu: Great, it works! Can the macro be changed so that the class is exportable only if declared with an '*' e.g.: "class MyClass*"? |
20:17:02 | * | Hakaslak joined #nim |
20:17:08 | dts|pokeball | ,eval import fsmonitor;echo(add(initMonitor(), "/")) |
20:17:19 | dts|pokeball | .eval import fsmonitor;echo(add(initMonitor(), "/")) |
20:17:22 | Mimbus | dts|pokeball: eval.nim(2, 9) Error: undeclared identifier: 'initMonitor' |
20:17:40 | dts|pokeball | .eval import fsmonitor;echo(add(newMonitor(), "/")) |
20:17:43 | Mimbus | dts|pokeball: 1 |
20:17:51 | dts|pokeball | .eval import fsmonitor;echo(add(newMonitor(), "/bin")) |
20:17:53 | Mimbus | dts|pokeball: 1 |
20:17:57 | dts|pokeball | hmmm |
20:18:16 | dts|pokeball | ah |
20:19:00 | flaviu | matkuki: I'm sure it can. See what the difference is between `class MyClass* of Blah` and `class MyClass of Blah` using dumpTree. |
20:19:29 | flaviu | matkuki: It'll be slightly harder than adding a `*` unconditionally though. |
20:19:54 | matkuki | thanks for the direction, will look into it. |
20:28:17 | * | yeye123 joined #nim |
20:28:55 | Araq | flaviu: no it cannot. since there are no postfix operators in Nim |
20:29:15 | Araq | we discussed this a few times |
20:30:30 | dv- | if I export a function with export instead of using *, it works but I get a XDeclaredButNotUsed hint |
20:30:42 | dv- | also, nimrod doc doesn't generate docs for it |
20:32:24 | * | yglukhov joined #nim |
20:33:07 | * | askatasuna quit (Quit: WeeChat 1.0.1) |
20:34:46 | Araq | dv-: 'export' is not meant as an alternative for * |
20:35:01 | * | yglukhov quit (Read error: Connection reset by peer) |
20:35:03 | Araq | export is forwarding symbols coming from a different module |
20:35:09 | * | yglukhov joined #nim |
20:36:24 | dv- | is there something else like it then? * is kinda ugly |
20:39:58 | gmpreussner | dv: you know what, i used to feel the same when i started using nim a couple days ago. now i'm used to it, and i actually like it. |
20:40:35 | gmpreussner | the reason i hated it is because i've been programming mostly in C++ for the past 15 years, so i always read 'pointer type' |
20:40:53 | dv- | yeah |
20:40:55 | gmpreussner | now i see 'public' instead. it only takes a few days :) |
20:41:24 | ldlework | Sometimes I hate that I have to type so many *'s to make things public |
20:41:24 | dv- | but also it would be useful to see all the exported symbols in one place |
20:41:29 | ldlework | But then I realized it goes both ways |
20:41:49 | dv- | (for example on top of the file) |
20:41:58 | Araq | ironically when I started with C, I hated the * everywhere because I read it as "multiplication" |
20:41:59 | ldlework | dv-: you can forward declare in Nim |
20:42:07 | gmpreussner | Araq: lol |
20:42:18 | Araq | dv-: you're supposed to use the docgen for that overview |
20:42:50 | Araq | "const multiplied with int. arrrrghh" |
20:43:45 | ldlework | lol |
20:46:02 | yeye123 | anyone else suddenly having problems with aporia? Error: unhandled exception: index out of bounds [EInvalidIndex] |
20:46:37 | gmpreussner | yeye123: i haven't even been able to compile it yet. still running into the "cant open glib2" issue |
20:46:53 | Araq | yeye123: maybe aporia only works with Nim now |
20:47:09 | Araq | from the EInvalidIndex I can tell you're still using Nimrod ;-) |
20:47:30 | yeye123 | gmpreussner:ok, i guess you have installed that from nimble ? |
20:47:38 | loz1 | hi guys, is nimrod ide source code available to public? |
20:47:40 | yeye123 | Araq: thanks, how do i upgrade? |
20:47:58 | Araq | bootstrap from github devel |
20:48:21 | Araq | there is no other way because we STILL haven't released 0.10.2 yet |
20:48:35 | yeye123 | ok, thanks |
20:48:58 | Araq | (hi Varriount|Busy, hi dom96_! You're blocking the future of programming.) |
20:49:21 | yeye123 | hehe ;) |
20:49:24 | gmpreussner | ok, nim is cancelled |
20:50:09 | * | milosn quit (Ping timeout: 252 seconds) |
20:50:18 | Araq | gmpreussner: aww what do you mean? |
20:50:31 | Araq | loz1: yes. |
20:50:49 | gmpreussner | j/k :) |
20:51:02 | * | rpag joined #nim |
20:51:09 | * | Demos joined #nim |
20:51:11 | loz1 | Araq: what is its name?) |
20:52:05 | dom96 | Araq: hrm? |
20:52:16 | flaviu | Araq: But it does work! |
20:52:50 | flaviu | Araq: StmtList(Command(Ident(!"class"), Infix(Ident(!"*"), Ident(!"MyClass"), Prefix(Ident(!"of"), Ident(!"BlahC"))))) |
20:53:04 | Araq | flaviu: well I guess it does, but it's weird, right? it's parsed as |
20:53:05 | Araq | yeah exactly |
20:53:14 | flaviu | Yep, but it's usable. |
20:53:58 | flaviu | And I did have a disclaimer that it would be hard :) |
20:54:19 | loz1 | ok aporia, i found it) |
20:54:26 | gmpreussner | Araq: with regard to matrices/tensors as standard arrays, there is a valid use case where it won't work. if you want the storage to be substitutable, i.e. sparse matrices vs. dense, then we can't alias the array type directly, but have to use composition and expose indexing operators manually. |
20:55:34 | gmpreussner | i whipped up a quick test for this scenario earlier, and i'm currently stuck with the assignment operator for supporting assignment of regular arrays (which is one of the complications you pointed out earlier) |
21:00:26 | Araq | gmpreussner: yeah there are valid use cases. there are lots of others, for instance if you want to have an assert in your a[i] operation |
21:02:02 | yeye123 | Araq: for your information, swithching to nim made the trick, thank you! |
21:02:14 | Araq | but I keep looking for alternative ways to accomplish the same |
21:02:42 | * | Trustable joined #nim |
21:03:56 | Araq | gmpreussner: for instance, what I would currently do is to simply introduce a new operator like: |
21:04:47 | Araq | template `|`(x, y): expr = x+y*SomeLength |
21:05:06 | Araq | and then use a[i|j] |
21:05:25 | Araq | (and simply arrays for 'a') |
21:07:59 | gmpreussner | i've seen that in one of your unit tests. you're talking about flattening two- or more dimensional arrays. |
21:08:31 | Araq | you can do the same for sparse matrices |
21:11:42 | gmpreussner | that's orthogonal to the issue i mentioned though. what i was saying is that we can't do something along the lines of: type Matrix = array[..], because that dictates the element storage. we do not want to expose how elements are stored. what we care about is the contract to access elements, i.e. [1][2] or [1, 2] |
21:11:57 | * | rpag quit (Quit: Leaving) |
21:12:22 | gmpreussner | for convenience, we still want to be able to assign regular matrices though, i.e. var a: Matrix[..] = [[0, 0][0, 0]] |
21:13:57 | gmpreussner | i'm currently trying to figure out what the signature for that assignment operator should be |
21:14:22 | flaviu | gmpreussner: Converter proc? |
21:15:32 | gmpreussner | flaviu: i'll take a look at those right away :) |
21:18:37 | * | loz1 quit (Ping timeout: 245 seconds) |
21:22:11 | gmpreussner | flaviu: interesting. does the name of a converter proc have any significance? it doesn't seem to be used in any of the examples i found |
21:22:31 | yeye123 | I want to step through my nim program and watch all the variables, what are my options? |
21:22:58 | Demos | compile with --lineDir:on --debugInfo |
21:22:59 | flaviu | gmpreussner: No significance. Although from the few examples I've seen, they've been of the form `foo2bar` |
21:23:04 | Demos | and attach a debugger to it |
21:23:18 | Demos | the debugger to use will depend on the compiler |
21:23:57 | flaviu | gdb on linux. |
21:24:11 | Demos | for gcc and clang you should be able to use gdb or lldb, for icc, clang-cl (do we even support clang-cl?), or vcc you can use windbg, or the VS debugger |
21:24:45 | yeye123 | ok, im on linux, I'll have a look at it, thank you guys |
21:24:57 | flaviu | variables might be mangled, so that sometimes makes things harder |
21:25:48 | Araq | gmpreussner: the reason that you have to give a name is that you can exclude it when importing |
21:25:57 | Araq | import module except theConverter |
21:26:50 | Araq | for the same reason TR macros need to have a name |
21:27:22 | Demos | and sometimes scope gets screwed up a bit, if I want to break on a specific line I sometimes use {.emit: "__debugbreak();".} (only works on windows) |
21:27:47 | flaviu | Araq: I think he's referring to whether naming it one thing or another makes a difference in where it applies. |
21:28:10 | Araq | flaviu: yeah and I indirectly answered that one too :P |
21:28:43 | Araq | the name is irrelevant otherwise, except that you can invoke them explicitly too |
21:29:02 | gmpreussner | yeah, that all makese sense, guys |
21:30:03 | gmpreussner | so i'm running into a minor snag: it looks like converter procs cannot be parameterized using the params of the return type. all params must be present in the from-type, i suppose? |
21:30:53 | Araq | that is correct |
21:30:59 | gmpreussner | that would make it a showstopper, because my to-types have generic parms that are definitely not part of the array to be assigned from |
21:31:44 | Araq | hrm |
21:34:34 | Araq | well overloading of '=' is in the works, but will take a while |
21:36:16 | gmpreussner | ok :) |
21:36:30 | Araq | that said, I wouldn't do it this way. I'd have some construct macro for the convenience of having |
21:36:37 | Araq | construct""" 0 0 1 |
21:36:45 | Araq | 3 4 5 ...""" |
21:37:23 | Araq | and then do the "ordinary" conversion from matrix to sparse matrix explicitly |
21:37:32 | Araq | in the other cases |
21:37:52 | Araq | but it depends very much on how common that is, of course |
21:55:24 | * | dom96__ joined #nim |
21:58:04 | * | dom96_ quit (Ping timeout: 258 seconds) |
21:59:19 | yeye123 | Error: no generic parameters allowed <--its getting late i guess, why cant i use myArray[i] inside a for loop with countup i? |
22:03:03 | gmpreussner | yeye123: can you post some more code? |
22:05:58 | yeye123 | ok, this is what i want to achieve (example): for i in countup(0,15): Word[i] = true |
22:06:36 | yeye123 | where Word is array of bool |
22:07:39 | ldlework | yeye123: provide some code? |
22:07:40 | EXetoC | (0..15) |
22:07:46 | ldlework | oh heh |
22:07:57 | ldlework | wait, his countup should still work tho |
22:07:59 | ldlework | right? |
22:08:11 | gmpreussner | looks ok to me |
22:09:00 | yeye123 | hmm |
22:09:00 | EXetoC | I'd assume that they are equivalent, but the latter is more common and it's short |
22:09:10 | flaviu | .eval var word: array[16, bool]; for i in 0..15:; word[i] = true |
22:09:11 | Mimbus | flaviu: eval.nim(2, 4) Error: invalid indentation |
22:09:19 | flaviu | .eval var word: array[16, bool];for i in 0..15:; word[i] = true |
22:09:21 | Mimbus | flaviu: <no output> |
22:09:26 | flaviu | works for me |
22:09:38 | * | rpag joined #nim |
22:09:47 | ldlework | :P |
22:09:52 | ldlework | dts|pokeball: good work |
22:10:34 | dts|pokeball | what now? |
22:10:48 | flaviu | dts|pokeball: Your bot has been useful once more. |
22:10:52 | dts|pokeball | :D |
22:11:01 | dts|pokeball | its not even channel ready yet |
22:11:02 | dts|pokeball | awesome |
22:11:02 | EXetoC | .eval |
22:11:04 | Mimbus | EXetoC: <no output> |
22:11:46 | gmpreussner | up next: flaviu's hard drive formatted by accident |
22:12:01 | flaviu | go ahead and try! |
22:12:14 | flaviu | Seriously, do it. use #nim-offtopic to avoid spamming this channel. |
22:13:08 | yeye123 | ok, sorry guys, there were some unrelated typo, it works now, thank you |
22:13:20 | gmpreussner | maybe later - im gonna be afk for a bit. are you running it in a chroot jail? |
22:13:25 | flaviu | Nope |
22:13:44 | dts|pokeball | bbl |
22:13:47 | flaviu | It's running as it's own user. I've set permissions so all private data is unreadable. |
22:14:15 | matkuki | Is there a way to use an `*` and `=` in a macro, like in type declarations: "type mytype* = object"? |
22:16:09 | flaviu | matkuki: I'm not sure what you mean. |
22:18:12 | matkuki | flaviu: I'm trying to make your class macro to look more like Nim's type declaration: "class MyClass* = object of TObject:" |
22:19:07 | matkuki | That looks almost exactly like Nim's type declaration with only an aditional colon at the end. |
22:19:14 | flaviu | matkuki: You can't use that exact syntax |
22:19:47 | matkuki | ok, thanks. |
22:21:00 | * | Mimbus quit (Remote host closed the connection) |
22:21:02 | ldlework | import basic_language_features |
22:21:08 | * | Mimbus joined #nim |
22:21:08 | * | Mimbus quit (Remote host closed the connection) |
22:22:16 | * | Mimbus joined #nim |
22:25:36 | * | z1y joined #nim |
22:30:37 | * | BlaXpirit quit (Ping timeout: 252 seconds) |
22:36:54 | * | Jesin quit (Quit: Leaving) |
22:38:47 | * | gour quit (Quit: Leaving) |
22:47:31 | * | z1y quit (Ping timeout: 258 seconds) |
22:56:52 | * | yeye123 quit (Quit: Leaving) |
22:57:57 | * | Trustable quit (Quit: Leaving) |
22:58:24 | * | EXetoC quit (Read error: Connection reset by peer) |
22:59:51 | * | EXetoC joined #nim |
23:00:15 | * | matkuki quit (Quit: ChatZilla 0.9.91.1 [Firefox 34.0.5/20141126041045]) |
23:16:04 | * | yglukhov quit (Quit: Be back later ...) |
23:58:08 | * | rpag is now known as candlefactory |