00:03:56 | * | argonica joined #nim |
00:10:38 | FromDiscord | <Nilts> In reply to @not logged in "and just to get": Is this a "calling convention"? |
00:11:08 | FromDiscord | <Elegantbeef> it practically is |
00:11:33 | FromDiscord | <Elegantbeef> How you send variables to a function is what a calling convention is |
00:12:03 | FromDiscord | <demotomohiro> https://en.wikipedia.org/wiki/X86_calling_conventions |
00:14:28 | FromDiscord | <Nilts> How do i make sure the SET stuff in the def is not ran until it is called? |
00:17:24 | FromDiscord | <Elegantbeef> it shouldnt do anything untill called |
00:18:29 | FromDiscord | <pyolyokh> In reply to @not logged in "well, you don't run": ^^ |
00:18:58 | FromDiscord | <Nilts> In reply to @Elegantbeef "it shouldnt do anything": Well the SET in the body would still run |
00:19:02 | FromDiscord | <pyolyokh> this person is extremely confused. |
00:19:09 | FromDiscord | <Nilts> In reply to @pyolyokh "this person is extremely": thanks |
00:19:46 | FromDiscord | <pyolyokh> if neither you nor the people talking to you realize that, it's never going to be cleared up. |
00:20:24 | FromDiscord | <pyolyokh> what is the 'first time around' where you think a function doesn't get run? |
00:22:11 | FromDiscord | <Nilts> sent a code paste, see https://play.nim-lang.org/#ix=4mcO |
00:23:50 | FromDiscord | <Nilts> Also, do i need a Scope enter and scope exit command? |
00:24:33 | FromDiscord | <Elegantbeef> your arg1 would be a reference and as such just works |
00:25:13 | FromDiscord | <Elegantbeef> arg2 is just "pop first value off stack" |
00:25:18 | FromDiscord | <Elegantbeef> i mean arg1 |
00:27:52 | FromDiscord | <Nilts> In reply to @Elegantbeef "arg2 is just "pop": then it would pop the func obj off the stack and set it to arg1 and still run |
00:29:32 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mcQ |
00:30:14 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mcR |
00:30:57 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mcT |
00:32:06 | FromDiscord | <Elegantbeef> https://en.wikipedia.org/wiki/X86_calling_conventions#Caller_clean-up and https://en.wikipedia.org/wiki/X86_calling_conventions#Callee_clean-up |
00:32:08 | FromDiscord | <Elegantbeef> Might help atleast |
00:33:38 | FromDiscord | <Nilts> sent a code paste, see https://play.nim-lang.org/#ix=4mcU |
00:37:46 | FromDiscord | <Nilts> In reply to @Elegantbeef "https://en.wikipedia.org/wiki/X86_calling_conventio": Where is the function declared in the assembly? |
00:40:00 | FromDiscord | <Nilts> i think im a little confused |
00:42:24 | FromDiscord | <pyolyokh> functions aren't declared in assembly. There are just addresses with code at them. |
00:43:09 | FromDiscord | <pyolyokh> the literal ` call callee ; call subroutine 'callee'` at that link still assumes that the assembler has some `callee:` label elsewhere |
00:43:57 | FromDiscord | <Nilts> In reply to @pyolyokh "the literal ` ": see, i need like a label system somewhere. But then there could only be global func |
00:43:59 | FromDiscord | <Nilts> (edit) "func" => "funcs" |
00:44:41 | FromDiscord | <Elegantbeef> Anonymous procedures and pointer procedures are the same |
00:45:00 | FromDiscord | <Elegantbeef> They just store an address to that procedure instead of directly using the label |
00:45:34 | FromDiscord | <Elegantbeef> So when you call one it implicitly dereferences a pointer |
00:46:16 | FromDiscord | <jtv> @Nilts Can take it to #offtopic but in general, function calls in byte code languages are done by SAVING the state of the caller, often on a stack, and pushing on the state of the function you're calling to, and transferring control to that address. You also save the address to return to, and the info you need to apply the right state. |
00:47:27 | FromDiscord | <jtv> Typically there's the "instruction pointer", the pointer to the instruction you're executing right now, and some pointer into a stack that contains info about local variables, etc. that allows you to distinguish between calling contexts |
00:51:45 | FromDiscord | <jtv> You will generally want symbol tables and to manage information about scopes in doing all that. Most intro to compilers books cover all of this reasonably well actually. Some of the more modern ones are really friendly |
00:51:57 | FromDiscord | <jtv> Someone posted one for you the other day that I skimmed and it looked good |
00:52:28 | FromDiscord | <Elegantbeef> Was it me with "crafting interpreters" |
00:52:31 | FromDiscord | <Elegantbeef> Or is there another one |
00:54:08 | FromDiscord | <Nilts> In reply to @jtv "<@910899642236043294> Can take it": what about #la` |
00:54:14 | FromDiscord | <Nilts> (edit) "#la`" => "#langdev" |
00:56:15 | FromDiscord | <Nilts> nvm |
00:56:40 | FromDiscord | <Elegantbeef> I mean given there isnt anything going on, here is likely fine |
00:56:48 | FromDiscord | <Elegantbeef> Not like Nim is the most active community |
00:57:28 | FromDiscord | <Nilts> ok, so is the semantic checker that makes the symbols supposed to connect to the bytecode? |
00:58:56 | FromDiscord | <Elegantbeef> You may want to `parse -> semantic check -> an intermediate representation -> codegen` |
00:59:12 | FromDiscord | <Elegantbeef> AST can be used for codegen, but it's not the most fun usage |
00:59:46 | * | argonica quit (Quit: Leaving) |
00:59:50 | FromDiscord | <Elegantbeef> But yes you should use the symbols generated from the AST to help with the bytecode |
00:59:58 | FromDiscord | <Elegantbeef> If your symbols are like Nim's that's sorta the point of them anyway |
01:01:23 | FromDiscord | <Nilts> hmmm, but i pop them |
01:01:49 | FromDiscord | <Elegantbeef> codegen should be a step before bytecode so popping them shouldnt do anything |
01:01:56 | FromDiscord | <Nilts> (edit) "them" => "them, and the symbol table gets destroyed." |
01:02:00 | FromDiscord | <Elegantbeef> well should be a step before interpretting |
01:02:21 | FromDiscord | <Elegantbeef> The symbol table should disappear after bytecode is generated |
01:02:32 | FromDiscord | <Elegantbeef> Though given JTV was helping you i probably should shush, might be competing designs |
01:03:17 | FromDiscord | <Nilts> In reply to @Elegantbeef "The symbol table *should*": no, im talking about during the semantic check. Here is the code if it helps: https://github.com/thatrandomperson5/JumpLang/blob/main/libjumplang/syms.nim |
01:06:14 | FromDiscord | <Nilts> In the file you can see that i have no good way of retrieving the sym tables. |
01:40:21 | FromDiscord | <voidwalker> What is your favourite library to work with sqlite ? |
01:40:37 | FromDiscord | <voidwalker> (edit) "What is your favourite library to work with sqlite ? ... " added "(except the stdlib one of course)" |
01:40:38 | FromDiscord | <Elegantbeef> The one that means i dont need a DB đ |
01:44:09 | FromDiscord | <pyolyokh> the stdlib one is losing the -d:staticSqlite flag so my favorite will be the non-std replacement for that |
01:45:05 | FromDiscord | <pyolyokh> when backwards compatibility isn't necessary, using a much more modern sqlite than the system one can yield a pretty good speed increase in itself |
01:53:26 | FromDiscord | <voidwalker> I like the syntax in this one: https://github.com/ire4ever1190/ponairi |
02:01:27 | FromDiscord | <voidwalker> while this is the most starred: https://github.com/juancarlospaco/nim-gatabase |
02:49:53 | * | ltriant quit (Ping timeout: 252 seconds) |
03:04:26 | * | argonica joined #nim |
03:08:58 | FromDiscord | <amadan> Used to use https://github.com/itsumura-h/nim-allographer and found that quite nice |
03:13:15 | * | jmdaemon joined #nim |
03:50:53 | * | argonica quit (Remote host closed the connection) |
03:53:27 | * | ltriant joined #nim |
03:58:27 | * | ltriant quit (Ping timeout: 256 seconds) |
04:02:13 | FromDiscord | <jtv> Sorry @Nilts I was at a dinner now I'm headed to bed, but I'll be around more tomorrow |
04:08:23 | FromDiscord | <jtv> Generally scopes are hierarchical though, where if I can't find a variable on a use in the local scope I go searching parent scopes. Pushing and popping may or may not make sense depending on how you're dealing w/ your tree, but you can always stash a reference to the scope in the tree. |
04:10:24 | FromDiscord | <jtv> But yeah, the symbol table generally just helps you check and produce code, it doesn't live while you're running. Tho, for some kinds of interpreters, it might make more practical sense if you're going to do a lot of runtime type lookup stuff. There are cases where it can work |
04:26:44 | * | xet7 quit (Remote host closed the connection) |
04:52:34 | * | ltriant joined #nim |
04:57:36 | * | ltriant quit (Ping timeout: 248 seconds) |
05:10:16 | * | arkurious quit (Quit: Leaving) |
05:57:17 | FromDiscord | <sOkam!> How do you get the bit representation of a number?â”I feel like this should be an easy one, but I can't seem to find it no matter where i look đ€ |
05:57:30 | FromDiscord | <sOkam!> (edit) "number?â”I" => "number in nim?â”I" |
05:58:48 | FromDiscord | <sOkam!> (edit) "How" => "~~How" | "nim?â”I" => "nim?~~â”~~I" | "đ€" => "đ€~~â”nvm, found it by searching for tohex. it was right next to it" |
06:27:11 | FromDiscord | <Rika> Because you were using the wrong term yeah, itâs not bit representation itâs binary representation |
06:31:36 | * | argonica joined #nim |
07:21:58 | * | ltriant joined #nim |
07:50:23 | FromDiscord | <xoich (xoich)> hello, how do I create a ref seq[int]? |
07:52:12 | FromDiscord | <Elegantbeef> `var a = new seq[int]` |
07:52:17 | FromDiscord | <Elegantbeef> `a[] = @[10, 20, 30]` |
07:55:22 | FromDiscord | <Arathanis> !eval |
07:55:28 | FromDiscord | <Arathanis> !eval |
07:55:31 | FromDiscord | <Arathanis> (edit) "!eval" => "=" |
07:56:07 | FromDiscord | <xoich (xoich)> thanks @elegantbeef\:matrix.org |
07:56:35 | FromDiscord | <Arathanis> sent a long message, see http://ix.io/4mdO |
07:57:00 | FromDiscord | <Arathanis> clearly i dont know how eval works |
07:58:26 | FromDiscord | <Elegantbeef> It only does single line since it's on irce |
07:58:36 | FromDiscord | <Arathanis> ohhh got it |
07:59:28 | FromDiscord | <Arathanis> !eval var mySeq = @[1, 2, 3]; echo mySeq; echo refMySeq[]; refMySeq[] = @[4, 5, 6, 7]; echo mySeq |
07:59:31 | NimBot | Compile failed: /usercode/in.nim(1, 42) Error: undeclared identifier: 'refMySeq' |
07:59:53 | FromDiscord | <Arathanis> !eval var mySeq = @[1, 2, 3]; var refMySeq = mySeq.addr; echo mySeq; echo refMySeq[]; refMySeq[] = @[4, 5, 6, 7]; echo mySeq |
07:59:56 | NimBot | @[1, 2, 3]â”@[1, 2, 3]â”@[4, 5, 6, 7] |
08:00:13 | FromDiscord | <Elegantbeef> That's also not a `ref seq` but a `ptr seq` |
08:00:39 | FromDiscord | <Arathanis> that makes sense |
08:01:19 | FromDiscord | <Arathanis> cause its unsafe and ptr is designed to be "unsafe" |
08:01:26 | FromDiscord | <Arathanis> whereas ref is not |
08:01:36 | FromDiscord | <Arathanis> so if you could just `.addr` any old thing to get a ref it would be |
08:01:39 | FromDiscord | <Arathanis> not great |
08:01:51 | FromDiscord | <Arathanis> but a ptr makes more sense |
08:02:03 | FromDiscord | <Elegantbeef> Not really |
08:02:07 | FromDiscord | <Elegantbeef> Since that's not what they asked |
08:02:39 | FromDiscord | <Arathanis> yes you are right, i was more messing around than anything else but in a mistaken way |
08:02:42 | FromDiscord | <Arathanis> i appreciate you correcting it |
08:02:55 | FromDiscord | <Arathanis> should have been ~~refMySeq~~ ptrMySeq |
08:25:33 | * | argonica quit (Quit: Leaving) |
09:02:17 | * | azimut quit (Ping timeout: 255 seconds) |
09:19:51 | * | PMunch joined #nim |
09:20:14 | FromDiscord | <System64 ~ Flandre Scarlet> can NimScript create a folder? |
09:20:33 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/nimscript.html#mkDir%2Cstring |
09:21:37 | FromDiscord | <System64 ~ Flandre Scarlet> perfect, thanks! |
09:47:42 | FromDiscord | <System64 ~ Flandre Scarlet> ``-O3 -I"./tilengine/includes" -L"tilengine/lib/wasm" -lz -lpng -lSDL2 -lTilengine``â”How can I pass it to the compiler please? |
09:48:11 | FromDiscord | <Elegantbeef> `--passL` or `--passC` |
09:48:28 | FromDiscord | <System64 ~ Flandre Scarlet> I need multiple passL / passC? |
09:49:03 | FromDiscord | <Elegantbeef> You can do it all in one |
09:49:30 | FromDiscord | <System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4mei |
09:49:47 | FromDiscord | <Elegantbeef> `switch("passL", "...")` |
09:50:12 | FromDiscord | <System64 ~ Flandre Scarlet> Something is incorrect? |
09:50:22 | FromDiscord | <Elegantbeef> Yes |
09:50:32 | FromDiscord | <Elegantbeef> `switch("leftHandHere", "rightHandHere")` |
09:56:16 | * | jmdaemon quit (Ping timeout: 248 seconds) |
10:00:04 | FromDiscord | <System64 ~ Flandre Scarlet> Let's gooo! https://media.discordapp.net/attachments/371759389889003532/1068108047450378250/image.png |
10:08:56 | PMunch | Nice! |
10:09:32 | Amun-Ra | sonic vibes |
10:09:42 | PMunch | @System64_~_Flandre_Scarlet, are you using the nim-tilengine wrapper? |
10:20:40 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @PMunch "@System64_~_Flandre_Scarlet, are you using": The one I did with Futhark |
10:38:11 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mex |
10:38:16 | FromDiscord | <4zv4l> like keeping it anonymous |
10:41:17 | FromDiscord | <Rika> no |
10:41:36 | FromDiscord | <Rika> you have to make either an enum type for famille, demoiselle, etc |
10:41:52 | FromDiscord | <Rika> actually ig you can just use a massive if statement or whatever |
10:41:59 | FromDiscord | <Rika> ofc i assume you dont want that so |
11:01:32 | PMunch | @System64_~_Flandre_Scarlet, oh right, that's really cool! |
11:01:53 | PMunch | I don't remember, was there a particular reason why you don't use the existing bindings? |
11:03:34 | PMunch | @4zv4l, not entirely sure what you want to achieve here |
11:18:04 | FromDiscord | <4zv4l> well I saw a Python script doing something similar and I wanted to try doing it in Nim |
11:18:12 | FromDiscord | <4zv4l> precising as less the type as possible |
11:23:14 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4meH |
11:23:47 | FromDiscord | <4zv4l> oooh because it's a string and not the field ? |
11:26:44 | FromDiscord | <Rika> Yes |
11:27:55 | FromDiscord | <4zv4l> anything I can do about that ? |
11:35:36 | FromDiscord | <sOkam!> Is there something similar to `runnableExamples:` that can be used for tests, instead of for examples? |
11:35:51 | FromDiscord | <sOkam!> (edit) "for" => "doc" |
11:36:27 | FromDiscord | <sOkam!> (edit) "tests, instead of doc examples?" => "tests?" |
11:38:23 | FromDiscord | <Phil> Not that I'm aware of |
11:38:32 | FromDiscord | <Phil> runnableExamples are kind of mini-tests |
11:54:16 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4meN |
11:54:59 | FromDiscord | <sOkam!> (edit) "https://play.nim-lang.org/#ix=4meN" => "https://play.nim-lang.org/#ix=4meO" |
11:55:18 | FromDiscord | <sOkam!> (edit) "https://play.nim-lang.org/#ix=4meO" => "https://play.nim-lang.org/#ix=4meP" |
11:55:22 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4meQ |
11:56:52 | FromDiscord | <sOkam!> In reply to @Isofruit "You're looking for the": lifesaver, thenks! |
12:22:21 | PMunch | sOkam, as @Phil pointed out runnableExamlpes can be used as a sort of mini-test. Basically they are compiled and run during documentation generation, and if an example fails to compile or run then it throws an error. So if you instead of doing `echo someProc() # This prints 5` does `assert someProc() == "5"` then you will get an error if `someProc` no longer returns 5. |
12:23:09 | FromDiscord | <Phil> As a sidenote, that is oen of the reasons I adopted the habit of add a documentation-compilation pipeline to any new package I make |
12:23:21 | FromDiscord | <Phil> (edit) "oen" => "one" |
12:26:55 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @PMunch "I don't remember, was": I created thoses bindings before the new ones exist |
12:27:10 | FromDiscord | <System64 ~ Flandre Scarlet> Btw is there a way to do compile-time conditionnal imports? |
12:27:30 | FromDiscord | <System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4meV |
12:39:52 | * | xet7 joined #nim |
12:43:19 | PMunch | @System64_~_Flandre_Scarlet, `when not defined(emscripten)` |
12:51:14 | FromDiscord | <System64 ~ Flandre Scarlet> Oh alright, thanks! |
12:52:21 | FromDiscord | <Phil> I do not comprehend, why can't I compile the nimforum on 1.6.10?â”I just get completely random EOF Errors while compiling the forum nim file which, lo and behold, disappear when I compile on my nim2 compatibility branch |
12:53:34 | FromDiscord | <Phil> Which is like, what do you even do with that if you don't even get a stacktrace |
13:02:22 | FromDiscord | <Phil> Oh flopping hell it was because of a bad nimcache and I don't know where it's stored by default |
13:09:02 | PMunch | ~/.cache/nim on Linux |
13:17:34 | FromDiscord | <Require Support> possible to write a kernel module in nim? đ€ |
13:19:08 | FromDiscord | <chmod222> Sure, why not |
13:32:48 | PMunch | @Require_Support, you could write your entire kernel in Nim if you wanted to |
13:49:49 | FromDiscord | <Require Support> https://tenor.com/view/possibilities-endless-possibilities-sponge-bob-rainbow-gif-12940820 |
14:17:04 | FromDiscord | <NtsĂ©kees> No matter which port of I try to open with `nimhttpd -p:ââââ`, it always yields âȘError: unhandled exception: Address already in use [OSError]â«.â”Yet, when I check the status of the ports, they are listed as âclosedâ. đ€š |
14:23:12 | FromDiscord | <NtsĂ©kees> Well, since the error comes from `oserr.nim(95)`, maybe this âaddressâ is not the port⊠|
14:24:07 | FromDiscord | <Ntsékees> (edit) "`oserr.nim(95)`," => "`asyncfutures.nim(437) > oserr.nim(95)`," |
14:24:17 | FromDiscord | <Ntsékees> (edit) "`asyncfutures.nim(437)" => "`asyncfutures.nim(437)`" | "oserr.nim(95)`," => "`oserr.nim(95)`," |
14:26:42 | FromDiscord | <0xÊ> when writing enums what is the standard of naming variants? do you prefix them, or no prefix? Also what casing is used? |
14:27:22 | FromDiscord | <0xÊ> for example for my tokens enum I have them prefixed right now with `tk`, and in camelCase |
14:27:46 | PMunch | @0xÊ, typically no prefix, and either camelCase or PascalCase |
14:28:01 | PMunch | The name of the enum kinda works like a prefix |
14:28:20 | PMunch | e.g. Token.Secure for example instead of tkSecure. |
14:28:46 | FromDiscord | <Ntsékees> In reply to @Ntsékees "No matter which port": I've used `python -m http.server` instead of `nimhttpd` and it works correctly. |
14:29:13 | PMunch | Of course in most cases you don't need the `Token.` part at all, and it will make sense from context and procedure signature what `Secure` would mean |
14:30:44 | PMunch | @Ntsékees, hmm that sounds strange |
14:31:39 | FromDiscord | <Ntsékees> anyway, issue closed of sorts, as I've found a working replacement |
14:31:48 | PMunch | Just tried it here with port 2000 and it worked just fine |
14:32:25 | PMunch | Could you run `nimhttpd --version`? |
14:32:31 | PMunch | And what OS are you on? |
14:32:56 | FromDiscord | <NtsĂ©kees> > â nimhttpd --versionâ”> 1.5.0 |
14:33:10 | PMunch | Hmm, that is the latest version |
14:33:11 | FromDiscord | <Ntsékees> Ubuntu Linux 22.10 |
14:33:29 | PMunch | And a Linux system as well, same as me |
14:36:53 | FromDiscord | <0xÊ> what can I do if the variants collide with keywords |
14:36:54 | FromDiscord | <0xÊ> :/ |
14:37:23 | FromDiscord | <0xÊ> I usually do `foo_` but it won't let me have the trailing underscore |
14:37:42 | FromDiscord | <Rika> Whatâs the whole context? |
14:38:00 | FromDiscord | <0xÊ> huh? |
14:38:16 | FromDiscord | <Rika> I donât understand what you mean by the variants colliding with keywords |
14:38:23 | FromDiscord | <0xÊ> oh I mean enum variants |
14:38:25 | FromDiscord | <Rika> What do you mean variants? Object variants? |
14:38:54 | FromDiscord | <Rika> Well you donât use the name, but I donât know of any keywords that are camel case? |
14:38:59 | FromDiscord | <Rika> I donât remember any at least |
14:39:02 | FromDiscord | <Rika> I mean Pascal case |
14:39:12 | FromDiscord | <0xÊ> I'm writing them using camelCase |
14:39:46 | FromDiscord | <0xÊ> is it more common to write them using PascalCase or camelCase |
14:40:06 | FromDiscord | <Rika> Usually itâs camel with the prefix or Pascal without, at least to me I would do such |
14:40:41 | FromDiscord | <Rika> Camel with has the keyword issue and sure thereâs a workaround (I think using ` around the identifier works but itâs ugly) |
14:41:05 | FromDiscord | <0xÊ> oh ok |
14:41:23 | FromDiscord | <0xÊ> I'll just go with pascal |
14:41:27 | FromDiscord | <Rika> If you think itâs acceptable to you, wrap the enum with ` |
14:44:14 | FromDiscord | <System64 ~ Flandre Scarlet> Is it normal it displays that when I try to load a JSON file? (I compiled to emscripten) https://media.discordapp.net/attachments/371759389889003532/1068179566016868402/image.png |
14:45:05 | FromDiscord | <System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4mfG |
14:45:55 | FromDiscord | <System64 ~ Flandre Scarlet> I also use std/json for json files |
14:57:06 | FromDiscord | <spooky> sent a code paste, see https://play.nim-lang.org/#ix=4mfK |
14:58:52 | FromDiscord | <spooky> (edit) "https://play.nim-lang.org/#ix=4mfK" => "https://play.nim-lang.org/#ix=4mfL" |
14:59:37 | * | azimut joined #nim |
15:04:49 | * | PMunch quit (Quit: Leaving) |
15:06:03 | * | azimut quit (Remote host closed the connection) |
15:07:17 | * | emery quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.) |
15:10:22 | * | azimut joined #nim |
15:22:42 | FromDiscord | <New> sent a code paste, see https://play.nim-lang.org/#ix=4mg0 |
15:23:37 | FromDiscord | <New> (edit) "https://play.nim-lang.org/#ix=4mg0" => "https://play.nim-lang.org/#ix=4mg1" |
15:23:52 | FromDiscord | <New> (edit) "https://play.nim-lang.org/#ix=4mg1" => "https://play.nim-lang.org/#ix=4mg2" |
15:26:09 | * | ehmry joined #nim |
15:27:30 | FromDiscord | <arkanoid> there so much information on the Nim chats that will be lost forever. if all the chat thing were forum posts, the community would feel much larger |
15:28:10 | FromDiscord | <Phil> On the one hand, yes, on the other: Often enough it's the 500th rendition on "How do I parse a string into an enum" ? |
15:28:26 | FromDiscord | <Phil> And the forum isn't really great for searchability either, SO imo is better there |
15:28:58 | FromDiscord | <Phil> Which is why I maintain my stance that for semi-complex questions that you couldn't find an answer to elsewhere, do a self answered SO question for the next person. |
15:31:38 | FromDiscord | <Phil> As for expect, I never used it, nor pexpect in python, so I'm not particularly familiar what ability is even looked for |
15:31:53 | FromDiscord | <New> In reply to @Isofruit "Which is why I": In fact, u right. Will go to SO then. Tnx. |
15:33:01 | FromDiscord | <Phil> In reply to @New "In fact, u right.": I mean, often times I find the answeres here, I just "document" them in SO questions đ |
15:37:08 | FromDiscord | <ringabout> Feeding them to GPT or similar might help đ |
15:38:09 | FromDiscord | <Phil> In reply to @New "In fact, u right.": https://github.com/Vindaar/shellâ”> Some terminal commands will require user input. Starting from version v0.5.0, basic support for a expect / send feature is available. It allows for functionality similar to the =expect(1)= program. |
15:39:59 | FromDiscord | <Phil> So you could figure out how to use expect with that, write up an example and post it on SO đ |
15:42:25 | FromDiscord | <New> In reply to @Isofruit "https://github.com/Vindaar/shell > Some terminal": i found that previously but not understand how to use <:PES2_Shrug:513352546341879808> â”And not understand is it necessary to have `expect` at end machine or not <:PES2_Shrug:513352546341879808> |
15:42:44 | FromDiscord | <Phil> In that case, Vindaar your type is requested |
15:43:06 | FromDiscord | <Phil> Because I don't have the 5 mins to invest to figure it out myself, about to head out |
15:45:28 | FromDiscord | <Vindaar> you don't need expect anymore. expect would be some string that appears in the output e.g. some yes/no query. I added the to option to just send though, because @ShalokShalom asked for it recently. anyway, what's not clear about the Readme explaining how it works? |
15:47:42 | FromDiscord | <New> sent a code paste, see https://paste.rs/1LP |
15:47:59 | FromDiscord | <New> (edit) "https://play.nim-lang.org/#ix=4mga" => "https://play.nim-lang.org/#ix=4mg9" |
15:48:35 | FromDiscord | <New> (edit) "https://play.nim-lang.org/#ix=4mg9" => "https://play.nim-lang.org/#ix=4mgc" |
15:49:38 | * | Phytolizer joined #nim |
15:51:33 | FromDiscord | <Vindaar> yes, in principle (single ticks are not valid though, have to use " for strings) . but in this particular case I consider that a very bad idea. you really don't want to hardcode your password into a code snippet like that. set up an ssh key for passwordless ssh login (if that's encrypted of course you'd need a password for that too). |
15:51:39 | * | arkurious joined #nim |
15:53:14 | FromDiscord | <New> In reply to @Vindaar "you don't need expect": > anyway, what's not clear about the areadme explaining how it worksâ”Im just not smart. Peobably. Idk. Father told me that. |
15:54:35 | FromDiscord | <Vindaar> wasn't meant as criticism, but just maybe something could be improved. anyway, no need to dunk on yourself |
15:56:06 | FromDiscord | <New> In reply to @Vindaar "yes, in principle (single": i know what hardcoding password is very bad idea, but this is my task, i just writing code đâ”We tryed ssh2.nim library, tryed empty build for this fucking machine. nothing working. i even dot speak about openssl compiling xDâ”_â”will try to use shell.nim then. something about 30 min and will try. big tnx |
15:57:44 | FromDiscord | <Phil> In reply to @New "i know what hardcoding": For a starting point it's not terrible, just don't check in that code đâ”You can always read the password in later from a json file |
15:57:51 | FromDiscord | <Phil> parsing in JSON isn't that hard |
15:57:57 | FromDiscord | <Phil> As in, takes like 3-4 lines of code |
16:00:35 | * | jkl quit (Quit: Gone.) |
16:00:45 | FromDiscord | <New> Btw never speaking before with person, who create library for my future or current code xD |
16:02:37 | FromDiscord | <Phil> Happens |
16:03:03 | * | jkl joined #nim |
16:15:46 | * | Phytolizer quit (Remote host closed the connection) |
16:21:44 | FromDiscord | <Require Support> what is a good to import objects and functions from a C header file in nim? |
16:21:59 | FromDiscord | <Require Support> (edit) "what is a good ... to" added "way" |
16:34:10 | FromDiscord | <New> In reply to @New "So, is it correct:": it asking password and waiting my input đŠ @Vindaar |
16:35:16 | FromDiscord | <New> sent a code paste, see https://play.nim-lang.org/#ix=4mgq |
16:35:29 | FromDiscord | <New> (edit) "https://play.nim-lang.org/#ix=4mgq" => "https://play.nim-lang.org/#ix=4mgr" |
16:39:54 | FromDiscord | <Require Support> sorry im clueless when it comes to C, `#define MODULE_LICENSE(_license) MODULE_INFO(license, _license)` how to import this into nim |
16:42:53 | FromDiscord | <New> sent a code paste, see https://play.nim-lang.org/#ix=4mgt |
16:43:13 | FromDiscord | <New> 1/2 :KEKWiggle: |
16:46:35 | FromDiscord | <Phil> In reply to @Require Support "sorry im clueless when": Best I can do you is link you to demo's article about that |
16:47:13 | FromDiscord | <Phil> https://internet-of-tomohiro.netlify.app/nim/clibrary.en.html#use-header-only-library-from-nim |
16:54:20 | FromDiscord | <Vindaar> In reply to @New "it asking password and": ah, I'm not sure, but it's possible that password input doesn't work via stdin, but a different FD. never thought about that, you'd need to read up on that |
16:54:31 | FromDiscord | <Vindaar> I'll be away for most of the evening now |
16:55:36 | FromDiscord | <New> In reply to @Vindaar "ah, I'm not sure,": :hello: https://media.discordapp.net/attachments/371759389889003532/1068212619200184370/image.png |
16:56:29 | FromDiscord | <System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4mgx |
16:56:56 | * | clemens3 joined #nim |
16:57:40 | FromDiscord | <New> https://media.discordapp.net/attachments/371759389889003532/1068213142812885054/image.png |
17:13:48 | FromDiscord | <enthus1ast> @System64 ~ Flandre Scarlet\: c2nim translates it like so\: |
17:14:01 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=4mgH |
17:14:42 | FromDiscord | <System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4mgI |
17:18:57 | * | Evolver joined #nim |
17:19:08 | Evolver | Do yall have a US registered charity? |
17:19:24 | Evolver | sorry, will ask in #nim-offtopic if that's better |
17:33:06 | * | nyeaa4928423 quit (Read error: Connection reset by peer) |
17:33:54 | * | nyeaa4928423 joined #nim |
17:37:32 | FromDiscord | <Leftbones> How do I deal with an ambiguous call when both `unicode` and `strutils` have an `align` proc? |
17:37:46 | FromDiscord | <Leftbones> doing `str.unicode.align(...)` was my first idea but that didn't work |
17:38:04 | FromDiscord | <enthus1ast> strutils.align() |
17:38:16 | FromDiscord | <Leftbones> Oh yeah I guess I can just call it that way huh |
17:38:37 | FromDiscord | <enthus1ast> so\: strutils.align(yourString, 3) |
17:39:02 | FromDiscord | <Leftbones> Yeah that did it lol, brain lapse. |
17:39:21 | FromDiscord | <Leftbones> Got so used to calling stuff the other way I forgot that was allowed |
17:40:04 | FromDiscord | <enthus1ast> yeah |
17:40:16 | FromDiscord | <Leftbones> Teaching myself Nim by remaking an old text editor of mine (which is how I like to learn new languages) and I'm working out how to offset the contents of the lines based on the buffer scrolling offsets |
17:40:23 | FromDiscord | <enthus1ast> another option is, if you do not use eg strutils.align |
17:40:28 | FromDiscord | <Leftbones> I got vertical offsets to work but horizontal offsets are giving me issues |
17:40:31 | FromDiscord | <enthus1ast> import strutils except align |
17:40:39 | FromDiscord | <Leftbones> In reply to @enthus1ast "import strutils except align": Didn't know this was an option, that's nice to know, thanks |
17:45:03 | FromDiscord | <Leftbones> Hm. Maybe typing this out will help me understand, or maybe someone else has an idea. I have a buffer that's a grid of cells (just characters for now) and a sequence of strings loaded from lines of a file. I'm scrolling the buffer vertically by writing the contents to the buffer cells offset by the vertical scroll amount. That works fine. But horizontal scrolling I can't offset the same way because I'm then working with a string, rather |
17:46:10 | FromDiscord | <Leftbones> https://media.discordapp.net/attachments/371759389889003532/1068225349525180497/Screen_Recording_2023-01-26_at_11.45.16_AM.mov |
17:47:08 | FromDiscord | <Leftbones> I'm figuring I need to just check if the x scroll offset is greater than the length of the string, then convert the string to a sequence and insert it into the buffer like that. Maybe that would work. |
17:48:17 | FromDiscord | <Leftbones> One problem is that converting the string line to a sequence removes all of the whitespace |
17:51:11 | FromDiscord | <Leftbones> Oh if I just skip converting the string to a sequence that works out fine. Empty discord debugging lol. |
17:52:24 | * | jmdaemon joined #nim |
19:23:50 | * | kenran joined #nim |
19:30:06 | FromDiscord | <Hourglass [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4mhu |
19:33:09 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mhv |
19:33:10 | FromDiscord | <Elegantbeef> This is probably more sensible than a table |
19:41:08 | FromDiscord | <Hourglass [She/Her]> And if it's none, then do something else? (For my other tokenizing code) |
19:42:27 | FromDiscord | <enthus1ast> or even omit the else, then you get warned (by error message) when you add another opKind but forgot to handle it somewhere |
19:43:04 | FromDiscord | <enthus1ast> in general i mean, idk about your current code |
19:43:58 | FromDiscord | <Hourglass [She/Her]> Yeah I have some more complex lexing rules that this rule is very important for xD |
19:44:05 | FromDiscord | <Hourglass [She/Her]> Thanks though Beef! |
19:45:21 | FromDiscord | <Elegantbeef> I mean either way you need to branch to the else |
19:46:39 | FromDiscord | <enthus1ast> yes, in this case it does not fit, but when operating on enums, this features catched some bugs in my code already |
20:23:40 | FromDiscord | <sOkam!> What does Nim do in the background to optimize int operations? Is simd used, or not at all? |
20:24:55 | FromDiscord | <Phil> I don't think simd is used because I've seen packages that explicitly mention it |
20:25:19 | FromDiscord | <Phil> But super big disclaimer that I have no idea what I'm talking about when it gets this low |
20:25:33 | FromDiscord | <Phil> https://github.com/guzba/nimsimd |
20:55:02 | FromDiscord | <sOkam!> sent a long message, see http://ix.io/4mhD |
21:04:04 | FromDiscord | <Hourglass [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4mhH |
21:04:29 | FromDiscord | <Hourglass [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4mhI |
21:04:33 | FromDiscord | <Elegantbeef> Simd can be implicitly added by the C compiler with flags, but it's best to do it explicitlyâ”(@Phil) |
21:05:02 | FromDiscord | <Hourglass [She/Her]> (Making a minimal reproducible example would be very, very much a pain and more effort than just cloning, unless there's a tool that merges Nim source files |
21:05:06 | FromDiscord | <Hourglass [She/Her]> (edit) "files" => "files)" |
21:06:08 | FromDiscord | <Elegantbeef> No to the first, the most specific version of the proc is used to the second.â”(@sOkam!) |
21:09:19 | FromDiscord | <djazz> I'm using a C lib called JPEGDEC (for embedded) but when run on my computer (linux, 64 bit) I get a SIGSEGV, I think it's trying to access some memory it's not allowed to. However, when running the executable with gdb, it runs fine and everything works. Any idea what might cause it? |
21:09:54 | FromDiscord | <djazz> It's when it is dereferencing a pointer to value that it crashes. |
21:10:18 | FromDiscord | <djazz> and in gdb it works and the value is correct |
21:11:34 | FromDiscord | <sOkam!> In reply to @Elegantbeef "No to the first,": both good and bad news then đ tyty âïž |
21:11:49 | FromDiscord | <Elegantbeef> What are you doing for the first though |
21:12:56 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4mhL |
21:13:03 | FromDiscord | <luteva> In reply to @djazz "I'm using a C": lol: debug the same code you are working with đ maybe you are just in a different folder having two compilations or something like this? |
21:13:29 | * | kenran quit (Remote host closed the connection) |
21:13:42 | FromDiscord | <djazz> I would rewrite it in Nim, but hey xD |
21:14:02 | FromDiscord | <djazz> I dont want to reinvent a jpeg decoder |
21:14:45 | FromDiscord | <sOkam!> @djazz does pixie not work in that system? |
21:15:22 | FromDiscord | <djazz> perhaps... does pixie have low memory footprint? |
21:15:33 | FromDiscord | <sOkam!> no clue bout that |
21:15:33 | FromDiscord | <djazz> don't want to decode it all into memory |
21:16:07 | FromDiscord | <sOkam!> if it doesn't, maybe you could rewrite it to decode in the way you need, just by tweaking it |
21:16:27 | FromDiscord | <sOkam!> not sure if a good or bad idea, just someting that popped in my mind, in case it helps |
21:16:30 | FromDiscord | <djazz> i could comment out the code that crashes it... heh |
21:16:47 | FromDiscord | <djazz> its in the EXIF parser |
21:22:03 | FromDiscord | <Elegantbeef> Sokam i'm uncertain the issue |
21:28:34 | FromDiscord | <djazz> hmm i think the C code is broken, that part of the jpeg hasnt been loaded it seems... |
21:36:07 | FromDiscord | <djazz> its for extracting the thumbnail, which I dont use anyway |
21:37:55 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4mhQ |
21:40:48 | FromDiscord | <treeform> hey, I need a sanity check 0x1FFFFFFFF00000000 / 2 is 0xffffffffc0000000 right??? why does wolfram alpha says its https://www.wolframalpha.com/input?i=0x1FFFFFFFF00000000+%2F+2 0xffffffff80000000 ??? C vs 8 in the middle? WTF |
21:41:27 | FromDiscord | <Elegantbeef> `SomeInteger` sokam |
21:42:41 | FromDiscord | <Elegantbeef> Doesnt fix the issue but makes your code a whole hell of a lot more readable |
21:42:51 | FromDiscord | <pyolyokh> In reply to @treeform "hey, I need a": 8 is 1000, C is 1100 |
21:43:11 | FromDiscord | <pyolyokh> you're shifting an F by 2. |
21:43:27 | FromDiscord | <sOkam!> yeah totally |
21:43:30 | FromDiscord | <pyolyokh> wolfram alpha isn't shifting by 2, it's doing something weird |
21:43:45 | FromDiscord | <pyolyokh> like, division with multiple conversions |
21:44:03 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4mhR |
21:45:18 | FromDiscord | <pyolyokh> In reply to @treeform "hey, I need a": also, you're not shifting by 2. you should have an 8 |
21:47:19 | FromDiscord | <treeform> so who is right me or wolfram alpha? |
21:47:40 | FromDiscord | <pyolyokh> you are definitely wrong, because you shifted by 2 to get C |
21:48:28 | FromDiscord | <pyolyokh> what's 123 in decimal divided by 10? 12.3â”what's 1010 in binary divided by 2? 101 |
21:49:20 | FromDiscord | <pyolyokh> F0 divided by 2 is 78 , not 7C |
21:49:21 | FromDiscord | <treeform> sent a code paste, see https://play.nim-lang.org/#ix=4mhU |
21:49:34 | FromDiscord | <pyolyokh> you're shifting 8 by 1, there |
21:49:40 | FromDiscord | <pyolyokh> you have F in your original question |
21:50:38 | FromDiscord | <pyolyokh> "F0 divided by 2 is 78" -> in decimal this is "240 divided by 2 is 120" |
21:50:38 | FromDiscord | <treeform> thanks that's my actual problem! |
21:50:47 | FromDiscord | <treeform> I did not see the 8 being there and not here |
21:50:58 | FromDiscord | <treeform> thank you for the sanity check! |
21:51:16 | FromDiscord | <treeform> I was looking for error in logic, but it was error in initial conditions |
21:51:46 | FromDiscord | <treeform> it caused me to pull hair out |
21:57:53 | FromDiscord | <sOkam!> Looks really promising for doing deterministic decimals mathâ”Posting in case its useful for anyone else https://media.discordapp.net/attachments/371759389889003532/1068288695821684757/fx.nim |
21:58:05 | FromDiscord | <sOkam!> (edit) "Looks" => "Looking" |
21:58:23 | FromDiscord | <Elegantbeef> I do also think you should just have `fx(i: SomeFloat)` and `fx(i: SomeInteger)` |
21:58:32 | FromDiscord | <Elegantbeef> Do not use `when` instead of just using proc dispatch |
22:00:00 | FromDiscord | <sOkam!> In reply to @Elegantbeef "I do also think": where do you mean? |
22:00:17 | FromDiscord | <Elegantbeef> There is no point in an exception that can be caught at CT |
22:00:18 | FromDiscord | <Elegantbeef> the `newFx` |
22:00:53 | FromDiscord | <sOkam!> what does it do if its missing the case then? |
22:01:01 | FromDiscord | <Elegantbeef> make that `fx` and write the 2 procs |
22:01:05 | FromDiscord | <Elegantbeef> statically error |
22:01:50 | FromDiscord | <sOkam!> ah, instead of the newFx, replacing it with those two procs? |
22:01:54 | FromDiscord | <sOkam!> sounds reasonable ye |
22:01:57 | FromDiscord | <Elegantbeef> Yes |
22:02:01 | FromDiscord | <Elegantbeef> No need for using `when` like this |
22:04:34 | FromDiscord | <sOkam!> ye, totally. very handy |
22:05:48 | FromDiscord | <m4ul3r> sent a code paste, see https://play.nim-lang.org/#ix=4mhV |
22:06:16 | FromDiscord | <m4ul3r> (edit) "https://play.nim-lang.org/#ix=4mhV" => "https://play.nim-lang.org/#ix=4mhW" |
22:07:32 | FromDiscord | <Elegantbeef> dynlib should be `header` |
22:07:39 | FromDiscord | <demotomohiro> `dynlib` pragma is for loading dll or so file, not for importing C functions in header file. |
22:07:42 | FromDiscord | <Elegantbeef> You dont dynamically load headers |
22:09:14 | FromDiscord | <demotomohiro> @m4ul3r In think you need to find which .dll file contains that function (read microsoft dev page for windows api). |
22:09:23 | FromDiscord | <m4ul3r> I see, i see that the one I was modeling off of was leaving off .h. |
22:09:25 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4mhZ |
22:09:46 | FromDiscord | <m4ul3r> I've been referencing the dev page, it is included in ktm32.h |
22:09:57 | FromDiscord | <m4ul3r> oh, forgetting the w |
22:10:50 | FromDiscord | <m4ul3r> ktmw32 - lolâ”looks like it is working with dynlib now |
22:14:13 | * | clemens3 quit (Read error: Connection reset by peer) |
22:15:36 | FromDiscord | <Elegantbeef> Sokam no clue what you mean |
22:17:18 | FromDiscord | <lithiumfrost> If I get back a buffer of LPBYTE and a length (I think that's a char []), how to I read and convert that back to a string value? |
22:17:19 | FromDiscord | <sOkam!> This: https://github.com/treeform/vmath/blob/f4c668874e48e9153d52c4d098f8202e5abec8a9/src/vmath.nim#L475-L476â”Which is used here: https://github.com/treeform/vmath/blob/f4c668874e48e9153d52c4d098f8202e5abec8a9/src/vmath.nim#L507-L512â”I started rewriting, but I might not even need to or something. I just assume its going to write the int representation and/or fail, since the LSP was complaining about it |
22:17:41 | FromDiscord | <sOkam!> (edit) "This: https://github.com/treeform/vmath/blob/f4c668874e48e9153d52c4d098f8202e5abec8a9/src/vmath.nim#L475-L476â”Which is used here: https://github.com/treeform/vmath/blob/f4c668874e48e9153d52c4d098f8202e5abec8a9/src/vmath.nim#L507-L512â”I started rewriting, but I might not even need to or something. I just assume its going to write the int representation and/or fail, since the LSP was complaining about it" => "sent a long message |
22:18:07 | FromDiscord | <Elegantbeef> It shouldnt error |
22:18:15 | FromDiscord | <Elegantbeef> It should write your value's type |
22:19:03 | FromDiscord | <sOkam!> but i have no `$` defined |
22:19:12 | FromDiscord | <Elegantbeef> Ah |
22:19:19 | FromDiscord | <Elegantbeef> Wait that doesnt matter for `type` |
22:19:27 | FromDiscord | <Elegantbeef> `typedesc` have `$` defined |
22:19:32 | FromDiscord | <sOkam!> oh |
22:19:44 | FromDiscord | <sOkam!> hmmm so this is only for vector/matrices then đ€ |
22:22:01 | FromDiscord | <sOkam!> wait, it is actually not registering the generic constructors in the mat.nim and vec.nim files |
22:22:30 | FromDiscord | <sOkam!> (edit) "wait, it is actually not registering the generic constructors ... in" added "from vmath.GVec and vmath.GMat" |
22:29:27 | FromDiscord | <lithiumfrost> Can I just cast the ptr to a Stream? |
22:30:32 | FromDiscord | <Elegantbeef> To get a string you do `$myCstring` |
22:31:54 | FromDiscord | <lithiumfrost> What if it's not null terminated? |
22:32:05 | FromDiscord | <lithiumfrost> I have a length instead |
22:32:53 | FromDiscord | <Elegantbeef> `copyMem` with a `newString(len)` |
22:33:22 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mi6 |
22:33:38 | FromDiscord | <lithiumfrost> Thanks, would have taken me forever to figure that one out |
22:35:14 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4mi7 |
22:35:32 | FromDiscord | <Elegantbeef> no `$` for your type |
22:35:38 | FromDiscord | <Elegantbeef> So it doesnt handle it and just emits a `...` |
22:36:29 | FromDiscord | <sOkam!> ahh |
22:36:56 | FromDiscord | <Elegantbeef> !eval echo (new int,) |
22:37:01 | NimBot | (...,) |
22:41:21 | FromDiscord | <sOkam!> `(arr: [91.902, 48.0])` theeere you go đ |
22:44:08 | FromDiscord | <sOkam!> wait, it should be zero padded đ€ â”do i need std/strformat for formatting an int with zeros before it when representing as a string? |
22:44:42 | FromDiscord | <sOkam!> (edit) "it" => "it," |
22:46:11 | * | clemens3 joined #nim |
22:46:54 | * | clemens3 quit (Client Quit) |
22:47:58 | * | clemens3 joined #nim |
22:48:48 | * | clemens3 quit (Client Quit) |
22:48:57 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4mi8 |
22:49:04 | FromDiscord | <Elegantbeef> formatFloat |
22:49:15 | FromDiscord | <sOkam!> but they are ints |
22:50:09 | FromDiscord | <sOkam!> i guess i could pass through float for a simpler version of the same idea, and truncate the zeros đ€ |
22:52:19 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix= |
23:05:39 | FromDiscord | <sOkam!> Is there a way to get the base type of some type that has inherited another?â”As in, getting `int32` as a result from checking the type of : `type Base = distinct int32` |
23:06:24 | FromDiscord | <Elegantbeef> distinctBase in std/typetraits |
23:06:24 | FromDiscord | <Elegantbeef> It's also not inheritance đ |
23:06:47 | FromDiscord | <sOkam!> what would it be called? aliasing? |
23:06:57 | FromDiscord | <Elegantbeef> Distinct type đ |
23:07:07 | FromDiscord | <Elegantbeef> Aliasing is `type A = b` |
23:10:12 | FromDiscord | <sOkam!> how do you do the same for a non-distinct type? |
23:11:28 | FromDiscord | <sOkam!> `print (Fx.distinctBase).type` is giving me `Base`, but that's where it should be getting the int32 from, because `Base = int32` and `Fx = distinct Base` |
23:13:36 | FromDiscord | <Elegantbeef> Make a macro if you want that |
23:13:40 | FromDiscord | <Elegantbeef> Dont see the point though |
23:14:13 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4mih |
23:14:36 | FromDiscord | <Elegantbeef> You're using an alias that's the point to alias a type |
23:14:44 | FromDiscord | <Elegantbeef> But it's not a complicated macro to get to the bottom |
23:15:20 | FromDiscord | <sOkam!> i've never written a macro ever, though. i have no clue how to navigate them. i tried before, and they are like cryptograms for me for some reason đ |
23:18:20 | termer | I hit a very interesting issue with Nim's asyncnet module |
23:18:55 | termer | In a multithreaded environment with asynchttpserver, you're supposed to call shouldAcceptRequest to check if the maximum number of file descritors have been reached |
23:19:42 | termer | however, in a multithreaded environment, there's apparently a vulnerability to race conditions, so 2 concurrent calls can return true even if a file descriptor has been opened |
23:19:42 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mik |
23:20:14 | termer | if you're restarting your HTTP thread, this leads to a memory leak if you're not closing your AsyncHttpServer socket |
23:20:16 | FromDiscord | <Elegantbeef> 'you're supposed to call shouldAcceptRequest to check if the maximum number of file descritors have been reached'â”â”that's a race condition and a half |
23:20:27 | termer | but if you are, then it can lead to a read to nil, which crashes the program |
23:20:57 | termer | I'll test it out with locks, but this looks like an area that could be documented |
23:21:08 | termer | I don't have this issue in a singlethreaded environment |
23:21:13 | FromDiscord | <Elegantbeef> Even with locks you can have a third program that opens another file descriptor |
23:21:20 | * | azimut quit (Ping timeout: 255 seconds) |
23:21:21 | * | azimut_ joined #nim |
23:21:34 | FromDiscord | <Elegantbeef> So it'll work without anything else happening on the PC |
23:21:54 | termer | So perhaps both the locking during the check and locking during the sleep between checks is necessary |
23:22:02 | FromDiscord | <Elegantbeef> The solution should be just "attempt to open and handle in the case it errors" |
23:22:32 | FromDiscord | <Elegantbeef> If that fails to work then a PR is needed to make it work |
23:22:33 | termer | well the issue is that the crash happens when closing the AsyncHttpServer |
23:22:54 | termer | I think it must be trying to close connections that are nil |
23:22:58 | termer | which seems like a bug |
23:25:02 | termer | I suppose this could be mitigated by handling IOSelectorsException around the accept call |
23:26:44 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4mil |
23:28:45 | FromDiscord | <Elegantbeef> And here i thought sokam said i was rude |
23:29:13 | termer | Interestingly, wrapping the acceptRequest call with a try/except doesn't solve the problem |
23:29:22 | termer | it only gets called a few times before something outside of that loop triggers it |
23:29:28 | termer | somewhere in async world |
23:29:41 | termer | the stack trace is useless lol |
23:29:44 | FromDiscord | <Elegantbeef> Yea i mean if you attempt to open a socket and it cannot an exception should be raised |
23:29:51 | FromDiscord | <Elegantbeef> So it's... quite silly how it presently works |
23:30:22 | FromDiscord | <Elegantbeef> Same with if attempt to add an asyncfd |
23:30:47 | FromDiscord | <Elegantbeef> I'd suggest using chronos |
23:30:50 | FromDiscord | <Elegantbeef> It likely isnt this silly |
23:31:05 | termer | Part of this could be mitigated if acceptRequest didn't take a callback |
23:31:17 | termer | cause it sends that away to be run some other place with asyncCheck |
23:31:21 | termer | instead of awaiting it right there |
23:31:58 | termer | with how it is currently, the exception gets raised in the context of the place where polling started |
23:32:04 | termer | so in this case, a waitFor in another proc |
23:32:28 | termer | Is Chronos good? I never wanted to touch that stuff cause it doesn't use asyncdispatch |
23:32:39 | termer | and introduces a whole new chain of dependencies |
23:35:40 | FromDiscord | <Elegantbeef> It's generally a better async implementation afaik |
23:35:41 | FromDiscord | <Elegantbeef> I dont use async so cannot say much |
23:45:22 | termer | looks like I'm gonna be using chronos |
23:48:21 | termer | So, I'm able to ward off some of the errors by restructuring things |
23:48:25 | termer | but it still eventually reads from nil |
23:48:30 | termer | on close |
23:49:49 | termer | it looks like a socket is nil somewhere |
23:50:25 | termer | ok...... |
23:50:34 | termer | so now I have to check whether the socket is nil |
23:50:59 | termer | The crashes stop when I add a nil check before doing any closing inside of asyncnet.nim |
23:51:56 | termer | There's also a memory leak here somewhere |
23:52:03 | termer | maybe |
23:56:44 | termer | Guess I'm nuking this code and starting with Chronos lol |
23:57:02 | termer | nim async networking is pretty insane |