00:00:00 | * | njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.) |
00:01:03 | * | njoseph joined #nim |
00:13:50 | * | abm quit (Read error: Connection reset by peer) |
00:40:50 | * | krux02 quit (Remote host closed the connection) |
00:48:02 | * | audiophile_ joined #nim |
00:50:58 | FromDiscord | <ElegantBeef> @Sabena Sema it also works with `type T` and `typedesc T` afaik |
00:51:11 | * | audiophile quit (Ping timeout: 240 seconds) |
00:51:13 | * | audiophile_ is now known as audiophile |
00:51:21 | FromDiscord | <Sabena Sema> isn't `type T` just command syntax though |
00:51:30 | FromDiscord | <Sabena Sema> it's the same as `type(T)` |
00:51:44 | FromDiscord | <ElegantBeef> nah `type T` == `typedesc T` as a param |
00:54:59 | FromDiscord | <theSherwood> Kind of a broad question, but what are the main differences between hindley-milner and nim's type system? |
00:56:45 | FromDiscord | <Sabena Sema> HM does global program inference, it can tell you the exact type of any typed thing, even if you don't specify it |
00:56:50 | FromDiscord | <Sabena Sema> nim can't do that |
00:58:29 | FromDiscord | <ElegantBeef> Nim's is just local scoped type inference |
00:58:44 | FromDiscord | <ElegantBeef> Actually local type inference ๐ |
00:58:59 | FromDiscord | <Rika> nim doesnt have inference by return type which makes me sad ๐ฆ |
00:59:19 | FromDiscord | <ElegantBeef> You mean something like auot? |
00:59:24 | FromDiscord | <ElegantBeef> (edit) "auot?" => "auto?" |
00:59:36 | FromDiscord | <Rika> no |
00:59:43 | FromDiscord | <Sabena Sema> sent a code paste, see https://play.nim-lang.org/#ix=2Wfd |
01:00:02 | FromDiscord | <Sabena Sema> it would infer the type from how you use it in the function |
01:00:19 | FromDiscord | <Rika> something like `var a: int = someProc[int#[this should not be needed]#](...)` |
01:00:51 | FromDiscord | <Rika> someproc is a generic proc [T](...): T |
01:00:53 | FromDiscord | <Sabena Sema> the thing is, doing full type inference like that really limits your type system design, and is also not that useful |
01:00:54 | * | gpanders joined #nim |
01:01:14 | FromDiscord | <ElegantBeef> Ah, makes sense |
01:02:11 | FromDiscord | <ElegantBeef> In my view the only type inference that we're really lacking is in case statements |
01:02:36 | FromDiscord | <ElegantBeef> `case yourEnum` feels like it should propogate to the `of` branches |
01:03:04 | FromDiscord | <Sabena Sema> also nim's generics take the approach of C++'s where it's not so stressed that the generic function actually works for all possible values of the generic parameters |
01:04:14 | FromDiscord | <ElegantBeef> Though i'd argue that's someone not using a typeclass or concept ๐ |
01:04:48 | FromDiscord | <Sabena Sema> even concepts don't enforce that in c++ |
01:04:54 | FromDiscord | <Sabena Sema> I forget if they do in nim |
01:05:20 | FromDiscord | <ElegantBeef> Well i'm saying that allowing generics into a function that doesnt support them is just bad limiting imo |
01:05:44 | FromDiscord | <ElegantBeef> Like for instance if you had a procedure that only works with string and you didnt do `[T: string]` |
01:05:52 | FromDiscord | <Sabena Sema> right, ofc the instantiation won't compile in c++, but the _definition_ compiles |
01:06:37 | FromDiscord | <Sabena Sema> it makes the generic system _much_ more powerful if you allow generics unconstrained generics like this |
01:06:44 | FromDiscord | <Sabena Sema> but can make it harder to do tooling and such |
01:06:48 | FromDiscord | <Sabena Sema> and can make errors worse |
01:07:55 | FromDiscord | <theSherwood> Fascinating. What sort of things does full type inference prevent you from doing? |
01:08:25 | FromDiscord | <Sabena Sema> overloading is one thing |
01:10:07 | FromDiscord | <mattrb> sent a code paste, see https://play.nim-lang.org/#ix=2Wfh |
01:10:40 | FromDiscord | <ElegantBeef> Yea, though i'd just check if `Count >= sizeOf(T) 8` |
01:10:54 | FromDiscord | <ElegantBeef> if it is return 0 else shift |
01:11:05 | FromDiscord | <ElegantBeef> Atleast that's what it seemed you were after yesterday |
01:11:31 | FromDiscord | <ElegantBeef> Ah nvm you did that ๐ |
01:11:34 | * | gpanders left #nim ("WeeChat 3.1") |
01:11:59 | FromDiscord | <ElegantBeef> Red the first if statement and didnt get where it was going |
01:12:04 | FromDiscord | <ElegantBeef> (edit) "Red" => "Read" |
01:12:20 | FromDiscord | <mattrb> Yeah literally just copying the Crystal implementation because that matches my assumptions :p |
01:12:58 | FromDiscord | <ElegantBeef> Well if you dont plan on using the system ones you can always overload the `shr` and `shl` from system, though only would work nicely from the same module |
01:14:05 | FromDiscord | <mattrb> I'd also like to fall back to the system ones in that implementation. Could I still do that with `import as` I guess? |
01:14:33 | FromDiscord | <mattrb> I mean I personally prefer the operators myself just because that's what I'm in the habit of typing, but I know Araq has voiced his opinion on that one ๐ |
01:14:34 | FromDiscord | <ElegantBeef> well you can do system.\`shr\`(a, b) but yea |
01:15:42 | FromDiscord | <mattrb> If I put that in a util file and imported it in every file, would that be enough? I assume system is implicitly the first import so anything else imported would overload system? |
01:15:46 | FromDiscord | <ElegantBeef> Well Nim is heavily inspired by wirth languages and due to that a lot of ops use the same words as their ancester version |
01:16:06 | FromDiscord | <ElegantBeef> It probably would be ambigious so would require your intervention, you can try though |
01:16:52 | FromDiscord | <mattrb> I'll just stick with the custom operators so that I don't mess it up anywhere with a bug that I'll never find :cringeharold: |
01:17:06 | FromDiscord | <ElegantBeef> Lol you do you ๐ |
01:24:14 | ForumUpdaterBot | New post on r/nim by sigzero: Versions 1.4.6 and 1.2.12 released, see https://reddit.com/r/nim/comments/mrsstr/versions_146_and_1212_released/ |
01:33:55 | * | audiophile quit (Quit: Default Quit Message) |
01:41:12 | * | Gustavo6046 quit (Ping timeout: 240 seconds) |
01:53:07 | * | gangstacat quit (Ping timeout: 260 seconds) |
01:54:29 | * | johnnynitwits quit (Quit: Bridge terminating on SIGTERM) |
01:54:29 | * | threenp quit (Quit: Bridge terminating on SIGTERM) |
01:56:37 | * | johnnynitwits joined #nim |
01:56:40 | * | threenp joined #nim |
01:57:57 | * | gangstacat joined #nim |
02:00:30 | * | vicfred quit (Remote host closed the connection) |
02:00:51 | * | vicfred joined #nim |
02:01:48 | * | vicfred quit (Max SendQ exceeded) |
02:01:52 | * | njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.) |
02:02:13 | * | njoseph joined #nim |
02:02:49 | * | vicfred joined #nim |
02:05:15 | * | gangstacat quit (Ping timeout: 260 seconds) |
02:05:51 | Prestige | sweet |
02:12:33 | * | vicfred quit (Quit: Leaving) |
02:15:53 | * | vicfred joined #nim |
02:18:39 | * | gangstacat joined #nim |
03:05:29 | * | vicfred quit (Quit: Leaving) |
03:08:45 | * | spiderstew_ joined #nim |
03:09:32 | * | spiderstew quit (Ping timeout: 258 seconds) |
03:13:45 | * | vicfred joined #nim |
03:31:32 | * | vicfred_ joined #nim |
03:33:47 | * | vicfred quit (Ping timeout: 246 seconds) |
03:38:04 | ForumUpdaterBot | New question by Dull Bananas: Nim: &quot;invalid type ... in this context&quot; error, see https://stackoverflow.com/questions/67118749/nim-quotinvalid-type-in-this-contextquot-error |
03:39:29 | * | vicfred__ joined #nim |
03:42:26 | * | vicfred_ quit (Ping timeout: 265 seconds) |
03:43:12 | * | beshr quit (Ping timeout: 240 seconds) |
03:44:16 | * | beshr joined #nim |
04:04:54 | * | vicfred__ quit (Quit: Leaving) |
04:19:31 | * | a_chou joined #nim |
04:25:33 | ForumUpdaterBot | New thread by Alexeypetrushin: How to disable logging from db_postgres?, see https://forum.nim-lang.org/t/7801 |
04:36:48 | * | a_chou quit (Quit: a_chou) |
04:37:19 | * | a_chou joined #nim |
04:44:13 | * | njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.) |
04:44:21 | * | njoseph joined #nim |
04:44:53 | * | njoseph quit (Client Quit) |
04:45:00 | * | njoseph joined #nim |
04:48:43 | * | njoseph quit (Client Quit) |
04:48:49 | * | njoseph joined #nim |
04:59:29 | * | rockcavera quit (Remote host closed the connection) |
05:54:04 | FromDiscord | <pietroppeter> In reply to @mlokis "doesn't stackowerflow recognize nim": @mlokis for Nim highlighting in stack overflow see this question and comments for a possible workaround: https://meta.stackexchange.com/questions/355491/add-syntax-highlighting-support-for-nim |
06:06:54 | * | a_chou quit (Remote host closed the connection) |
07:01:47 | * | PMunch joined #nim |
07:04:40 | PMunch | There, the playground is back online now |
07:04:44 | PMunch | Sorry about the downtime |
07:05:00 | PMunch | I'll have to figure out how to get docker to clean up after itself better.. |
07:05:24 | FromDiscord | <ElegantBeef> So much lost money |
07:05:25 | FromDiscord | <ElegantBeef> Shame! |
07:06:02 | PMunch | Lost money? |
07:08:41 | FromDiscord | <ElegantBeef> I've been told i'm terrible at jokes |
07:08:46 | FromDiscord | <Rika> Whatโs the joke |
07:08:58 | FromDiscord | <ElegantBeef> Exactly |
07:09:01 | FromDiscord | <Rika> Donโt tell me youโre so terrible the joke doesnโt |
07:09:04 | FromDiscord | <Rika> God |
07:09:30 | FromDiscord | <ElegantBeef> Nah the actual joke was to imply that massive amounts of money depend on nim playground running properly |
07:09:50 | FromDiscord | <Rika> But no idiot would imply that..? |
07:11:04 | FromDiscord | <ElegantBeef> Any one can be perceived as an idiot if they're silly enough to make an implication as such |
07:11:23 | PMunch | Haha :P |
07:24:46 | PMunch | Added another step of cleaning to the maintenance script. This will hopefully either keep it from crashing, or just push the window of manual intervention further into the future so I forget more of how I solve it :P |
07:25:09 | FromDiscord | <Rika> Why donโt you have a system for notification of crash |
07:25:26 | PMunch | Well it wasn't crashed as such |
07:25:40 | PMunch | I do have a ticker on my status bar telling me if the server is down |
07:25:59 | PMunch | The problem now was that it was just so bogged down in work that it didn't get anything done |
07:26:02 | FromDiscord | <ElegantBeef> He may have put a post it on top if it |
07:26:13 | PMunch | But it was still replying to my "HEAD" requests |
07:36:05 | ForumUpdaterBot | New thread by Alexeypetrushin: How to get column names for `db_postgres.getAllRows`?, see https://forum.nim-lang.org/t/7802 |
07:36:16 | FromDiscord | <jtiai> I don't have anything to ask but I just wanted to express my gratitude for those brave souls who helped me with my stupid questions and in complete ignorance with Nim. Finally pieces are falling into places. |
07:38:06 | PMunch | Haha, we where all there at some point :) |
07:39:07 | FromDiscord | <ElegantBeef> Yes we were ๐ |
07:39:34 | saem | Wait, it's supposed to get better? |
07:39:49 | FromDiscord | <ElegantBeef> Nah saem you touch the compiler it only goes downhill from there |
07:40:16 | FromDiscord | <ElegantBeef> You'll be speaking in semAuxProcs and semthis and semthat any semtime semnow |
07:40:28 | saem | Do I touch the compiler or does it touch me? |
07:40:45 | saem | semYeah |
07:41:08 | FromDiscord | <ElegantBeef> I believe to prevent araq from being arrested for enabling sex crimes you neither |
07:41:10 | FromDiscord | <ElegantBeef> (edit) removed "you" |
07:41:34 | saem | I mean... I'm into it. |
07:42:08 | FromDiscord | <ElegantBeef> We dont judge |
07:42:13 | FromDiscord | <ElegantBeef> Ok we do just not much |
07:42:16 | saem | My list has grown, I want to get back to typeDesc stuff soonish |
07:42:55 | saem | Beef, BTW you ever poked at CPS? |
07:43:32 | FromDiscord | <ElegantBeef> I've looked at it briefly but nope |
07:43:58 | FromDiscord | <ElegantBeef> I feel like you overestimate my intelligence by a factor of atleast 10 |
07:43:58 | saem | Didn't speak to you? |
07:44:25 | FromDiscord | <ElegantBeef> I mean if we went over everything that spoke to me, we'd be here all night |
07:44:34 | saem | Hehe |
07:44:42 | FromDiscord | <Rika> Iโm afraid that code does not speak |
07:45:45 | FromDiscord | <ElegantBeef> What would you know rika |
07:45:51 | FromDiscord | <ElegantBeef> My pillow says you dont know anything |
07:46:15 | saem | Your pillow is a pikachu |
07:46:15 | FromDiscord | <ElegantBeef> Jokes aside, why were you wondering? |
07:46:51 | saem | I'm trying to suss out what does it doesn't seem accessible about it. |
07:47:47 | FromDiscord | <ElegantBeef> I might be the best person then, considering my lack of actually writing async code ๐ |
07:48:18 | FromDiscord | <ElegantBeef> Atleast based off my understanding being able to use it to async stuff is a big benefit of it |
07:48:35 | saem | CPS isn't necessarily about async, you _could_ use it for that. |
07:49:45 | saem | You can use it for generators, iterators, lots of stuff |
07:50:06 | FromDiscord | <ElegantBeef> Yea yea yea, i get that everytime i say that |
07:50:12 | saem | Could end up with an actor system, some thread pool thing. |
07:55:04 | FromDiscord | <ElegantBeef> Anywho i dont really understand CPS as you can tell, all i know is they kids away from abusive parents |
08:02:04 | * | motersen quit (Remote host closed the connection) |
08:02:05 | * | Vladar joined #nim |
08:16:56 | FromDiscord | <Gary M> I had to dig up some CPS stuff because it's such an archaic way of programming from the 70's lol |
08:17:00 | FromDiscord | <Gary M> https://media.discordapp.net/attachments/371759389889003532/832529999683911690/Screenshot_20210416-011530.jpg |
08:17:08 | FromDiscord | <Gary M> I found this conversation amusing |
08:18:52 | PMunch | Haha |
08:39:23 | * | arecaceae quit (Read error: Connection reset by peer) |
08:39:42 | * | arecaceae joined #nim |
08:47:04 | saem | CPS is bonkers if you're actually programming that by hand, it'd be like hand IR/some heavily desugared code. |
08:47:45 | saem | Anyways I'm curious what folks make of the CPS library. |
08:51:41 | FromDiscord | <flywind> `nim-cps` lacks event loop support for windows and it doesn't seems to support multi-threads scheduler? |
08:53:08 | saem | That's more a matter of writing those than an impossibility. |
08:54:41 | saem | Feature gaps aren't a big deal, I'm more curious about the gaps in understanding concepts, trying to use it for initial cases, writing a basic scheduler, etc. |
08:59:37 | FromDiscord | <ElegantBeef> Well if you need me to i can always give it a whirl to see what i can actually grasp and then complain about |
09:02:14 | ForumUpdaterBot | New thread by Alexeypetrushin: The `db_postgres` can't execute multiple queries, possible bug?, see https://forum.nim-lang.org/t/7804 |
09:04:05 | saem | @ElegantBeef: that sounds good. |
09:40:26 | * | NimBot joined #nim |
09:42:34 | * | Vladar quit (Quit: Leaving) |
09:53:05 | PMunch | @Araq, are you around? I was wondering if there is a way to force the code generation for emit to be an inline object and not just an assignment from an object generated elsewhere? |
10:01:39 | * | natrys joined #nim |
10:08:38 | * | wasted_youth2 quit (Quit: Leaving) |
10:17:38 | * | audiophile joined #nim |
10:20:56 | * | clyybber joined #nim |
10:38:40 | * | wasted_youth2 joined #nim |
10:49:42 | * | Vladar joined #nim |
11:45:19 | * | lritter joined #nim |
11:47:41 | * | natrys quit (Ping timeout: 240 seconds) |
12:01:07 | * | natrys joined #nim |
12:10:11 | * | natrys quit (Ping timeout: 240 seconds) |
12:16:40 | ForumUpdaterBot | New thread by Acroobat: Any valuable linux project to join?, see https://forum.nim-lang.org/t/7805 |
12:25:33 | * | natrys joined #nim |
12:26:41 | * | tefter joined #nim |
12:49:52 | Clonkk[m] | In case anybody is interested, I have a file which when I edit it cause nimsuggest (and neovim but I assume the former cause the latter) to take 110% CPU |
12:50:37 | Prestige | Are you using nimlsp? |
12:51:15 | Clonkk[m] | nimlsp and alaviss plugins for neovim |
12:51:55 | Prestige | It's a nimlsp issue - PMunch we should remove the chk we talked about last week ^ |
12:52:30 | PMunch | Oh yeah, that should definitely be moved |
12:52:37 | Prestige | https://github.com/PMunch/nimlsp/blob/master/src/nimlsp.nim#L506 |
12:52:52 | Prestige | probably can just remove it from this case |
12:54:54 | * | tane joined #nim |
12:55:18 | * | sacredfrog quit (Quit: ZNC 1.8.2 - https://znc.in) |
12:55:51 | * | sacredfrog joined #nim |
13:36:45 | PMunch | Prestige, there, done |
13:36:58 | PMunch | Seems to work as well, in my very limited test |
13:42:40 | * | rockcavera joined #nim |
13:43:16 | PMunch | I moved it into didSave, which is where the other diagnostics stuff is |
13:43:45 | PMunch | But Clonkk[m], nimsuggest (the library that nimlsp uses) is known to sometimes peg your CPU or consume all your memory |
13:43:50 | PMunch | So YMMV |
13:44:50 | Clonkk[m] | <PMunch "But Clonkk, nimsuggest (the libr"> So I've heard. That's why I wasn't sure if it was related to the ``chk`` issue since the other issue I openened last week was infact linked to syntax highlighting |
13:45:34 | Clonkk[m] | I'll test again with 0.3.2 |
13:47:39 | * | krux02 joined #nim |
13:56:32 | Clonkk[m] | I don't think that was the problem. I still have the issue ๐ |
13:59:33 | PMunch | Do you have a file or project I can replicate it with? |
14:00:03 | Clonkk[m] | It happens after opening https://github.com/Clonkk/flambeau/blob/feat_generic_tensor/flambeau/tensors.nim |
14:00:29 | Clonkk[m] | Few seconds later nimsuggest and nvim both go to 100% CPU |
14:02:13 | * | Clonkk[m] < https://matrix.org/_matrix/media/r0/download/matrix.org/ehuKCCYdUpgtGrddFBtCISjT/message.txt > |
14:02:29 | Clonkk[m] | (not sure if it's useful since I don't know what it means) |
14:02:59 | PMunch | does it just spam that? |
14:05:23 | PMunch | Oops, gotta go |
14:05:24 | * | PMunch quit (Quit: leaving) |
14:05:49 | Clonkk[m] | No worries ๐ thatnks for the help - it might not even be linked to nimlsp |
14:17:23 | FromDiscord | <mlokis> can i manipulate with seq len and cap on unsafe level?, i would like to implements go-like slicing, (will see if that's a good idea) |
14:17:55 | FromDiscord | <Rika> Look into the experimental views in the experimental manual |
14:31:32 | FromDiscord | <exelotl> (are they less broken now?) ๐ |
14:37:18 | * | filcuc joined #nim |
14:37:57 | * | natrys quit (Quit: natrys) |
14:38:00 | filcuc | are global objects default allocated in a shared heap? |
14:38:44 | FromDiscord | <mlokis> does seq act as pointer of is it copied when moving it around scopes? |
14:39:05 | FromDiscord | <mlokis> i mean the content of seq |
14:39:55 | liblq-dev | the content is copied, but if the compiler is able to deduce that this is the last place where a copy would normally occur, it'll perform what's called a move |
14:40:06 | liblq-dev | which essentially means, the data in the seq won't be copied |
14:40:28 | FromDiscord | <mlokis> so i should pass `ref seq[]` |
14:40:33 | liblq-dev | no |
14:40:36 | liblq-dev | do not use ref seq[T] |
14:40:54 | liblq-dev | use var seq[T] instead |
14:40:55 | FromDiscord | <mlokis> i mean should i pass seq by reference |
14:41:13 | liblq-dev | `ref` does not mean reference |
14:41:24 | FromDiscord | <mlokis> if i want to retrun is from func |
14:41:26 | liblq-dev | `ref` is what nimions call a "managed pointer" |
14:41:35 | FromDiscord | <mlokis> (edit) "retrun" => "return" |
14:41:38 | liblq-dev | which basically means "GC'd" |
14:41:57 | liblq-dev | if you wanna return a seq from a proc you just use `seq[T]` regularly |
14:42:21 | FromDiscord | <mlokis> it will not get copied? |
14:42:26 | liblq-dev | no |
14:42:42 | liblq-dev | returning a value from a procedure always moves the value |
14:42:55 | * | natrys joined #nim |
14:43:03 | FromDiscord | <mlokis> even if it is getter? |
14:43:14 | liblq-dev | hmm |
14:43:19 | liblq-dev | that's a more difficult question |
14:43:40 | liblq-dev | if you don't assign the resulting seq to a `var`, then yes |
14:44:03 | liblq-dev | it'll store a pointer to that seq without copying the data |
14:44:23 | FromDiscord | <Hi02Hi> isnt there lent to help with this? |
14:44:45 | liblq-dev | there is |
14:44:55 | FromDiscord | <Hi02Hi> https://nim-lang.org/docs/destructors.html#lent-typeโต"To eliminate even more creation/copy <-> destruction pairs, a proc's return type can be annotated as lent T. This is useful for "getter" accessors that seek to allow an immutable view into a container." |
14:45:24 | saem | Clonkk[m]: when nimsuggest went to space, which part of that file precisely were you editing? |
14:46:02 | FromDiscord | <mlokis> but i mean, now that i returned seq, the caller can read the content and mutate it but cannot change size, else the seq would get copied to new container, em i right? |
14:46:41 | liblq-dev | the caller can only mutate the content of the seq if they assign it to a `var` |
14:46:44 | FromDiscord | <Rika> Can change size if capacity allows |
14:46:49 | liblq-dev | in which case a copy is made |
14:46:52 | FromDiscord | <Rika> And that yes |
14:47:09 | FromDiscord | <Rika> Can var stuff be returned now? |
14:47:10 | FromDiscord | <mlokis> In reply to @Rika "Can change size if": forget about cap |
14:47:18 | liblq-dev | unless you return `var` or `lent`, which will return a mutable or immutable handle respectively to your original seq |
14:47:26 | FromDiscord | <mlokis> (edit) "forget" => "forgot" |
14:47:48 | FromDiscord | <mlokis> nice so i can use var in return value |
14:47:49 | liblq-dev | @Rika i think it could always be returned, just that with view types it became more "common" or something |
14:47:59 | FromDiscord | <Rika> I see |
14:48:16 | FromDiscord | <mlokis> tx |
14:48:38 | liblq-dev | i think what view types introduce is storing that returned var/lent somewhere |
14:48:50 | liblq-dev | instead of only being able to use it immediately |
14:49:07 | FromDiscord | <Rika> Huh |
14:50:33 | FromDiscord | <mlokis> sent a code paste, see https://play.nim-lang.org/#ix=2Wiv |
14:50:41 | * | idf quit (Ping timeout: 240 seconds) |
14:51:26 | FromDiscord | <mlokis> (edit) "https://play.nim-lang.org/#ix=2Wiv" => "https://play.nim-lang.org/#ix=2Wiw" |
14:51:37 | * | tiorock joined #nim |
14:51:38 | * | tiorock quit (Changing host) |
14:51:38 | * | tiorock joined #nim |
14:51:38 | * | rockcavera is now known as Guest40911 |
14:51:38 | * | Guest40911 quit (Killed (tepper.freenode.net (Nickname regained by services))) |
14:51:38 | * | tiorock is now known as rockcavera |
14:52:24 | FromDiscord | <mlokis> (edit) "https://play.nim-lang.org/#ix=2Wiw" => "https://play.nim-lang.org/#ix=2Wiy" |
14:57:55 | FromDiscord | <mlokis> we probably dont have any tool that formats the code |
14:58:03 | * | idf joined #nim |
14:58:25 | FromDiscord | <Rika> Nimpretty |
14:59:12 | * | vicfred joined #nim |
14:59:47 | FromDiscord | <mlokis> is it command line thing? |
15:01:14 | * | azed joined #nim |
15:01:43 | * | kuon joined #nim |
15:02:11 | FromDiscord | <Rika> Yes |
15:16:00 | * | def- quit (Quit: -) |
15:17:16 | * | def- joined #nim |
15:18:11 | * | azed quit (Quit: WeeChat 3.1) |
15:21:40 | FromGitter | <HJarausch> How to create a pull request? โ I have clone nim into github/HJarausch/Median. There I have modified some files. How can I create a pull request now? โ Many thanks for a hint, โ Helmut [https://gitter.im/nim-lang/Nim?at=6079ab8481866c680c295f46] |
15:35:57 | filcuc | are global objects default allocated in a shared heap? |
15:44:04 | Clonkk[m] | <saem "Clonkk: when nimsuggest went to "> Sorry I just saw your message. Not a specifically part; it happens ~1 seconds after I opened the file. Usually I'm at the beginning of the file |
16:10:47 | * | tefter_ joined #nim |
16:12:41 | FromDiscord | <jtiai> I have code <https://play.nim-lang.org/#ix=2Wj5> and as seen in the code, I just try to store value to `Memory.data[0]` and read it back. But why I do get 0 instead of 42? |
16:12:50 | FromDiscord | <mlokis> is here a test coverage tool for nim? |
16:13:46 | * | tefter quit (Ping timeout: 252 seconds) |
16:21:06 | * | justsomeguy quit (Ping timeout: 240 seconds) |
16:24:42 | * | tefter_ is now known as tefter |
16:31:27 | FromDiscord | <demotomohiro> @jtiai |
16:31:29 | FromDiscord | <demotomohiro> Range chack in your code should be `m.startAddr <= memaddr and m.endAddr >= memaddr`. |
16:36:18 | liblq-dev | that's a weird way to do a range check |
16:36:28 | liblq-dev | why not just memaddr in m.startAddr .. m.endAddr? |
16:37:55 | liblq-dev | or at least switch the sides of the comparisons so that it's more clear what you're comparing to |
16:41:37 | FromDiscord | <jtiai> Well didn't know better way. |
16:41:49 | * | junland quit (Quit: %ZNC Disconnected%) |
16:42:53 | * | junland joined #nim |
16:44:26 | FromDiscord | <jtiai> that apparently fixed it... |
16:58:55 | * | justsomeguy joined #nim |
17:11:19 | * | justsomeguy left #nim ("WeeChat 3.0.1") |
17:19:30 | FromDiscord | <Goel> @mlokis Like this? https://github.com/status-im/nim-testutils |
17:33:09 | reversem3 | Do you guys think nim will ever have a programming structure ? like when to do use types , generics, templates, macros. Nim isn't an oop language so ..... |
17:33:40 | FromDiscord | <Solitude> what? |
17:34:12 | * | hyiltiz quit (Ping timeout: 240 seconds) |
17:36:29 | FromDiscord | <jtiai> Apparently some people never heard of prototype based programming... |
17:37:19 | * | hyiltiz joined #nim |
17:39:24 | FromDiscord | <Yardanico> Apparently some people never heard of some_trendy_buzzword-based programming... |
17:39:48 | * | audiophile_ joined #nim |
17:40:10 | FromDiscord | <jtiai> prototype based is quite old. |
17:40:57 | FromDiscord | <Solitude> i prefer write-stuff based programming |
17:41:03 | FromDiscord | <Yardanico> nice |
17:42:11 | FromDiscord | <haxscramper> In reply to @reversem3 "Do you guys think": "When to use ..." - just start with a proc + struct (object) and add stuff as needed |
17:43:17 | * | audiophile quit (Ping timeout: 260 seconds) |
17:43:21 | reversem3 | Yeah thats what I have been doing , but really want to get into meta programming , its like magic lol |
17:43:25 | * | audiophile_ is now known as audiophile |
17:43:56 | reversem3 | Anyway I was just curious , kind of new the answer already |
17:44:02 | reversem3 | * Anyway I was just curious , kind of knew the answer already |
17:44:18 | FromDiscord | <Yardanico> metaprogramming is not really a separate "programming structure" |
17:44:56 | reversem3 | what I mean is paradigm (I guess would be a better term) |
17:45:20 | FromDiscord | <haxscramper> There is no paradigm to metaprogramming, though there are a couple books on DSL construction |
17:45:23 | FromDiscord | <haxscramper> But that is not really necessar |
17:45:46 | FromDiscord | <haxscramper> Usually that is exactly "write-stuff based programming" as solitude just mentioned |
17:45:49 | FromDiscord | <haxscramper> Identify a problem that can't elegantly solved by simple code and write a macro for that |
17:46:04 | reversem3 | ahh ok |
17:46:22 | FromDiscord | <haxscramper> https://nim-lang.org/blog/2021/03/10/fusion-and-pattern-matching.html explains how you can approach writing more complex macros |
17:46:41 | reversem3 | very cool thanks |
17:47:09 | FromDiscord | <haxscramper> If you need some rules/directions it would probably be "Use macros for DSL, not for sugar" |
17:47:20 | FromDiscord | <haxscramper> "When in doubt add IR" |
17:47:36 | reversem3 | IR ? |
17:48:03 | FromDiscord | <haxscramper> Intermediate representation. Though this one is only applicable when you have macro of certain complexity and not sure how to deal with all DSL features in a nice way |
17:48:28 | FromDiscord | <haxscramper> You can basically ignore it for the most part, especially when starting writing macro |
17:49:54 | FromDiscord | <haxscramper> Though the question of "how do I get into metaprogramming" is actually kind of important, because not a lot of languages make such big accent on that, so it might be a good idea to come up with a more comprehensive response than just "write-stuff" |
17:51:25 | FromDiscord | <haxscramper> Like a bridge between the states of "I know macros are cool"+"I have a problem" and "To solve my problem using macros I would have to do this and that" |
17:55:16 | FromDiscord | <whisperdev> How can one tell if a Nim program is using ARC or ORC? |
17:55:36 | FromDiscord | <Yardanico> if you just want to check for either of them |
17:55:42 | FromDiscord | <Yardanico> when defined(gcDestructors) |
17:56:28 | FromDiscord | <Yardanico> for different ones specifically you can use compileOption from system or gcArc and gcOrc (but afaik the first one is preferred |
17:56:35 | FromDiscord | <Yardanico> e.g. when compileOption("gc", "arc"): do stuff |
17:56:46 | FromDiscord | <Yardanico> like https://github.com/Yardanico/nim-snippets/blob/master/interdetails.nim |
17:58:54 | FromDiscord | <whisperdev> What I mean is when I have a binary ๐ |
17:59:11 | FromDiscord | <Yardanico> well, then you use some reverse engineering tool |
17:59:23 | FromDiscord | <Yardanico> if you find any references to eqsink, eqcopy, eqdestroy - it's arc or orc |
17:59:42 | FromDiscord | <Yardanico> what's your usecase btw? |
18:00:08 | FromDiscord | <whisperdev> no use case just curious |
18:00:09 | FromDiscord | <whisperdev> but i see |
18:00:45 | FromDiscord | <whisperdev> But wait.If I just nimble install this: https://github.com/fox0430/moe/blob/develop/moe.nimble |
18:00:50 | FromDiscord | <whisperdev> This is not using arc... |
18:01:00 | FromDiscord | <Yardanico> of course? |
18:01:05 | FromDiscord | <Solitude> arc isnt default |
18:01:15 | FromDiscord | <whisperdev> In reply to @Yardanico "if you find any": I was grep-ing for those and saw them... |
18:01:39 | FromDiscord | <Yardanico> how were you greping for them? |
18:01:59 | FromDiscord | <whisperdev> strings moe | grep eqcopy |
18:02:48 | FromDiscord | <Solitude> In reply to @whisperdev "This is not using": it is using orc |
18:02:54 | FromDiscord | <Solitude> https://github.com/fox0430/moe/blob/develop/src/moe.nim.cfg#L4 |
18:03:07 | FromDiscord | <Yardanico> kek |
18:03:13 | FromDiscord | <whisperdev> great |
18:13:28 | FromDiscord | <Alea> is there anyway to make an array containing different types? |
18:13:46 | FromDiscord | <haxscramper> You can use variant objects |
18:14:19 | FromDiscord | <haxscramper> https://nim-lang.org/docs/manual.html#types-object-variants |
18:14:33 | FromDiscord | <Yardanico> In reply to @Alea "is there anyway to": yeah, as haxscramper said, but generally you really rarely need to store "different types" in containers |
18:14:35 | FromDiscord | <haxscramper> And wrap different types in different branches |
18:14:48 | FromDiscord | <Yardanico> usually people who come from python to nim try to adapt their python knowledge to nim directly |
18:14:55 | FromDiscord | <Yardanico> regarding different types in lists, etcv |
18:14:56 | FromDiscord | <Yardanico> (edit) "etcv" => "etc" |
18:15:08 | FromDiscord | <Alea> I'm coming from C, so I was thinking an array of pointers |
18:15:24 | FromDiscord | <haxscramper> you can do type erasure via pointers of course |
18:15:27 | FromDiscord | <Yardanico> then again, you don't do that in Nim usually :) |
18:16:41 | FromDiscord | <Alea> it really confuses me how people making games keep track of so many different objectsโตthey all have different types, and yet are kept in one central list |
18:16:56 | FromDiscord | <Yardanico> they probably have one base type |
18:17:03 | FromDiscord | <Yardanico> or just nim object variants :) |
18:18:41 | FromDiscord | <haxscramper> Though nim variant objects are only really suitable when you have a closed object hierarchy that is not intended to be expanded by the user. You can do `ref of RootObj` and `case kind` at the same time though |
18:23:47 | reversem3 | <FromDiscord "<Yardanico> well, then you use s"> As far as I have seen when you reverse engineer a nim binary that header sticks out like a sore thumb |
18:24:09 | reversem3 | everything I have compiled so far has the same header information |
18:24:45 | reversem3 | just use R2 or radare2 |
18:25:00 | FromDiscord | <Yardanico> what header |
18:25:23 | FromDiscord | <Yardanico> I know about r2, ghidra and similar, but not sure what header you're talking about, I know about NimMain and friends, but again, we were talking about ARC/ORC specifically |
18:28:32 | * | beshr quit (Ping timeout: 240 seconds) |
18:29:19 | * | beshr joined #nim |
18:47:46 | * | filcuc quit (Quit: KVIrc 5.0.0 Aria http://www.kvirc.net/) |
18:50:33 | * | liblq-dev left #nim ("User left") |
18:57:47 | * | lritter quit (Ping timeout: 246 seconds) |
19:07:39 | ForumUpdaterBot | New thread by Mantielero: An easy way of displaying video?, see https://forum.nim-lang.org/t/7806 |
19:14:21 | FromDiscord | <mlokis> can i somehow restrict generic argument to things with witch you can index into collection? |
19:14:46 | * | D_ quit (Ping timeout: 258 seconds) |
19:15:23 | FromDiscord | <Yardanico> @mlokis you mean things that have an array subscript operator? |
19:15:29 | FromDiscord | <Yardanico> you can use concepts |
19:16:06 | FromDiscord | <mlokis> In reply to @Yardanico "you can use concepts": but how? |
19:16:12 | FromDiscord | <Yardanico> just use them 4HEad |
19:16:24 | FromDiscord | <Yardanico> https://nim-lang.org/docs/manual_experimental.html#concepts |
19:16:56 | FromDiscord | <madman> do concepts work well with arc/orc |
19:18:52 | FromDiscord | <Yardanico> concepts are not related to arc/orc at all |
19:18:56 | FromDiscord | <Yardanico> so yes, they do work fine with arc/orc |
19:19:02 | FromDiscord | <Yardanico> what |
19:19:03 | FromDiscord | <mlokis> sent a code paste, see https://play.nim-lang.org/#ix=2WjZ |
19:19:17 | FromDiscord | <Yardanico> oh, so you want something that can index an existing sequence? |
19:19:20 | FromDiscord | <mlokis> (edit) "https://play.nim-lang.org/#ix=2WjZ" => "https://play.nim-lang.org/#ix=2Wk0" |
19:19:31 | FromDiscord | <mlokis> yes this works |
19:19:35 | FromDiscord | <Yardanico> you don't need a concept for that, only ints can index sequences anyway |
19:19:40 | FromDiscord | <Yardanico> or other things that convert to int |
19:19:44 | FromDiscord | <Yardanico> with converters |
19:20:29 | FromDiscord | <mlokis> but i need that nice error when someone tries string as id |
19:26:57 | FromDiscord | <Yardanico> In reply to @mlokis "but i need that": they'll just get a type mismatch |
19:31:47 | FromDiscord | <JSONBash> out of curiosity is there a way to manually mark a cyclic type so that you can use arc? or will libraries like asyncdispatch always be orc? |
19:35:02 | FromDiscord | <Yardanico> In reply to @JSONBash "out of curiosity is": wdym "mark a cyclic type"? |
19:35:10 | FromDiscord | <Yardanico> ARC does not prevent you from compiling the code that has cycles |
19:35:11 | FromDiscord | <Yardanico> it'll just leak |
19:35:13 | FromDiscord | <Yardanico> (edit) "it'll just leak ... " added "memory" |
19:35:46 | FromDiscord | <haxscramper> Unless you use non-traced reference via `{.cursor.}` or raw ptr? |
19:35:50 | FromDiscord | <haxscramper> (edit) "ptr?" => "ptr?" |
19:36:00 | FromDiscord | <Yardanico> well, that's not really related imo :P |
19:36:13 | FromDiscord | <Yardanico> At max ARC will emit a warning if it sees that some code absolutely forms a cycle, but ORC exists because only the simplest of cases can be detected at compile-time |
19:36:31 | FromDiscord | <Yardanico> but I don't think that you should use asyncdispatch with ARC anyway, it'll leak quite a lot of memory |
19:37:21 | FromDiscord | <JSONBash> my real question is will programs that use ARC ever be able to manaully tuned to use ORC? or if there is a cycle is has to use ORC? |
19:37:34 | FromDiscord | <Yardanico> still, not sure what do you mean |
19:37:47 | FromDiscord | <Yardanico> ARC/ORC are interchangeable, ORC is just ARC + a cycle collector |
19:38:13 | FromDiscord | <Yardanico> if you have code that forms a cycle at runtime, ARC will at max just leak memory, while ORC will be able to collect that cycle |
19:38:30 | FromDiscord | <Yardanico> And if you mean if you can enable/disable the ORC step at runtime, then yes, you can |
19:38:39 | FromDiscord | <JSONBash> as far as i uderstand the cycle collector makes it soft realtime, but arc can be used for hard realtime? unless i understand that wrong |
19:39:00 | FromDiscord | <Yardanico> that's because ORC has to collect cycles |
19:39:11 | FromDiscord | <Yardanico> we have GC_runOrc/GC_enableOrc/GC_disableOrc |
19:39:17 | FromDiscord | <JSONBash> so if i have cycles, i can only ever have soft realtime |
19:39:27 | FromDiscord | <Yardanico> no, you can have hard realtime and leak memory |
19:39:50 | FromDiscord | <JSONBash> yeah point taken ahha |
19:40:00 | FromDiscord | <JSONBash> what if i dont want memory leaks? |
19:40:07 | FromDiscord | <JSONBash> am i SOL? |
19:40:22 | FromDiscord | <JSONBash> (i dont have a use case just curious) |
19:40:25 | FromDiscord | <Yardanico> again, you can only run ORC when you want to |
19:40:28 | FromDiscord | <Yardanico> https://github.com/nim-lang/Nim/blob/devel/lib/system/orc.nim#L405 |
19:40:37 | FromDiscord | <Yardanico> three Orc procs here |
19:40:44 | FromDiscord | <Yardanico> actually more |
19:43:12 | FromDiscord | <JSONBash> so if i have cycles my only options are: a) have orc collect cycles to which i can control when that happens if i choose to b) leak memory if i dont want to run orc cycle collection |
19:43:46 | FromDiscord | <Yardanico> and yeah, in this case haxscramper's advice is correct too - you can mark fields/variables with {.cursor.} which is unsafe, but if you know what you're doing you can avoid cycles |
19:43:50 | FromDiscord | <JSONBash> and if i choose b is there anyway to manually 'free' the cycle memory? |
19:44:12 | FromDiscord | <JSONBash> okay that seems like a pretty reasonable solution |
19:44:14 | FromDiscord | <Yardanico> cursor is an annotation which makes the compiler to not increase the refcount |
19:44:21 | FromDiscord | <JSONBash> and to be clear, i don't know what I am doing lol |
19:44:24 | FromDiscord | <Yardanico> https://nim-lang.org/docs/destructors.html#the-dotcursor-annotation |
19:45:55 | FromDiscord | <JSONBash> oh okay I see |
19:46:38 | FromDiscord | <JSONBash> i dont fully understand how I would use cursor, but there is a way to avoid cycle data structures if i know what im doing |
19:46:43 | FromDiscord | <JSONBash> ? |
19:48:16 | FromDiscord | <Yardanico> it always depends on your usecase |
19:49:36 | FromDiscord | <haxscramper> My use case is `ref` object tree that sometimes might have reference to other elements (potentially forming a cycle) that I would eventually wrap as a C/C++ library, so I would prefer to make it fully ARC-compliant |
19:50:22 | FromDiscord | <haxscramper> I asked basically the same question and advised to use `{.cursor.}`, which seems exactly what I would need in this case |
19:52:45 | FromDiscord | <JSONBash> sweet, thank you both for the help ๐ |
19:58:42 | * | konradmb[m] joined #nim |
20:06:31 | FromDiscord | <ellliottt> hi, just started using nim. how would i implement a stack? |
20:07:15 | FromDiscord | <ellliottt> im guessing an array plus some accessor functions, but is there a more idiomatic way> |
20:07:16 | FromDiscord | <ellliottt> (edit) "way>" => "way?" |
20:07:54 | FromDiscord | <Yardanico> In reply to @ellliottt "hi, just started using": just a seq will work |
20:08:18 | FromDiscord | <Yardanico> since seqs have a `pop` proc |
20:08:29 | FromDiscord | <Yardanico> there are also deques https://nim-lang.org/docs/deques.html |
20:09:33 | FromDiscord | <ellliottt> oh nice, thankyou :) |
20:11:01 | FromDiscord | <ellliottt> maybe a stupid question, where do i find the docs for builtin types like `seq`? |
20:12:06 | FromDiscord | <Yardanico> In reply to @ellliottt "maybe a stupid question,": https://nim-lang.org/docs/system.html |
20:13:00 | FromDiscord | <ellliottt> ahh the name `system` confused me. thanks! |
20:13:13 | FromDiscord | <Yardanico> @ellliottt system is the module that is always imported |
20:13:17 | FromDiscord | <Yardanico> in all nim files |
20:13:52 | FromDiscord | <Yardanico> it's also worth checking https://nim-lang.org/documentation.html |
20:13:59 | FromDiscord | <Yardanico> e.g. https://narimiran.github.io/nim-basics/ |
20:14:33 | FromDiscord | <ellliottt> yeah i read through the introduction tutorial, going to try writing some stuff now :) |
20:14:43 | FromDiscord | <Yardanico> well, there are a lot of other tutorials except that one :) |
20:15:18 | FromDiscord | <ellliottt> tbh i feel somewhat comfortable already, ive used python/haskell/c and nim feels like its right in the middle of all of them |
20:15:28 | FromDiscord | <ellliottt> so im going to try and just jump in and try some stuff |
20:15:38 | FromDiscord | <ellliottt> if i get overwhelmed ill try some of the guides, thankyou :) |
20:19:17 | * | happycorsair[m] joined #nim |
20:19:37 | FromDiscord | <j-james> If you're looking for quick-and-dirty examples, I really like https://nim-by-example.github.io/ |
20:20:16 | * | beshr quit (Remote host closed the connection) |
20:21:10 | FromDiscord | <Yardanico> oh, maybe I should a PR to here, change some small things |
20:25:47 | ForumUpdaterBot | New thread by Quokka70: Global array access can have side effects?, see https://forum.nim-lang.org/t/7807 |
20:34:48 | FromDiscord | <ellliottt> sent a code paste, see https://play.nim-lang.org/#ix=2Wkl |
20:34:54 | FromDiscord | <ellliottt> (edit) "https://play.nim-lang.org/#ix=2Wkl" => "https://play.nim-lang.org/#ix=2Wkm" |
20:35:07 | FromDiscord | <Yardanico> nim strings don't have a specific encoding, they're just a sequence of chars |
20:35:13 | FromDiscord | <Yardanico> to treat strings as unicode there's a unicode module |
20:35:18 | FromDiscord | <Yardanico> https://nim-lang.org/docs/unicode.html |
20:35:41 | FromDiscord | <Yardanico> e.,g. for your second line you need echo "โ".runeAt(0) |
20:36:24 | FromDiscord | <Yardanico> and your third line is incorrect - to get a sequence of runes from a string you use toRunes |
20:36:34 | FromDiscord | <Yardanico> so echo "โ".toRunes()[0] |
20:37:11 | FromDiscord | <ellliottt> ah i see |
20:37:14 | FromDiscord | <ellliottt> thanks :) |
20:37:26 | FromDiscord | <dk> `Rune()` is a dumb type converter |
20:37:49 | FromDiscord | <ellliottt> is it more efficient to just store a `seq[Rune]` rather than a `string` then |
20:38:18 | FromDiscord | <Yardanico> not really |
20:38:32 | FromDiscord | <Yardanico> but if you need to do a lot of unicode operations on a string, then it's more efficient I guess |
20:38:37 | FromDiscord | <Yardanico> but just to store string is better |
20:39:05 | FromDiscord | <ellliottt> if your string contains unicode data then you need to convert it to a `seq[Rune]` to do anything to it |
20:39:11 | FromDiscord | <Yardanico> not neccessarily |
20:39:22 | FromDiscord | <dk> there's also an iterator |
20:39:38 | FromDiscord | <Yardanico> but anyway, `Rune` is internally represented as an `int32` so it's less efficient, especially if your string is mainly ASCII |
20:39:53 | FromDiscord | <Yardanico> then each ascii char will be represented as 4 bytes instead of one |
20:41:57 | FromDiscord | <ellliottt> ok i misunderstood that |
20:42:24 | FromDiscord | <ellliottt> so just `.runeAt` to get a rune, but store it as a string for space efficiency |
20:42:43 | FromDiscord | <Yardanico> depends on how often you need to do some specific operations on it as a unicode string |
20:43:32 | FromDiscord | <Yardanico> @ellliottt ah right sorry, runeAt isn't really what you want |
20:43:50 | FromDiscord | <Yardanico> it's better to use the iterators from the unicode module |
20:44:16 | FromDiscord | <Yardanico> since runeAt returns the unicode rune at the byte index |
20:44:30 | FromDiscord | <Yardanico> also there are a lot of procs in the unicode module that take a string and return a string |
20:44:37 | FromDiscord | <Yardanico> but internally they do specific unicode operations |
20:44:42 | FromDiscord | <Yardanico> like https://nim-lang.org/docs/unicode.html#swapCase%2Cstring |
20:44:51 | FromDiscord | <ellliottt> ah ok |
20:45:06 | FromDiscord | <ellliottt> so `for ch in runes(some_string) ...` |
20:45:36 | FromDiscord | <Yardanico> yeah |
20:49:54 | FromDiscord | <Yardanico> actually, looking at nim by example again, I wonder if we can use https://github.com/pietroppeter/nimib for it |
20:50:06 | FromDiscord | <Yardanico> I know, rewriting is wasting time, but it's much more suited for Nim specifically :P |
20:52:25 | FromDiscord | <ellliottt> sorry for more questions. are iterators first class, or can they only be used in a `for` loop? |
20:52:37 | FromDiscord | <ellliottt> (edit) "iterators" => "iterator instances" |
20:52:40 | FromDiscord | <Yardanico> by default iterators are inlined |
20:52:46 | FromDiscord | <Yardanico> but there are closure iterators that are "first class" |
20:52:51 | FromDiscord | <Yardanico> they can be passed around, etc |
20:52:55 | FromDiscord | <ellliottt> oh nice |
20:53:04 | FromDiscord | <Yardanico> https://nim-by-example.github.io/for_iterators/ :P |
20:53:15 | FromDiscord | <ellliottt> thanks :P |
21:05:04 | * | vicfred_ joined #nim |
21:06:16 | * | vicfred quit (Read error: Connection reset by peer) |
21:13:40 | * | Vladar quit (Quit: Leaving) |
21:19:12 | FromDiscord | <ellliottt> sent a code paste, see https://play.nim-lang.org/#ix=2Wkz |
21:21:08 | FromDiscord | <Yardanico> raise (ref Exception)(someData: 5) |
21:21:12 | FromDiscord | <Yardanico> (edit) "Exception)(someData:" => "MyException)(someData:" |
21:22:31 | FromDiscord | <ellliottt> whats going on there? |
21:22:41 | FromDiscord | <ellliottt> why can you call a ref? |
21:22:48 | FromDiscord | <Yardanico> this is object construction syntax |
21:22:56 | FromDiscord | <Yardanico> `raise` only can raise refs |
21:23:07 | FromDiscord | <Yardanico> so you construct a new ref MyException with someData equal to 5 |
21:23:21 | FromDiscord | <Yardanico> you can of course have MyException be "ref object of Exception" and then can raise it with just raise MyException(someData: 5) |
21:23:31 | FromDiscord | <ellliottt> ahh that makes sense |
21:23:32 | FromDiscord | <ellliottt> thanks |
21:24:20 | FromDiscord | <ellliottt> so in that case the default behavior of `Exception` taking a string message is overwritten s |
21:24:21 | FromDiscord | <ellliottt> (edit) removed "s" |
21:24:27 | FromDiscord | <ellliottt> so i need my own `msg` field |
21:28:42 | FromDiscord | <dk> In reply to @ellliottt "so i need my": there is already such a field https://github.com/nim-lang/Nim/blob/devel/lib/system/exceptions.nim#L34 |
21:29:32 | FromDiscord | <ellliottt> oh so it inherets the field from `Exception` |
21:29:37 | FromDiscord | <dk> but really, what's the points of providing anything more than a message |
21:30:02 | FromDiscord | <ellliottt> In reply to @dk "but really, what's the": in this case im parsing some text, and i want to return the current state of the parser along with a message |
21:30:17 | FromDiscord | <ellliottt> so that the message can be formatted later |
21:30:27 | FromDiscord | <ellliottt> (edit) "so that the message can be formatted later ... " added "with info from the state" |
21:52:20 | * | MightyJoe quit (Quit: I'm out!) |
21:54:57 | * | cyraxjoe joined #nim |
21:58:10 | FromDiscord | <Yardanico> Apparently now github activity shows new releases of the repos you starred |
21:58:17 | FromDiscord | <Yardanico> (even if you don't watch them) |
21:58:37 | FromDiscord | <Yardanico> https://media.discordapp.net/attachments/371759389889003532/832736765335961660/unknown.png |
22:18:02 | * | Jesin quit (Quit: Leaving) |
22:21:15 | * | tane quit (Quit: Leaving) |
22:21:47 | * | D_ joined #nim |
22:38:30 | * | Jesin joined #nim |
22:39:05 | FromDiscord | <clyybber> In reply to @Yardanico "Apparently now github activity": I think theres a seperate watch feature for that; something like "watch for releases" |
22:39:08 | FromDiscord | <clyybber> maybe you enabled that? |
22:39:12 | FromDiscord | <Yardanico> no, I double-checked |
22:39:31 | FromDiscord | <Yardanico> for ytdl I have this one (it's the default) https://media.discordapp.net/attachments/371759389889003532/832747056446963754/unknown.png |
22:39:41 | FromDiscord | <Yardanico> same for https://github.com/Celludriel/X4_Universe_Generation_Tool which I don't even remember that I starred :P |
22:39:44 | FromDiscord | <Yardanico> (but I sure did) |
22:40:44 | FromDiscord | <clyybber> oh, cool |
22:41:13 | FromDiscord | <Yardanico> didn't find it in their changelog so I'm a bit confused |
22:45:34 | FromDiscord | <ellliottt> sorry for asking so many questions ๐
can i get `runes(str)` as a closure iterator? or is there a difference in how they are defined? |
22:47:14 | FromDiscord | <dk> I guess you can wrap the inline iterator in a new closure iterator, but that would suck |
22:47:45 | FromDiscord | <dk> people generally don't use closure iterators I think |
22:48:23 | FromDiscord | <ellliottt> In reply to @dk "I guess you can": how would that work, and why would it be bad? |
22:48:37 | FromDiscord | <Yardanico> In reply to @ellliottt "how would that work,": it would be bad because it means worse performance |
22:48:40 | FromDiscord | <ellliottt> or do you mean make a new iterator that does `for ..` |
22:48:41 | FromDiscord | <Yardanico> why do you want to wrap it in a closure iterator? |
22:48:42 | FromDiscord | <ellliottt> (edit) "..`" => "... yield`" |
22:49:19 | FromDiscord | <ellliottt> im parsing some text so i want to read a file one rune at a time |
22:49:30 | FromDiscord | <Yardanico> you usually use a while loop for that |
22:49:51 | FromDiscord | <ellliottt> but im writing a parser, so it cant be contained in a while loop |
22:49:59 | FromDiscord | <ellliottt> i want my parser state to store the iterator/stream |
22:50:00 | FromDiscord | <Yardanico> it can, why not? |
22:50:06 | FromDiscord | <ellliottt> recursive functions |
22:50:21 | FromDiscord | <ellliottt> i guess it could be a loop but it would be horrible to write |
22:50:33 | FromDiscord | <Yardanico> well, I'm still not sure if I understand why you can't just do it with a simple for loop |
22:50:41 | FromDiscord | <Yardanico> but you can check https://github.com/kostya/benchmarks/blob/master/brainfuck/bf.nim which uses closure iterators for a similar thing |
22:50:59 | FromDiscord | <Yardanico> although this is not really idiomatic nim, it's been written to be in line with other implementations, usually you'd not use a closure iterator here |
22:52:11 | FromDiscord | <ellliottt> what im doing is (badly) reimplementing a stream type |
22:52:31 | FromDiscord | <ellliottt> cant i store a file handle and pull bytes from it? |
22:53:14 | FromDiscord | <Yardanico> sure, but that might again be not very efficient since you'll have to do a system call every time you read the stuff from the file :P |
22:53:30 | FromDiscord | <Yardanico> there's https://nim-lang.org/docs/memfiles.html which maps files to memory |
22:53:45 | FromDiscord | <Yardanico> but it's better to just read everything from the file first, if the file's not big of course |
22:54:30 | FromDiscord | <ellliottt> memmap is how you'd do it in C probably, so i guess ill go with that :) |
22:55:00 | FromDiscord | <ellliottt> ah, but reading runes from that will be hard |
22:55:11 | FromDiscord | <ellliottt> since the `unicode` functions take strings |
22:55:23 | FromDiscord | <Yardanico> why would it be hard? |
22:56:19 | FromDiscord | <ellliottt> if i have an index into a memfile, i dont know how many bytes to read to get a rune |
22:58:48 | FromDiscord | <ellliottt> i dont see a way to index into a memfile anyway |
22:58:57 | FromDiscord | <ellliottt> it just has functions for opening/closing/flushin |
22:58:59 | FromDiscord | <ellliottt> (edit) "opening/closing/flushin" => "opening/closing/flushing" |
23:13:52 | * | krux02 quit (Ping timeout: 240 seconds) |
23:17:52 | * | vicfred_ quit (Quit: Leaving) |
23:31:18 | * | Jesin quit (Quit: Leaving) |
23:40:02 | * | Jesin joined #nim |
23:47:25 | * | Gustavo6046 joined #nim |