00:21:31 | * | fowl quit (Quit: Leaving) |
00:28:08 | * | DAddYE quit (Remote host closed the connection) |
00:43:40 | * | io2 quit () |
00:49:14 | * | MFlamer quit (Quit: Page closed) |
00:51:40 | * | Yeri quit (Quit: Yeri) |
00:57:26 | * | fowl joined #nimrod |
01:24:55 | reactormonk | remind me of the lambda syntax again |
01:28:07 | fowl | do(an: int)->bool: false |
01:29:31 | reactormonk | kk |
01:30:52 | fowl | that'll be $2 |
01:33:30 | reactormonk | btc address? |
01:33:42 | fowl | 2 btc? |
01:35:55 | reactormonk | hell nah, 0.02 |
01:38:47 | fowl | ill take paypal, btc isnt useful to me |
01:47:57 | * | brson quit (Ping timeout: 276 seconds) |
01:49:09 | * | brson joined #nimrod |
02:00:59 | * | jpoirier joined #nimrod |
02:03:31 | * | jpoirier quit (Client Quit) |
02:04:41 | * | fowl quit (Quit: Leaving) |
02:06:40 | * | ltbarcly quit (Read error: Operation timed out) |
02:10:11 | * | q66 quit (Quit: Leaving) |
02:25:05 | * | JStoker quit (Ping timeout: 246 seconds) |
02:33:01 | * | Yeri joined #nimrod |
02:54:06 | * | JStoker joined #nimrod |
03:07:53 | * | ltbarcly joined #nimrod |
03:12:16 | * | ltbarcly quit (Ping timeout: 240 seconds) |
03:13:22 | * | ltbarcly joined #nimrod |
03:34:47 | * | MFlamer joined #nimrod |
03:39:05 | * | ltbarcly quit (Ping timeout: 268 seconds) |
03:59:44 | * | brson quit (Ping timeout: 260 seconds) |
04:01:26 | * | brson joined #nimrod |
04:12:01 | * | Yeri quit (Quit: Yeri) |
04:58:02 | * | d34th_ joined #nimrod |
04:59:50 | * | d34th quit (Ping timeout: 240 seconds) |
04:59:50 | * | reactormonk quit (Ping timeout: 240 seconds) |
04:59:51 | * | d34th_ is now known as d34th |
05:00:11 | * | logosd quit (Remote host closed the connection) |
05:01:48 | * | brson quit (Quit: leaving) |
06:53:59 | * | reactormonk joined #nimrod |
07:46:39 | * | Associ8or quit (Quit: Associ8or) |
07:49:36 | * | io2 joined #nimrod |
08:34:21 | MFlamer | Hi, is anyone on? |
08:55:58 | NimBot | Araq/Nimrod master 33f1146 Zahary Karadjov [+0 ±3 -0]: fix regressions affecting the echo magic and the creating of rod files... 3 more lines |
09:38:58 | * | q66 joined #nimrod |
10:44:09 | dom96 | hello |
10:44:12 | * | BitPuffin quit (Ping timeout: 276 seconds) |
11:14:42 | * | ltbarcly joined #nimrod |
11:19:11 | * | ltbarcly quit (Ping timeout: 260 seconds) |
12:13:39 | dom96 | Hrm, c2nim translates that union strangely. Maybe it is correct, but the fields are simply omitted so it feels like a bug: https://gist.github.com/dom96/35cd1b5942ccf9db5ec0 |
12:53:45 | * | EXetoC joined #nimrod |
13:23:24 | * | Hannibal_Smith joined #nimrod |
14:13:24 | EXetoC | Araq: tell us about this "top secret" company |
14:28:56 | * | Associat0r joined #nimrod |
14:28:56 | * | Associat0r quit (Changing host) |
14:28:56 | * | Associat0r joined #nimrod |
15:07:59 | dom96 | opencv is fun :D |
15:32:32 | MFlamer | Good morning. Is it possible to get the address of an element of a seq using seq[].addr ? |
15:33:23 | dom96 | yes, but it's not a good idea to do that AFAIK |
15:35:48 | EXetoC | why not, if the answer is yes? |
15:36:09 | dom96 | what if the sequence is sorted? |
15:36:32 | * | ltbarcly joined #nimrod |
15:37:10 | MFlamer | proc test(table: openarray[int]) = echo table[0].addr this dosent work for me |
15:37:30 | EXetoC | it needs to be a var |
15:38:28 | EXetoC | no wait |
15:39:06 | EXetoC | not in the case of openarray I guess, but what's the error? |
15:41:07 | * | ltbarcly quit (Ping timeout: 260 seconds) |
15:41:17 | MFlamer | Error: expression has no address |
15:41:40 | EXetoC | ok I might be confused as always. I was just looking at a generic function that is apparently never instantiated, so see what happens if you make it a 'var' |
15:42:25 | EXetoC | the address cannot be taken otherwise |
15:43:14 | MFlamer | works if its a var. Thanks. |
15:43:41 | MFlamer | are all arguments passed by value if not a var? |
15:43:54 | MFlamer | i.e. copied? |
15:45:30 | EXetoC | the compiler might pass an arg by reference either way, depending on what's more efficient |
15:46:50 | * | ltbarcly joined #nimrod |
15:49:03 | MFlamer | got it |
15:49:20 | EXetoC | so users don't really need to care about that in general |
15:49:54 | EXetoC | unless, of course, the purpose of 'var' is modification |
15:51:48 | * | ltbarcly quit (Ping timeout: 256 seconds) |
16:22:00 | MFlamer | proc compareAndSwap*[T: ptr|ref|pointer](mem: var T, expected: T, newValue: T): bool is this proc looking for 3 ptr(or ref) or 1 ptr(or ref) and 2 values? |
16:23:05 | MFlamer | seems like the latter, but having trouble getting it to type check |
16:29:20 | EXetoC | it takes 3 T, where each argument must have the same type |
16:30:45 | EXetoC | do you want something like this: "proc compareAndSwap(mem: var ptr|ref|pointer, expected, newValue: ptr|ref|pointer): bool"? |
16:31:10 | EXetoC | you might be able to simplify a little by the use of 'distinct', but I don't know if those changes are in yet |
16:32:30 | MFlamer | the proc is in the atomics module, seems like it should take a ptr and 2 values |
16:36:10 | MFlamer | if I were going to define it I would think it would look like "proc compareAndSwap[T](mem: ptr|ref|pointer, expected, newValue: T): bool" |
16:36:30 | EXetoC | ok, but for now, all three arguments must be instantiated by the same variant specified by T |
16:37:30 | MFlamer | and the typeclass restriction is saaying they should all be refs or ptrs? |
16:40:05 | EXetoC | it doesn't have anything to do with the actual type class, but rather the fact that there's one type argument, which means that the compiler must be able to deduce a single type |
16:40:50 | EXetoC | it's the same with just [T], just that no constraints are present |
16:44:20 | MFlamer | I get that but, in this case [T: ptr|ref|pointer] is restricting all T's to ptr, ref or pointer. Correct? |
16:47:45 | EXetoC | yes, as in compareAndSwap(ptr, ptr, ref) won't work |
16:51:45 | EXetoC | or compareAndSwap(int, int, int), to answer your last question :> |
16:53:30 | MFlamer | thanks. It just doesnt seem right, the C function its calling wants (ptr, val, val) not (ptr, ptr, ptr). I wonder if this proc is used anywhere else yet..... |
16:56:10 | EXetoC | at least InterlockedCompareExchangePointer seems to take three pointers |
16:57:50 | EXetoC | and the first argument points to a pointer (so a pointer to a pointer), so it looks correct to me |
16:58:50 | EXetoC | but then there's this "bool __sync_bool_compare_and_swap (type *ptr, type oldval type newval, ...)" |
17:02:26 | MFlamer | yeah, thats what I was looking at |
17:05:41 | EXetoC | makes sense. wanna patch it? I might otherwise, a little later |
17:13:41 | MFlamer | I'll see what I can do. |
17:21:01 | Hannibal_Smith | Is it possible to change object variant at runtime? |
17:21:01 | Hannibal_Smith | Like |
17:21:01 | Hannibal_Smith | root.kind = ElementKind.inner |
17:21:01 | Hannibal_Smith | root.left = newElement(key, data) |
17:21:01 | Hannibal_Smith | root.key = key |
17:33:21 | MFlamer | In the example the kind field is called the discriminator: For safety its address cannot be taken and assignments to it are restricted: The new value must not lead to a change of the active object branch. For an object branch switch system.reset has to be used. |
17:33:41 | MFlamer | thats a quote from the manual, never tried it though |
17:34:31 | Hannibal_Smith | The compiler don't complains...but the code at the moment is incomplete so I can't test it |
17:35:01 | Hannibal_Smith | Thank you MFlamer |
17:35:46 | Hannibal_Smith | Probably the correct way is to override the object with a new one |
17:35:56 | Hannibal_Smith | Uhm... |
17:36:06 | Hannibal_Smith | I don't know if is viable |
17:37:11 | EXetoC | what do you mean? |
17:37:46 | Hannibal_Smith | http://ideone.com/L7NH9M |
17:37:46 | Hannibal_Smith | Is the current type |
17:38:11 | Hannibal_Smith | If I override a TElement |
17:38:31 | Hannibal_Smith | The reference that others TElement keeps |
17:38:41 | Hannibal_Smith | Are of the new TElement? |
17:40:01 | Hannibal_Smith | Uhm...probably I must thinking something strange |
17:40:31 | Hannibal_Smith | Setting directly the new TElement keeping track of the parent |
17:40:41 | Hannibal_Smith | Should do the task |
17:40:51 | Hannibal_Smith | Like parent.left = newElement(...) |
17:48:46 | EXetoC | if it does in fact work, then you still can't assign to the kind field according to what he quoted |
17:50:06 | MFlamer | if I'm on windows, is the default C compiler still gcc? |
17:50:31 | MFlamer | like defined(gcc) == true |
17:51:01 | EXetoC | Hannibal_Smith: and I think an exception was thrown once when I assigned to the wrong field, but I'm not sure |
17:51:11 | EXetoC | try and see if the above works |
17:53:11 | EXetoC | MFlamer: I think so, and the windows installers come with GCC |
17:54:41 | Hannibal_Smith | EXetoC, you where right |
17:54:51 | Hannibal_Smith | It's checked at runtime |
17:54:51 | Hannibal_Smith | Hint: operation successful (7596 lines compiled; 0.883 sec total; 13.133MB) [SuccessX] |
17:54:51 | Hannibal_Smith | > Process terminated with exit code 0 |
17:54:51 | Hannibal_Smith | > /tmp/aporia/a1 |
17:54:51 | Hannibal_Smith | Traceback (most recent call last) |
17:54:51 | Hannibal_Smith | a1.nim(11) a1 |
17:54:51 | Hannibal_Smith | Error: unhandled exception: key is not accessible [EInvalidField] |
17:54:51 | Hannibal_Smith | > Process terminated with exit code 256 |
17:54:51 | MFlamer | ok, I guess the atomics calls would still be into OS code using windows.h, even if compiled with gcc? |
17:57:21 | Hannibal_Smith | (I used this code: |
17:57:21 | Hannibal_Smith | var element = TElement[uint, uint](kind: ElementKind.leaf, key:1, data:1, left: nil, right: nil) |
17:57:21 | Hannibal_Smith | echo element.kind |
17:57:21 | Hannibal_Smith | I think is valid) |
18:00:11 | Hannibal_Smith | This is a problem... |
18:00:11 | Hannibal_Smith | while tmp_element.kind == inner: |
18:00:11 | Hannibal_Smith | if tmp_element.key < key: |
18:00:11 | Hannibal_Smith | tmp_element = tmp_element.left |
18:00:11 | Hannibal_Smith | else: |
18:00:11 | Hannibal_Smith | tmp_element = tmp_element.right |
18:00:11 | EXetoC | does it work? I think only data should be assigned to in this case |
18:00:11 | Hannibal_Smith | So this code is invalid |
18:00:21 | MFlamer | I'm getting "operation successful (7830 lines compiled; 0.110 sec total; 13.133MB) [SuccessX]" but no .exe is actually created. |
18:02:51 | EXetoC | Hannibal_Smith: right |
18:03:11 | * | logosd joined #nimrod |
18:03:31 | Araq | MFlamer: the .exe is produced in the project's directory I think |
18:03:46 | Araq | or in the current directory I dunno lol |
18:03:56 | Hannibal_Smith | proc is_inner[TKey, TData](e: TElement[Tkey, TData]): bool = |
18:03:56 | Hannibal_Smith | case e.kind |
18:03:56 | Hannibal_Smith | of inner: true |
18:03:56 | Hannibal_Smith | else: false |
18:03:56 | Hannibal_Smith | I think this should be ok |
18:04:26 | Araq | Hannibal_Smith: it's pointless cargo cult code |
18:04:51 | Hannibal_Smith | Uhm? |
18:04:51 | Araq | I'd use e.kind directly |
18:05:26 | Hannibal_Smith | Sorry, I'm lost |
18:05:26 | Hannibal_Smith | while tmp_element.kind == inner: <-Is this code invalid? |
18:05:46 | Araq | I don't think so. why would it? |
18:06:11 | Hannibal_Smith | var element = TElement[uint, uint](kind: ElementKind.leaf, key:1, data:1, left: nil, right: nil) |
18:06:11 | Hannibal_Smith | echo element.kind |
18:06:26 | Hannibal_Smith | I tried this before |
18:06:26 | Hannibal_Smith | And got an exception |
18:06:36 | EXetoC | only one of the fields are valid for that particular kind |
18:07:06 | EXetoC | Araq: that line alone looks fine. can't you query it? |
18:07:16 | Hannibal_Smith | Hint: operation successful (7596 lines compiled; 0.883 sec total; 13.133MB) [SuccessX] |
18:07:16 | Hannibal_Smith | > Process terminated with exit code 0 |
18:07:16 | Hannibal_Smith | > /tmp/aporia/a1 |
18:07:16 | Hannibal_Smith | Traceback (most recent call last) |
18:07:16 | Hannibal_Smith | a1.nim(11) a1 |
18:07:16 | Hannibal_Smith | Error: unhandled exception: key is not accessible [EInvalidField] |
18:07:16 | Hannibal_Smith | > Process terminated with exit code 256 |
18:07:26 | EXetoC | only data is |
18:07:41 | MFlamer | yes, but in this case it wasn't getting produced. It's building now. But still having trouble with the atomics module. Was this c2nim code? |
18:08:11 | Araq | it's not c2nim code but indeed I never tested it |
18:08:31 | EXetoC | you're instantiating it with 'leaf' as the kind. also, there's probably a memory overlap, so chances are that you'd assign something twice as a result, had it worked |
18:09:01 | * | o2wtf2o joined #nimrod |
18:09:11 | Araq | hi o2wtf2o , welcome |
18:09:21 | MFlamer | ok, I'm gonna see if I can get it working |
18:09:31 | Araq | excellent, thank you |
18:09:31 | EXetoC | but it shouldn't work, since it's a tagged union, rather than a regular union (like in C), where there's no type safety |
18:10:01 | Araq | Hannibal_Smith: the error message is perfectly clear :P |
18:10:01 | Hannibal_Smith | Ahhh |
18:10:01 | MFlamer | I've got a little start on a LockFreeHashTable |
18:10:11 | Hannibal_Smith | Sorry, yes |
18:10:21 | EXetoC | *type distinction |
18:15:01 | MFlamer | "Error: execution of an external program failed; rerun with --parallelBuild:1 to see the error message" and then I do, and gives no error, just acts like it's successful and produces no .exe. Guess I should file a bug for that |
18:15:11 | Hannibal_Smith | Araq, for now the only difference from the C++ is a 1 more work per element...but the code is way better in the Nimrod version |
18:15:21 | Hannibal_Smith | *1 more word |
18:18:52 | Araq | MFlamer: please run the GCC commands yourself then and see what that produces |
18:19:12 | Araq | the command should be at the top of the generated C files |
18:21:22 | Hannibal_Smith | Uhm...maybe is something more than a word...I think that filed access is checked every time using variant type |
18:21:52 | Hannibal_Smith | Or compiler can do something about this? |
18:22:52 | Araq | 0.9.3 can in theory optimize of these away but doesn't do that yet. Plus it's disabled in release builds anyway. |
18:23:02 | Araq | *optimize most of these |
18:23:02 | Hannibal_Smith | Ok |
18:24:32 | Hannibal_Smith | A question, Nimrod support this? a = if a: ,,, |
18:24:32 | Hannibal_Smith | ? |
18:24:52 | Araq | yes 'if' can be used as an expression |
18:25:02 | Hannibal_Smith | Great |
18:26:27 | Hannibal_Smith | Are there some example about the indentation? |
18:26:37 | Hannibal_Smith | I think that I missed it in the tutorial |
18:26:52 | Araq | the tutorial is a bit outdated :P |
18:27:12 | Araq | the manual is usually much better kept up to date |
18:28:02 | MFlamer | OK, I see the nimrod compiler generates and keeps the C file. Good tip! |
18:28:02 | Hannibal_Smith | http://nimrod-code.org/manual.html#if-statement |
18:28:12 | Hannibal_Smith | There aren't any example of using if as an expression |
18:28:32 | Araq | http://nimrod-code.org/manual.html#if-expression |
18:28:52 | Hannibal_Smith | Ok |
18:29:12 | Hannibal_Smith | I think it cannot be expanded on multiple lines, right? |
18:29:32 | Araq | var x = if a: |
18:29:32 | Araq | 12 |
18:29:42 | Araq | else: |
18:29:42 | Hannibal_Smith | Ok, thank you |
18:29:42 | Araq | 13 |
18:30:12 | Araq | you need at least 0.9.2 for this to work iirc |
18:30:27 | Hannibal_Smith | I'm on the git version of yesterday |
18:31:52 | Hannibal_Smith | The code looks more good now |
18:37:52 | shevy | hmm slight off topic questions |
18:38:12 | shevy | does nimrod have something related to pdf (reading, generating) or spreadsheets (reading, parsing, writing) - anything? |
18:45:52 | MFlamer | hasThreadSupport should be true as long as I conpile with -t:on, right? |
18:46:12 | MFlamer | compile, sorry |
18:49:12 | EXetoC | lib/system.nim:882: hasThreadSupport = compileOption("threads") |
18:50:52 | MFlamer | thanks! |
18:53:32 | * | EXetoC quit (Quit: WeeChat 0.4.1) |
18:53:47 | * | EXetoC joined #nimrod |
18:53:47 | EXetoC | http://nimrod-code.org/threads.html |
18:54:47 | EXetoC | this mentions --threads:on, and that might do it |
18:56:12 | EXetoC | seems like the correct way to do it, if I'm not mistaken |
18:58:12 | MFlamer | yep, that was it. I was using -t:on for some reason |
18:59:02 | MFlamer | now I'm gettin somewhere. Got some of the atomics to work |
19:11:07 | Hannibal_Smith | If I have this code: "var x = y" and y is a ref object, how I can change directly the object, like in C++: *pointer = value? |
19:12:27 | Hannibal_Smith | I want to execute later: x = newY(...) |
19:15:47 | EXetoC | should work if the function returns the same type |
19:16:47 | Hannibal_Smith | Uhm... |
19:16:47 | Hannibal_Smith | Interesting approach |
19:17:02 | Hannibal_Smith | I used to emulate the classical C approach |
19:17:02 | Hannibal_Smith | --- |
19:17:02 | Hannibal_Smith | tmp_element = if tmp_element.key < key: |
19:17:02 | Hannibal_Smith | newElement(key, old_element, new_element) |
19:17:02 | Hannibal_Smith | else: |
19:17:02 | Hannibal_Smith | newElement(tmp_element.key, new_element, old_element) |
19:17:02 | Hannibal_Smith | --- |
19:17:42 | Hannibal_Smith | But I was stalled, because I don't know how "emulate" pointers in Nimrod |
19:19:27 | EXetoC | I don't know what you mean. Nimrod has pointers |
19:21:07 | * | ltbarcly joined #nimrod |
19:21:07 | Hannibal_Smith | var tmp_element: pointer = addr(root) |
19:21:17 | Hannibal_Smith | Something like this? |
19:21:42 | MFlamer | Araq: I have a generated C file that I can manually compile with gcc, but when nimrod trys to build an .exe I get Error: execution of an external program failed. Any ideas? |
19:22:27 | EXetoC | I don't know what newElement returns, but 'new' implies a reference on some sort, as per convention |
19:22:37 | EXetoC | and initFoo is used for value type constructors |
19:23:07 | Hannibal_Smith | Uhm...yes it's impossible to take the address of something on the GC... |
19:24:27 | Hannibal_Smith | http://ideone.com/oTHcyT |
19:24:27 | Hannibal_Smith | Is the current code |
19:24:42 | Hannibal_Smith | add is the proc in question |
19:25:02 | Hannibal_Smith | I allocate tree's node on the GC |
19:26:32 | Hannibal_Smith | http://ideone.com/0bHVOA <-It's the respective C++ code |
19:27:12 | Hannibal_Smith | In the C++ version I used a pointer for tmp_element |
19:27:12 | Araq | MFlamer: that's strange. you are on windows, right? |
19:27:27 | EXetoC | you should already have a reference then |
19:27:27 | MFlamer | yes |
19:28:02 | Araq | maybe nimrod uses a different gcc for some reason? |
19:28:12 | EXetoC | and having a raw pointer instead is of questionable usefulness, but I'm sure you can't make it work somehow |
19:28:32 | EXetoC | I would examine the code, but the screen resolution is low atm, and there are too many wrapped lines :> |
19:28:47 | MFlamer | I'll check |
19:28:47 | * | ltbarcly quit (Ping timeout: 264 seconds) |
19:29:52 | Hannibal_Smith | EXetoC, from what I understand, if var x = y |
19:29:52 | Hannibal_Smith | If y is a ref type |
19:30:02 | Hannibal_Smith | If i change x |
19:30:12 | Hannibal_Smith | It don't change y |
19:30:22 | Hannibal_Smith | But change x to operate on another ref object |
19:30:32 | * | ltbarcly joined #nimrod |
19:31:07 | Hannibal_Smith | Am I wrong? |
19:31:32 | Hannibal_Smith | Ahhh, sorry for my English |
19:31:52 | Araq | Hannibal_Smith: I think you mean the right thing |
19:32:22 | Hannibal_Smith | So...I have to use malloc? |
19:32:32 | Araq | no? why would you? |
19:32:52 | * | MFlamer quit (Quit: Page closed) |
19:33:02 | Hannibal_Smith | Is possible to take a pointer of something on the GC? |
19:33:02 | Araq | sure |
19:33:32 | Hannibal_Smith | It's great...where I can find more info about this? |
19:35:42 | Araq | lib/pure/collections/critbits.nim implements a crit bit tree |
19:35:42 | * | ltbarcly quit (Ping timeout: 264 seconds) |
19:35:52 | Hannibal_Smith | Ok, thank you |
19:36:02 | Araq | line 96 following |
19:36:22 | Araq | seems to be similar to what you have in mind |
19:36:32 | * | EXetoC quit (Quit: WeeChat 0.4.1) |
19:36:52 | * | MFlamer joined #nimrod |
19:38:22 | * | ltbarcly joined #nimrod |
19:43:12 | * | ltbarcly quit (Ping timeout: 264 seconds) |
19:45:07 | * | ltbarcly joined #nimrod |
19:45:07 | Hannibal_Smith | Araq, yes it's exactly was I was searching to do |
19:45:07 | Hannibal_Smith | Thank you |
19:48:32 | * | OrionPK joined #nimrod |
19:49:42 | * | ltbarcly quit (Ping timeout: 245 seconds) |
19:50:42 | * | ltbarcly joined #nimrod |
19:52:02 | MFlamer | Araq: I verified It's the same gcc |
19:53:32 | Araq | perhaps windows holds some lock so that .exe may not be written when you invoke it via nimrod? could be the case if the program is still running |
19:54:12 | Araq | or you need admin rights to the directory |
19:55:32 | * | ltbarcly quit (Ping timeout: 261 seconds) |
19:56:42 | * | ltbarcly joined #nimrod |
20:01:22 | * | ltbarcly quit (Ping timeout: 245 seconds) |
20:02:12 | * | ltbarcly joined #nimrod |
20:02:42 | MFlamer | I did a little test and I think gcc is missing some atomics functions |
20:02:42 | MFlamer | atomicstest.c: In function 'check': atomicstest.c:12:1: note: '__sync_fetch_and_nand' changed semantics in GCC 4.4 atomicstest.c:18:1: note: '__sync_nand_and_fetch' changed semantics in GCC 4.4 C:\Users\mflamer\AppData\Local\Temp\ccc66YWr.o:atomicstest.c:(.text+0x26): undefined reference to `___sync_fetch_and_or_4' C:\Users\mflamer\AppData\Local\Temp\ccc66YWr.o:atomicstest.c:(.text+0x46): undefined reference to `___sync_fetch_and_nan |
20:04:32 | MFlamer | or minGW specifically. |
20:10:53 | Araq | well it should be a builtin really, it shouldn't generate a call to ___sync_whatever |
20:11:23 | Araq | it should produce some nice assembler code, otherwise what's the point? |
20:12:03 | * | ltbarcly quit (Ping timeout: 264 seconds) |
20:12:43 | * | ltbarcly joined #nimrod |
20:14:53 | MFlamer | apparently this is a known limitation of minGW 32bit. I think it may be fixed for the 64bit version. Any problem using the 64bit minGW with nimrod? |
20:15:13 | Araq | none that I'm aware of |
20:15:28 | Hannibal_Smith | What is the correct way of doing this? |
20:15:28 | Hannibal_Smith | proc newElement[Tkey, TData](key: Tkey, data: TData) : ref TElement[Tkey, TData] = |
20:15:28 | Hannibal_Smith | new(TElement(kind: ElementKind.leaf, key: key, data: data)) |
20:15:53 | Araq | type PElement ... |
20:16:03 | Araq | and then in the proc body |
20:16:13 | Araq | PElement(kind: ElementKind.Leaf, key ...) |
20:16:33 | Hannibal_Smith | Ok, easy |
20:17:03 | MFlamer | Araq: are you saying these gcc calls look less performant that we would like http://gcc.gnu.org/onlinedocs/gcc-4.3.5/gcc/Atomic-Builtins.html? |
20:17:03 | Hannibal_Smith | I my english was so bad, I would be to add some documentation about this... |
20:17:13 | * | ltbarcly quit (Ping timeout: 245 seconds) |
20:17:13 | Hannibal_Smith | *wasn't |
20:17:33 | Araq | Hannibal_Smith: write some tutorial in your native language then instead :-) |
20:17:53 | Hannibal_Smith | It's something that I will try to do |
20:18:28 | Hannibal_Smith | I have to implementate for school some cool data structures likes skiplist |
20:18:38 | Hannibal_Smith | So it will be interesting comparing C++11 vs Nimrod |
20:18:48 | * | ltbarcly joined #nimrod |
20:19:23 | Araq | ok. fyi I consider skip lists stupid ;-) |
20:19:33 | Hannibal_Smith | Ahahahah |
20:20:13 | Araq | it uses variable length arrays to store lists of pointers for its list structure |
20:20:43 | Araq | which doesn't make too much sense really |
20:21:23 | Hannibal_Smith | Sutter adived skiplist as a good data structure in a multi threading enviroment |
20:21:23 | Hannibal_Smith | *advised |
20:23:23 | * | Araq remembers the proof of the average case for searching in a skip list |
20:24:03 | * | Araq has nightmares |
20:26:33 | Hannibal_Smith | Error: internal error: (filename: compiler/semtypes.nim, line: 832) |
20:26:33 | Hannibal_Smith | No stack traceback available |
20:26:33 | Hannibal_Smith | > Process terminated with exit code 256 |
20:26:53 | Hannibal_Smith | I must did something really bad |
20:26:53 | Araq | yup |
20:27:03 | Araq | report a bug please |
20:27:13 | Araq | an internal error is a bug |
20:27:33 | Hannibal_Smith | Github? |
20:27:43 | Araq | yes |
20:28:08 | Araq | MFlamer: no, that's not what I'm saying |
20:29:53 | Araq | I thought maybe you need to link to something for the atomics to work, but that doesn't make sense as there should be no dependency to some lib for these |
20:30:23 | MFlamer | ok, got it |
20:30:33 | * | ltbarcly quit (Ping timeout: 263 seconds) |
20:31:13 | * | ltbarcly joined #nimrod |
20:32:53 | Hannibal_Smith | https://github.com/Araq/Nimrod/issues/590 |
20:33:53 | Araq | PElement = ref TElement # make that |
20:34:13 | Araq | PElement[TKey, TData] = ref TElement[TKey, TData] |
20:35:33 | Araq | likewise use PElement[TKey, TData](kind: ElementKind.inner, key: key, left: nil, right: nil) and note how pointless your 'newElement' procs are :P |
20:35:53 | Hannibal_Smith | Ok |
20:42:13 | * | ltbarcly quit (Ping timeout: 245 seconds) |
20:43:43 | * | Mat2 joined #nimrod |
20:43:43 | * | ltbarcly joined #nimrod |
20:43:43 | Mat2 | hello |
20:43:53 | Araq | servus Mat2 |
20:44:08 | * | reactormonk quit (Ping timeout: 260 seconds) |
20:44:08 | Hannibal_Smith | proc newElement[Tkey, TData](key: Tkey, data: TData) : PElement[Tkey, TData] = |
20:44:08 | Hannibal_Smith | PElement(kind: ElementKind.leaf, key: key, data: data) |
20:44:23 | Hannibal_Smith | tree.nim(27, 10) Error: object constructor needs an object type |
20:44:23 | Hannibal_Smith | Why this is not ok? |
20:44:33 | Araq | learn to read |
20:44:53 | Araq | I told you to use PElement[TKey, TData](...) |
20:45:03 | Mat2 | hi Araq |
20:48:48 | * | ltbarcly quit (Ping timeout: 260 seconds) |
20:50:13 | Hannibal_Smith | I think this is the last thinkg, tmp_element.kind , that is the corrective of pointer->field? |
20:50:43 | * | ltbarcly joined #nimrod |
20:51:13 | Hannibal_Smith | *what is the equivalent of pointer->filed? |
20:51:23 | Araq | pointer.field |
20:51:33 | Hannibal_Smith | Error: undeclared identifier: 'kind' |
20:53:33 | Hannibal_Smith | The code is |
20:53:43 | Hannibal_Smith | var tmp_element = addr(root) |
20:53:43 | Hannibal_Smith | |
20:53:43 | Hannibal_Smith | while tmp_element.kind == ElementKind.inner: |
20:53:43 | Hannibal_Smith | ... |
20:54:08 | Hannibal_Smith | Root is stack allocated |
20:56:08 | Hannibal_Smith | Ahhh sorry... |
20:56:43 | Hannibal_Smith | It's better to treat TTree as an alias |
20:58:03 | Mat2 | what do you mean exactly with the statement, that root is stack allocated ? |
21:00:08 | Hannibal_Smith | Uhm...I didn't think that was a strange thing to say |
21:05:33 | * | ltbarcly quit (Ping timeout: 245 seconds) |
21:06:43 | * | ltbarcly joined #nimrod |
21:11:33 | * | ltbarcly quit (Ping timeout: 260 seconds) |
21:13:13 | * | ltbarcly joined #nimrod |
21:24:03 | MFlamer | Araq: I have the atomics working now. It was the minGW version. |
21:24:53 | MFlamer | I'll fix up our module and submit a patch |
21:25:13 | Araq | excellent |
21:27:33 | * | jpoirier joined #nimrod |
21:30:33 | Araq | hi jpoirier, welcome |
21:30:53 | jpoirier | howdy |
21:31:03 | Mat2 | hi |
21:35:13 | jpoirier | question, does nimrod-code.org eventually get updated from github.com/Araq/Nimrod/tree/master/web |
21:35:33 | Araq | yes |
21:36:43 | * | EXetoC joined #nimrod |
21:44:28 | * | ltbarcly quit (Ping timeout: 264 seconds) |
21:45:13 | * | ltbarcly joined #nimrod |
21:49:33 | * | o2wtf2o quit (Quit: Page closed) |
21:51:49 | * | ltbarcly quit (Ping timeout: 245 seconds) |
21:53:14 | * | ltbarcly joined #nimrod |
21:53:24 | Mat2 | ciao |
21:53:24 | * | Mat2 quit (Quit: Verlassend) |
21:57:49 | * | ltbarcly quit (Ping timeout: 260 seconds) |
21:58:44 | * | ltbarcly joined #nimrod |
22:00:15 | dom96 | hi |
22:01:58 | Hannibal_Smith | Hi dom96 |
22:07:30 | * | ltbarcly quit (Ping timeout: 245 seconds) |
22:09:35 | * | ltbarcly joined #nimrod |
22:12:21 | * | MFlamer quit (Ping timeout: 250 seconds) |
22:30:06 | Araq | dom96: c2nim translates a union to its first field |
22:30:20 | Araq | there is a slight chance that's correct and the best we can do |
22:30:33 | Araq | you need to cast to access the other fields |
22:30:58 | dom96 | I see. |
22:31:12 | dom96 | Perhaps a little union macro would be possible |
22:31:30 | dom96 | Which would generate correct types, and accessors. |
22:31:55 | Araq | yeah sure |
22:32:07 | dom96 | Another issue I encountered: |
22:32:19 | dom96 | What's void in Nimrod? |
22:32:26 | Araq | 'void'? |
22:32:50 | dom96 | lets see |
22:33:16 | Araq | "void*" is "pointer" |
22:33:49 | dom96 | The compiler complains if I have 'ptr void' it seems |
22:34:06 | Araq | ok, will fix it |
22:34:21 | Araq | c2nim should know about void* already |
22:34:34 | dom96 | Would it not also make sense to use 'any'? |
22:34:40 | Araq | no |
22:34:50 | Araq | any is not compatible |
22:35:13 | dom96 | ok, fix that then. |
22:35:27 | Araq | make a proper bug report please |
22:35:30 | dom96 | Another thing: size_t should be translated into csize. |
22:35:47 | Araq | no, to 'int' |
22:35:53 | EXetoC | 'pointer' won't do? |
22:36:15 | dom96 | EXetoC: OpenCV has a "arr" type which is void. |
22:36:21 | Hannibal_Smith | size_t is not an uint? |
22:36:38 | dom96 | Araq: docs say that csize = size_t |
22:37:26 | Araq | Hannibal_Smith: I try to avoid unsigned if possible |
22:37:35 | Hannibal_Smith | Ok |
22:39:23 | dom96 | Araq: The OpenCV docs actually state what type TArr can be, I tried stating the types using '|' but it doesn't seem to be working. |
22:40:09 | Araq | you use '|' to simulate a union? good luck with that |
22:40:25 | dom96 | no |
22:40:36 | dom96 | This has nothing to do with unions |
22:40:40 | Araq | dom96: I just checked c2nim translates void* to pointer |
22:40:51 | Araq | so make a proper bug report or I can't fix it |
22:40:59 | dom96 | I guess you don't get it then. |
22:41:09 | dom96 | typedef void CvArr; |
22:41:28 | Araq | lol |
22:41:34 | dom96 | And then functions take 'CvArr*' |
22:41:40 | Araq | yeah of course |
22:41:54 | Araq | foolish |
22:42:11 | * | ltbarcly quit (Ping timeout: 240 seconds) |
22:42:16 | Araq | typedef struct CvArr CvArr; would have gained them some type safety ... |
22:42:52 | dom96 | I wanted to do: type TArr = TIplImage | TMat |
22:42:57 | dom96 | But maybe that's not even supported |
22:43:00 | * | EXetoC quit (Quit: WeeChat 0.4.1) |
22:43:07 | * | ltbarcly joined #nimrod |
22:44:16 | dom96 | Using 'auto' causes a compiler crash btw |
22:44:41 | dom96 | but since it's equal to 'expr' it's no surprise I guess |
22:44:45 | Araq | *shrug* |
22:46:49 | dom96 | ok, i'll just shrug too then. |
22:47:55 | * | ltbarcly quit (Ping timeout: 264 seconds) |
22:49:05 | * | ltbarcly joined #nimrod |
22:52:45 | * | Yeri joined #nimrod |
22:53:31 | * | ltbarcly quit (Ping timeout: 240 seconds) |
22:53:33 | dom96 | Araq: Voila, https://github.com/Araq/Nimrod/issues/591 |
22:55:02 | Araq | that's not a bug |
22:55:07 | * | ltbarcly joined #nimrod |
22:55:26 | Araq | and in fact your c2nim issue with typedef void cv; cv* is not either |
22:57:01 | dom96 | so what should I do in my wrapper? |
22:57:16 | Araq | fix the C sources |
22:57:18 | Araq | make it |
22:57:30 | Araq | typedef struct CvArr CvArr; |
22:57:48 | dom96 | no. I spent a couple of hours getting the generated code working |
22:57:54 | dom96 | I'm not redoing all that work. |
22:58:04 | dom96 | Tell me what to do in the Nimrod code |
22:58:07 | Araq | s/ptr void/pointer |
23:00:28 | Araq | or do: type TCvArr = object |
23:00:38 | Araq | s/ptr void/ptr TCvArr |
23:00:47 | Araq | for improved type safety |
23:01:35 | dom96 | That won't work. |
23:01:46 | Araq | why not? |
23:01:57 | dom96 | TArr can be an IplImage, TMat and other things. |
23:02:18 | Araq | IplImange = object of TCvArr ? |
23:02:19 | * | ltbarcly quit (Ping timeout: 264 seconds) |
23:02:30 | Araq | TMat = object of TCvArr ? |
23:02:36 | dom96 | that will work |
23:02:55 | Araq | make TCvArr {.inheritable, pure.} for that |
23:03:19 | dom96 | See, would have been so much easier if you just told me this from the beginning, instead of shrugging :P |
23:03:39 | * | ltbarcly joined #nimrod |
23:03:41 | Araq | I only shrugged about yet another "auto" bug |
23:04:20 | Araq | which you should report for zahary_ btw |
23:05:13 | dom96 | hrm, I don't think this is working |
23:06:06 | dom96 | yep, OpenCV doesn't like it |
23:09:15 | dom96 | Of course, I may just be doing something silly with OpenCV. |
23:09:32 | dom96 | But it works when I use TArr = TIplImage |
23:10:31 | * | ltbarcly quit (Ping timeout: 240 seconds) |
23:12:30 | Araq | do you need to access the fields of TArr etc? |
23:13:05 | * | io2 quit () |
23:13:12 | * | ltbarcly joined #nimrod |
23:13:13 | dom96 | It is mostly for function params |
23:13:40 | Araq | you can do: |
23:13:54 | Araq | type TCvArr = object |
23:14:08 | Araq | data: array [0.. maxSize, byte] |
23:14:36 | Araq | and then only use ptr TCvArr and don't even have TIpImage etc. |
23:14:56 | dom96 | and how do I know maxSize? |
23:15:26 | Araq | maxSize needs to be max(sizeof(TArr), sizeof(TIpImage), ...) etc |
23:15:42 | Araq | but this only works if you don't have arrays of them |
23:15:49 | Araq | so gah, better don't do it this |
23:15:53 | Araq | way |
23:18:34 | * | Hannibal_Smith quit (Quit: Sto andando via) |
23:21:17 | dom96 | Any other ideas? |
23:22:02 | Araq | pastebin the types |
23:22:36 | dom96 | TIplImage and TMat? |
23:22:42 | * | ltbarcly quit (Ping timeout: 264 seconds) |
23:23:14 | Araq | all of them, or simply everything you have so far |
23:23:48 | dom96 | https://gist.github.com/dom96/85ab79fbe42d24b40696 |
23:24:13 | * | ltbarcly joined #nimrod |
23:28:34 | Araq | both TArr and TIplImage are barely used? |
23:29:25 | Araq | sorry, please pastebin again with everything, including proc signatures |
23:29:31 | Araq | so that I can see how it's used |
23:30:52 | * | ltbarcly quit (Ping timeout: 240 seconds) |
23:32:42 | * | ltbarcly joined #nimrod |
23:36:52 | dom96 | argh |
23:37:16 | dom96 | https://gist.github.com/dom96/76f7edb8a41a643d2365 |
23:37:35 | dom96 | They are used in there |
23:40:46 | Araq | well I can't see why the "object of" stuff doesn't work. it should |
23:41:02 | Araq | but you can also leave the types as they are and introduce converters |
23:41:31 | Araq | convert toArr(x: ptr TIplImpage): ptr TArr = cast[ptr TArr](x) |
23:43:07 | * | ltbarcly quit (Ping timeout: 264 seconds) |
23:44:14 | * | ltbarcly joined #nimrod |
23:45:38 | dom96 | meh, i'm too tired to play around with it now |
23:46:54 | dom96 | Would be nice if | worked |
23:47:18 | dom96 | but anyway, good night |
23:47:23 | Araq | good night |
23:50:53 | * | ltbarcly quit (Ping timeout: 240 seconds) |
23:53:17 | * | ltbarcly joined #nimrod |
23:58:06 | * | ltbarcly quit (Ping timeout: 264 seconds) |
23:58:48 | * | ltbarcly joined #nimrod |