00:00:57 | * | LeoNerd24 quit (Killed (Sigyn (Spam is off topic on freenode.))) |
00:36:04 | * | vlad1777d quit (Ping timeout: 240 seconds) |
00:38:40 | * | dddddd quit (Remote host closed the connection) |
00:39:50 | * | Robe2 joined #nim |
00:46:16 | * | Robe2 quit (Remote host closed the connection) |
00:51:57 | FromGitter | <adam-r-kowalski> What are you’re thoughts on having some sort of numeric tower defined in terms of concepts like Haskell does? Something like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb01e2d2e0e027fb9947cce] |
00:52:37 | FromGitter | <adam-r-kowalski> That way we don’t have to limit ourselves to int64/int32/etc but people can make their own int types and have them work as fully first class numeric types |
00:57:06 | * | skellock quit (Quit: WeeChat 1.9.1) |
01:00:04 | * | elrood quit (Quit: Leaving) |
01:03:59 | * | Guest1907827 joined #nim |
01:06:59 | * | Guest1907827 quit (Remote host closed the connection) |
01:09:14 | * | _0ffh joined #nim |
01:14:32 | * | velix8 joined #nim |
01:16:47 | * | mpk3 joined #nim |
01:17:20 | * | _0ffh quit (Quit: leaving) |
01:20:03 | * | mpk3 quit (Remote host closed the connection) |
01:25:03 | * | velix8 quit (Ping timeout: 245 seconds) |
01:42:35 | * | EvilBill21 joined #nim |
01:43:48 | * | a_chou joined #nim |
01:45:28 | * | EvilBill21 quit (Remote host closed the connection) |
01:49:12 | * | a_chou quit (Remote host closed the connection) |
01:49:29 | * | a_chou joined #nim |
01:51:19 | FromGitter | <gogolxdong> what does bind do ? |
01:55:31 | FromGitter | <dm1try> @kayabaNerve ⏎ ⏎ > The 1st async function used to resume after the sync function called the 2nd async function and returned. ⏎ ⏎ AFAIK, it will only return if the second async function yields control somehow(ex. `await sleep_async(1)`) [https://gitter.im/nim-lang/Nim?at=5bb02d135af485306839be2b] |
01:58:31 | FromGitter | <dm1try> at least in the current implementation(though not sure about old versions of `asyncdispatch`) |
02:19:10 | * | a_chou quit (Quit: a_chou) |
02:33:15 | * | raehik joined #nim |
02:39:53 | * | raehik quit (Remote host closed the connection) |
02:40:48 | * | seppia joined #nim |
02:42:34 | * | seppia quit (Remote host closed the connection) |
02:54:42 | FromGitter | <kayabaNerve> @dm1try It works on Linux. |
03:00:34 | FromGitter | <kayabaNerve> Some async thing was changed that only changes effects on Windows and I'm trying to minimize it. |
03:01:15 | FromGitter | <kayabaNerve> My codes in multiple files so it's tricky too |
03:13:23 | * | smt quit (Read error: Connection reset by peer) |
03:22:06 | FromGitter | <kdheepak> Hi all. I'm still struggling with the ref and non ref objects in Nim. |
03:22:15 | FromGitter | <kdheepak> I wanted to ask a few questions. |
03:23:00 | FromGitter | <kdheepak> Perhaps this is just my lack of understanding, but I'm struggling to understand this from the documentation and from the resources that various people have linked here in this chat room. |
03:23:35 | FromGitter | <kdheepak> I have this very simple code base as an example to discuss. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb041b619b139275a20f07c] |
03:25:53 | FromGitter | <kdheepak> Here is my understanding so far: ⏎ ⏎ in C, after a struct is defined, it can be created using either on the stack allocation or on the heap. i.e. if it is created on the stack, it is local to the current scope and that memory should not be accessed when the scope has been terminated. |
03:26:51 | FromGitter | <kdheepak> The struct that is created on the stack can however be "returned" from a function, in which case it results in copy semantics. This can be an expensive operation for large data structures. |
03:28:20 | FromGitter | <kdheepak> In C, when a function is called, a struct that was created on the stack can be passed into the function by value or by reference (i.e. pointer). |
03:29:22 | FromGitter | <kdheepak> If the struct is passed into the function by value, it is copied into the function scope, and thus any change does not affect the struct that was allocated on the stack in the main scope. |
03:29:43 | FromGitter | <kdheepak> If the struct was passed into the function by reference / pointer, then it can be modifed. |
03:30:05 | FromGitter | <kdheepak> Hopefully all that is correct. All the above was for how things work in C. |
03:30:56 | FromGitter | <kdheepak> In Nim however, there seems to be two ways of defining a struct, two ways of creating a struct and two ways of passing a struct into a function. And this is where my confusion arises. |
03:31:52 | FromGitter | <kdheepak> ``` PersonObj = object of RootObj ⏎ name: string``` ⏎ ⏎ This is the standard syntax for defining a object in Nim, which translates to a C struct. [https://gitter.im/nim-lang/Nim?at=5bb043a7a9be136b94d1d722] |
03:32:45 | FromGitter | <kdheepak> And this code works fine, ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb043ddae7be94016dafe36] |
03:33:06 | FromGitter | <kdheepak> Based on my understanding, this creates a PersonObj struct on the stack. |
03:34:36 | FromGitter | <kdheepak> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb0444cef4afc4f28f6edd1] |
03:34:51 | FromGitter | <kdheepak> This results in a compile error. |
03:35:27 | FromGitter | <kdheepak> And this works. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb0447f19b139275a20fd9b] |
03:35:56 | FromGitter | <kdheepak> This is when PersonObj is allocated on the stack, so things make sense. |
03:41:59 | FromGitter | <kdheepak> Now when I create a type called PersonRef i.e. ref PersonObj ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Can I get a reference to PersonObj by casting the PersonObj var p to the corresponding type? [https://gitter.im/nim-lang/Nim?at=5bb046076e5a401c2df315be] |
03:42:04 | FromGitter | <kdheepak> Does this make sense to do? |
03:48:48 | * | chemist69 quit (Ping timeout: 252 seconds) |
03:50:34 | * | chemist69 joined #nim |
03:54:01 | FromGitter | <kdheepak> I think my main source of confusion stems from the fact that the following works, and I have no clue why: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb048d95af48530683a43b7] |
03:54:31 | FromGitter | <kdheepak> Does nim not care about the number of `ref` keywords in front of PersonObj? |
03:58:16 | FromGitter | <kdheepak> I just generated the c code to compare the two cases, it seems to be largely identical. There's differences in the random variable names. |
04:04:29 | FromGitter | <kayabaNerve> You can have a pointer to a pointer. You can have a ref of a ref. |
04:04:50 | FromGitter | <kdheepak> How to make a type that's a ref of a ref? |
04:08:16 | FromGitter | <kdheepak> I get this error often and I have no idea what this means: `test.nim(12, 18) Error: object constructor needs an object type` |
04:08:46 | FromGitter | <kdheepak> I'm trying to get a ref of ref example working: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb04c4ebbdc0b2505c23ec1] |
04:08:56 | FromGitter | <kdheepak> This does not compile. |
04:16:19 | FromGitter | <kdheepak> Is there an easy way to ensure that all the seq values of a type object are initialized to empty seq? |
04:16:24 | FromGitter | <kdheepak> Or do I have to do it manually? |
04:37:03 | FromDiscord_ | <demotomohiro> I think seq is always initialized to empty unless you specify initial value even if it is one of object 's field |
04:37:51 | FromDiscord_ | <demotomohiro> https://wandbox.org/permlink/hMfct7t86kIYzOne |
04:37:59 | FromGitter | <kayabaNerve> Now that it's not nil |
04:44:21 | FromGitter | <kayabaNerve> @kdheepak ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb054a5271506518d94505f] |
04:44:52 | FromGitter | <kayabaNerve> Wait |
04:44:53 | FromGitter | <kayabaNerve> Typo |
04:45:17 | FromGitter | <kayabaNerve> Fixed |
04:46:42 | FromGitter | <kdheepak> Thank you! |
04:46:55 | FromGitter | <kdheepak> It looks like this also works: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb0553fc08b8b3067ad2d63] |
04:47:25 | FromGitter | <kdheepak> Since `p[] = new PersonRef` creates an instance of PersonObj that is allocated on the heap. |
04:48:25 | FromGitter | <kdheepak> Thanks @demotomohiro |
04:49:04 | FromDiscord_ | <demotomohiro> kdheepak: you're wellcome |
04:49:40 | FromDiscord_ | <demotomohiro> In my understanding, in C, struct can be created on static, stack or heap |
04:50:11 | FromDiscord_ | <demotomohiro> you can use struct to declare global variable in C |
05:02:10 | * | miran joined #nim |
06:05:27 | * | stefanos82 joined #nim |
06:22:44 | * | stefanos82 quit (Quit: Quitting for now...) |
06:52:24 | * | andrzej5 joined #nim |
06:54:10 | * | andrzej5 quit (Remote host closed the connection) |
06:59:36 | FromGitter | <kdheepak> My nim code is slower than my Python code that does almost the same thing, how do I go about debugging / optimizing my nim binary? |
07:00:25 | FromGitter | <kdheepak> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb074891e23486b9366b480] |
07:01:44 | FromGitter | <kdheepak> I'm actually genuinely surprised by this. My Python code was very hacky / just a prototype, and I was expecting my naive Nim implementation to be better than that. |
07:02:05 | FromGitter | <kdheepak> I think I just have a lot more to learn about Nim! |
07:07:58 | FromGitter | <ephja> @kdheepak try this https://nim-lang.org/docs/nimprof.html |
07:08:24 | Araq | just post your code on the forum, people will optimize it to death for you |
07:09:57 | FromGitter | <kdheepak> Thanks! I'll look at that! |
07:10:44 | FromGitter | <kdheepak> Haha @Araq that would be great! Unfortunately I have to go through the legal department at my organization before I can post it anywhere. |
07:11:06 | FromGitter | <ephja> has anyone ever stepped over code with a gdb and not have the instructions executed? I need to test it again because that's just weird. I think I was able to skip "assert(false)" and possibly other things |
07:11:45 | FromGitter | <ephja> stepping only, no jumps |
07:11:53 | Araq | kdheepak: what does the code do? json, parsing by line, ...? |
07:12:07 | Araq | did you compile with -d:release ? |
07:12:23 | Araq | did you put your code in a 'main' proc? (you should) |
07:12:33 | FromGitter | <kdheepak> Yes. Parses a domain specific file format to json and prints the json to the screen. |
07:12:55 | Araq | did you try the packedJson module? |
07:13:17 | FromGitter | <kdheepak> This is how I've running it. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb0778d5af48530683b35de] |
07:14:26 | FromGitter | <bung87> think you can post related parts code |
07:14:57 | Araq | for parsing the lines iterator and 'scanf' is better than e.g. the lines proc and those terrible 'split' variants |
07:15:15 | * | jeremym10 joined #nim |
07:15:30 | FromGitter | <kdheepak> I'm building it using `-d:release`. |
07:15:57 | FromGitter | <ephja> that checks if it's the main module, but you should put most code inside some function. name it whatever you want and then call it some time after |
07:16:27 | FromGitter | <kdheepak> Yup, all my code is in separate procs, that is called from main. |
07:17:26 | FromGitter | <kdheepak> No code is being executed in the "module namespace" (Python speak), if that's what I'm being asked. |
07:17:34 | Araq | ok, good |
07:17:50 | FromGitter | <kdheepak> except type definitions / a couple of const |
07:17:57 | Araq | yeah sure |
07:18:03 | * | jeremym10 quit (Remote host closed the connection) |
07:18:31 | FromGitter | <kdheepak> I can share the profile_results. |
07:20:40 | FromGitter | <kdheepak> Added a gist here (https://gist.github.com/kdheepak/fdfd779b19b2e33ab69f3e343cb4f028) |
07:21:40 | FromGitter | <kdheepak> One thing I noticed is that the profile_results is not deterministic, changes between runs. |
07:22:26 | FromGitter | <bung87> genericSeqAssign this is slow op. |
07:23:09 | FromGitter | <bung87> last time I hit performance issue , it take 50% of time. |
07:24:17 | FromGitter | <kdheepak> I changed one of my most used objects to `ref object`. New times: ⏎ ⏎ ``` 0.06s user 0.06s system 90% cpu 0.132 total``` [https://gitter.im/nim-lang/Nim?at=5bb07a20c7bf7c366292d88c] |
07:24:49 | FromGitter | <kdheepak> That's faster than Python: ⏎ ⏎ ```python test.py 0.08s user 0.04s system 50% cpu 0.253 total``` [https://gitter.im/nim-lang/Nim?at=5bb07a415331811c2e28def3] |
07:25:18 | FromGitter | <bung87> guess can be more faster |
07:27:04 | FromGitter | <kdheepak> I think so too. |
07:27:24 | FromGitter | <kdheepak> I'll be able to share this code in perhaps a couple of weeks. |
07:28:24 | FromGitter | <kdheepak> I'm also testing it on really small files at the moment. Should maybe see more difference on larger files? |
07:28:25 | FromGitter | <gogolxdong> How to build windows executable on Linux machine? |
07:28:37 | FromGitter | <bung87> you will need compare it with c or cpp program in the end. |
07:29:04 | FromGitter | <kdheepak> I will have to write c or cpp for that :P |
07:29:32 | Araq | in a couple of weeks Nim will optimize the heck out of it |
07:30:02 | FromGitter | <kdheepak> ( I've only mainly used Python, Java, MATLAB, Javascript. This is really my first foray into this low level of a language. ) |
07:30:26 | FromGitter | <kdheepak> @Araq because of new features heading Nim's way? |
07:30:48 | Araq | yeah |
07:31:06 | FromGitter | <kdheepak> Ooo. Interesting. Can I ask what features? |
07:32:04 | miran | "for parsing the lines iterator and 'scanf' is better than e.g. the lines proc and those terrible 'split' variants"; Araq: what do you mean by "those terrible 'split' variants"? splitLines and splitWhitespace? |
07:32:38 | FromGitter | <bung87> I ve implemented a lib that faster than a python lib that has python c api . |
07:33:30 | FromGitter | <bung87> reduce half time costs. |
07:33:36 | Araq | kdheepak: in a way these new features taught me how to optimize high-level Nim code |
07:33:43 | miran | so what would be the recommended (fastest) way to read a multiline file? |
07:34:08 | Araq | miran: write a lexer. use lexim, scanf, lexbase or something else |
07:34:28 | miran | ...or do it at compile time? ;) |
07:34:41 | Araq | parsing with 'split' is slow and only works for toys |
07:34:55 | FromGitter | <kdheepak> Sounds too good to be true! will be watching! |
07:34:57 | Araq | for instance, take this list of items |
07:35:07 | Araq | a b c "d e" |
07:35:09 | FromGitter | <kdheepak> My "Lexer" and "Scanner" may need optimizing too. |
07:35:33 | * | nsf joined #nim |
07:36:11 | Araq | it doesn't work with splitWhitespace(), whitespace here can also be within quotes |
07:38:31 | FromGitter | <timotheecour> > *<Araq>* in a couple of weeks Nim will optimize the heck out of it ⏎ ⏎ ya, also curious which features |
07:40:58 | miran | Araq: haven't you heard that Araq only wants bug-fixes, no new features!! :P :D |
07:43:18 | FromGitter | <bung87> guess it’s not new it’s always in araq’s mind. |
07:43:24 | FromGitter | <bung87> for optimizing |
07:44:07 | Araq | don't take me too seriously, I'm still proud of this result: https://github.com/nim-lang/Nim/blob/devel/tests/destructor/tprevent_assign.nim |
07:45:21 | Araq | the move optimizer is starting to work |
07:46:38 | Araq | but moves and code specialization for genericReset/genericAssignment will solve 80% of performance problems for naively written Nim code |
07:51:00 | FromGitter | <bung87> the x:int type too simple. |
07:52:42 | * | Vladar joined #nim |
07:58:22 | * | nsf quit (Quit: WeeChat 2.2) |
08:00:03 | FromGitter | <gogolxdong> Foo is object , in allowThis, there are two assignments , b and c are two copies of Foo , yes? |
08:01:38 | FromGitter | <gogolxdong> but if changes to ref object , got `Error: signature for '=destroy' must be procT: object (x: var T)` |
08:03:30 | * | gmpreussner quit (Ping timeout: 244 seconds) |
08:03:53 | * | gmpreussner joined #nim |
08:04:07 | FromGitter | <gogolxdong> ah, overloaded ``=`` , is this the syntax works for object only, how about ref object? I see a blueprint without ref in the future, yes? |
08:06:19 | * | andjjj230 joined #nim |
08:06:46 | * | oem_ joined #nim |
08:06:57 | FromGitter | <gogolxdong> for a big object , proc `=` would be tricky. |
08:10:49 | miran | speaking of reading input and scanf, how can i match something that is `$w-$w-$w`, and i want it to be just one match? |
08:11:18 | Araq | bung87: the 'x: int' type is irrelevant |
08:13:33 | * | andjjj230 quit (Remote host closed the connection) |
08:13:58 | miran | i've tried using `$*`, but it doesn't work as i hoped |
08:14:18 | Araq | miran: scanf supports custom matchers |
08:14:32 | FromGitter | <bung87> just for show prevent assign? or other type of object same thing? |
08:15:40 | FromGitter | <Bennyelg> Hey, How Can I print object memory address |
08:16:23 | miran | Araq: so if i want to match "fbqijys-whqii-huiuqhsx-660[qhiwf]", i cannot do: `line.scanf("$*$i[$w]", name, sector, chSum)`, and i need to write a proc to capture the part before first digit? |
08:16:46 | Vladar | Bennyelg: echo object.addr ? |
08:17:11 | Araq | bung87: read the example again. *when* does it prevent assignment. |
08:17:18 | FromGitter | <Bennyelg> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb0868eae7be94016dc4990] |
08:17:43 | FromGitter | <Bennyelg> need to cast ? |
08:18:04 | Araq | miran: '$*' would be eager and needs to be replaced with a custom matcher |
08:18:13 | FromGitter | <Bennyelg> this works echo (castint (p.addr)) |
08:18:21 | Vladar | Bennyelg: convert to string probably |
08:18:28 | Vladar | or that |
08:18:33 | FromGitter | <Bennyelg> thanks |
08:19:19 | miran | Araq: thanks. will do it. i thought i might simplify things with scanf, but i'm back to square one |
08:21:15 | Araq | https://nim-lang.org/docs/strscans.html#user-definable-matchers |
08:21:24 | Araq | should still simplify your code |
08:23:52 | miran | from the same page it seems that both $* and $+ should work ("Matches until the token following the $+ was found") for my `$*$i[$w]` example - they should match everything until a digit. but that's not the case |
08:24:13 | Araq | $i is not a token |
08:24:22 | Araq | it's a matcher |
08:24:25 | miran | oh |
08:25:12 | miran | yup, works when there is a token. sorry for bothering |
08:25:13 | FromGitter | <gogolxdong> =destroy makes sure `otherTree` and `b` goes out of scope be destroyed, only pass c to take2 proc ,right? |
08:25:17 | Araq | it could be supported but then it would fail for custom matchers |
08:31:15 | FromGitter | <gogolxdong> Foo() allocated on stack, ref object which is usually constructed by new(Foo) allocated on heap ,right? |
08:32:32 | FromGitter | <gogolxdong> all local copies of object will be destroyed as long as they goes out of scope, but ref object remains on heap which requires GC. |
08:35:09 | * | sagax quit (Ping timeout: 252 seconds) |
08:36:50 | FromGitter | <gogolxdong> Object type with destructor becomes superior to ref object in this way. |
08:37:42 | * | saho6 joined #nim |
08:39:06 | * | saho6 quit (Killed (Sigyn (Spam is off topic on freenode.))) |
08:43:37 | * | kalii joined #nim |
08:45:23 | FromGitter | <gogolxdong> We used split a lot , need to replace with scanf. TBH, the difference is unknown if not mentioned. |
08:46:05 | * | kalii quit (Remote host closed the connection) |
08:52:05 | FromGitter | <timotheecour> @araq any chance you could take a look at https://github.com/nim-lang/Nim/pull/9116 please ? I need it for other PR |
08:53:12 | miran | nitpicking, but i expected that cases 0 and 1 would not raise "not all cases are covered" for `case i mod 2` :'( |
08:55:40 | FromGitter | <codenoid> is nim has interactive console |
08:56:00 | Araq | miran: we did that, it sucked, here is what do use instead |
08:56:35 | Araq | template staticMod(x, n): untyped = range[0..n-1](x mod n) |
08:57:59 | miran | nice, thanks |
09:01:19 | FromGitter | <mratsim> @codenoid in 6 months: https://github.com/nim-lang/Nim/issues/8927 |
09:03:03 | FromGitter | <mratsim> @timotheecour Optimization in Nim is easy, just remove GenericResets ;) https://github.com/nim-lang/Nim/issues/8745 |
09:04:57 | * | moei1 joined #nim |
09:05:35 | * | moei1 quit (Remote host closed the connection) |
09:07:36 | Araq | timotheecour: Need to decide on a development model first. |
09:09:52 | * | jglick6 joined #nim |
09:10:58 | * | rogerh joined #nim |
09:11:04 | FromGitter | <timotheecour> by that u mean branch for bugfix only (19.X) vs branch for development (devel)? |
09:13:17 | * | jglick6 quit (Remote host closed the connection) |
09:13:56 | FromGitter | <gogolxdong> @shashlick , nimnuklear doesn't compile on windows10. |
09:14:48 | FromGitter | <timotheecour> my take on this: we should never stop development of new features on devel branch; we can create a new stable branch that will only accept cherry picks (or manually edited cherry picks) from devel branch corresponding to regressions, and maybe critical bug fixes. |
09:15:13 | * | rogerh quit (Remote host closed the connection) |
09:16:12 | * | xet7 quit (Quit: Leaving) |
09:16:42 | FromGitter | <timotheecour> dmd follows a similar development model: master vs stable branches; master development are never stopped |
09:21:56 | FromGitter | <gogolxdong> nuklear_sdl_gl3.nim(308, 21) Error: type mismatch: got <proc (usr: handle, text: cstring, len: cint){.cdecl, gcsafe, locks: 0.}> but expected 'plugin_copy = proc (a2: handle, a3: cstring, len: cint){.closure.}' |
09:22:39 | * | chemist69 quit (Ping timeout: 252 seconds) |
09:23:05 | * | chemist69 joined #nim |
09:31:07 | FromGitter | <kdheepak> I ran my nim parser on a larger file, and am getting much slower results than in Python. |
09:31:33 | FromGitter | <kdheepak> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb097f5271506518d95a337] |
09:32:13 | FromGitter | <kdheepak> I'll just have to share the code before I'm able to make progress on this I think. I've tried everything I can think of at the moment. |
09:33:14 | FromGitter | <Bennyelg> @kdheepak can you share your code on gist ? |
09:34:28 | FromGitter | <kdheepak> Oddly the profile results don't have as many calls ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb098a4c7bf7c3662937e9c] |
09:34:29 | FromGitter | <ephja> oh so there are float ranges now |
09:34:41 | FromGitter | <kdheepak> That's the entire profile_results.txt this time. |
09:36:07 | * | Tortice joined #nim |
09:36:20 | FromGitter | <kdheepak> @Bennyelg it's not a large code base but I don't think I can put it in a gist easily ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb09914ef4afc4f28f89994] |
09:36:44 | FromGitter | <Bennyelg> no need the files |
09:37:06 | FromGitter | <Bennyelg> just the gist with your code flow both in nim and python |
09:38:09 | * | miran quit (Ping timeout: 252 seconds) |
09:39:47 | * | oem_ quit (Ping timeout: 252 seconds) |
09:42:26 | FromGitter | <kdheepak> I'll be able to share the files in a couple of weeks I think. |
09:43:52 | * | nsf joined #nim |
09:51:25 | * | geocar joined #nim |
09:54:27 | * | jjido joined #nim |
09:58:17 | * | jrcloud joined #nim |
10:00:11 | FromGitter | <gogolxdong> what's the different between sdl2 only and sdl2+nuklear? |
10:02:07 | * | jrcloud quit (Remote host closed the connection) |
10:04:48 | FromDiscord_ | <Shield> pure sdl2 is just for 2d, sdl2+nuklear is using sdl2 to handle window events and sound while nuklear handles drawing things on screen, and it can do 3d, uses shaders... |
10:12:01 | FromGitter | <kdheepak> How to check if a reference pointer has been initialized or not? |
10:12:23 | * | dddddd joined #nim |
10:12:32 | FromGitter | <kdheepak> I'm getting a Illegal Storage Access error |
10:12:40 | * | lagrenouille0 joined #nim |
10:15:22 | * | tzui joined #nim |
10:15:33 | FromGitter | <kdheepak> I am using the `isNil` magic to avoid this. |
10:15:42 | FromGitter | <kdheepak> Please suggest if there's a better way. |
10:16:03 | FromGitter | <gogolxdong> clear. |
10:16:31 | * | lagrenouille0 quit (K-Lined) |
10:16:55 | * | jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
10:17:39 | * | tzui quit (Client Quit) |
10:19:18 | * | MiVo13 joined #nim |
10:22:37 | * | MiVo13 quit (Remote host closed the connection) |
10:24:30 | FromGitter | <gogolxdong> sdl2 text field events has issues , the same with a long time ago. |
10:25:31 | FromGitter | <gogolxdong> oh, it's nimx's text field |
10:26:31 | FromGitter | <gogolxdong> nimnuklear demo works well, but doesn't compile on windows. |
10:28:05 | * | tzui joined #nim |
10:35:26 | * | krux02 joined #nim |
10:37:00 | * | arecaceae quit (Remote host closed the connection) |
10:37:19 | * | arecaceae joined #nim |
10:45:50 | * | jjido joined #nim |
10:50:32 | FromGitter | <gogolxdong> http://ix.io/1nUu |
10:52:01 | FromGitter | <gogolxdong> the same problem with zachcater's nuklear-nim wrapping of nk_edit_string,but on windows. |
10:53:30 | FromGitter | <gogolxdong> want to build a graphical program for my wife :) |
10:54:22 | FromGitter | <kdheepak> Medium size files take a really long time to parse (30k lines). Like 60 seconds or more. Any suggestions on how to debug this? |
10:56:08 | FromDiscord_ | <Shield> kdheepak it's better to use options when your reference can be nil |
10:56:54 | FromDiscord_ | <Shield> are you parsing the file line by line? it's better to parse a chunk to a buffer then check for the lines in the buffer |
10:58:41 | FromGitter | <vivekimsit> @mratsim thanks |
11:05:37 | * | elrood joined #nim |
11:07:17 | * | workrat1 joined #nim |
11:08:21 | * | workrat1 quit (Remote host closed the connection) |
11:09:07 | * | PMunch joined #nim |
11:10:34 | * | doom25 joined #nim |
11:10:40 | FromGitter | <gogolxdong> Brilliant ! Got it work! |
11:15:36 | * | doom25 quit (Remote host closed the connection) |
11:15:55 | FromGitter | <gogolxdong> {.cdecl.} for closure as C interoperability on windows. |
11:20:19 | * | gb00s quit (Quit: The Lounge - https://thelounge.github.io) |
11:22:21 | * | efdee2 joined #nim |
11:23:29 | FromGitter | <krux02> @kdheepak what are you parsing? |
11:24:42 | FromGitter | <krux02> @kdheepak the main reason why parsing becomes is a parsing algorithm that creates a lot of intermediate objects allocated on the heap. |
11:26:55 | * | jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
11:28:08 | * | efdee2 quit (Ping timeout: 252 seconds) |
11:33:45 | FromGitter | <krux02> the main reason why a parsing algorithm becomes slow is ... |
11:33:56 | FromGitter | <krux02> someone ate a few words of my former message |
11:38:09 | FromGitter | <mratsim> yeah @kdheepak Seeing your first code examples I’m pretty sure you allocate too much |
11:38:56 | FromGitter | <mratsim> Python GC will reuse small buffers, but Nim just returns them to the OS, it’s up to you to reuse heap objects |
11:45:41 | * | xet7 joined #nim |
11:48:56 | Tortice | with httpclient, can I upload multiple files to the same key? |
11:51:01 | FromGitter | <bung87> the question is in HTTP can you upload multiple files to the same key? |
11:53:38 | Tortice | in python I do this by https://stackoverflow.com/a/20769921 |
11:54:53 | FromGitter | <bung87> yeah you can upload multiple files one request. |
11:55:33 | * | avieks joined #nim |
11:57:37 | FromGitter | <bung87> https://github.com/nim-lang/Nim/blob/master/lib/pure/httpclient.nim#L211 |
11:58:26 | FromGitter | <bung87> https://github.com/nim-lang/Nim/blob/master/lib/pure/httpclient.nim#L423 |
12:01:32 | * | avieks quit (Remote host closed the connection) |
12:11:26 | * | boser7 joined #nim |
12:12:03 | * | boser7 quit (Remote host closed the connection) |
12:14:52 | * | nsf quit (Quit: WeeChat 2.2) |
12:15:58 | * | xet7 quit (Remote host closed the connection) |
12:23:03 | * | SenasOzys quit (Ping timeout: 252 seconds) |
12:28:20 | * | stefanos82 joined #nim |
12:30:31 | * | PMunch quit (Remote host closed the connection) |
12:36:25 | * | sku1d8 joined #nim |
12:37:19 | * | sku1d8 quit (Killed (Sigyn (Spam is off topic on freenode.))) |
12:39:32 | * | elrood quit (Quit: Leaving) |
12:40:50 | * | Vladar quit (Remote host closed the connection) |
12:41:12 | * | Vladar joined #nim |
12:42:04 | * | SenasOzys joined #nim |
12:52:02 | Tortice | with ui, how do I use a threadpool to update the ui after a certain number of seconds? I get Error: 'spawn' takes a GC safe call expression trying to use it with sleep |
12:55:23 | * | noudle22 joined #nim |
12:56:33 | FromGitter | <bung87> `spawn yourProc()` |
12:57:24 | Tortice | I have spawn update(count, total, status) |
12:57:55 | * | noudle22 quit (Remote host closed the connection) |
12:58:11 | Tortice | and update is http://ix.io/1nVv |
12:58:35 | Tortice | actually, that's missing $1 and $2 |
12:59:49 | Tortice | this is update(): http://ix.io/1nVz |
13:01:06 | * | vlad1777d joined #nim |
13:02:31 | FromGitter | <bung87> not sure you can pass `data ` to the proc |
13:03:44 | Tortice | is it not valid? https://nim-lang.org/docs/manual.html#parallel-amp-spawn-spawn-statement |
13:05:08 | Tortice | data is just httpclient.newMultiPartData() |
13:05:13 | Tortice | with some fields |
13:06:19 | FromGitter | <bung87> “We call a proc p GC safe when it doesn't access any global variable that contains GC'ed memory (string, seq, ref or a closure) either directly or indirectly through a call to a GC unsafe proc." |
13:06:41 | FromGitter | <bung87> “f must be gcsafe." |
13:06:56 | Tortice | oh, you're right - data is global |
13:10:14 | * | ToddShepard7 joined #nim |
13:10:31 | * | RoboMWM22 joined #nim |
13:12:51 | * | gangstacat joined #nim |
13:14:17 | Tortice | so here's a simple one, how to fix the type mismatch? https://ptpb.pw/LJ-c |
13:14:46 | * | RoboMWM22 quit (Remote host closed the connection) |
13:19:07 | FromGitter | <bung87> you messed up with these two index assign ? https://github.com/nim-lang/Nim/blob/master/lib/pure/httpclient.nim#L441 |
13:19:44 | FromGitter | <mratsim> @Tortice, threadpool are not the proper tool for a longlived UI thread |
13:19:55 | * | ToddShepard7 quit (Remote host closed the connection) |
13:20:01 | FromGitter | <mratsim> either use async or use createThread for a long-lived thread |
13:20:57 | * | w0rp22 joined #nim |
13:22:13 | Tortice | If I messed up the index assignment, then what am I assigning? It should be data["message"], am I assigning something else? |
13:24:54 | * | xet7 joined #nim |
13:27:29 | * | w0rp22 quit (Remote host closed the connection) |
13:27:48 | * | blingrang joined #nim |
13:28:32 | * | blingrang quit (Remote host closed the connection) |
13:28:51 | FromGitter | <bung87> hmm seems matched, dont know why you got this |
13:32:27 | * | nsf joined #nim |
13:44:04 | * | smt joined #nim |
13:50:00 | * | derlafff quit (Remote host closed the connection) |
14:00:00 | * | derlafff joined #nim |
14:25:52 | * | tdc quit (Quit: WeeChat 1.5) |
14:26:25 | * | tdc joined #nim |
14:29:38 | * | Tortice quit (Read error: Connection reset by peer) |
14:32:20 | * | derlafff quit (Remote host closed the connection) |
14:38:11 | * | tefter joined #nim |
14:41:59 | * | SenasOzys quit (Remote host closed the connection) |
14:42:48 | * | SenasOzys joined #nim |
14:44:01 | * | jjido joined #nim |
14:46:19 | * | jjido quit (Client Quit) |
14:48:28 | * | jjido joined #nim |
14:50:13 | * | lilltiger2 joined #nim |
14:51:48 | * | lilltiger2 quit (Remote host closed the connection) |
14:53:27 | * | redlegion quit (Quit: Ded.) |
14:53:47 | shashlick | @gogolxdong you got it working? |
14:55:12 | * | vlad1777d quit (Ping timeout: 268 seconds) |
14:59:29 | FromDiscord_ | <exelotl> one thing I've been wondering... Nim iterators look and feel a lot like coroutines. Is it possible to use them as such? (i.e. calling an iterator manually to resume it, not as part of a for loop) |
14:59:46 | Yardanico | well, I think you can't really do that |
15:00:24 | * | sph joined #nim |
15:02:17 | * | redlegion joined #nim |
15:02:18 | * | sph quit (Remote host closed the connection) |
15:02:21 | * | redlegion quit (Changing host) |
15:02:21 | * | redlegion joined #nim |
15:04:11 | FromDiscord_ | <Shield> that's exactly how asyn functions work, they're closure iterators under the hood |
15:05:15 | FromDiscord_ | <Shield> the tricky part is knowing how long should a function run before yielding to let other functions get some time |
15:06:41 | FromDiscord_ | <Shield> nim does have coroutines btw, try those |
15:07:38 | * | Tortice joined #nim |
15:32:05 | FromDiscord_ | <exelotl> yeah, but this doesn't quite seem like what i'm after https://nim-lang.org/docs/coro.html |
15:33:11 | FromDiscord_ | <exelotl> at least, the docs don't make it clear at all how these are supposed to be used |
15:38:10 | FromDiscord_ | <exelotl> can you use nim coroutines like this? http://leafo.net/posts/itchio-and-coroutines.html |
15:40:02 | * | edcragg quit (Quit: ZNC - http://znc.in) |
15:41:17 | * | edcragg joined #nim |
15:44:07 | * | erratic joined #nim |
15:49:21 | * | vlad1777d joined #nim |
15:52:41 | * | SenasOzys quit (Ping timeout: 252 seconds) |
15:54:43 | * | elrood joined #nim |
16:02:55 | * | SenasOzys joined #nim |
16:04:11 | * | rimd2r12 joined #nim |
16:05:05 | * | derlafff joined #nim |
16:08:25 | * | cori joined #nim |
16:11:28 | * | rimd2r12 quit (Remote host closed the connection) |
16:13:28 | FromGitter | <Bennyelg> (https://files.gitter.im/nim-lang/Nim/jgqw/image.png) |
16:14:17 | FromGitter | <Bennyelg> Finish line. |
16:14:18 | FromGitter | <Bennyelg> (https://files.gitter.im/nim-lang/Nim/2Rz9/image.png) |
16:15:19 | * | kori joined #nim |
16:15:52 | FromDiscord_ | <exelotl> nice :D |
16:15:59 | FromGitter | <Bennyelg> Oo hehe |
16:17:31 | krux02 | exelotl: you can't call inline iterators like coroutines, they are in loop only. |
16:19:17 | * | kori quit (Remote host closed the connection) |
16:19:23 | * | jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
16:22:54 | FromDiscord_ | <exelotl> ah ok. I have different question now, is there a way to store a struct as 'static const' and take a pointer to it? |
16:25:11 | FromDiscord_ | <exelotl> I was trying to do e.g. const myVTable = EntityVTable(update: cast[EntityFn](update), draw: cast[EntityFn](draw), .....) |
16:25:27 | * | axhanul joined #nim |
16:26:06 | FromDiscord_ | <exelotl> where EntityFn has nimcall convention so update and draw are just function pointers |
16:26:48 | FromDiscord_ | <exelotl> but I can't get a pointer to myVTable because 'const' doesn't allow it |
16:28:26 | * | axhanul quit (Remote host closed the connection) |
16:33:01 | * | tdog joined #nim |
16:33:39 | * | tdc quit (Ping timeout: 252 seconds) |
16:34:27 | * | Jesin joined #nim |
16:38:01 | Araq | unsafeAddr ? |
16:39:38 | FromDiscord_ | <exelotl> I managed to get it working with unsafeAddr but I had to use `let myVTable` instead of const |
16:41:25 | FromGitter | <bung87> why not using const now? |
16:41:52 | FromGitter | <bung87> I also tried const table, does not figure out. |
16:42:02 | * | Trustable joined #nim |
16:46:38 | FromDiscord_ | <exelotl> https://gist.github.com/geckojsc/19df2068afc4b5093b8ffe32e471e147 |
16:50:33 | FromGitter | <bung87> well does not work it out. |
17:00:59 | Tortice | please forgive the spaghetti, but when I uncomment line 33 all of my memory is exhausted and the program is killed http://ix.io/1nWr - what I want to happen is have the GUI updated after 10 seconds |
17:02:54 | * | anamok joined #nim |
17:04:05 | anamok | Hi. How can I format an integer to be divided by thousands? Examples: 2018 -> "2,018", or 1_234_567 -> "1,234,567". |
17:04:33 | * | miran joined #nim |
17:08:59 | * | TheLemonMan joined #nim |
17:09:11 | TheLemonMan | anamok, insertSep |
17:09:45 | anamok | TheLemonMan, can you give a short example? |
17:10:00 | Tortice | https://nim-lang.org/docs/strutils.html#insertSep%2Cstring%2CChar%2Cint |
17:10:21 | Tortice | insertSep("1000000", digits=3) |
17:10:22 | anamok | OK, found it |
17:10:25 | anamok | thanks |
17:10:40 | leorize | !eval echo insertSep($10000, ',') |
17:10:41 | NimBot | Compile failed: in.nim(1, 6) Error: undeclared identifier: 'insertSep' |
17:10:50 | leorize | !eval import strutils; echo insertSep($10000, ',') |
17:10:53 | NimBot | 10,000 |
17:11:02 | anamok | awesome, this is exactly what I needed |
17:12:06 | TheLemonMan | I now hate nimble's centralized registry, the package submission process should be automatized |
17:18:51 | Araq | TheLemonMan: IMO Nimble should just search github |
17:19:12 | Araq | DRY holds for package managers too. |
17:19:14 | Araq | bbl |
17:20:36 | FromGitter | <dom96> Yep. The process should be automatised. |
17:21:01 | FromGitter | <dom96> You keep suggesting this Araq, but this isn’t practical |
17:21:04 | TheLemonMan | yeah, to be honest I'd just drop the search feature alltogether, google (or whatever your favourite search engine is) is much better than your hand-rolled search (or shithub one, that's terrible right now) |
17:21:11 | FromGitter | <dom96> you can’t “just search github” |
17:21:34 | TheLemonMan | go approach is cool, just let the user drop a list of vcs urls and be done with it |
17:21:49 | FromGitter | <dom96> You can do that with nimble too if you want |
17:22:00 | FromGitter | <dom96> But then I won’t be using your package :p |
17:23:16 | TheLemonMan | that's the main problem |
17:23:20 | FromGitter | <dom96> But you know... I made nimble decentralised on purpose to allow anyone to create a package repo |
17:23:35 | FromGitter | <dom96> So go for it. |
17:23:52 | Yardanico | we have a user named So in this channel :P |
17:24:04 | TheLemonMan | a repo/registry makes it not so decentralized in my eyes |
17:24:11 | FromGitter | <dom96> Create an improved version or improve what we have |
17:28:20 | FromGitter | <dom96> Every decentralised system becomes centralised. Look at git and GitHub |
17:28:28 | TheLemonMan | I don't think we're in dire need of another package manager |
17:28:30 | FromGitter | <dom96> We need a centralised repo for convenience |
17:29:59 | TheLemonMan | convenient for who? the end user that in 99% of the times already knows about the package he's about to install? |
17:30:52 | FromGitter | <dom96> How do you deal with conflicting names without a single repo? |
17:31:32 | * | tiorock joined #nim |
17:31:33 | * | tiorock quit (Changing host) |
17:31:33 | * | tiorock joined #nim |
17:31:33 | * | rockcavera is now known as Guest30569 |
17:31:33 | * | Guest30569 quit (Killed (weber.freenode.net (Nickname regained by services))) |
17:31:33 | * | tiorock is now known as rockcavera |
17:32:34 | TheLemonMan | let the user deal with that in the unlikely case that a) two packages share the same name b) the end user needs both |
17:32:50 | TheLemonMan | gotta optimize for the average case |
17:33:24 | * | Voziv1 joined #nim |
17:34:11 | shashlick | Only need centralized for search |
17:34:22 | shashlick | Cause not everyone knows about packages |
17:34:53 | shashlick | That being said, submitting multiple packages is a pain, have to manually edit the json |
17:35:07 | * | Voziv1 quit (Remote host closed the connection) |
17:35:09 | TheLemonMan | can't you just use goog.le for that? |
17:35:12 | shashlick | Single packages are easy with nimble publish |
17:35:41 | shashlick | Google doesn't necessarily mean you will find what you need |
17:35:48 | shashlick | You don't know what you don't know |
17:36:50 | FromGitter | <dom96> Google won’t answer questions like “what’s the most popular package?” |
17:36:51 | TheLemonMan | I don't get how limiting the search on the registry will help with that |
17:37:33 | FromGitter | <dom96> Plus. The fact that somebody bothered to add a package to the registry is a good signal that the package is at least somewhat reliable. |
17:38:35 | FromGitter | <kayabaNerve> Putting links directly in code like Go seems like a great way to break stuff. |
17:39:55 | FromGitter | <dom96> Oh yeah |
17:40:12 | FromGitter | <dom96> In fact, that’s number one reason why we need our own centralised registry |
17:40:34 | FromGitter | <dom96> People randomly remove their git repos |
17:41:47 | TheLemonMan | yeah let's keep talking about more edge cases |
17:42:04 | * | chemist69 quit (Ping timeout: 240 seconds) |
17:42:16 | TheLemonMan | the registry is just a collection of links, if the user pulls a repo you're SOL anyway |
17:42:50 | miran | sorry to interrupt, quick question: is there to replace my repeated code "for x in x1 .. x2: for y in y1 .. y2:" with some template/macro that will do that for me? |
17:43:01 | miran | *is there a way to... |
17:43:23 | TheLemonMan | and now you can vendor your dependencies in go, you don't just "Put[ting] links directly in code" |
17:43:24 | FromGitter | <kayabaNerve> TheLemonMan not if the registry has the updated link or the packages itself. |
17:43:53 | FromGitter | <kayabaNerve> My comment was about package version control though. |
17:44:08 | FromGitter | <kayabaNerve> Also, good to know |
17:44:26 | * | chemist69 joined #nim |
17:44:51 | miran | ok, i think i found a way with a template, that was easier than i thought |
17:46:12 | TheLemonMan | miran, an iterator yielding (int, int) maybe? but a template is also good IMO |
17:46:57 | TheLemonMan | oh, hacktoberfest starts tomorrow |
17:47:31 | shashlick | Well fork every package submitted and maintain own copy then |
17:48:04 | FromGitter | <dom96> Edge cases? |
17:48:18 | FromGitter | <dom96> These are real issues that already happened to us. |
17:48:37 | shashlick | They have happened in npm, go, etc |
17:48:44 | shashlick | Python has pip |
17:48:50 | FromGitter | <dom96> Araq has already forked tons of packages defensively. As have I. |
17:48:59 | miran | TheLemonMan: speaking of hacktoberfest — dom96, i have written a short introduction to nim-hacktober |
17:49:08 | FromGitter | <dom96> And yeah, in npm’s case that was particularly bad |
17:49:24 | miran | dom96: i can send/show it to you, to see what should be changed/added |
17:49:37 | shashlick | Well it's the standard centralized vs decentralized discussion |
17:49:52 | FromGitter | <dom96> miran: awesome. Sure, you can just create a PR on the website repo and I can review it that way if you’d like. |
17:49:56 | shashlick | All great decentralized but quality goes to the toilet |
17:50:19 | shashlick | Apple app store vs the rest |
17:50:27 | shashlick | Everyone wants control |
17:50:33 | miran | @dom96 i think this is in too early stage to create a PR. i'll upload it to gist and share the link here |
17:52:13 | FromGitter | <dom96> Okay. Whatever you prefer. |
17:52:30 | * | jjido joined #nim |
17:52:51 | FromGitter | <dom96> Btw I’m heading to meet @cabhishek |
17:53:18 | FromGitter | <dom96> In SF today. If anyone’s around, you’re welcome to join us |
17:53:36 | miran | https://gist.github.com/narimiran/88f2a5f80ae2beaaf549504cf37e0ec6 |
17:53:57 | miran | ^ @dom96 |
17:55:09 | miran | it is still work in progress, so if anybody has something to add, please let me know (you can add a comment there) |
17:59:19 | * | ggbit joined #nim |
17:59:27 | * | tdog quit (Ping timeout: 252 seconds) |
17:59:55 | FromGitter | <dom96> Nice! I would add some explanation of what docs we’re looking for. How to document Nim code and generate the docs. |
18:00:34 | FromGitter | <dom96> For the last section I would mention that once the package is written it can be submitted to our packages repo, which counts as a PR :) |
18:00:59 | miran | @dom96 ok, will work on that tomorrow, now i'm too tired. good idea about PR to packages repo! |
18:04:57 | * | geocar left #nim (#nim) |
18:05:20 | * | tdog joined #nim |
18:12:00 | * | ArchDuke joined #nim |
18:13:41 | FromGitter | <Bennyelg> @narimiran cool intro |
18:14:01 | miran | thanks @Bennyelg |
18:14:09 | * | Trustable quit (Remote host closed the connection) |
18:14:22 | * | ArchDuke quit (Remote host closed the connection) |
18:14:57 | Tortice | asking again: when I uncomment line 33 all of my memory is exhausted and the program is killed http://ix.io/1nWr - what I want to happen is have the GUI updated after 10 seconds |
18:14:59 | * | ggbit quit (Quit: Page closed) |
18:16:23 | FromGitter | <cabhishek> @dom96 👍 |
18:17:05 | TheLemonMan | updating the UI from a different thread is usually a big no depending on the toolkit |
18:18:21 | * | jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
18:18:56 | Tortice | I thought that was the right thing to do, but I come from python land with http://appjar.info/pythonThreads/ & http://appjar.info/pythonLoopsAndSleeps/ as reference |
18:20:47 | TheLemonMan | come on, the first link states "Threads don't always work nicely with GUIs, so your thread mustn't try to change the GUI, instead you will need to put any GUI updates in a Queue" |
18:25:08 | anamok | In Kotlin there is a construct that I really liked: `repeat(5) { ... }` , which executes the body 5 times. I find it more elegant than `for i in 0 ..< 5`. Is there a way to replicate repeat in Nim? |
18:26:12 | TheLemonMan | template/macro |
18:26:13 | miran | template called repeat? |
18:26:57 | anamok | proc and func is clear, but template/macro is new to me |
18:27:28 | miran | anamok: i'll show you the example, just a sec |
18:28:36 | Tortice | okay, this no longer tries to update the gui from a different thread, but it doesn't appear to wait at all http://ix.io/1nWQ |
18:28:37 | TheLemonMan | anamok, https://gist.github.com/LemonBoy/f7345ddb8f7ac47534e2f989eeb4a122 |
18:29:01 | miran | anamok: http://ix.io/1nWS/ |
18:29:45 | miran | anamok: ok, TheLemonMan's version has a bit more things in it. take his version as he is much more experienced than me :) |
18:29:46 | anamok | Thanks! It's really great that you can do that in Nim. |
18:36:30 | anamok | I'm working on a little library where I have this: `func toInt*(a: string): int = parseInt(a)` . If I replace func with template, they both work. What's the difference? Which one should it be? |
18:36:52 | * | jjido joined #nim |
18:39:37 | miran | is should be func |
18:39:50 | FromDiscord_ | <Shield> a func is a normal function, you call it it works, a template however will inject its content at the place where you call it, as if you copy pasted its content there, same as inlining |
18:40:35 | miran | anamok: see the list of priorities here: https://nim-lang.org/docs/manual.html#macros-statement-macros |
18:40:44 | FromDiscord_ | <exelotl> TheLemonMan: what's the purpose of static[] in that template? |
18:41:21 | TheLemonMan | exelotl, force the argument to be a CT one |
18:42:55 | FromGitter | <bung87> https://github.com/bung87/cpp_nim_interop/blob/master/src/cpp_nim_interop/std/vector.nim how to make it work cpp vector <=> seq ? |
18:44:11 | FromGitter | <bung87> I hit stackoverflow sometime and can not get representation when call `echo toVector( @[1, 2])` |
18:45:21 | Tortice | so I'm guessing I shouldn't be using spawn, but rather createThread? http://ix.io/1nWQ |
18:49:16 | FromDiscord_ | <Shield> what are you trying to do? |
18:50:32 | Tortice | I want to loop over each chunk in the sequence, wait a certain number of seconds, update the gui, then continue |
18:51:18 | FromGitter | <vivekimsit> Hi, I want to buy the nim in action book, is there any promo or discount available ;p |
18:52:54 | FromDiscord_ | <Shield> i don't think i understood your code, why are you spawning a wait(seconds) in a separate thread? |
18:53:00 | * | piro_14 joined #nim |
18:55:09 | * | skellock joined #nim |
18:57:21 | * | piro_14 quit (Remote host closed the connection) |
18:58:13 | Tortice | because the ui blocks with sleep in the same thread |
18:59:03 | * | lewd24 joined #nim |
19:00:29 | FromDiscord_ | <Shield> spawning sleep in another thread will create a thread and make it sleep, then it ends, the main thread isn't affected whatsoever |
19:01:33 | Tortice | then what's the solution if I'm not supposed to update the gui from a seperate thread? |
19:02:26 | * | lewd24 quit (Read error: Connection reset by peer) |
19:02:58 | FromDiscord_ | <Shield> you want to call dump() itself in another thread and use normal sleeping, you use channels to make the second thread send data about its state, while the main thread will try to read from that channel to know the state of the thread |
19:05:50 | FromDiscord_ | <exelotl> it's a shame you can't define a macro that allows this config MyConfig: x, y: int |
19:06:08 | FromDiscord_ | <exelotl> it has to be like this config MyConfig: x:int y:int |
19:06:53 | FromDiscord_ | <exelotl> if I omit the comma then it's valid nim syntax config MyConfig: x y: int |
19:07:08 | FromDiscord_ | <exelotl> but that seems unconventional. :s |
19:09:07 | * | nsf quit (Quit: WeeChat 2.2) |
19:12:21 | * | krux02 quit (Remote host closed the connection) |
19:13:49 | Tortice | where should I spawn the thread from if I can't do it from the button press proc? |
19:14:47 | * | mirv_ joined #nim |
19:17:56 | * | mirv_ quit (Remote host closed the connection) |
19:24:10 | FromGitter | <vivekimsit> For some reasons I think `nimble test` is not running my tests |
19:24:27 | FromGitter | <vivekimsit> it just says `Success: All tests passed` |
19:24:39 | FromGitter | <vivekimsit> even if I change my tests to fail |
19:25:40 | stefanos82 | dom96: are you available for a second? |
19:27:33 | stefanos82 | dom96: the latest nim dev version fails to compile your NimbleExample/math you demonstrated in your book. |
19:27:55 | stefanos82 | is says now "Error: undeclared identifier: 'math'" |
19:28:01 | stefanos82 | it used to work before |
19:28:09 | stefanos82 | yes, the package is installed |
19:32:31 | stefanos82 | Araq: did you break multiline comments #[ ... ]# by mistake in nim version 407ede3aaefc94bc79c0edba158e4403ccfbb401? |
19:32:36 | stefanos82 | it does not work |
19:33:26 | stefanos82 | this is the error it throws: "Error: end of multiline comment expected" |
19:36:43 | stefanos82 | OK, I closed it and reopened it and now works >:| |
19:37:17 | FromGitter | <vivekimsit> my tests are not working too |
19:37:51 | stefanos82 | interesting |
19:38:01 | stefanos82 | did you check your generated log file? |
19:38:40 | FromGitter | <vivekimsit> its just says all tests passed |
19:39:07 | FromGitter | <vivekimsit> how to select older version by choosenim? |
19:40:39 | * | tdog quit (Ping timeout: 252 seconds) |
19:41:33 | * | riidom quit (Remote host closed the connection) |
19:43:20 | stefanos82 | I have no idea; what does choosenim --help say? |
19:44:37 | Tortice | vivekimsit, just type the version |
19:44:42 | Tortice | $ choosenim 0.18.0 |
19:44:50 | stefanos82 | cool |
19:45:13 | Tortice | help with type mismatch? http://ix.io/1nXb |
19:46:14 | stefanos82 | what line does it say it's the mismatch |
19:46:22 | Tortice | 101 |
19:46:56 | FromGitter | <vivekimsit> ok, can confirm now. Switching back to version `0.18.0` runs my tests again |
19:49:40 | FromGitter | <kdheepak> @mratsim @krux02 Interesting. Thanks for the comments. My initial impression was that even if I allocate a lot of objects on the heap, it should just consume more memory and shouldn't effect speed as much. Nim's gc should take care of the memory allocations eventually. |
19:50:48 | FromGitter | <kdheepak> Your comments seem to indicate that I should allocate on the heap. Should I reuse existing allocations or call the GC? |
19:50:49 | FromDiscord_ | <Shield> @torice read the docs for createThread, that's not how you use it, you need to pass a thread variable to store the thread, it's not like spawn, check some threading examples |
19:52:00 | FromGitter | <kdheepak> People are going to have such a laugh when I share my code, because it's probably so poorly optimized. |
19:52:08 | FromGitter | <kdheepak> I just coded the way I would in Python. |
19:52:42 | stefanos82 | why choosenim cannot be found with nimble search command? |
19:53:07 | FromGitter | <kdheepak> I'm still not sure why creating a large number of objects on the heap and storing them in a seq would be slow though. |
19:53:31 | stefanos82 | ah I see to run a script first -_- |
19:54:27 | * | ExEs47 joined #nim |
19:54:28 | FromGitter | <vivekimsit> Can someone please check if they are able to run their tests after switching to 0.19.0? |
19:54:45 | Yardanico | what's the error you're getting? |
19:56:07 | FromGitter | <vivekimsit> no error, it just says `Success: All tests passed` |
19:56:19 | FromGitter | <vivekimsit> even for failing tests |
19:56:35 | FromGitter | <vivekimsit> switching back to older version works as expected |
19:59:48 | * | ExEs47 quit (Remote host closed the connection) |
20:00:34 | stefanos82 | how can I uninstall choosenim if I want to? there's no information anywhere on the project's page |
20:02:40 | FromGitter | <vivekimsit> yes, I just sent a PR to update the usage section |
20:03:26 | FromGitter | <vivekimsit> lol, changing readme changed the Travis test |
20:03:35 | FromGitter | <vivekimsit> broke* |
20:03:58 | * | arthurnn28 joined #nim |
20:07:11 | * | bodie_7 joined #nim |
20:07:23 | Tortice | should be createThread(Thread, dump(url, seconds, dir, status)? |
20:09:09 | * | arthurnn28 quit (Remote host closed the connection) |
20:11:49 | FromGitter | <kdheepak> @vivekimsit I'm able to run my tests in 0.19.0 |
20:11:59 | stefanos82 | @vivekimsit: when you decide to install a different version along with the existing one, where will it place it inside $HOME/.nimble/bin/ ? |
20:16:43 | * | bodie_7 quit (Ping timeout: 245 seconds) |
20:20:18 | * | jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
20:28:07 | * | Tortice quit (Remote host closed the connection) |
20:34:10 | FromGitter | <mratsim> @kdheepak on a local PC (i.e. without networking) memory allocation is the most costly thing. |
20:34:38 | FromGitter | <mratsim> that’s why most games use a memory pool for example, to reuse memory already allocated. |
20:35:30 | FromGitter | <mratsim> Since dynamicc language work so often with strings, both JS and Python will optimize a lot small memory allocations and reuse them from a pool |
20:36:06 | FromGitter | <mratsim> but Nim (and C, C++, Rust, …) will not give you easy tool that are hard to go around when there not sufficient |
20:36:13 | * | miran quit (Ping timeout: 268 seconds) |
20:36:51 | FromGitter | <mratsim> Have a look into this blog post to write a fast parser: https://nim-lang.org/blog/2017/05/25/faster-command-line-tools-in-nim.html the example is with CSV |
20:42:07 | * | nsf joined #nim |
20:53:26 | * | TheLemonMan quit (Quit: "It's now safe to turn off your computer.") |
20:54:12 | * | nsf quit (Quit: WeeChat 2.2) |
21:02:20 | * | skellock quit (Quit: WeeChat 1.9.1) |
21:05:25 | * | Vladar quit (Remote host closed the connection) |
21:09:00 | * | gangstacat quit (Quit: Ĝis!) |
21:34:53 | * | druonysus quit (Read error: Connection reset by peer) |
21:56:20 | * | nitram27 joined #nim |
21:58:30 | * | nitram27 quit (K-Lined) |
21:59:13 | FromGitter | <kdheepak> Thanks for the comment @mratsim! |
21:59:31 | FromGitter | <kdheepak> I refactored my code base to use less allocations on the heap. |
22:00:40 | * | tzui quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
22:00:58 | FromGitter | <kdheepak> Initially I was using a object for each character: I had something like the following ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ This made it easy to [https://gitter.im/nim-lang/Nim?at=5bb14799bbdc0b2505c7b603] |
22:01:28 | FromGitter | <kdheepak> This made it easy to print out the exact position of the error when I wasn't able to parse the file. |
22:02:07 | FromGitter | <kdheepak> I've now refactored the codebase to no longer use Character, and store the line_index and column_index in the token. Can probably optimize it more. |
22:02:39 | * | darithorn joined #nim |
22:03:05 | FromGitter | <kdheepak> But good news! ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bb14819c7bf7c3662977e9f] |
22:03:14 | FromGitter | <kdheepak> Nim is about 8 times faster now. |
22:03:52 | FromGitter | <alehander42> what is source_text? the token text/the line/the whole text? |
22:04:13 | FromGitter | <kdheepak> Yes. ( bad idea? ) |
22:04:16 | * | TViernion26 joined #nim |
22:04:30 | FromGitter | <alehander42> but which one of them? :D |
22:04:33 | * | krux02 joined #nim |
22:05:00 | FromGitter | <kdheepak> Haha omg sorry I didn't read, it was the whole text |
22:06:06 | * | darithorn_ joined #nim |
22:06:29 | * | darithorn_ quit (Client Quit) |
22:06:37 | FromGitter | <alehander42> I just thought that the code that generates the error, knows about the text anyway, so it doesn't need to be pointed to from each character? (but maybe it can be somehow ambigious) |
22:06:46 | FromGitter | <alehander42> each token* |
22:06:55 | FromGitter | <alehander42> ah that's the old code anyway |
22:06:56 | FromGitter | <alehander42> nvm |
22:06:58 | FromGitter | <ephja> doesn't that make it one copy of the whole string for every processed character? |
22:07:25 | FromGitter | <gogolxdong> yes |
22:07:38 | * | TViernion26 quit (Remote host closed the connection) |
22:08:04 | * | MoaMoaK21 joined #nim |
22:09:38 | * | darithorn quit (Ping timeout: 272 seconds) |
22:11:52 | * | wildlander quit (Quit: Konversation terminated!) |
22:12:50 | * | MoaMoaK21 quit (Remote host closed the connection) |
22:13:55 | FromGitter | <kdheepak> That would explain why things were so very slow. |
22:14:07 | * | ChrisWi9 joined #nim |
22:18:00 | * | ChrisWi9 quit (Remote host closed the connection) |
22:23:29 | * | gangstacat joined #nim |
22:24:20 | * | elrood quit (Quit: Leaving) |
22:35:21 | anamok | Having a unicode string, how to get its last character? Ex.: "helló"[^1] doesn't give back the ó character. |
22:36:12 | FromGitter | <kdheepak> Might have to use `Rune`? |
22:36:34 | FromGitter | <mratsim> ^ |
22:36:37 | * | Tortice joined #nim |
22:36:54 | FromGitter | <mratsim> yes see here: https://nim-lang.org/docs/unicode.html#runeLen%2Cstring |
22:37:24 | FromGitter | <kdheepak> The last character in that string is what you get. What you want is the last Unicode character. You can't use normal indexing for that unfortunately. |
22:37:27 | FromGitter | <mratsim> I think we need a seq[Rune] or type UtfString = distinct string to avoid issues |
22:38:12 | FromGitter | <kdheepak> Python has spoiled me here. I'm so used to not even thinking about the somewhat low level details. |
22:42:03 | anamok | `echo toSeq("helló".runes)[^1]` works |
22:45:36 | * | darkoneko joined #nim |
22:45:53 | Tortice | http://ix.io/1nXU cannot instantiate Thread got: <int literal(0)> expected: <TArg> |
22:48:26 | krux02 | kdheepak: when you use [^1] on a string you get the last byte of a string |
22:48:58 | krux02 | while what anamok says is true it is extremely inefficient. |
22:49:42 | krux02 | it converts the entire string into a new seq object that is around 4 times bigger than the original string just to get the last rune |
22:50:07 | krux02 | kdheepak: never index by rune, that never works |
22:52:19 | krux02 | kdheepak: just look at how multibyte sequentces in unicode are composed, then you can find out a very fast and reliable way to get the last rune. |
22:53:07 | * | darkoneko quit (Ping timeout: 268 seconds) |
22:54:53 | * | r0kc4t joined #nim |
22:55:07 | * | r0kc4t quit (Remote host closed the connection) |
23:01:27 | anamok | How to get the unicode codepoint of "ó"? I tried `ord('ó')` but got an error: missing closing ' for character literal. |
23:02:57 | krux02 | anamok, that one is a multibyte rune, character literals can only hold single byte characters. |
23:03:17 | krux02 | or in other words "bytes" |
23:03:31 | krux02 | maybe "char" is the wrong word |
23:04:53 | krux02 | anamok: manybe there are unicode functions to help you, but first of all you really need to know how multibyte utf8 works |
23:05:11 | FromGitter | <bung87> anamok you need unicode module |
23:05:32 | krux02 | then you will know how to get the unicode codepoint, but you might look for a helper, if you don't find one, you will be able to write it. |
23:05:51 | FromGitter | <bung87> no it’s in std |
23:06:31 | krux02 | bung87: my point is, just because there is a module for it, it doesn't mean you can spare yourself from understanding the basics. |
23:07:40 | FromGitter | <bung87> yeah I agree |
23:09:43 | krux02 | btw my PR on nim-mode got merged |
23:09:58 | krux02 | code highlighting is now fast |
23:10:47 | * | kali-chewy joined #nim |
23:10:59 | krux02 | says a lot about emacs that you can screp up syntax highlighting to be slow, but yea for Nim it's fast, until somebody breaks it. |
23:11:12 | krux02 | I go to bed now. |
23:11:28 | * | kali-chewy quit (Killed (Sigyn (Spam is off topic on freenode.))) |
23:11:29 | FromGitter | <bung87> do you have document about epc ? |
23:11:40 | krux02 | no |
23:11:53 | krux02 | epc is a real complexity monster in my eyes |
23:12:18 | krux02 | and the reason to use epc was async |
23:12:29 | krux02 | the problem of nimsuggest, it isn't async |
23:12:30 | FromGitter | <bung87> so what is using in transport layer. |
23:12:34 | krux02 | it blocks the input |
23:13:11 | krux02 | theri is epc in use, but that part is not what I understand |
23:13:28 | krux02 | I am happy I understand the fontification process now, kind of. |
23:13:34 | FromGitter | <bung87> guess that’s the reason why vscode-nim using one process per file. |
23:13:42 | krux02 | at least well enough to make it fast. |
23:13:57 | krux02 | ouch, one process per file |
23:14:16 | krux02 | processes are not cheap. |
23:14:42 | FromGitter | <bung87> yeah I tried remain one process per workspace but does not work. |
23:15:13 | krux02 | emacs does not have a concept of a workspace |
23:15:26 | krux02 | I really needed to get used to that |
23:16:06 | anamok | thanks, bye |
23:16:22 | * | anamok quit (Remote host closed the connection) |
23:16:30 | krux02 | I think vscode is a complexity monster as well. It just uses more popular web tech |
23:16:32 | FromGitter | <bung87> I impelemented a nim version switch at vscode status bar can change it for current workspace. |
23:17:07 | krux02 | switch what version? |
23:17:28 | FromGitter | <bung87> but for a nim language server ,must first implemented language protocol. |
23:17:35 | FromGitter | <bung87> nimsuggest version |
23:18:28 | krux02 | I now understand what is so broken about LSP |
23:19:20 | * | lbt10 joined #nim |
23:19:36 | krux02 | at least I think |
23:19:54 | FromGitter | <bung87> MS implemented js version and C# version |
23:20:04 | krux02 | It uses this high overhead network protocol and it has no support for low level features, such as syntax highlighting. |
23:20:48 | krux02 | I don't use vscode for one very simple reason. |
23:21:30 | FromGitter | <bung87> vscode is still cool, no more configuration, the default behaviour fine to me |
23:21:52 | krux02 | I think the whole web technology stack is technology cancer. It grows complexety and eats all resources available to the computer for nothing more than a little bit of styling and interactivity. It should die sooner rather than later. |
23:22:16 | krux02 | I can't fight it anymore when it also grows in my development stack |
23:23:18 | krux02 | bung87, yes I agree. I want to change nim-mode, so that it also works without configuration. |
23:23:31 | krux02 | a lot of things work fine in vscode |
23:23:44 | krux02 | other are just horrible |
23:24:03 | FromGitter | <bung87> speak of cancer , the node package come to my head |
23:24:28 | * | lbt10 quit (Killed (Sigyn (Spam is off topic on freenode.))) |
23:24:43 | krux02 | I know node, and I don't even program javascript at all. |
23:24:53 | krux02 | not even as a compilation target |
23:25:05 | FromGitter | <bung87> so much developers can get involved |
23:26:36 | krux02 | somebody showed me how node package manager automatically wanted to check out something that was a combanation of a git hash and a version number |
23:26:41 | krux02 | total nonsense |
23:26:53 | krux02 | but yea, nimble is broken, too. |
23:27:14 | krux02 | I never had a reproducable build in nimble |
23:27:28 | krux02 | whenever I compiled on another computer, it didn't work. |
23:27:54 | krux02 | nimble isn't helping at all to manage dependencies reliably. |
23:28:17 | krux02 | but yea, I go to sleep for now. |
23:29:00 | FromGitter | <bung87> good night |
23:29:24 | * | krux02 quit (Remote host closed the connection) |
23:31:48 | Tortice | I clearly don't get threads cannot instantiate Thread got: <int literal(0)> expected: <TArg> |