00:00:00 | FromDiscord | <abby.> but the lexer kinda needs to get the token and then increment the position afterward no? |
00:00:08 | FromDiscord | <abby.> not increment and then get the token |
00:00:25 | FromDiscord | <abby.> (edit) "the" => "my" |
00:00:48 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4fsY |
00:01:13 | FromDiscord | <Elegantbeef> Are you saying "how do you implement post increment" |
00:02:04 | FromDiscord | <abby.> yes for my lexer |
00:02:11 | FromDiscord | <Elegantbeef> You then just post increment |
00:02:11 | FromDiscord | <ChocolettePalette> It must be possible with macros |
00:02:15 | FromDiscord | <abby.> since i need to get the current token and then increment |
00:02:19 | FromDiscord | <Elegantbeef> why bring macros into this |
00:02:50 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4fsZ |
00:03:00 | FromDiscord | <abby.> gotcha |
00:03:28 | FromDiscord | <ChocolettePalette> `for (int i = 0; i < 1; ++i) cout << i << '\n'` |
00:03:28 | FromDiscord | <abby.> so similar to how it would work in other languages without ++ then |
00:04:19 | FromDiscord | <ChocolettePalette> If you change ++i to i++, behaviour will change |
00:04:23 | FromDiscord | <Elegantbeef> `for i in 0..0: echo i`? |
00:04:45 | FromDiscord | <Elegantbeef> or `for i in 1..0: echo i` |
00:04:48 | FromDiscord | <Elegantbeef> Eitherway you can get the same semantics in a more readable way |
00:06:55 | FromDiscord | <ChocolettePalette> How about if you need to write smth like`++i - j++`? |
00:09:42 | FromDiscord | <Elegantbeef> How about you quit trolling and go write some real code |
00:11:10 | FromDiscord | <huantian> beef you can't just call someone out like that |
00:13:34 | arkanoid | is there a limit to the amount of possible ayncCheck branches in an async program, beside and other very large variables? |
00:13:44 | arkanoid | *beside ram |
00:14:30 | FromDiscord | <huantian> I don't think so? |
00:20:54 | FromDiscord | <ChocolettePalette> In C++ there's a very readable operator originating fron math "X approaches N" where X is a variable and N is a constant, used like this\:`for (int x = 100; x-->0;) cout << x << endl;`But it seems that it can't be achieved in Nim without post-increment/decrement 😔 |
00:21:16 | FromDiscord | <Elegantbeef> Really going for those deep trolls today |
00:21:53 | FromDiscord | <Elegantbeef> `for x in countDown(100, 0)` you happy?! |
00:22:32 | FromDiscord | <ChocolettePalette> Oooo well it lacks a funny arrow but saves many butes actually so yes I am! |
00:25:39 | FromDiscord | <huantian> In reply to @ChocolettePalette "In C++ there's a": right but that notation doesn't even make sense coming from mathematics |
00:27:25 | FromDiscord | <ChocolettePalette> sent a code paste, see https://play.nim-lang.org/#ix=4ft3 |
00:27:44 | FromDiscord | <huantian> right but have you considered what the limit actually means in mathematics |
00:28:48 | FromDiscord | <ChocolettePalette> No 😔 I only duckduckgoogled it because it has that arrow just like C++ |
00:29:25 | FromDiscord | <Elegantbeef> "that arrow" |
00:29:37 | FromDiscord | <Elegantbeef> Joining two operators together stealthly isnt a new operator |
00:30:23 | FromDiscord | <ChocolettePalette> Well you can define operator --\> in Nim fortunately |
00:30:34 | FromDiscord | <ChocolettePalette> Omg and you can actually use it |
00:30:37 | FromDiscord | <Elegantbeef> can even make it an iterator |
00:30:54 | FromDiscord | <abby.> In reply to @ChocolettePalette "In C++ there's a": i hate this so much |
00:31:34 | FromDiscord | <abby.> also cant u do |
00:31:56 | FromDiscord | <abby.> sent a code paste, see https://play.nim-lang.org/#ix=4ft8 |
00:32:02 | FromDiscord | <Elegantbeef> Correct |
00:32:07 | FromDiscord | <abby.> i fucking hate this |
00:32:10 | FromDiscord | <abby.> why \ |
00:32:11 | FromDiscord | <abby.> (edit) removed "\" |
00:32:11 | FromDiscord | <Elegantbeef> like i said you can even make it an iterator |
00:32:15 | FromDiscord | <abby.> oh dear god |
00:32:35 | FromDiscord | <abby.> cant wait for `<$>` operator like in haskell |
00:32:55 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4ft9 |
00:33:08 | FromDiscord | <abby.> close enough |
00:33:11 | FromDiscord | <abby.> https://media.discordapp.net/attachments/371759389889003532/1040061524070367293/image.png |
00:33:45 | FromDiscord | <Elegantbeef> User defined operators arent that bad, it's dumbly defined ones |
00:33:45 | FromDiscord | <Elegantbeef> I mean even C++ got it wrong with `<<` in iostream |
00:34:16 | FromDiscord | <abby.> oh just you wait |
00:34:45 | FromDiscord | <abby.> sent a code paste, see https://play.nim-lang.org/#ix=4ftb |
00:35:33 | FromDiscord | <Elegantbeef> See dumbly defined |
00:35:35 | FromDiscord | <abby.> not the exact same but ill take it |
00:35:52 | FromDiscord | <abby.> i could define |
00:35:53 | FromDiscord | <Elegantbeef> Yea you leftout the state machine |
00:36:18 | FromDiscord | <Elegantbeef> You can do exactly what C++ does with Nim's |
00:36:33 | FromDiscord | <abby.> oh god |
00:36:36 | FromDiscord | <abby.> i hate that |
00:36:36 | FromDiscord | <ChocolettePalette> sent a code paste, see https://play.nim-lang.org/#ix= |
00:37:17 | FromDiscord | <ChocolettePalette> sent a code paste, see https://play.nim-lang.org/#ix=4ftc |
00:37:55 | FromDiscord | <ChocolettePalette> ah you already made it |
00:38:35 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4ftd |
00:40:41 | FromDiscord | <Elegantbeef> Technically I should've made an Enum but alas |
00:42:23 | FromDiscord | <ChocolettePalette> sent a code paste, see https://play.nim-lang.org/#ix=4ftg |
00:45:37 | FromDiscord | <Elegantbeef> See i've never used words that have even got me threatened to be banned but chocolette here.... 😛 |
00:48:30 | FromDiscord | <abby.> @ElegantBeef any idea whats going on w/ this? |
00:48:39 | FromDiscord | <abby.> sent a code paste, see https://play.nim-lang.org/#ix=4fti |
00:48:56 | FromDiscord | <abby.> wait i fixed it |
00:52:46 | FromDiscord | <DecentArmchair> sent a code paste, see https://play.nim-lang.org/#ix=4ftj |
00:53:29 | FromDiscord | <DecentArmchair> The problematic line (135):↵`(Result).align = 0;` |
00:54:11 | FromDiscord | <DecentArmchair> Looks like the code generates right below it at line 137:↵`(Result).align = ((TextProperties::Alignment) 2);` |
00:54:36 | FromDiscord | <DecentArmchair> Any idea where to go from here? Am I missing something needed to cast the initial result the code generates before assigning to it? |
00:57:00 | FromDiscord | <Elegantbeef> Well firstly `align: TextProperties.Alignment` is invalid |
00:57:18 | FromDiscord | <Elegantbeef> It should be `align: TextProperties` |
00:57:33 | FromDiscord | <Elegantbeef> Secondly how do you import `TextProperties`? |
00:58:32 | FromDiscord | <abby.> whats the best way of doing docstrings in nim? |
00:58:33 | FromDiscord | <DecentArmchair> (Much needed) background info:↵Using the nim-panda3d bindings from here:↵https://github.com/rdb/nim-panda3d/ |
00:58:48 | FromDiscord | <Elegantbeef> Using doc comments `## This is a doc comment`↵(@abby.) |
00:59:00 | FromDiscord | <abby.> @DecentArmchair also unrelated but cool to meet another trans person |
00:59:10 | FromDiscord | <DecentArmchair> sent a code paste, see https://play.nim-lang.org/#ix=4ftk |
00:59:10 | FromDiscord | <abby.> In reply to @Elegantbeef "Using doc comments `##": inside the function or outside? |
00:59:16 | FromDiscord | <Elegantbeef> Inside |
00:59:17 | FromDiscord | <DecentArmchair> In reply to @abby. "<@197933326261026816> also unrelated but": Howdy 🤠 |
00:59:50 | FromDiscord | <Griphcode きつね> hi |
00:59:53 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4ftl |
01:00:02 | FromDiscord | <Elegantbeef> You can use `##` or `##[comment here]##` for multi line comments |
01:00:50 | FromDiscord | <DecentArmchair> In reply to @Elegantbeef "Well firstly `align: TextProperties.Alignment`": I was told that was the intended way to use the type |
01:00:51 | FromDiscord | <Elegantbeef> I dont know the C++ backend much but i think something is up with the bindings |
01:01:23 | FromDiscord | <DecentArmchair> sent a code paste, see https://play.nim-lang.org/#ix=4ftn |
01:01:31 | FromDiscord | <Elegantbeef> Eh i'm looking at their code they do things weid |
01:01:33 | FromDiscord | <Elegantbeef> weird\ |
01:01:54 | FromDiscord | <Elegantbeef> They have TextPropertiesAlignmnent\` but you have to access it using a dot operator |
01:03:26 | FromDiscord | <abby.> @ElegantBeef i more am asking how do i document parameters of functions |
01:03:31 | FromDiscord | <Elegantbeef> This reads a lot like someone wants their code to be like C++ and not Nim, but anyway i think it's with the backend Nim thinks it can zero the memory by doing `= 0` but it needs to do something different |
01:03:39 | FromDiscord | <Elegantbeef> Read the stdlib↵(@abby.) |
01:03:45 | FromDiscord | <DecentArmchair> In reply to @Elegantbeef "They have TextPropertiesAlignmnent\` but": I can edit the library to access that and get what I need working, but I was looking to use as intended and something seems to be specifically up with the generated file not catching the type |
01:03:59 | FromDiscord | <DecentArmchair> In reply to @Elegantbeef "This reads a lot": Thoughts on how I should proceed then? |
01:04:03 | FromDiscord | <abby.> is there a page on documenting functions or something or do i have to read the stdlib code |
01:04:10 | FromDiscord | <Elegantbeef> I havent used the C++ interop ever so nope |
01:04:19 | FromDiscord | <abby.> https://nim-lang.org/docs/docgen.html↵foudn this |
01:04:21 | FromDiscord | <Elegantbeef> The stdlib documents cod |
01:04:22 | FromDiscord | <Elegantbeef> code\ |
01:04:37 | FromDiscord | <Elegantbeef> Look at a module, click on `source` then see what they do |
01:04:45 | FromDiscord | <DecentArmchair> In reply to @Elegantbeef "I havent used the": Thanks for helping regardless <3 |
01:05:19 | FromDiscord | <Elegantbeef> Holy shit the swizzle code in `core.nim` |
01:05:46 | FromDiscord | <Elegantbeef> Jesus fucking christ 😄 |
01:05:57 | FromDiscord | <Elegantbeef> That's thousands of lines of swizzle code |
01:06:17 | FromDiscord | <huantian> what's a swizzle |
01:06:35 | FromDiscord | <Elegantbeef> Accessors for like `.xzz` on a vector |
01:06:53 | FromDiscord | <huantian> ah |
01:07:26 | FromDiscord | <DecentArmchair> In reply to @huantian "what's a swizzle": https://media.discordapp.net/attachments/371759389889003532/1040070146150113310/image.png |
01:07:30 | FromDiscord | <Elegantbeef> https://github.com/GaryMcWhorter/slam/blob/main/src/slam/vectors/vectors.nim#L58-L158 Way less code to use the dotoperators |
01:08:09 | FromDiscord | <Elegantbeef> It's certainly the reason github doesnt embed the file |
01:08:14 | FromDiscord | <Elegantbeef> It also slows down compilation |
01:08:23 | FromDiscord | <alice.> In reply to @DecentArmchair "": what the actual fuck |
01:09:14 | FromDiscord | <Elegantbeef> They wanted swizzles for their vector types |
01:09:25 | FromDiscord | <Elegantbeef> It's perfectly reasonable assuming you didnt know about dotoperators |
01:09:37 | FromDiscord | <Elegantbeef> Or Nim macros in anyregard |
01:09:47 | FromDiscord | <Elegantbeef> I'd prefer a `.swizzle(xzz)` over that mess |
01:10:03 | FromDiscord | <DecentArmchair> In reply to @alice. "what the actual fuck": The code generation is actually insane |
01:10:21 | FromDiscord | <DecentArmchair> > i love it |
01:10:35 | FromDiscord | <Elegantbeef> Well if anyone wants to make that code cleaner the above solutions are much easier |
01:20:44 | FromDiscord | <alice.> also are seq just mutable arrays? |
01:21:13 | FromDiscord | <huantian> mutable length |
01:21:18 | FromDiscord | <alice.> In reply to @DecentArmchair "The code generation is": is this for swizzling? |
01:21:26 | FromDiscord | <alice.> In reply to @huantian "mutable length": as in u can push/pop items? |
01:21:30 | FromDiscord | <huantian> ye |
01:21:35 | FromDiscord | <Elegantbeef> They're growable arrays |
01:21:59 | FromDiscord | <alice.> also whats the convention for const variables |
01:22:09 | FromDiscord | <alice.> camelCase or SHOUT_CASE |
01:22:26 | FromDiscord | <Elegantbeef> NEP1 suggests upper pacal iirc |
01:23:00 | FromDiscord | <huantian> yeah that or camelCase |
01:23:29 | FromDiscord | <Elegantbeef> Shout case is the worst, but luckily Nim has style insensitivity |
01:33:38 | FromDiscord | <alice.> In reply to @Elegantbeef "Shout case is the": wdym by style insensitivity |
01:34:07 | FromDiscord | <Elegantbeef> Nim only cares about the first character's casing |
01:34:12 | FromDiscord | <Elegantbeef> `myVar` == `myvar` |
01:34:36 | FromDiscord | <Elegantbeef> `MyVar` != `myVar` |
01:35:44 | FromDiscord | <alice.> oh thats very cool |
01:36:11 | FromDiscord | <Elegantbeef> So weird when someone says that's nice, given so many that dont use Nim despise it |
01:36:23 | FromDiscord | <alice.> why would u despise it |
01:36:30 | FromDiscord | <alice.> if u have two variables that differ only by casing |
01:36:33 | FromDiscord | <alice.> what the fuck are you doing |
01:36:53 | FromDiscord | <Rika> That’s what we’ve been fucking telling everyone else but they still be saying “what the fuck” lmao |
01:36:59 | FromDiscord | <alice.> this just means u can pick one and be consistent |
01:37:10 | FromDiscord | <alice.> no one is saying use one at random every 10 lines |
01:37:13 | FromDiscord | <Elegantbeef> But "My C `GlFloat` and `glFloat` 😄 |
01:37:16 | FromDiscord | <Rika> Lol |
01:37:29 | FromDiscord | <alice.> In reply to @Elegantbeef "But "My C `GlFloat`": these are different types no? |
01:37:33 | FromDiscord | <Elegantbeef> Sorry it's `GlFloat` and `Gl_Float` |
01:37:40 | FromDiscord | <Elegantbeef> Nim also doesnt see `_` in names |
01:37:44 | FromDiscord | <Elegantbeef> So those are the same |
01:37:49 | FromDiscord | <Elegantbeef> And my response is the same |
01:37:52 | FromDiscord | <alice.> In reply to @Elegantbeef "Sorry it's `GlFloat` and": why are they distinct |
01:37:53 | FromDiscord | <Elegantbeef> Good riddance |
01:38:07 | FromDiscord | <Elegantbeef> Dont look at me i didnt write opengl 😄 |
01:38:13 | FromDiscord | <alice.> thank god |
01:38:21 | FromDiscord | <alice.> i would have admitted u to an asylum lol |
01:38:27 | FromDiscord | <alice.> opengl is a mess |
01:38:32 | FromDiscord | <Rika> In reply to @alice. "why are they distinct": Only god knows |
01:38:44 | FromDiscord | <alice.> i wonder if its some weird C struct namespacing thing? |
01:38:45 | FromDiscord | <alice.> but idk |
01:38:47 | FromDiscord | <Elegantbeef> `GLfloat` is a type `GL_Float` is a enum |
01:39:09 | FromDiscord | <alice.> why would u name the enum the same as the type???? |
01:39:15 | FromDiscord | <Elegantbeef> Cause C |
01:39:28 | FromDiscord | <alice.> call it like `GLFloat` and `GLFloatType` or `GLFloatProperty` |
01:40:24 | FromDiscord | <Elegantbeef> Yep but it's a reason why people dislike it "It makes C interop hard", "It's allows inconsistent code" |
01:41:05 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/RFCs/issues/456 if you ever are bored and want a read |
01:51:04 | FromDiscord | <alice.> @ElegantBeef how do i make a subtype in nim? |
01:51:19 | FromDiscord | <alice.> object that has properties of another object |
01:53:04 | FromDiscord | <banan|crab> i dont get this error |
01:53:06 | FromDiscord | <banan|crab> https://media.discordapp.net/attachments/371759389889003532/1040081635141505074/unknown.png |
01:53:11 | FromDiscord | <banan|crab> i get it when doing a post request |
01:53:34 | FromDiscord | <alice.> @banan|crab fellow nim user :0 |
01:53:37 | FromDiscord | <Elegantbeef> do you have `libcrypto` installed? |
01:55:11 | FromDiscord | <banan|crab> https://media.discordapp.net/attachments/371759389889003532/1040082163518930945/unknown.png |
01:55:28 | FromDiscord | <banan|crab> In reply to @Elegantbeef "do you have `libcrypto`": no |
01:55:31 | FromDiscord | <banan|crab> how do i install it |
01:55:38 | FromDiscord | <banan|crab> In reply to @alice. "<@996044212158083084> fellow nim user": hello |
01:55:38 | FromDiscord | <Elegantbeef> My question doesnt change |
01:55:42 | FromDiscord | <Elegantbeef> Depends on your distro |
01:56:04 | FromDiscord | <banan|crab> what is it |
01:56:26 | FromDiscord | <Elegantbeef> It's a cryptography library named libcrypto 😄 |
01:56:47 | FromDiscord | <banan|crab> why does it need it |
01:56:55 | FromDiscord | <Elegantbeef> `https` |
01:57:14 | FromDiscord | <banan|crab> hm |
01:58:54 | FromDiscord | <huantian> ye it's part of openssl |
01:59:24 | FromDiscord | <banan|crab> theres no nix package 😦 |
01:59:33 | FromDiscord | <huantian> you want openssl_1_1 |
01:59:48 | FromDiscord | <huantian> if you're on unstable |
01:59:48 | FromDiscord | <banan|crab> ah thanks |
02:00:10 | FromDiscord | <huantian> one day nim will udpate to open ssl 3 |
02:00:24 | FromDiscord | <banan|crab> ah |
02:00:44 | FromDiscord | <huantian> (edit) "udpate" => "update" |
02:00:54 | FromDiscord | <huantian> (edit) "open ssl" => "openssl" |
02:00:54 | FromDiscord | <alice.> am i doing inheritance right? |
02:01:00 | FromDiscord | <alice.> sent a code paste, see https://paste.rs/WY6 |
02:01:41 | FromDiscord | <banan|crab> the webhook works but it just crashes https://media.discordapp.net/attachments/371759389889003532/1040083796281802812/unknown.png https://media.discordapp.net/attachments/371759389889003532/1040083796617334925/unknown.png |
02:01:43 | FromDiscord | <Elegantbeef> Do it all in one error block and you should do `BaseError = object of CatchableError` |
02:01:54 | FromDiscord | <Elegantbeef> Also `CatchableError`s have a `msg` field so you dont need `reason` |
02:01:57 | FromDiscord | <alice.> In reply to @Elegantbeef "Do it all in": wdym? |
02:02:14 | FromDiscord | <alice.> can i still have the LexerError inherit f rom it? |
02:02:37 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4ftr |
02:02:48 | FromDiscord | <alice.> gotcha |
02:02:52 | FromDiscord | <Elegantbeef> I assume you want this to work with exceptions? |
02:03:07 | FromDiscord | <alice.> i kinda prefer to do them individually and not in one big type block |
02:03:12 | FromDiscord | <alice.> is it just personal preference? |
02:03:21 | FromDiscord | <Elegantbeef> No there is forward declaration in type defs |
02:03:28 | FromDiscord | <alice.> wdym? |
02:03:30 | FromDiscord | <Elegantbeef> The compiler does left then right |
02:03:36 | FromDiscord | <banan|crab> In reply to @banan|crab "the webhook works but": https://media.discordapp.net/attachments/371759389889003532/1040084278815498260/unknown.png |
02:03:47 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3ZEx |
02:03:48 | FromDiscord | <banan|crab> whats making it crash |
02:04:15 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4fts |
02:04:34 | FromDiscord | <alice.> sent a code paste, see https://play.nim-lang.org/#ix=4ftt |
02:04:38 | FromDiscord | <Elegantbeef> You dont need `inheritable` |
02:04:44 | FromDiscord | <Elegantbeef> `object of` is inheritable |
02:05:18 | FromDiscord | <alice.> so how do i use this new CatchableError type? |
02:05:55 | FromDiscord | <Elegantbeef> `raise (ref LexerError)(src: "hmm", msg: "You dun goofed", line: 100)` |
02:06:12 | FromDiscord | <alice.> why the ref thing? |
02:06:21 | FromDiscord | <Elegantbeef> Cause exceptions are heap allocated |
02:06:58 | FromDiscord | <Elegantbeef> Again this is only if you want to work with exceptions |
02:07:02 | FromDiscord | <Elegantbeef> Which i was assuming you did |
02:07:04 | FromDiscord | <alice.> i do |
02:09:26 | FromDiscord | <alice.> how do i make a function that returns a ref object |
02:09:31 | FromDiscord | <alice.> so i dont have to type this everywhere |
02:09:43 | FromDiscord | <Elegantbeef> The same was as you make any function |
02:09:45 | FromDiscord | <Elegantbeef> way |
02:09:58 | FromDiscord | <alice.> but how do i return ref |
02:10:11 | FromDiscord | <alice.> sent a code paste, see https://play.nim-lang.org/#ix=4ftu |
02:10:17 | FromDiscord | <Elegantbeef> The same was as you return a non ref |
02:10:20 | FromDiscord | <alice.> this obviously doesnt work |
02:10:27 | FromDiscord | <alice.> sent a code paste, see https://play.nim-lang.org/#ix=4ftv |
02:10:34 | FromDiscord | <Elegantbeef> `(ref LexerError)(...)` |
02:10:39 | FromDiscord | <Elegantbeef> I didnt do that for fun |
02:10:40 | FromDiscord | <alice.> oh that |
02:10:48 | FromDiscord | <Elegantbeef> I did that cause it's required |
02:11:07 | FromDiscord | <alice.> still errors |
02:11:15 | FromDiscord | <alice.> sent a code paste, see https://play.nim-lang.org/#ix=4ftu |
02:11:23 | FromDiscord | <Elegantbeef> ... |
02:11:24 | FromDiscord | <alice.> sent a code paste, see https://play.nim-lang.org/#ix=4ftw |
02:11:29 | FromDiscord | <Elegantbeef> ` (ref LexerError)(src: src, msg: msg, span: span, line: line)` |
02:11:37 | FromDiscord | <Elegantbeef> You are not converting to `ref LexerErro` |
02:11:38 | FromDiscord | <alice.> oh i dont put it twice? |
02:11:47 | FromDiscord | <Elegantbeef> you're constructing a `(ref LexerError)` |
02:11:54 | FromDiscord | <alice.> ah |
02:14:23 | FromDiscord | <alice.> sorry for my idiotness |
03:20:32 | * | arkurious quit (Quit: Leaving) |
03:40:25 | FromDiscord | <alice.> how would i implement a union type? |
03:41:30 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/tut1.html |
03:46:16 | FromDiscord | <alice.> @ElegantBeef i mean like a sum type |
03:46:24 | FromDiscord | <alice.> i cant fidn anything on here about it |
03:46:44 | FromDiscord | <alice.> unless i missed something |
03:47:01 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/tut2.html#object-oriented-programming-object-variants |
03:47:38 | FromDiscord | <Elegantbeef> There is also https://github.com/alaviss/union |
03:47:47 | FromDiscord | <alice.> thank you |
03:56:19 | FromDiscord | <JeysonFlores> What's the best strategy to not have global variables? I have a simple asyncHttpServer and some routes need to access to an object declared and initialized outside the http server handler, it doesn't give any error but there's that pesky warning alert when I compile my program |
03:57:10 | FromDiscord | <Elegantbeef> Pass a state object to the procedure |
03:59:28 | FromDiscord | <JeysonFlores> This is the declaration of the serve() procedure, and the module API doesn't show any proc that lets me modify the Request object before passing the callback https://media.discordapp.net/attachments/371759389889003532/1040113435452653631/image.png |
03:59:59 | FromDiscord | <Elegantbeef> What warning are you talking about anyway? |
04:00:25 | FromDiscord | <JeysonFlores> In reply to @Elegantbeef "What warning are you": Warning: 'cbIter' is not GC-safe as it accesses 'connections' which is a global using GC'ed memory [GcUnsafe2] |
04:00:38 | * | derpydoo quit (Quit: derpydoo) |
04:00:57 | FromDiscord | <JeysonFlores> It works, but if the compiler throws that warning is because there's a better way of doing it I guess |
04:02:12 | FromDiscord | <Elegantbeef> You can hide the warning for that if you wanted or convert that access to gcsafe |
04:03:33 | FromDiscord | <JeysonFlores> In reply to @Elegantbeef "You can hide the": how can I convert that access to gcsafe? |
04:04:03 | FromDiscord | <Elegantbeef> `{.cast(gcSafe).}: #Code here` |
04:07:01 | FromDiscord | <JeysonFlores> holy crap it worked |
04:07:19 | FromDiscord | <JeysonFlores> does gcsafe only works for safe global variable access operations? |
04:07:41 | FromDiscord | <JeysonFlores> (edit) "only works for" => "mean something about" |
04:07:50 | FromDiscord | <Elegantbeef> Basically it's just thread safety analysis |
04:08:35 | FromDiscord | <JeysonFlores> In reply to @Elegantbeef "`{.cast(gcSafe).}: #Code here`": Ok, so if I want any variable to be safely accessed through async procedures or threads this pragma is the way to go? |
04:09:09 | FromDiscord | <Elegantbeef> It doesnt make it safe it tells the compiler "I know what i'm doing" |
04:10:19 | FromDiscord | <JeysonFlores> so..... if I want to make it safe I have to use something like a Lock? |
04:17:25 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#ix=4ftP |
04:22:43 | FromDiscord | <Elegantbeef> you dont need the `of` you can just do `func2(base: BaseObj)` and `func2(obj: Child1)` |
04:24:27 | FromDiscord | <Elegantbeef> If you need it to use dynamic dispatch look at methods |
04:24:48 | FromDiscord | <user2m> ahhh gotcha ok I'll take a look see |
04:25:10 | FromDiscord | <huantian> it's weird that this doesn't work though |
04:25:16 | FromDiscord | <Elegantbeef> No it's not |
04:25:23 | FromDiscord | <Elegantbeef> `BaseObj` doesnt have `attrib2` |
04:26:03 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4ftQ |
04:26:05 | FromDiscord | <Elegantbeef> But at that point use procedures |
04:28:40 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#ix=4ftR |
04:28:44 | FromDiscord | <Elegantbeef> You dont need method here |
04:28:49 | FromDiscord | <user2m> Thanks @ElegantBeef that got it working! |
04:29:05 | FromDiscord | <user2m> isn't that how you do dynamic dispatching? |
04:29:11 | FromDiscord | <user2m> with the method keyword? |
04:30:41 | FromDiscord | <Elegantbeef> Yes but you arent using dynamic dispatch |
04:31:51 | * | pech quit (Quit: Leaving) |
04:32:04 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/F7u |
04:32:06 | FromDiscord | <Elegantbeef> That's dynamic dispatch |
04:33:47 | FromDiscord | <user2m> ahhh I see I need to do more reading on dynamic dispatch. Also could you link me some docs on the when keyword? I keep searching "nim when keyword" and coming up with nothing. The when keyword seems to be what make this work and I'm not sure why |
04:34:16 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/manual.html the holy grail |
04:34:21 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/manual.html#statements-and-expressions-when-statement |
04:35:23 | * | tanami quit (Ping timeout: 248 seconds) |
04:37:20 | FromDiscord | <user2m> Fantastic thank you! "The when statement enables conditional compilation techniques" I'm guessing this is why your solution worked? |
04:37:36 | FromDiscord | <user2m> https://media.discordapp.net/attachments/371759389889003532/1040123032947146783/image.png |
04:37:38 | FromDiscord | <Elegantbeef> Yes |
04:37:51 | FromDiscord | <user2m> amazing |
04:40:03 | FromDiscord | <huantian> sent a code paste, see https://play.nim-lang.org/#ix=4ftV |
04:40:14 | FromDiscord | <huantian> if you wanted to do the type check at runtime |
04:40:37 | FromDiscord | <Elegantbeef> Correct |
04:40:42 | FromDiscord | <Elegantbeef> But that's just dynamic dispatchin |
04:40:45 | FromDiscord | <huantian> ye |
04:58:04 | * | droidrage joined #nim |
05:01:32 | FromDiscord | <JeysonFlores> In reply to @Elegantbeef "`{.cast(gcSafe).}: #Code here`": is there any way to attach this pragme to the global variable declaration? is quite ugly putting this pragma in every use of the var |
05:02:03 | FromDiscord | <Elegantbeef> You can also just annotate your proc `{.gcsafe.}` and if threads are off it's gcsafe |
05:12:17 | FromDiscord | <JeysonFlores> mmm ok I think I get it and as long as I use locks to access that variable will be safe |
05:13:41 | * | rockcavera quit (Remote host closed the connection) |
05:13:45 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4fu2 |
05:17:47 | FromDiscord | <JeysonFlores> but you said that pragma will only tell the compiler that the following code is safe (without actually making it) so that means that in order to make it safe it's all up to me isn't it? |
05:18:04 | FromDiscord | <JeysonFlores> (edit) "me" => "me," |
05:18:16 | FromDiscord | <JeysonFlores> (edit) "but you said that pragma will only tell the compiler that the following code is safe (without actually making it) so that means that in order to ... make" added "actually" |
05:19:12 | FromDiscord | <JeysonFlores> and I searched and it seems that locks are the way to make safe reads/writes from different threads or async procedures |
05:19:27 | FromDiscord | <Elegantbeef> You dont need locks for async |
05:19:51 | FromDiscord | <JeysonFlores> In reply to @Elegantbeef "You dont need locks": so async procs can access global variables safely? |
05:20:13 | FromDiscord | <Elegantbeef> Yea there is no threading there |
05:20:33 | FromDiscord | <JeysonFlores> perfect. Thanks |
05:32:59 | FromDiscord | <user2m> sent a code paste, see https://paste.rs/k1A |
05:33:05 | FromDiscord | <user2m> sent a code paste, see https://paste.rs/SKG |
05:33:08 | FromDiscord | <user2m> I keep getting this error on what seems like a basic tempate |
05:33:09 | FromDiscord | <Elegantbeef> No return type |
05:33:32 | FromDiscord | <user2m> do you mean I should add a return type to the template? |
05:33:53 | FromDiscord | <Elegantbeef> Yes |
05:34:29 | FromDiscord | <user2m> ahh I see |
05:40:53 | FromDiscord | <baalajimaestro> Does nim go well with jemalloc? |
05:41:02 | FromDiscord | <baalajimaestro> I just tried it on python, and it improved memory usage by a nice amount |
05:42:03 | FromDiscord | <Rika> no, nim doesnt by default use malloc iirc, but you can make it with -d:useMalloc when compiling your code, then plugging jemalloc via however you'd do it on c as well |
05:46:41 | FromDiscord | <Elegantbeef> It's not too hard to change the allocator |
05:49:19 | FromDiscord | <pyryrin> Are pointers gc'd |
05:49:28 | FromDiscord | <Elegantbeef> No |
05:53:02 | FromDiscord | <scarf> would bigger stdlib better for nim? |
05:53:07 | FromDiscord | <Rika> no |
05:53:08 | FromDiscord | <scarf> (edit) "would bigger stdlib ... better" added "be" |
05:53:29 | FromDiscord | <scarf> could you tell me why? |
05:53:53 | FromDiscord | <Rika> developers are scarce |
05:54:17 | FromDiscord | <scarf> so it's because big stdlib is hard to maintain, right? |
05:54:50 | FromDiscord | <Rika> yes |
05:55:19 | FromDiscord | <scarf> i see |
06:03:12 | FromDiscord | <Prestige> I don't see anything really missing from the stdlib |
06:03:40 | FromDiscord | <Prestige> We could definitely improve on the preexisting stdlib though |
06:03:52 | FromDiscord | <Elegantbeef> `concepts.nim` so everyone has easy concepts that others can use 😛↵(@Prestige) |
06:04:11 | FromDiscord | <Prestige> Yeah, concepts would be great if finished... |
06:04:29 | FromDiscord | <Elegantbeef> That's not what i mean |
06:05:23 | FromDiscord | <Prestige> Wdym? |
06:06:12 | FromDiscord | <Elegantbeef> I mean a module that has a bunch of concepts for things like Vector2, Color and other types that others would want to abstract away |
06:07:04 | FromDiscord | <Prestige> Hmm interesting, haven't seen it. I just want my own concepts |
06:08:36 | FromDiscord | <Elegantbeef> https://github.com/beef331/truss3d/blob/master/src/truss3D/shaders.nim#L132-L168 is kinda stupid for anyone else to implement 😄 |
06:09:37 | FromDiscord | <Prestige> Looks nice |
06:10:04 | FromDiscord | <Prestige> I created an "Iterable" concept I'm using in a project, seems sane |
06:21:59 | FromDiscord | <ChocolettePalette> concept 😔 |
06:22:56 | FromDiscord | <ChocolettePalette> Aren't they experimental? |
06:23:08 | FromDiscord | <Elegantbeef> Experimental schemimental |
06:23:59 | FromDiscord | <ChocolettePalette> They are kinda cool doe |
06:36:47 | FromDiscord | <Rika> ngl id mark the whole nim language as experimental ~~ban in 3, 2, 1,~~ |
06:36:52 | FromDiscord | <Rika> is joke |
06:36:59 | FromDiscord | <Elegantbeef> "What is a spec" |
06:50:47 | FromDiscord | <ajusa> In reply to @Elegantbeef ""What is a spec"": "the implementation is the spec" |
06:51:58 | FromDiscord | <Rika> the spec is always wrong |
06:57:34 | FromDiscord | <Require Support> does `nim devel` and `--mm:orc` hate var parameters? `Error: 'handleRequest' is not GC-safe as it calls 'selectExt'` |
06:57:56 | FromDiscord | <Elegantbeef> The obviously dont hate var paramters |
07:02:22 | FromDiscord | <Require Support> https://github.com/status-im/nim-websock/blob/acbe30e9ca1e51dcbbfe4c552ee6f16c7eede538/websock/websock.nim#L317 have a program that uses websock and chronos but I think it fails to compile on devel and orc because of this.↵↵declared here and uses var params: https://github.com/status-im/nim-websock/blob/acbe30e9ca1e51dcbbfe4c552ee6f16c7eede538/websock/websock.nim#L57 |
07:04:09 | * | ltriant quit (Ping timeout: 260 seconds) |
07:05:00 | FromDiscord | <ShalokShalom> Concepts would be a good feature to advertise 2.0 |
07:08:38 | FromDiscord | <Rika> if only they werent that buggy |
07:09:19 | FromDiscord | <ringabout> In reply to @Require Support "does `nim devel` and": stricteffects on the devel branch sometimes requires explicit `gcsafe` pragmas. |
07:12:58 | FromDiscord | <Require Support> In reply to @ringabout "stricteffects on the devel": hey that worked, thanks. Idk what it does but at least it built something |
07:18:35 | FromDiscord | <EliasG2> is there a way to make an array with a size that is not known during compile time, yet cannot be resized once created? |
07:18:43 | FromDiscord | <Elegantbeef> `seq[T]` |
07:18:51 | FromDiscord | <Elegantbeef> Wrap that with a distinct |
07:18:59 | FromDiscord | <Elegantbeef> Someone really should make a fixed seq package |
07:20:10 | FromDiscord | <EliasG2> In reply to @Elegantbeef "Wrap that with a": how would that look? |
07:20:25 | FromDiscord | <Elegantbeef> `type FixedSeq[T] = distinct seq[T]` |
07:20:43 | FromDiscord | <EliasG2> and is it as efficient as if i knew the size and used an array? |
07:20:48 | FromDiscord | <Rika> no |
07:20:49 | FromDiscord | <Elegantbeef> Then implement all your operators and features as `FixedSeq` |
07:21:20 | FromDiscord | <EliasG2> In reply to @Elegantbeef "`type FixedSeq[T] = distinct": ok, thanks |
07:21:23 | FromDiscord | <Rika> the efficiency of an array is because the size is known specifically at compile time |
07:21:39 | FromDiscord | <Elegantbeef> The only efficieny difference is one is heap allocated |
07:22:03 | FromDiscord | <Rika> alloca go brr |
07:22:04 | FromDiscord | <Rika> sorry |
07:24:26 | FromDiscord | <EliasG2> In reply to @EliasG2 "ok, thanks": but how do i set the size when creating the sequence? |
07:25:03 | FromDiscord | <Require Support> https://nim-lang.org/docs/system.html#newSeqOfCap%2CNatural |
07:25:48 | FromDiscord | <EliasG2> In reply to @Require Support "https://nim-lang.org/docs/system.html#newSeqOfCap%2": ah |
07:26:28 | FromDiscord | <Elegantbeef> You might need to make it an object to keep the size persistent |
07:30:08 | FromDiscord | <alice.> hi all |
07:30:24 | FromDiscord | <alice.> is there a way i can reuse op here instead of having to do unaryOp and binOp? |
07:30:33 | FromDiscord | <alice.> sent a code paste, see https://play.nim-lang.org/#ix=4fun |
07:32:41 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4fuo |
07:33:43 | FromDiscord | <alice.> but this will mean that unless its unary theres only one left hand side? |
07:33:48 | FromDiscord | <alice.> unless im reading wrong |
07:34:35 | FromDiscord | <Elegantbeef> Sorry i meant `isBinary` |
07:34:40 | FromDiscord | <alice.> ah |
07:34:43 | FromDiscord | <alice.> gotcha |
07:35:21 | FromDiscord | <Elegantbeef> You could also use a flag on the node instead but that's up to you |
07:37:14 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4fur |
07:37:37 | FromDiscord | <Elegantbeef> This is likely better for memory consumption and possibly performance as it'll reduce heap allocation costs |
07:37:47 | FromDiscord | <alice.> gotchu |
07:37:53 | FromDiscord | <Elegantbeef> But you have to implement the checks if you accidently access `right` on a unary |
07:39:36 | * | PMunch joined #nim |
07:49:22 | * | ltriant joined #nim |
07:49:49 | FromDiscord | <ShalokShalom> sent a long message, see http://ix.io/4fus |
07:51:05 | FromDiscord | <Elegantbeef> I swear you dont read my messages |
07:51:32 | FromDiscord | <ShalokShalom> Give me a rehash 🙂 |
07:51:48 | * | kenran joined #nim |
07:51:51 | FromDiscord | <Elegantbeef> It's down to the author of the bindings to the dynamic library to dictate whether a procedure is pure or not |
07:52:06 | FromDiscord | <Elegantbeef> Nim cannot know if C code is pure so it's either impure or pure at the discretion of the binding author |
07:54:18 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4fuu |
07:55:15 | * | ltriant quit (Ping timeout: 260 seconds) |
07:56:40 | PMunch | @ShalokShalom, if I get what you're asking then no, that's not possible |
07:56:58 | PMunch | Nim doesn't actually understand the C code you try to call. It only knows how to call it. |
07:57:12 | FromDiscord | <ShalokShalom> Then dont compile |
07:57:14 | PMunch | There is no inspection of the C code at all to ensure that things are correct |
07:57:23 | FromDiscord | <Elegantbeef> I explained this all before pmunch |
07:57:30 | PMunch | Aight |
07:57:30 | FromDiscord | <ShalokShalom> If you dont know if its pure, treat it as none pure |
07:57:38 | FromDiscord | <Elegantbeef> Which Nim does |
07:57:49 | FromDiscord | <ShalokShalom> You suggested me otherwise? |
07:57:52 | FromDiscord | <Elegantbeef> The one that decides it's pure is the one that copies the bindings |
07:58:21 | FromDiscord | <ShalokShalom> You said, Nim trusts its user |
07:58:28 | FromDiscord | <Elegantbeef> It does |
07:58:41 | FromDiscord | <Elegantbeef> You can do `{.cast(noSideEffect).}` on sideffected code |
07:59:02 | FromDiscord | <Elegantbeef> There is no such thing as perfectly pure code, an allocation is a side effect |
07:59:04 | FromDiscord | <ShalokShalom> I haven't tried it myself, but I understood this so, that putting func and using a library in it from Godot, would compile |
07:59:59 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4fuv |
08:00:02 | FromDiscord | <ShalokShalom> In reply to @Elegantbeef "There is no such": I am asking for the default behavior. ↵↵Can I trust func to be pure in any setup to be pure for sure |
08:00:06 | * | FromDiscord quit (*.net *.split) |
08:00:06 | * | hexeme quit (*.net *.split) |
08:00:06 | * | qwr quit (*.net *.split) |
08:00:06 | * | Ekho quit (*.net *.split) |
08:00:06 | * | def- quit (*.net *.split) |
08:00:06 | * | mal`` quit (*.net *.split) |
08:00:06 | * | om3ga quit (*.net *.split) |
08:00:06 | * | dv^_^ quit (*.net *.split) |
08:00:06 | * | oisota quit (*.net *.split) |
08:00:07 | * | dom96 quit (*.net *.split) |
08:00:07 | * | void09 quit (*.net *.split) |
08:00:17 | * | qwr joined #nim |
08:00:18 | * | def-- joined #nim |
08:00:42 | * | def-- is now known as def- |
08:01:50 | * | om3ga joined #nim |
08:02:18 | * | void09 joined #nim |
08:02:28 | * | mal`` joined #nim |
08:02:48 | * | dom96 joined #nim |
08:04:23 | * | hexeme joined #nim |
08:12:10 | * | Ekho joined #nim |
08:16:04 | * | FromDiscord joined #nim |
08:16:20 | FromDiscord | <Elegantbeef> But hey it works https://wandbox.org/permlink/duuUegY0iSfXgprZ |
08:17:58 | FromDiscord | <ShalokShalom> In reply to @Elegantbeef "Overriding the compiler's side": You talk about specifically telling the compiler to make an exception. |
08:18:15 | FromDiscord | <Elegantbeef> Yes cause real code isnt cut dry |
08:18:23 | FromDiscord | <ShalokShalom> I talk about the compiler not telling the truth about purity. |
08:18:38 | FromDiscord | <Elegantbeef> I mean allocating is by definition impure |
08:18:53 | FromDiscord | <Elegantbeef> So like do you want to have a perfectly pure function, or do you want a reasonably pure function |
08:19:11 | FromDiscord | <Rika> what is the truth about purity |
08:19:14 | FromDiscord | <ShalokShalom> In reply to @Elegantbeef "Nim's side effect analysis": Unless you load a libary that is in Cpp |
08:19:25 | FromDiscord | <ShalokShalom> In reply to @Rika "what is the truth": That its pure. |
08:19:30 | FromDiscord | <Rika> define |
08:21:18 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4fuz |
08:21:24 | FromDiscord | <Elegantbeef> Like i said allocating is mutating global state |
08:21:37 | FromDiscord | <Elegantbeef> Even just growing/shrinking the stack mutates global state |
08:21:39 | FromDiscord | <Rika> ~~unsafe as fuck lmao~~ |
08:21:45 | FromDiscord | <Elegantbeef> Lol |
08:21:49 | FromDiscord | <Elegantbeef> The point stands |
08:22:02 | FromDiscord | <Elegantbeef> 100% pure code is pointless code |
08:22:40 | FromDiscord | <Elegantbeef> Even comparing values is impure as it writes to registers |
08:22:41 | FromDiscord | <Elegantbeef> So like how pure do we want |
08:22:41 | FromDiscord | <Elegantbeef> Do we want something usable or something pure |
08:23:54 | FromDiscord | <ShalokShalom> Pure as in Haskell |
08:23:59 | FromDiscord | <Rika> i really dont understand what you're aiming for |
08:24:00 | FromDiscord | <ShalokShalom> That's enough for me |
08:24:03 | FromDiscord | <Elegantbeef> So pure as in Nim |
08:24:04 | FromDiscord | <Elegantbeef> Got it |
08:24:10 | FromDiscord | <ShalokShalom> Its just that the state doesnt bite yoi |
08:24:30 | FromDiscord | <ShalokShalom> No, in Haskell you cant compile with a mutating library |
08:24:45 | FromDiscord | <Elegantbeef> Haskell has pointers |
08:24:51 | FromDiscord | <Rika> haskell has C binding ability |
08:24:54 | FromDiscord | <ShalokShalom> In reply to @Rika "i really dont understand": Lets say someone does a tutorial↵↵I plan to do so |
08:25:08 | FromDiscord | <ShalokShalom> Then you explain the people the sense behind func |
08:25:15 | FromDiscord | <ShalokShalom> And when you use proc instead |
08:25:27 | FromDiscord | <ShalokShalom> Then you go on and let them try their code |
08:25:44 | FromDiscord | <ShalokShalom> They use eg a Godot library and it is mutating state |
08:25:51 | FromDiscord | <ShalokShalom> They use it within a func |
08:26:02 | FromDiscord | <ShalokShalom> Why is that not nonsense? |
08:26:23 | FromDiscord | <ShalokShalom> This will go through, and the newbie will just be confused |
08:27:06 | FromDiscord | <Elegantbeef> Except if you use godot-nim they dont work with func iirc |
08:27:09 | FromDiscord | <Rika> can you show us what godot library is "incorrectly" marked as nosideeffectsd |
08:27:09 | FromDiscord | <Elegantbeef> So... |
08:27:17 | FromDiscord | <Elegantbeef> And again this is to the author |
08:27:23 | FromDiscord | <ShalokShalom> In reply to @Elegantbeef "Even comparing values is": You are constantly coming up with weird side cases. ↵↵I speak about using external code, that cant be verified. |
08:27:28 | FromDiscord | <Elegantbeef> The author of the C libraries has to annotated `noSideEffect` |
08:27:36 | FromDiscord | <Elegantbeef> It doesnt infer C api's as pure |
08:27:44 | FromDiscord | <Elegantbeef> So the same thing exists in haskell |
08:27:48 | FromDiscord | <Elegantbeef> Cause you depend on C-Apis |
08:27:48 | FromDiscord | <ShalokShalom> In reply to @Rika "can you show us": So far as I understand, is it not possible to check for purity in C/C++ libraries. |
08:27:58 | FromDiscord | <Elegantbeef> It is possible |
08:28:02 | FromDiscord | <Rika> why so? |
08:28:08 | FromDiscord | <Elegantbeef> A programmer can read the code and say "Yep this has no side effect" |
08:28:15 | FromDiscord | <ShalokShalom> In reply to @Elegantbeef "Except if you use": That would make a lot of sense |
08:28:22 | FromDiscord | <Rika> not all code can be proven, but that doesnt mean most code isnt provable |
08:28:42 | FromDiscord | <ShalokShalom> Somebody said C libs can not be proven at all |
08:28:51 | FromDiscord | <Elegantbeef> They cannot be proven by Nim |
08:28:54 | FromDiscord | <Elegantbeef> It doesnt read C |
08:29:02 | FromDiscord | <ShalokShalom> Yeah, what mean |
08:29:06 | FromDiscord | <Rika> beef youre starting to misunderstand now i believe |
08:29:08 | FromDiscord | <Elegantbeef> They can be proven by programmers or something that can speak C |
08:29:17 | FromDiscord | <ShalokShalom> He does all the time |
08:29:26 | FromDiscord | <Elegantbeef> Lol |
08:29:41 | FromDiscord | <ShalokShalom> In reply to @Elegantbeef "They can be proven": But until Nim can verify that, you dont compile |
08:29:51 | FromDiscord | <ShalokShalom> Dont compile, if you are uncertain |
08:29:55 | FromDiscord | <Elegantbeef> Well then nothing in Nim is pure cause it uses C allocation functions |
08:29:55 | FromDiscord | <ShalokShalom> Make guarantees |
08:30:07 | FromDiscord | <ShalokShalom> I want to trust you with my code. |
08:30:07 | FromDiscord | <Elegantbeef> So yay we're back to no pure functions |
08:30:25 | FromDiscord | <ShalokShalom> I care about loading libraries. |
08:30:39 | FromDiscord | <ShalokShalom> About practical applications |
08:30:54 | FromDiscord | <Rika> In reply to @ShalokShalom "Dont compile, if you": nim doesnt assume anything by default, only if a (not the) programmer decides they want to say "ok this is no side effects" will it assume it is NSE |
08:31:18 | FromDiscord | <ShalokShalom> Ok, isnt this was func is doing?/ |
08:31:29 | FromDiscord | <ShalokShalom> Doesnt it say 'this is pure' |
08:31:30 | FromDiscord | <Rika> no it is what cast(NSE) is doing |
08:31:48 | FromDiscord | <Rika> there's a difference between "make this pure" and "I fucking know this is pure" |
08:31:54 | FromDiscord | <ShalokShalom> And then there is strictFuncs and they still allow for impure libraries |
08:31:57 | FromDiscord | <Rika> func is the former |
08:32:00 | FromDiscord | <Rika> cast is the latter |
08:32:05 | FromDiscord | <ShalokShalom> Ok |
08:32:11 | FromDiscord | <Elegantbeef> Of course strictFuncs allow impure libraries |
08:32:28 | FromDiscord | <Elegantbeef> No one is going to disallow all third party libraries in a func |
08:32:32 | FromDiscord | <Elegantbeef> That neuters the language |
08:32:37 | FromDiscord | <jmgomez> The context of purity only makes sense in user's code |
08:32:41 | FromDiscord | <ShalokShalom> It makes it strict. |
08:32:47 | FromDiscord | <Elegantbeef> No it makes it pointless |
08:32:48 | FromDiscord | <ShalokShalom> In reply to @jmgomez "The context of purity": Yeah, thanks. |
08:33:34 | FromDiscord | <Elegantbeef> https://github.com/juancarlospaco/nim-easings/blob/master/src/easings.h let's use this example |
08:33:37 | FromDiscord | <ShalokShalom> In reply to @Rika "func is the former": Yeah. This is how I understand it and it shows, that potentially impure sources could be raising a warning |
08:33:40 | FromDiscord | <Elegantbeef> I read the code i know it has no side effect |
08:33:44 | FromDiscord | <ShalokShalom> Or dont compile |
08:33:44 | FromDiscord | <Elegantbeef> In your world that doesnt matter |
08:34:21 | FromDiscord | <Elegantbeef> We see this has 0 pointers and 0 global state, yet it's still impure code since Nim cannot detect that |
08:34:25 | FromDiscord | <ShalokShalom> In reply to @Elegantbeef "I read the code": You dont, very often. Sometimes there is a hidden side effect. ↵↵And I see this, as already stated, as a tool for newbies to rely on. |
08:34:38 | FromDiscord | <Elegantbeef> It's not |
08:34:51 | FromDiscord | <ShalokShalom> They understand the difference between pure and impure, apply it properly with func and proc and can rely on it |
08:34:53 | FromDiscord | <Elegantbeef> Func is a tool to ensure code has no side effect in Nim and if it does it allows you to manage it |
08:34:55 | FromDiscord | <ShalokShalom> Thats my vision. |
08:35:25 | * | ltriant joined #nim |
08:35:32 | FromDiscord | <Elegantbeef> You can either override the analysis and make the code function or solve the problem another way |
08:35:49 | FromDiscord | <Elegantbeef> I do not see why allowing C procedures to be called in func is a bad thing as any otherway would vastly diminish the usefulness of func |
08:35:55 | FromDiscord | <ShalokShalom> Once I load state mutating code from cpp into my Nim code, I see this as part of my Nim code. |
08:35:56 | FromDiscord | <Rika> well unfortunately i guess this is where "give programmers the choice" is a bad thing for you |
08:36:11 | FromDiscord | <ShalokShalom> As much a Python developers see NumPy as part of their Python |
08:36:13 | FromDiscord | <Elegantbeef> Well then dont use func↵(@ShalokShalom) |
08:36:19 | FromDiscord | <Rika> what? |
08:36:24 | FromDiscord | <Rika> what does that mean |
08:36:25 | FromDiscord | <ShalokShalom> In reply to @Rika "well unfortunately i guess": But then give me the choice |
08:36:34 | FromDiscord | <Elegantbeef> A pragmatist understands the limitations of their tools and knows where to use them and where not to |
08:36:34 | FromDiscord | <ShalokShalom> Give me the choice to have this strict |
08:36:50 | FromDiscord | <ShalokShalom> In reply to @Rika "what does that mean": What do you mean? |
08:36:55 | FromDiscord | <Rika> In reply to @ShalokShalom "But then give me": just look for any "noSideEffects" in your library code beforehand i think is what araq would say |
08:37:01 | FromDiscord | <Rika> In reply to @ShalokShalom "What do you mean?": i mean to beef |
08:37:19 | FromDiscord | <ShalokShalom> In reply to @Rika "just look for any": But this is a Nim feature?/ |
08:37:22 | FromDiscord | <Elegantbeef> What does what mean rika? |
08:37:25 | FromDiscord | <jmgomez> In reply to @ShalokShalom "Once I load state": Then you have to digging in the cpp code and make a wrapper that you can trust.. what's the problem you are trying to solve? |
08:37:34 | FromDiscord | <ShalokShalom> How can I apply this to any and all C libraries |
08:37:51 | FromDiscord | <Rika> In reply to @ShalokShalom "But this is a": i think its the same thing with araq and unsafety, "just grep for cast addr ptr" etc |
08:38:07 | FromDiscord | <ShalokShalom> In reply to @jmgomez "Then you have to": That the compiler does assume there is state changing stuff in a library, if it cant know for sure otherwise |
08:38:21 | FromDiscord | <ShalokShalom> And then raise a warning |
08:38:29 | FromDiscord | <ShalokShalom> Or prevent compilation |
08:38:56 | FromDiscord | <ShalokShalom> In reply to @Rika "i think its the": I mean, noSideEffects is a Nim feature |
08:39:03 | FromDiscord | <ShalokShalom> Its not a Cpp feature |
08:39:05 | FromDiscord | <jmgomez> In reply to @ShalokShalom "That the compiler does": but the compiler only assumes it if someone tells it to do it, right? If you think the person that did the wrapper is wrong. You can go ahead and override that, cant you? |
08:39:09 | FromDiscord | <Rika> that is what i mean |
08:39:20 | FromDiscord | <Rika> grep your nim libraries for those |
08:39:27 | FromDiscord | <ShalokShalom> And even it it would, I couldn't rely on the libraries author |
08:39:31 | FromDiscord | <Rika> since ofc you'd need to make nim bindings for your cpp libraries |
08:39:53 | FromDiscord | <Elegantbeef> I dont get how you can trust a library author enough to use their code but not enough that they know where to cast side effect safety |
08:40:03 | FromDiscord | <Rika> ill be out |
08:40:05 | FromDiscord | <Rika> i have work |
08:40:12 | FromDiscord | <ShalokShalom> Hnn, so you mean I could implement this on the bindings level? |
08:40:23 | FromDiscord | <ShalokShalom> And then even know for sure, what changes state? |
08:40:39 | FromDiscord | <ShalokShalom> It would be a tradeoff. But I could accept this |
08:41:39 | FromDiscord | <jmgomez> To specify the side effects on the bindings? Sure |
08:42:41 | FromDiscord | <jmgomez> But getting it right is tricky because of what you just said, it may be hard to know what the other side is exactly doing |
08:43:11 | FromDiscord | <ShalokShalom> Then just assume its impure |
08:43:25 | FromDiscord | <ShalokShalom> That's highly likely in a game engine library anyway |
08:43:31 | FromDiscord | <ShalokShalom> And also in many other cases |
08:43:38 | FromDiscord | <Elegantbeef> Nim does assume it's impure |
08:43:48 | FromDiscord | <Elegantbeef> We said this multiple times |
08:43:48 | FromDiscord | <ShalokShalom> Then show me this |
08:43:52 | FromDiscord | <ShalokShalom> And prevent compiling |
08:43:55 | FromDiscord | <ShalokShalom> Its that easy |
08:44:00 | FromDiscord | <ShalokShalom> Give me the choice |
08:44:10 | FromDiscord | <Elegantbeef> It does if a programmer didnt override it |
08:44:13 | FromDiscord | <jmgomez> The choice is there.. |
08:44:16 | FromDiscord | <Elegantbeef> If you're using a programmers code you ostensibly trust them |
08:44:24 | FromDiscord | <jmgomez> exactly |
08:44:29 | * | ltriant quit (Ping timeout: 260 seconds) |
08:44:40 | FromDiscord | <Elegantbeef> So why the fuck are you using their code if you dont trust where they put code |
08:44:56 | FromDiscord | <ShalokShalom> In reply to @jmgomez "The choice is there..": Without specifying this in the binding, ideally. |
08:45:06 | FromDiscord | <ShalokShalom> In reply to @Elegantbeef "So why the fuck": I trust them to be impure. |
08:45:12 | FromDiscord | <ShalokShalom> I dont try new users |
08:45:22 | FromDiscord | <ShalokShalom> Its not about the library author |
08:45:26 | FromDiscord | <Elegantbeef> You do realise that you're painting this picture that doesnt exist |
08:45:40 | FromDiscord | <Elegantbeef> no one is doing `proc myCFunc: int {.importc, nosideeffect.}` |
08:45:43 | FromDiscord | <ShalokShalom> https://discord.com/channels/371759389889003530/371759389889003532/1040180234181427212 |
08:46:02 | FromDiscord | <Elegantbeef> Ah yes link a discord link to the guy using matrix |
08:46:05 | FromDiscord | <ShalokShalom> In reply to @Elegantbeef "no one is doing": I am not caring about proc at all |
08:46:21 | FromDiscord | <ShalokShalom> I care about a Godot library being called within a func, that changes state. |
08:46:34 | FromDiscord | <Elegantbeef> Did the authors annotate it as `noSideEffect`? |
08:46:40 | FromDiscord | <Elegantbeef> You're bitching about a non existent issue |
08:47:14 | FromDiscord | <jmgomez> In reply to @ShalokShalom "I care about a": if that's true, it's wrong you can PR or Fork...? |
08:47:16 | FromDiscord | <ShalokShalom> https://media.discordapp.net/attachments/371759389889003532/1040185861066723348/Screenshot_20221110-0946472.png |
08:47:30 | FromDiscord | <Elegantbeef> I clearly went to discord and read it |
08:47:47 | FromDiscord | <ShalokShalom> Thy |
08:48:02 | FromDiscord | <Elegantbeef> There isnt a single `noSideEffect` in the godot docs |
08:48:06 | FromDiscord | <Elegantbeef> So why are you complaining? |
08:48:55 | FromDiscord | <Elegantbeef> > I am not caring about proc at all↵Also to this `proc{.noSideEffect.}` is a func |
08:49:01 | FromDiscord | <Elegantbeef> They're literally the same thing |
08:49:40 | FromDiscord | <Elegantbeef> But yes please do find me a `noSideEffect` proc from godot-nim |
08:49:57 | FromDiscord | <Elegantbeef> Just cause i'd like you to have an actual argument instead of inane rambling about a non issue |
08:50:18 | FromDiscord | <alice.> dumb question incominggg |
08:50:24 | FromDiscord | <alice.> how do i treat this enum like a string? |
08:50:27 | FromDiscord | <Elegantbeef> Better than what's happening |
08:50:36 | FromDiscord | <alice.> sent a code paste, see https://play.nim-lang.org/#ix=4fuJ |
08:51:41 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4fuK |
08:51:56 | FromDiscord | <Elegantbeef> Strutils `%` operator is very nice for things like this |
08:52:29 | FromDiscord | <alice.> im kinda confused whats happening here |
08:52:36 | FromDiscord | <alice.> how would i use this in place of |
08:52:46 | FromDiscord | <alice.> ` raise lexerError(lexer.src, LexerErrors.UnexpectedCharacter, span, lexer.line)↵` |
08:53:07 | FromDiscord | <Elegantbeef> `($LexerErrors.UnexpectedCharacter % $myChar)` |
08:53:37 | FromDiscord | <Elegantbeef> `%` replaces `$#` |
08:53:58 | FromDiscord | <Elegantbeef> You can also do `$1` if you prefer it being numbered |
08:54:23 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/strutils.html#%25%2Cstring%2CopenArray%5Bstring%5D |
08:54:42 | FromDiscord | <alice.> gotcha |
08:58:19 | FromDiscord | <alice.> @ElegantBeef how do i do more than one of these % substitutions |
08:58:28 | FromDiscord | <Elegantbeef> RTFM |
08:58:50 | FromDiscord | <alice.> oh i just chained %s |
08:59:02 | FromDiscord | <Elegantbeef> No it's an array |
08:59:12 | FromDiscord | <Elegantbeef> Do you not read docs? |
08:59:29 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/1040188938054291476/image.png |
08:59:34 | FromDiscord | <alice.> oh its an array |
08:59:43 | FromDiscord | <Elegantbeef> I'm going to go before i say something that causes someone to say "that's mean" |
08:59:45 | FromDiscord | <alice.> my brain thought they were ( ) |
09:00:13 | * | ltriant joined #nim |
09:07:14 | * | ltriant quit (Ping timeout: 260 seconds) |
09:20:41 | * | ox joined #nim |
09:20:52 | * | oz quit (Ping timeout: 246 seconds) |
09:27:52 | * | jmdaemon quit (Ping timeout: 252 seconds) |
09:33:42 | FromDiscord | <Tanguy> Is there a way to disable every hints except one? `--hint:SuccessX:on --hints:off` doesn't work |
09:33:56 | FromDiscord | <Tanguy> (the other way around doesn't work either) |
09:44:14 | om3ga | Hello guys! I binded meow_fft, but for some reason compiler wont find the meow_fft_generate_workset_real. What I miss? Here is example of the code: https://play.nim-lang.org/#ix=4fuZ <--- binds, https://play.nim-lang.org/#ix=4fv0 <--- what fails |
09:56:22 | FromDiscord | <alice.> is there a way to have one file refer to another? i want to split the expression parsing stuff and the regular parsing stuff into 2 files |
09:56:24 | FromDiscord | <alice.> for readability |
09:56:32 | FromDiscord | <alice.> but it causes a cyclic import |
09:59:52 | FromDiscord | <ChocolettePalette> You might need to consider changing architecture |
10:01:42 | FromDiscord | <alice.> how would i solve it? |
10:01:55 | FromDiscord | <alice.> i want the expression parsing and regular parsing not in one giant file |
10:01:57 | FromDiscord | <alice.> if possible |
10:02:05 | FromDiscord | <Elegantbeef> `include` |
10:02:18 | FromDiscord | <alice.> still doesnt work |
10:03:22 | FromDiscord | <alice.> expression_parser is like: https://pastebin.com/pTcrE6Q3↵parser is like: https://pastebin.com/BHjdBqP6 |
10:07:10 | FromDiscord | <alice.> how would i restructure this? |
10:08:35 | FromDiscord | <haxscramper> Damn these 350+ messages about funcs @Rika @ElegantBeef how do you manage that |
10:08:57 | FromDiscord | <Elegantbeef> Shitposting is my speciality |
10:10:14 | FromDiscord | <alice.> so yeah i need to restructure this so it doesn't have cyclic imports |
10:10:26 | FromDiscord | <Elegantbeef> Or use forward declares |
10:10:41 | FromDiscord | <alice.> that would work? |
10:10:44 | FromDiscord | <Elegantbeef> Yes |
10:10:47 | FromDiscord | <Elegantbeef> It's what Nim does |
10:11:02 | FromDiscord | <alice.> is that the best way to solve this or should i restructure it in a better way? |
10:16:38 | * | dv^_^ joined #nim |
10:17:20 | FromDiscord | <&Makarov/1> hello beautiful people https://media.discordapp.net/attachments/371759389889003532/1040208533200838656/image.png |
10:17:43 | FromDiscord | <&Makarov/1> why i need to use ref when declaring the Node type ? |
10:18:45 | FromDiscord | <Elegantbeef> Unless you have infinite memory there is no other way of doing it |
10:18:49 | FromDiscord | <Elegantbeef> You need some possible terminating |
10:19:13 | FromDiscord | <&Makarov/1> In reply to @Elegantbeef "Unless you have infinite": i didnt quite get it |
10:19:48 | FromDiscord | <&Makarov/1> alright i do :jo |
10:19:51 | FromDiscord | <&Makarov/1> (edit) ":jo" => "😂" |
10:19:54 | FromDiscord | <&Makarov/1> thanks ! |
10:20:13 | FromDiscord | <&Makarov/1> https://tenor.com/view/spongebob-squarepants-tired-sleepy-exhausted-sleep-deprived-gif-5215701 |
10:20:23 | FromDiscord | <&Makarov/1> m just like that 😂 ☝️ |
10:22:23 | FromDiscord | <ShalokShalom> In reply to @Elegantbeef "Just cause i'd like": I am fine with godot-nim↵↵I actually care about pupils, as said, you get used to this |
10:22:34 | FromDiscord | <ShalokShalom> They expect it to work under any condition |
10:23:29 | FromDiscord | <Rika> In reply to @haxscramper "Damn these 350+ messages": Consistent misunderstanding |
10:24:11 | FromDiscord | <rdb> In reply to @Elegantbeef "Jesus fucking christ 😄": The bindings are auto-generated, so code size wasn't actually a concern of mine. But I'll look at the other method you suggested. |
10:28:54 | FromDiscord | <rdb> Actually, code size is a bit of a concern because nim has a known bug where it can't count line numbers past 65535. 😅 |
10:29:28 | FromDiscord | <Elegantbeef> Shit now that just seems like a dick comment |
10:29:53 | FromDiscord | <Elegantbeef> It also slows the compiler down cause it still semantically checks them all |
10:31:18 | FromDiscord | <ShalokShalom> In reply to @rdb "Actually, code size is": That looks like the multiply of 64, or so? |
10:41:55 | FromDiscord | <offbeat-stuff (offbeat-stuff)> Hi, -\> could not import\: SSL\_get\_peer\_certificate |
10:42:01 | FromDiscord | <offbeat-stuff (offbeat-stuff)> openssl version↵OpenSSL 3.0.7 1 Nov 2022 (Library\: OpenSSL 3.0.7 1 Nov 2022) |
10:42:56 | FromDiscord | <offbeat-stuff (offbeat-stuff)> Artix linux , xanmod kernel |
10:43:05 | FromDiscord | <rdb> In reply to @ShalokShalom "That looks like the": It's the limit of an unsigned 16-bit integer. |
10:43:21 | FromDiscord | <offbeat-stuff (offbeat-stuff)> any idea how to fix it |
10:43:26 | FromDiscord | <offbeat-stuff (offbeat-stuff)> \> |
10:43:30 | FromDiscord | <offbeat-stuff (offbeat-stuff)> ? |
10:44:55 | FromDiscord | <offbeat-stuff (offbeat-stuff)> i get the error when running nimble |
10:45:11 | FromDiscord | <offbeat-stuff (offbeat-stuff)> or nim programs compiled with -d\:ssl |
10:45:27 | FromDiscord | <jmgomez> In reply to @rdb "Actually, code size is": From where that comes from? We have bindings with +150k LoC. are you using code reordering? |
10:45:30 | FromDiscord | <rdb> In reply to @Elegantbeef "Shit now that just": No offence taken. 🙂 The bindings are a proof-of-concept I mostly hacked up in a spare afternoon after learning about nim and without knowledge of dot operators just writing a for loop to dump out a bunch of swizzles seemed the quickest way to do it. 😛 |
10:45:36 | FromDiscord | <rdb> In reply to @jmgomez "From where that comes": Generated bindings. |
10:45:45 | FromDiscord | <rdb> (edit) "bindings." => "bindings for a huge C++ library." |
10:45:51 | FromDiscord | <jmgomez> I mean the idea of 65k limit |
10:46:00 | FromDiscord | <offbeat-stuff (offbeat-stuff)> does nim not support openssl 3? |
10:46:11 | FromDiscord | <jmgomez> Are you using the code reordering pragma? |
10:46:15 | FromDiscord | <rdb> In reply to @jmgomez "I mean the idea": https://github.com/nim-lang/Nim/issues/15165 |
10:47:00 | FromDiscord | <jmgomez> Ohh the limit of the error not the limit of the code size. Gotcha |
10:47:39 | FromDiscord | <rdb> Right. Tbf it goes above the limit mostly because I have the textual documentation comments from the original C++ library included. |
10:48:06 | FromDiscord | <jmgomez> But if you don’t have errors it should be good. Still that needs to be fixed oc |
10:48:21 | FromDiscord | <jmgomez> Again, we have files bigger than that in NimForUE |
10:51:12 | FromDiscord | <rdb> Cool, so both our bindings are for 3D game engines |
10:52:16 | FromDiscord | <jmgomez> That’s great. Which one are you binding? |
10:52:46 | FromDiscord | <rdb> Panda3D https://github.com/rdb/nim-panda3d |
10:55:19 | FromDiscord | <rdb> Elegantbeef: Hmm, dot operators are an experimental feature, it seems. That may be why I've not considered them before. |
10:57:02 | * | ltriant joined #nim |
11:03:19 | * | ltriant quit (Ping timeout: 260 seconds) |
11:12:24 | * | ltriant joined #nim |
11:35:43 | FromDiscord | <Rika> In reply to @offbeat-stuff (offbeat-stuff) "does nim not support": No, use 1.1 |
11:52:27 | FromDiscord | <rdb> Can I make a custom dot operator macro "fail" in some way, so that a regular "undeclared identifier" error is generated by nim? |
11:52:59 | FromDiscord | <offbeat-stuff (offbeat-stuff)> thanks↵(@Rika) |
11:53:19 | FromDiscord | <offbeat-stuff (offbeat-stuff)> had to download a different package |
11:53:40 | FromDiscord | <rdb> (edit) "identifier"" => "field"" |
11:56:19 | FromDiscord | <alice.> In reply to @alice. "so yeah i need": how would i do this btw |
11:58:22 | FromDiscord | <ringabout> In reply to @offbeat-stuff (offbeat-stuff) "does nim not support": The devel branch has added openssl 3 support. |
11:58:57 | FromDiscord | <vindaar> can you clarify what you mean? I mean in what case should it work and in which fail?↵(@rdb) |
12:00:38 | FromDiscord | <rdb> In reply to @vindaar "can you clarify what": Normally, when I access `obj.blargh` I get an error like "undeclared field 'blargh' of type whatever"↵I have defined a custom dot operator macro so I can do `obj.xzzy`↵But now doing `obj.blargh` no longer results in an error message, it just gets substituted as a void type symbol↵Of course I can call `error()` in my macro and generate my own error, but is there a cleaner way? |
12:02:34 | FromDiscord | <rdb> I want users of my API to be able to do `obj.xzzy` (which works fine) but continue to get a helpful error message when doing `obj.blargh` |
12:05:23 | FromDiscord | <rdb> It looks like just doing something like ``result = quote do: `field`(`this`)`` in the "else" case gets me pretty close, it generates an undeclared identifier error so maybe that's good enough |
12:08:46 | FromDiscord | <vindaar> If you really need dot operator macros, then yes as far as I'm aware either calling `error` or "letting it fail" by constructing the resulting code anyway are the only two options |
12:09:45 | FromDiscord | <vindaar> I do the same here https://github.com/SciNim/Unchained/blob/master/src/unchained/units.nim#L475-L478 and it gives acceptable error messages |
12:13:37 | FromDiscord | <scarf> In reply to @Avahe "I don't see anything": could definitely use RAII or context manager (python `with`) or python's pathlib (3rd party one is 3y old and unmaintained) |
12:18:33 | PMunch | Hmm, Prologue just hard crashed on me |
12:18:37 | PMunch | free(): double free detected in tcache 2 |
13:10:24 | * | kenran quit (Remote host closed the connection) |
13:11:16 | FromDiscord | <dlesnoff> In reply to @PMunch "free(): double free detected": At least the C error is clear, have you looked at the generated C code? |
13:11:37 | * | dnh joined #nim |
13:12:02 | FromDiscord | <dlesnoff> (edit) "code?" => "code's corresponding line? (If it doesn't give a line, have you run valgrind on it?" |
13:14:07 | FromDiscord | <dlesnoff> sent a code paste, see https://play.nim-lang.org/#ix=4fvv |
13:15:23 | FromDiscord | <dlesnoff> I am on nim 1.6.8. Does this works on earlier Nim versions? |
13:19:10 | FromDiscord | <planetis> sent a code paste, see https://play.nim-lang.org/#ix=4fvw |
13:33:30 | PMunch | @dlesnoff, well the full error stack looks like this: http://ix.io/4fvy |
13:34:07 | FromDiscord | <ringabout> How about the devel branch? |
13:36:27 | PMunch | Hmm, I'm unable to build this on devel |
13:36:45 | PMunch | regex.nim(856, 18) Error: Exception can raise an unlisted exception: Exception |
13:37:02 | FromDiscord | <ringabout> Update regex version |
13:37:05 | PMunch | Ah, never mind |
13:37:07 | PMunch | Yeah |
13:37:28 | PMunch | Hmm, it runs fine on devel |
13:38:00 | FromDiscord | <ringabout> The devel branch defaults to ORC though. |
13:38:35 | PMunch | I tried to build with ORC on the stable branch as well |
13:38:39 | PMunch | But that still errored out |
13:39:20 | FromDiscord | <ringabout> How about using `--mm:refc` with devel? |
13:43:37 | FromDiscord | <ringabout> https://github.com/nim-lang/website/pull/347 |
13:44:17 | FromDiscord | <ringabout> v2 is coming. |
13:44:35 | PMunch | I tried with the 1.6.10 rc now with refc and it worked fine |
13:44:48 | * | derpydoo joined #nim |
13:45:04 | FromDiscord | <ringabout> nice |
13:47:12 | PMunch | By the way, it's also logging things incorrectly |
13:47:22 | FromDiscord | <dlesnoff> Well I couldn't guess the errors from the stack 🤔 |
13:47:31 | PMunch | I reply with a 201 CREATED, but the log still says DEBUG 200 OK |
13:49:06 | FromDiscord | <ringabout> That's weird |
13:57:28 | * | arkurious joined #nim |
14:02:25 | * | PMunch quit (Quit: Leaving) |
14:04:03 | * | disso_peach joined #nim |
14:18:07 | FromDiscord | <fbpyr> sent a long message, see https://paste.rs/7jR |
14:19:19 | FromDiscord | <fbpyr> sent a code paste, see https://play.nim-lang.org/#ix=4fvO |
14:25:49 | FromDiscord | <scarf> sent a code paste, see https://play.nim-lang.org/#ix=4fvT |
14:30:05 | FromDiscord | <Rika> `when tail is string: (new version)`↵`else: (the original body)` |
14:30:14 | FromDiscord | <Rika> I’m on a phone |
14:30:40 | Zevv | Is there any magic in nim allowing a fallthrough in a case? ie, omitting the 'break' in the generated C code? |
14:30:48 | FromDiscord | <Rika> Even then it doesn’t matter, the cast doesn’t generate code iirc |
14:30:59 | FromDiscord | <Rika> “Cast” we call it conversion here in Nim |
14:31:03 | FromDiscord | <Rika> Cast is another thing |
14:31:09 | FromDiscord | <Rika> In reply to @Zevv "Is there any magic": No |
14:31:17 | Zevv | that's what I thought :/ |
14:31:56 | FromDiscord | <scarf> In reply to @Rika "Even then it doesn’t": would `"foo".string` be same to `"foo"` (in compiled binary)? |
14:32:18 | FromDiscord | <Rika> I’m not sure but I would think so |
14:32:30 | FromDiscord | <scarf> (edit) "binary)?" => "binary)?↵since i get this warning: `conversion from string to itself is pointless [ConvFromXtoItselfNotNeeded]`" |
14:32:35 | FromDiscord | <Rika> Please test, I don’t have a computer to confirm on right now |
14:32:43 | FromDiscord | <Rika> But I recall it being the same |
14:32:55 | FromDiscord | <Rika> That’s just a warning, sure |
14:34:23 | * | derpydoo quit (Quit: derpydoo) |
14:55:16 | FromDiscord | <zajrik> sent a long message, see http://ix.io/4fvY |
14:57:03 | FromDiscord | <zajrik> (edit) "http://ix.io/4fvY" => "http://ix.io/4fw0" |
15:12:28 | FromDiscord | <haxscramper> Result has isSome, isNone? |
15:14:42 | * | derpydoo joined #nim |
15:15:01 | FromDiscord | <zajrik> Yes and no. It has those as shortcuts for it's own isOk and isErr, but when I tried to use the shortcuts the compiler would only pick up Option procs and gave compiler errors. After setting the fieldElement in the Match to "isOK" and "isErr" respectively, it worked as expected |
15:16:38 | FromDiscord | <zajrik> I'm able to do `if Ok(@val) ?= foo` and use it in case statement macros and its great 👍 |
15:17:21 | FromDiscord | <zajrik> And same with `Err(@val)` |
15:17:38 | FromDiscord | <haxscramper> Well, I guess editing the source code is the way to go then. I don't exactly remember all implementation details and I thought isNone being present will fix the issue |
15:18:05 | FromDiscord | <haxscramper> You can try haxscramper/hmatching on GitHub |
15:18:10 | FromDiscord | <haxscramper> Fusion is dead anyway |
15:18:25 | FromDiscord | <haxscramper> In reply to @haxscramper "You can try haxscramper/hmatching": Can't guarantee this one will work though |
15:19:27 | FromDiscord | <zajrik> Oh really?? I had no idea it was dead |
15:19:42 | FromDiscord | <zajrik> I've been away from nim for quite some time now |
15:19:56 | FromDiscord | <haxscramper> Well, it doesn't move anywhere |
15:20:14 | FromDiscord | <haxscramper> It doesn't stink either, so someone might mistake it for sleeping |
15:20:21 | FromDiscord | <haxscramper> But I think it is dead |
15:20:31 | FromDiscord | <haxscramper> You can poke it with a PR/issue though |
15:20:47 | FromDiscord | <haxscramper> Hopefully it will make some funny noises |
15:20:52 | FromDiscord | <haxscramper> Like "PRS are welcome" |
15:21:13 | FromDiscord | <zajrik> I mean, it's still definitely functioning, and I wouldn't want to add support for an external lib to an internal lib, seems silly |
15:21:44 | FromDiscord | <haxscramper> You copied the source code whole anyway |
15:22:55 | FromDiscord | <zajrik> I should clarify, I wouldn't want to add official support for an external lib in an internal lib lol |
15:23:08 | FromDiscord | <zajrik> Doing it for my own little work project is fiiiine |
15:23:49 | FromDiscord | <haxscramper> Oh yeah that of course |
15:23:58 | FromDiscord | <haxscramper> Hmatching is just a fork of fusion/matching |
15:24:13 | FromDiscord | <haxscramper> With six months of work that nobody bothered to merge |
15:24:31 | FromDiscord | <zajrik> Oof. Any noteworthy additions? |
15:25:42 | FromDiscord | <tope> sent a long message, see http://ix.io/4fwl |
15:27:13 | FromDiscord | <tope> or is this thinking just entirely wrong and I should never mark arguments as sink? (so far I've only marked unary operators as sink, marking binary generates a ton of superfluous copies when arguments are not last-use) |
15:28:26 | * | derpydoo quit (Remote host closed the connection) |
15:33:51 | FromDiscord | <haxscramper> In reply to @zajrik "Oof. Any noteworthy additions?": nothing for Result |
15:38:56 | FromDiscord | <deech> @haxscramper Does hmatching have exhaustiveness checking? |
15:39:06 | FromDiscord | <haxscramper> no |
15:39:17 | FromDiscord | <haxscramper> it is too hard to implement |
15:39:30 | FromDiscord | <deech> Hah! Yes, yes it is. 🙂 |
15:40:03 | FromDiscord | <deech> Trying to get that really puts a damper on the kinds of matching features you can offer. |
15:40:11 | FromDiscord | <ShalokShalom> In reply to @haxscramper "Fusion is dead anyway": Shouldnt this then be announced? |
15:40:19 | FromDiscord | <haxscramper> hah lol |
15:40:22 | FromDiscord | <haxscramper> it should |
15:40:27 | FromDiscord | <haxscramper> next quesion |
15:40:28 | FromDiscord | <ShalokShalom> There is a blog post, that actually encourages using it |
15:40:29 | FromDiscord | <haxscramper> who cares? |
15:40:31 | FromDiscord | <haxscramper> answer: nobody |
15:40:32 | FromDiscord | <ShalokShalom> Ok.. |
15:40:34 | FromDiscord | <ShalokShalom> Me? |
15:40:46 | FromDiscord | <haxscramper> you do, core devs don't |
15:41:01 | FromDiscord | <ShalokShalom> You agree? |
15:41:25 | FromDiscord | <haxscramper> I mean, it is effectively dead, not officially. I agree that projects should announce whether they are actively maintained or not |
15:41:33 | FromDiscord | <haxscramper> like nimble that ships almost two-year-old version |
15:41:39 | FromDiscord | <haxscramper> fusion that hasn't seen updates in god knows what |
15:41:50 | FromDiscord | <ShalokShalom> Particularly when they were announced quite big quite recently as the hot new thing |
15:41:51 | FromDiscord | <haxscramper> drnim that is dead on arrival and had request to be removed |
15:42:03 | FromDiscord | <ShalokShalom> I mean particularly the pattern matching post |
15:42:19 | FromDiscord | <haxscramper> 1 It was a year and a half ago( |
15:42:28 | FromDiscord | <haxscramper> 2 when I wrote it the fusion was part of default shipping |
15:42:37 | FromDiscord | <haxscramper> 3 I literally watched the shit go down the drain before my eyes |
15:42:41 | FromDiscord | <ShalokShalom> Yeah, its one of the more recent blog posts, if I am not mistaken. |
15:42:46 | FromDiscord | <haxscramper> it was unbundled right when I was writing the article |
15:42:59 | FromDiscord | <haxscramper> and never cared for after |
15:43:01 | FromDiscord | <haxscramper> (edit) "and never cared for after ... " added "that" |
15:43:12 | FromDiscord | <ShalokShalom> In reply to @haxscramper "3 I literally watched": Would you explain? 🤪 |
15:43:14 | FromDiscord | <deech> That's a shame, it could clean up a lot of compiler code. |
15:43:28 | FromDiscord | <ShalokShalom> Unbundled? |
15:43:43 | FromDiscord | <ShalokShalom> In reply to @deech "That's a shame, it": Cyo does this 😋 |
15:44:12 | FromDiscord | <haxscramper> In reply to @ShalokShalom "Unbundled?": https://github.com/nim-lang/fusion/pull/33 merge my work into fusion |
15:44:17 | FromDiscord | <haxscramper> https://github.com/nim-lang/Nim/pull/16925 |
15:44:23 | FromDiscord | <ShalokShalom> In reply to @haxscramper "With six months of": Ah, I see. |
15:44:24 | FromDiscord | <haxscramper> unbundle fusion couple weeks later |
15:44:27 | FromDiscord | <ShalokShalom> Thanks |
15:44:35 | FromDiscord | <ShalokShalom> Crazy |
15:45:19 | FromDiscord | <ShalokShalom> What a squandering |
15:45:44 | FromDiscord | <ShalokShalom> Its also rude against you |
15:45:45 | FromDiscord | <haxscramper> In reply to @deech "That's a shame, it": It could, but, well, FP and compiler implementation are not exactly friends with all this mutable state and so on |
15:45:59 | FromDiscord | <haxscramper> But the compiler itself could see a lot of improvements from the functional approaches |
15:46:24 | FromDiscord | <haxscramper> Even just `Result` and `Option` could make the code cleaner in lots of places |
15:46:57 | FromDiscord | <ShalokShalom> In reply to @haxscramper "It doesn't stink either,": Lets conclude it with sleep walking |
15:47:12 | FromDiscord | <haxscramper> damn that's a good one |
15:47:56 | FromDiscord | <deech> Not necessarily functional but so much of the compiler is just checking for nil and accessing a couple of fields. `Result` and `Option` are more or less unusable with matching. Type inference isn't good enough for a workflow based solely on map and flatmap. |
15:48:16 | FromDiscord | <deech> (edit) "with" => "without" |
15:48:32 | FromDiscord | <ShalokShalom> In reply to @haxscramper "it is too hard": What would help you, to implement this? 👀 |
15:49:28 | FromDiscord | <ShalokShalom> In reply to @deech "Not necessarily functional but": Type inference in Nim, you might say and yes, I pattern matching and option go hand in hand |
15:50:30 | FromDiscord | <haxscramper> I'm not sure if it is even possible in the current matching implementation - it can do `{key: @value}`, and you can't exhaustively check for all `keys` in table for example. There might be a strict mode or certain edge cases. It might be possible to come up with an intermediate solution for this, something that only supports some edge cases |
15:50:59 | FromDiscord | <haxscramper> But I haven't looked into this in too much detail to be honest, because it requires a big effort to identify possible places where the exhaustiveness checking is applicale |
15:51:31 | FromDiscord | <haxscramper> Also this will most likely transition the macro from `untyped` to `typed` domain, which is a much bigger problem |
15:51:31 | FromDiscord | <ShalokShalom> Have you looked, how others do it?/ |
15:51:41 | FromDiscord | <haxscramper> other languages? |
15:51:47 | FromDiscord | <ShalokShalom> Yes |
15:51:57 | FromDiscord | <haxscramper> 1 they have it as a compiler built-in so the information is readily available to them |
15:51:59 | FromDiscord | <ShalokShalom> Like, how are they doing it?/ |
15:52:08 | FromDiscord | <haxscramper> 2 I don't think I've see thing like `{key:}` anywhere |
15:52:21 | FromDiscord | <ShalokShalom> How is it not a compiler plugin for us |
15:52:22 | FromDiscord | <haxscramper> 3 IIRC the algorithm is still exponential, there was a Rust article about that |
15:52:36 | FromDiscord | <haxscramper> In reply to @ShalokShalom "How is it not": have you seen the quote in the documentation? |
15:53:01 | FromDiscord | <haxscramper> https://media.discordapp.net/attachments/371759389889003532/1040293007200628797/image.png |
15:53:25 | FromDiscord | <ShalokShalom> Macro is not the first choice 🙂 |
15:53:54 | FromDiscord | <deech> You can simply force an `else` , poor man's exhaustiveness checking. |
15:54:03 | FromDiscord | <ShalokShalom> You can.. Doesnt mean 'you should write half of the stdlib as macros' |
15:54:52 | FromDiscord | <zajrik> No, absolutely not. A compiler built-in would be the best option, but a macro is certainly the fastest way to get solid pattern matching coverage out there until such a time that a true, compiler supported solution can come about |
15:55:30 | FromDiscord | <ShalokShalom> Nim is 15 years old |
15:55:35 | FromDiscord | <zajrik> It gets the job done for now. Hopefully someday we'll see the real thing |
15:55:51 | FromDiscord | <ShalokShalom> Pattern matching is not exactly an exotic feature |
15:56:11 | FromDiscord | <haxscramper> macro allows to make experiments without creating an overly bloated compiler with millions of `--experimental` switches |
15:56:22 | FromDiscord | <ShalokShalom> I see. Makes sense |
15:56:24 | FromDiscord | <haxscramper> it allows to discuss the implementation without getting bogged down in details |
15:56:30 | FromDiscord | <haxscramper> of the compiler internals |
15:56:35 | FromDiscord | <haxscramper> because the thing is largely self-contained |
15:56:57 | FromDiscord | <haxscramper> In reply to @ShalokShalom "Nim is 15 years": asm is 1920 years old |
15:57:14 | FromDiscord | <haxscramper> on the more serious note |
15:57:40 | FromDiscord | <haxscramper> feels weird to write stdlib modules for a language that was created when I went to the first class in school |
15:57:47 | FromDiscord | <haxscramper> (edit) "class" => "grade" |
15:58:05 | FromDiscord | <ShalokShalom> Wow |
15:58:13 | FromDiscord | <haxscramper> In reply to @zajrik "It gets the job": Maybe the built-in implementation will be smaller, feature-wise |
15:58:17 | FromDiscord | <ShalokShalom> A quarter of a million people have seen the fireship video |
15:58:33 | FromDiscord | <haxscramper> There are a lot of things that might be too hard to implement fully correct |
15:58:50 | FromDiscord | <haxscramper> exhaustiveness is one of them |
15:58:56 | FromDiscord | <haxscramper> current impl effectively makes it too hard |
15:59:02 | FromDiscord | <haxscramper> smaller impl might work |
15:59:13 | FromDiscord | <zajrik> It would definitely be a ground-up kind of thing |
15:59:14 | FromDiscord | <ShalokShalom> Smaller in features, like..? |
15:59:33 | FromDiscord | <ShalokShalom> Would other work on the compiler contribute to do this easier? |
15:59:45 | FromDiscord | <ShalokShalom> Like, is there any groundwork that can be done |
16:00:29 | FromDiscord | <haxscramper> I think implementation-wise this still can be done in a manner similar to macro |
16:00:38 | FromDiscord | <haxscramper> Just with `PNode` instead of `NimNode` |
16:00:59 | FromDiscord | <haxscramper> So there is not a lot of additional groundwork needed aside from actually implementing it |
16:01:06 | FromDiscord | <haxscramper> and of course coming up with a design and rationale |
16:02:32 | FromDiscord | <dlesnoff> In reply to @ShalokShalom "A quarter of a": youtube views aren't equal to the number of people that watched it.↵There are far less different people than views. |
16:04:03 | FromDiscord | <ShalokShalom> In reply to @Jiezron "youtube views aren't equal": Isnt that accounted for? |
16:04:07 | FromDiscord | <jmgomez> @haxscramper that's sad to know that fusion is abandoned. I stopped using using case for pattern matching after this: https://github.com/nim-lang/Nim/issues/20435 so pretty quickly.. Do you have any idea of what to fix in order to make that work? |
16:04:28 | FromDiscord | <ShalokShalom> Like, I know they account for views who quit in under 10 seconds, and such |
16:05:34 | FromDiscord | <ShalokShalom> In reply to @haxscramper "and of course coming": That's why I asked about the other languages. |
16:05:46 | FromDiscord | <ShalokShalom> Did you seek inspiration at them? |
16:06:11 | FromDiscord | <ShalokShalom> To come up with a design. |
16:07:07 | FromDiscord | <haxscramper> In reply to @Jiezron "youtube views aren't equal": https://plausible.io/nim-lang.org?period=30d |
16:07:51 | FromDiscord | <deech> IMO it's best to come up ways it can concretely help now. Like, X is a bug that wouldn't have happened if we had it etc. |
16:08:08 | FromDiscord | <haxscramper> In reply to @jmgomez "<@608382355454951435> that's sad to": haven't seen this issue, but IIRC this is a known problem because untyped-macros-un-generics and so on |
16:08:32 | FromDiscord | <haxscramper> https://github.com/nim-lang/fusion/pull/33#issuecomment-716140197 |
16:08:42 | FromDiscord | <haxscramper> In reply to @ShalokShalom "To come up with": yes |
16:09:42 | FromDiscord | <ShalokShalom> Plausible looks good |
16:20:05 | FromDiscord | <Tanguy> For what it's worth, we are using Result & Option without matching at a fairly large scale↵And sure, it's not as nice, but works |
16:29:03 | * | jmdaemon joined #nim |
16:30:28 | * | oisota joined #nim |
16:33:58 | FromDiscord | <zajrik> It's a pretty simple patch to support matching Results :Eyes: but yeah, they're totally fine to work with without matching. I'm just a sucker for cleaner code and less repetition |
16:38:01 | FromDiscord | <zajrik> I didn't know that about case statement macros not working in generic procedures though, thats rough |
16:39:46 | FromDiscord | <Phil> In reply to @Tanguy "For what it's worth,": You're stuck with only being able to return 1 exception type, aren't you? |
16:40:02 | FromDiscord | <Phil> Trying to recall what I saw of the result docs like half a year ago when I looked at them |
16:41:30 | FromDiscord | <Tanguy> That's specific to result (or monads) in general, not a question of pattern matching |
16:41:55 | FromDiscord | <jmgomez> In reply to @zajrik "It's a pretty simple": well most of the time you use functors around them and only need pm to concrete it or actually produce the effect |
16:42:14 | FromDiscord | <jmgomez> In reply to @Isofruit "You're stuck with only": doesnt exception has dynamic dispatching? |
16:42:50 | FromDiscord | <Phil> In reply to @jmgomez "doesnt exception has dynamic": It was more that Result isn't set up that you can have like 1 "success"-result and N "failure"-results encapsuling N different exceptions why it failed |
16:43:12 | FromDiscord | <Phil> Or at least that's what I meant and how I perceived the Result type at the time |
16:43:35 | FromDiscord | <Tanguy> What one of our team does is use `Result[T, CatchableError]` to get around this, which isn't great imo (I'm a Result absolutist though) |
16:44:23 | FromDiscord | <Tanguy> But Result allows you to use non-gced type as error, which is not possible with exception |
16:44:35 | FromDiscord | <Phil> I fully agree that Result is really nice, but I'd like to be able to explicitly communicate with the caller method "I failed because I didn't have a db connection" vs "I failed because the connection you gave me was nil" |
16:44:54 | FromDiscord | <Tanguy> Then you would use an enum |
16:45:05 | FromDiscord | <Tanguy> as error type |
16:45:13 | FromDiscord | <Phil> But then you have an enum per method where you want to use result |
16:45:30 | FromDiscord | <Phil> well, more than 1 exception-type-result |
16:45:31 | FromDiscord | <Tanguy> (I meant "I'm not a Result absolutist", typo) |
16:45:56 | FromDiscord | <Phil> Now that changes the meaning dramatically 😄 |
16:47:12 | FromDiscord | <Tanguy> Yup 🙂 If you want to see lively discussions about results vs exception, this thread is nice https://github.com/status-im/nim-codex/discussions/41↵And also contains my point of view |
16:47:40 | * | joast joined #nim |
16:47:45 | FromDiscord | <jmgomez> In reply to @Isofruit "It was more that": You could have a failure as variant, that's what I do |
16:47:51 | FromDiscord | <Phil> Lively as in lots of participants or lively as in people loosing it? |
16:48:24 | FromDiscord | <Phil> In reply to @jmgomez "You could have a": Same issue as with enum, now you have a variant per result that has more than 1 failure reason, feels like a lot of extra code |
16:50:32 | FromDiscord | <jmgomez> In reply to @Isofruit "Same issue as with": Dont follow that last part. Either you express the error in the type system or you dont.. not sure how exceptions can be better there. i.e. you need an exception type per error |
16:51:24 | FromDiscord | <jmgomez> But oc, both approaches can be mixed.. I guess this is more of a style/opinated discussion rather than a technical one |
16:52:27 | FromDiscord | <Freyr> Can I ask about problems I'm having with my code in this channel? |
16:53:11 | FromDiscord | <Phil> In reply to @jmgomez "Dont follow that last": I'm more contrasting it against the way Rust does it than weighing it against exceptions in general.↵In rust you just go `Result<Type, ErrorType1, ErrotType2, ErrorType3.... etc.>` , the errortype thing is basically an openarray equivalent |
16:53:17 | FromDiscord | <Phil> And yeah Freyr, this is the channel for that |
16:53:45 | FromDiscord | <Phil> (edit) "equivalent" => "equivalent. ↵And then you can match against all of them" |
16:54:15 | FromDiscord | <Phil> I guess to build the equivalent you'd basically have to generate a varObject from the type definition you throw into the proc |
16:55:11 | FromDiscord | <jmgomez> In reply to @Isofruit "I'm more contrasting it": like a new type per error, just in there? So you endup with an arity of errors +1? That's seem a bit of a mess TBH. What I proposed was to expand the error type, rather than result |
16:55:32 | FromDiscord | <zajrik> In reply to @Inkyrius "Can I ask about": I sure hope so because otherwise I've been doing it in the wrong place lol |
16:56:50 | FromDiscord | <Freyr> sent a code paste, see https://play.nim-lang.org/#ix=4fwI |
16:58:51 | FromDiscord | <Freyr> `echo (some(5) >>= (x => some(x+1))).value` is what I'm actually running |
16:59:03 | FromDiscord | <Phil> In reply to @jmgomez "like a new type": Basically, you literally throw in the errortype, you don't have to define a new type↵`fn main() -> Result<(), UpErrorType> {` , you'd just add types after UpErrorType |
17:02:21 | * | rockcavera joined #nim |
17:02:21 | * | rockcavera quit (Changing host) |
17:02:21 | * | rockcavera joined #nim |
17:04:53 | FromDiscord | <jmgomez> sent a code paste, see https://play.nim-lang.org/#ix=4fwN |
17:05:26 | FromDiscord | <Freyr> Wait no I think I've found what's causing it |
17:05:47 | FromDiscord | <Freyr> It works if I replace the `=>` from sugar with a full `proc` |
17:06:00 | FromDiscord | <Freyr> `echo (some(5) >>= (proc (n: int): Maybe[int] = some(n+1))).value` runs fine |
17:07:10 | FromDiscord | <Phil> In reply to @Inkyrius "`echo (some(5) >>= (proc": You might be running into issues with the order of macro evaluation (this is me doing wild guesses) |
17:07:30 | * | tanami joined #nim |
17:10:21 | FromDiscord | <rdb> In reply to @vindaar "If you really need": I don't "need" dot operator macros, but I got chewed out here for not using them, so... |
17:13:07 | FromDiscord | <Freyr> In reply to @Isofruit "You might be running": Seems to be related to passing generic functions to other generic functions, replacing the lambda with `proc addOne[A](n: A): Maybe[A] = some(n+1)` doesn't work but `proc addOne(n: int): Maybe[int] = some(n+1)` does |
17:14:30 | FromDiscord | <Freyr> Even if you define the generic `addOne` before the `>>=` |
17:15:56 | FromDiscord | <Phil> In reply to @Inkyrius "Seems to be related": What I can tell you is that when I start passing procs around within generic procs, I typically have the procs explicitly defined without using sugar and within my generic procs I try to do some compile-time assigning to a variable I later don't use, just to get better type checking |
17:17:08 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4fwQ |
17:17:21 | FromDiscord | <Phil> readArticleById is an explicitly defined proc elsewhere, as are all the other procs |
17:18:05 | FromDiscord | <Phil> I could pass in readArticleById etc. directly into `createUpdateHandler` but by doing so, if I accidentally fuck up somewhere, I get the compiler to tell me "I failed to assign this proc at line X" instead of the cryptic output it would normally give me |
17:18:28 | FromDiscord | <Phil> Maybe something similar could be applicable to your scenario? |
17:18:52 | FromDiscord | <jmgomez> In reply to @Inkyrius "Seems to be related": It may be an issue with auto. Did you try to explicitly use the type in the lambda argument? |
17:19:17 | FromDiscord | <jmgomez> i.e. (x:MyType)=>blabla instead of (x)=>blabla |
17:21:02 | FromDiscord | <Freyr> Yep that works |
17:22:02 | FromDiscord | <Freyr> Wonder why it doesn't work if I make it a generic named function rather than a lambda |
17:22:25 | FromDiscord | <Freyr> The compiler should be able to tell what the types are there |
17:41:06 | FromDiscord | <dlesnoff> As a beginner, I wish something like this tutorial [Learning Nim: Macros and Pattern Matching](https://www.youtube.com/watch?v=GJpn6SfR_1M). I did not manage to make this old code work again. |
17:48:23 | FromDiscord | <ShalokShalom> In reply to @Jiezron "As a beginner, I": https://dev.to/beef331/demystification-of-macros-in-nim-13n8 |
17:48:26 | FromDiscord | <ShalokShalom> Maybe not the same |
17:48:34 | FromDiscord | <ShalokShalom> I found it enlightening |
17:55:38 | FromDiscord | <Rika> In reply to @haxscramper "": when the fuck did i get quoted |
17:55:40 | FromDiscord | <Rika> damn |
18:41:12 | * | pro joined #nim |
18:42:28 | * | xet7 quit (Remote host closed the connection) |
18:45:19 | * | xet7 joined #nim |
18:57:18 | FromDiscord | <ShalokShalom> Your 15 minutes of fame are gone |
18:57:49 | FromDiscord | <ShalokShalom> That quickly puff 💨 |
19:15:51 | FromDiscord | <alice.> what's the best ways to modularize a large file in nim and not deal w cyclic dependency? |
19:18:38 | FromDiscord | <michael_zks> sent a long message, see http://ix.io/4cn1 |
19:19:45 | FromDiscord | <alice.> i'm not clicking that link lmao |
19:27:01 | FromDiscord | <huantian> <@&371760044473319454> |
19:31:10 | FromDiscord | <ShalokShalom> In reply to @alice. "what's the best ways": There is |
19:32:03 | FromDiscord | <ShalokShalom> https://nim-lang.org/docs/manual_experimental.html#code-reordering |
19:50:43 | FromDiscord | <dlesnoff> In reply to @ShalokShalom "https://dev.to/beef331/demystification-of-macros-in": The @ElegantBeef tutorial helped me to understand macros, but I wish to understand better getType, getTypeImpl, and pattern matching. |
19:51:39 | FromDiscord | <ShalokShalom> Well, pattern matching is currently in reconstruction anyway |
19:51:55 | FromDiscord | <ShalokShalom> But I get it |
19:55:07 | FromDiscord | <alice.> sent a long message, see http://ix.io/4fxB |
19:55:16 | FromDiscord | <ShalokShalom> In reply to @haxscramper "With six months of": Araw is asking in #internals for the details on this, I think 🙂 |
19:55:24 | FromDiscord | <ShalokShalom> (edit) "Araw" => "Araq" |
19:55:56 | FromDiscord | <haxscramper> Well, I don't care |
19:56:01 | FromDiscord | <ShalokShalom> Ok |
19:56:02 | FromDiscord | <alice.> https://paste.gg/p/anonymous/fd1541fac2a345dbb4623e3098622e87 |
19:56:16 | FromDiscord | <alice.> im not sure why this is happening |
19:56:23 | FromDiscord | <haxscramper> I said to him everything I wanted on the forum a year ago |
19:56:28 | FromDiscord | <alice.> (edit) "long message," => "code paste," | "http://ix.io/4fxB" => "https://play.nim-lang.org/#ix=4fxC" |
19:57:17 | FromDiscord | <alice.> building w verbose gives me |
19:57:23 | FromDiscord | <alice.> what am i doing wrong here? |
19:57:24 | FromDiscord | <alice.> sent a code paste, see https://play.nim-lang.org/#ix=4fxD |
19:57:47 | FromDiscord | <Elegantbeef> `Error: attempting to call undeclared routine: 'parseRelational'` |
19:57:55 | FromDiscord | <alice.> except it is declared? |
19:57:57 | FromDiscord | <ShalokShalom> Do you have the pull request at hand that tries to merge it?/ |
19:58:17 | FromDiscord | <alice.> @ElegantBeef i sent the files in the paste.gg link which cause this |
19:58:37 | FromDiscord | <Elegantbeef> I personally say dont usecode reordering |
19:58:52 | FromDiscord | <alice.> yeah that didnt fix shit |
19:58:59 | FromDiscord | <alice.> i commented it and it still cant find them |
19:59:03 | FromDiscord | <haxscramper> In reply to @ShalokShalom "Do you have the": There is a closed PR in fusion |
19:59:20 | FromDiscord | <Elegantbeef> you dont export expression |
19:59:27 | FromDiscord | <alice.> wdym? |
19:59:36 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4fxE |
19:59:37 | FromDiscord | <alice.> oh |
19:59:39 | FromDiscord | <Elegantbeef> Nim doesnt export symbols you import automatically |
19:59:56 | FromDiscord | <Elegantbeef> It only exports symbols you tell it to so anything marked with `` |
20:00:02 | FromDiscord | <Elegantbeef> Or if you `export x` |
20:06:15 | FromDiscord | <alice.> gotcha |
20:09:38 | FromDiscord | <ShalokShalom> Wait, there is an alternative to 👀 |
20:09:49 | FromDiscord | <Elegantbeef> Kinda but not really |
20:10:12 | FromDiscord | <Elegantbeef> export is meant to export modules or symbols from modules you import |
20:12:09 | FromDiscord | <ShalokShalom> Ah, I see. |
20:12:19 | FromDiscord | <ShalokShalom> Is it possible with a macro? |
20:12:27 | FromDiscord | <ShalokShalom> 😜 |
20:13:07 | FromDiscord | <Elegantbeef> Can you write the code normally? |
20:13:28 | * | krux02 joined #nim |
20:13:32 | FromDiscord | <vestel> Can I disable nim's dead code elimination? |
20:13:48 | FromDiscord | <Elegantbeef> No |
20:14:04 | FromDiscord | <Elegantbeef> I mean you can do `{.exportC.}` on procedures, but you cannot disable it otherwise |
20:14:20 | FromDiscord | <vestel> it kinda breaks my opaque predicates |
20:14:45 | FromDiscord | <Elegantbeef> What? |
20:15:14 | FromDiscord | <vestel> if statements that always evals to true |
20:15:25 | FromDiscord | <vestel> used as obfuscation |
20:17:30 | FromDiscord | <Elegantbeef> So you mean constant folding |
20:17:54 | FromDiscord | <Elegantbeef> Dead code elimination is removing unused code, not evaluating static code |
20:18:03 | FromDiscord | <alice.> sent a code paste, see https://paste.rs/qnH |
20:18:10 | FromDiscord | <Elegantbeef> compiler with `--implicitStatic:off` |
20:18:11 | FromDiscord | <Freyr> Is there any good documentation of how concepts work in nim? |
20:18:11 | FromDiscord | <Elegantbeef> compile even |
20:18:37 | FromDiscord | <alice.> the fact that i have to use unique names is kinda annoying |
20:18:52 | FromDiscord | <Elegantbeef> You can always base it off the Nim AST |
20:18:59 | FromDiscord | <alice.> wdym? |
20:19:03 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/manual_experimental.html#concepts is it↵(@Freyr) |
20:19:10 | FromDiscord | <Elegantbeef> You can always go copy how the Nim AST works |
20:19:20 | FromDiscord | <alice.> which is how exactly |
20:19:27 | FromDiscord | <Elegantbeef> You can go read the source |
20:19:28 | FromDiscord | <Elegantbeef> Cmon |
20:20:52 | FromDiscord | <alice.> so they have seperate types? |
20:21:48 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/Nim/blob/devel/compiler/ast.nim#L779-L797 |
20:21:59 | FromDiscord | <Elegantbeef> The seperate types are due to the original being in pascal |
20:23:59 | FromDiscord | <alice.> im confused af |
20:25:15 | FromDiscord | <alice.> how do i break it down into structs?? |
20:25:41 | FromDiscord | <Elegantbeef> What? |
20:26:40 | FromDiscord | <alice.> i dont want one massive ASTNode for every kind |
20:26:51 | FromDiscord | <alice.> i want to dispatch based on its .kind and then return a specialized struct |
20:26:54 | FromDiscord | <alice.> inheriting from it |
20:27:11 | FromDiscord | <Elegantbeef> Well then use inheritance and have a very slow compiler |
20:27:47 | FromDiscord | <alice.> In reply to @alice. "i dont want one": i just dont want it to be confusing af |
20:28:05 | * | krux02 quit (Remote host closed the connection) |
20:28:07 | FromDiscord | <alice.> In reply to @Elegantbeef "https://github.com/nim-lang/Nim/blob/devel/compiler": also this is way too confusing to read |
20:28:11 | FromDiscord | <alice.> i have no idea what they are doing |
20:28:42 | * | krux02 joined #nim |
20:30:24 | FromDiscord | <Elegantbeef> Complex AST is just a sequence |
20:30:31 | FromDiscord | <alice.> In reply to @alice. "is there a better": because if i do this i cant have any duplicate names |
20:30:47 | FromDiscord | <alice.> so how should i do this |
20:31:08 | FromDiscord | <Elegantbeef> So instead of specialising a bunch of data like you're doing you'd just have a sequence of AstNodes for things that are more than 1 |
20:31:24 | FromDiscord | <alice.> could u give an example? |
20:32:05 | FromDiscord | <Elegantbeef> In Nim a procedure call is a `nkCall(nkIdent)` |
20:32:37 | FromDiscord | <EliasG2> how would i do something like this? i want to make a ecs thing, and all types of component have a list of types of component they need, this does not work https://media.discordapp.net/attachments/371759389889003532/1040363370387357786/image.png |
20:32:47 | FromDiscord | <Elegantbeef> so it'd be like `PNode(kind: nkCall, sons: @[PNode(kind: nkIdent, name: procName), arg1, arg2, arg3)])` |
20:33:16 | FromDiscord | <Elegantbeef> Types dont exist at runtime so you cannot make a method operate that way |
20:33:28 | FromDiscord | <EliasG2> (edit) "how would i do something like this? i want to make" => "sent" | "ecs thing, and all types of component have a list of types of component they need, this does not work" => "code paste, see https://play.nim-lang.org/#ix=4fxN" |
20:33:34 | FromDiscord | <Elegantbeef> Also if you're using methods/OOP you're not making an ECS but likely an EC |
20:33:44 | FromDiscord | <voidwalker> string of size 4 representing big endian number, to uint32 little endian, best way ? |
20:34:04 | FromDiscord | <EliasG2> In reply to @Elegantbeef "Types dont exist at": how would i then do? |
20:34:07 | FromDiscord | <Elegantbeef> `std/endians` + `copyMem` |
20:34:12 | FromDiscord | <alice.> @ElegantBeef im still confused could u give an example of how i would implement this |
20:34:46 | * | pro quit (Quit: pro) |
20:35:01 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4fxR |
20:35:30 | FromDiscord | <alice.> and why do i want this |
20:35:30 | FromDiscord | <alice.> i just want distinct types |
20:35:35 | FromDiscord | <Elegantbeef> You'd need `method hasAllComponents(ent: Entity): bool`↵(@EliasG2) |
20:35:38 | FromDiscord | <alice.> for binary expressions, variables etc |
20:35:52 | FromDiscord | <Elegantbeef> Well then do it your way |
20:36:06 | FromDiscord | <alice.> is it not possible? |
20:36:12 | FromDiscord | <Elegantbeef> I dont know what you want |
20:36:21 | FromDiscord | <alice.> ill write a idealistic example |
20:37:22 | FromDiscord | <EliasG2> In reply to @Elegantbeef "You'd need `method hasAllComponents(ent:": if that is supposed to check if the entity has all required components for a component, it would still need to know what kind of component i am checking for |
20:37:28 | * | jjido joined #nim |
20:38:19 | FromDiscord | <alice.> sent a code paste, see https://play.nim-lang.org/#ix=4fxS |
20:38:20 | FromDiscord | <Elegantbeef> Well then make it `hasAllComponent(comp: Component)` |
20:38:27 | FromDiscord | <Elegantbeef> Yes like i said alice you want OOP |
20:38:29 | FromDiscord | <Elegantbeef> So go use oop |
20:38:39 | FromDiscord | <Elegantbeef> Method dispatch + oop |
20:39:05 | FromDiscord | <alice.> is this a bad way to do it? |
20:39:11 | FromDiscord | <EliasG2> In reply to @Elegantbeef "Well then make it": so i would need an instance of the component to check it, i cannot use types? |
20:39:15 | FromDiscord | <alice.> i just dont want a massively overcomplicated ast |
20:39:16 | FromDiscord | <Elegantbeef> You can even make a template for this elias |
20:42:17 | FromDiscord | <EliasG2> In reply to @Elegantbeef "You can even make": how would that work? the small section from https://nim-lang.org/docs/tut2.html#generics is all i have read about them |
20:43:07 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4fxT |
20:43:10 | FromDiscord | <Elegantbeef> Sorry a template lacks the required capabillities |
20:43:15 | FromDiscord | <Elegantbeef> A macro would be required |
20:43:26 | FromDiscord | <Elegantbeef> Also are you actually after an ECS or a Unity like EC? |
20:44:07 | FromDiscord | <alice.> how would i best represent this in a cleaner way |
20:44:13 | FromDiscord | <alice.> using OOP seems like a antipattern |
20:44:15 | FromDiscord | <Elegantbeef> An ECS is a specifically designed API that is highly efficient for cache and memory and does not use methods |
20:44:31 | FromDiscord | <Elegantbeef> I told you how I'd do it you didnt want to do it that way so dont ask me |
20:44:44 | FromDiscord | <alice.> what is your children even for??? |
20:44:49 | FromDiscord | <alice.> in the example u gave |
20:44:52 | FromDiscord | <Elegantbeef> All the children nodes |
20:45:03 | FromDiscord | <Elegantbeef> In the example i gave it'd be the name of the procedure and arguments |
20:45:04 | FromDiscord | <alice.> but i want to dispatch based on their KIND |
20:45:18 | FromDiscord | <Elegantbeef> Case statements exist |
20:45:19 | FromDiscord | <EliasG2> In reply to @Elegantbeef "An ECS is a": i am probably just making an ec, then |
20:45:20 | FromDiscord | <voidwalker> In reply to @Elegantbeef "`std/endians` + `copyMem`": code please ? :\ What am I supposed to be copying and why ? There's somethign funky with the string memory. If I manually assign its values to array[4, uint8], I get the right result, directly with the string not |
20:45:29 | FromDiscord | <alice.> but then i have to have variables that have unique names |
20:47:00 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4fxX |
20:47:24 | FromDiscord | <EliasG2> In reply to @EliasG2 "i am probably just": the components on the entities will just hold data, and i will then have a proc for each component (that needs one) that most likely loops over all entities and updates them |
20:47:47 | FromDiscord | <Elegantbeef> https://github.com/enthus1ast/ecs might help you elias |
20:48:03 | FromDiscord | <Elegantbeef> That sounds like ECS |
20:48:09 | FromDiscord | <Elegantbeef> So you're doing it completely wrong |
20:48:36 | FromDiscord | <Elegantbeef> Method and OOP is to be avoided for ECS |
20:48:51 | FromDiscord | <Elegantbeef> You use simple structs and have low level operations to allocate and manage |
20:49:22 | FromDiscord | <Elegantbeef> This isnt a very good ECS that one should use but it's a very light one on macros https://github.com/beef331/nimtrest/blob/master/yeacs.nim |
20:49:31 | FromDiscord | <Elegantbeef> Polymorph also exists but i doubt you'd want to read that |
20:50:03 | FromDiscord | <EliasG2> In reply to @Elegantbeef "Method and OOP is": how would i make a base component that the components extend without a little bit of oop? |
20:53:42 | FromDiscord | <Elegantbeef> I dont really count stack based OOP as oop but yea you do it stack wise |
20:53:47 | FromDiscord | <Elegantbeef> Like yeacs does |
20:54:17 | FromDiscord | <Elegantbeef> You dont use `ref object of X` you do `object of X` and store the layout of the archetype elsewhere |
20:54:30 | FromDiscord | <Elegantbeef> This way when operating on the data it's fast as you have small types that are contiguously stored |
20:56:38 | FromDiscord | <voidwalker> blah, so the bytes of the int I need to convert are 0 0 0 192. I get 3221225472 as value for both leInt and beInt. It's supposed to be 192 |
20:57:41 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4fy1 |
20:57:59 | FromDiscord | <Elegantbeef> When i query for given components i instantiate the components then check which position they are in, then i yield all of the components that way |
20:58:04 | FromDiscord | <Elegantbeef> Well you kinda lied 😄↵(@voidwalker) |
20:58:09 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4fy2 |
20:58:10 | FromDiscord | <voidwalker> I did ? |
20:58:16 | FromDiscord | <Elegantbeef> You dont want a uint32 you want each byte in reverse |
20:58:46 | FromDiscord | <voidwalker> of course I want a uint32, it's a 4 byte long number.. |
20:59:44 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4fy3 |
20:59:50 | FromDiscord | <Elegantbeef> You said you have `0 0 0 192` and expect the result to be 192 |
21:00:20 | FromDiscord | <voidwalker> isn't big/little endians the bytes in reverse? |
21:03:52 | FromDiscord | <Elegantbeef> You then likely dont have BE |
21:04:17 | FromDiscord | <Elegantbeef> Cause 3221225472 is 0 0 0 192 flipped |
21:05:20 | FromDiscord | <voidwalker> The length prefix is a four byte big-endian value. :\ |
21:06:19 | FromDiscord | <Elegantbeef> I dont know what to say |
21:09:27 | FromDiscord | <voidwalker> so you mean 0 0 0 192 is actually little endian ? |
21:11:23 | * | rockcavera quit (Remote host closed the connection) |
21:11:51 | * | rockcavera joined #nim |
21:13:33 | FromDiscord | <Elegantbeef> No clue |
21:13:38 | FromDiscord | <auxym> `0 0 0 192` is 192 in BE |
21:14:06 | FromDiscord | <auxym> https://en.wikipedia.org/wiki/Endianness#/media/File:Big-Endian.svg |
21:17:24 | FromDiscord | <auxym> I'm not a huge fan of the endians module personally, consider using the `READ32BE` macro defined here (https://justine.lol/endian.html), translated to nim. This way you can read a single byte at a time from your stream and `or` it into your result. |
21:30:21 | FromDiscord | <voidwalker> oh lol, I was actually looking for the ` swapEndian32` proc |
21:32:28 | FromDiscord | <voidwalker> so I just needed ` swapEndian32(addr leInt, addr msgLenS[0])` |
21:44:16 | * | ltriant quit (Ping timeout: 252 seconds) |
22:03:39 | * | ltriant joined #nim |
22:08:12 | * | xet7 quit (Read error: Connection reset by peer) |
22:19:43 | * | nyeaa49284 quit (Quit: Ping timeout (120 seconds)) |
22:19:59 | * | nyeaa49284 joined #nim |
22:20:22 | FromDiscord | <auxym> yeah, that's (one reason) why I'm not a big fan of `std/endians`, the naming of procs isn't super clear and the types (`pointer`) don't help either |
22:25:58 | FromDiscord | <voidwalker> uhm can i define a string using decimal values for the chars ? |
22:27:33 | FromDiscord | <Elegantbeef> `var a = "\xaa\xaa\xaa"` |
22:28:01 | FromDiscord | <voidwalker> that's hex |
22:29:09 | FromDiscord | <Elegantbeef> same thing |
22:29:10 | FromDiscord | <Elegantbeef> `"\101\102"` |
22:34:02 | * | jmd_ joined #nim |
22:34:27 | * | jmdaemon quit (Ping timeout: 255 seconds) |
22:39:17 | * | jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…) |
22:42:35 | FromDiscord | <voidwalker> is there maybe some more versatile/efficient (async) socks library to be using rather than the std one ? |
22:42:52 | FromDiscord | <voidwalker> for a task like a torrent client |
22:43:39 | FromDiscord | <voidwalker> (edit) "socks" => "sockets" |
22:48:42 | * | dnh quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
22:55:51 | FromDiscord | <auxym> you mean std/asyncnet? |
22:57:42 | * | euantorano quit (Read error: Software caused connection abort) |
22:57:52 | * | euantorano joined #nim |
23:00:35 | FromDiscord | <auxym> you could also probably access raw socket stuff in chronos |
23:15:03 | * | xet7 joined #nim |
23:32:05 | * | LuxuryMode joined #nim |
23:40:09 | * | krux02 quit (Remote host closed the connection) |
23:52:39 | FromDiscord | <Freyr> sent a code paste, see https://play.nim-lang.org/#ix=4fyu |