00:21:47 | * | xet7 quit (Ping timeout: 252 seconds) |
00:35:05 | FromDiscord | <Girvo> In reply to @soda "i havent programmed in": Same lol. To the point where we've ditched our existing (shit) C++ firmware for a new Nim-based one |
00:35:33 | FromDiscord | <Elegantbeef> Any compiler bugs so far girvo? |
00:36:16 | * | xet7 joined #nim |
00:43:32 | * | xet7 quit (Ping timeout: 240 seconds) |
00:44:50 | * | xet7 joined #nim |
00:53:32 | * | xet7 quit (Ping timeout: 240 seconds) |
00:56:39 | FromDiscord | <Girvo> Nothing so far! |
00:56:58 | FromDiscord | <Girvo> Running stable v1.6.4 at the moment. Any bug I've run into has been my own fault or a misconfig on my end |
01:44:23 | FromDiscord | <Girvo> One thing I want to take a crack at, is seeing if I can get Nim code running on the FreeRTOS windows port. Would be nice to be able to simulate some of our code. Dunno how thats going to go mind you |
01:53:33 | * | arkurious quit (Quit: Leaving) |
02:07:05 | FromDiscord | <exelotl> In reply to @whee "using db_odbc (so no": Yeah pretty much. I guess you want something like https://github.com/treeform/tabby but for DB results instead of CSV rows? That's starting to smell a lot like an ORM :P |
02:15:54 | FromDiscord | <congusbongus> maybe https://github.com/bluenote10/NimData which is pandas-like |
02:20:46 | FromDiscord | <exelotl> To roll it yourself I think you can't do it with just a template, you need a macro that takes a typedesc and generates the appropriate code to convert each field (`parseInt`, `parseFloat`, etc.) |
02:50:15 | FromDiscord | <whee> In reply to @exelotl "Yeah pretty much. I": It's kinda like an ORM, but not as heavy. What I really want is what db_sqlite/db_mysql/db_postgres do with DbColumns, but it's not available with db_odbc (probably because every database's implementation is unique and ODBC is more generic) |
03:00:41 | FromDiscord | <whee> I'll check these two repos out, though, I bet there's something in there that will give me ideas |
03:54:11 | FromDiscord | <Girvo> Like a Data Mapper? |
04:23:21 | FromDiscord | <soda> In reply to @Girvo "Same lol. To the": Nah C++ still has it's supremacy unfortunately and I'm sure i will code in it again, though maybe if in the future nim can produce smaller binaries and have a simpler memory mngmt model. then it could really replace it. |
04:23:52 | FromDiscord | <Elegantbeef> Is arc/orc not a simple memory management model? |
04:25:03 | FromDiscord | <soda> i really just want to be able to allocate and free memory on my own |
04:25:09 | FromDiscord | <Elegantbeef> You can |
04:25:15 | FromDiscord | <Girvo> You totally can, and I am right now 😄 |
04:25:20 | FromDiscord | <soda> i was told i can't here |
04:25:50 | FromDiscord | <Girvo> Combined with ARC its quite nice actually. I control the memory for the things that I _really_ need to in the embedded space, but ARC handles everything thats less important or more transient |
04:25:56 | FromDiscord | <Elegantbeef> You can allocate and free your own memory, just `ref`, `string`, `seq` do not have easy means of freeing |
04:26:07 | FromDiscord | <soda> yeah |
04:26:09 | FromDiscord | <soda> was told that too |
04:26:22 | FromDiscord | <soda> and they should |
04:26:35 | FromDiscord | <Girvo> For my part though, the only time I'm managing memory directly is because I'm crossing the boundary over to C/C++ libraries |
04:26:55 | FromDiscord | <Elegantbeef> Yea arc is very efficient so i dont really see the point in making those manually managable |
04:27:22 | FromDiscord | <Girvo> I mean I wouldn't be opposed to being able to, in some manner, but I certainly haven't need to so far and thats in the embedded space |
04:27:42 | FromDiscord | <Elegantbeef> For references you can do `GcRef` and `GcUnref` |
04:27:58 | FromDiscord | <Elegantbeef> Oh same for string/seq |
04:28:05 | FromDiscord | <Elegantbeef> So there you go you can manually manage them |
04:28:06 | FromDiscord | <Girvo> Yeah, some of the "embedded Nim" stuff does that |
04:28:45 | FromDiscord | <soda> the inclusion of gc makes the binary larger than what i'd need at work for eg |
04:28:56 | FromDiscord | <Elegantbeef> Arc doesnt include a GC |
04:29:04 | FromDiscord | <Elegantbeef> It's all move semantics |
04:29:12 | FromDiscord | <Girvo> Its reference counting now, with very little space needed for it |
04:29:19 | FromDiscord | <Elegantbeef> Just like RAII |
04:29:36 | FromDiscord | <Girvo> ^ so much so that binding C++ libraries is a lot nicer now, in my experience |
04:29:39 | FromDiscord | <soda> yeah i know that one doesn't |
04:29:45 | FromDiscord | <soda> In reply to @Girvo "^ so much so": yeah for sure |
04:29:54 | FromDiscord | <Girvo> Used to be really painful lol |
04:29:55 | FromDiscord | <soda> the syntax sugar approach to C++ is really nice |
04:30:05 | FromDiscord | <soda> (edit) "C++" => "object orientation" |
04:30:32 | FromDiscord | <soda> (edit) "doesn't" => "doesn't. there are other reasons too." |
04:30:58 | FromDiscord | <Girvo> Interestingly, using Nim with ARC has lead to _less_ memory usage than our existing C++ firmware, though thats confounded by the sheer crappiness of the original firmwares code lol |
04:32:16 | FromDiscord | <Girvo> @ElegantBeef I haven't used it: does GcUnref immediately free, or will it free when the scope ends? |
04:32:28 | FromDiscord | <Elegantbeef> It abides by the GC mechanism |
04:32:44 | FromDiscord | <Girvo> Alrighty |
04:34:47 | FromDiscord | <Girvo> sent a code paste, see https://play.nim-lang.org/#ix=3SBQ |
04:34:59 | FromDiscord | <Girvo> Though its wrong, coz it's missing the GC_Ref needed |
04:35:06 | FromDiscord | <Elegantbeef> Yea something like that |
04:35:17 | FromDiscord | <Elegantbeef> Though i was more talking about using `ref` instead |
04:35:47 | FromDiscord | <Girvo> Oh yeah haha, sorry I'm down in C land right now. This looks like I might be able to remove some of the C code I've had to write and move it to Nim even easier |
04:36:03 | FromDiscord | <soda> hmm |
04:36:16 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/czm |
04:36:19 | FromDiscord | <Elegantbeef> Lol element didnt liike that |
04:36:27 | FromDiscord | <Girvo> hahaha |
04:36:30 | FromDiscord | <Girvo> But yeah I get it |
04:36:51 | FromDiscord | <soda> is there documentation for how gcfree works with arc? |
04:36:54 | FromDiscord | <Girvo> I'm gonna have a look at the output and play, but yeah this looks super handy for some of the global-ish bits that I need to pass to ESP-IDF lol |
04:36:55 | FromDiscord | <Elegantbeef> This gives you that `malloc` like behaviour but with "safe" mechanism |
04:36:59 | FromDiscord | <Girvo> Yeah! |
04:37:04 | FromDiscord | <Girvo> (edit) "Yeah!" => "Yeah, nice!" |
04:37:10 | FromDiscord | <Elegantbeef> It decrements the reference counter and it's killed at end of scope just like normal |
04:37:55 | FromDiscord | <Elegantbeef> `GcRef` and `GcUnref` just decrement the reference counting mechanism and allow a collection of the memory after it |
04:38:20 | FromDiscord | <Girvo> Yeah. So its just scope-based then once the ref count is 0. Nice |
04:38:35 | FromDiscord | <Elegantbeef> Valgrind can ensure this |
04:39:09 | FromDiscord | <Girvo> Nice |
04:39:28 | FromDiscord | <Elegantbeef> Well it can show if it leaks(just use `-d:useMalloc`) |
04:39:53 | FromDiscord | <Girvo> In reply to @soda "is there documentation for": Not that I'm directly aware of. Most docs are around the more "vanilla" ways of programming Nim in my experience, though ARC itself is pretty conceptually simple, at least in practice anyway |
04:40:53 | FromDiscord | <soda> i need malloc(). free() and --gc:none |
04:40:54 | FromDiscord | <soda> 😂 |
04:40:59 | FromDiscord | <soda> (edit) "malloc()." => "malloc()," |
04:41:44 | FromDiscord | <Girvo> I mean those exist haha 🙂 You can absolutely write Nim as if it's a syntax-over-C basically. I did that ages ago writing some software for my Pebble smart watch |
04:41:59 | FromDiscord | <soda> yeah |
04:42:01 | FromDiscord | <Girvo> You do have to give up quite a bit of Nim's standard library though |
04:42:13 | FromDiscord | <Girvo> It very much ends up feeling like a different C syntax, including its lack-of-standard-library lol |
04:42:22 | FromDiscord | <soda> i have not spent a lot of time on this yet |
04:42:27 | FromDiscord | <soda> i might over the weekend |
04:43:01 | FromDiscord | <Girvo> Have a play! Inspecting the C output (esp. with `-d:danger`) is enlightening for this stuff too, I've found |
04:43:14 | FromDiscord | <soda> nice |
04:44:00 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/pIb |
04:44:30 | FromDiscord | <Elegantbeef> with `-d:freeIt` all memory is freed, but without it we leak obviously |
04:44:40 | FromDiscord | <Girvo> ooooh interesting |
04:45:09 | FromDiscord | <Elegantbeef> So you can use `ref` and `GcRef` similarly to `malloc` |
04:45:29 | FromDiscord | <Elegantbeef> And since the data for the GC is written next to the heap allocation you can pass it as a pointer to C and nothing bad happens |
04:45:51 | FromDiscord | <Girvo> Hell yeah. My task list has acquired a new to-do item lol. Defintely going to replace the C lib that I wrote to manage some of the icky-er stuff this way |
04:45:54 | FromDiscord | <Elegantbeef> Infact `var` and `ref` are C interopable atm |
04:46:24 | FromDiscord | <Elegantbeef> Though `{.byRef.}` is probably better than using `var` |
04:47:00 | FromDiscord | <Girvo> In reply to @Elegantbeef "Though `{.byRef.}` is probably": Why is that? (Honest question, I've been using `var` for the most part as the nesper library uses it) |
04:47:30 | FromDiscord | <soda> yah nice |
04:47:34 | FromDiscord | <Elegantbeef> for C interop in the case where there are a lot of `T` it's just generally more desirable |
04:47:43 | FromDiscord | <Girvo> Yeah that makes sense |
04:48:34 | FromDiscord | <Girvo> Oh btw, pthreads from `import posix` with `{.thread.}` is working wonderfully on the ESP32 🙂 |
04:48:43 | FromDiscord | <Girvo> So cheers for all the help on that |
04:48:47 | FromDiscord | <Elegantbeef> Nice! |
04:49:11 | FromDiscord | <Girvo> Even is working with my binding over the top of the `esp_pthreads.h` extensions, quite nicely too |
04:49:23 | FromDiscord | <Elegantbeef> Good to hear |
04:49:48 | FromDiscord | <Girvo> And fixed up a lot of the scoping/heap weirdness that working with straight FreeRTOS tasks had. Though I do want to go back and solve that once and for all too, at some point |
04:50:27 | FromDiscord | <Elegantbeef> Do you still need cdecl\`? |
04:50:33 | FromDiscord | <Girvo> Not that I need to: `pthreads.h` on FreeRTOS/ESP-IDF just wraps the Task stuff anyway, and the `esp_pthreads.h` extensions give you the extra RTOS functionality |
04:50:45 | FromDiscord | <Girvo> Nah, I am using `noconv` though |
04:51:14 | FromDiscord | <Girvo> Oh, its working great with a shared lock too |
04:54:16 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3SBS |
04:54:28 | FromDiscord | <Elegantbeef> Can safe a bit of typing |
04:54:30 | FromDiscord | <Elegantbeef> save even |
04:54:47 | FromDiscord | <Girvo> Yeah already done haha 🙂 Cheers though! |
04:54:55 | FromDiscord | <Elegantbeef> Ah |
04:55:57 | FromDiscord | <Elegantbeef> Good thing I do not drink if I drank every time you said "cheers" to me I'd be fucking dead 😛 |
04:56:00 | FromDiscord | <Girvo> Actually question, is there a way to export a pragma? I'm currently just re-defining it |
04:56:12 | FromDiscord | <Girvo> hahaha not wrong 😉 I'd kill most of my coworkers too based on our Slack chat |
04:56:41 | FromDiscord | <Elegantbeef> Seems like you cannot |
04:56:55 | FromDiscord | <Elegantbeef> so probably best to make it a macro |
04:57:04 | FromDiscord | <Girvo> Yeah might do |
04:57:15 | FromDiscord | <Girvo> Not that it matters right now, it's only defined in two files anyway |
05:00:26 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3SBV |
05:19:13 | FromDiscord | <Elegantbeef> [evoalg](https://matrix.to/#/@evoalg:matrix.org)\: where are all your questions anyway?! |
05:19:54 | FromDiscord | <evoalg> hehe ummm I've been a little busy 😉 |
05:20:25 | FromDiscord | <evoalg> but I'm glad you've been missing my questions 😉 |
05:22:57 | * | slowButPresent quit (Quit: leaving) |
05:46:59 | FromDiscord | <demotomohiro> @Elegantbeef Why don't your `rtosThread` macro use `macros.expectKind` proc? |
05:48:16 | FromDiscord | <Elegantbeef> expect kind doesnt give nice errors |
05:50:03 | FromDiscord | <Elegantbeef> `Error: Expected one of {nnkProcDef, nnkFuncDef}, got nnkMethodDef` is a useless error message to a programmer |
05:50:44 | FromDiscord | <Elegantbeef> Completely fine for helper macro procedures, completely useless for user facing code |
05:51:53 | FromDiscord | <Elegantbeef> `error` to me really makes macros feel like language features |
05:53:09 | FromDiscord | <m4ul3r> I'm trying to create a static binary on windows that has threading. I'm passing the args `--passC:"-static" --threads:on` on my `nim c` but the resulting binary is the same size without.↵The issue I'm running in to is a windows error saying `libwinpthread-1.dll is missing` when trying to run the binary on a different machine. Looking into that it is because the different windows machine doesn't have wingw64, thus the need for static link |
05:54:06 | FromDiscord | <Elegantbeef> You need to override the dll and statically link it |
05:54:18 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/nimc.html#dynliboverride |
05:54:33 | FromDiscord | <Elegantbeef> So you need to get a `.lib` file for that library |
05:54:50 | FromDiscord | <Elegantbeef> a static binary is not the same as static linking |
05:55:21 | FromDiscord | <m4ul3r> My bad, yes I do mean I need a static binary. I will check into this. Thanks! |
05:56:42 | FromDiscord | <demotomohiro> @Elegantbeef I see |
05:57:40 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/953894872270663710/image.png |
05:57:42 | FromDiscord | <Elegantbeef> Just for example |
05:58:19 | FromDiscord | <demotomohiro> You can copy your excutable with .dll files to other machine |
05:58:34 | FromDiscord | <Elegantbeef> That's the "proper" solution |
05:59:56 | FromDiscord | <Rika> In reply to @Elegantbeef "Seems like you cannot": you can't but the trick that the stdlib uses is to make a pragma pragma only module and include it |
06:00:45 | FromDiscord | <Elegantbeef> I dont know what that `include` keyword means, personally i dont even think it exists |
06:06:27 | * | Gustavo6046 joined #nim |
06:07:33 | FromDiscord | <huantian> Include that seems like a good way to make clean code |
06:10:31 | FromDiscord | <Rika> i mean whatever, you do you, i would rather the include than to make a bulky macro |
06:10:46 | FromDiscord | <Rika> since in this case its not going to break anything |
06:12:20 | FromDiscord | <Elegantbeef> Well the annoying part is that you cannot export the pragma so if you had a `rtosthreads.nim` you also have to include the pragma for cleaner code |
06:12:39 | FromDiscord | <Elegantbeef> Having to include it everywhere suuuuuucks |
06:21:01 | FromDiscord | <Rika> only if it is userfacing then i guess |
07:36:09 | * | PMunch joined #nim |
07:51:06 | * | Gustavo6046_ joined #nim |
07:51:10 | * | Gustavo6046_ quit (Remote host closed the connection) |
07:52:31 | * | Gustavo6046 quit (Read error: Connection reset by peer) |
08:06:32 | FromDiscord | <nariod> Hello guys,↵New Nim programmer here! Is there a chan for win32 API related dev? |
08:06:44 | FromDiscord | <Elegantbeef> You can just ask here |
08:07:08 | FromDiscord | <Rika> No |
08:07:15 | FromDiscord | <Rika> There is no channel |
08:07:40 | FromDiscord | <nariod> OK thx! |
08:16:10 | PMunch | Hmm, I have a small program which sends a bunch of request to my service and measures latencies. Is there a nice little library to display a list of values as a distribution graph? |
08:20:01 | FromDiscord | <Elegantbeef> Scinim has plotty |
08:20:32 | PMunch | Hmm, I was thinking something simple in the terminal |
08:21:21 | PMunch | I guess I could easily hack something together with drawille |
08:22:10 | FromDiscord | <Rika> Doesn’t curses/-like libraries have graphing tools |
08:22:48 | FromDiscord | <Elegantbeef> There is also https://github.com/Yardanico/asciigraph |
08:23:55 | PMunch | Hmm, asciigraph seems very close to what I want |
08:24:48 | FromDiscord | <Elegantbeef> Jesus it's like 3 functions |
08:26:40 | PMunch | I guess if I do a countTable and get them out ordered and pass it to asciigraph it might work |
09:04:44 | PMunch | Hmm, I think I need a log scale for this.. |
09:09:21 | * | [R] quit (Read error: Connection reset by peer) |
09:22:01 | FromDiscord | <Phil> Design question! |
09:22:09 | PMunch | Design answer! |
09:25:56 | FromDiscord | <Phil> sent a long message, see https://paste.rs/M70 |
09:27:02 | FromDiscord | <Phil> Ah, the deletion logic-wise also should happen in the service, because the repository shouldn't deal with what happens on the disk imo, only what happens in the database. |
09:27:22 | FromDiscord | <Phil> service, controller and repository are all separate modules |
09:27:37 | FromDiscord | <Elegantbeef> 'This must be in that order because only after storing it on disk do you know what filepath the file will have and thus which filepath you need to store in the database entry.' ? |
09:28:26 | FromDiscord | <Elegantbeef> How do you download the file to a directory without knowing what directory to store it to? |
09:29:07 | FromDiscord | <Phil> I know in which directory it will be, but I don't know for sure the filename it'll have after storing. ↵That is because if the user saves a file "lala.jpg" and that file already exists, I append a random string of 10 chars to the end of the filename |
09:29:39 | FromDiscord | <Phil> so even if the user uploads "lala.jpg" the final file path may be "/my/dir/lala_LFASH91m.jpg" |
09:30:00 | PMunch | It depends on your database logic, but try/except sounds like the logical choice if it throws an exception |
09:30:20 | PMunch | And you probably wouldn't re-raise it, but that depends on what kind of logic you have further up |
09:30:48 | FromDiscord | <Phil> The std/db_sqlite module will be throwing a DBError essentially because the database itself will throw `CHECK constraint failed: wikientries.models_Only_One_Article` |
09:31:46 | FromDiscord | <Elegantbeef> I still dont understand how you wouldnt know that it's going to be named with the random characters |
09:31:55 | FromDiscord | <Phil> Ah, right, that piece of info is missing.↵In my controller I try-except my service calls because if something goes wrong, my except is returning a HTTP400/500 whatevs with a custom message attached |
09:32:03 | FromDiscord | <enthus1ast> I've build image upload service, by hashing the image, creating folder by the name of the hash and put the image there, this way i also could put a generated thumbnail next to the image↵(@Phil) |
09:32:17 | FromDiscord | <enthus1ast> and no naming issues |
09:33:10 | PMunch | Yeah keeping the user-supplied filename is probably just going to cause issues |
09:33:14 | FromDiscord | <enthus1ast> must not be a crypto secure hash, something fast |
09:33:49 | FromDiscord | <enthus1ast> the other benefit of this is that you can just point the webserver to the public dir, an noone can guess the whole path because of this hash |
09:33:57 | FromDiscord | <katlyn> i think elegantbeef's point is that you can determine the file name, write to the database, then write the file just as easily as the order you do things now - you just swap the two storage steps |
09:34:10 | PMunch | But yeah, catch the DBError where the file was created, delete the file, then re-raise it or wrap it in a new exception type. |
09:34:16 | FromDiscord | <Elegantbeef> Indeed my point |
09:34:47 | PMunch | Well that works until two people try to upload a file called the same at the same time |
09:35:36 | FromDiscord | <Phil> In reply to @Elegantbeef "I still dont understand": I mostly don't like the design that creates of splitting the proc that figures out the name from the proc that stores the file (which is logic that is housed in a separate utils module), it means my code in the service needs to be aware that there's a possible file-name-change inbound.↵And also the possible issue that you might have name-collisions (as unlikely as they might be) during |
09:37:44 | FromDiscord | <Phil> In reply to @enthus1ast "I've build image upload": I like this solution so far, though it might be more computationally intensive than strictly necessary (no idea how fast hashing an image to a string is, really). Why not only hash the image to a string and use that string as a normal filename instead of making a dir out of it? |
09:38:58 | FromDiscord | <Rika> I’m late; so you want a rollback outside of only the database? |
09:39:07 | FromDiscord | <Elegantbeef> Use the hash of `epochTime` and be very funny |
09:39:10 | FromDiscord | <Phil> In reply to @Rika "I’m late; so you": Pretty much |
09:39:36 | FromDiscord | <Phil> wait... why don't I just append a unix timestamp at each file's end.... |
09:39:47 | FromDiscord | <Elegantbeef> Fuck what a magical idea |
09:40:03 | FromDiscord | <Phil> I mean, you were the one that had it 😛 |
09:40:07 | FromDiscord | <Rika> I have no idea what you’re thinking |
09:40:20 | FromDiscord | <Elegantbeef> That someone likes to overcomplicate isues |
09:40:37 | FromDiscord | <Phil> No wait, false alarm, still don't like that logic flow. |
09:41:02 | FromDiscord | <Elegantbeef> I wasnt going to let you use it anyway |
09:41:09 | FromDiscord | <Elegantbeef> Under some weird IP law i own it probably |
09:41:31 | FromDiscord | <Phil> Runs into the same issue as before that I essentially insert database logic into the middle of file-storage-logic |
09:41:31 | FromDiscord | <enthus1ast> @Phil\: have you considered my folder solution? |
09:41:39 | FromDiscord | <enthus1ast> much more robust and deterministic |
09:41:41 | FromDiscord | <Phil> In reply to @enthus1ast "<@180601887916163073>\: have you considered": Yeh, I threw in the question for why folder |
09:42:03 | FromDiscord | <Elegantbeef> The fuck is a "database"? |
09:42:18 | FromDiscord | <Phil> A cookie |
09:42:20 | FromDiscord | <Phil> tasty too |
09:42:33 | FromDiscord | <Elegantbeef> One day I'll not be able to make that joke |
09:42:54 | FromDiscord | <Elegantbeef> I'll have the silly idea to make a game that needs a backend eventually and enter hell |
09:43:34 | FromDiscord | <Phil> Don't larger games need to store states of various places in the world in a database? |
09:43:53 | FromDiscord | <Phil> Assuming an RPG or something of the sort |
09:44:31 | FromDiscord | <Phil> In reply to @enthus1ast "I've build image upload": Ohhh you made the hash the folder so you could preserve the filename |
09:45:04 | FromDiscord | <enthus1ast> yes |
09:45:14 | * | krux02 quit (Remote host closed the connection) |
09:45:17 | FromDiscord | <enthus1ast> and was also generating thumbnails for the images |
09:45:21 | FromDiscord | <enthus1ast> and put them in the same folder |
09:45:30 | FromDiscord | <Phil> hmmmm |
09:46:08 | FromDiscord | <enthus1ast> this way i could do\: \<hash\>/thumb.x.y.png |
09:46:27 | FromDiscord | <Phil> On the one hand, that's some degree of complexity. On the other, it gives me a lot of flexibility to do things with the image without turning it into an insane mess, which is nice |
09:46:35 | FromDiscord | <enthus1ast> and its deterministric because i can easily create the whole path name from the original file |
09:47:12 | FromDiscord | <enthus1ast> AAAND it preserves the original filename even when hosted on a cdn or webserver |
09:47:17 | FromDiscord | <Phil> Yeh, I see the benefits, I think it's a really good solution, particularly if you do stuff like creating thumbnails etc. |
09:47:29 | FromDiscord | <Elegantbeef> Sure but i'm a failure of a dev so i'll never work on anything big |
09:48:22 | FromDiscord | <Phil> Denied, you're cool beef, if you put yourself in the oven you could even be hot beef |
09:48:42 | PMunch | @Elegantbeef, okay these are the two graphs: http://ix.io/3SCD |
09:48:55 | PMunch | Not sure if I did the bucketing correctly though.. |
09:49:10 | FromDiscord | <Phil> CLI graphs? |
09:49:12 | FromDiscord | <Phil> I'm on board |
09:49:17 | PMunch | Yup |
09:49:35 | FromDiscord | <Phil> I like the bottom representation |
09:49:41 | FromDiscord | <Phil> Really clear and easy to look at |
09:50:16 | PMunch | The bottom one is from asciigraph, the top one is just something I threw together with drawille |
09:50:37 | PMunch | I like the resolution of the top one though |
09:51:08 | FromDiscord | <Phil> Hmm yeah you can go 4 times more precise |
09:51:15 | FromDiscord | <Phil> Is there a way to increase contrast to the background? |
09:51:37 | FromDiscord | <Rika> No |
09:51:43 | FromDiscord | <Rika> Well yes but it’s terminal dependent |
09:51:59 | FromDiscord | <Rika> Though tbf that pixel thing is also terminal dependent to some degree |
09:52:04 | FromDiscord | <Phil> In reply to @enthus1ast "AAAND it preserves the": What did you use for image hashing? |
09:52:51 | FromDiscord | <Rika> You could probably use xx hash |
09:53:09 | FromDiscord | <enthus1ast> back then i've used sha1 |
09:53:09 | PMunch | Now I just need to figure out how to do log scales.. |
09:53:12 | FromDiscord | <enthus1ast> but xx hash |
09:53:15 | FromDiscord | <enthus1ast> is faster i |
09:53:28 | FromDiscord | <Phil> is that something I can google or is xx a placeholder? |
09:53:42 | FromDiscord | <enthus1ast> https://github.com/OpenSystemsLab/xxhash.nim |
09:54:07 | FromDiscord | <Rika> https://github.com/khchen/hashlib if you want more hash algorithms |
09:54:13 | FromDiscord | <enthus1ast> have a look i cant remember which one was the fastest xx hash |
09:55:14 | FromDiscord | <Rika> xx hash is good because it isn’t cryptographic like SHA is lol |
09:55:43 | FromDiscord | <enthus1ast> yes, but there is even a higher speed version of xxhash |
09:56:03 | FromDiscord | <enthus1ast> Version Speed on 64-bit Speed on 32-bit↵XXH64 13.8 GB/s 1.9 GB/s↵XXH32 6.8 GB/s 6.0 GB/s |
09:56:09 | FromDiscord | <Phil> Anything majorly speaking against std/hashes? |
09:56:26 | FromDiscord | <enthus1ast> yes, you could not easily do them on commandline |
09:56:47 | FromDiscord | <enthus1ast> for a default hash you can generate your pathname on commandline |
09:57:07 | FromDiscord | <enthus1ast> and on the next nim hash change they'll break |
09:57:50 | FromDiscord | <Rika> In reply to @Isofruit "Anything majorly speaking against": Not really |
09:58:16 | FromDiscord | <Rika> In reply to @enthus1ast "and on the next": I am unsure about stability of the hashes module but I don’t think it will happen |
09:58:23 | FromDiscord | <Phil> I don't think I understand enthus1ast, why am I caring about commandline? |
09:58:35 | FromDiscord | <Rika> I don’t understand either |
09:59:08 | FromDiscord | <enthus1ast> there will be a day when you must administrate your website, ( i did in a 5+ years runtime of my service) |
09:59:21 | FromDiscord | <enthus1ast> then its nice when you can just generate the hash by commandline |
10:00:07 | FromDiscord | <Phil> Ah, to figure out where a given image was stored |
10:00:13 | FromDiscord | <Rika> You could just make the tool? |
10:00:20 | FromDiscord | <Rika> It’s not particularly hard I’d say |
10:00:57 | FromDiscord | <Rika> Nim used wy hash for reference |
10:01:02 | FromDiscord | <Rika> Uses |
10:01:07 | FromDiscord | <enthus1ast> echo /path/to/my/public/ `xxhash myFile` |
10:02:11 | FromDiscord | <enthus1ast> i do not claim this is the perfect solution, but its stuff i found useful for my service |
10:02:17 | FromDiscord | <Phil> check |
10:05:29 | PMunch | Hmm, I really need to get a better font.. |
10:05:36 | FromDiscord | <enthus1ast> also xxhash has a streaming api, i've used this for larger files |
10:06:13 | FromDiscord | <enthus1ast> (in another project though, but still) |
10:09:57 | FromDiscord | <Phil> I made a TODO to refactor image uploading to follow your suggestion since I like it, I'll get around to it when I find the time |
10:23:33 | FromDiscord | <fbpyr> sent a long message, see https://paste.rs/qAy |
10:26:35 | FromDiscord | <fbpyr> if I manually placed the `gitlib2.so` in the same directory, there were no complaints about the missing .so .. |
10:43:54 | * | dtan joined #nim |
10:59:34 | * | dtan quit (Quit: Quit) |
10:59:50 | FromDiscord | <abdu> How do we have build_all able to pause and then resume again in its build process ?↵Please help out |
11:01:45 | * | dtan joined #nim |
11:08:32 | * | dtan quit (Ping timeout: 240 seconds) |
11:14:35 | FromDiscord | <enthus1ast> [fbpyr](https://matrix.to/#/@fbpyr:tchncs.de)\: either load the so by hand useing dynlib (which requires a wrapper patch i guess) or use another programm that just unpacks your app and the so, then calls your app, or use a installer creator (or your distributions package manager), or bundle all in a zip file |
11:15:40 | FromDiscord | <enthus1ast> the correct solution would be imho to use your distributions package manager |
11:15:50 | FromDiscord | <enthus1ast> another solution is to statically link everything |
11:16:45 | FromDiscord | <enthus1ast> but depending on your distro, creating a package might be an even bigger project than your app \:) (hem hem .deb hem hem) |
11:18:57 | FromDiscord | <enthus1ast> @abdu\: why would you need this? |
11:51:33 | FromDiscord | <fbpyr> sent a long message, see http://ix.io/3SDh |
11:56:50 | PMunch | Hey, Futhark has gotten 100 stars :) |
12:16:40 | FromDiscord | <enthus1ast> [fbpyr](https://matrix.to/#/@fbpyr:tchncs.de)\: for windows you could use nsis or inno setup |
12:19:08 | FromDiscord | <enthus1ast> or just a zip folder \:) |
12:19:49 | FromDiscord | <enthus1ast> but with such installer creators its easy to eg add desktop start menu shortcuts, create uninstallert etc |
12:43:13 | * | slowButPresent joined #nim |
12:45:28 | FromDiscord | <fbpyr> well my installer only installs a couple of small addins from git repos for existing applications (using git as autoupdater), so I would not need any desktop shortcuts. ↵but maybe more 'officially looking installers' are a better way for the users.. 🤔 |
12:49:39 | FromDiscord | <demotomohiro> @PMunch Congratulations! |
13:05:12 | * | arkurious joined #nim |
13:15:53 | * | xet7 joined #nim |
13:36:35 | * | Guest67 joined #nim |
13:44:33 | * | Guest67 quit (Quit: Client closed) |
13:44:55 | * | juztziggs joined #nim |
13:50:21 | * | juztziggs quit (Quit: Client closed) |
14:24:22 | FromDiscord | <auxym> In reply to @fbpyr "well my installer only": you can use wix to build MSIs. it's a bit confusing but gets better once you wrap your head around the MSI format. It's basically a database with a dozen or so tables (eg there's a table with files to be installed), so you look up the reference for the tables. |
14:24:58 | FromDiscord | <auxym> this: https://wixtoolset.org/ |
14:25:30 | PMunch | Hmm, I did start working on a Nim based Windows installer generator after having to write InnoScript for some work project |
14:25:47 | PMunch | Someone else took over the project however, so I never completed it |
14:26:08 | PMunch | Well, they took over creating the installer, not the project itself |
14:52:31 | PMunch | Anyone else having trouble with GitHub? |
14:52:48 | nrds | <Prestige99> yep |
14:52:50 | nrds | <Prestige99> lot of outages rn |
14:54:43 | PMunch | Hmm, that's inconvenient.. |
14:58:36 | nrds | <Prestige99> very :P https://www.githubstatus.com/ |
14:59:33 | FromDiscord | <Rika> the whole thing is degraded xd |
15:00:06 | nrds | <Prestige99> Time to answer emails |
15:00:24 | * | vicecea quit (Remote host closed the connection) |
15:00:52 | * | vicecea joined #nim |
15:02:42 | * | PMunch quit (Quit: Leaving) |
15:04:05 | FromDiscord | <Rika> how dreadful |
15:18:07 | FromDiscord | <auxym> oh damn... is this why my platformio randomly stopped working? Here I am just spent an hour reinstalling vscode, nuking my profile, reinstalling Anaconda... D: |
15:18:39 | FromDiscord | <Rika> damn |
15:19:33 | FromDiscord | <auxym> I'm becoming less and less of a fan of PIO, not the first time it randomly breaks on me. but work is work :\ (and c++ ugh) |
15:58:16 | * | xet7 quit (Ping timeout: 245 seconds) |
15:59:18 | * | xet7 joined #nim |
16:14:07 | * | zgasma quit (Quit: nyaa~) |
16:26:44 | FromDiscord | <Daan Breur> matrixcheck |
16:30:28 | FromDiscord | <exelotl> matrix, heck |
16:30:51 | FromDiscord | <Daan Breur> lol |
16:42:11 | * | zgasma joined #nim |
17:10:37 | FromDiscord | <Shinyzenith> has anyone faced this issue before? https://github.com/PMunch/futhark/issues/22 |
17:10:51 | FromDiscord | <Shinyzenith> and yes I have linked my binary with wayland-server |
17:45:08 | * | pro joined #nim |
18:00:02 | FromDiscord | <shrekman!> havent used nim yet, how much would an exe of hello world take in nim |
18:01:24 | FromDiscord | <Daan> In lines of code or in compiled file size? |
18:01:53 | nrds | <Prestige99> https://play.nim-lang.org/#ix=1Kcr <- in code |
18:04:23 | Amun-Ra | shrekman!: a few KB, if you worry about the size write in asm |
18:20:06 | * | krux02 joined #nim |
18:25:24 | FromDiscord | <Rika> someone got hello world down to 160b in nim i believe |
18:25:29 | FromDiscord | <Rika> but its not idiomatic, naturally |
18:28:52 | FromDiscord | <mratsim> In reply to @shrekman! "havent used nim yet,": https://hookrace.net/blog/nim-binary-size/ |
18:29:19 | Amun-Ra | it needs a refresh tho |
18:33:11 | FromDiscord | <shrekman!> In reply to @Amun-Ra "shrekman!: a few KB,": im looking for an efficient, portable language |
18:33:23 | FromDiscord | <shrekman!> does it compile to cross platform easily? |
18:34:01 | FromDiscord | <Rika> i mean i guess, what platforms are we talking about |
18:49:53 | FromDiscord | <shrekman!> debian based systems, windows and maybe mac |
18:50:11 | FromDiscord | <Rika> then sure that's easy for nim |
18:50:23 | FromDiscord | <Rika> there's also other stuff like solaris haiku bsd embedded systems etc |
18:50:35 | * | pro quit (Quit: pro) |
18:56:54 | Amun-Ra | shrekman!: well, imho you found it |
19:05:50 | FromDiscord | <TennisBowling> sent a code paste, see https://play.nim-lang.org/#ix=3SGL |
19:06:39 | FromDiscord | <huantian> seems good |
19:07:30 | * | Gustavo6046 joined #nim |
19:07:32 | FromDiscord | <Rika> probably needs the type for url, i dont remember types being inferrable in procedure signatures |
19:07:48 | FromDiscord | <Rika> !eval func initNodeInstance(url = ""): int = discard |
19:07:51 | NimBot | <no output> |
19:07:56 | FromDiscord | <Rika> huh they do |
19:07:58 | FromDiscord | <Rika> cool |
19:08:09 | FromDiscord | <huantian> you just have to make sure it's non ambiguous ig |
19:08:27 | FromDiscord | <Rika> status btw is by default false |
19:08:54 | FromDiscord | <TennisBowling> sent a code paste, see https://play.nim-lang.org/#ix=3SGN |
19:09:05 | FromDiscord | <TennisBowling> (edit) "https://play.nim-lang.org/#ix=3SGN" => "https://paste.rs/wuE" |
19:09:07 | FromDiscord | <TennisBowling> In reply to @Rika "probably needs the type": so should I do `url: string = ""`? |
19:09:11 | FromDiscord | <Rika> no no |
19:09:13 | FromDiscord | <Rika> it works |
19:09:13 | FromDiscord | <Rika> its fine |
19:09:20 | FromDiscord | <huantian> In reply to @TennisBowling "cool! I also try": this is because self is immutable |
19:09:31 | FromDiscord | <Rika> and you cannot make it mutable because your proc is async |
19:10:09 | FromDiscord | <Rika> you kinda can bodge it by using `ref` |
19:10:42 | FromDiscord | <TennisBowling> why can't it be mutable when async? |
19:11:50 | FromDiscord | <TennisBowling> In reply to @Rika "you kinda can bodge": so does this just set `self` to the pointer of the object? |
19:12:04 | FromDiscord | <Rika> semantics are weird, you can hold futures without `await`ing them so once you call it and take its future the value is now changed even if your proc hasnt "finished" running, i guess |
19:12:08 | FromDiscord | <Rika> this is just a guess |
19:12:23 | FromDiscord | <Rika> In reply to @TennisBowling "so does this just": no it means that you would have to pass in a reference which is annoying |
19:12:41 | FromDiscord | <Rika> or you'd have to deal with reference semantics everywhere else if youre making the type ref |
19:12:47 | NimEventer | New thread by DMisener: Simple linked list questions: Correct proc signature for first(), see https://forum.nim-lang.org/t/9019 |
19:13:19 | FromDiscord | <TennisBowling> wait but if I call it with `NodeInstance.setOnline()` do I need to pass the nodeinstance ref? |
19:13:48 | FromDiscord | <Rika> you'd need to create a reference as ive said and yes it is annoying |
19:13:55 | FromDiscord | <Rika> even then i guess it doesnt work |
19:14:03 | FromDiscord | <Rika> so your only option is to make the whole type ref |
19:16:06 | FromDiscord | <TennisBowling> In reply to @TennisBowling "hey. In python I": with the initNodeInstance I'm getting that it can make side effects, but how? |
19:17:57 | reversem3[m] | Getting illegal storage access running nimble runr for nico https://play.nim-lang.org/#ix=3SGO |
19:17:59 | FromDiscord | <huantian> In reply to @Rika "semantics are weird, you": <https://play.nim-lang.org/#ix=3SGV> it mentions violating memory safety which ig sure |
19:18:25 | FromDiscord | <huantian> In reply to @TennisBowling "with the initNodeInstance I'm": It's just a normal proc, you can do anything you want like `echo`ing |
19:18:25 | FromDiscord | <Rika> In reply to @TennisBowling "with the initNodeInstance I'm": is what you posted the whole code? |
19:18:27 | FromDiscord | <Rika> for the proc |
19:18:38 | FromDiscord | <Rika> In reply to @huantian "It's just a normal": he uses func here |
19:18:43 | FromDiscord | <huantian> oh huh |
19:19:02 | FromDiscord | <TennisBowling> In reply to @Rika "for the proc": what proc? |
19:19:20 | FromDiscord | <huantian> In reply to @Rika "he uses func here": oh I didn't notice |
19:19:50 | FromDiscord | <TennisBowling> should I use proc for the init? |
19:19:57 | FromDiscord | <huantian> if you want side effects you should use proc |
19:20:33 | FromDiscord | <huantian> func is a shortcut for `{.noSideEffect.}` |
19:20:34 | * | krux02 quit (Read error: Connection reset by peer) |
19:20:52 | * | krux02 joined #nim |
19:21:13 | FromDiscord | <huantian> In reply to @huantian "<https://play.nim-lang.org/#ix=3SGV> it mentions vi": hm actually maybe it does make sense, async does expand into iterators? |
19:22:09 | FromDiscord | <TennisBowling> In reply to @huantian "if you want side": right but I don't see how this func can make side effects |
19:22:16 | FromDiscord | <TennisBowling> I probably misunderstand side effects |
19:23:04 | FromDiscord | <Rika> side effects can be echoing or mutating a global |
19:23:10 | FromDiscord | <huantian> newHttpClient() has side effects, see your error message |
19:23:13 | FromDiscord | <Rika> ~~rather technically echoing is mutating a global~~ |
19:23:30 | FromDiscord | <huantian> sent a code paste, see https://paste.rs/u7x |
19:24:09 | FromDiscord | <TennisBowling> oh I see |
19:24:28 | FromDiscord | <TennisBowling> this doesn't really matter so I'll just make it a proc? |
19:24:34 | FromDiscord | <Rika> sure |
19:24:38 | FromDiscord | <Rika> thats fine |
19:24:55 | FromDiscord | <TennisBowling> cool thank you! |
19:24:57 | FromDiscord | <huantian> oh yeah I forgot FutureVar exists, isn't that supposed to be used for var params in {.async.} |
19:25:27 | FromDiscord | <Rika> really |
19:25:42 | arkanoid | nimscript + async is a thing? |
19:25:56 | FromDiscord | <Rika> future var is a return type tho isnt it |
19:26:04 | FromDiscord | <huantian> yeah uh hm |
19:26:24 | FromDiscord | <Rika> its an async equivalent for returning a var T |
19:26:42 | FromDiscord | <Daan> What is recommended for a Type, tuple or object |
19:26:59 | FromDiscord | <huantian> In reply to @Rika "its an async equivalent": yeah I can't remember what I was thinking of |
19:27:47 | FromDiscord | <huantian> I guess either use ref, or just return a copy of your object when you can |
19:28:13 | FromDiscord | <huantian> In reply to @Daan "What is recommended for": somewhat depends but you probably want object |
19:29:15 | FromDiscord | <Daan> It is for Thread data↵(@huantian) |
19:31:18 | FromDiscord | <Rika> object |
19:32:30 | FromDiscord | <Daan B> @Rika\: Thanks |
19:34:35 | FromDiscord | <Daan B> sent a code paste, see https://play.nim-lang.org/#ix=3SGZ |
19:34:50 | FromDiscord | <Daan B> sent a code paste, see https://play.nim-lang.org/#ix=3SH0 |
19:34:51 | FromDiscord | <Rika> exported |
19:35:51 | FromDiscord | <Daan B> So if you make the `Type` in a separate file you use an asterisks else you don't |
19:38:25 | FromDiscord | <Daan B> Or am I completely wrong? |
19:38:26 | FromDiscord | <Daan B> So if you make the `Type` in a separate file you use an asterisks else you don't |
19:41:06 | arkanoid | how to use multiple cores in nimscript? Do I have to rely on threads? |
19:41:35 | Amun-Ra | hmm, fork? |
19:42:20 | arkanoid | I just have a long list of "exec" commands that I can run in parallel. They are cpu bound so yeah I need thread or multiprocessing, but unsure which is easier/suggested in nimscript |
19:51:57 | FromDiscord | <exelotl> In reply to @Daan B "So if you make": Yes, if you make `Type` in some module and want it to be usable in other modules that import it, you need the asterisks (on the type itself and on all the fields that you want to be accessible) |
19:53:19 | FromDiscord | <Daan B> Thanks. |
19:57:47 | FromDiscord | <Elegantbeef> arkanoid you're going to have to use the shells forking capabilities, nimscript doesnt know what a thread is |
19:58:31 | arkanoid | Elegantbeef, mmm ok. I guess exec is sent straight to the shell |
19:58:45 | arkanoid | so backgrounding with "&" would work |
19:58:48 | FromDiscord | <Elegantbeef> Unless you're calling compiled Nim 'nimscript' 😀 |
20:05:13 | arkanoid | nope, I'm running "nim myscript.nims" |
20:05:32 | arkanoid | I'm trying to start replacing my daily bash and python script with nim |
20:06:04 | arkanoid | you know, simple utils you drop in working directory to replace boring daily tasks |
20:06:22 | FromDiscord | <Elegantbeef> So are you using Nim then? |
20:07:13 | FromDiscord | <Daan B> Arkanoid, what do you mean? |
20:07:16 | FromDiscord | <Elegantbeef> If so you can use https://nim-lang.org/docs/osproc.html#execProcesses%2CopenArray%5Bstring%5D%2Cproc%28int%29%2Cproc%28int%2CProcess%29 or similar |
20:08:09 | FromDiscord | <TennisBowling> sent a code paste, see https://play.nim-lang.org/#ix=3SHd |
20:10:05 | FromDiscord | <Elegantbeef> Which line is the source of that error? |
20:10:57 | arkanoid | Elegantbeef, why you call running "nim myscript.nims" compiled nim? Is't code like this executed in nim vm? |
20:11:19 | FromDiscord | <Elegantbeef> I mean i dont get why you're using nimscript |
20:11:47 | FromDiscord | <Elegantbeef> https://github.com/PMunch/nimcr and carry on |
20:13:53 | FromDiscord | <Elegantbeef> Nimscript running in the normal compiler lacks many things that makes it as capable as other scripting languages, so you're just setting yourself up for tedium using it for automating tasks imo |
20:18:30 | FromDiscord | <Mysterysib> What compiler does nim use? |
20:18:46 | FromDiscord | <Elegantbeef> 'any' C compiler |
20:18:49 | FromDiscord | <Mysterysib> does it compile to C and then ASM, or straight to ASM? |
20:19:07 | FromDiscord | <Elegantbeef> On linux it defaults to gcc, on windows it defaults to mingw, on mac defaults to clang |
20:19:09 | FromDiscord | <Mysterysib> Ahh, so you could use LLVM |
20:19:34 | FromDiscord | <Elegantbeef> https://github.com/arnetheduck/nlvm does exist |
20:19:40 | FromDiscord | <Elegantbeef> There isnt much benefit to using llvm but yes you can |
20:20:07 | FromDiscord | <Mysterysib> Mhmm cool |
20:20:41 | FromDiscord | <Mysterysib> You know that site where you could see the ASM various compilers produce? Would be interesting to compare to what's produced from Nim! |
20:20:54 | FromDiscord | <Elegantbeef> Godbolt supports nim |
20:20:56 | FromDiscord | <Rika> Godbolt |
20:21:46 | reversem3[m] | I have tried 4 different versions of nim to run this nico example and all of tell me "illegal storage" |
20:21:51 | FromDiscord | <Mysterysib> Woah proc square is a lot longer than C++ |
20:21:52 | Amun-Ra | I often type goldbot instead |
20:24:09 | reversem3[m] | I tried to get advice in the nim-gamedev but seems pretty empty , https://play.nim-lang.org/#ix=3SGO |
20:25:05 | reversem3[m] | It's probably an osx issue. Later I'll try a new nico template and see if that runs by itself. |
20:31:57 | FromDiscord | <TennisBowling> In reply to @Elegantbeef "Which line is the": not sure |
21:01:02 | * | krux02 quit (Ping timeout: 240 seconds) |
21:09:06 | FromDiscord | <mattrb> sent a code paste, see https://play.nim-lang.org/#ix=3SHm |
21:13:16 | FromDiscord | <Generic> well you could have something exactly like this in C++ |
21:13:49 | FromDiscord | <Generic> sent a code paste, see https://play.nim-lang.org/#ix=3SHo |
21:13:56 | FromDiscord | <Generic> but there's no function like this in the standard library |
21:15:24 | FromDiscord | <Generic> more importantly being eable to just implicitly pass variables as mutable is the groundwork for lots very common things in Nim |
21:15:40 | FromDiscord | <Generic> like all seq or Table operations |
21:16:01 | FromDiscord | <Generic> because they are value objects, they're passed in as the first parameter as a var parameter |
21:16:51 | FromDiscord | <demotomohiro> Nim add runtime error checks (overflow, out of bound etc) and stack trace. When you wanto to compare assembly output of Nim and C/C++ add -d:danger option to optimize code and remove runtime checks. |
21:17:36 | FromDiscord | <mattrb> In reply to @Generic "well you could have": Are there other languages in which an array access on a value type isn't a copy? |
21:18:13 | FromDiscord | <Generic> like I demonstrated, in C++, the same thing can be done |
21:18:31 | FromDiscord | <Recruit_main707> other than c++ i guess |
21:19:28 | FromDiscord | <Generic> none I can think of atm, though there aren't really that many languages with non primitive value types |
21:22:47 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=3SHt |
21:24:32 | FromDiscord | <mattrb> sent a code paste, see https://play.nim-lang.org/#ix=3SHu |
21:24:42 | FromDiscord | <mattrb> It does inc the second array value like nim, though |
21:25:01 | FromDiscord | <Generic> C++ doesn't initialise values by default |
21:25:05 | FromDiscord | <mattrb> Ah |
21:25:14 | FromDiscord | <Generic> so you get what was already there before |
21:25:21 | FromDiscord | <mattrb> Makes sense then, so it behaves just like nim aside from zeroing the array |
21:25:26 | FromDiscord | <Generic> also int a = arr[0]; |
21:25:31 | FromDiscord | <Generic> copies |
21:25:59 | FromDiscord | <Generic> it's the int& (C++) or var int (Nim) in the function signature which says that no copy should be done |
21:26:05 | FromDiscord | <mattrb> Right, the part that's unintuitive to me for both nim anc c++ is that `inc(arr[1])` _doesn't_ copy |
21:26:07 | FromDiscord | <Generic> but instead the value passed should be modified |
21:26:32 | FromDiscord | <mattrb> It's useful, but coming from other languages it just wasn't intuitive to me that that wouldn't copy the value on access |
21:27:30 | FromDiscord | <mattrb> It's useful, don't get me wrong. I just only caught it in my unit tests and was confused at first |
21:27:42 | FromDiscord | <demotomohiro> Incrementing with `arr[1] += 1` is also unintuitive for you? |
21:28:27 | FromDiscord | <mattrb> Hmm |
21:28:48 | FromDiscord | <mattrb> That makes sense, which I guess means my intuition wasn't very solid 🤔 |
21:30:12 | FromDiscord | <mattrb> Is there a way in nim or in another language to make a variable assignment like `var a = arr[0]; inc(a)` behave more like `inc(arr[0])` and _not_ copy? |
21:30:48 | FromDiscord | <mattrb> My usecase being that I want to pull out a mutable reference to a value in the array, mess with it, and not have to stick it back in the array (or have to index off of the array for every operation) |
21:31:17 | FromDiscord | <Generic> https://nim-lang.org/docs/sugar.html#dup.m%2CT%2Cvarargs%5Buntyped%5D |
21:33:47 | FromDiscord | <demotomohiro> https://demotomohiro.github.io/littlesugar/withAliases.html↵https://github.com/demotomohiro/littlesugar |
21:36:18 | FromDiscord | <Elegantbeef> In the world of macros anything is possible 😛↵(@mattrb) |
21:38:49 | FromDiscord | <mattrb> In reply to @demotomohiro "Incrementing with `arr[1] +=": Actually, my intuition would be that `arr[0] += 1` is actually just sugar for `arr[0] = arr[0] + 1`, which wouldn't break my intuition since it's a set rather than a get operation on the array, which I _would_ assume behaves that way |
21:39:22 | FromDiscord | <Elegantbeef> I mean it is |
21:39:44 | FromDiscord | <Elegantbeef> and `inc(arr[0])` is sugar for `arr[0] = arr[0] + 1` 😛 |
21:40:56 | FromDiscord | <mattrb> Isn't `inc` a proc though? |
21:41:03 | FromDiscord | <Elegantbeef> so is `+=` |
21:41:39 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3SHz |
21:41:49 | FromDiscord | <demotomohiro> @Elegantbeef, Why view type is not implemented as library when anything is possible in the world of macros?↵https://nim-lang.org/docs/manual_experimental.html#view-types |
21:41:49 | FromDiscord | <Elegantbeef> Which means "successive value" or in the case of integers `val + 1` |
21:42:09 | FromDiscord | <mattrb> Which is still unintuitive to me then, since it's accessing a value from an array then passing it to a proc. I would have assumed the array access would always copy |
21:42:14 | FromDiscord | <Elegantbeef> Cause it's easier and more intuitive to implement in compiler |
21:42:15 | * | wyrd quit (Ping timeout: 240 seconds) |
21:42:33 | FromDiscord | <Elegantbeef> Well it only copies on assignment for optimizations and feature reasons↵(@mattrb) |
21:42:57 | FromDiscord | <Mysterysib> Is there an auto null I can define globally? |
21:43:14 | FromDiscord | <mattrb> It's unintuitive to me that array access copies on assignment (even to a `var` variable), but not on calling a proc with a `var` parameter |
21:43:32 | FromDiscord | <mattrb> I think the fact that those behave differently is the root of my confusion |
21:43:36 | FromDiscord | <demotomohiro> C++ has container types that a[x] returns reference not copy. |
21:47:49 | FromDiscord | <mattrb> In reply to @Elegantbeef "In the world of": How would you address this with a macro? |
21:49:24 | * | wyrd joined #nim |
21:50:53 | FromDiscord | <demotomohiro> `var x: int` and arr[1] are both locations somewhere in the memory. So they can work same way. |
21:54:06 | FromDiscord | <mattrb> But `var x = arr[1]` is a copy of `arr[1]`, so if I want to the mutate x, I'll need to stick it back in the array when I'm done |
21:54:26 | FromDiscord | <Elegantbeef> Well except when view types exist |
21:57:20 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3SHG |
21:57:54 | FromDiscord | <Elegantbeef> Nim has declarative mutability which informs dispatch on what procedure to call to give us reference properties, it's hard to do it any other way |
21:59:13 | FromDiscord | <demotomohiro> Maybe `with` module can help you.↵https://nim-lang.org/docs/with.html |
22:00:03 | FromDiscord | <Elegantbeef> Well it's quite simple anything that takes a `var T` either mutates that or returns from it |
22:00:29 | FromDiscord | <Elegantbeef> I dont see how `with` helps |
22:00:51 | FromDiscord | <mattrb> sent a code paste, see https://play.nim-lang.org/#ix=3SHI |
22:01:11 | FromDiscord | <demotomohiro> `byAddr` can be dangrous whe you use it to a element of seq or string. |
22:01:28 | FromDiscord | <mattrb> I'm currently building a lox interpreter in nim. I'd be curious to have some input when I'm done on how I could make it more idiomatic |
22:01:29 | FromDiscord | <Elegantbeef> Well yea it's an unsafe version of `views` |
22:01:52 | FromDiscord | <mattrb> But it's in the stdlib, which makes it a better version of views 👀 |
22:02:16 | FromDiscord | <Elegantbeef> Views is in the compiler? |
22:02:17 | FromDiscord | <Elegantbeef> It's an experimental flag to get a borrow checker |
22:02:39 | FromDiscord | <mattrb> Ah, just behind a flag. Got it |
22:02:53 | FromDiscord | <demotomohiro> View types is much safer than `byAddr` but experimal. |
22:03:31 | FromDiscord | <Elegantbeef> Yea views is like Rust's borrow checker, allowing some nicer APIs |
22:03:58 | FromDiscord | <Elegantbeef> Dont need things like `byaddr` when you have a view |
22:06:13 | FromDiscord | <mattrb> Using byAddr allowed for this at least, which is nice. Haven't looked at the output, but I'd imagine it's better optimized too since it doesn't have to index off of the array constantly https://gist.github.com/mattrberry/040dd950e9e9caffbc3103ef327a9578 |
22:07:38 | FromDiscord | <Elegantbeef> is frame supposed to be static? |
22:08:34 | FromDiscord | <mattrb> At the moment, since I haven't implemented function calls :p |
22:09:40 | FromDiscord | <Elegantbeef> Is that supposed to run until no more frames? |
22:12:13 | FromDiscord | <mattrb> It will run until returning from the top-level function, defined by the first CallFrame in vm.frames |
22:12:32 | FromDiscord | <Elegantbeef> ah was wondering if we could just use a iterator |
22:13:21 | FromDiscord | <mattrb> The callframes are a stack that the vm will push and pop to. Would probably be weird to lay an iterator over that |
22:13:25 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3SHP |
22:15:10 | FromDiscord | <Elegantbeef> It's the same as the byaddr i guess just without using byaddr/decls 😛 |
22:16:57 | FromDiscord | <demotomohiro> Using iterator without loop looks strange but looks good. |
22:17:24 | FromDiscord | <Elegantbeef> Yea it's kinda a hack of course |
22:21:54 | FromDiscord | <mattrb> Thanks for the help today, as usual :) |
22:33:52 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3SHT there we go a less hacky version \:PO |
22:48:17 | * | kayabaNerve quit (Ping timeout: 240 seconds) |
22:58:26 | * | arkurious quit (Quit: Leaving) |
23:16:38 | FromDiscord | <Girvo> Morning all |
23:16:57 | FromDiscord | <Elegantbeef> Afternoon |
23:17:43 | FromDiscord | <Girvo> I'm likely ahead of you time-wise, so my time is more correct than yours 😉 |
23:18:05 | FromDiscord | <Elegantbeef> Time is a construct of man only the sun knows which is more accurate |
23:18:42 | FromDiscord | <Girvo> Haha not wrong |
23:18:47 | FromDiscord | <abdu> How do we do inserted body block of argument in macro ?↵just like inserted body block of template on: `template foo( i:int, codes:untyped) =`↵Please help! |
23:21:07 | FromDiscord | <Elegantbeef> `template foo( i:int, codes:untyped) = codes` |
23:38:46 | NimEventer | New question by itil memek cantik: Do some insertion of body block of argument in macro, see https://stackoverflow.com/questions/71520262/do-some-insertion-of-body-block-of-argument-in-macro |
23:39:38 | FromDiscord | <Girvo> Does anyone know what the performance implications of `pegs` are? I wonder if it's suitable for my embedded use-case for parsing some AT command responses. Might not even need it really, it's mostly `CRLF` line separated data |
23:40:58 | FromDiscord | <mattrb> In reply to @Elegantbeef "https://play.nim-lang.org/#ix=3SHT there we go": Seems like play.nim-lang.org is down :/ |
23:46:49 | FromDiscord | <Elegantbeef> I think it's' generally efficent, best thing would to be to benchmark it↵(@Girvo) |
23:47:06 | FromDiscord | <Elegantbeef> Yea @mattrb https://wandbox.org use this for now |