01:12:18 | * | fedorafan quit (Ping timeout: 244 seconds) |
01:35:07 | * | xet7 joined #nim |
02:50:17 | * | rockcavera quit (Remote host closed the connection) |
03:57:13 | * | SchweinDeBurg joined #nim |
04:21:23 | * | fedorafan joined #nim |
04:34:27 | * | alexdaguy joined #nim |
04:41:37 | * | ntat joined #nim |
05:24:13 | * | nils` quit (Ping timeout: 276 seconds) |
05:56:59 | * | xet7 quit (Remote host closed the connection) |
05:58:52 | FromDiscord | <heysokam> Is it possible to switch on typedesc?↵`case T of int: ... of float: ...` etc |
05:59:55 | Amun-Ra | iirc no, but you can use if |
06:00:00 | Amun-Ra | or when |
06:00:13 | Amun-Ra | when is even better |
06:00:54 | FromDiscord | <heysokam> `when T == int` or `when T is int`? which is the correct one? |
06:01:07 | Amun-Ra | I prefer is |
06:01:10 | FromDiscord | <heysokam> assuming `T` is `typedesc` |
06:14:02 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#pasty=WrDmTDdC |
06:15:02 | FromDiscord | <heysokam> answer to my own question: `T is int` is the correct one. `==` just errors |
06:18:29 | * | alexdaguy quit (Quit: WeeChat 4.6.2) |
06:49:37 | * | xet7 joined #nim |
06:52:54 | * | xet7 quit (Remote host closed the connection) |
06:56:58 | * | xet7 joined #nim |
07:35:14 | * | fedorafan quit (Ping timeout: 252 seconds) |
08:02:20 | * | redj quit (Quit: No Ping reply in 180 seconds.) |
08:03:52 | * | redj joined #nim |
08:06:33 | * | xet7 quit (Remote host closed the connection) |
08:11:52 | * | nils` joined #nim |
08:27:18 | * | fedorafan joined #nim |
08:35:02 | * | fedorafan quit (Remote host closed the connection) |
08:35:25 | * | fedorafan joined #nim |
08:52:57 | FromDiscord | <mkadd.sh> In reply to @heysokam "answer to my own": Typedesc, only works in particular cases. You cannot assign a typedesc to a case, case expects you to pass some already defined value. |
08:54:25 | FromDiscord | <mkadd.sh> If you want to practice typedesc it is much better to use it in generic procs or templates. |
08:54:29 | FromDiscord | <mkadd.sh> https://tenor.com/view/hello-gif-13062150862685254762 |
09:40:38 | * | SchweinDeBurg quit (Ping timeout: 252 seconds) |
09:42:32 | * | SchweinDeBurg joined #nim |
09:42:39 | * | fedorafan quit (Read error: Connection reset by peer) |
09:42:57 | * | fedorafan joined #nim |
10:20:54 | * | skippy8 joined #nim |
11:05:38 | * | xet7 joined #nim |
11:18:14 | * | andy-turner joined #nim |
11:25:23 | FromDiscord | <mratsim> sent a long message, see https://pasty.ee/BIKRLARA |
11:45:38 | FromDiscord | <riku5543> sent a code paste, see https://play.nim-lang.org/#pasty=FXunKNtX |
12:10:20 | FromDiscord | <mratsim> In reply to @riku5543 "Hi there, I was": use object variants or inheritance with `type Animal = ref object of RootObj` |
12:11:02 | FromDiscord | <mratsim> or `State[T]` |
12:11:50 | FromDiscord | <riku5543> In reply to @mratsim "or `State[T]`": Ooh yeah I didn't fully understand object variants in the docs, how does State[T] work, please? |
12:12:36 | FromDiscord | <mratsim> sent a code paste, see https://play.nim-lang.org/#pasty=xKuRFeOi |
12:12:59 | FromDiscord | <mratsim> you'll have multiple state objects though |
12:13:10 | FromDiscord | <mratsim> it's compile-time polymorphism |
12:13:50 | FromDiscord | <mratsim> sent a code paste, see https://play.nim-lang.org/#pasty=bteHhPgi |
12:14:24 | FromDiscord | <mratsim> and each objects has an associated enter proc and you replace the State.enter proc with it. |
12:14:38 | FromDiscord | <mratsim> That's what is done in C to emulate polymorphism / inheritance |
12:14:46 | FromDiscord | <mratsim> (edit) "objects" => "object" |
12:15:23 | FromDiscord | <riku5543> I think that would work for what I was trying to do, thank you very much! I'll try it out soon. I was using variants for other procs but couldn't wrap my head around getting it to work with the State definition. I thought about using a raw pointer as well but it felt dirty in this language lol |
12:16:01 | FromDiscord | <mratsim> inheritance + method are the simplest then. |
12:16:14 | FromDiscord | <mratsim> the example is even with cat and dog |
12:16:32 | FromDiscord | <riku5543> Ah okay |
12:18:19 | FromDiscord | <mratsim> mmh, I lost the tutorial that has the Cat / Dog thing |
12:19:07 | FromDiscord | <mratsim> ah it's there: https://nim-by-example.github.io/oop/ |
12:19:34 | FromDiscord | <mratsim> sent a code paste, see https://play.nim-lang.org/#pasty=KUvjKotW |
14:02:50 | * | Guest7666 joined #nim |
14:04:13 | * | Guest7666 quit (Client Quit) |
14:11:15 | * | fedorafan quit (Read error: Connection reset by peer) |
14:11:35 | * | fedorafan joined #nim |
15:40:56 | * | fedorafan quit (Remote host closed the connection) |
15:41:21 | * | fedorafan joined #nim |
15:54:48 | * | skippy8 quit (Quit: WeeChat 4.5.2) |
16:12:57 | FromDiscord | <gyatsoyt> sent a code paste, see https://play.nim-lang.org/#pasty=GvMNdUSm |
16:15:27 | * | skippy8 joined #nim |
16:16:23 | FromDiscord | <nnsee> In reply to @gyatsoyt "How do I compile": honestly just wsl it |
16:17:46 | FromDiscord | <gyatsoyt> sent a code paste, see https://play.nim-lang.org/#pasty=kfMQsJOk |
16:17:55 | FromDiscord | <gyatsoyt> This happens on wsl |
16:38:05 | * | andy-turner quit (Quit: Leaving) |
16:42:06 | * | SchweinDeBurg quit (Quit: WeeChat 4.7.0-dev) |
16:42:36 | * | beholders_eye joined #nim |
17:03:09 | FromDiscord | <mr_rowboto> How is using `method` for polymorphism in `nim` seen? |
17:03:34 | FromDiscord | <mr_rowboto> sent a code paste, see https://play.nim-lang.org/#pasty=FrKbTBoQ |
17:03:51 | FromDiscord | <Elegantbeef> Avoid inheritance and use a tagged union |
17:03:59 | FromDiscord | <Elegantbeef> Is the general consensus |
17:04:05 | FromDiscord | <mr_rowboto> nice |
17:04:07 | FromDiscord | <mr_rowboto> no vtables |
17:04:10 | Amun-Ra | I've never used 'method' in nim |
17:04:17 | FromDiscord | <mr_rowboto> how are tagged unions implemented? |
17:04:30 | FromDiscord | <Elegantbeef> Like C tagged unions |
17:04:41 | FromDiscord | <mr_rowboto> oh, ok, manually? |
17:04:43 | FromDiscord | <Elegantbeef> Each branch creates a anonymous struct inside of a union with a tag |
17:04:55 | FromDiscord | <Elegantbeef> No there are object variants |
17:05:00 | FromDiscord | <Elegantbeef> But you said how are they implemented and I told you 😄 |
17:05:09 | FromDiscord | <Elegantbeef> How does one declare one? Using an object variant |
17:05:19 | FromDiscord | <mr_rowboto> In reply to @Elegantbeef "But you said how": of course |
17:05:20 | Amun-Ra | mr_rowboto: https://nim-lang.org/docs/manual.html#types-object-variants |
17:05:50 | FromDiscord | <mr_rowboto> Thanks. |
17:12:32 | * | fedorafan_ joined #nim |
17:14:11 | * | fedorafan quit (Read error: Connection reset by peer) |
17:14:48 | Amun-Ra | there's one restriction: fields of different kinds and type can't share the same name |
17:16:21 | * | amadaluzia joined #nim |
17:18:00 | FromDiscord | <mr_rowboto> good enough |
17:20:10 | Amun-Ra | https://play.nim-lang.org/#pasty=fXwzEAqB |
17:20:21 | FromDiscord | <mr_rowboto> What I need is that code `A` couples to `B`, while `C`, `D`, etc. implementors interface through `B`.↵I have no need for anything dynamic truly, as long as I can recompile, and link with `C` or `D`, without changing `A`. |
17:21:16 | FromDiscord | <mr_rowboto> In reply to @Amun-Ra "https://play.nim-lang.org/#pasty=fXwzEAqB": nice |
17:21:53 | FromDiscord | <mr_rowboto> In reply to @mr_rowboto "What I need is": I think that with variants I'd have to change `I` right? |
17:22:01 | FromDiscord | <mr_rowboto> (edit) "variants" => ""Object variants"" |
17:22:39 | FromDiscord | <mr_rowboto> (edit) "`I`" => "`B`" |
17:34:34 | * | beholders_eye quit (Ping timeout: 245 seconds) |
17:48:02 | FromDiscord | <entropydev> Is it possible to cast a string as an `array[48, byte]` |
17:48:08 | FromDiscord | <entropydev> (edit) "byte]`" => "byte]`?" |
17:48:49 | FromDiscord | <entropydev> or is it possible that strings are not formated the same way a cstring would be? |
17:49:55 | Amun-Ra | strings are cstring compatible |
17:50:57 | FromDiscord | <entropydev> It seems like when I do this I am getting a lot of empty space |
17:51:57 | Amun-Ra | https://play.nim-lang.org/#pasty=ZzrSzswE |
17:53:09 | FromDiscord | <entropydev> sent a code paste, see https://play.nim-lang.org/#pasty=XMKNdSqC |
17:53:30 | FromDiscord | <entropydev> this is not returning what I am expecting |
17:54:19 | Amun-Ra | it's not compileable |
17:54:32 | Amun-Ra | does it have to be array? |
17:54:39 | FromDiscord | <entropydev> yes |
17:54:55 | FromDiscord | <entropydev> it does compile, what should be breaking? |
17:55:25 | Amun-Ra | I mean the test case |
17:55:43 | Amun-Ra | here's openArray: https://play.nim-lang.org/#pasty=rCwIKkKc |
17:56:13 | FromDiscord | <entropydev> yeah, it would be better for it to be a fixed array size |
17:57:32 | Amun-Ra | you can create an array and copyMem |
17:57:47 | FromDiscord | <entropydev> https://play.nim-lang.org/#pasty=rCwIKkKc |
17:58:04 | FromDiscord | <entropydev> why are there all these 0s in the array? |
17:58:54 | Amun-Ra | I don't see any zeros |
17:59:22 | FromDiscord | <entropydev> when I run this code it prints to the console |
17:59:31 | FromDiscord | <entropydev> and the byte array is mostly 0s |
17:59:50 | Amun-Ra | that's my code at the link :> |
17:59:59 | FromDiscord | <entropydev> no I sent a link |
18:00:05 | Amun-Ra | yes |
18:00:11 | Amun-Ra | click on the link |
18:00:19 | FromDiscord | <entropydev> https://play.nim-lang.org/#pasty=rCwIKkKc |
18:00:37 | FromDiscord | <entropydev> https://play.nim-lang.org/#pasty=AIxNQgGZ |
18:00:42 | Amun-Ra | ^ let decoded = "foobar"; echo repr decoded.toOpenArrayByte(0, decoded.high) |
18:00:52 | FromDiscord | <entropydev> ok, how about that? |
18:02:01 | Amun-Ra | it's looks like physical representation of string is different from an array one |
18:03:11 | FromDiscord | <entropydev> now, I thought cstrings would be essentially an array with a \0 termination at the end? |
18:03:23 | Amun-Ra | but not "array" per se |
18:03:46 | Amun-Ra | cstrings are more like UncheckedArray |
18:04:04 | FromDiscord | <entropydev> ok, so how do I make the string into that? |
18:04:34 | FromDiscord | <entropydev> I would prefer fixed length if it's possible |
18:04:38 | Amun-Ra | use openArray / create array and copy data |
18:05:13 | Amun-Ra | var bytes {.noinit.}: array[48, byte]; copyMem bytes[0].addr, decoded[0].addr, 48 |
18:05:36 | Amun-Ra | 48 → bytes.len |
18:08:01 | FromDiscord | <entropydev> huh, well that did it, this ; operator is interesting, is it like a pipe? |
18:09:01 | Amun-Ra | it's just two separate lines written into single one for IRC: line1 ; line2 |
18:09:17 | Amun-Ra | var bytes {.noinit.}: array[48, byte] |
18:09:25 | Amun-Ra | copyMem bytes[0].addr, decoded[0].addr, bytes.len |
18:09:58 | Amun-Ra | that works exactly like in C or Python |
18:12:04 | FromDiscord | <entropydev> Well thanks, that was very helopful |
18:12:12 | FromDiscord | <entropydev> (edit) "helopful" => "helpful" |
18:12:14 | Amun-Ra | no worries |
18:41:30 | * | fedorafan_ quit (Remote host closed the connection) |
18:41:52 | * | fedorafan_ joined #nim |
19:09:39 | * | fedorafan_ quit (Remote host closed the connection) |
19:10:04 | * | fedorafan_ joined #nim |
19:20:46 | * | amadaluzia_ joined #nim |
19:25:22 | * | amadaluzia_ quit (Ping timeout: 272 seconds) |
19:25:39 | FromDiscord | <treeform> In reply to @albassort "hello treeform": hello |
20:34:55 | * | ntat quit (Quit: leaving) |
20:59:05 | * | amadaluzia quit (Ping timeout: 244 seconds) |
20:59:33 | * | amadaluzia joined #nim |
21:14:29 | * | amadaluzia quit (Ping timeout: 248 seconds) |
21:38:30 | * | amadaluzia joined #nim |
22:20:35 | * | amadaluzia quit (Read error: Connection reset by peer) |
22:20:55 | * | amadaluzia joined #nim |
22:26:59 | * | skippy8 quit (Quit: WeeChat 4.5.2) |
22:50:21 | * | drewr quit (Ping timeout: 252 seconds) |
23:48:19 | FromDiscord | <schelz_> im working on a wrap for directx9 in nim, if anyone is interested in giving me a feedback im glad: https://github.com/SchelZ/d9Nim |
23:48:38 | FromDiscord | <schelz_> (edit) "glad:" => "glad to hear:" |