00:16:23 | * | hmmm quit () |
00:30:02 | FromDiscord | <kodkuce> in nim if i change a char of stirng is whole new string created or just that char changes, i am not talking about adding more chars or deleting some just changing |
00:30:11 | FromDiscord | <kodkuce> (edit) "stirng" => "string" |
00:33:01 | Zoom[m] | @kodkuce how exactly do you perform that change? |
00:33:29 | FromDiscord | <kodkuce> var mysting = "i am string" |
00:33:42 | FromDiscord | <kodkuce> myasting[2] = 'z' |
00:34:07 | FromDiscord | <kodkuce> my logic is should not create a new string |
00:34:21 | FromDiscord | <kodkuce> or at least there is no need to |
00:34:46 | mipri | it doesn't create a new string. |
00:37:12 | FromDiscord | <kodkuce> ye i just tryed some JS stuff and was wtf |
00:39:26 | mipri | there not being a need to, depends. replacing the nth unicode rune of a string might change the width of the bytes involved. but mystring is directly mutated in your code. If you think you're seeing something else, you might be seeing value semantics when you're expecting reference semantics: mycopy = mystring; mystring[2] = 'z' won't create a new string the assignment, but it'll create a new one for mycopy |
00:47:58 | Zoom[m] | disruptek: I liked that paper on CPC. Skipped reading the proofs, obviously :) |
01:00:00 | * | njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.) |
01:01:06 | * | njoseph joined #nim |
01:13:04 | * | hnOsmium0001 quit (Ping timeout: 240 seconds) |
01:15:21 | * | hnOsmium0001 joined #nim |
01:20:43 | * | Tanger joined #nim |
01:52:37 | * | NimBot joined #nim |
01:57:58 | FromDiscord | <Quibono> If I want an x by x array, how do I instantiate that? |
01:59:15 | FromDiscord | <Rika> array[N, array[M, Type]] |
01:59:19 | FromDiscord | <Rika> but |
01:59:20 | FromDiscord | <nikki> i think you mean 'initialize' (instantiation is for when specific versions of a generic proc are materialized) |
01:59:24 | FromDiscord | <Rika> uh |
01:59:29 | FromDiscord | <Rika> well i misread |
01:59:49 | FromDiscord | <Rika> well you dont really need to initialize it? its zero-set by default |
02:00:19 | FromDiscord | <nikki> yeah and if you wanna fill it you can just nested for loop 😄 |
02:01:15 | FromDiscord | <InventorMatt> if you use fill from algorithms you don't even need to nest a for loop |
02:02:13 | FromDiscord | <Quibono> Sorry, yeah initialize. |
02:03:47 | FromDiscord | <Quibono> Trying to do a pagerank implementation in Nim. |
02:12:28 | * | abm quit (Read error: Connection reset by peer) |
02:25:25 | FromGitter | <jrfondren> little log munger that decompresses stdin and splits some lines. Rust: 150ms. Nim: 300ms. Nim (-d:danger --gc:arc): 200ms |
02:25:35 | FromDiscord | <Rebel> Best way to convert string to cstring? `cast[cstring](mystring)` will suffic? |
02:25:45 | FromDiscord | <Rika> mystring.cstring |
02:26:15 | FromGitter | <jrfondren> and then: I need some temporary transition code to auto-populate a column if it's missing. Nim: add an 'if' branch. Rust: uh I'd have to rewrite half the program, Nim is good enough, don't bother doing this. |
02:26:50 | FromDiscord | <Rika> lol |
02:27:11 | FromDiscord | <Rika> its fast enough, if you need any faster you'll be sacrificing sanity is what i thikn about nim vs rust |
02:27:17 | FromDiscord | <Rebel> Poggers thanks Rika |
02:28:07 | FromGitter | <jrfondren> unexpected late-comer requirements like "oh yeah mutate the input in such-and-such case" really screw with Rust, yeah. Oh suddenly all these &strs have to be Strings. great. |
02:28:26 | * | bung joined #nim |
02:28:46 | FromGitter | <jrfondren> incidentally -d:danger saves 30s and --gc:arc saves the rest. quite a large savings on this little app. |
02:29:06 | FromDiscord | <Rika> i like the &str vs String difference, just not how it's written |
02:30:20 | FromGitter | <jrfondren> yep, I imagine the rest of the savings for Nim is hidden in viewtype improvements and a viewtype-producing split. I'll look at this code again when I can add that |
02:31:24 | * | apahl quit (Ping timeout: 240 seconds) |
02:33:35 | * | apahl joined #nim |
02:33:39 | FromDiscord | <Rika> i believe views are being worked on soon, soon we shall say nim is faster than rust www |
02:51:07 | FromDiscord | <Rebel> Would one port this from golang to Nim via casting before calling fmt? Or can you do casting within fmt? `return fmt.Sprintf("%.1f %cB", float64(b)/float64(div), "kMGTPE"[exp])` |
02:54:43 | FromDiscord | <Rika> what are you casting? |
02:54:54 | FromDiscord | <Rika> fmt as in fmt""? |
02:55:09 | FromDiscord | <Rika> yes you can cast in the {} for fmt |
02:56:57 | FromDiscord | <Rebel> ah |
02:56:59 | FromDiscord | <Rebel> excellent |
02:57:01 | FromDiscord | <Rebel> there is a `formatFloat` |
02:57:06 | FromDiscord | <Rebel> (edit) "there is a `formatFloat` ... " added "in strutils" |
02:59:18 | FromDiscord | <Rebel> rtfm ftw |
02:59:43 | FromDiscord | <Rika> lmao |
03:06:02 | * | muffindrake quit (Ping timeout: 264 seconds) |
03:08:09 | * | muffindrake joined #nim |
03:26:32 | FromDiscord | <Plas> Anyone know how to do memory management in Nim?↵ie. allocating/deallocating bytes |
03:29:48 | mipri | declare a variable with a type containing bytes and you'll get bytes. newString or newSeqOfCap are probably what you want, but you can also alloc0(int.sizeof * 50) or whatever to get a pointer. http://zevv.nl/nim-memory/ goes into detail. |
03:33:56 | FromDiscord | <UNIcodeX> try `-d:lto` or `--passL:-flto` |
03:35:02 | FromDiscord | <ElegantBeef> Worth noting the new discord reply doesnt currenty do anything so for IC users it doesnt... show anything 😄 |
03:35:13 | FromDiscord | <ElegantBeef> IRC users |
03:35:18 | FromDiscord | <ElegantBeef> It just says your message |
03:36:48 | FromDiscord | <Plas> lol |
03:37:11 | FromDiscord | <UNIcodeX> err. right. 😅 |
03:37:12 | FromDiscord | <UNIcodeX> jrfondren: try adding those switches |
03:38:39 | FromDiscord | <UNIcodeX> well... one or the other that is. |
03:42:02 | * | thomasross quit (Quit: Leaving) |
03:55:21 | * | nekits07 quit (Read error: Connection reset by peer) |
03:55:57 | * | nekits07 joined #nim |
04:06:01 | * | supakeen quit (Quit: WeeChat 2.9) |
04:06:37 | * | supakeen joined #nim |
04:08:22 | FromDiscord | <emekoi> are there some things macros can't due even if they produce a valid AST? |
04:08:33 | FromDiscord | <Rika> like? |
04:08:38 | FromDiscord | <Rika> wdym? |
04:09:47 | FromDiscord | <emekoi> i'm writng a macro for serialization and i'm trying to use `?` to denote optional fields, but it won't work no matter what i do |
04:10:25 | FromDiscord | <emekoi> if i manually specify the field as `Option` it works just fine and produces the exact same AST |
04:10:57 | FromDiscord | <Rika> how are you checking the ast |
04:11:21 | FromDiscord | <emekoi> printing it with `treeRepr` |
04:13:43 | FromDiscord | <Daniel> What is AST? |
04:14:14 | FromDiscord | <emekoi> abstract syntax tree |
04:15:17 | FromDiscord | <Daniel> k, will google for those |
04:15:25 | FromDiscord | <Daniel> found this https://media.discordapp.net/attachments/371759389889003532/779198186840784946/1280px-Abstract_syntax_tree_for_Euclidean_algorithm.png |
04:15:36 | FromDiscord | <ElegantBeef> Can we see the macro? |
04:18:32 | FromDiscord | <emekoi> http://ix.io/2ELZ |
04:21:23 | FromDiscord | <emekoi> here are the errors i get: http://ix.io/2EM1 |
04:21:50 | FromDiscord | <ElegantBeef> I threw it in nim playground i see the errors |
04:27:55 | FromDiscord | <ElegantBeef> Well i got it to work by making it get the typeof https://play.nim-lang.org/#ix=2EM2 |
04:28:03 | FromDiscord | <ElegantBeef> line 52 |
04:30:03 | FromDiscord | <emekoi> hmm, i guess type and typedesc aren't interchangable |
04:30:12 | FromDiscord | <emekoi> thanks for your help! |
04:33:40 | * | apahl quit (Remote host closed the connection) |
04:34:05 | * | apahl joined #nim |
04:57:09 | FromDiscord | <𝓑𝓮𝓷𝓾𝓶𝓫𝓮𝓭> Question IRT the streams used OS procs (startProcess is what I'm using to start the proc). Am I missing something or is there just no way to just immediately return from `readStr` on the output and error streams?↵↵What I'm experiencing is that the `readStr` will block until the process finishes, which doesn't work for this application (I need to stream stderr/out as it happens) |
04:57:20 | FromDiscord | <𝓑𝓮𝓷𝓾𝓶𝓫𝓮𝓭> (edit) "Question IRT the streams used ... OS" added "in" |
04:58:12 | FromDiscord | <𝓑𝓮𝓷𝓾𝓶𝓫𝓮𝓭> It may be the underlying buffer isn't flushing to the stream until the process exits too, I'm not certain |
05:29:15 | * | rockcavera quit (Remote host closed the connection) |
05:35:23 | * | waleee-cl quit (Quit: Connection closed for inactivity) |
06:16:51 | * | muffindrake quit (Quit: muffindrake) |
06:58:58 | * | narimiran joined #nim |
07:20:59 | * | habamax joined #nim |
07:28:11 | * | vicfred_ joined #nim |
07:28:24 | * | natrys joined #nim |
07:31:04 | * | vicfred quit (Ping timeout: 265 seconds) |
08:09:25 | * | hyiltiz quit (Quit: hyiltiz) |
08:17:37 | * | antranigv quit (Ping timeout: 264 seconds) |
08:36:19 | * | Tanger quit (Quit: Leaving) |
08:49:15 | * | hyiltiz joined #nim |
08:49:15 | * | hyiltiz quit (Changing host) |
08:49:15 | * | hyiltiz joined #nim |
08:50:59 | * | jjido joined #nim |
08:55:45 | * | hnOsmium0001 quit (Quit: Connection closed for inactivity) |
08:58:38 | FromDiscord | <iWonderAboutTuatara> hey |
08:58:53 | FromDiscord | <iWonderAboutTuatara> I'm writing a rubiks cube solver, right now I'm just implementing logic for turns |
08:59:11 | FromDiscord | <iWonderAboutTuatara> the cube is represented as a type object with 6 arrays, each of which with 9 chars representing colors of the stickers |
08:59:21 | FromDiscord | <iWonderAboutTuatara> doing the rotations of the cube takes quite a lot of code |
08:59:33 | FromDiscord | <iWonderAboutTuatara> sent a code paste, see https://play.nim-lang.org/#ix=2EMK |
08:59:46 | FromDiscord | <iWonderAboutTuatara> Is there any way I can write a macro to automatically generate this?' |
09:00:07 | * | lum[m] quit (Quit: Idle for 30+ days) |
09:00:08 | * | hnOsmium0001[m] quit (Quit: Idle for 30+ days) |
09:00:42 | FromDiscord | <iWonderAboutTuatara> the rotation code itself I mean |
09:00:43 | FromDiscord | <Rika> i dont understand the code |
09:00:46 | FromDiscord | <iWonderAboutTuatara> because there's ~24 turns |
09:01:16 | FromDiscord | <iWonderAboutTuatara> basically, when you rotate the cube, sets of 3 stickers are rotated |
09:01:46 | FromDiscord | <iWonderAboutTuatara> if you turn the right side upwards, the 3 stickers on the bottom take the place of the 3 on the front, the front takes place of the top, etc |
09:02:56 | FromDiscord | <iWonderAboutTuatara> the way I'm doing it is that I copy the original values of the 3 stickers that I'll be replacing, then replace it with what it should be replaced with |
09:03:07 | FromDiscord | <iWonderAboutTuatara> there's a bit on the bottom which is different logic entirely |
09:07:14 | FromDiscord | <nikki> firstly, idk if rubiks cube rotations should be copying seqs... |
09:07:47 | FromDiscord | <Rika> why seqs? didnt you just say arrays |
09:07:47 | FromDiscord | <iWonderAboutTuatara> Probably not for speed reasons |
09:07:51 | FromDiscord | <nikki> i feel like since the layout is known you should be using arrays |
09:07:58 | FromDiscord | <Rika> okay |
09:07:58 | FromDiscord | <iWonderAboutTuatara> I don't know the difference honestly |
09:08:10 | FromDiscord | <Rika> memory layout |
09:08:14 | FromDiscord | <iWonderAboutTuatara> As in seq is probably slower |
09:08:18 | FromDiscord | <iWonderAboutTuatara> Than would be necessary |
09:08:22 | FromDiscord | <iWonderAboutTuatara> No like from my perspective |
09:08:28 | FromDiscord | <nikki> arrays have a static size and format. seqs are growable and have an intermediate obj with a ptr and size |
09:08:35 | FromDiscord | <iWonderAboutTuatara> Right |
09:08:38 | FromDiscord | <nikki> this is the perspective to have |
09:08:58 | FromDiscord | <iWonderAboutTuatara> But every time in the past I've tried to use arrays, something subtly broke and I've just switched back to seq |
09:09:26 | FromDiscord | <nikki> sure. another approach is just using an object that has defined layout for everything |
09:09:38 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=2EMP |
09:10:27 | FromDiscord | <nikki> it seems like a 3x3x3 array works? with colors at each point |
09:10:29 | FromDiscord | <Rika> the ptr is the major thing in the seq that makes it slower |
09:11:01 | FromDiscord | <nikki> needing heap allocations on every copy, and potential cache misses on every access |
09:11:23 | narimiran | i see lots of repeated 2, 5, 8 code. you can refactor that |
09:11:26 | FromDiscord | <Rika> i think the cache misses is the major performance factor |
09:11:45 | FromDiscord | <iWonderAboutTuatara> Performance doesn't matter too much |
09:11:46 | FromDiscord | <nikki> i agree, unless you copy seqs every time you rotate like in this code |
09:11:56 | FromDiscord | <nikki> in which case allocations maybe come up too |
09:12:00 | FromDiscord | <iWonderAboutTuatara> @narimiran how would I refactor that? |
09:12:07 | FromDiscord | <iWonderAboutTuatara> This is just the first thing they came to mind |
09:12:36 | FromDiscord | <nikki> sure, but it's actually easier to write with arrays |
09:12:41 | FromDiscord | <iWonderAboutTuatara> This is the rotation function, if there's a way to change it that would make my life easier or would make it much faster without too much headache km willing |
09:12:46 | narimiran | something like `proc doStuff(to, from: seq[char]) = to[2] = from[2]; etc.` |
09:13:00 | narimiran | and then `doStuff(cube.u, cube.f)` |
09:13:08 | FromDiscord | <iWonderAboutTuatara> Oh that would make it less messy |
09:13:15 | FromDiscord | <nikki> i only bring it up cuz, if sugaring it anyways, may as well sugar an array |
09:13:15 | FromDiscord | <iWonderAboutTuatara> Good idea |
09:13:16 | Zoom[m] | Why not implement a 3x12 array to simplify at least horizontal moves? |
09:13:30 | FromDiscord | <iWonderAboutTuatara> I don't know |
09:13:41 | FromDiscord | <iWonderAboutTuatara> This is the first thing that came to my mind |
09:14:11 | FromDiscord | <iWonderAboutTuatara> @nikki how would I switch this to using arrays? |
09:14:17 | FromDiscord | <Rika> well the first thing you think of is rarely the best solution to take |
09:14:31 | FromDiscord | <iWonderAboutTuatara> Agreed, but this isn't a professional product |
09:14:46 | FromDiscord | <iWonderAboutTuatara> Just my own fun, I don't think anybody will ever use it |
09:14:49 | FromDiscord | <Rika> yeah but this is good practice for coding better innit? |
09:14:53 | Zoom[m] | At least in one direction there's no change in colour sequence, so you need to move arrays, not items |
09:14:53 | FromDiscord | <nikki> yeah but to learn, you have to do it right |
09:15:04 | FromDiscord | <nikki> anyways; i think 3x3x3 array |
09:15:08 | FromDiscord | <nikki> of color enums |
09:15:11 | * | jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
09:15:21 | FromDiscord | <iWonderAboutTuatara> I thought about 3x3x3, the issue is thinking in pieces vs stickers |
09:15:36 | FromDiscord | <iWonderAboutTuatara> Of tuples of color enums right? |
09:15:39 | FromDiscord | <nikki> cool. so what layout are you thinking 🤔 |
09:15:49 | FromDiscord | <iWonderAboutTuatara> Pretty much what I have |
09:15:53 | Zoom[m] | Reasoning in 3d is hard |
09:15:59 | FromDiscord | <iWonderAboutTuatara> @Zoom seems to have an interesting idea as well |
09:16:00 | FromDiscord | <nikki> i don't think i parsed it fully tbh |
09:16:01 | * | PMunch joined #nim |
09:16:02 | FromDiscord | <iWonderAboutTuatara> Yeah also that |
09:16:33 | FromDiscord | <nikki> all that was known was it's static / bounded at least |
09:16:39 | FromDiscord | <iWonderAboutTuatara> Cube is a type made of 6 seqs, each of which contains the stickers for one face |
09:16:41 | FromDiscord | <nikki> another thing that helps is some kinda neighborhood graph thingy |
09:16:55 | FromDiscord | <nikki> ah i see ok cool |
09:17:06 | FromDiscord | <nikki> yeah so i think it helps to do faces such that |
09:17:19 | * | hmmmmm joined #nim |
09:17:20 | FromDiscord | <nikki> you do front / back as 1 bit |
09:17:25 | FromDiscord | <nikki> and left right as another |
09:17:26 | hmmmmm | hallo :> |
09:17:29 | FromDiscord | <nikki> and top bottom as another |
09:18:18 | FromDiscord | <iWonderAboutTuatara> Why is that better? |
09:18:26 | FromDiscord | <nikki> nah actually that's mostly for vertices |
09:18:27 | FromDiscord | <nikki> nvm |
09:18:37 | FromDiscord | <iWonderAboutTuatara> Yeah that just seems more confusing |
09:18:49 | FromDiscord | <iWonderAboutTuatara> I think dealing with stickers instead of pieces is easier |
09:19:01 | FromDiscord | <nikki> yeah i was talking about faces for stickers |
09:19:08 | FromDiscord | <nikki> how to index faces |
09:19:19 | FromDiscord | <iWonderAboutTuatara> I just have them as fields in the type |
09:19:25 | FromDiscord | <iWonderAboutTuatara> Works fine |
09:19:36 | FromDiscord | <nikki> in any case, it'd be nice to index faces such that their neighborhood is some property of the index |
09:19:50 | FromDiscord | <nikki> but, idk if such a neighborhood exists among naturals |
09:19:58 | FromDiscord | <iWonderAboutTuatara> What do you mean by neighborhood in this case? |
09:20:15 | FromDiscord | <nikki> like that they share an edge |
09:20:46 | FromDiscord | <iWonderAboutTuatara> Oh that |
09:20:53 | FromDiscord | <iWonderAboutTuatara> Like partitioning a space sort of |
09:21:07 | * | antranigv joined #nim |
09:21:16 | FromDiscord | <iWonderAboutTuatara> I didn't know that had a name, I thought that was just a thing in topo |
09:21:30 | FromDiscord | <nikki> this is interesting |
09:21:49 | FromDiscord | <nikki> one thing that felt for sure was that bc. it's a known static size of data and layout |
09:21:54 | FromDiscord | <nikki> whatever the model is that is chosen |
09:22:02 | FromDiscord | <nikki> an array / object layout makes sense |
09:22:10 | FromDiscord | <iWonderAboutTuatara> Yeah agreed |
09:22:16 | FromDiscord | <iWonderAboutTuatara> Arrays are the better thing to use here |
09:22:18 | FromDiscord | <nikki> now i gotta sleep on the rest :p |
09:22:24 | FromDiscord | <iWonderAboutTuatara> I don't know how different they are though |
09:22:27 | FromDiscord | <iWonderAboutTuatara> Oh lol |
09:22:31 | FromDiscord | <iWonderAboutTuatara> This has been super useful |
09:22:33 | FromDiscord | <iWonderAboutTuatara> Thanks! |
09:22:44 | FromDiscord | <nikki> i'd say to just go low level and think about copying element by element |
09:22:54 | FromDiscord | <nikki> don't do "copy array to array with =" or sth |
09:22:55 | FromDiscord | <iWonderAboutTuatara> That's what I'm doing at the moment |
09:22:58 | FromDiscord | <nikki> like happened with the seqs |
09:23:03 | FromDiscord | <iWonderAboutTuatara> Oh nevermind that's not what I'm doing |
09:23:16 | FromDiscord | <nikki> the seqs seemed to have had seq-level copying done |
09:23:20 | FromDiscord | <iWonderAboutTuatara> That kind of is what I'm doing actually |
09:23:29 | FromDiscord | <nikki> i think making own procs for those primitives that have clear names like |
09:23:32 | FromDiscord | <iWonderAboutTuatara> I got lazy for buffers and just copied the entire seq |
09:23:37 | FromDiscord | <nikki> copy across face or sth |
09:23:44 | FromDiscord | <nikki> will be useful |
09:23:46 | FromDiscord | <iWonderAboutTuatara> Utility procs are desperately needed I agree |
09:24:14 | FromDiscord | <nikki> then the algo is made of those parts, then when someone reads a post like yours above it'll be like "copy edge. move <blah>" or whatever which seems good |
09:24:16 | FromDiscord | <iWonderAboutTuatara> For readability sake |
09:24:27 | FromDiscord | <nikki> people always think like algo code has to look hard to read but |
09:24:47 | FromDiscord | <nikki> stockfish, one of the top chess engines, is so readable |
09:24:52 | FromDiscord | <iWonderAboutTuatara> No, this is just super duper early stage and I didn't think to make a utility function for this kind of stuff |
09:24:54 | FromDiscord | <iWonderAboutTuatara> True |
09:24:59 | FromDiscord | <iWonderAboutTuatara> Stockfish code is beautiful |
09:25:04 | FromDiscord | <nikki> no just makijg a general point |
09:25:24 | FromDiscord | <nikki> not digging at urs 😄 |
09:25:40 | FromDiscord | <nikki> probs will also help when showing progress on discord lolol |
09:26:30 | Zoom[m] | If you do a solver, you'll probably need to output a sequence of resulting discreet steps in conventional form, so it may be beneficial in realizing your logic in those steps, to simplify. |
09:26:33 | FromDiscord | <iWonderAboutTuatara> No worries, I understood |
09:26:46 | FromDiscord | <iWonderAboutTuatara> @Zoom |
09:26:48 | FromDiscord | <nikki> great point Zoom |
09:26:56 | FromDiscord | <iWonderAboutTuatara> Currently, each rotation is its own function |
09:27:19 | FromDiscord | <iWonderAboutTuatara> When doing the solver, I guess I can just get it to store notation depending on what rotation it's applying? |
09:27:44 | FromDiscord | <nikki> this is such an interesting data layout puzzle lol |
09:27:52 | FromDiscord | <iWonderAboutTuatara> Honestly |
09:27:52 | Zoom[m] | I reason there should be only 2 functions, for horizontal and for vertical rotation, with subroutines, depending on row/column |
09:27:59 | FromDiscord | <nikki> i rly shud go to bed but i may be having voxel dreams |
09:28:17 | FromDiscord | <iWonderAboutTuatara> @Zoom |
09:28:31 | FromDiscord | <nikki> there are 3 axes of rotation |
09:28:40 | FromDiscord | <iWonderAboutTuatara> One of them don't matter |
09:28:49 | FromDiscord | <iWonderAboutTuatara> Wait no I'm insane |
09:28:53 | FromDiscord | <nikki> lulz |
09:28:55 | FromDiscord | <Rika> lol |
09:29:02 | FromDiscord | <iWonderAboutTuatara> There should be 3 in simplest case |
09:29:06 | FromDiscord | <nikki> only if ur in gimbal lock ;D |
09:29:09 | PMunch | Good morning everyone :) |
09:29:11 | FromDiscord | <iWonderAboutTuatara> What am I doing lmao |
09:29:16 | FromDiscord | <iWonderAboutTuatara> Good morning! |
09:29:29 | Zoom[m] | I'm pulling this out of my... nowhere. Never solved one. :D |
09:29:38 | FromDiscord | <iWonderAboutTuatara> Oh lmao |
09:29:51 | FromDiscord | <iWonderAboutTuatara> I actually think the 3 functions thing would cause more trouble than it's worth |
09:29:53 | FromDiscord | <nikki> none of us have solved one, that's why we're in a coding discord |
09:29:54 | FromDiscord | <iWonderAboutTuatara> Hard to tell |
09:29:56 | FromDiscord | <nikki> not a math discord |
09:30:12 | FromDiscord | <iWonderAboutTuatara> I actually do solve them lmao |
09:30:32 | FromDiscord | <iWonderAboutTuatara> I'm not good, I average like 18 seconds, but I know how to |
09:30:43 | FromDiscord | <nikki> can u do it w/ ur feet |
09:30:48 | FromDiscord | <iWonderAboutTuatara> I wish |
09:30:54 | FromDiscord | <iWonderAboutTuatara> Wca removed the feet event |
09:30:59 | FromDiscord | <iWonderAboutTuatara> Feet was the biggest meme |
09:31:00 | FromDiscord | <Rika> "not good"↵"averages at 18 seconds" |
09:31:05 | FromDiscord | <iWonderAboutTuatara> Lmaooo |
09:31:05 | FromDiscord | <Rika> motherfucker whats good then |
09:31:11 | FromDiscord | <iWonderAboutTuatara> 18s is very doable |
09:31:16 | FromDiscord | <iWonderAboutTuatara> Sub10 is very good |
09:31:16 | FromDiscord | <nikki> lol they're from mercury |
09:31:19 | FromDiscord | <nikki> where time is ... different |
09:31:26 | FromDiscord | <Rika> bitch i'd be surprised if i could solve one in a year |
09:31:36 | FromDiscord | <nikki> @Rika have u tried enabling arc |
09:31:41 | FromDiscord | <nikki> i heard it makes things faster |
09:31:41 | FromDiscord | <iWonderAboutTuatara> If you tried and used Google you'd do it in < 10 minutes |
09:31:50 | FromDiscord | <Rika> i already refactored myself to use C |
09:32:01 | FromDiscord | <iWonderAboutTuatara> Most people get to sub 20 within a year or so, I've been doing it for 3 years on and off |
09:32:05 | FromDiscord | <nikki> lol ur probs stuck in a corruption-based infinite loop |
09:32:14 | FromDiscord | <iWonderAboutTuatara> That's what happens when you use c |
09:32:25 | FromDiscord | <iWonderAboutTuatara> Something breaks and it's really hard to find out what |
09:32:32 | FromDiscord | <iWonderAboutTuatara> And then you go back to Nim |
09:32:40 | FromDiscord | <iWonderAboutTuatara> Maybe that's just me |
09:32:48 | FromDiscord | <nikki> the problem is assuming you're meant to find out |
09:32:52 | FromDiscord | <nikki> that's very self-centered |
09:33:12 | FromDiscord | <nikki> in c the machine giveth, and it taketh away |
09:33:22 | FromDiscord | <iWonderAboutTuatara> Well said |
09:33:55 | FromDiscord | <iWonderAboutTuatara> On that note, if I don't sleep the universe shall taketh away my ability to function tomorrow |
09:33:58 | FromDiscord | <iWonderAboutTuatara> Goodnight everyone |
09:34:24 | FromDiscord | <Rika> sleep well |
09:35:07 | Zoom[m] | Good night |
09:45:48 | * | suchasurge quit (Quit: Ping timeout (120 seconds)) |
09:46:08 | * | suchasurge joined #nim |
09:58:21 | ForumUpdaterBot | New thread by Jasonfi: Hot-reload an entire application?, see https://forum.nim-lang.org/t/7125 |
10:08:22 | ForumUpdaterBot | New thread by Jasonfi: Enabling hot-reloading causes the chronicles module to fail to compile, see https://forum.nim-lang.org/t/7127 |
10:36:09 | * | bung quit (Ping timeout: 260 seconds) |
10:37:49 | planetis[m] | <Zoom[m] "So I meant, if I'm not really us"> Well, there is dead code elimination maybe they are not included |
10:41:09 | * | bung joined #nim |
10:42:52 | Zoom[m] | planetis: you're right of course, I wasn't thinking clearly at the moment and didn't separate two reasons in my head (the second being I'd like the compiler to throw an error on runtime use) |
10:55:32 | * | abm joined #nim |
11:10:11 | * | bung quit (Quit: Lost terminal) |
11:26:16 | * | hmmmmm quit (Remote host closed the connection) |
11:44:27 | PMunch | Hmm, is it just me or are the st_mode and st_nlink fields swapped in this struct? https://man7.org/linux/man-pages/man2/stat.2.html https://github.com/nim-lang/Nim/blob/devel/lib/posix/posix_linux_amd64.nim#L220-L244 |
11:47:35 | PMunch | Curiously it was correct before posix got split: https://github.com/nim-lang/Nim/commit/ce86b4ad78aae11f62c50e4f46e8ab2a124356b4#diff-c41c09133bbe27fb23f2618d1246d3dd52941d5f3fb93e830d0873da0b97cb8cL267 |
11:49:51 | FromGitter | <ynfle> Will nim run on the new M1 macs? |
11:50:38 | PMunch | With the correct compiler flags? sure |
11:51:27 | PMunch | Might have to rewrap some stuff though |
11:53:20 | FromDiscord | <Rebel> Is there a way to not make ld crash? |
11:53:30 | FromDiscord | <Rebel> sent a code paste, see https://play.nim-lang.org/#ix=2ENA |
11:53:34 | Zoom[m] | Hey Peter, you streams get turned down A LOT by YT. |
11:53:40 | FromDiscord | <Rebel> (edit) "crash?" => "crash when compiling?" |
11:53:49 | Zoom[m] | Previous stream by 23db, last one by 19dB |
11:53:50 | PMunch | Zoom[m], yeah it's weird.. |
11:54:02 | Zoom[m] | You probably have your sound set too hot. |
11:54:20 | Zoom[m] | You can PM me with your processing chain and we can figure this out |
11:54:42 | PMunch | Can I PM you on IRC when you're on matrix? |
11:55:10 | Zoom[m] | Surprisingly, yes. I talked with TrustableCode this way |
11:55:25 | PMunch | Huh, cool |
12:02:54 | * | Vladar joined #nim |
12:03:34 | FromDiscord | <lqdev> @ynfle why wouldn't it? |
12:04:39 | * | rockcavera joined #nim |
12:06:01 | * | supakeen quit (Quit: WeeChat 2.9) |
12:06:37 | * | supakeen joined #nim |
12:10:47 | FromGitter | <ynfle> My guess is a lot of stuff the that is defined for mac only will change |
12:28:46 | ForumUpdaterBot | New thread by Satoru: What's the difference between `,` and `;` in the parameter list of procs?, see https://forum.nim-lang.org/t/7129 |
12:30:22 | * | krishtx joined #nim |
12:30:43 | * | krishtx left #nim (#nim) |
12:38:47 | ForumUpdaterBot | New thread by Satoru: Why is the implicit `result` so widely used?, see https://forum.nim-lang.org/t/7130 |
12:44:47 | ForumUpdaterBot | New thread by Daef: Marshal: loading nested TableRef segfaults, see https://forum.nim-lang.org/t/7131 |
13:14:11 | * | jjido joined #nim |
13:18:57 | FromDiscord | <inv> Hello, Are there any http-server for nim which supports chunk-streaming ? |
13:20:51 | FromDiscord | <flywind> chunk encoding? |
13:24:51 | FromDiscord | <inv> Yep, the main idea - to not just enable encoding - but to send long-running data, from database for example |
13:25:01 | Zoom[m] | PMunch: on your TermFM: KDE Plasma has a terminal embedded in the file browser which follows your position |
13:28:07 | Zoom[m] | Why not just write some shim layer to connect your terminal with an existing File Manager? |
13:34:51 | Zoom[m] | I think you don't want to rely on existing buses for communicating, so may be you can use FM which are easy to extend/have plugin support |
13:44:33 | FromDiscord | <inv> Ok, if no chunks - which RPC would you recommend? I cannot find gRPC for nim |
13:45:02 | FromDiscord | <inv> I see this one, but not sure is it ok not not: https://github.com/oswjk/nimtwirp |
13:47:39 | FromDiscord | <flywind> What about JSON RPC? |
13:47:54 | FromDiscord | <flywind> !repo nim-json-rpc |
13:47:54 | disbot | https://github.com/status-im/nim-json-rpc -- 9nim-json-rpc: 11Nim library for implementing JSON-RPC clients and servers 15 37⭐ 6🍴 |
13:49:48 | * | jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
13:53:42 | * | waleee-cl joined #nim |
13:55:05 | * | lritter joined #nim |
13:56:26 | * | Kaivo joined #nim |
14:00:17 | FromDiscord | <inv> Thx. Was thinking about something more "binary" |
14:03:40 | Zevv | inv: websocket? |
14:07:11 | Zoom[m] | PMunch: More on TermFM why not use kernel's inotify to watch for changes in the current dir? |
14:08:29 | * | vicfred_ quit (Quit: Leaving) |
14:19:56 | * | vicfred joined #nim |
14:28:22 | * | tsujp quit (Read error: Connection reset by peer) |
14:31:32 | PMunch | Zoom[m], well this was mostly just thrown together for fun to see how I could do it. I'm guessing the KDE Plasma solution requires you to use one particular shell/file manager? This just requires that your terminal sets $WINDOWID and you're good |
14:31:49 | PMunch | And what would I use inotify for? |
14:32:50 | Zoom[m] | PMunch: yeah, of course. I meant this idea even got to KDE. You can look at the implementation. |
14:33:59 | Zoom[m] | To update the view when something happens with the files. It may be that something else than your terminal changes them |
14:34:02 | PMunch | Aah right, yeah I guess it's not exactly a novel idea |
14:34:12 | PMunch | That is true |
14:34:40 | Zoom[m] | Also, it means it can be async to the term |
14:35:38 | * | vicfred quit (Quit: Leaving) |
14:37:04 | PMunch | Well you can interact with it regardless of what the term is doing, but the state of it is locked to what the term does |
14:37:57 | PMunch | Come to think of it I might want to move some stuff around, as it is now it will query all the files in the folder when you scroll, which isn't great |
14:39:46 | * | natrys quit (Quit: natrys) |
14:40:05 | Zoom[m] | File browsing is fun stuff but it's full of edge cases, especially when you start considering file preview, remote places and stuff. |
14:40:40 | Zoom[m] | On the other hand, I'm choosey, as I move stuff |
14:40:46 | Zoom[m] | a lot |
14:42:17 | PMunch | Oh for sure, this file manager is very basic |
14:45:45 | Zoom[m] | SpaceFM supports plugins, I think. I'd use that to talk to it. Write a daemon that follows your term and comunicates with the plugin. |
14:46:09 | Zoom[m] | This would be very useable fast |
14:47:00 | PMunch | Hmm, that seems complicated though :P |
14:47:22 | PMunch | This was 250 odd lines |
14:48:00 | PMunch | Hmm, SpaceFM seems a bit overkill |
14:48:10 | PMunch | And it has tabs, how is that going to work? |
14:48:26 | Zoom[m] | It can be very minimal, from whatI remember seeing it in some distros like Antix |
14:49:14 | Zoom[m] | I remember seeing it being used with tiling WMs showing nothing but a file panel |
14:49:27 | Zoom[m] | That's just from the top of my head |
14:49:41 | PMunch | That's probably possible to reconfigure though, which would break this |
14:49:46 | Zoom[m] | <PMunch "Hmm, that seems complicated thou"> But it's 250 for the current form, which is not a lot. What I'm talking about could be a few hundred lines for a complete project |
14:49:51 | PMunch | Possibly even just a keyboard shourtcut |
14:50:24 | PMunch | Fair enough, but that interaction might be harder than you expect |
14:51:43 | Zoom[m] | What do you envision it to be able to do besides exchanging paths? |
14:53:34 | PMunch | Not much tbh |
14:53:42 | PMunch | It was mostly meant as a PoC |
14:53:58 | PMunch | But icons based on file-type would be nice |
14:54:56 | Zoom[m] | I meant, any functionality that would complicate things if you'd went with my suggestion |
14:56:21 | PMunch | Oh, not really |
14:56:45 | PMunch | But the file manager I integrate with might have different plans which breaks this project |
14:57:16 | Zoom[m] | It depends on how stable their plugin API is (if they have one) |
14:57:53 | PMunch | True |
14:58:20 | Zoom[m] | If you get the daemon part and choose the protocol, the sink part shouldn't be hard to port between different FMs |
14:58:23 | * | opal quit (Ping timeout: 240 seconds) |
14:59:54 | PMunch | I mean the API so far is basically "show this path" <-> "could you move to this path?" |
15:03:45 | Zoom[m] | That's great, it means you're bound for success |
15:03:49 | Zoom[m] | Looky-looky: https://ignorantguru.github.io/spacefm/spacefm-manual-en.html#sockets |
15:04:26 | * | bung joined #nim |
15:06:51 | PMunch | Hmm, seems like it might be possible |
15:07:36 | Zoom[m] | So, just a daemon that binds the terminal with the socket |
15:08:18 | PMunch | But it needs to instruct SpaceFM to not show multiple tabs and such.. |
15:08:36 | Zoom[m] | And the good thing is, you can then write backends for other FMs |
15:09:36 | PMunch | Well that is already possible. My FM isn't really doing much of anything in regards to the terminal. It just reads an X window hints and runs `xdotools` on the terminal window. |
15:10:08 | PMunch | The part of TermFM that is actually interacting with the terminal is like 10 lines of code |
15:13:57 | PMunch | I guess I should use xdo instead of calling xdotools come to think of it |
15:16:25 | * | opal joined #nim |
15:17:06 | ForumUpdaterBot | New thread by AlectronikHQ: Which type to use for a flexible array?, see https://forum.nim-lang.org/t/7132 |
15:22:40 | * | NimBot joined #nim |
15:36:50 | planetis[m] | hey @PMunch is it ok if I use a version of your rpn macro as an example? https://github.com/nim-lang/fusion/pull/47 |
15:36:51 | disbot | ➥ New example for buildAst |
15:37:34 | PMunch | Sure, no problem .) |
15:38:06 | planetis[m] | thanks! |
15:48:06 | planetis[m] | i realised that i removed so much it doesn't even need to be a macro 🤦 |
15:48:31 | planetis[m] | anyway... |
15:49:06 | planetis[m] | its just an example |
16:02:27 | * | habamax quit (Quit: leaving) |
16:14:55 | PMunch | Nothing needs to be a macro |
16:15:01 | PMunch | It's just much more fun |
16:15:50 | * | jjido joined #nim |
16:17:04 | FromGitter | <iffy> Why are the addresses after createSam() different than within? I guess it's making a copy, but I don't want it to. https://play.nim-lang.org/#ix=2EOU |
16:21:59 | FromGitter | <deech> Is there any documentation on how to use `expandArc`? I checked the both the experimental and regular manual. |
16:28:43 | * | bonoot joined #nim |
16:30:16 | bonoot | does anyone else think `once`/`closureScope`/`rangeCheck` etc templates should be out of the system module? their names are too generic imo |
16:53:23 | * | hnOsmium0001 joined #nim |
16:53:39 | * | Troz joined #nim |
16:54:04 | Troz | Why does zeroMem have no side effects? |
16:55:10 | * | bonoot quit (Remote host closed the connection) |
17:02:50 | * | Troz quit (Remote host closed the connection) |
17:10:32 | disruptek | nim people think mm is side-effect-free. |
17:10:41 | disruptek | the nimpletons. |
17:13:59 | mipri | or rather, it's implicitly invoked to initialize variables, and there are no side effects there, but it's an error for the proc to have that pragma since you can use it to create side effects elsewhere, by zeroing arbitrary memory. it's a bug. |
17:17:36 | mipri | or, it's not a bug and noSideEffect permits stuff like zeroMem |
17:17:38 | mipri | manual: This means that the proc/iterator only changes locations that are reachable from its parameters and the return value only depends on the arguments. If none of its parameters have the type var T or out T or ref T or ptr T this means no locations are modified. |
17:19:30 | disruptek | like i said, nimskulls. |
17:19:49 | mipri | https://play.nim-lang.org/#ix=2EPk <- side-effect-free mutation |
17:21:35 | disruptek | unless it works under .strictFuncs, no one cares. |
17:21:43 | disruptek | the zeroMem, i mean. |
17:22:04 | mipri | similar to D's notion of purity rather than an FP one: https://dlang.org/spec/function.html#pure-functions , but you can get by avoiding obviously suspicious parameters like var, ref, ptr. |
17:22:51 | disruptek | i'm personally satisfied with strictFuncs and expect it to be the default in another release or two. |
17:24:52 | mipri | https://play.nim-lang.org/#ix=2EPn <- side-effect-free strictfunc mutation |
17:26:14 | disruptek | yeah, those are fine. |
17:27:30 | mipri | zeroMem works too: https://play.nim-lang.org/#ix=2EPo . the experimental manual just says "var parameter" |
17:27:48 | disruptek | yes, that's fine, too. |
17:28:00 | disruptek | you're explicitly telling it what it can mutate. |
17:28:37 | disruptek | try zero'ing random memory. |
17:43:20 | FromGitter | <iffy> What about https://play.nim-lang.org/#ix=2EPw ? |
17:46:56 | FromDiscord | <lqdev> values behind pointers in nim are mutable by definition |
17:47:19 | FromDiscord | <lqdev> your code sample is unsafe btw |
17:47:30 | disruptek | lol |
17:48:20 | disruptek | try zero'ing random memory. |
17:48:48 | FromDiscord | <lqdev> remember that trick i used in _MEM.RECALL(); to quit the game |
17:49:00 | disruptek | haha |
17:49:07 | disruptek | i vaguely remember something about that. |
17:49:15 | FromDiscord | <lqdev> `zeroMem(cast[pointer](0), 1)` |
17:49:38 | FromDiscord | <lqdev> yea let's just write zero to nil |
17:49:41 | FromDiscord | <lqdev> what could go wrong |
17:49:43 | disruptek | cast[pointer](0)[] |
17:50:05 | FromDiscord | <lqdev> excuse that, i wrote this during a game jam. could've just used nil, i know. |
17:50:35 | disruptek | clyybber: btw, we need halt. |
17:50:44 | disruptek | it's basically yield. |
17:51:19 | FromDiscord | <Quibono> What does the warning message mean when it says "Implementation of X expected" |
17:51:33 | FromDiscord | <Quibono> I changed some stuff in a proc and it threw that |
17:51:42 | disruptek | you probably changed a signature that no longer matches the proc definition. |
17:51:44 | FromDiscord | <lqdev> you forgot the = after your proc declaration |
17:51:47 | disruptek | or that. |
17:52:31 | FromDiscord | <Quibono> Lol, thank you, turned out it was a double ,, |
17:52:46 | FromDiscord | <Quibono> Gotta love stupid typos. |
17:52:52 | FromDiscord | <iWonderAboutTuatara> You forgot to implement the proc |
17:52:53 | disruptek | neat; that's probably a bug. |
17:52:58 | FromDiscord | <iWonderAboutTuatara> Oh lmao |
17:53:25 | FromDiscord | <iWonderAboutTuatara> By the way, how do I swap elements in an array with temp variables? |
17:53:36 | disruptek | swap |
17:53:42 | FromDiscord | <iWonderAboutTuatara> Swap complains that I'm giving it char char |
17:53:53 | FromDiscord | <iWonderAboutTuatara> They're in the same array |
17:54:01 | disruptek | repro? |
17:54:03 | FromDiscord | <iWonderAboutTuatara> without temp variables |
17:54:12 | FromDiscord | <iWonderAboutTuatara> Gimme a minute or so |
17:54:19 | disruptek | without temp variables? |
17:54:22 | FromDiscord | <iWonderAboutTuatara> I'll send a Nim playground like when I get back to my computer |
17:54:25 | FromDiscord | <iWonderAboutTuatara> Just using swap |
17:54:30 | FromDiscord | <iWonderAboutTuatara> You don't need temp variables |
17:54:32 | disruptek | what do you think swap uses? |
17:54:45 | FromDiscord | <iWonderAboutTuatara> It says it's faster than temp variables, so no idea |
17:55:00 | * | habamax joined #nim |
17:55:11 | mipri | https://play.nim-lang.org/#ix=2EPB - swap with two chars in the same array |
17:55:34 | FromDiscord | <iWonderAboutTuatara> I tried that and it wasn't happy with me |
17:55:38 | disruptek | maybe i'm thinking of a different impl. |
17:55:41 | mipri | if you change that 'var a' to a 'let a', you'll get an error that says: Error: type mismatch: got <char, char> |
17:55:41 | FromDiscord | <iWonderAboutTuatara> I'll repro in a minute |
17:55:49 | mipri | but the actual problem is shown below that |
17:55:49 | disruptek | coulda sworn it just created a :tmp. |
17:55:56 | FromDiscord | <iWonderAboutTuatara> It is definitely a var array |
17:56:01 | mipri | "but expression 'a[0] is immutable, not 'var'" |
17:56:12 | FromDiscord | <iWonderAboutTuatara> It gives that error yes |
17:56:19 | FromDiscord | <iWonderAboutTuatara> I haven't used a single let statement |
17:56:25 | FromDiscord | <iWonderAboutTuatara> If it helps the array are components of a type |
17:56:43 | mipri | that doesn't help at all |
17:56:59 | disruptek | swap uses a temp variable. |
17:57:33 | FromDiscord | <iWonderAboutTuatara> Huh |
17:57:54 | disruptek | look at compiler/ccgexprs.genSwap. |
17:58:17 | disruptek | but anyway, swap() as you know it should be faster than a swap() you could write. |
17:58:59 | FromDiscord | <iWonderAboutTuatara> > This is often more efficient than tmp = a; a = b; b = tmp. Particularly useful for sorting algorithms.↵↵var |
17:59:04 | FromDiscord | <iWonderAboutTuatara> Confusing |
17:59:11 | disruptek | but correct. |
17:59:52 | * | bung quit (Quit: Lost terminal) |
17:59:57 | FromDiscord | <Quibono> Okay, so new error, I've got an array of objects, i'm iterating through the objects in the array, and I'd like to change their values, but it says it cannot be assigned to. |
18:00:46 | FromDiscord | <iWonderAboutTuatara> sent a code paste, see https://play.nim-lang.org/#ix=2EPF |
18:00:49 | FromDiscord | <iWonderAboutTuatara> here's repro |
18:01:33 | mipri | Quibono: for v in array.mitems: v = whatever |
18:01:37 | FromDiscord | <iWonderAboutTuatara> https://play.nim-lang.org/#ix=2EPG |
18:02:03 | mipri | you don't have a let anywhere but parameters are immutable by default |
18:02:10 | mipri | so 'a' is the same thing as a 'let' |
18:02:28 | mipri | change that to 'a : var array[9, char]' |
18:04:41 | FromDiscord | <Quibono> So I have "s.curVal = rspJson["p"].getFloat" |
18:05:57 | FromDiscord | <Quibono> Sorry for not getting it I'm just still really unfamiliar with Nim. |
18:06:09 | disruptek | don't sweat it. |
18:06:16 | disruptek | everyone starts from zero. |
18:06:21 | FromDiscord | <Quibono> Like it's a conditional change to one object in the array |
18:06:52 | disruptek | in the same way that variables you declare are `var` or `let`, parameters in procs are `var` or ``. |
18:07:10 | FromDiscord | <iWonderAboutTuatara> oh I see |
18:07:16 | FromDiscord | <iWonderAboutTuatara> I didn't think that through very much aha |
18:07:17 | FromDiscord | <iWonderAboutTuatara> thanks |
18:07:32 | FromDiscord | <iWonderAboutTuatara> I had var arrays for the other functions |
18:07:37 | FromDiscord | <iWonderAboutTuatara> just brainslipped I guess |
18:07:40 | FromDiscord | <iWonderAboutTuatara> thanks! |
18:14:04 | FromDiscord | <Quibono> Lol, so now I fixed that, annnd json is raising an error somewhere in my parseJson(response) logic. |
18:14:44 | FromDiscord | <Quibono> `node.kind == JObject` [AssertionDefect] |
18:17:12 | * | jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
18:17:17 | FromDiscord | <Quibono> So it's not a JObject... |
18:18:38 | FromDiscord | <Quibono> Okay it's a JArrat |
18:32:25 | FromDiscord | <shadow.> is there an easy way to remove an item from a `Deque` by index? |
18:32:37 | FromDiscord | <shadow.> if it's a doubly-linked list internally it shouldn't be that hard right? |
18:32:46 | disruptek | it's a seq internally. |
18:33:11 | FromDiscord | <shadow.> wait what |
18:33:30 | FromDiscord | <shadow.> do seq's have o(1) insertion at start? |
18:33:35 | FromDiscord | <shadow.> (edit) "insertion at start?" => "prepend time complexity?" |
18:33:47 | FromDiscord | <shadow.> (edit) "o(1)" => "O(1)" |
18:34:13 | disruptek | nope. |
18:34:25 | FromDiscord | <shadow.> but the deque should? |
18:34:35 | disruptek | yep. |
18:34:40 | FromDiscord | <shadow.> hmm |
18:34:44 | FromDiscord | <shadow.> so it's more than just a few proc's lmao |
18:34:54 | FromDiscord | <shadow.> alright |
18:35:11 | FromDiscord | <shadow.> so then if i need fast filtering i should probably use a doubly linked list instead right |
18:35:29 | disruptek | !repo skiplists |
18:35:29 | disbot | https://github.com/disruptek/skiplists -- 9skiplists: 11generic skip list implementations💃 15 6⭐ 1🍴 |
18:36:13 | FromDiscord | <shadow.> :o |
18:36:40 | FromDiscord | <shadow.> could that be used as a priority queue as well? |
18:36:48 | FromDiscord | <shadow.> normal queue |
18:36:55 | disruptek | sure. |
18:37:23 | FromDiscord | <shadow.> does it have O(1) enqueue and dequeue? |
18:37:29 | disruptek | yes. |
18:37:47 | FromDiscord | <shadow.> alr nice thanks |
18:37:52 | disruptek | the manual indicates order for all procs afaik. |
18:38:21 | FromDiscord | <shadow.> oh nice! |
18:38:59 | FromDiscord | <Quibono> Can someone help me with working with JArrays? everything I try just seems to blow up. |
18:39:13 | disruptek | what isn't covered in the manual? |
18:39:46 | * | jjido joined #nim |
18:41:36 | disruptek | shadow.: i'm wrong; all the procs don't have order. |
18:42:20 | disruptek | operations inside the list are log n, everything else is 1. |
18:43:00 | disruptek | unless it's, like, count(), which is n, of course. |
18:50:13 | FromDiscord | <Daniel> did anyone ever use this: https://nimwc.org/ |
18:50:21 | FromDiscord | <Daniel> (edit) "did" => "Did" | "Didanyone ever use this: https://nimwc.org/ ... " added "?" |
18:54:39 | FromDiscord | <jseb> i'm curious to try and wrap a javascript library (three.js). I've read that: https://github.com/nim-lang/Nim/wiki/Nim-for-TypeScript-Programmers↵I still get no clue. Is there any other doc i could read, please ? |
18:55:02 | * | jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
18:59:56 | * | rockcavera quit (Remote host closed the connection) |
19:09:58 | * | jjido joined #nim |
19:10:11 | * | xet7_ quit (Quit: Leaving) |
19:11:56 | * | xet7 joined #nim |
19:21:47 | FromGitter | <deech> I have a module that defines an `Option` which is unrelated to the one in stdlib, I need both for my current module so I have my `Option` imported qualified, `import M as M` which hopefully means that when I use things from `M` I have to prefix the name with `M.` but it still complains about ambiguity with the stdlib `Option`. |
19:26:34 | FromGitter | <deech> Ah hah, I need to do `from M import nil`. |
19:34:51 | FromDiscord | <nikki> when you look up eg. foo["bar"] in a JsonNode it doesn't compute the hash of "bar" at compile time (bc. it's a string literal), does it |
19:36:06 | FromDiscord | <Quibono> Is there a standard decimal library people use? |
19:37:01 | FromDiscord | <nikki> what do you mean by a decimal library 🤔 |
19:37:34 | FromDiscord | <Quibono> I mean a library to properly represent decimals so I can write code that deals with money. |
19:37:51 | FromDiscord | <Quibono> Without weird $1.0000002 stuffs |
19:37:51 | FromDiscord | <nikki> what does a proper representation look like |
19:37:57 | FromDiscord | <nikki> for money you probably want to use integers |
19:38:04 | FromDiscord | <nikki> integers numbers of cents |
19:38:34 | FromDiscord | <Quibono> Yeah, I was just wondering if somebody had already written a library that does money. |
19:38:46 | FromDiscord | <nikki> ah got it |
19:39:07 | FromDiscord | <nikki> so, a standard money library |
19:39:33 | FromDiscord | <Quibono> Yeah, or just fixed point decimal library. |
19:39:50 | FromDiscord | <Quibono> Fixed precision I guess? |
19:40:09 | disruptek | there are a bunch of libs out there and more all the time. |
19:40:13 | * | rockcavera joined #nim |
19:41:25 | FromDiscord | <Quibono> https://github.com/JohnAD/decimal128 This seems like the newest/best. |
19:42:04 | FromDiscord | <nikki> interesting didn't realize this category of things was actually called decimal 😮 cool |
19:42:46 | FromDiscord | <Quibono> Although this one doesn't have very good documentation. |
19:43:49 | FromDiscord | <Quibono> Yeah, and Nim doesn't even have an obvious/reliable way to round to a set precision. |
19:44:00 | FromDiscord | <Quibono> (That I've seen) |
19:44:07 | FromDiscord | <nikki> really? seems actually somewhat documented which is more than can be said for a lot of random open source |
19:46:24 | FromDiscord | <Quibono> Well like I'd like them to show how to set precision (found it in the source code). |
19:46:45 | FromDiscord | <Quibono> I'm coming from Python where anything I'd use was pretty well documented, so yeah I'm spoiled with that I think. |
19:52:26 | * | hmmm joined #nim |
19:52:35 | hmmm | hallo! |
19:59:41 | hmmm | munchie I've seen your youtube stream |
19:59:55 | hmmm | you have a huge beard and a very nice editor setup |
20:00:00 | hmmm | is that vim? |
20:03:17 | FromDiscord | <Daniel> sent a code paste, see https://play.nim-lang.org/#ix=2ERb |
20:04:46 | FromDiscord | <Daniel> (edit) "https://play.nim-lang.org/#ix=2ERb" => "https://play.nim-lang.org/#ix=2ERc" |
20:06:50 | FromDiscord | <lqdev> @Daniel nah he's on IRC so you can ping him just by is name |
20:07:02 | FromDiscord | <lqdev> PMunch |
20:07:48 | * | lritter quit (Remote host closed the connection) |
20:18:58 | * | Kaivo quit (Quit: offline for the weekend) |
20:20:53 | * | aaronm quit (Ping timeout: 260 seconds) |
20:22:26 | FromDiscord | <Daniel> rgr, tnx |
20:27:49 | * | kungtotte joined #nim |
20:28:45 | hmmm | halp, I'm compiling my nim file on vscode with F6 from my project folder, but after execution I find myself in the folder "C:\Users\hmmm" |
20:28:58 | hmmm | I want to stay in the previous folder :| |
20:36:26 | * | aaronm joined #nim |
20:54:46 | disruptek | i want you to stay there, too. |
21:06:06 | * | vicfred joined #nim |
21:07:05 | hmmm | hey ! |
21:07:08 | hmmm | :| |
21:10:16 | * | habamax quit (Ping timeout: 240 seconds) |
21:21:25 | * | tane joined #nim |
21:21:31 | FromGitter | <iffy> I have `var obj = ptr Foo` and Foo.things is a Table[int, Thing]. If I `var a = obj.things[4]; a.name = "bob"` would you expect `obj.things[4].name` to be "bob"? Or is `a` a copy of obj.things[4]? |
21:22:35 | FromDiscord | <nikki> iffy: depends on whether `Thing` is a `ptr` or `ref` kind of thing, and also if not, if whether `.name` and `.name=` are actually procs that alias something else |
21:22:50 | FromDiscord | <nikki> also `var object = ptr Foo` is not actually syntax that works? i think |
21:23:00 | FromDiscord | <nikki> maybe you mean `var obj: ptr Foo` |
21:23:40 | FromGitter | <iffy> Yes on the typo. `type Thing = object \n name*: string` |
21:24:08 | FromGitter | <iffy> nikki: ^ |
21:24:10 | mipri | that's a value type, so a is a copy, and obj.things[4].name wouldn't change |
21:24:13 | FromDiscord | <nikki> then `a` is a copy i believe. you can also just trying it rq to verify |
21:24:43 | FromGitter | <iffy> How can I prevent myself from working on copies? I keep thinking I'm using Python :P |
21:24:56 | FromDiscord | <nikki> practice |
21:25:08 | FromDiscord | <nikki> my default is to actually think of things as copies haha |
21:25:10 | FromGitter | <iffy> As in, I'd like a compiler error to tell me I'm modifying a copy rather than the thing. |
21:25:30 | mipri | in Python everything's a reference type and in Nim almost everything's a value type. You really just have to stop thinking you're using Python |
21:25:45 | FromDiscord | <nikki> another thing i do is i actually don't `type X = ref Y` or `type X = ptr Y` a lot; i explicitly write `ptr` and `ref` in most places. unless it's a value type with a ptr or ref field, for sure |
21:25:48 | FromGitter | <iffy> I just watched Araq's video from a few days ago and he mentioned being able to disable copying? |
21:26:06 | mipri | you can define an {.error.} =copy proc for a type |
21:26:11 | FromDiscord | <nikki> yeah proc `=copy`(a: var T, b: T) {.error} |
21:26:40 | FromGitter | <iffy> In this case `=copy(a: var Thing, b: Thing) {.error.}` ? |
21:26:42 | mipri | but that won't save you if you're not thinking. even with copy disabled for Thing, you could make a copy of the name |
21:27:02 | FromDiscord | <nikki> practice is the main thing |
21:27:30 | FromDiscord | <nikki> don't look for tricks, just keep practicing. the `=copy` thing is for when you want that to actually be part of the type's meaning -- that it's non-copyable |
21:27:37 | FromGitter | <iffy> Is there something I can put right here? `var a = obj.things[4]` Something like `var a = breakIfCopy obj.things[4]`? |
21:27:40 | FromDiscord | <nikki> some times i do that and then still have an explicit `.copy` proc so i can only explicitly copy |
21:28:03 | FromDiscord | <nikki> just remember that `=` means to copy |
21:28:06 | mipri | since almost everything's a value type in Nim, almost any kind of assignment is going to copy what you're looking at |
21:28:33 | FromDiscord | <nikki> `=` is also copy for refs and ptrs -- the ref or ptr is copied, and the new copy just points at the same destination |
21:28:39 | FromGitter | <iffy> okay, I can retrain to think "everything's a copy" |
21:29:17 | FromGitter | <iffy> But `obj.things[4].name = "bob"` does no copying of Thing, right? |
21:29:25 | FromDiscord | <nikki> nope |
21:29:37 | FromGitter | <iffy> everything's a copy |
21:29:39 | FromGitter | <iffy> everything's a copy |
21:29:59 | Zevv | was that a pun |
21:30:01 | mipri | the right hand side of an assignment gets copied, not the left hand side |
21:30:50 | FromGitter | <iffy> right |
21:30:51 | FromDiscord | <nikki> there are a few other thiings -- you can mark a declaration as `{.byaddr.}` -- and also if it's the last read of the right hand side it may move it (but it should have equivalent visible behavior to copying (barring side effects in `=copy` hooks etc.)) |
21:31:24 | mipri | the point of copy ellision is performance rather than semantics though. you still get value semantics |
21:31:58 | FromDiscord | <nikki> i think it's not just performance, it makes move-only types actually useable |
21:32:07 | FromDiscord | <nikki> and that's a semantic thing |
21:32:19 | FromDiscord | <nikki> i use it for unique handles on resources in a few cases |
21:33:16 | FromDiscord | <nikki> but yeah for value-like types it should have equivalent visible behavior to copying as noted |
21:33:30 | FromGitter | <iffy> So if I made `obj.things: Table[int, ref Thing]` then `var a = obj.things[4]; a.name="bob"` would change `obj.things[4].name == "bob"`? |
21:34:07 | FromDiscord | <nikki> idk what "would change means" but that expression would be true after the assignment, yeah |
21:34:08 | mipri | yeah. try it |
21:34:32 | FromDiscord | <nikki> just make sure to have some non-nil ref at obj.things[4] |
21:36:03 | FromGitter | <iffy> k, I'll try it. I'm not actually doing bob and things. This is in a Java app that runs Nim in a thread and uses JNI. So "try it" isn't always straightforward, but I think it makes sense in my head. Thank you! |
21:36:33 | mipri | you can write a little bit nim in a file with dummy types and 'nim r file' to run it. or use play.nim-lang.org |
21:37:20 | FromGitter | <iffy> yep, I've made a few trimmed down samples (without the Java mess) but sometimes I trim out the problem |
21:39:33 | FromDiscord | <nikki> what's the timeline on the next nim minor release? 🤔 lots of destructor fixes in it |
21:51:36 | * | hmmm quit (Ping timeout: 240 seconds) |
22:13:58 | * | mal`` quit (Quit: Leaving) |
22:14:18 | * | hyiltiz quit (Remote host closed the connection) |
22:14:30 | * | mal`` joined #nim |
22:15:26 | * | hyiltiz joined #nim |
22:17:24 | FromDiscord | <Gyllou> is there a nim idiomatic way to override the hash function of primitives for use in a table? |
22:17:58 | * | hmmm joined #nim |
22:18:17 | FromDiscord | <Gyllou> or would i have to write a wrapper class for a primitive and make a custom hash for that |
22:19:00 | * | hmmm quit (Client Quit) |
22:19:47 | FromDiscord | <haxscramper> First solution that I come up with is to use `distinct`, but maybe there is a less drastic approach. But this is better than wrapper class |
22:20:01 | FromDiscord | <Gyllou> yea wrapper class seems ghetto |
22:20:30 | FromDiscord | <haxscramper> As it creates no runtime overhead and you could use all functions of original type by just converting back |
22:20:39 | FromDiscord | <Gyllou> im trying to write a graph library, one part will be made from mostly nim std, the other implementations will be for hpc |
22:20:54 | FromDiscord | <Gyllou> okay ill have to look at distinct i havent played with it yet |
22:21:32 | FromDiscord | <Gyllou> i want to override the has for primitives for the hpc version to use a more performant hash function for better throughput |
22:21:40 | FromDiscord | <Gyllou> (edit) "has" => "hash" |
22:24:45 | * | narimiran quit (Ping timeout: 240 seconds) |
22:26:59 | disruptek | i think tables will want to use a compatible hash but it doesn't have to be the same impl. |
22:27:06 | disruptek | i would use distinct, also. |
22:30:34 | FromDiscord | <haxscramper> Sadly there is no `template<class Hash = std::hash<Key>>`-like thing for table implementation, so `hash` for ints is kind of hard-coded. |
22:30:48 | disruptek | wouldn't make sense to change it. |
22:31:03 | disruptek | hash(x) == x, after all. |
23:38:28 | * | Vladar quit (Quit: Leaving) |
23:44:22 | * | tane quit (Quit: Leaving) |
23:44:34 | * | jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |