00:03:01 | cheatfate | jabb, var bar = addr(foo) |
00:03:13 | jabb | that creates something i have to dereference |
00:03:14 | * | ftsf joined #nim |
00:04:11 | cheatfate | jabb, https://nim-lang.org/docs/manual.html#overloading-resolution-automatic-dereferencing |
00:04:55 | jabb | yes, but for a basic type i just want the value of |
00:05:01 | jabb | or change |
00:05:13 | jabb | i'd have to do bar[] = new_value |
00:05:22 | jabb | using addr |
00:06:37 | cheatfate | you don't need to dereference it |
00:07:06 | cheatfate | just make bar = new_value |
00:07:33 | jabb | http://ideone.com/2ONGKZ (prog.nim(7, 7) Error: type mismatch: got (int literal(10)) but expected 'ptr int') |
00:08:10 | cheatfate | hmm |
00:09:23 | jabb | :P |
00:11:57 | cheatfate | then maybe you need to dereference it by yourself |
00:12:15 | jabb | :/ |
00:12:36 | jabb | the feature exists in procs, seems like an inconsistency to me |
00:13:14 | jabb | proc baz(x: var int) = ... behaves as expected, basically a "int &", instead of an "int *" |
00:13:28 | jabb | but outside procs, no "int &"s? |
00:13:59 | * | handlex joined #nim |
00:15:12 | Araq | yes, that's exactly right |
00:15:26 | jabb | ? |
00:15:43 | Araq | and the inconsistency exists for memory safety reasons, look at C# if you don't believe me |
00:16:16 | Araq | "but outside of procs, no int &s"? yes, that's exactly right |
00:17:37 | zachcarter | sorry Varriount - had to run for a bit - it does handle it but for some reason my bgfx backend isn’t binding the right texture for the right draw call |
00:26:14 | * | PMunch quit (Quit: leaving) |
00:29:01 | * | Matthias247 quit (Read error: Connection reset by peer) |
00:40:03 | * | handlex quit (Quit: handlex) |
00:41:24 | * | yglukhov joined #nim |
00:45:45 | * | yglukhov quit (Ping timeout: 240 seconds) |
01:10:56 | * | Jesin joined #nim |
01:14:39 | * | surge-protect quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client) |
01:18:35 | * | surge-protect joined #nim |
01:35:02 | * | zachcarter quit (Ping timeout: 240 seconds) |
01:38:40 | jabb | hmm |
01:38:50 | jabb | p: pointer, is like a void pointer? |
01:38:58 | jabb | but p: ptr int is an int pointer? |
01:43:31 | * | yglukhov joined #nim |
01:45:15 | cheatfate | jabb, yep |
01:46:34 | * | handlex joined #nim |
01:48:00 | jabb | cheatfate: there are quite a few ways to make a pointer lol |
01:48:08 | jabb | why so many keywords? |
01:48:09 | * | yglukhov quit (Ping timeout: 260 seconds) |
01:48:57 | jabb | ptr, addr(), ref, pointer, var (as parameter) |
01:49:25 | jabb | x.addr |
01:49:37 | cheatfate | x.addr = addr(x) = addr x |
01:49:51 | jabb | why so many ways to do the same thing? lol |
01:49:56 | jabb | ohhh |
01:50:00 | jabb | because it's a function |
01:50:25 | cheatfate | i'm not a creator of language... i don't know reasons |
01:50:26 | jabb | okay, still: ptr, addr, ref, pointer, var can all create reference/pointer |
01:50:49 | cheatfate | ptr is for non GC memory |
01:50:52 | cheatfate | ref for GC memory |
01:51:06 | cheatfate | pointer don't care about GC/nonGC |
01:51:29 | cheatfate | var notation for procedures arguments return values only |
01:51:42 | jabb | can also use var in return |
01:52:01 | cheatfate | ^^^ arguments & return values only |
02:00:28 | jabb | nim's philosophy regarding unsigned is no. what about network or low level bit streams? |
02:08:10 | cheatfate | nim has unsigned, its not so restrictive as java |
02:10:20 | FromGitter | <Varriount> Nim's take on unsigned (or rather, Araq's) is "unsigned should only be used when strictly necessary" |
02:11:28 | * | shashlick quit (Ping timeout: 240 seconds) |
02:13:17 | * | shashlick joined #nim |
02:30:54 | * | Snircle quit (Quit: Textual IRC Client: www.textualapp.com) |
02:50:02 | * | chemist69 quit (Ping timeout: 240 seconds) |
03:04:21 | * | chemist69 joined #nim |
03:30:38 | * | handlex quit (Quit: handlex) |
03:33:06 | * | zachcarter joined #nim |
03:35:32 | * | zachcarter quit (Read error: Connection reset by peer) |
03:35:52 | * | zachcarter joined #nim |
03:45:25 | * | yglukhov joined #nim |
03:49:44 | * | yglukhov quit (Ping timeout: 240 seconds) |
03:50:19 | zachcarter | I could use some help. I have a type defined as : |
03:50:29 | zachcarter | nk_handle* = object {.union.} |
03:50:29 | zachcarter | `ptr`*: pointer |
03:50:30 | zachcarter | id*: cint |
03:51:06 | zachcarter | I’m trying to check when the object pointed to by `ptr` is not initialized |
03:51:19 | zachcarter | I can do a check like : |
03:51:44 | zachcarter | if not handle.`ptr`.isNil: |
03:52:26 | zachcarter | but if I try to derference `ptr` and then repr the object or do any sort of comparison on it or anything, I get a segfault |
03:59:27 | * | Nobabs27 quit (Quit: Leaving) |
04:06:30 | * | rauss joined #nim |
04:27:00 | FromGitter | <Varriount> zachcarter: Could you rename the member? 'ptr' is already a builtin typeclass, which might cause some problems. |
05:10:05 | * | zachcarter quit (Quit: zachcarter) |
05:18:30 | * | yglukhov joined #nim |
05:22:44 | * | yglukhov quit (Ping timeout: 240 seconds) |
05:41:01 | jabb | what are threading options and shared state among threads? |
05:41:11 | jabb | is it just mutexes? |
05:42:08 | jabb | wait, data can't be shared across threads? |
06:05:24 | * | zachcarter joined #nim |
06:07:15 | FromGitter | <Varriount> Jabb: The default garbage collector uses a per-thread heap |
06:09:23 | FromGitter | <Varriount> You can use channels, the parallel and spawn mechanisms, or unsafe pointer passing. |
06:20:51 | jabb | apparently its slow? |
06:27:14 | FromGitter | <Varriount> Slow is relative. |
06:28:23 | FromGitter | <Varriount> Jabb: What's your use case? |
06:40:33 | jabb | high performant database |
06:46:22 | * | gokr joined #nim |
06:52:02 | * | nsf joined #nim |
06:54:07 | * | gokr left #nim (#nim) |
06:59:39 | * | libman joined #nim |
07:05:40 | * | zachcarter quit (Quit: zachcarter) |
07:07:19 | * | yglukhov joined #nim |
07:10:00 | * | yglukhov quit (Read error: Connection reset by peer) |
07:10:30 | * | yglukhov joined #nim |
07:23:04 | jabb | Varriount, too slow for that? |
07:27:16 | * | bjz joined #nim |
07:48:48 | * | filcuc joined #nim |
07:51:39 | * | rokups joined #nim |
07:53:53 | * | bjz quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…) |
07:57:30 | * | sdw joined #nim |
07:58:20 | * | bjz joined #nim |
07:58:58 | * | rauss quit (Quit: WeeChat 1.7) |
08:01:44 | * | chemist69 quit (Ping timeout: 255 seconds) |
08:05:55 | * | Arrrr joined #nim |
08:05:55 | * | Arrrr quit (Changing host) |
08:05:55 | * | Arrrr joined #nim |
08:06:19 | * | chemist69 joined #nim |
08:15:40 | * | Vladar joined #nim |
08:17:40 | * | Andris_zbx joined #nim |
08:18:03 | FromGitter | <Varriount> Jabb: Are you connecting to a database, or building one? |
08:25:09 | rokups | Araq: is there any good reason why variables in generated c code do not contain original names? for instance "NimStringDesc* T1_; T1_ = (NimStringDesc*)0; T1_ = foo_RdSvqy2gdVZp9a5p9cZtZqDg(((NimStringDesc*) &TM_V45tF8B8NBcxFcjfe7lhBw_2), ((NimStringDesc*) &TM_V45tF8B8NBcxFcjfe7lhBw_3)); printf("%s\012", T1_? (T1_)->data:"nil");" has weird "T1_" and "TM_*" |
08:25:10 | rokups | variable names. having original variable name as prefix for mangled one would be really helpful for debugger support. |
08:25:54 | Araq | these are compiler generated temps |
08:26:20 | Araq | there is no Nim name we could use for them, real Nim vars have their original name as a prefix |
08:26:31 | Araq | and locals are often not mangled at all |
08:27:10 | Araq | besides, with --debuggger:native in nimcache there are .ndi files which have the mapping from Nim to C names |
08:28:15 | rokups | hmm okay, but then it seems that -d:debug is doing some kind of optimizations and what not since its not 1:1 mapping to written code |
08:28:43 | * | bjz_ joined #nim |
08:29:51 | Araq | sure and GCC's debug code also uses stack slots that are not in my C code ... |
08:30:10 | * | bjz quit (Ping timeout: 268 seconds) |
08:30:51 | rokups | also this: https://i.imgur.com/lxCvYfj |
08:31:33 | rokups | not really sure whats going on here, seems some kind of variable mapping is going on but.. maybe debugger support needs to do some nim-specific sutff? |
08:31:58 | Araq | Nim's #line generation is a bit weird at times |
08:32:02 | Araq | for instance |
08:32:11 | Araq | var x = "foo" |
08:32:21 | Araq | translates to |
08:32:28 | Araq | tmp = "foo" |
08:32:32 | Araq | x = tmp |
08:32:47 | Araq | (well more complex than that but you get the idea) |
08:33:17 | Araq | so only the last step corresponds to a Nim source line but we emit the #line before the tmp assignment |
08:34:01 | Araq | but then that's what GCC does too, a C statement can produce more than 1 asm instruction... |
08:34:27 | FromGitter | <Varriount> If your connecting to a database, you're likely using a worker model, where each worker grabs |
08:35:19 | rokups | heh well im not even sure what could be done to improve this, but it definitely needs some love |
08:35:57 | rokups | vs code nim/debugging support is pretty good already. was surprised to find that out yesterday. and i was one of those vs code naysayers |
08:36:45 | jabb | Varriount, building |
08:37:32 | * | surge-protect quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client) |
08:38:03 | jabb | implementing |
08:38:21 | rokups | Araq: if you got time you could introduce me about to required codegen changes to allow overriding cpp virtual methods. now that coroutines are done (for now) i think maybe i could try tackle this one. |
08:38:36 | libman | I was ***SO*** close to making an intelligent and useful Nim forum post for once... |
08:39:29 | Araq | rokups: what about the memory usages? you said -d:nimCoroutines increases booting mem usage by a whole lot? |
08:39:36 | libman | I typed up http://pastebin.com/raw/nTyKq9K4 ... I was ready to post. I hit preview, and I saw that... Araq came and beat me to it by a few minutes... |
08:40:16 | rokups | Araq: i was telling you about how booting got fixed, that bug was middle step :p its fixed ofc, it boots nicely with usual 300-ish mem usage :p |
08:40:31 | rokups | gc tests passing as well |
08:40:52 | Araq | libman: yeah but you used a profiler and/or timing tools. |
08:41:01 | Araq | I only skimmed the code :P |
08:41:18 | Araq | your post adds some new information, please submit it |
08:43:16 | chemist69 | rokups: how do you setup nim debugging in VS code? |
08:43:58 | rokups | chemist69: i installed microsoft cpp tools and native debug extension. native debug extension allows setting breakpoints in nim code, then can use either of them to debug nim |
08:44:13 | rokups | it seems that microsoft's cpp debugger is better |
08:44:41 | chemist69 | ok, thanks. |
08:46:16 | rokups | end result with microsoft's debugger https://i.imgur.com/2d7o1S5 |
08:46:39 | rokups | that other screenshot was from native debug extension. |
08:47:26 | chemist69 | nice. |
08:51:28 | libman | Any verdict on the suggestion of adding OS package manager info to the download page? https://forum.nim-lang.org/t/2813 |
08:54:44 | euantor | PSA in case anybody has missed it: https://blog.cloudflare.com/incident-report-on-memory-leak-caused-by-cloudflare-parser-bug/ |
08:54:46 | * | evacchi joined #nim |
08:55:08 | euantor | Change your passwords on any site using CloudFlare (including DigitalOcean, which I know @dom96 uses to host Nim sites) |
08:55:59 | evacchi | hi all. I was wondering how hard would it be to make coroutines in coro work on a pool of threads |
08:56:28 | evacchi | as far as I understand, it looks like using shared data structures for temp storage might be enough |
08:56:37 | euantor | And here's a (incomplete) list of sites using CloudFlare: https://github.com/pirate/sites-using-cloudflare |
08:57:02 | evacchi | (I was thinking fibers, actors, etc.) |
08:59:14 | * | butchster quit (Ping timeout: 240 seconds) |
09:09:45 | * | ftsf quit (Quit: :q!) |
09:12:02 | Arrrr | I don't think i have an account in any single one of those webpages |
09:12:55 | Araq | libman: if you promise to maintain it, I'm willing to add it |
09:13:35 | libman | OK, I'll whip up some HTML tomorrow. |
09:13:39 | Araq | though in general I am not a fan of telling people "use this modified outdated Nim version *tied* to your OS" |
09:14:50 | Araq | and I think Linux package management is stupid and a hack on top of a file hierarchy that is a hillarious fundamentally broken design |
09:15:17 | libman | Do distros really make bad modifications? |
09:15:30 | * | Vladar quit (Remote host closed the connection) |
09:16:06 | rokups | they probably do not in this case. but as language is still not 1.0 i would prefer seeing simple shellscript that provides latest compiler instead. |
09:16:24 | rokups | because honestly - if person is looking for compiler he sure as hell can compile it |
09:16:42 | rokups | its more troublesome on windows though, but its different story |
09:17:56 | libman | I'm neutral on whether the download page encourages building from source instead of pkgs, I just thought it would be useful info to have on the download page. |
09:18:16 | * | evacchi quit (Ping timeout: 268 seconds) |
09:18:39 | euantor | I really like Rust's approach - point everybody to a single shell/batch script that can maintain versions and do automatic updates (in their case, rustup) |
09:21:45 | * | evacchi joined #nim |
09:21:59 | evacchi | so, I'm pretty new to Nim, and I wanted to try and write a minimal actor library as an exercise. So I played around with "shared" data structures (as you called them) such as the "sharedtable" module. I was able to make work a simple proof of concept which (at the end of the day) does the same as the "tasking" example with iterators |
09:22:07 | evacchi | then I stumbled upon the coro module, which I assume is still expected to schedule coroutines on a single thread (is that right?) |
09:22:12 | evacchi | so I was wondering how much work would it be to resume coroutines on a different thread |
09:23:04 | rokups | evacchi: i do not think that is doable at all due thread-local heaps nim uses. resuming coroutine on another thread would wreck havoc in gc |
09:23:28 | evacchi | huh, that's what I feared |
09:24:11 | rokups | with some work you could whip up support to do this for gcsafe coroutines, but that does not sound too useful in general.. |
09:24:25 | rokups | but is there really a need for this? |
09:24:25 | * | krux02 joined #nim |
09:24:55 | Araq | Erlang uses task local heaps and it works out quite well |
09:24:57 | rokups | you can have multiple threads running multiple coroutine loops and schedule your coroutines on whichever thread runs least amount of coroutines or something |
09:24:58 | * | couven92 joined #nim |
09:25:15 | Araq | we use thread local heaps though, but maybe we can make them task local |
09:25:40 | Araq | rokups showed us how to transform thread local vars to task local vars :-) |
09:25:41 | krux02 | what's the difference between thread and task? |
09:25:50 | krux02 | I know thread and process |
09:25:57 | rokups | hmm i am not so sure its a good idea |
09:26:04 | Araq | there task == coroutine |
09:26:47 | krux02 | so that thing that is called goroutine in go |
09:27:07 | krux02 | ok I got it |
09:27:24 | krux02 | is there a performance advantage in thread local heap? |
09:27:37 | rokups | there is safety advantage |
09:28:28 | krux02 | I heared that one of the performance problems of malloc is, that it needs to be synchronized between threads |
09:28:33 | Araq | performance advantage: no contention possible, write barriers do not have to be threadsafe... |
09:29:01 | FromGitter | <andreaferretti> I think the advantage, for an actor library, would be that one could migrate actors between threads without losing state stored on the heap |
09:29:29 | FromGitter | <andreaferretti> so an actor that does work does not block all other actors that happened to live on the same thread |
09:30:00 | krux02 | andreaferetti: as far as I know, an actor is not bound to a thread |
09:30:01 | rokups | some actors live on one thread, some on another. one thread can execute one actor at a time. i do not see a problem |
09:30:13 | krux02 | an actor is on that thread that just has time at that moment |
09:30:50 | rokups | if you manage state object yourself you can share it among threads, but if you shoot yourself in the foot thats on you |
09:31:24 | rokups | but if you start coroutine on a thread and start using gc-managed objects then that coroutine is bound to a thread |
09:31:42 | rokups | but coroutines most of the time are short-lived |
09:32:30 | krux02 | that is by the way also a problem in go. The thread that executes a goroutine/coroutine/actor/task from time to time just changes. An OpenGL context is bound to the thread. As soon as go changes the thread: boom! |
09:32:59 | krux02 | it can be prevented by locking the thread, but it needs to be done in that language |
09:33:39 | evacchi | we use thread local heaps though, but maybe we can make them task local <--- that would be pretty cool |
09:34:05 | FromGitter | <andreaferretti> what I was trying to say is that - while actor actions are short lived - actors could accumulate state |
09:34:09 | rokups | that would take away easy concurency though. suddenly coroutine is same as thread |
09:34:16 | FromGitter | <andreaferretti> if this state lives in the heap, this prevents actor migration |
09:34:59 | FromGitter | <andreaferretti> if heaps were task-local, one could migrate actors between threads without losing the state |
09:35:29 | rokups | at the cost of coroutines running on same thread not being able to interact with objects owned by other coroutines |
09:36:33 | rokups | but it is not clear if migrating running coroutine is even worth all the trouble |
09:37:32 | rokups | go probably migrates them around to balance out tasks among worker threads. i would just have programmer define which coroutine is potentially long running so long running ones would be spread evenly across the threads while short-running ones would go to thread that executes least amount of coroutines |
09:38:53 | krux02 | well instead of thousands of coroutines, one could also just create all jobs on a big list of jobs with an update proc that truely return, then everybody can handle scheduling according to their needs, or simplest case just have a sinle loop |
09:39:58 | FromGitter | <andreaferretti> @krux02 I am not sure I understand your suggestion, can you elaborate? |
09:40:31 | * | sz0 joined #nim |
09:41:04 | Araq | rokups: ok, back to your question |
09:41:04 | krux02 | I just wanted to mention, there is always more than one solution to a problem, and I personally do not use coroutines at all. |
09:41:21 | krux02 | and I don't necessarily need them |
09:41:41 | krux02 | but coroutines are AFAIK nothing more than resumable functions |
09:42:02 | Araq | coroutines do have the problem that they are not serializable, so if you base your game on them, "save game state" can become very problematic |
09:42:48 | Araq | since the state is in what you cannot control from the language directly, the hardware stacks that are full of pointers |
09:42:51 | krux02 | I didn't even think about that, but yes |
09:43:25 | rokups | i dont even know what executing code has to do with state saving \o/ |
09:44:09 | krux02 | so instead of a coroutine that gives the control back in intervals, there would be an object with update, and update stores the state in the object and when update is called again it knows from the object state where to continue |
09:44:33 | krux02 | then all you need for serialization is to serialize the objects |
09:44:37 | FromGitter | <andreaferretti> the problem is - where does this object live? |
09:44:44 | FromGitter | <andreaferretti> if it is bound to a thread |
09:45:03 | krux02 | it's in the control of the programmer |
09:45:06 | FromGitter | <andreaferretti> you are suddenly in a position where this object running for too long can stall other objects |
09:45:11 | FromGitter | <andreaferretti> if it is not |
09:45:23 | FromGitter | <andreaferretti> you need to migrate its state everytime you move it between threads |
09:45:42 | Araq | rokups: methods are not attached to a type only generic methods are |
09:45:45 | krux02 | well for games, the update of a thread does not allocate |
09:45:54 | Araq | that needs to be changed for the C++ interop to work |
09:45:56 | FromGitter | <andreaferretti> the context is - how to design an actor library |
09:45:56 | krux02 | of an object I mean |
09:46:05 | FromGitter | <andreaferretti> like Akka for Scala |
09:47:15 | krux02 | Well I would ask how Akka solves it |
09:47:52 | FromGitter | <andreaferretti> the JVM has a shared heap :-) |
09:49:22 | rokups | Araq: the way i imagine it is `method foo(this: var Bar) {.virtual.}` |
09:49:44 | krux02 | I don't know how far you can get when you say you also make task local heaps |
09:50:00 | krux02 | isn't that a lot of individual heaps? |
09:50:50 | Araq | rokups: yeah but for a start we'll use method foo(this: var Bar) {.exportc.} = ... |
09:51:14 | krux02 | At the moment I don't know how the thread local heaps work, but I imagine they simply work by calling the C malloc ahead of time, and the locally manage those chunks for single threads, so that malloc as called less often |
09:51:18 | Araq | exportc'ed methods need to be attached to the type just like it's done for generic methods already |
09:51:46 | Araq | and then you need to patch ccgtypes.nim so that the method is generated in the struct {} declaration |
09:52:14 | Araq | krux02: we don't use malloc, we use the OS's memory management directly |
09:52:38 | rokups | Araq: there probably should be additional checks as well? for instance that Bar's parent is importc'ed? |
09:52:46 | krux02 | does the OS haves something more smart that malloc? |
09:53:14 | Araq | rokups: yeah but that can wait |
09:53:29 | Araq | hardest part is to convince the codegen that structs can have routines in them |
09:53:56 | FromGitter | <andreaferretti> well, erlang uses one heap per actor and works fine |
09:53:59 | Araq | krux02: malloc uses the OS under the hood, we skip the man in the middle |
09:55:27 | krux02 | since I did not yet work with threads, I only need to use allocate shared, when I expect another thread frees the memory I just allocated, when other threads are only reading that memory I am fine? |
09:56:31 | rokups | Araq: could you point me to source files that i will be modifying? will be way faster than for me to find out on myself. in general i do get the idea, will see if anything can come out of this. |
09:56:48 | rokups | ah wait you already told, ccgtypes.nim |
09:58:28 | * | evacchi quit (Ping timeout: 240 seconds) |
10:02:46 | * | evacchi joined #nim |
10:05:42 | evacchi | I'm pretty happy my question has generated this conversation :) BTW, besides try and shoving an actor model in Nim, then I'm wondering what patterns would be "idiomatic" for Nim instead of actors |
10:06:39 | evacchi | I mean, I'm currently working on a project where being able to freely spawn "tasks" regardless of where they will be executed it's pretty conveniente |
10:06:44 | evacchi | *convenient |
10:07:43 | krux02 | evacchi, well you can do that when you have your own scheduler |
10:08:49 | evacchi | these tasks have state that must be maintained in some way, so they are not really short-lived in a broad sense. As Andrea Ferretti was saying, the action they perform when they are resumed are usually short; OTOH their state might be kept around for quite a while (possibly the whole application lifetime) |
10:09:26 | evacchi | @krux02 yes, that is basically what you need; that and being able to migrate state across running "tasks" |
10:09:40 | evacchi | but if you cross thread boundaries, again, you are in trouble |
10:10:03 | * | chemist69 quit (Ping timeout: 240 seconds) |
10:10:24 | krux02 | well you could make all tasks single threaded :P |
10:10:34 | * | Vladar joined #nim |
10:10:44 | evacchi | :P |
10:11:15 | evacchi | in some sense you are right; you can "pin" group of actors to one thread, and never migrate them, but that's a bit limiting |
10:11:59 | krux02 | but honestly, I programmed a while now, and almost all situations I encountered where people wanted to spread the work across threads, there was much more potential for optimizing single threaded |
10:13:18 | FromGitter | <andreaferretti> @krux02 it is not about doing things fast |
10:13:20 | evacchi | heh. that's assuming you have control on that. the point of an actor framework is (also) to abstract that kind of detail away |
10:13:29 | FromGitter | <andreaferretti> it is about not blocking work from other actors |
10:13:56 | krux02 | they just needed to do a few easy step: Don't use interpreted scripting languages, don't use pointer heavy data structures with a lot of overhead, organize your data so that you can process it in a linear scan and make sure that there is only data in the scan that is actually used |
10:14:43 | krux02 | those simple steps often give a performance boost in a factor that "spreading out to multiple threads" can only dream of |
10:14:53 | * | chemist69 joined #nim |
10:16:14 | FromGitter | <andreaferretti> @krux02 if you don't have anything to contribute to the question in case - which is about being able to move coroutines between threads - please do not derail the discussion |
10:16:23 | krux02 | maybe working with actors is great, I programmed in scala and I like the idea of no shared state, just messages. |
10:17:24 | krux02 | but on the other side, I did not really use actors for anything |
10:26:08 | krux02 | maybe it is just because I am not a web developer |
10:27:17 | krux02 | sorry, for my unproductive contributions |
10:27:46 | Araq | evacchi: .async await runs "tasks" in a scheduler |
10:28:32 | evacchi | Araq: yes, but you can't migrate tasks across thread boundaries |
10:31:22 | Araq | *shrug*, once I have this problem I'll make the scheduler use multiple threads |
10:31:48 | evacchi | heh :P |
10:32:23 | FromGitter | <andreaferretti> it is not a minor problem though :-) |
10:32:40 | FromGitter | <andreaferretti> one long running async task can block any other async thing |
10:32:51 | FromGitter | <andreaferretti> it is workable the way it is right now |
10:33:09 | FromGitter | <andreaferretti> but for some models of computation (actors in particular) works really badly |
10:33:46 | cheatfate | andreaferretti: is not a problem, just spawn more schedulers using threads/processes |
10:34:32 | FromGitter | <andreaferretti> ok, so here we are to the starting point :-) |
10:34:42 | evacchi | cheatfate: then how do you know when a scheduler is "too busy" ? can you migrate a task scheduled there to one that it is "less busy" ? |
10:34:54 | FromGitter | <andreaferretti> so, the question is |
10:34:54 | FromGitter | <andreaferretti> how to move a task between these threads? |
10:35:36 | cheatfate | evacchi, i dont need to know when scheduler is "too busy" |
10:36:30 | FromGitter | <andreaferretti> you do, if you don't want to starve tasks living in the same scheduler |
10:36:48 | * | arnetheduck joined #nim |
10:37:11 | cheatfate | andreaferretti: but whole program still can work, because other schedulers can work on their clients, while one scheduler will process long-running task |
10:37:13 | krux02 | andreaferetti: do you have example code, where the current Nim solution just doesn't work very well? |
10:37:38 | FromGitter | <andreaferretti> no |
10:38:01 | FromGitter | <andreaferretti> but I think I did not make a very good job in explaining the issue |
10:38:10 | FromGitter | <andreaferretti> let me start from Akka (or any similar framework) |
10:38:32 | cheatfate | what is Akka? |
10:38:52 | FromGitter | <andreaferretti> an actor framework for the JVM |
10:38:56 | FromGitter | <andreaferretti> it allows me to start any number of actors that will be summoned by messages and do a short computation |
10:39:10 | FromGitter | <andreaferretti> actors are scheduled on a thread pool and they can keep state |
10:39:26 | FromGitter | <andreaferretti> because everything that happens inside an actor is single threaded |
10:39:47 | FromGitter | <andreaferretti> the only point of contention is a queue where messages directed to an actor are scheduled |
10:39:50 | * | allan0 left #nim ("WeeChat 1.7") |
10:39:54 | FromGitter | <andreaferretti> this has to be threadsafe |
10:40:07 | FromGitter | <andreaferretti> it is a very simple and convenient mutlithreading model |
10:40:12 | krux02 | andreaferretti: I am not sure if starting from Akka is a good idea, even though I know Akka, I am not very familiar with using it. So I don't know how woll the concepts of akka actually work out |
10:40:29 | FromGitter | <andreaferretti> I have been trying to explain the basics above |
10:40:46 | evacchi | krux02: they've been doing that in Erlang for ages |
10:40:57 | FromGitter | <andreaferretti> now, crucially, the scheduling of actors upon threads is dynamic |
10:41:01 | evacchi | it worked out pretty well for them |
10:41:05 | krux02 | I remember I watched a 1 hour video about Akka explaining all the concepts |
10:41:16 | FromGitter | <andreaferretti> if an actor takes too long for whatever reasons |
10:41:32 | FromGitter | <andreaferretti> the other ones are not blocked, because of the thread pool |
10:41:56 | FromGitter | <andreaferretti> this requires to be able to move the actor state between threads |
10:41:57 | krux02 | it's long aga, but I think one of the most important ones is, that all actors know their parents they spawed from. And whon one actor dies, it will never be unnoticed unlike threads |
10:42:05 | evacchi | the scheduling has to be dynamic *also* because actors may spawn new actors |
10:42:13 | FromGitter | <andreaferretti> just let me finish :-D |
10:42:28 | FromGitter | <andreaferretti> in akka, this is trivial, because the heap is shared |
10:42:48 | FromGitter | <andreaferretti> in erlang, this is trivial again, because each actor has its own heap |
10:43:15 | FromGitter | <andreaferretti> the problem is: how to write a library that allows this model of computation on top of per thread nim heaps? |
10:43:39 | krux02 | the question is, do you need to write it on top of per thread nim heaps? |
10:43:45 | krux02 | Nim also has shared allocation |
10:44:07 | krux02 | and you could implement the erlang model in a nim-actors library |
10:44:15 | FromGitter | <andreaferretti> yes, but this would require that actors never use the stdlib |
10:44:29 | FromGitter | <andreaferretti> I mean, one can do their own things using allocShared |
10:44:38 | evacchi | it would rule-out any kind of garbage collection |
10:44:47 | FromGitter | <andreaferretti> but just have a string in your state and it does not work anymore |
10:44:57 | cheatfate | without real use-case this looks like something too abstract... |
10:45:11 | krux02 | I get the problem |
10:46:02 | FromGitter | <andreaferretti> there are plenty of use cases - from telecom switches to http servers to game servers - most things you can think of have been implemented in the actor model |
10:46:11 | krux02 | I know that c++ has custom allocators for the entire STL |
10:47:00 | FromGitter | <andreaferretti> http://doc.akka.io/docs/akka/current/intro/use-cases.html |
10:47:07 | FromGitter | <andreaferretti> http://stackoverflow.com/questions/1636455/where-is-erlang-used-and-why |
10:47:16 | cheatfate | andreaferretti: i dont think actors model is good enough for networking servers... because you have bottle-neck on receiving connection/message |
10:47:24 | krux02 | If I remember correctly they are pretty useless, because there were not designed with these intentions, but to handle other weird things like far and near pointers, but the idea is that the solution could be that the nim library allows changing the allocator |
10:47:32 | FromGitter | <andreaferretti> whatsapp runs on erlang, spark is written on top of akka and so on |
10:47:55 | krux02 | twitter uses scala (afaik) |
10:49:44 | krux02 | cheatfate: actually it works pretty nice with networking. All you need is an actor on the receiving site that works passes incoming messages to the individual handlers |
10:50:14 | cheatfate | andreaferretti: its very easy to run something in 1000 servers, even if it slow by design... if you know akka so good, is it possible to ask you run benchmark for simple "Hello World" output via network? |
10:50:39 | cheatfate | and then run same benchmark for simple single-threaded asynchttpserver |
10:50:48 | cheatfate | so we can compare design, not approach |
10:50:56 | krux02 | cheatfate: that is not really a good benchmark at all |
10:51:02 | cheatfate | krux02, why? |
10:51:30 | * | zachcarter joined #nim |
10:51:44 | krux02 | well, because akka is designed to work for server clouds |
10:52:17 | krux02 | you can't just send a single "Hello World" from one computer to another, and say hey it's slow/fast |
10:53:07 | evacchi | cheatfate: now you are moving target to remote actor systems which is a completely different thing |
10:53:21 | cheatfate | krux02, but andreaferretti said it can be used for http/game servers |
10:53:39 | evacchi | pony is an "actor language" from the ground up, and it does not implement remoting AFAIK |
10:53:53 | * | PMunch joined #nim |
10:54:06 | evacchi | cheatfate: well at some point, yes; the discussion started with application-local actors |
10:54:07 | FromGitter | <andreaferretti> well, you asked for real case uses |
10:54:22 | FromGitter | <andreaferretti> the point, anyway, is not raw performance |
10:54:27 | FromGitter | <andreaferretti> is not stalling actors |
10:54:27 | krux02 | yes it can be used for game servers, and it can be used in a way that autalmatically when too many requests come it, it triggers to start up another computer in the network that then starts handling requests |
10:54:28 | evacchi | application can still communicate using scokets at network boundaries |
10:54:39 | cheatfate | as for me every cloud based http/game servers can be shrinked to one server |
10:54:39 | evacchi | yet, using actors as the async computation model |
10:55:23 | cheatfate | and also this is one of Akka lights : "50 million msg/sec on a single machine. Small memory footprint; ~2.5 million actors per GB of heap." |
10:55:49 | krux02 | I think Akka is just too big to be part of and standard library. The question is just, what needs to change in the standard library, so that something like Akka is implementable as a third library construct without any conflicts |
10:56:27 | evacchi | we are not talking about writing akka on nim |
10:56:42 | krux02 | I thought so |
10:56:44 | Araq | andreaferretti: not stalling is a hard problem with thread pools |
10:56:52 | evacchi | an actor library is actually a very thin abstraction over threads/coroutines and it can be written in a very few lines of code |
10:58:02 | evacchi | *provided* you have a scheduler impl (to schedule the actor's message handling routine) and concurrent data structures (to hold mailboxes) |
10:58:09 | Araq | you can move the offending task around but without extensive runtime injections it will stay offending aka uncooperative |
10:58:36 | Araq | every 'while' loop has the potential to block a CPU core for good |
10:58:43 | FromGitter | <andreaferretti> yes |
10:59:13 | FromGitter | <andreaferretti> the point is that other actors can run on the other CPUs! |
10:59:26 | Araq | so then it blocks one CPU out of e.g. 16 |
10:59:44 | Araq | but here is the thing: you have lots of tasks |
10:59:54 | Araq | and many tasks share the same code/logic |
11:00:26 | Araq | so eventually you have lots of offensive tasks and every thread in your thread pool is affected |
11:00:49 | FromGitter | <andreaferretti> yeah, it is a problem of course |
11:00:56 | FromGitter | <andreaferretti> but moving tasks between threads mitigates it |
11:01:49 | Araq | that can be good or bad. "mitigating" problems can also mean "you won't find the problem until after 30 days in production" |
11:01:53 | evacchi | well, there's no fix for badly written code |
11:03:02 | krux02 | are you talking about that coroutines that don't schedule, because they are stuck in a while loop? |
11:03:23 | Araq | krux02: yes |
11:04:19 | krux02 | well, I would fix it by documenting it. I mean isn't that the price for coroutines? They are more lightweight, but they can only schedule on certain predefined points? |
11:05:03 | evacchi | (BTW Erlang's actor can be preempted IIRC; OTOH Akka's can't) |
11:05:16 | Araq | yes, but the point is we start with this design and then hack around the design to protect against it :P |
11:06:50 | krux02 | well my solution is to write a timing library that uses the high performance counter of the system to measure the time each actor did not have the chance to schedule. Run it and evaluate your highlights |
11:07:06 | * | evacchi quit (Remote host closed the connection) |
11:07:27 | FromGitter | <andreaferretti> @krux02 really, we are talking about two different things |
11:07:46 | krux02 | ok? |
11:08:17 | FromGitter | <andreaferretti> the question is whether one could be able to move coroutines between threads |
11:08:40 | * | evacchi joined #nim |
11:08:45 | FromGitter | <andreaferretti> no amount of trying to speed up the work they do will completely eradicate the use case |
11:09:18 | Araq | well you can move a task to different thread |
11:09:25 | Araq | you just need to deepcopy its state |
11:09:26 | krux02 | I am sorry when I apper to be stupid today |
11:10:24 | krux02 | I just thought it is not possible to move coroutines between threads, because they use thread local allocations/state |
11:10:35 | FromGitter | <andreaferretti> I think there is just some misunderstanding - talking directly usually clears things up much better than a chat window :-) |
11:10:43 | Araq | I think it's fair to request an explicit 'yieldMoveToDifferentCpu' |
11:11:02 | FromGitter | <andreaferretti> that would definitely be useful! |
11:11:22 | FromGitter | <andreaferretti> even if some deep copy needs to be performed from time to time |
11:11:24 | krux02 | yes I agree |
11:11:50 | Araq | the copy should still be more efficient than a heap per task model |
11:11:54 | krux02 | I think a yieldMoveToDifferentCpu should not happen secrently in the background |
11:12:06 | krux02 | it might be something you want to be aware of, or to avoid entirely |
11:12:26 | Araq | yeah |
11:13:05 | evacchi | Araq: would it ? I mean what if state is relatively large ? (genuinely curious) |
11:13:37 | krux02 | evacchi: that is why it is explicit |
11:13:51 | krux02 | then the programmer can evaluate if it is worth doing it |
11:13:58 | krux02 | or to solve it in a different way |
11:14:38 | Araq | evacchi: heaps per task are not cheap, you can memory fragmentation problems and Erlang under the hood does share iirc to mitigate the problem |
11:14:47 | Araq | *can get |
11:15:03 | evacchi | I see |
11:15:28 | Araq | or at least Nim's current heap implementation is not a good fit for this design |
11:16:07 | krux02 | Araq: where do I find the alloc implementation of nim? |
11:16:19 | Araq | lib/system/alloc.nim |
11:18:11 | evacchi | btw thanks for all the feedback, that was useful |
11:21:48 | Araq | evacchi: you might want to try an thread==actor model for testing purposes |
11:22:19 | Araq | everybody claims threads have too much overhead, but a modern Linux can handle 100_000s of threads |
11:22:36 | Araq | and it uses an O(1) scheduler |
11:23:43 | Araq | and you don't have to deal with this "omg, this IO operation can block" nonsense :-) |
11:24:12 | Araq | (yes, it can block, the OS knows it can then run a different thread on the CPU core) |
11:25:04 | Araq | (the OS also knows how to preempt while true loops running wild) |
11:25:18 | PMunch | Hmm, quick question. When writing a macro, is it possible to get the names of the attributes a function expects? |
11:26:37 | evacchi | yes, although on different kernels threads are less lightweight. e.g. threads on MacOS (which I use for development) have a much lower numeric limit |
11:27:04 | Araq | and Linux uses memory overcommitment for the thread stacks (finally something where overcommit is useful, even for all the wrong reasons) |
11:28:00 | evacchi | http://www.jstorimer.com/blogs/workingwithcode/7970125-how-many-threads-is-too-many |
11:28:17 | * | chemist69 quit (Ping timeout: 255 seconds) |
11:28:36 | Calinou | what about Windows? |
11:30:50 | evacchi | I'm not sure about windows but I think the kernel it's optmized for threads; moreover by peeking at rokups PR I just discovered they have native fibers |
11:30:55 | evacchi | which is pretty cool |
11:37:38 | * | evacchi quit (Remote host closed the connection) |
11:43:32 | cheatfate | windows kernel is not optimized on threads, threads are part of windows kernel every execution in windows is thread specific |
11:44:18 | * | sz0 quit (Quit: Connection closed for inactivity) |
11:46:36 | * | chemist69 joined #nim |
12:00:54 | * | libman quit (Quit: Connection closed for inactivity) |
12:02:08 | * | yglukhov_ joined #nim |
12:02:09 | * | yglukhov quit (Read error: Connection reset by peer) |
12:02:31 | * | Snircle joined #nim |
12:07:51 | * | yay joined #nim |
12:20:37 | * | zachcarter quit (Quit: zachcarter) |
12:29:28 | PMunch | No-one? |
12:29:29 | * | yglukhov_ quit (Read error: Connection reset by peer) |
12:29:44 | * | yglukhov joined #nim |
12:32:45 | * | yglukhov quit (Remote host closed the connection) |
12:33:21 | * | yglukhov joined #nim |
12:36:05 | rokups | PMunch: likely noone understood the question |
12:37:55 | PMunch | Oh sorry, I'm writing a macro that turns a DSL into calls to an existing library. While doing this I've found that it might be useful to check if a certain function call (it's name generated on compile-time based on information from the DSL) has a specific argument. |
12:38:10 | rokups | also moving coroutine to another thread would require deepCopying all the objects whose reference is on coroutine stack for example. its not just coroutine state. |
12:40:00 | rokups | PMunch: its a long time since i wrote macros, but maybe you can pass that func to a macro and dump ast or something? |
12:40:44 | * | yglukhov quit (Ping timeout: 255 seconds) |
12:40:50 | PMunch | Hmm, I don't think so. Since the AST doesn't immediately identify the parameter names.. |
12:41:05 | Araq | PMunch: you can use getType in the macro and the type has parameter info |
12:41:19 | PMunch | Ah, okay. Thanks :) |
12:41:20 | Araq | but for this the AST has to be 'typed' |
12:41:25 | PMunch | Hmm |
12:41:31 | krux02 | PMunch: you can also get the ast of proc implementations |
12:42:04 | krux02 | there you might get the names of proc parameters |
12:46:31 | PMunch | Hmm, another question. This macro takes things on the form "Element(parameter = true): <children>" where <children> is a list of similar elements. Is there some form of list comprehension that can give me the parts separately or would I have to parse it manually? I.e. can I somehow get "Element", ["parameter": "true"], [<children>] |
12:47:50 | Araq | manually here seems to mean x[0], x[1], x[2] |
12:48:24 | PMunch | Well x[0], x[1..<x.high], x[x.high] |
12:48:56 | PMunch | You could have Element(parameter = true, something = "else"): <children> |
12:49:18 | PMunch | Which would come out as a Call with an Ident, two ExprEqExpr, and a StmtList |
12:50:58 | * | Arrrr quit (Ping timeout: 240 seconds) |
12:51:30 | * | yglukhov joined #nim |
13:00:06 | stisa | Not sure what you mean, maybe loop over element and use copychildrento to copy childrens to a nnkstmt or something? |
13:01:19 | krux02 | I have a lot of error messages in my code from my editor, but it just compiles fine |
13:01:26 | krux02 | how can that happen? |
13:03:00 | stisa | problems with nimsuggest maybe? |
13:04:41 | krux02 | stisa: yes that is basically what I said |
13:04:53 | krux02 | I just updated nimsuggest to the latest version |
13:11:37 | cheatfate | krux02, what is level of verbosity? |
13:13:29 | cheatfate | and what editor you use? |
13:13:51 | niv | can someone explain to my why some stdlib calls use BiggestInt, and some use int? particularily, getFileSize(): BiggestInt; but all the io seek/set procs just use the system int |
13:16:56 | krux02 | I use emacs |
13:17:06 | krux02 | and it is something that worked in the past |
13:17:31 | krux02 | cheatfate: it is not horrible, but it is wrong |
13:17:50 | krux02 | I have around 10 wrong error reports |
13:18:03 | krux02 | in 400 lines of code |
13:18:03 | cheatfate | krux02, then maybe you should report it |
13:19:43 | krux02 | last time I reported something for emacs, was in december, I didn't even get a reply: https://github.com/nim-lang/nim-mode/issues/147 |
13:20:22 | * | xet7 quit (Quit: Leaving) |
13:28:33 | PMunch | Is there a way to get a slice out of an object with a [] procedure? Stuff you can normally call with something[5] to get it's 5th element, is there a way to do something[1..5] to get only elements 1 through 5? |
13:30:26 | FromGitter | <andreaferretti> https://nim-lang.org/docs/system.html#[],seq[T],Slice[int] |
13:31:49 | PMunch | Well it's not really a sequence, it just has a [] procedure |
13:32:21 | FromGitter | <andreaferretti> ah, I don't think so |
13:32:31 | FromGitter | <andreaferretti> you can write your own |
13:32:41 | FromGitter | <andreaferretti> system has it for seqs, strings and arrays |
13:33:10 | PMunch | Yeah, writing my own now based on the source of the method you sent |
13:33:35 | PMunch | It's for NimNodes so maybe it should be part of the macros module Araq? |
13:43:56 | krux02 | PMunch, yes it's a loop |
13:44:49 | krux02 | PMunch: do you plan to write one that returns a seq? |
13:44:58 | * | zachcarter joined #nim |
13:45:20 | PMunch | Currently I just grabbed the one for seqs and modified it like this http://ix.io/nKs |
13:46:04 | zachcarter | So I’ve made these Nuklear bindings, but the Nuklear header file has a lot of structs which contain members named things like ptr and pointer |
13:46:51 | zachcarter | I’m compiling the nuklear file like this - https://github.com/zacharycarter/nuklear-nim/blob/master/nuklear.nim#L3 |
13:47:02 | zachcarter | https://github.com/zacharycarter/nuklear-nim/blob/master/src/bind.c |
13:47:21 | PMunch | Also added the micro-proc high: http://ix.io/nKt |
13:47:44 | zachcarter | is there any way to do name mangling on the header file before compilation? |
13:47:58 | zachcarter | I don’t want to touch nuklear.h if I can avoid it... |
13:48:09 | krux02 | PMunch: I also once tried to add high |
13:48:13 | zachcarter | and I’d like to keep nuklear imported as a submodule |
13:48:16 | krux02 | did not work out very well |
13:48:49 | krux02 | when it's defined in the same module it worked fine, but imported from somewhere else it did not work |
13:49:28 | * | nsf quit (Quit: WeeChat 1.7) |
13:49:41 | krux02 | zachcarter: do you know git subtrees? |
13:49:57 | zachcarter | negative krux02 |
13:50:19 | krux02 | it is basically what you want to solve |
13:50:25 | zachcarter | okay let me read up on them |
13:50:51 | krux02 | the important bit it, that it allows you to commit to the subtree |
13:51:11 | krux02 | so you can touch nuklear.h and still get updates |
13:51:50 | zachcarter | okay sweet thank you |
13:51:52 | krux02 | nice side effect is, that your repository can be cloned without being aware of submodules/subtrees, they get automatically cloned, too. |
13:51:59 | zachcarter | ah sweet |
13:52:08 | zachcarter | alright I’ll ditch the submodule and go for a subtree |
13:52:09 | rokups | you are talking of submodules, and commit would go into submodule git repo, not to main repo |
13:52:23 | krux02 | I am talking about subtrees |
13:52:45 | rokups | uh.. this is a new thing? |
13:52:47 | zachcarter | yeah subtree sounds like a better solution that my current submodule thing |
13:52:49 | krux02 | https://developer.atlassian.com/blog/2015/05/the-power-of-git-subtree/ |
13:52:57 | zachcarter | that’s the article I’m reading |
13:53:07 | krux02 | it's the first to find on google |
13:53:12 | rokups | live and learn lol |
13:53:12 | zachcarter | :D |
13:53:13 | krux02 | and it is good |
13:53:30 | zachcarter | I think these ptr and pointer fields are causing me a lot of issues with nuklear |
13:53:47 | zachcarter | not sure what I should be naming them |
13:54:06 | krux02 | well you could keep the name and live with the backticks |
13:54:13 | rokups | zachcarter: what exactly is a problem with the fields? |
13:54:38 | zachcarter | so I’m doing this nil check here - |
13:54:45 | zachcarter | if not cmd.texture.`ptr`.isNil: |
13:55:01 | zachcarter | even if that check passes |
13:55:10 | zachcarter | and I try to do something like - |
13:55:11 | Araq | https://mail.python.org/pipermail/python-dev/2012-December/123028.html |
13:55:18 | Araq | we should do the same |
13:55:29 | Araq | optimize our tables data structure |
13:55:31 | zachcarter | let textureHandle = cast[ptr TextureHandle](cmd.texture.`ptr`) |
13:55:31 | zachcarter | if not textureHandle.isNil: |
13:55:32 | zachcarter | if textureHandle[] == TextureHandle(): |
13:55:33 | zachcarter | echo "HERE" |
13:55:39 | rokups | ah that, you can name struct field to something more appropriate, sec ill show u how |
13:55:55 | zachcarter | I’ll get a segfaul |
13:55:57 | zachcarter | tt |
13:56:04 | zachcarter | like I”m trying to dereference a null pointer |
13:56:35 | rokups | pointr {.importc: "ptr".}: pointer |
13:56:59 | rokups | good luck on figuring out a good name |
13:57:04 | zachcarter | thank you |
13:57:35 | rokups | Araq: i dont really see where exactly list of procs could be attached to a type. point me to the file/proc :| |
13:57:43 | PMunch | krux02, huh. That's weird, but I'm only using it in one module here so that's fine |
13:58:04 | PMunch | Araq, I actually saw a talk about that recently |
13:58:28 | PMunch | Basically showed all the iterations that the Python tables implementation has had |
13:58:54 | PMunch | And I thought about writing those kinds of tables for Nim |
14:04:58 | zachcarter | hrm - rokups what I can I do about method signatures and reserved keywords and bindings to C? |
14:05:02 | zachcarter | anything? |
14:05:14 | zachcarter | or the same thing? |
14:05:40 | rokups | zachcarter: if you are talking about names of func parameters - they are irrelevant |
14:05:48 | zachcarter | ah okay |
14:06:00 | zachcarter | thanks |
14:07:39 | krux02 | Araq: I like the hash memory optimization |
14:08:31 | krux02 | Not sure about the performance, but my guess would be that the performance difference is neglible |
14:09:54 | Araq | I think OrderedTable should have use this optimization which is also used heavily for json |
14:09:56 | PMunch | krux02, you might be surprised |
14:10:07 | Araq | and we had reports json is eating too much RAM |
14:15:03 | zachcarter | hrm rokups - I’m getting compilation errors when trying to compile my bindings using your suggestion, not sure why but the errors are specific to the type members I changed from using backticks to the importc pragma |
14:15:05 | zachcarter | so like |
14:15:18 | zachcarter | nk_handle* = object {.union.} |
14:15:18 | zachcarter | pointr* {.importc: "ptr".}: pointer |
14:15:19 | zachcarter | id*: cint |
14:15:46 | zachcarter | nuklear_nuklear.c:261:44: error: no member named 'ptr' in 'nkhandle_lOpzfyOGEOkCq7IVFDfLiA' |
14:15:47 | zachcarter | T_TA49blRGL9cD0tQs9aEM0rD3w_0[38].offset = offsetof(nkhandle_lOpzfyOGEOkCq7IVFDfLiA, ptr); |
14:16:29 | zachcarter | I’m guessing maybe because other C code tries to refer to that ptr field? |
14:16:42 | rokups | zachcarter: you should importc structs as well |
14:17:01 | rokups | otherwise you are redefining compatible struct, but i do not think it is a safe approach |
14:17:08 | rokups | and in this case its not even compatible |
14:17:11 | zachcarter | ah okay |
14:17:28 | * | bjz_ quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…) |
14:17:35 | rokups | https://gist.github.com/8b32a4035a25a983439978283399d4b7 |
14:17:53 | rokups | full example |
14:17:55 | zachcarter | thank you |
14:18:06 | zachcarter | didn’t know I could do this |
14:19:43 | Araq | rokups: grep for x.methods.safeAdd((col,s)) |
14:19:54 | rokups | ty |
14:21:45 | rokups | but you should really stop using one/two letter abbreviated variables. its easy to loose one's head in there due to this :p |
14:25:35 | Araq | I never use more than 14 of them at the same time |
14:26:24 | Learath2 | libsodium wrapper returns publickeys in strings, i want to put them in array[32, uint8], currently i just loop and assign char by char, is there a better way? |
14:26:44 | Araq | learath2: no |
14:27:03 | * | couven92 quit (Read error: Connection reset by peer) |
14:27:30 | Learath2 | is it even correct to return strings which might contain null bytes |
14:28:03 | Araq | yeah |
14:28:53 | Learath2 | hmm always thought null bytes were somehow important in nim strings :P guess i was wrong |
14:32:57 | PMunch | Huh, why can't you have a tuple type with a list of it's own type inside of it? |
14:33:38 | PMunch | Oh wait, yeah that makes sense |
14:34:30 | zachcarter | hrm rokups: this is turning into a disaster for me :P |
14:34:50 | PMunch | Hmm, I now declared it to have a ptr to a seq[<type>]. That means I have to instantiate the seq explicitly right? |
14:35:13 | zachcarter | https://gist.github.com/zacharycarter/ebf9740c13e065e026f8b1ca3563afd9 |
14:35:44 | rokups | zachcarter: you are overreacting :p show me nim code instead |
14:36:27 | zachcarter | okay so let me show you what I’ve done, give you a little context here |
14:36:42 | zachcarter | here’s my original bindings - https://github.com/zacharycarter/nuklear-nim/blob/master/nuklear.nim |
14:36:55 | zachcarter | here’s the header file I’m binding to ( it’s a bear ) - |
14:37:13 | zachcarter | https://github.com/vurtun/nuklear/blob/5f78107fc5fa50345e31190bf6d4b2224080a646/nuklear.h |
14:37:57 | zachcarter | now these bindings for the most part work - but I’m noticing in certain structures in nuklear.h where he’s using reserved Nim keywords as struct member names, I’m getting some weird results in Nim |
14:38:19 | zachcarter | for instance here - https://github.com/vurtun/nuklear/blob/5f78107fc5fa50345e31190bf6d4b2224080a646/nuklear.h#L456 |
14:39:57 | zachcarter | all I did to account for these reserved names, was add backticks to the corresponding member properties in the nim objects |
14:40:15 | Araq | this is not a header file, this has full function bodies |
14:40:25 | zachcarter | it’s a single header library |
14:40:39 | zachcarter | sorry I should have specified |
14:40:43 | Araq | you can't #include it more than once |
14:40:50 | Araq | so how is it a header file? |
14:41:09 | zachcarter | I guess it’s not |
14:41:11 | rokups | code builds only when some preprocessor variable is defined |
14:41:21 | zachcarter | code’s only included yeah |
14:41:25 | zachcarter | that’s what this file is for - |
14:41:39 | zachcarter | https://github.com/zacharycarter/nuklear-nim/blob/master/src/bind.c |
14:41:42 | zachcarter | and in my bindings - |
14:41:53 | zachcarter | https://github.com/zacharycarter/nuklear-nim/blob/master/nuklear.nim#L3 |
14:43:01 | zachcarter | if I do as you suggested rokups and try to define any of the types like - https://gist.github.com/rokups/8b32a4035a25a983439978283399d4b7 |
14:43:16 | zachcarter | (I didn’t include the header pragma as I wasn’t sure how to resolve that) |
14:43:28 | Araq | you're doing it wrong |
14:43:29 | FromGitter | <Varriount> Jabb: What kind of state would need to be shared among workers? |
14:43:35 | zachcarter | okay |
14:43:39 | Araq | {.compile: "foo.c".} |
14:43:51 | Araq | type WeAreFree = object |
14:44:05 | Araq | x, y: cint # only layouts have to match |
14:44:24 | zachcarter | ahhh okay |
14:44:33 | Araq | proc foo(x: WeAreFree) {.importc: "foO", cdecl.} |
14:45:18 | * | rauss joined #nim |
14:46:11 | zachcarter | so I have my pragmas mixed up and only layouts have to match is what you’re pointing out correct Araq? |
14:46:19 | * | yglukhov quit (Remote host closed the connection) |
14:46:27 | rokups | and what if struct has custom alignment or something? matching layout will blow up in your face |
14:46:54 | * | yglukhov joined #nim |
14:47:02 | Araq | and what if you want it to work on the LLVM backend? |
14:47:05 | rokups | its ok most of the time though. zachcarter you were handed a shotgun, now its your turn to be responsible ^_^ |
14:47:21 | zachcarter | :) |
14:47:55 | Araq | fucking around in C land is worse than the occasional alignment problems which usually indicate stupid C code you don't want to use |
14:48:18 | zachcarter | so does importc need to come before cdecl? |
14:48:24 | Araq | no. |
14:48:38 | zachcarter | okay, I wasn’t sure if that was a mistake I was making too or not, thank you |
14:49:51 | rokups | if only we could avoid using all the stupid c code is out there ;) |
14:49:58 | Learath2 | uhm what does the syntax prox x*[y] mean? |
14:50:34 | rokups | Araq: overriding virtual methods - should they be nim methods or procs? |
14:50:45 | Araq | methods |
14:50:58 | * | yglukhov quit (Ping timeout: 240 seconds) |
14:51:41 | Araq | yummy, nimsuggest's memory leaks are gone :-) |
14:51:57 | zachcarter | I’d like to avoid using the stupid c code out there but there’s too much not written in pure nim yet |
14:52:10 | zachcarter | and no one is signing up to port 17k lines of C code to nim atm |
14:52:13 | zachcarter | :/ |
14:52:17 | zachcarter | myself included |
14:52:33 | rokups | langserver protocol support wanted for nimsuggest |
14:52:58 | rokups | ability to configure suggestion format (camelCase/snake_case) for nimsuggest wanted |
14:54:36 | Araq | c2nim can translate C function bodies too :P |
14:54:52 | Araq | rokups: link? |
14:55:29 | rokups | Araq: http://langserver.org/ |
14:55:52 | rokups | that thing is getting popular, clang recently got it's langserver. opens up potentially easy IDE support |
14:56:40 | zachcarter | Araq: this is true, I did start working on a port at one point but certain C constructs stumped me |
14:56:43 | zachcarter | I’m not the best C programmer |
14:56:57 | zachcarter | I have 4 days off next week, maybe I’ll give it another go |
14:57:00 | FromGitter | <evacchi> isn't vscode nim support already langserver-based ? |
14:58:55 | FromGitter | <evacchi> (huh; i could have sworn it) |
14:59:44 | Araq | no that uses the EPC protocol that is compatible with emacs |
15:01:36 | rokups | emacs has langserver support as well by the way. do any other editors support EPC? |
15:01:58 | rokups | err sorry, emacs lsp support is work in progress |
15:03:09 | * | yglukhov joined #nim |
15:04:50 | * | Arrrr joined #nim |
15:04:51 | * | Arrrr quit (Changing host) |
15:04:51 | * | Arrrr joined #nim |
15:12:32 | * | vlad1777d joined #nim |
15:26:25 | Araq | * The kind of a completion entry. |
15:26:25 | Araq | */ |
15:26:25 | Araq | namespace CompletionItemKind { |
15:26:25 | Araq | export const Text = 1; |
15:26:26 | Araq | export const Method = 2; |
15:26:27 | Araq | export const Function = 3; |
15:26:29 | Araq | export const Constructor = 4; |
15:26:30 | Araq | export const Field = 5; |
15:26:31 | Araq | export const Variable = 6; |
15:26:32 | Araq | export const Class = 7; |
15:26:33 | Araq | export const Interface = 8; |
15:26:34 | Araq | export const Module = 9; |
15:26:35 | Araq | export const Property = 10; |
15:26:36 | Araq | export const Unit = 11; |
15:26:37 | Araq | export const Value = 12; |
15:26:38 | Araq | export const Enum = 13; |
15:26:39 | Araq | export const Keyword = 14; |
15:26:40 | Araq | export const Snippet = 15; |
15:26:41 | Araq | export const Color = 16; |
15:26:42 | Araq | export const File = 17; |
15:26:43 | Araq | export const Reference = 18; |
15:26:44 | Araq | } |
15:26:45 | Araq | meh, that doesn't look well thought-out |
15:26:58 | Araq | Nim has concepts that do not map to these easily |
15:28:09 | rokups | i do not think this stuff i set in stone. concepts are bound to be added anyway because they are coming in c++ |
15:28:35 | rokups | so its just PR-away i guess ;) |
15:29:02 | Araq | no I mean concepts like "macro" |
15:29:14 | Araq | or "type" (that's not a class...) |
15:35:37 | * | Vladar quit (Quit: Leaving) |
15:42:02 | PMunch | Given a tuple(name:string, arguments:seq[NimNode]) where arguments are ExprEqExpr. What's the best way to create a let somesym = name(arguments)" |
15:42:30 | PMunch | Currently I'm creating the NimNodes and putting them together |
15:43:43 | krux02 | Araq: I see color is a very important completion item kind |
15:45:12 | krux02 | PMunch: let sym = genSym(nskLet, name) |
15:45:56 | krux02 | no |
15:46:13 | PMunch | Well, I'd want the result of a let statement be visible after the macro. So that would be a regular let |
15:46:16 | PMunch | Not a gensymlet |
15:47:32 | krux02 | well you can use quote do and there is a pragma that lets you make an identifier visible outside of the macro |
15:48:05 | krux02 | but it's best when the identifier comes from user code in some why, then you also don't need to hack it visible |
15:48:19 | PMunch | Hmm |
15:48:23 | krux02 | macrocall(myIdent) |
15:48:32 | PMunch | The thing is I'm creating a macro to generate UIs |
15:49:00 | PMunch | And sometimes it's necessary to have a reference to certain elements |
15:49:19 | krux02 | well it's best when you create a full example of pastebin |
15:49:30 | krux02 | otherwise I don't understan what you are talking about |
15:49:31 | PMunch | So I wanted to include a syntax in order to scope those as lets or vars |
15:49:50 | krux02 | include a syntax? |
15:49:53 | krux02 | what does that mean? |
15:50:14 | PMunch | http://ix.io/nKA |
15:50:20 | PMunch | That's my DSL so far |
15:50:56 | krux02 | ok that's looks a lot like qt :P |
15:51:15 | PMunch | () is arguments to the widget, [] is widgets for the add function (when adding as a child), <name>% is create an identifier (what I'm talking about atm). |
15:51:42 | * | yglukhov quit (Remote host closed the connection) |
15:52:05 | krux02 | where do you create an identifier? |
15:52:16 | PMunch | So in that snippet you would be able to do myButton.text = "woo" after calling the macro |
15:52:18 | * | yglukhov joined #nim |
15:52:25 | krux02 | ah myButten |
15:52:33 | * | yglukhov quit (Remote host closed the connection) |
15:52:44 | krux02 | I would say, take the identifier you get from the ast |
15:52:48 | * | yglukhov joined #nim |
15:52:50 | krux02 | don't transform it to a string |
15:52:55 | krux02 | keep it as a nimNode |
15:53:10 | PMunch | That's what I currently have |
15:53:10 | krux02 | and it will be visible automatically in user code |
15:53:15 | PMunch | Oh |
15:53:29 | PMunch | So if I just reuse the Ident it should be fine? |
15:53:34 | krux02 | yes |
15:53:55 | krux02 | reusing idents is also useful, because the NimNode has positional information |
15:54:05 | PMunch | Aaah, that's cool |
15:54:42 | krux02 | for example you can pass a NimNode to the error proc, so that the error message from the compiler emits locations in the dsl |
15:58:25 | * | rosshadden quit (Ping timeout: 260 seconds) |
16:00:39 | * | rosshadden joined #nim |
16:00:58 | * | themagician joined #nim |
16:05:53 | * | arnetheduck quit (Ping timeout: 260 seconds) |
16:13:43 | * | Trustable joined #nim |
16:23:20 | * | yglukhov quit (Remote host closed the connection) |
16:23:53 | * | yglukhov joined #nim |
16:24:35 | krux02 | Araq: is it possible to pass a function symbol to a generic? |
16:25:06 | krux02 | the idea is, that I do not want to pass a simple closure, but a set of function overloads |
16:26:24 | Araq | well that's what 'mixin' is for? |
16:27:00 | Araq | a set of overloaded procs has no type though, so if you wanna pass it explicitly the generic has to be a template |
16:27:58 | * | yglukhov_ joined #nim |
16:30:28 | * | yglukhov quit (Ping timeout: 240 seconds) |
16:32:29 | * | yglukhov_ quit (Ping timeout: 260 seconds) |
16:32:39 | krux02 | so I have to use a template I guess |
16:33:25 | * | gmpreussner quit (Ping timeout: 260 seconds) |
16:36:09 | PMunch | How do I check if an ident already exists in the scope? |
16:36:45 | PMunch | I want to either do "ident = <element>" or "var ident = <element>" depending on if it exists or not |
16:36:51 | * | nsf joined #nim |
16:37:46 | FromGitter | <andreaferretti> `when defined(blah):` |
16:38:06 | FromGitter | <andreaferretti> or `when declared(blah):` |
16:38:11 | FromGitter | <andreaferretti> I always mix them |
16:39:55 | PMunch | In a macro? |
16:41:05 | FromGitter | <andreaferretti> no, in normal context |
16:41:17 | FromGitter | <andreaferretti> but you can write a macro that produces this (I think) |
16:41:22 | PMunch | Hmm |
16:41:28 | zachcarter | can someone help me understand why this is happening - https://gist.github.com/zacharycarter/5a4df1496cd01727462d8211f8d83fba |
16:41:53 | zachcarter | in my nim code when I echo image.handle.id I get 2 |
16:41:57 | zachcarter | in my c code I get 0 |
16:42:50 | * | abeaumont quit (Ping timeout: 255 seconds) |
16:42:54 | * | shodan45 quit (Ping timeout: 252 seconds) |
16:43:19 | * | rektide_ quit (Ping timeout: 245 seconds) |
16:44:11 | * | gmpreussner joined #nim |
16:44:49 | * | Andris_zbx quit (Remote host closed the connection) |
16:47:21 | * | filcuc quit (Quit: KVIrc 4.9.2 Aria http://www.kvirc.net/) |
16:51:01 | * | shodan45 joined #nim |
16:52:28 | PMunch | Hmm, andreaferretti. Now I've got http://ix.io/nKB and call it by "result.add getAst(updateOrCreate(widget.identifier, asgn))" where widget.identifier is an Ident and asgn is a NimNode(nnkAsgn) |
16:52:33 | PMunch | But I get all kinds of errors |
16:52:43 | PMunch | That the symbols don't have a type.. |
16:54:00 | FromGitter | <andreaferretti> sorry, cannot help you |
16:54:07 | FromGitter | <andreaferretti> was just some random idea |
16:54:29 | PMunch | I think it would work if I can get it running :P |
16:55:54 | zachcarter | I think maybe my problem has to do with the union? |
16:56:16 | PMunch | I mean, this works fine: http://ix.io/nKD |
16:58:31 | zachcarter | PMunch: I can try fooling around with it if you can put together a self contained example for me |
16:58:41 | PMunch | Hmm |
16:58:43 | PMunch | Hold on |
16:58:44 | zachcarter | since I can’t figure out my C binding code problem |
17:04:43 | PMunch | http://ix.io/nKF |
17:04:45 | PMunch | There you go |
17:04:48 | zachcarter | thanks |
17:05:01 | PMunch | Both the commented out version and the other should work in the end |
17:05:05 | PMunch | Currently only the top one works |
17:05:27 | zachcarter | gotcha |
17:06:48 | zachcarter | hrm PMunch this works for me - |
17:07:07 | zachcarter | https://gist.github.com/zacharycarter/5f7c49ec7ba5ed66dd931cbe6e0e3d6a |
17:07:16 | zachcarter | not sure if I’m misunderstanding what you’re trying to do |
17:08:29 | zachcarter | that’s a pretty nifty trick though |
17:08:30 | PMunch | Wait, that works for you? |
17:08:32 | zachcarter | yes it does |
17:08:33 | demi- | zachcarter: don't you have to declare the type the nim type is related to for that to work correctly? |
17:08:40 | demi- | (for your code problem) |
17:08:51 | PMunch | Nim version? |
17:08:57 | zachcarter | devel PMunch |
17:09:11 | zachcarter | demi-: which type would that be |
17:09:13 | PMunch | Yeah but which? :P |
17:09:16 | zachcarter | actually PMunch 16.1 |
17:09:22 | demi- | the union declaration you have |
17:09:28 | PMunch | Hmm, I'm on 0.16.1 as well |
17:09:33 | zachcarter | Nim Compiler Version 0.16.1 (2017-01-31) [MacOSX: amd64] |
17:09:34 | zachcarter | Copyright (c) 2006-2017 by Andreas Rumpf |
17:09:35 | zachcarter | git hash: 8071648129909d47ff7d8d071938ba4c078fc7e4 |
17:09:36 | zachcarter | active boot switches: -d:release |
17:09:40 | zachcarter | ah demi-: I do have that declared |
17:09:56 | zachcarter | type |
17:09:57 | zachcarter | nk_handle* = object {.union.} |
17:09:58 | zachcarter | pointr*: pointer |
17:09:59 | zachcarter | id*: cint |
17:10:10 | * | nsf quit (Quit: WeeChat 1.7) |
17:10:25 | zachcarter | oh I see what you mean demi |
17:10:28 | demi- | no i mean, a {.cdecl: "nk_handle", union.} |
17:10:35 | zachcarter | right right |
17:10:35 | demi- | or whatever |
17:10:42 | zachcarter | hrm I hadn’t ever tried that let me see if that works |
17:10:43 | demi- | importc, i think |
17:11:21 | PMunch | Hmm, my version is younger than yours.. |
17:11:24 | PMunch | 55782205a4bcbe8584fbb96425ae530a302be15f |
17:12:24 | dom96 | hello guys |
17:12:32 | PMunch | Hi dom96 |
17:13:06 | dom96 | How are things? |
17:13:23 | zachcarter | demi:- not working |
17:13:24 | zachcarter | https://gist.github.com/zacharycarter/5a4df1496cd01727462d8211f8d83fba |
17:13:26 | zachcarter | updated gist |
17:13:57 | zachcarter | PMunch: interesting, wonder what changed between versions to allow it to work |
17:14:03 | Learath2 | system.writeLine seems broken :/ http://paste.pr0.tips/Hq ./test genkey test.key only has 1 newlines but i call writeline 3 times on it :/ |
17:14:15 | PMunch | Yeah, me too |
17:14:21 | PMunch | And if it was intentional or not.. |
17:14:22 | Learath2 | disclaimer: its very possible that i messed up too :P |
17:14:34 | PMunch | Araq, would you know? |
17:15:14 | PMunch | https://gist.github.com/zacharycarter/5f7c49ec7ba5ed66dd931cbe6e0e3d6a That runs on git hash: 8071648129909d47ff7d8d071938ba4c078fc7e4 but not on git hash: 55782205a4bcbe8584fbb96425ae530a302be15f |
17:15:35 | dom96 | Ooh, lot's of people asking questions, I like it :) |
17:15:57 | PMunch | Haha yeah it's busy here today :) |
17:15:58 | zachcarter | dom96: maybe you can help me with this binding problem I’m having - https://gist.github.com/zacharycarter/5a4df1496cd01727462d8211f8d83fba |
17:16:06 | demi- | PMunch: you could just git bisect it? |
17:16:10 | zachcarter | it’s making zero sense to me |
17:16:49 | dom96 | Learath2: that's a lot of code, try reproducing it in a small sample, it will probably help you find the problem (if it is your fault) and if not then it will make it easier for us to test. |
17:17:38 | PMunch | demi-, hmm time to learn bisect then? |
17:17:55 | dom96 | zachcarter: the {.union.} looks suspect to me, although I guess it should work since the C type def is a union. |
17:17:59 | demi- | yeah, it is pretty easy https://git-scm.com/docs/git-bisect |
17:18:06 | dom96 | zachcarter: still, give it a try without |
17:18:09 | zachcarter | okay |
17:18:26 | zachcarter | even without I print 0 from C :/ |
17:18:29 | PMunch | Huh, reading the man page now. That actually seems super useful :S |
17:18:58 | dom96 | zachcarter: oh, it's the C that's printing 0 |
17:18:59 | dom96 | hrm |
17:19:01 | zachcarter | yeah |
17:19:12 | zachcarter | Nim is printing what I expect |
17:19:19 | zachcarter | which is 2 |
17:21:50 | PMunch | Hmm, when I have nim installed. Do I need to do the whole csources dance? Or is that just for bootstrapping? |
17:21:58 | Learath2 | dom96: turned out to be a great idea :P figured it out |
17:22:08 | dom96 | Learath2: :D |
17:22:20 | dom96 | zachcarter: gonna try compiling it locally |
17:23:28 | * | Nobabs27 joined #nim |
17:24:42 | Learath2 | just need to work out the algorithm to verify the certs and im done \o/ |
17:24:53 | Learath2 | oops w/c |
17:27:36 | zachcarter | dom96: thanks |
17:30:12 | zachcarter | dom96: going to switch from IRC to gitter |
17:30:37 | PMunch | :/ |
17:30:39 | PMunch | Poor IRC |
17:30:46 | zachcarter | oh I prefer IRC |
17:30:52 | zachcarter | i’m just about to go mobile and get in the car |
17:30:57 | PMunch | Ah right |
17:31:09 | PMunch | I thought you meant a permanent switch :P |
17:31:13 | zachcarter | haha nan |
17:31:15 | zachcarter | nah* |
17:31:32 | * | zachcarter quit (Quit: zachcarter) |
17:37:31 | FromGitter | <ivankoster> hmm, i want to cast a uint32 with the most significant bit set to an int32 but it throws an overflow exception. I just want to interpret the bit pattern as an int32, how do i prevent the error from throwing? |
17:38:39 | PMunch | Hmm, when I pull the branch zachcarter had I still can't get the code to run.. |
17:39:37 | FromGitter | <zacharycarter> Weird... |
17:40:03 | PMunch | http://ix.io/nKI |
17:40:24 | PMunch | That's the code I have, the run which fails, and my Nim version |
17:41:10 | PMunch | The treeRepr looks weird, but if it worked for zacharycarter I don't see why it shouldn't work for me.. |
17:41:34 | PMunch | zacharycarter, which OS are you on? |
17:41:47 | FromGitter | <zacharycarter> Osx sierra |
17:41:57 | FromGitter | <ivankoster> ```var x = 0xFFFFFFFF'u32 ⏎ echo((int32)x) # throws overflow exception``` ⏎ ⏎ How to make this work? I'm dealing with a low level protocol. Sorry for interrupting ! [https://gitter.im/nim-lang/Nim?at=58b07064e961e53c7f61861d] |
17:42:52 | dom96 | PMunch: did you rebootstrap? |
17:43:13 | PMunch | Yeah |
17:43:26 | PMunch | rm csources, pull it, build.sh, the whole thing |
17:43:29 | dom96 | ivankoster: try cast[int32](x) |
17:43:32 | FromGitter | <krux02> how about -1? |
17:43:32 | FromGitter | <krux02> or do a cast |
17:43:41 | FromGitter | <krux02> castint32 (x) |
17:44:21 | FromGitter | <krux02> ``castint32 (x)`` |
17:44:24 | FromGitter | <Varriount> I didn't even realize Nim supported the `(type)value` casting notation |
17:44:41 | FromGitter | <zacharycarter> Same |
17:44:44 | * | Vladar joined #nim |
17:44:45 | FromGitter | <Varriount> Then again, that probably resolves to `type value` |
17:45:20 | dom96 | PMunch: and koch boot as well? |
17:45:27 | demi- | ivankoster because it generates range checks: https://gist.github.com/samdmarshall/e48fc5b5598a5e173af6e84eb97229e0#file-default-txt-L4 |
17:45:32 | dom96 | you don't need to re-build from C sources btw |
17:45:56 | dom96 | Can't wait to finish `choosenim`, it will make this stuff so much more magical and easy (hopefully) :) |
17:46:39 | FromGitter | <ivankoster> Thanks guys, `castint32 (x)` indeed works :D |
17:46:42 | * | Trustable quit (Remote host closed the connection) |
17:47:26 | * | gokr joined #nim |
17:47:58 | FromGitter | <ivankoster> then i guess `(int32)x` is not really a cast but a conversion, and `castT ()` is an actual cast? |
17:48:01 | demi- | dom96: is that going to be like `*env` for most other languages |
17:48:06 | krux02 | trying to post ``cast[int32](x)`` either fails on the irc side or on the gitter side |
17:48:20 | krux02 | wow that one actually worked |
17:48:25 | krux02 | double backticks |
17:48:30 | PMunch | dom96, now I did "git checkout 8071648129909d47ff7d8d071938ba4c078fc7e4" "bin/nim koch c" "./koch boot -d:release" |
17:48:36 | PMunch | Still won't work |
17:48:54 | krux02 | it's not different than ``int32(x)`` |
17:49:00 | krux02 | it's a conversion |
17:49:38 | dom96 | demi-: yes, like rustup |
17:49:44 | krux02 | and ``(int32)x`` is a but different in the ast, but it is at the moment equivalent of a call |
17:49:45 | demi- | cool |
17:50:00 | FromGitter | <ivankoster> AH, thanks @krux02 that explains it |
17:50:18 | krux02 | I would not recommend using it at all |
17:50:36 | dom96 | krux02: submit a bug report to BlaXpirit's repo :) |
17:50:57 | FromGitter | <ivankoster> Im making google protobuf for nim, i have no choice but to cast. low level protocols .. |
17:51:15 | * | handlex joined #nim |
17:51:17 | FromGitter | <ivankoster> brb dinner |
17:51:37 | krux02 | dom96: a bug report for what? |
17:51:51 | PMunch | Now I even went back to 0.16.0, bug persists |
17:51:59 | PMunch | dom96, do you get the code to run? |
17:52:03 | dom96 | krux02: For FromGitter |
17:52:08 | PMunch | https://gist.github.com/zacharycarter/5f7c49ec7ba5ed66dd931cbe6e0e3d6a |
17:53:05 | * | vlad1777d quit (Quit: Leaving) |
17:55:36 | krux02 | PMunch http://ix.io/nKJ |
17:55:41 | * | jabb left #nim (#nim) |
17:55:52 | krux02 | does the same, but it's "nicer", at least to me |
17:55:54 | krux02 | :P |
17:57:25 | FromGitter | <zacharycarter> Dom96: did that gist compile for you? |
17:57:41 | FromGitter | <krux02> yes |
17:58:17 | FromGitter | <krux02> why? What is the problem? |
17:58:27 | PMunch | krux02, thanks. That does indeed look nicer :) |
17:58:37 | FromGitter | <zacharycarter> With my gist? |
17:59:04 | FromGitter | <krux02> what I posted compiles nicely |
17:59:09 | FromGitter | <krux02> I am on latest Nim version |
17:59:13 | FromGitter | <krux02> devel |
17:59:26 | krux02 | and the original, too |
17:59:46 | PMunch | Hmm |
17:59:53 | PMunch | test.nim(18, 7) template/generic instantiation from here |
17:59:54 | PMunch | lib/core/macros.nim(269, 22) Error: expression 'test' has no type (or is ambiguous) |
18:00:01 | PMunch | That's what I get when I try to run it |
18:00:35 | FromGitter | <zacharycarter> Krux02 im referring to - https://gist.github.com/zacharycarter/5a4df1496cd01727462d8211f8d83fba |
18:00:55 | dom96 | zacharycarter: afraid not |
18:01:07 | krux02 | PMunch: well test.nim only has 17 lines in the gist, so I can't tell you the result |
18:01:23 | FromGitter | <zacharycarter> Dom96: hmmm |
18:01:44 | PMunch | krux02, the one you gave me had 18 :) |
18:03:33 | * | handlex quit (Quit: handlex) |
18:04:06 | FromGitter | <zacharycarter> Guess ill wait to see what araq can offer since the union thing isnt fixing anything |
18:04:40 | dom96 | PMunch: your code works for me |
18:05:03 | PMunch | Windows, latest devel? |
18:05:42 | dom96 | OS X |
18:05:46 | dom96 | slightly dated devel |
18:05:53 | PMunch | Hmm, so it appears to work on OSX |
18:05:59 | PMunch | But not on Linux |
18:07:47 | FromGitter | <zacharycarter> @Araq if and when you have time can you take a look at having - https://gist.github.com/zacharycarter/5a4df1496cd01727462d8211f8d83fba and tell me why my C code is printing 0 and not 2? |
18:12:16 | * | yglukhov joined #nim |
18:12:56 | krux02 | PMunch I am on Linux |
18:13:15 | krux02 | zacherycarter: I am sorry on my computer the result is also 0 |
18:13:25 | krux02 | I did not know that this was unexpected result |
18:13:30 | PMunch | Well, now I feel like an idiot.. |
18:13:34 | krux02 | did not look too clearly on the code |
18:13:35 | PMunch | Figured it out |
18:13:43 | PMunch | My file is called test.nim |
18:13:54 | PMunch | So test is declared, as the name of the module -_- |
18:14:19 | FromGitter | <zacharycarter> Krux02: no prob |
18:15:53 | * | brson joined #nim |
18:16:33 | * | yglukhov quit (Ping timeout: 260 seconds) |
18:18:26 | FromGitter | <zacharycarter> I should have elaborated |
18:21:02 | * | handlex joined #nim |
18:21:43 | FromGitter | <zacharycarter> @krux02 does the problem make sense? |
18:22:02 | krux02 | yes, I also took a look at the generated source |
18:22:05 | krux02 | but no luck |
18:22:14 | krux02 | I would try to debug the generated sourcecode |
18:22:22 | krux02 | and see what is wrong there |
18:22:37 | krux02 | it not the best code to read, but it is possible |
18:22:43 | krux02 | when you navigate with search |
18:23:09 | krux02 | but at the moment I can't really take a deeper look |
18:23:20 | FromGitter | <zacharycarter> Alright i started doing that and then my eyes felt like they were being stabbed with a rusty spork |
18:23:51 | FromGitter | <zacharycarter> Ill give it another go |
18:24:12 | krux02 | well first start to save the generated sorucecode somewher else, where you can edit it, and don't be afraid, that it is overwritten |
18:24:38 | krux02 | compile without debug information from nim |
18:24:41 | FromGitter | <zacharycarter> Np i appreciate the confirmation of the issue |
18:24:47 | FromGitter | <zacharycarter> Okay |
18:24:49 | krux02 | but then add debug information on the c compilation |
18:24:53 | krux02 | and then start debugging |
18:25:05 | FromGitter | <zacharycarter> Gotcha thx |
18:25:23 | * | hjsagg joined #nim |
18:25:42 | krux02 | then you will either find out what you did wrong, or what the code generator did wrong |
18:25:53 | FromGitter | <zacharycarter> Right |
18:26:11 | krux02 | when it is the later one, that's a very good prototype for a bug report, because it actually can go into detail of the code generator what is generated wrongly |
18:26:39 | FromGitter | <zacharycarter> Keeping my fingers crossed its the latter and ill have my first nim bug |
18:26:57 | krux02 | there are a lot |
18:27:37 | FromGitter | <zacharycarter> Ill try to fix it if it ends up being a bug |
18:27:41 | * | djellemah quit (Ping timeout: 255 seconds) |
18:27:44 | * | djellemah_ joined #nim |
18:27:58 | FromGitter | <zacharycarter> Get my nim contrib toes wet |
18:28:42 | subsetpark | Can anybody tell what's happening here? https://www.irccloud.com/pastebin/R9hi1rqq/ |
18:29:38 | dom96 | subsetpark: is this inside `nim secret`? |
18:30:15 | * | handlex quit (Quit: handlex) |
18:31:00 | PMunch | http://ix.io/nKO |
18:31:02 | PMunch | Hmm |
18:31:08 | subsetpark | dom96: it is |
18:31:19 | dom96 | subsetpark: I wouldn't trust it |
18:31:29 | subsetpark | However, I get that same error message whenever I try to compile some code that's also calling random on a typed range |
18:31:33 | dom96 | PMunch: beautiful |
18:32:30 | PMunch | Haha, thanks :P |
18:32:35 | PMunch | But it doesn't work.. |
18:33:07 | * | Nobabs27 quit (Quit: Leaving) |
18:36:49 | PMunch | It seems like Nim struggles with either the genSym, or my crazy when's.. |
18:36:57 | dom96 | subsetpark: probably just doesn't support cshort |
18:37:01 | PMunch | dom96, is there another way of checking if an identifier is in a scope? |
18:37:05 | * | yglukhov joined #nim |
18:37:22 | dom96 | not that I know of |
18:37:27 | dom96 | what's the problem with 'when'? |
18:37:56 | PMunch | I dunno, it was when I introduced the when-adding macro that thing went south |
18:40:42 | subsetpark | dom96: ah, that hadn't occured to me |
18:41:32 | subsetpark | but i'm able to assign foo.cshort..bar.cshort to something |
18:42:43 | krux02 | PMunch, why do you so much want this when not declared? |
18:43:08 | PMunch | Ugh, long story |
18:43:27 | krux02 | why don't you let the dsl allow let/var statements? |
18:43:41 | PMunch | Because I don't like the way it looks |
18:43:46 | PMunch | And I thought this would be easier.. |
18:44:20 | krux02 | well, I personally hate when a programming language has no clear distinction detween declaration, and just an assignment |
18:44:59 | krux02 | I can never be sure that my local assignment is not changing a global variable/global state |
18:45:02 | subsetpark | dom96: Check out that example; it fails on the call to `random`, not on assinging to CountRange https://www.irccloud.com/pastebin/7xbhVafj/ |
18:46:00 | krux02 | and it breaks consistency with the rest of the nim language, where assignemens also never introduce new variables |
18:46:31 | PMunch | Yeah, I know |
18:46:39 | PMunch | I'm not 100% locked into the idea |
18:46:42 | PMunch | But I want to try it |
18:46:55 | * | yglukhov quit (Remote host closed the connection) |
18:47:30 | * | yglukhov joined #nim |
18:47:31 | krux02 | well as a proof of concept, and to test your skills, if you can bend Nim to do that, it's quite nice if it works, When you actually want to do it, I just discourage you to do it at all. |
18:48:58 | subsetpark | `random` takes a slice[T] so I didn't imagine it would have a problem with cshorts |
18:50:20 | dom96 | subsetpark: take a look at the code in random.nim |
18:50:39 | dom96 | It seems like the problem is that there is no `+`(x: int, y: int16): int |
18:51:25 | subsetpark | ahh.... gross :( |
18:51:27 | dom96 | or actually |
18:51:31 | dom96 | `random(x.b - x.a) + x.a` returns an `int` |
18:51:38 | * | zachcarter joined #nim |
18:51:40 | dom96 | But T is int16 |
18:52:01 | * | yglukhov quit (Ping timeout: 260 seconds) |
18:52:02 | dom96 | This error could be far clearer |
18:52:47 | dom96 | Could you report it on GitHub? |
18:52:55 | subsetpark | sure |
18:52:56 | dom96 | I will label it as "error messages" |
18:54:20 | dom96 | Although I think this is two bugs |
18:55:10 | subsetpark | https://github.com/nim-lang/Nim/issues/5430 |
18:59:59 | * | brson quit (Quit: leaving) |
19:01:02 | * | zachcarter quit (Quit: zachcarter) |
19:02:56 | dom96 | Commented |
19:04:41 | * | yglukhov joined #nim |
19:04:53 | subsetpark | thanks ! |
19:07:44 | * | rektide joined #nim |
19:08:28 | * | yglukhov quit (Remote host closed the connection) |
19:09:02 | * | yglukhov joined #nim |
19:12:43 | * | rektide left #nim (#nim) |
19:13:43 | * | yglukhov quit (Ping timeout: 240 seconds) |
19:14:57 | * | Nobabs27 joined #nim |
19:15:48 | subsetpark | Um, in response Araq called me incompetent... |
19:15:55 | subsetpark | That's a really shitty way to build a community, dudes |
19:16:01 | Araq | hey sorry |
19:16:09 | Araq | I didn't call you incompetent |
19:16:41 | Araq | but ok, I edited my remark |
19:17:49 | Araq | and I was referring to dom's reading competence because he should know better by now. |
19:18:48 | Araq | and this "error message did personally confuse me so it's a compiler problem" is annoying me |
19:20:48 | Nobabs27 | ok |
19:22:04 | federico3 | should I use renderTree or astToStr to convert a chunk of code to text? |
19:22:36 | dom96 | Araq: Please think about this carefully. Not everyone that writes Nim has as much experience with it as I do. |
19:22:49 | dom96 | Perhaps you're right and I should "have known better" |
19:23:07 | dom96 | But these messages are just as much for me as they are for others. |
19:24:38 | * | nsf joined #nim |
19:24:40 | Araq | federico3: these are very different, astToStr doesn't work for PNode |
19:24:57 | Araq | and renderTree only works on PNodes, I think |
19:25:09 | Araq | (or does macros.nim offer that one too?) |
19:26:02 | Araq | dom96: I bet it even refers to the column of the '=' in the statement |
19:26:17 | dom96 | Araq: No, in fact it refers to the `+` |
19:26:20 | dom96 | Which is what confused me. |
19:27:53 | FromGitter | <Varriount> subsetpark: What are you working on? |
19:28:01 | Araq | ouch, you're right |
19:31:43 | * | Matthias247 joined #nim |
19:34:05 | Araq | dom96: I'm sorry. |
19:34:50 | dom96 | No worries. It's all good. |
19:35:22 | federico3 | thanks Araq |
19:35:28 | dom96 | Btw, if you'd like I can create a special repo for these "error messages" issues. |
19:35:31 | * | libman joined #nim |
19:37:26 | subsetpark | Varriount: Doing some tabu search optimizers |
19:37:29 | subsetpark | Why do you ask? |
19:38:03 | Araq | krux02: is https://github.com/nim-lang/Nim/issues/5428 a regression? |
19:40:41 | krux02 | if you mean that I have code that once worked, and then doesn't, then no. |
19:40:50 | krux02 | it is new code |
19:40:57 | krux02 | it is also wrong code |
19:41:27 | krux02 | there are multiple parts that are just wrong, but error message is a bug of it's own |
19:41:52 | * | yglukhov joined #nim |
19:47:28 | * | hjsagg quit (Ping timeout: 240 seconds) |
19:49:47 | * | hjsagg joined #nim |
19:50:36 | FromGitter | <Varriount> subsetpark: I'm curious. :D |
19:51:06 | FromGitter | <Varriount> I like to see what fascinating things other people are working on. |
19:54:00 | subsetpark | Hopefully I'll be able to open source it soon... It's part of reimplementing a lot of our inner loops at my work |
19:55:01 | * | hjsagg quit (Ping timeout: 260 seconds) |
19:59:12 | * | Arrrr quit (Quit: Leaving.) |
20:13:31 | * | Jesin quit (Quit: Leaving) |
20:13:52 | * | brson joined #nim |
20:15:28 | * | Jesin joined #nim |
20:19:50 | * | Jesin quit (Client Quit) |
20:21:20 | libman | Remember to upvote https://www.reddit.com/r/programming/comments/5vzua1/bristech_video_nim_programming_language_stands/ for much win. ;) |
20:23:56 | * | Jesin joined #nim |
20:25:15 | * | ThisAsYou left #nim (#nim) |
20:38:27 | * | vlad1777d joined #nim |
20:49:54 | * | shodan45 quit (Quit: No Ping reply in 180 seconds.) |
20:54:16 | * | shodan45 joined #nim |
20:55:07 | * | nsf quit (Quit: WeeChat 1.7) |
21:01:58 | * | gokr quit (Ping timeout: 240 seconds) |
21:02:11 | * | rokups quit (Quit: Connection closed for inactivity) |
21:02:21 | * | themagician_g joined #nim |
21:04:06 | * | themagician quit (Ping timeout: 260 seconds) |
21:07:38 | * | gokr joined #nim |
21:08:30 | * | zachcarter joined #nim |
21:14:41 | * | cjbest joined #nim |
21:19:14 | * | gokr quit (Ping timeout: 240 seconds) |
21:23:13 | zachcarter | okay so I think I found a compiler generation error |
21:23:35 | zachcarter | I’m trying to confirm but I’m C retarded - can anyone help me understand how to produce an executable with clang? |
21:23:43 | zachcarter | I understand how to produce an object file but I don’t know how to link it |
21:24:23 | demi- | `clang -x c -arch x86_64 -lbar -Isome/dir/ foo.c -o foo` |
21:24:38 | cjbest | I can't help, but I would like to propose the new term C-tarded |
21:25:06 | zachcarter | thank you |
21:25:33 | demi- | iirc also -L for specifying library search paths |
21:25:37 | cjbest | This is coming from somebody who is also a Nimbecile |
21:25:43 | demi- | you may also want -g for debugging |
21:26:00 | zachcarter | gotcha |
21:29:44 | zachcarter | cjbest I like them both |
21:30:52 | cjbest | I'm trying to use the contributed kissfft binding which I've installed via nimble. Trivial "import kissfft/kissfft" fails, saying "fatal error: 'kiss_fft.h' file not found". As far as I can tell, this file is in the package, but does not get copied into the nimcache directory. Can anybody point me in a direction to help diagnose? |
21:31:36 | cjbest | zachcarter hah thanks |
21:32:15 | demi- | cjbest: you may need to install the library separately and reference the header path that it is installed to |
21:32:33 | * | brson quit (Ping timeout: 260 seconds) |
21:33:39 | cjbest | demi- as in don't try to use the nimble-installed version, but put it somewhere in my build path? |
21:34:24 | demi- | cjbest: it depends on how that dependency is configured, a bunch of wrappers don't include the C library, as they would have to update the wrapper version with the library |
21:34:49 | dom96 | it seems that the repo contains the .c and .h files |
21:35:02 | demi- | ah, i see |
21:35:15 | subsetpark | If I call a proc with a bunch of callbacks, can that fail typechecking depending on whether the procs I pass in are defined as closures, or in local scope - assuming I haven't made any mention of call style where I've defined the original proc? |
21:35:37 | subsetpark | rather, "or in global scope" |
21:35:53 | Araq | yes, of course |
21:36:04 | Araq | the calling conventions need to match |
21:36:05 | dom96 | cjbest: might need to edit the wrapper, instead of {.header: "kiss_fft.h".} put {.header: "kissfft/kiss_fft.h".} |
21:36:18 | cjbest | dom96 thanks, will try that |
21:37:11 | dom96 | or maybe you need to tell Nim to pass a flag to the C compiler to look for header files in `nimble path kissfft`/kissfft |
21:37:29 | subsetpark | Araq: right, but I mean if I didn't specify any calling conventions in the proc that accepts the callback. Like, if I have proc foo() that accepts some proc(x: int), and I call foo with something that I've defined as a closure, does that count as the calling conventions "not matching"? |
21:37:34 | dom96 | (Perhaps the Nim compiler should do that automatically) |
21:39:20 | Araq | proc types default to .closure and outer procs use .nimcall |
21:39:38 | zachcarter | dom9 / Araq: could you confirm if this is a generator bug or not for me please |
21:39:39 | Araq | there is an implicit conversion from .nimcall to .closure |
21:39:45 | zachcarter | https://gist.github.com/zacharycarter/5b634c8cf5ae436efaa682523a1236c1 |
21:39:50 | zachcarter | I will link to line numbers in 2 seconds |
21:40:20 | zachcarter | test1.nim / test1.c and test1.generated.c are the problem files |
21:40:29 | zachcarter | this line is problematic - https://gist.github.com/zacharycarter/5b634c8cf5ae436efaa682523a1236c1#file-test-generated-c-L120 |
21:40:45 | zachcarter | if you compare it to test2.nim / test2.c / test2.generated.c |
21:40:46 | zachcarter | and this line |
21:40:58 | zachcarter | https://gist.github.com/zacharycarter/5b634c8cf5ae436efaa682523a1236c1#file-test2-generated-c-L104 |
21:41:43 | Araq | not a bug, annotate nuk_image with .byCopy |
21:41:57 | zachcarter | thank you Araq |
21:42:07 | * | hjsagg joined #nim |
21:43:06 | * | dom96 wasn't even aware of this |
21:43:14 | zachcarter | :D |
21:43:29 | * | Trustable joined #nim |
21:43:36 | zachcarter | I think that explains my whole zero / 2 problem dom96 |
21:43:49 | dom96 | zachcarter: If you have some time would you (or anyone else) be interested in writing a "Wrapping C guide"? |
21:43:51 | subsetpark | Araq: Ok, so my understanding of that is - assuming I haven't declared any calling conventions anywhere: If I define a proc that expects some proc argument, it will default that argument's CC to .closure; and since .nimcall procs are convertible to .closure procs, it effectively "shouldn't matter" under normal circumstances - since I'm not specifying any |
21:43:51 | subsetpark | calling conventions anywhere, all of my procs will end up as either .nimcall or .closure, and procs which TAKE procs as arguments will expect/accept .closure |
21:44:00 | zachcarter | dom96 I could do that |
21:44:18 | zachcarter | I was already thinking about getting a blog going and writing some posts about my experiences wrapping soloud and nuklear |
21:44:46 | zachcarter | I have some time off next week I’ll take a stab at it |
21:44:49 | dom96 | I'd love to have a tutorials section on our new website. |
21:46:10 | Araq | subsetpark: no, it matters soon enough, because implicit conversions are not applied in array constructors for instance |
21:47:12 | * | bjz joined #nim |
21:47:28 | zachcarter | would be very nice dom96 |
21:47:41 | Araq | dom96: it only comes up in poorly written C code ;-) that said, I intend to change this after 0.16.2 because more and more people stumble upon this |
21:47:57 | Araq | especially when they don't even use a C middle layer |
21:48:02 | subsetpark | hm. I don't *think* that's my problem but it's hard to tell, because the type error message has concrete types on the left side but generic types on the right side. Is there any compile-time ability to, for instance, type check individual arguments with their expected type? |
21:48:37 | Araq | subsetpark: just give me a code snippet instead please |
21:49:08 | cjbest | dom96 got it compiling with --cincludes:`nimble path kissfft` |
21:50:07 | subsetpark | I imagine you'll find it a lot to take in... https://ghostbin.com/paste/gh4yo |
21:50:42 | dom96 | cjbest: Good. It would be nice if Nim could automatically add that. |
21:50:45 | subsetpark | https://ghostbin.com/paste/zc5pa |
21:50:46 | dom96 | Araq: Thoughts? ^ |
21:51:19 | subsetpark | The invocation happens on zc5pa:177, the original proc is defined on gh4yo:50 |
22:00:03 | Araq | MarkTabu*[T, T2] = proc(tabus: TabuQueue[T2], scoreState: ScoreState[T], diffWith: T) |
22:00:47 | Araq | proc markTabu(tabuQueue: TabuStateQueue, stateScore: WorkerScoreState, diffWith: WorkerDataState) |
22:01:08 | Araq | WorkerDataState = seq[WorkerState] |
22:02:23 | subsetpark | yeah? That seems right |
22:02:54 | subsetpark | T = WorkerDataState, WorkerScoreState = ScoreState[WorkerDataState] = ScoreState[T] |
22:03:59 | Araq | yeah, I dunno then |
22:04:51 | subsetpark | Can you think of a way to get the typechecker to report which individual argument is failing typechecking? |
22:06:19 | Araq | yeah sure, and so can you |
22:06:48 | Araq | proc optimizeProto*[StateT, TabuElementT]( |
22:06:48 | Araq | initialState: StateT, |
22:06:48 | Araq | getNeighborhood: GetNeighborhood[StateT]) = discard |
22:07:00 | Araq | add more and more parameters and see when it fails |
22:07:09 | subsetpark | sure... I guess I was wondering if there was a more verbose form of typechecking |
22:07:11 | subsetpark | but i'll do that |
22:07:28 | Araq | this things smells like "template" to me though |
22:07:53 | subsetpark | can you elaborate? I'd love to streamline it |
22:08:36 | Araq | template optimize(markTabu, markGoodMove, restart: untyped; ...) = ... |
22:09:11 | subsetpark | right, so basically skip the typechecking until we actually try to invoke the callbacks? |
22:10:21 | Araq | yup |
22:10:41 | dom96 | cjbest: can you create an issue for this? |
22:10:45 | Araq | it's just an optimization algorithm, hardly 100 lines |
22:11:21 | subsetpark | Sorry, I don't understand the implication |
22:11:31 | Araq | the type signature reads like a programming exercise and you want to have all these callbacks inlined anyway |
22:11:36 | cjbest | dom96: sure, in nim-lang/Nim/issues? |
22:11:59 | dom96 | cjbest: yeah, thanks :) |
22:12:31 | cjbest | Will do. Wasn't sure if this was a "the library should just update to fix" or a nim thing. It used to compile like a year ago |
22:16:54 | subsetpark | Well, it's definitely not an exercise... |
22:18:12 | Araq | subsetpark: one issue that I can see is that objective is overloaded |
22:18:31 | * | dddddd joined #nim |
22:18:36 | Araq | and the compiler might have problems in determining what you meant in this context |
22:18:50 | subsetpark | yeah, I can definitely get rid of that overloading |
22:19:20 | Araq | subsetpark: I mean the type signature is overwhelming me |
22:20:48 | subsetpark | yeah, you're not the only one. I would love to find a less hairy way to put this together. The Python code its a translation of is highly OO - tons of inheritance - and my first unsuccessful pass was using `object of` and `method`. Declaring callbacks within a closure seems better than that, but I agree that the type signature of optimize is really painful |
22:21:43 | * | FromGitter quit (Ping timeout: 240 seconds) |
22:22:31 | * | FromGitter joined #nim |
22:25:23 | subsetpark | Part of what optimize is doing is the generic side. How would I do that in a template, just pass in the types to instantiate as arguments to the template? |
22:31:17 | Araq | I don't really understand your problem enough to answer this question |
22:31:52 | Araq | I'm not sure my template idea would work out either, once one did read https://en.wikipedia.org/wiki/Tabu_search maybe your design is just right |
22:32:38 | subsetpark | Ok... For now I'll just debug the types |
22:33:19 | Araq | I note though that the wiki pseudocode is 20 lines and you have 100 ;-) |
22:34:07 | subsetpark | Yes, if you can imagine it, my version is more powerful than the pseudocode on wikipedia |
22:35:38 | zachcarter | fixed some issues in my bgfx nuklear backend and a major issue in nuklear-nim thanks for the help today guys |
22:39:26 | subsetpark | It's boiled down to this : https://www.irccloud.com/pastebin/Uf746y6h/ |
22:40:20 | * | Vladar quit (Quit: Leaving) |
22:41:18 | subsetpark | ugh... found it |
22:42:28 | Araq | even at the risk of sounding offensive yet again |
22:43:06 | subsetpark | uh huh... |
22:43:14 | Araq | I usually start with a concrete not generic implementation with concrete types everywhere and once that works, I generalize it |
22:43:59 | subsetpark | Oh, don't get me wrong - I have done that already. This is the second module that uses this as a framework |
22:44:20 | Araq | well I'm also lazy, so I do generalize after I actually need it to work with different types :-) |
22:44:37 | subsetpark | I'm pretty phobic of any kind of magic - as you can see, I still don't even really understand templates |
22:46:12 | Araq | do you know C's #define? templates are very comparable except that they are safer |
22:46:33 | subsetpark | No, the only templating I know is erlang's define() |
22:47:13 | subsetpark | I understand them in principle, it's using them for things that require, eg, generic programming or passing in code blocks where I hit the edge of my understanding |
22:48:16 | * | rauss quit (Quit: WeeChat 1.7) |
22:48:24 | Araq | alright |
22:48:37 | Araq | well what was the issue? |
22:48:38 | * | butchster joined #nim |
22:49:46 | subsetpark | Just one type of many. objective's second argument was an Option[WorkerDataState] when it should have been an Option[WorkerScoreState] |
22:49:51 | subsetpark | Now i'm dealing with an illegal capture |
22:51:36 | Araq | you also use [] pointer derefs where not valid, afaict |
22:51:57 | subsetpark | Where's that? |
22:53:03 | Araq | sorry, just closed the tabs and ghost doesn't show me again |
22:53:09 | Araq | in your queue handling |
22:53:26 | Araq | you have initQueue thats a value type, not a ref |
22:56:01 | subsetpark | oh, I define a proc `initQueue` - I probably am just reimplementing the built-in init for ref Deques |
22:56:20 | subsetpark | proc initQueue[T](): TabuQueue[T] = |
22:56:20 | subsetpark | new(result) |
22:56:20 | subsetpark | result[] = initDeque[Tabu[T]]() |
22:57:18 | subsetpark | I'll rename to initTabuQueue |
23:01:23 | Araq | the convention says it needs to be named newDeque or newTabeQueue |
23:01:39 | Araq | 'new' prefix, not 'init' prefix |
23:03:16 | subsetpark | Works for me. Good to know |
23:03:44 | subsetpark | Is the procedure body correct according to convention? |
23:07:17 | * | yglukhov_ joined #nim |
23:07:17 | * | yglukhov quit (Read error: Connection reset by peer) |
23:07:27 | Araq | yeah I guess |
23:12:07 | subsetpark | ha, that's that raving endorsement i was looking for |
23:13:14 | * | yglukhov_ quit (Ping timeout: 268 seconds) |
23:18:52 | * | Matthias247 quit (Read error: Connection reset by peer) |
23:20:39 | * | yglukhov joined #nim |
23:21:09 | * | sdw quit (Read error: Connection reset by peer) |
23:21:37 | * | Trustable quit (Remote host closed the connection) |
23:21:40 | * | sdw joined #nim |
23:21:40 | * | sdw quit (Changing host) |
23:21:40 | * | sdw joined #nim |
23:21:53 | FromGitter | <Varriount> subsetpark: :D |
23:23:12 | * | bjz quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…) |
23:23:24 | * | hjsagg quit (Remote host closed the connection) |
23:25:08 | * | rosshadden quit (Ping timeout: 255 seconds) |
23:26:04 | * | rosshadden joined #nim |
23:56:43 | * | Sentreen quit (Ping timeout: 240 seconds) |