00:00:07 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dbg |
00:00:34 | FromDiscord | <Elegantbeef> Are you sure your file is open, are you sure you're not reading outside of the string or file |
00:00:45 | FromDiscord | <Elegantbeef> Are you sure your string is intialised |
00:00:49 | FromDiscord | <sOkam!> how can i check for those? |
00:01:11 | FromDiscord | <sOkam!> In reply to @Elegantbeef "Are you sure your": does readFile initialize the string on asignment? |
00:01:59 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dbi |
00:02:21 | FromDiscord | <sOkam!> (edit) "https://play.nim-lang.org/#ix=4dbi" => "https://play.nim-lang.org/#ix=4dbj" |
00:03:47 | FromDiscord | <sOkam!> (edit) "https://play.nim-lang.org/#ix=4dbj" => "https://paste.rs/hAK" |
00:05:52 | FromDiscord | <Patitotective> In reply to @sOkam! "What can this type": send some code |
00:06:05 | FromDiscord | <sOkam!> its a bit complex, which is why i didn't. but will do |
00:15:37 | FromDiscord | <sOkam!> This is the code for the error. Tried to condense it a bit, but its a lot anyway. Sry about that↵https://dpaste.com/HNG6BE6U9 |
00:16:04 | FromDiscord | <Elegantbeef> What is line 91? |
00:16:06 | FromDiscord | <sOkam!> If you see some lib import missing, the are actually in the files |
00:16:23 | FromDiscord | <sOkam!> The output of compiling? |
00:16:35 | FromDiscord | <Elegantbeef> `proc decodeTga(data: string): Tga =` |
00:16:35 | FromDiscord | <Elegantbeef> you dont do `new result` |
00:16:38 | FromDiscord | <Elegantbeef> QED |
00:17:05 | FromDiscord | <sOkam!> I thought result exists by default without creating it 🤔 |
00:17:13 | FromDiscord | <Elegantbeef> It's a ref type |
00:17:17 | FromDiscord | <Elegantbeef> You need to heap allocate the memory |
00:17:21 | FromDiscord | <sOkam!> ah kk |
00:18:05 | FromDiscord | <sOkam!> `result = new result`? |
00:18:11 | FromDiscord | <Elegantbeef> `new ressult` |
00:19:11 | FromDiscord | <sOkam!> ah yeah, that fixes that issue. tysm! |
00:30:26 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dbp |
00:30:31 | FromDiscord | <Elegantbeef> > index out of bounds, the container is empty |
00:30:47 | FromDiscord | <sOkam!> I can read |
00:31:01 | FromDiscord | <sOkam!> I wouldn't ask if I understood what that means |
00:31:14 | FromDiscord | <Elegantbeef> It means you're attempting to index out of the range of the collection |
00:31:28 | FromDiscord | <Elegantbeef> It's a defect cause it's supposed to be handled in logic and not try except |
00:32:48 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dbq |
00:33:35 | FromDiscord | <sOkam!> if that's not the problem, I don' |
00:33:45 | FromDiscord | <sOkam!> (edit) "don'" => "don't understand where the issue is coming from" |
00:34:53 | FromDiscord | <auxym> the full stacktrace should tell you where the error is from |
00:35:18 | FromDiscord | <sOkam!> it doesn't, else I wouldn't be asking |
00:36:02 | FromDiscord | <sOkam!> Oh, nvm, it does. it points to that for loop line |
00:36:18 | FromDiscord | <sOkam!> and how is that out of range? 🧩 |
00:37:11 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dbr |
00:38:14 | FromDiscord | <Elegantbeef> How is `width` and `height` calculated? |
00:38:20 | FromDiscord | <sOkam!> comes from the header |
00:38:46 | FromDiscord | <sOkam!> the size of the image is 64x64, and its being read correctly. checked with some echos and it prints 64 correctly |
00:38:55 | FromDiscord | <Elegantbeef> So that code clearly isnt the index error |
00:39:04 | FromDiscord | <Elegantbeef> Index errors require indexing |
00:40:13 | FromDiscord | <Elegantbeef> That's all error |
00:40:17 | FromDiscord | <Elegantbeef> you do not set the result |
00:40:18 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dbs |
00:40:35 | FromDiscord | <sOkam!> oh the same as before |
00:40:54 | FromDiscord | <sOkam!> kk, never handled ref types before, so I guess the whole file is gonna be full of them |
00:41:03 | FromDiscord | <Elegantbeef> This isnt even a ref issue |
00:41:04 | FromDiscord | <Elegantbeef> it's a seq issue |
00:41:16 | FromDiscord | <sOkam!> what's the diff? |
00:41:18 | FromDiscord | <Elegantbeef> you're doing `[i]` without doing `result = newSeq[T](size)` |
00:51:34 | FromDiscord | <! Nilts> How would i turn an array of hex colors into a png in nim? |
00:53:24 | FromDiscord | <exelotl> Use nimPNG: https://github.com/jangko/nimPNG |
00:58:04 | FromDiscord | <! Nilts> In reply to @exelotl "Use nimPNG: https://github.com/jangko/nimPNG": how would i install it? |
00:58:21 | FromDiscord | <! Nilts> oops. |
00:58:22 | FromDiscord | <! Nilts> nvm |
00:58:26 | FromDiscord | <! Nilts> is there docs |
01:08:46 | FromDiscord | <exelotl> The docs are pretty minimal but what you probably want is encodePNG32 or encodePNG24 ? |
01:10:20 | FromDiscord | <! Nilts> ok |
01:10:27 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dbv |
01:10:45 | FromDiscord | <exelotl> Oh wait there's savePNG32 and savePNG24, they will take care of writing the file for you |
01:11:13 | FromDiscord | <exelotl> Without those you have to set up a stream and call writeChunks |
01:17:23 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dbx |
01:18:51 | FromDiscord | <Elegantbeef> Dont know |
01:19:41 | FromDiscord | <Patitotective> dont tell me that :[ |
01:20:28 | FromDiscord | <! Nilts> Im banging my head now with a different problem. Converting binary 2 string is corrupting my bytes! how do i just get a hex rep of a binary file!. |
01:20:42 | FromDiscord | <Elegantbeef> You do have overloads that are intersections |
01:20:50 | FromDiscord | <Elegantbeef> `var List` and `var seq` are intersections |
01:21:55 | FromDiscord | <Elegantbeef> For my VM interop this is basically all i do https://github.com/beef331/nimscripter/blob/master/src/nimscripter/vmconversion.nim#L8-L40 |
01:21:57 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dby |
01:22:24 | FromDiscord | <! Nilts> In reply to @not logged in "Im banging my head": is there somewhere else i should ask this? |
01:26:16 | FromDiscord | <Patitotective> In reply to @Elegantbeef "For my VM interop": difference is that i have three types to decode from |
01:26:31 | FromDiscord | <Elegantbeef> It's the same thing |
01:28:16 | FromDiscord | <Patitotective> :| |
01:28:27 | FromDiscord | <Elegantbeef> I dont see why having 3 types changes anything |
01:30:23 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dbA |
01:31:09 | FromDiscord | <Elegantbeef> I dont know why you're providing APIs for anything but the primitives |
01:31:33 | FromDiscord | <Elegantbeef> Implement the primitives in this module, then implement the non primitive stdlib implementations |
01:38:04 | NimEventer | New thread by Nlits: How do I turn binary file data into hex representation , see https://forum.nim-lang.org/t/9531 |
01:39:58 | FromDiscord | <sOkam!> Is it possible to add a variable to the string contents of an exception message?↵Last attempt I tried said something about & potentially raising an exception too, and complained↵Is there a way to do it that doesn't create issues? |
01:47:25 | FromDiscord | <Patitotective> In reply to @sOkam! "Is it possible to": `except Exception as error: error.msg.add "huh"` (?) |
01:47:48 | FromDiscord | <Elegantbeef> what? |
01:48:51 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dbC |
01:50:45 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dbD |
01:51:01 | FromDiscord | <Elegantbeef> `import std/strformat` |
01:51:17 | FromDiscord | <Elegantbeef> `fmt"Unsupported TGA data type {myVar}"` |
01:51:28 | FromDiscord | <sOkam!> oh fmt doesn't create exception? |
01:51:38 | FromDiscord | <sOkam!> I tried with &, and it complained |
01:51:39 | FromDiscord | <Patitotective> what exception? |
01:51:55 | FromDiscord | <sOkam!> I don't remember, but it complained when I tried the obvious formatted string |
01:51:59 | FromDiscord | <sOkam!> which is why i asked |
01:52:08 | FromDiscord | <Patitotective> well, it should work with `&` |
01:52:12 | FromDiscord | <Elegantbeef> fmt shouldnt raise an exception |
01:52:18 | FromDiscord | <Elegantbeef> They're string operations |
01:52:30 | FromDiscord | <sOkam!> should, but didn't. so made me think I was doing something incorrect |
01:52:52 | FromDiscord | <sOkam!> (edit) "should, but didn't. so made me think I was doing something incorrect ... " added "by using strformat" |
01:54:13 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dbE |
01:54:29 | FromDiscord | <Elegantbeef> So handle that excepption? |
01:55:06 | FromDiscord | <sOkam!> so its not obvious how? |
01:55:30 | FromDiscord | <sOkam!> ive never used exceptions in my life, don't assume I know as much as you do |
01:55:54 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dbF |
01:56:04 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/manual.html#exception-handling |
01:56:18 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/tut2.html#exceptions |
01:57:09 | * | arkurious quit (Quit: Leaving) |
02:17:12 | FromDiscord | <Patitotective> In reply to @Elegantbeef "Implement the primitives in": in the same module, right? |
02:17:50 | FromDiscord | <Elegantbeef> Doesnt have to be |
02:33:29 | FromDiscord | <Patitotective> this is getting too big https://media.discordapp.net/attachments/371759389889003532/1030669713933606983/unknown.png |
02:36:38 | FromDiscord | <ChocolettePalette> Just merge them into a single file "useful functions.nim" |
02:38:26 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dbH |
02:38:50 | FromDiscord | <Elegantbeef> Why include |
02:39:06 | FromDiscord | <Patitotective> annoys you more |
02:39:13 | FromDiscord | <Elegantbeef> ah |
02:54:57 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dbK |
02:55:23 | FromDiscord | <Patitotective> (edit) "https://play.nim-lang.org/#ix=4dbK" => "https://play.nim-lang.org/#ix=4dbL" |
03:10:59 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dbO |
03:11:09 | FromDiscord | <sOkam!> (edit) "https://play.nim-lang.org/#ix=4dbO" => "https://play.nim-lang.org/#ix=4dbP" |
03:11:23 | FromDiscord | <Elegantbeef> that's correct, and you dont nee `@` |
03:11:36 | FromDiscord | <Elegantbeef> you can just do `if myVal notin validTypes` |
03:11:49 | FromDiscord | <sOkam!> `notin`, kk |
03:20:20 | FromDiscord | <Rika> In reply to @Elegantbeef "that's correct, and you": It isn’t |
03:20:42 | FromDiscord | <Rika> Not int in container would bitwise invert the int and check that if it’s in the container no? |
03:21:07 | FromDiscord | <Elegantbeef> !eval echo not 10 in [10] |
03:21:13 | NimBot | false |
03:22:06 | FromDiscord | <Elegantbeef> !eval echo not -11 in [10] |
03:22:10 | NimBot | true |
03:22:20 | FromDiscord | <Rika> Lol |
03:29:09 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dbT |
03:29:17 | FromDiscord | <Elegantbeef> Congrats |
03:29:39 | FromDiscord | <Patitotective> my life is done |
03:29:50 | FromDiscord | <Elegantbeef> You now can move to a more sane format |
03:31:10 | FromDiscord | <Rika> Released from hell |
03:31:31 | FromDiscord | <Patitotective> after all this intellectual effort im not going to change kdl |
03:34:09 | FromDiscord | <Patitotective> In reply to @Elegantbeef "You now can move": or grow along kdl to a saner version of ourselves |
03:34:11 | FromDiscord | <Patitotective> 🌃 |
03:35:26 | FromDiscord | <Rika> In reply to @Patitotective "or grow along kdl": Doubt |
04:40:13 | NimEventer | New Nimble package! tabcompletion - stdin tab completion library, see https://github.com/z-kk/tabcompletion |
06:43:45 | * | rockcavera quit (Remote host closed the connection) |
06:48:44 | * | fallback quit (Ping timeout: 268 seconds) |
06:49:00 | * | rb quit (Ping timeout: 264 seconds) |
07:33:24 | * | rwb joined #nim |
07:38:05 | * | Guest7 joined #nim |
07:38:30 | * | Guest7 quit (Client Quit) |
07:41:42 | * | LuxuryMode joined #nim |
07:59:13 | * | jjido joined #nim |
08:12:37 | * | fallback joined #nim |
08:12:43 | FromDiscord | <Phil> Self-answered SO question incoming, basically me copy pasting the thread I opened on the nim forum about how to unroll a for-loop over a compile-time-seq over to SO because I can just find things easier on SO |
08:13:00 | FromDiscord | <Phil> (edit) "SO" => "SO." |
08:13:07 | NimEventer | New question by Philipp Doerner: How to iterate over a compile-time seq in a manner that unrolls the loop?, see https://stackoverflow.com/questions/74077788/how-to-iterate-over-a-compile-time-seq-in-a-manner-that-unrolls-the-loop |
08:19:10 | FromDiscord | <Rika> Plagiarism smh |
08:19:20 | FromDiscord | <Rika> Oh you opened it :inatehe: |
08:26:16 | FromDiscord | <Phil> I typically don't understand other people's question well enough to transform them into an SO question 😛 |
08:29:11 | FromDiscord | <4zv4l> are `case of` comptime ? |
08:29:34 | FromDiscord | <Elegantbeef> case statements require constants for the branches |
08:29:48 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4dcx |
08:29:59 | FromDiscord | <Elegantbeef> Nim's case statements only support ordinals |
08:30:03 | FromDiscord | <Elegantbeef> on top of it |
08:30:25 | FromDiscord | <4zv4l> so I have to use if else ? |
08:30:30 | FromDiscord | <Elegantbeef> Yes |
08:31:50 | FromDiscord | <4zv4l> alright xD thanks ! |
08:32:57 | FromDiscord | <mantielero (mantielero)> Quick question\: using the following is not feasible, is it?↵\`\`\`nim |
08:33:40 | FromDiscord | <Elegantbeef> No nested openarrays are not valid |
08:33:59 | FromDiscord | <mantielero (mantielero)> Thanks |
08:39:09 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=4dcB really made me make some funny code↵(@Phil) |
08:39:28 | FromDiscord | <Elegantbeef> Eh shit i'll do it properly |
08:43:30 | FromDiscord | <Phil> In reply to @Elegantbeef "https://play.nim-lang.org/#ix=4dcB really made me": ?↵Want to provide a third way to unroll loops on compile-time seqs? |
08:43:40 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=4dcC here we go, the real final way |
08:45:22 | FromDiscord | <Phil> What's name and body for? |
08:45:39 | FromDiscord | <Elegantbeef> To get the AST of the nodes |
08:46:03 | FromDiscord | <Phil> But do I throw in the seq into nameP? Is that the body of the variable that gets the seq value put into it? |
08:46:15 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dcD |
08:46:18 | FromDiscord | <Phil> (edit) removed "body of the" |
08:48:25 | FromDiscord | <Elegantbeef> It unrolls iterators more than anything else |
08:48:37 | FromDiscord | <Elegantbeef> As such it's very reusable |
08:50:23 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4dcF |
08:55:03 | FromDiscord | <Phil> Added it to the SO response |
08:55:53 | FromDiscord | <Elegantbeef> probably `x.items` |
08:55:57 | FromDiscord | <Elegantbeef> But yes |
09:18:31 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
09:36:08 | FromDiscord | <Phil> For reference, ORC was the GC for nim 2.0 right? |
09:43:04 | FromDiscord | <Rika> I believe so yes |
10:07:11 | * | kenran joined #nim |
10:07:15 | * | kenran quit (Remote host closed the connection) |
10:17:46 | FromDiscord | <Phil> Beef! Question |
10:17:58 | FromDiscord | <Rika> You should just ask it |
10:21:17 | FromDiscord | <ringabout> In reply to @Isofruit "For reference, ORC was": True, 2.0 is coming in one or two month. |
10:21:22 | FromDiscord | <ringabout> (edit) "month." => "months." |
10:21:29 | FromDiscord | <ringabout> (edit) "In reply to @Isofruit "For reference, ORC was": True, ... 2.0" added "and" |
10:21:37 | FromDiscord | <Phil> Say I have a string "bhfrhjjh {% instruction somefilepathstring %} ezubsdhh" known at compile time.↵How can I replace, at compile time, the symbol somefilepathstring with the actual value inside of it before another parser at compile time goes over the string and tries to turn the expression in between {%%} into Nim code? |
10:22:02 | FromDiscord | <Phil> (edit) ""bhfrhjjh" => "`"bhfrhjjh" | "ezubsdhh"" => "ezubsdhh"`" |
10:26:00 | * | TrueBlue[m] quit (Read error: Connection reset by peer) |
10:26:03 | * | reversem3[m] quit (Read error: Connection reset by peer) |
10:28:11 | FromDiscord | <ringabout> You can iterate over the existing string to generate a new string at compile time. |
10:30:21 | * | reversem3[m] joined #nim |
10:40:09 | * | jmdaemon quit (Ping timeout: 252 seconds) |
10:41:41 | FromDiscord | <Phil> O.O... Right! That might actually be a workable minimal hack for my problem.↵Well at least it means only hacky code in my package.↵↵Read in the nimja file before nimja, replace the variables with their actual strings and hand only that modified string over to nimja for parsing |
10:41:42 | * | TrueBlue[m] joined #nim |
10:42:55 | FromDiscord | <Phil> Wait.. shit, no. Unless I completely copy how nimja reads in templates and templates within those templates I'm still screwed |
10:43:10 | FromDiscord | <Phil> Which is a lot of work again, dangit! |
11:57:22 | FromDiscord | <ezquerra> If you define operator `+` for a type, do you automatically get the corresponding operator `+=`? I thought it would but it does not seem to be the case... |
12:02:25 | FromDiscord | <Rika> you do not |
12:03:42 | FromDiscord | <Rika> i guess you can make it so by `proc +=[T](a: var T; b: T) = a = a + b` ofc with the correct backticks |
12:04:04 | FromDiscord | <Rika> but i think in general its not desirable |
12:04:22 | FromDiscord | <ezquerra> Why not? |
12:10:03 | FromDiscord | <Rika> actually, hm |
12:10:33 | FromDiscord | <Goel> sent a code paste, see https://play.nim-lang.org/#ix=4ddQ |
12:10:44 | FromDiscord | <Rika> In reply to @Rika "i guess you can": `proc +=[T, U](a: var T; b: U) = a = a + b` allows for more "flexibility" since sometimes you have a + that takes two different types |
12:10:51 | FromDiscord | <Goel> (edit) "https://play.nim-lang.org/#ix=4ddQ" => "https://paste.rs/2VP" |
12:11:00 | FromDiscord | <Rika> as long as + is +(T, U): T |
12:11:47 | FromDiscord | <Goel> (edit) "https://play.nim-lang.org/#ix=4ddT" => "https://paste.rs/riw" |
12:24:39 | * | arkurious joined #nim |
12:32:31 | * | derpydoo joined #nim |
12:40:19 | FromDiscord | <jos> is there a way to trivially compile nim to wasm |
12:40:27 | FromDiscord | <jos> like without installing a third party toolchain or something |
12:43:18 | FromDiscord | <auxym> mostly using emscripten afaik. eg: https://github.com/beef331/wasm3 |
12:46:16 | FromDiscord | <jos> thanks i'll try that |
13:07:57 | FromDiscord | <Rika> emscripten is "a third party toolchain" |
13:09:07 | FromDiscord | <Horizon [She/Her]> In reply to @jos "thanks i'll try that": There's also nlvm, which is just Nim but generates LLVM directly |
13:09:32 | FromDiscord | <Horizon [She/Her]> https://github.com/arnetheduck/nlvm |
13:09:59 | FromDiscord | <Horizon [She/Her]> In reply to @jos "like without installing a": Also, if you already have clang installed, it's possible to use that to generate WASM |
13:11:20 | FromDiscord | <Horizon [She/Her]> Nim likely never will have native WASM support though since really, it's not needed, since it uses a C (or C++) compiler (like emscripten and clang), and those can already output WASM↵↵As in, compilers exist for C and C++ to compile it to WASM |
13:16:34 | FromDiscord | <jos> with WASI coming around it would be nicer than using emscripten |
13:17:42 | FromDiscord | <jos> i think that would unlock more execution environments too |
13:18:01 | FromDiscord | <jos> since emscripten generates js shims, it basically only works in the browser or node, or something with a js runtime too |
13:18:24 | FromDiscord | <jos> but with wasi you can embed wasm modules in say, your own application for scripting support, without a js runtime |
13:18:42 | FromDiscord | <jos> not sure how accurate all that is but it's my understanding |
13:19:04 | FromDiscord | <jos> nvm emscripten supports wasi now too |
13:26:12 | FromDiscord | <auxym> In reply to @flywind "True, and 2.0 is": Is it really? Would be nice to get an official heads up with final list of breaking changes. Last I checked there was still a bunch of open RFCs with ongoing discussion about which breaking changes should make it into 2.0 |
13:36:25 | FromDiscord | <ringabout> Breaking changes are always documented in the changelog. |
13:36:52 | FromDiscord | <ringabout> https://github.com/nim-lang/Nim/blob/devel/changelog.md#changes-affecting-backward-compatibility |
13:44:57 | FromDiscord | <Phil> Wait a sec, I thought the correct way to raise an exception is raise stuff with the error suffix. Isn't defect suffix only for when you want to program to crash if this is encountered? Why does error get deprecated? |
13:47:15 | FromDiscord | <Rika> what do you mean |
13:47:59 | FromDiscord | <Rika> raising stuff with the error suffix (that are aliased to defect) is equivalent to raising stuff with the defect suffix |
13:48:08 | FromDiscord | <Rika> they were aliased for compat. reasons |
13:48:53 | FromDiscord | <Rika> "but i wanted to avoid the dialect fracture" you cannot i believe |
13:51:43 | * | CyberTailor joined #nim |
13:51:52 | * | CyberTailor left #nim (#nim) |
14:01:00 | FromDiscord | <Phil> Ah, the defect aliases get deprecated, but a bunch of errors in general. I think I just didnt parse the sentence as such |
14:01:15 | FromDiscord | <Phil> (edit) "but" => "not" |
14:02:18 | FromDiscord | <Horizon [She/Her]> Question: What's the appropriate way to represent literals in Nim? |
14:02:38 | FromDiscord | <Phil> ? |
14:03:17 | FromDiscord | <Horizon [She/Her]> The code here is written in Java and uses the `Object` type to represent literals in Nim, idk how to handle them: https://craftinginterpreters.com/representing-code.html#:~:text=expression%22%2C%0A%20%20%20%20%20%20%22-,Literal%20%20%3A%20Object,-value%22%2C |
14:04:29 | FromDiscord | <Phil> Sorry I just dropped off from sports so a bit slow right now, so literally just representing strings known at compile time only need within a module? |
14:04:46 | FromDiscord | <Phil> Or is this about string interpolation |
14:05:48 | FromDiscord | <Horizon [She/Her]> Dw! I'm making an interpreter and currently on the part about representing the AST, I'm trying to figure out how to store them like CI is talking about |
14:05:54 | FromDiscord | <Horizon [She/Her]> I think that makes sense? |
14:06:56 | FromDiscord | <Horizon [She/Her]> I'll figure this out later actually |
14:10:58 | * | kenran joined #nim |
14:12:37 | FromDiscord | <Phil> I think right now I'm not at capacity to actually properly even understand the question 😅 |
14:13:32 | FromDiscord | <Horizon [She/Her]> Fair enough, i'm probably rambling a bit too haha |
14:24:46 | FromDiscord | <Phil> Mostly because I see string literal, I immediately think "why not just put it in a const?"↵Thus I'm not understanding the "representation" aspect of it |
14:25:11 | FromDiscord | <Phil> I'm reasonably sure you're not after variable assignment, but can't imagine what else, thus perplexion |
14:26:06 | * | derpydoo quit (Quit: derpydoo) |
14:49:37 | * | PMunch joined #nim |
15:30:47 | FromDiscord | <auxym> @Horizon [She/Her] use a variant object, like the nim compiler itself does? nnkStringLiteral, nnkIntLiteral, etc. Each variant kind has a field with the value of appropriate type. |
15:31:22 | FromDiscord | <auxym> If you want more inspiration, you can search github for nim implementations of lox / crafting interpreters, there are a few out there |
15:34:21 | FromDiscord | <auxym> I'm pretty that writing compilers/parsers/ASTs is the main reason Araq included variant objects in the language 😛 |
15:36:07 | FromDiscord | <Horizon [She/Her]> Ah fair lol |
15:36:24 | FromDiscord | <Bung> sent a code paste, see https://play.nim-lang.org/#ix=4dfc |
15:36:38 | FromDiscord | <Bung> (edit) "https://play.nim-lang.org/#ix=4dfc" => "https://play.nim-lang.org/#ix=4dfd" |
15:36:44 | FromDiscord | <Bung> (edit) "https://play.nim-lang.org/#ix=4dfd" => "https://play.nim-lang.org/#ix=4dfe" |
15:44:27 | * | strogon14 left #nim (Und tschüss!) |
16:03:57 | FromDiscord | <qb> sent a code paste, see https://play.nim-lang.org/#ix=4dfr |
16:25:57 | FromDiscord | <Patitotective> In reply to @Rika "Doubt": dont mind me, i was alienated |
16:26:09 | FromDiscord | <Patitotective> (edit) "In reply to @Rika "Doubt": dont mind me, i was alienated ... " added "because it was bedtime" |
16:27:40 | FromDiscord | <jos> sent a code paste, see https://play.nim-lang.org/#ix=4dfC |
16:28:19 | * | jmdaemon joined #nim |
16:36:01 | * | xet7 joined #nim |
16:48:49 | FromDiscord | <qb> mh I'm confused. https://play.nim-lang.org/#ix=4dfK |
16:51:40 | * | jjido joined #nim |
16:58:26 | PMunch | @qb, what confuses you? |
17:00:05 | PMunch | Ah, never mind, I see where you got confused |
17:00:35 | PMunch | When you set your pixel you only use the x coordinate, try this instead: https://play.nim-lang.org/#ix=4dfO |
17:01:41 | PMunch | Or this, if you want an actual 2D array without doing the math yourself: https://play.nim-lang.org/#ix=4dfS |
17:01:55 | PMunch | The data is stored exactly the same in memory either way |
17:04:33 | FromDiscord | <SREagle> nice to know, the 2nd looks more intuitive, I would probably have used the 1st approach, since I do so in other languages, Thx for the example! |
17:06:41 | FromDiscord | <qb> In reply to @PMunch "Or this, if you": Yea I got it. But thats even better |
17:08:35 | FromDiscord | <Scoobery Doobery> sent a code paste, see https://play.nim-lang.org/#ix=4dfV |
17:09:19 | FromDiscord | <Scoobery Doobery> (edit) "https://play.nim-lang.org/#ix=4dfV" => "https://play.nim-lang.org/#ix=4dfW" |
17:09:56 | FromDiscord | <Scoobery Doobery> I omitted the contents of `draw` for clarity. It seems like `FnPtr` aliases a `func` correctly, but the compile error convinces me that's not the case |
17:10:50 | FromDiscord | <Scoobery Doobery> Since `func` isn't allowed in type descriptions, I can't specify that for my `FnPtr` type |
17:14:19 | PMunch | @Scoobery_Doobery, not quite sure, this seems to work fine: https://play.nim-lang.org/#ix=4dg0 |
17:15:04 | FromDiscord | <Scoobery Doobery> On the latest as well. Damn. |
17:15:19 | FromDiscord | <Scoobery Doobery> Must be some other package I imported or something. Urgh |
17:15:21 | PMunch | Huh? |
17:15:35 | FromDiscord | <Scoobery Doobery> I just mean we're both on the latest versions of Nim |
17:15:36 | PMunch | Try to create a minimal sample you can shar |
17:15:39 | PMunch | share* |
17:16:05 | PMunch | Oh right, the playground should automatically update to always be the latest version |
17:16:13 | PMunch | Currently it's running 1.6.8 I believe |
17:19:56 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dg3 |
17:20:47 | PMunch | Hmm, hard to tell without seeing how it's used |
17:21:19 | PMunch | Typically I'd expect node.len to return node.children.len, but without any context for how this is to be used it's hard to tell if that would be intuitive or not |
17:21:46 | PMunch | (If you've provided context elsewhere I'm sorry, just joined the channel :)) |
17:22:30 | FromDiscord | <Scoobery Doobery> Not sure what was up with my code before, but rewriting it differently seems to have got rid of the error. Still, I have no clue what I did wrong initially lmao |
17:23:56 | PMunch | Might been a silly typo somewhere |
17:24:00 | PMunch | Those can be hard to miss :P |
17:24:11 | PMunch | Easy to miss* hard to spot* |
17:24:20 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dg5 |
17:24:23 | FromDiscord | <Patitotective> https://kdl.dev |
17:24:32 | FromDiscord | <qb> So another task which I wanna do now with this matrix is to get a rectangle 1010 from the center of it. Can't I just slice it that way? https://play.nim-lang.org/#ix=4dg4 |
17:31:35 | PMunch | Hmm, yeah in that case I think what you proposed would make sense |
17:31:47 | PMunch | Well, it depends on what's most commonly used I guess |
17:33:06 | * | wallabra quit (Ping timeout: 260 seconds) |
17:35:03 | PMunch | Hmm, or maybe it's better to be explicit. Look at the nested child nodes for example |
17:35:19 | PMunch | What would you expect `section[0]` to be? |
17:35:26 | PMunch | Or `section.len` for that matter |
17:41:10 | * | jjido quit (Ping timeout: 268 seconds) |
17:41:12 | * | wallabra joined #nim |
17:44:43 | PMunch | Hmm, I was going to write a BME280 library for Ratel, mostly to test if my USI implementation of I2C for the ATTiny85 was correct |
17:44:53 | PMunch | But that sensor is complex.. |
17:47:54 | * | derpydoo joined #nim |
18:10:29 | PMunch | Hmm, and here I was thinking I could get some simple Hacktoberfest PRs in.. |
18:14:04 | FromDiscord | <Patitotective> In reply to @PMunch "Hmm, yeah in that": i think ill just keep the most intuitive ones which i think are `node["key"]`, `node["key"]=` and `node.add` since it can have two overloads for `KdlNode` (add to children) and `KdlVal` (add to args)↵`node[0]` and `node.len` can be confused with arguments and children↵:] |
19:07:17 | * | derpydoo quit (Ping timeout: 250 seconds) |
19:07:34 | * | kenran quit (Remote host closed the connection) |
19:07:57 | PMunch | Hmm, I'm creating enums for the settings for the BME280, anyone got some good names for the settings in Table 27? https://www.mouser.com/datasheet/2/783/BST-BME280-DS002-1509607.pdf |
19:08:18 | PMunch | Section 5.4.6, page 30 |
19:15:01 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dgH |
19:16:38 | PMunch | Hmm, removing the T but otherwise those are fine I guess |
19:16:46 | FromDiscord | <Patitotective> wonder if you could make a `range[0.25, 62.5, 125, 250, 500, 1000, 10, 20]` |
19:16:55 | FromDiscord | <Patitotective> (edit) "wonder if you could make a `range[0.25, 62.5, 125, 250, 500, 1000, 10, 20]` ... " added "or w/e" |
19:17:01 | PMunch | I was considering ms or us though.. |
19:17:05 | FromDiscord | <auxym> I sometimes prefix the unit for stuff like that |
19:17:16 | PMunch | Yeah that's what I was thinking |
19:17:23 | FromDiscord | <auxym> so ms05, etc |
19:17:30 | FromDiscord | <auxym> or us500 i guess |
19:17:57 | FromDiscord | <auxym> and I tend to use {.pure.} |
19:18:20 | PMunch | `type StandBy = enum us500, us62500, ms125, ms250, ms500, ms1000, ms10, ms20` |
19:18:26 | PMunch | Something like that? |
19:18:49 | * | derpydoo joined #nim |
19:18:50 | PMunch | Does pure really do anything nowadays though? |
19:19:10 | FromDiscord | <Patitotective> you gotta always do `StandBy.us500` afaik |
19:19:21 | PMunch | That was how they used to work |
19:19:26 | PMunch | But that was removed quite a while ago |
19:19:47 | PMunch | And about the range thing, I would assign the values that I need to write the register as the value for the enum |
19:20:23 | PMunch | Ah, but you wanted to be able to write 0.5 and it auto-converted to 001 I guess |
19:21:35 | PMunch | I guess I could use custom numeric literals: https://nim-lang.org/docs/manual.html#numeric-literals-custom-numeric-literals |
19:21:59 | PMunch | And have something like 0.26'ms |
19:22:23 | PMunch | Or 0.5'sbt (short for stand-by time) |
19:24:01 | PMunch | Or of course a `converter toStandByTime(x: static[SomeNumber]): StandBy = <Conversion logic>` |
19:24:57 | FromDiscord | <Patitotective> i think using custom numeric literals would be really neat |
19:25:02 | FromDiscord | <Patitotective> idiomatic |
19:42:10 | PMunch | @Patitotective, something like this? https://play.nim-lang.org/#ix=4dgJ |
19:42:18 | PMunch | Doesn't handle 62.50 though :P |
19:47:53 | PMunch | Not sure if I can import strutils on a microcontroller though.. |
19:52:41 | FromDiscord | <Patitotective> @PMunch https://play.nim-lang.org/#ix=4dgN |
19:52:55 | FromDiscord | <Patitotective> could also use `parseEnum` |
19:54:59 | PMunch | Hmm, yeah that works I guess |
20:07:07 | FromDiscord | <halc> little question, if I slice a view type with `someView[a..b]`, will that make a copy? Or should I use `toOpenArray` again? |
20:07:16 | FromDiscord | <halc> (edit) "again?" => "again to prevent that?" |
20:10:07 | FromDiscord | <Generic> the latter |
20:10:21 | FromDiscord | <halc> I see |
20:10:32 | FromDiscord | <Generic> slicing returns a seq, so it copies |
20:15:45 | PMunch | @Patitotective, this works |
20:19:38 | * | PMunch quit (Quit: leaving) |
20:20:50 | FromDiscord | <Patitotective> In reply to @PMunch "<@762008715162419261>, this works": forgot the link? |
20:49:59 | * | derpydoo quit (Ping timeout: 250 seconds) |
21:05:56 | * | derpydoo joined #nim |
21:06:46 | FromDiscord | <auxym> In reply to @PMunch "But that was removed": Wow, I was not even aware of that. Too bad, I kind of prefer qualifying enums most of the time |
21:07:16 | FromDiscord | <Patitotective> In reply to @auxym "Wow, I was not": related https://github.com/nim-lang/Nim/issues/8066 |
21:11:16 | * | wallabra quit (Ping timeout: 260 seconds) |
21:13:25 | * | wallabra joined #nim |
21:22:34 | FromDiscord | <halc> how do I make an `openArray[char]` into a new `string`? |
21:27:47 | FromDiscord | <auxym> hm, not sure there's a way without copying with a loop, or copymem |
21:29:55 | FromDiscord | <auxym> sent a code paste, see https://play.nim-lang.org/#ix=4dhb |
21:32:00 | * | clemens3 joined #nim |
21:32:31 | FromDiscord | <halc> fair enough |
21:33:55 | * | clemens3 left #nim (#nim) |
21:34:12 | FromDiscord | <Patitotective> damn, decoding object variants is really tricky↵the code looks so messy↵https://github.com/Patitotective/kdl-nim/blob/devel/src/kdl/decoder.nim#L101 |
21:34:23 | FromDiscord | <dizzyliam> or `strutils.join` |
21:35:56 | FromDiscord | <dizzyliam> as in `stringy = arrayOfChars.join("")` |
21:36:04 | FromDiscord | <dizzyliam> probably slower but a nice one-liner |
21:36:40 | FromDiscord | <Patitotective> In reply to @karma_corrections "probably slower but a": the implementation does look slower |
21:36:51 | FromDiscord | <Patitotective> (edit) "In reply to @karma_corrections "probably slower but a": the implementation does ... look" added "not" |
21:37:06 | FromDiscord | <Patitotective> In reply to @karma_corrections "as in `stringy =": `arrayOfChars.join()` is enough :] |
21:37:28 | FromDiscord | <Patitotective> In reply to @Patitotective "the implementation does not": https://github.com/Patitotective/kdl-nim/blob/devel/src/kdl/decoder.nim#L101 |
21:37:31 | FromDiscord | <dizzyliam> good point |
21:37:35 | FromDiscord | <Patitotective> (edit) "https://github.com/Patitotective/kdl-nim/blob/devel/src/kdl/decoder.nim#L101" => "https://github.com/nim-lang/Nim/tree/version-1-6/lib/pure/strutils.nim#L1772" |
22:06:58 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dhj |
22:19:05 | FromDiscord | <Patitotective> am i doing something wrong? |
22:19:06 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dhm |
22:19:56 | FromDiscord | <Patitotective> (edit) "https://play.nim-lang.org/#ix=4dhm" => "https://play.nim-lang.org/#ix=4dhn" |
22:20:38 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4dho |
22:26:51 | FromDiscord | <jos> how does the acyclic pragma work if you have a tree, for example, which is acyclic except it can contain userdata-- and there's no guarantee that userdata may contain a node in the tree |
22:27:06 | FromDiscord | <jos> is there a strategy for something like that |
22:27:53 | FromDiscord | <Elegantbeef> The pragma tells the compiler the structure does not ever reference itself |
22:28:07 | FromDiscord | <Elegantbeef> You could use a `{.cursor.}` but that means you have to be sure about ownership |
22:33:01 | FromDiscord | <qb> `random.nim(325, 10) `x.a <= x.b` [AssertionDefect]` |
22:33:25 | FromDiscord | <qb> whats exactly the issue there? |
22:33:35 | FromDiscord | <Elegantbeef> Slices should be `low..high` |
22:35:56 | * | derpydoo quit (Ping timeout: 268 seconds) |
22:51:02 | FromDiscord | <40yd> sent a code paste, see https://play.nim-lang.org/#ix=4dhz |
22:58:47 | FromDiscord | <Phil> In reply to @40yd "Hi, I'm new to": Do all your intended procedures have the exact same signature? |
23:01:25 | FromDiscord | <Phil> Like, same parameter types in the same order? |
23:28:34 | FromDiscord | <40yd> Thx reply:) no, listener object could be different types like, Dog type, Cat type, Fox type(each type has different callback proc name) |
23:28:54 | FromDiscord | <40yd> In reply to @Isofruit "Do all your intended": Thx reply:) no, listener object could be different types like, Dog type, Cat type, Fox type(each type has different callback proc name) |
23:34:51 | FromDiscord | <Phil> That might turn into a problem, if you want to store them together in a seq or table or sth. They need to be of the same type. The only alternative you have that I'm aware of is object variants, which are only an option if the number of different procs is limited |
23:42:29 | FromDiscord | <40yd> In reply to @Isofruit "That might turn into": ic, so if i put pre-defined Types to enum, it might be possible. I'll try it:) |
23:42:35 | FromDiscord | <Require Support> anyone familiar on how to create async named pipes on windows using nim? |