00:05:43 | * | cyraxjoe joined #nim |
00:09:32 | FromDiscord | <VVX7> what version of MinGW should I use to cross-compile a library using bearssl from linux to windows? |
00:10:22 | FromDiscord | <VVX7> I installed MinGw following the Nim compiler docs here https://nim-lang.github.io/Nim/nimc.html#crossminuscompilation-for-windows |
00:18:39 | adnan338 | Ok another question regarding enums; I have a enum of strings only. When I pass an item of that enum to 'echo' it's able to print the string but why can't it be passed to '$' function? |
00:18:59 | adnan338 | https://play.nim-lang.org/#ix=2L09 |
00:19:50 | adnan338 | oh wait it does |
00:19:53 | adnan338 | nevermind hahah |
00:31:16 | * | Gustavo6046 quit (Ping timeout: 240 seconds) |
00:34:28 | * | D_ quit (Quit: No Ping reply in 180 seconds.) |
00:35:34 | * | D_ joined #nim |
00:44:12 | * | krux02 quit (Remote host closed the connection) |
00:54:10 | * | Tanger joined #nim |
00:55:47 | * | adnan338 quit (Quit: adnan338) |
00:58:30 | * | Gustavo6046 joined #nim |
01:00:20 | FromDiscord | <KallDrexx> So I'm confused. On this box I have a global MinGW setup and Nim does not seem happy with it. A simple `echo "hi"` program fails with the following output: https://gist.github.com/KallDrexx/941560895d1387961bdbd49a2d292493 |
01:00:59 | FromDiscord | <KallDrexx> I don't know enough about C to understand those compile errors |
01:01:48 | FromDiscord | <KallDrexx> Anyone have any idea? |
01:04:39 | mipri | NIM_STATIC_ASSERT(sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8, ""); |
01:04:58 | mipri | NI isn't the same size as a pointer, and NIM_INTBITS isn't the same size as eight NIs |
01:06:27 | mipri | Nim is producing code that expects a compilation environment that doesn't match your actual one. Maybe just 64bit vs. 32bit. |
01:06:45 | mipri | you can probably fix that by telling Nim that you've got some other kind of environment. |
01:06:47 | FromDiscord | <KallDrexx> yeah when you said pointer size I realized maybe mingw installed 32bit not 64bit |
01:20:23 | * | adnan338 joined #nim |
01:20:29 | * | adnan338 quit (Client Quit) |
01:20:43 | * | adnan338 joined #nim |
01:25:37 | * | junland_ quit (Quit: %ZNC Disconnected%) |
01:27:26 | * | junland joined #nim |
01:32:00 | * | abm quit (Quit: Leaving) |
01:43:15 | FromDiscord | <KallDrexx> Well that was annoying so I just figured out why nim's `finish.exe` wasn't working for me and used that |
02:06:22 | * | Gustavo6046_ joined #nim |
02:06:43 | * | Gustavo6046 quit (Ping timeout: 258 seconds) |
02:08:21 | * | Gustavo6046_ is now known as Gustavo6046 |
02:15:39 | * | taprack quit (Remote host closed the connection) |
02:16:05 | * | taprack joined #nim |
02:29:25 | * | taprack quit (Ping timeout: 240 seconds) |
02:40:17 | saem | @leorize[m]: check it: https://github.com/nim-lang/nimsuggest/issues/119 |
02:40:18 | disbot | ➥ nimsuggest outline doesn't account for includes |
02:40:46 | saem | Hopefully it makes sense. :D |
03:00:18 | leorize[m] | yea that's a bug |
03:01:01 | leorize[m] | iirc it used to show everything, will try to debug it later |
03:01:28 | saem | hmm |
03:02:31 | leorize[m] | I used to jump around sem with outline so pretty sure it's supposed to work |
03:04:37 | FromGitter | <redblack3_gitlab> Hey guys, I'm trying to get this code to work: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ The second line is gibberish. Seems like the `importcpp` pragma is trying to get generic params from the `Vector3` type alias, which only has 1 generic parameter. [https://gitter.im/nim-lang/Nim?at=5ff528c54498e01bbf8d4199] |
03:05:24 | FromGitter | <redblack3_gitlab> Anyone know if there a work-around for this, or am I doing it wrong? |
03:07:03 | leorize[m] | I think you would have to define it for each tvec separately |
03:07:50 | leorize[m] | you can use a template for that |
03:09:01 | FromGitter | <redblack3_gitlab> Ya I did try that, but that introduced complications with the functions that work on those types, since Vector[3, T] and Vector3[T] need to be fully interchangeable. |
03:09:43 | leorize[m] | saem: not sure if my memory is still correct, but the include should share the same owner as the main one |
03:09:45 | FromGitter | <redblack3_gitlab> How would I use a template? I tried something like `template Vector3[T] = Vector[3, T]` before, but that doesn't work with `type[]` |
03:10:23 | leorize[m] | saem so you can probably use that to figure if a node is a part of the file nimsuggest is inspecting |
03:14:43 | leorize[m] | redblack3_gitlab: you would wanna make the template define the type for you |
03:15:26 | leorize[m] | but you want to define functions that will work on the Vector[S, T] typeclass too? |
03:18:26 | FromGitter | <redblack3_gitlab> Yes, like this one: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5ff52c02d5f4bf2965cb6e98] |
03:28:37 | * | muffindrake quit (Ping timeout: 260 seconds) |
03:30:54 | * | muffindrake joined #nim |
03:36:30 | disruptek | leorize[m]: you figured out testes, right? |
03:37:30 | disruptek | i think i added code to do a debug run after a release failure (on ci only) but i can't remember. |
03:37:48 | disruptek | i might have been high. |
03:45:52 | * | Gustavo6046 quit (Ping timeout: 260 seconds) |
03:50:25 | * | Gustavo6046 joined #nim |
03:51:16 | leorize[m] | disruptek: yea, though you should make it output all the error messages always |
03:51:22 | leorize[m] | don't know why you would hide them |
03:51:53 | disruptek | well, it was made to help me debug cps. 😁 |
03:52:57 | disruptek | i often want to see which tests succeed. i don't really want to run individual compiler processes for each test. |
03:53:10 | leorize[m] | redblack3_gitlab: so you don't need the `S` in `[S, T]`, ever? |
03:53:32 | leorize[m] | then we can autogenerate that stuff |
03:53:39 | leorize[m] | but why don't you use nim-glm though |
03:54:55 | leorize[m] | disruptek: it certainly confused me the first time I tried |
03:55:35 | disruptek | it's weird how few people read READMEs. i will raise it on the page. |
04:00:13 | disruptek | i guess i did add a debug build but it doesn't work. |
04:00:18 | disruptek | so, yeah, i guess i was high. |
04:04:04 | * | Gustavo6046 quit (Remote host closed the connection) |
04:04:18 | * | Gustavo6046 joined #nim |
04:05:27 | * | Jesin quit (Read error: Connection reset by peer) |
04:11:34 | FromDiscord | <Anonymous Poet> hey all, has anyone had issues with nim's http server and the Content Length header? |
04:11:57 | FromDiscord | <Anonymous Poet> im trying to use nim with openfaas and mostly got it set up, but ran into an issue with POST |
04:12:10 | FromDiscord | <Anonymous Poet> im trying to debug the go + nim http boundary |
04:12:12 | disruptek | !issues content length http |
04:12:13 | disbot | https://github.com/nim-lang/Nim/issues/16436 -- 3AsyncHttpClient doesn't handle errors |
04:12:13 | disbot | https://github.com/nim-lang/Nim/issues/14794 -- 3Multipart upload in httpclient broken |
04:12:13 | disbot | https://github.com/nim-lang/Nim/issues/13923 -- 3Very high memory usage due to numerous inefficiencies in the STD lib (async) 7& 27 more... |
04:12:38 | disruptek | looks like at least 30 likely candidates for your consideration, if you have access to a web-browser. |
04:13:18 | FromDiscord | <Anonymous Poet> interesting, thanks, ill dig into them if needed, but my issue seems pretty surface level still |
04:13:29 | FromDiscord | <Anonymous Poet> (also only the first 3 show up on discord) |
04:13:32 | disruptek | what does that mean? |
04:13:37 | FromDiscord | <Anonymous Poet> like, the header doesnt seem to get passed at all |
04:13:53 | disruptek | so? |
04:13:58 | FromDiscord | <Anonymous Poet> sent a code paste, see https://play.nim-lang.org/#ix=2L0S |
04:14:10 | disruptek | if you're on irc you can speak to disbot directly to get more than 3 results. |
04:14:15 | disruptek | sadly, you're not on irc. |
04:14:18 | FromDiscord | <Anonymous Poet> sent a code paste, see https://play.nim-lang.org/#ix=2L0T |
04:20:24 | FromDiscord | <Anonymous Poet> looking at the issue tracker on nim-lang, the closest ones are https://github.com/nim-lang/Nim/issues/6870 https://github.com/nim-lang/Nim/issues/10726 but both are closed, and neither is about receiving a non-zero content length (the first one is the closest) |
04:20:33 | disbot | ➥ HTTP response without Content-Length is not accessible ; snippet at 12https://play.nim-lang.org/#ix=2L0U |
04:21:17 | disruptek | i would look at the raw string prior to parse. |
04:21:22 | FromDiscord | <Anonymous Poet> i was on here the other day and i think either beef or someone else helped me narrow down the relevant line from asynchttpserver where the content length was checked; now im wondering if theres a step earlier in the process |
04:21:33 | FromDiscord | <Anonymous Poet> do you know what file that would be in? |
04:21:46 | mipri | lib/pure/asynchttpserver.nim |
04:22:10 | leorize[m] | disruptek: if you ever wonder about how the matcher thingy for github actions looks like when it works: https://github.com/alaviss/nim-sys/commit/2ed66db9eb002022d926043a51ef95e91d4fdef0 |
04:22:32 | FromDiscord | <Anonymous Poet> sent a code paste, see https://play.nim-lang.org/#ix=2L0V |
04:22:57 | disruptek | leorize[m]: yeah, it spams me all the time. 😆 |
04:25:01 | FromDiscord | <Anonymous Poet> it seems like that is the raw strings, and indeed they dont contain a content length |
04:25:22 | FromDiscord | <Anonymous Poet> sent a code paste, see https://play.nim-lang.org/#ix=2L0X |
04:25:26 | disruptek | where is your GOd now |
04:25:34 | FromDiscord | <Anonymous Poet> hm? |
04:25:55 | disruptek | obvs, it's time to write your client in nim, too. |
04:26:17 | FromDiscord | <Anonymous Poet> oh, the go code isnt mine, its openfaas |
04:26:41 | disruptek | well, i won't tell anyone. |
04:26:44 | FromDiscord | <Anonymous Poet> i made a ticket a few days ago but its not gotten any attention yet |
04:26:47 | disruptek | i can't vouch for mipri, though. |
04:26:55 | FromDiscord | <Anonymous Poet> so im trying to fix the thing myself, haha |
04:28:24 | * | spiderstew_ joined #nim |
04:31:57 | * | spiderstew quit (Ping timeout: 265 seconds) |
04:35:29 | FromDiscord | <VVX7> I'm confused by wrapping exteranl C libraries. I'm trying to cross-compile somethign with BearSSL from Linnux to Windows but Nim complains that the imported C lib is not found. I expected MinGW to build it. Do I need to build the DLL first and then pass it to Nim during build? |
04:35:45 | FromDiscord | <VVX7> or is there something else going on there I'm not grasping |
04:36:23 | saem | Oh, it's a silly environment variable, isn't it poet? |
04:36:29 | disruptek | does the .dll file exist? |
04:36:38 | disruptek | if so, put it adjacent to the .exe. |
04:37:24 | disruptek | yes, it does need to be built first, just as you'd need to build it on linux, first. |
04:38:21 | disruptek | actually, i'm not sure it needs to exist at build time. |
04:38:31 | disruptek | i don't x-compile windows garbage. |
04:38:32 | FromDiscord | <VVX7> the dll does not exist. Am building from Linux and the build fails because Nim doesn't see the library. I just expected that it would be built automatically as a dependancy |
04:38:44 | disruptek | i doubt it would be. |
04:39:02 | disruptek | but it sounds like it /is/ needed. 😉 |
04:39:34 | FromDiscord | <Anonymous Poet> not sure i follow, but i dont think so. do you mind elaborating? |
04:41:08 | FromDiscord | <Anonymous Poet> i dont have too much experience cross compiling, but i think by default cross compiling c/c++ code doesnt "just work"; usually you need to compile in the same env you want to run in |
04:43:27 | FromDiscord | <ElegantBeef> Poet discord's reply system doesnt work for the irc bridge 😄 |
04:44:33 | FromDiscord | <VVX7> sent a code paste, see https://play.nim-lang.org/#ix=2L0Z |
04:45:20 | FromDiscord | <Anonymous Poet> oh, good to know about the replies |
04:45:31 | FromDiscord | <Anonymous Poet> @VVX7 can you build on the windows machine? |
04:45:35 | FromDiscord | <Anonymous Poet> or is it only a deploy target? |
04:46:25 | * | adnan338 quit (Quit: adnan338) |
04:47:43 | FromDiscord | <VVX7> I could build it on Windows but it's an extra step. Seems like something I'm not getting right. But I haven't found any examples of cross compiling with imported c libs that would help me understand if it's my fault. |
04:48:19 | * | rockcavera quit (Remote host closed the connection) |
04:50:15 | FromDiscord | <Anonymous Poet> do you have the sources all they way down? ie. including for bearssl? |
04:50:38 | FromDiscord | <Anonymous Poet> because if not, its possible that theres some unix deps somewhere that you wouldnt be able to work around no matter what |
04:56:21 | FromDiscord | <VVX7> @Anonymous Poet Yep, their installed with nim-bearssl. I can build the binary as an ELF and it works. But it complains the same C sources are not found when the target is for windows. 🤷♂️ |
04:57:30 | ForumUpdaterBot | New thread by Chris3606: Export by Ordinal for Windows DLLs?, see https://forum.nim-lang.org/t/7338 |
04:59:02 | FromDiscord | <Anonymous Poet> just because you can build the elf binary doesnt necessarily mean you have all the sources (you may need to check for dynamically linked deps, like with `ld`) but assuming that you do have all the sources, thats maybe weird |
04:59:41 | FromDiscord | <Anonymous Poet> one observation is that the path you posted above goes to `\csources\src\codec\dec32be.c` - im not sure if unix will treat that as a path or an escape char |
05:00:13 | FromDiscord | <Anonymous Poet> sent a code paste, see https://play.nim-lang.org/#ix=2L10 |
05:02:56 | FromDiscord | <Anonymous Poet> disruptek, if you're still around, i think ive identified my issue |
05:03:01 | disruptek | what is it? |
05:03:22 | FromDiscord | <Anonymous Poet> it seems like even though go has the content length, for whatever reason, it passes "Transfer-Encoding: chunked" instead of content length |
05:03:33 | FromDiscord | <Anonymous Poet> and it doesnt seem like the nim http server has any support for this atm |
05:03:42 | disruptek | neat. |
05:03:46 | FromDiscord | <Anonymous Poet> or at the very least, the check for Content-Length is hard coded and non-optional |
05:04:38 | FromDiscord | <Anonymous Poet> im willing to try adding this and making a PR, but im not sure what would actually be required to implement chunked encoding |
05:05:15 | disruptek | i think it's pretty straightforward but that doesn't mean the impl will be trivial. |
05:08:02 | saem | https://github.com/nim-lang/Nim/issues/7126 |
05:08:03 | disbot | ➥ No way to process async HTTP response in chunks |
05:09:51 | saem | You should still be able to buffer it, but ouch. |
05:09:53 | FromDiscord | <Anonymous Poet> saem, that looks like its on the sending end, whereas im talking on the receiving end |
05:11:48 | FromDiscord | <Anonymous Poet> i think this is the most appropriate place for changes: https://github.com/nim-lang/Nim/blob/d721f5cecad90a0aa7e2ea144607ffafdf647e31/lib/pure/asynchttpserver.nim#L252 |
05:16:37 | saem | Regardless, the faas send out of spec, it needs to provide the size in bytes |
05:19:46 | saem | But I could be remembering the spec wrong. |
05:22:43 | FromDiscord | <Anonymous Poet> https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding |
05:22:54 | FromDiscord | <Anonymous Poet> its valid, sadly |
05:23:10 | FromDiscord | <Anonymous Poet> and i dont see it dont it explicitly, i think its a go stdlib thing unfortunately |
05:24:03 | FromDiscord | <Anonymous Poet> the good news is that maybe ill contribute something to nim! 😄 |
05:26:52 | FromDiscord | <flywind> see https://github.com/nim-lang/Nim/pull/8447 |
05:26:53 | disbot | ➥ Added chunked response to asynchttpserver. |
05:27:30 | disruptek | shocker. |
05:28:29 | FromDiscord | <flywind> And https://github.com/iocrate/netkit/blob/master/netkit/http/chunk.nim |
05:33:20 | leorize | saem: so what have you found when debugging outline? |
05:33:44 | leorize | does it work if you remove the file check? |
05:33:48 | saem | Was making dinner and watching TV |
05:34:00 | saem | Going to give it a go now, but I have an idea of where to look |
05:35:41 | FromDiscord | <Anonymous Poet> the first example flywind linked is definitely for sending, so while it might be useful for inspiration, its not what i need |
05:35:50 | leorize | saem: haven't run any tests other than the one you shown, but this should work: http://ix.io/2L14/patch |
05:36:05 | leorize | basically I change the file check into owner check |
05:36:13 | FromDiscord | <Anonymous Poet> the second file linked also seems to be sending, but not 100%, and it seems like the rest of the repo might be useful; i need to dig around more |
05:36:19 | FromDiscord | <Anonymous Poet> but thanks everyone for the help |
05:36:38 | * | adnan338 joined #nim |
05:36:39 | * | adnan338 quit (Client Quit) |
05:36:53 | * | adnan338 joined #nim |
05:39:03 | saem | Yup, I see that. I'm just hitting it with the debugger so I can test some assumptions |
05:48:18 | * | narimiran joined #nim |
05:50:05 | saem | I _think_ the code walk up the owners (successive includes) until it encounters a skPackage owner, then take the previous skModule's fileIndex as that means it would work regardless of the depth of includes... presently it would break for immediate symbols AFAICT. |
05:50:15 | saem | Gonna give that a shot |
05:51:15 | disruptek | owners is being deprecated; you might be able to use the new itemId instead. |
05:51:30 | saem | Thanks for the tidbit! |
05:51:52 | disruptek | i mean, use what works, but know that owners is rather brittle by comparison. |
05:52:59 | saem | Is owners going away because ownership can change from the perspective of IC when thinking about different compilation branches? |
05:53:31 | disruptek | no, it's just annoying. 😁 |
05:53:36 | saem | LoL |
05:54:03 | disruptek | slow and brittle. |
05:54:15 | leorize | this seems to be simpler than what you were talking about yesterday :P I thought you found the grand bug of nimsuggest |
05:55:46 | saem | Oh no, I think those are there... I mean we're relying on this stuff to be accurate and I saw some things that make me wondering how consistent/clean this data is. |
05:56:34 | leorize | one thing I do know is that TLineInfo and TFileInfo is very accurate due to their simple construction (they're built during parsing with very simple code paths) |
05:56:49 | leorize | except when `{.line.}` come into play because that pragma is evil |
05:56:54 | disruptek | saem: one ownership element that changes, possibly, is generics that get recorded in the modules in which they are used. |
05:57:42 | saem | disruptek: I mean couldn't someone be a jerk and have a when with one branch as include and another as import and then it gets hilarious? |
05:58:05 | disruptek | they may be owned by an external module. i don't actually how how it ended up being impl'd. |
05:58:20 | disruptek | the include/import is pretty harmless. |
06:00:18 | saem | That makes sense now that I think about it more, because since the forked path is in the module with the when statement, it should end up as two different things in IC terms. |
06:01:07 | disruptek | right. |
06:11:22 | * | Tlangir joined #nim |
06:14:26 | * | Tanger quit (Ping timeout: 272 seconds) |
06:27:49 | * | nyd joined #nim |
06:27:55 | * | nyd left #nim (#nim) |
06:37:20 | * | waleee-cl quit (Quit: Connection closed for inactivity) |
06:41:01 | saem | Unfortunately, I can't seem to find an index structure that lets me use the item id to walk back up the tree of includes like owner id does. I thought I'd seen something a while back but who knows. Owner id it is. |
06:45:01 | * | greenfork joined #nim |
06:48:07 | FromDiscord | <Zed> Well i've been away from nim for a while now, what's been happening? |
06:49:52 | * | Tlanger joined #nim |
06:49:56 | FromDiscord | <ElegantBeef> Nimthing much |
06:50:19 | leorize | IC happened |
06:50:35 | leorize | doesn't seem to improve performance by much though |
06:51:25 | FromDiscord | <ElegantBeef> Clearly we're just missing the `doItFaster` macro |
06:52:59 | saem | Stop trying to make fetch happen. |
06:53:04 | * | Tlangir quit (Ping timeout: 272 seconds) |
06:53:14 | FromDiscord | <Zed> the discord certainly grew a bit |
06:53:25 | FromDiscord | <Zed> (edit) "the discord ... certainly" added "channels" |
06:53:27 | saem | Rude |
06:53:44 | FromDiscord | <Zed> lol |
06:54:42 | saem | What brought you to Nim in the first place? |
06:55:25 | FromDiscord | <Zed> my hate for python slowness |
06:55:46 | FromDiscord | <Zed> and the fact that i cant stick to one language |
06:56:36 | saem | Can I ask what took you away (you don't have to answer if it's a sore spot)? |
06:57:55 | FromDiscord | <Zed> Uni did, went to swift and java |
06:58:14 | saem | That'll do it. What brings you back? |
06:58:20 | FromDiscord | <Zed> tried go for a bit but hate the amount on `if err != nil{}` you have to put everywhere |
06:58:34 | FromDiscord | <ElegantBeef> Clearly they just missed me |
06:58:36 | saem | Is it the need... the need for speed? |
06:58:44 | FromDiscord | <Zed> yes |
06:59:03 | FromDiscord | <Zed> i am speed |
06:59:06 | saem | ElegantBeef every morning when I'm in work slack I wish I was here so I stop missing you. |
06:59:24 | FromDiscord | <Zed> what about you? what brought you here? |
06:59:35 | FromDiscord | <ElegantBeef> Saem for some reason i just dont believe you |
06:59:54 | saem | Don't torture me. :( |
07:00:20 | FromDiscord | <ElegantBeef> Saem is here cause he really is masochistic and loves working on tooling |
07:00:33 | saem | Or is one |
07:00:56 | FromDiscord | <Zed> ah |
07:01:15 | saem | My day job took me away from programming, I get to talk about it... and even then not even that. Wanted to just do things in my spare time, figured I'd try to get into making crappy games. Started with Typescript, wanted type driven emit, when to Haxe, tried hashlink, it's okish to use, but don't look under the covers... |
07:01:54 | saem | Then I saw Nim and HCR and the JS target, figured Haxe is so raw, how far off could Nim be? I'm already in the boonies at this point. |
07:02:23 | FromDiscord | <ElegantBeef> It's ok that's where i live |
07:02:57 | FromDiscord | <Zed> haha, i assume you've tried impboxs game framework then |
07:03:02 | saem | Anyhow... Figured I'd start by fixing the tooling because I want a productive environment and wanted to learn Nim, and the next thing you know I ported the TypeScript extension for Nim to Nim. |
07:03:13 | saem | nah, heaps mostly |
07:03:16 | FromDiscord | <ElegantBeef> My reason is i wanted to learn something lower than C# and nothing else tickled my fancy at a glance |
07:03:37 | saem | in Haxe that is. In Nim I haven't touched anything yet. |
07:03:44 | saem | I'm at like step -13 |
07:03:55 | FromDiscord | <ElegantBeef> I've been toying with godot + nim |
07:03:57 | leorize | I got here because I need pascal with metaprogramming |
07:04:24 | FromDiscord | <ElegantBeef> I now cannot use a language without metaprogramming without going crazy |
07:04:50 | saem | It's not that hard, but I also think code generation is good so I'm a little weird. |
07:04:58 | leorize | I can't live without something like Nim's `template` anymore |
07:05:11 | FromDiscord | <ElegantBeef> Indeed |
07:05:43 | FromDiscord | <ElegantBeef> I wrote a small airplane controller in godot and possibly wrote 1 template to reduce redundant logic |
07:06:13 | FromDiscord | <ElegantBeef> sent a code paste, see https://play.nim-lang.org/#ix=2L1i |
07:06:13 | FromDiscord | <ElegantBeef> Totally not a silly use case 😄 |
07:06:42 | FromDiscord | <ElegantBeef> ~~Dont say i could just use a var proc~~ that makes too much sense |
07:46:38 | FromDiscord | <lqdev> beef lol `lazyClamp(x, y, a, b)` isn't any more readable than `clamp(x + y, a, b)` |
07:49:05 | Zevv | no, but it's lazy |
07:50:07 | Zevv | I bet it tries not to evaluate "x+y" if not needed |
07:51:04 | FromDiscord | <Randall> How do I test a function that raises an exception at compile time? `doAssertRaises` doesn't work (is the code expanded before the template?) |
07:51:31 | FromGitter | <ornamentist> The Nim experimental documentation (https://nim-lang.org/docs/manual_experimental.html#concepts) for Concepts shows an example with a Haskell style Functor |
07:51:58 | FromGitter | <ornamentist> The last line of that example says the example code prints "true", but for me it prints "false" |
07:52:21 | FromGitter | <ornamentist> Has the compiler implementation diverged from that documentation? |
07:53:09 | FromDiscord | <CodeHz> why, template is just ast transformer, should got same result as hand-written |
07:53:11 | FromDiscord | <Randall> sent a code paste, see https://play.nim-lang.org/#ix=2L1t |
07:56:02 | FromDiscord | <CodeHz> that's why it is experimental (: |
07:57:48 | FromDiscord | <CodeHz> the problem is Option has not export his field |
07:58:23 | FromDiscord | <CodeHz> so val is private, maybe they used to be public field |
07:58:44 | FromGitter | <ornamentist> Fair enough--I expect experimental features to change as needed by the implementers |
08:00:48 | FromDiscord | <CodeHz> (edit) the problem is Option has not export its field |
08:03:47 | FromGitter | <offbeat-stuff> https://play.nim-lang.org/#ix=2L1x throws error |
08:06:13 | saem | spelling mistake, cxt? |
08:06:47 | FromGitter | <offbeat-stuff> thanks very confused myself |
08:10:10 | * | PMunch joined #nim |
08:10:58 | FromGitter | <offbeat-stuff> print expersion inside templates |
08:11:51 | FromGitter | <offbeat-stuff> Like print(createWin("Hello")) becomes like echo "createWin(\"Hello\")" |
08:12:45 | * | Tlanger quit (Ping timeout: 240 seconds) |
08:13:59 | * | Tanger joined #nim |
08:17:41 | * | saem leorize: https://github.com/nim-lang/Nim/pull/16608 that's ma fix. |
08:17:42 | disbot | ➥ outline shows included declarations |
08:18:39 | saem | Once that's accepted I gotta tweak the caching structure in my extension but otherwise it should work well. \o/ |
08:27:22 | adnan338 | Hello, How does one define an optional range literal in function arguments. Compiler thinks `proc minute(m : Option[0 .. 59]) = echo m.get()` means m is an Option of a slice |
08:31:33 | FromDiscord | <Randall> sent a code paste, see https://play.nim-lang.org/#ix=2L1D |
08:36:11 | adnan338 | https://play.nim-lang.org/#ix=2L1E |
08:36:32 | adnan338 | Still giving me an issue |
08:37:10 | FromDiscord | <Rika> You need to specify it is a range I believe |
08:37:22 | adnan338 | Did that too |
08:37:24 | adnan338 | https://play.nim-lang.org/#ix=2L1F |
08:38:02 | FromDiscord | <Rika> No, I mean in the some call |
08:38:41 | FromDiscord | <Rika> https://play.nim-lang.org/#ix=2L1H |
08:39:54 | adnan338 | Ah I see. Thank you. |
08:40:00 | * | taprack joined #nim |
08:46:17 | * | Tanger quit (Remote host closed the connection) |
08:54:39 | FromGitter | <offbeat-stuff> How do i import this enum |
08:54:41 | FromGitter | <offbeat-stuff> enum class FramebufferClear: GLbitfield { ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ }; [https://gitter.im/nim-lang/Nim?at=5ff57ad081c55b09c7ee4fb5] |
08:56:50 | FromDiscord | <mratsim> @offbeat-stuff: type FrameBufferClear {.importcpp, size: sizeof(cint).} = enum |
08:57:39 | FromDiscord | <mratsim> for example: https://github.com/numforge/agent-smith/blob/master/third_party/ale_wrap.nim#L66-L81 |
08:58:03 | FromGitter | <offbeat-stuff> Also how do i importcpp values for its fields or do i not need to |
08:58:24 | FromDiscord | <mratsim> and another: https://github.com/SciNim/flambeau/blob/master/flambeau/raw_bindings/tensors.nim#L135-L147 |
08:58:41 | FromDiscord | <mratsim> an enum doesn't have fields |
08:58:55 | FromGitter | <offbeat-stuff> For the possible values |
08:59:00 | FromDiscord | <mratsim> you need to specify the name = value map yourself |
08:59:22 | FromDiscord | <mratsim> especially if they don't go from 0 to max-1 |
08:59:59 | FromDiscord | <mratsim> you can c2nim that though |
09:00:55 | FromGitter | <offbeat-stuff> Well It's quite a big game engine like framework so I don't want to do it also very deep c++ library from magnum.graphics |
09:04:04 | FromGitter | <offbeat-stuff> Also cannot convert array[4,float32] to const Color4& |
09:04:20 | FromGitter | <offbeat-stuff> In c++ {1.0f,1.0f,1.0f,1.0f} works |
09:07:02 | FromGitter | <offbeat-stuff> typedef Math::Color4<Float> Color4; |
09:08:56 | * | polm joined #nim |
09:15:21 | FromDiscord | <mratsim> you can c2nim the specific enum declaration if it's big |
09:15:40 | FromDiscord | <mratsim> you can do initializer lists with varargs |
09:16:34 | FromDiscord | <mratsim> this is the syntax: https://github.com/SciNim/flambeau/blob/master/flambeau/raw_bindings/tensors.nim#L318↵@offbeat-stuff |
09:19:22 | FromGitter | <offbeat-stuff> mratsim Does 0x00000100 not mean the same in nim |
09:19:27 | FromGitter | <offbeat-stuff> as in c++ |
09:20:11 | FromDiscord | <mratsim> so you can just do proc color4(a0, a1, a2, a3): Color4 {.constructor, importcpp: "Math::Color4<Float>({@}).} and create a small wrapper that unpacks the array[4, float] in individual components |
09:20:38 | FromDiscord | <mratsim> it's the same but Nim defaults to int which are 64 bit on 64-bit platforms |
09:20:43 | * | Vladar joined #nim |
09:20:46 | FromGitter | <offbeat-stuff> typedef unsigned int GLbitfield; |
09:20:49 | FromDiscord | <mratsim> C++ default to C int which are 32-bit |
09:21:23 | FromGitter | <offbeat-stuff> I think I should just pull em from opengl wrapper |
09:21:59 | FromDiscord | <mratsim> so your enum is deriving from an unsigned integer? |
09:22:07 | FromDiscord | <mratsim> that's a weird declaration |
09:24:07 | FromGitter | <offbeat-stuff> What does invalid order in enum 'DepthBufferBit' even mean |
09:27:35 | PMunch | That you have the elements out of order |
09:27:37 | PMunch | By their value |
09:28:01 | PMunch | enum One = 1, Zero = 0 for example |
09:28:13 | PMunch | Instead of enum Zero = 0, One = 1 |
09:30:55 | * | Tanger joined #nim |
09:36:38 | narimiran | hey PMunch! i tried to rebase https://github.com/nim-lang/Nim/pull/15729 on the latest devel, but i cannot force-push to your repo. could you do it? (and while at it, you can remove 4 out of 5 my commits - the ones that were reverted) |
09:36:39 | disbot | ➥ Implements streams for sockets |
09:37:00 | * | hnOsmium0001 quit (Quit: Connection closed for inactivity) |
09:38:50 | PMunch | The ones from November? |
09:40:50 | polm | Hello, I'm trying to wrap a C++ library and getting an error on compilation about an "undefined reference to systemInit000" I don't understand |
09:41:17 | polm | detailed error is here: https://gist.github.com/polm/7a6baeed8a49a84b46c4e0285c085514 |
09:41:27 | polm | code is here: https://github.com/polm/hajikami/blob/main/hajikami.nim |
09:41:32 | * | krux02 joined #nim |
09:41:42 | * | taprack quit (Ping timeout: 260 seconds) |
09:41:58 | polm | The systemInit000 seems to be something nim defines internally in c++ code, and I saw some references to it on the forums, but didn't see a similar problem anywhere, so I'm not sure what's going on... |
09:46:16 | narimiran | PMunch: you can remove all of mine except "a different way to fix mismatching tags" |
09:48:02 | FromDiscord | <inv> Hi. Are there any way to unpublish package from nimble? I want to republish it with lower-case name |
09:48:27 | FromDiscord | <Rika> You can rename |
09:48:34 | FromDiscord | <Rika> See the packages repo |
09:48:34 | narimiran | @inv send a PR where you rename it |
09:48:42 | FromDiscord | <inv> yep, thx |
09:50:35 | FromDiscord | <inv> https://github.com/nim-lang/packages/pull/1773 |
09:50:36 | disbot | ➥ Decimal => decimal |
09:51:08 | * | mids joined #nim |
09:53:49 | * | taprack joined #nim |
09:56:29 | narimiran | PMunch: heh, you don't believe in force push, huh? :D |
09:56:38 | PMunch | That was a force push.. |
09:56:44 | PMunch | But I messed it up |
09:57:39 | PMunch | I'm not quite sure what you want me to do TBH |
09:58:48 | narimiran | sorry :) |
09:59:12 | narimiran | i guess you merged devel, not rebased |
09:59:48 | narimiran | oh, now is ok |
10:00:24 | narimiran | i guess the only problem was that github showed me "there are xyz changes since you last viewed this PR" |
10:01:02 | PMunch | Only thing I did was force-push the backup I took of the old branch before I started messing about with it :P |
10:01:17 | PMunch | And yeah, I messed up and merged with devel at some point.. |
10:01:58 | PMunch | To tidy it up I think I need to start on a fresh devel and cherry-pick in our changes |
10:02:12 | PMunch | Then force-pushing that |
10:02:29 | narimiran | i have that version, but i cannot force-push it |
10:03:48 | narimiran | but i didn't have to do any cherry picking, it was just `git rebase devel` |
10:04:28 | narimiran | and then `git rebase -i HEAD~10` to remove my unneeded commits |
10:05:09 | FromGitter | <HJarausch_gitlab> Have a macro disabling itself if called a second time *within the same namespace*. E.g. if it is within the same proc outside of any *block*. Is this possible? |
10:07:11 | FromDiscord | <haxscramper> You probably can hack it with two-step macro, something like `when not declared(macroWasEvaluated): macroBody` and `const macroWasEvaluated = true` following it |
10:07:42 | FromDiscord | <haxscramper> This might prevent evaluation of the same macro in the scope |
10:07:43 | PMunch | narimiran, there, better? |
10:08:04 | PMunch | Maybe I should've renamed your commit while I was at it.. |
10:08:14 | narimiran | yeah :) |
10:08:16 | narimiran | and yeah :) |
10:08:30 | FromDiscord | <haxscramper> But that is an ugly hack, and you should really try to avoid this |
10:08:58 | PMunch | There you go |
10:12:49 | narimiran | PMunch: great, thanks! now, what to do with @planetis-m's remarks? should `rsPeekData` be changed or not? |
10:13:02 | narimiran | (i can do that, just want your input on it0 |
10:14:56 | * | polm left #nim (#nim) |
10:20:00 | PMunch | Nope, his changes doesn't make sense in the slightest |
10:20:20 | PMunch | He sets result to the amount of data received, which is just wrong |
10:21:16 | PMunch | Imagine I read 10 bytes, then setPosition to 5 and then read 10 bytes. Then if will see that it needs to read 5 more bytes, read those into the buffer, copy ten bytes from position 5 and out into the buffer, and return 10. |
10:21:27 | PMunch | His version will do the same reading, but return 5 |
10:24:58 | PMunch | Only problem in my solution is if `recv` reads less than the given amount of bytes, then it will return a buffer with 0s in it |
10:25:05 | PMunch | Guess that should be fixed |
10:30:43 | narimiran | PMunch: before you do that, let me push just the move to `std/` |
10:31:33 | narimiran | done. and your explanation for rsPeekData makes sense to me |
10:36:03 | PMunch | Good, want to try your hand at implementing it? :P |
10:36:43 | narimiran | not sure you really want that :P :D |
10:38:20 | narimiran | oh, wait. can we use the value we now discard? |
10:57:36 | PMunch | Yup, that's the idea |
11:00:33 | narimiran | PMunch: ok, i'll give it a try after lunch and i'll ping you when i have something (most likely: something = questions) |
11:00:42 | PMunch | Haha, sounds good |
11:08:10 | FromDiscord | <inv> @timotheecour Hi, Are you here? What do you think about the line? Should it pass opt param?: https://github.com/nim-lang/Nim/blob/version-1-4/lib/std/jsonutils.nim#L214 |
11:08:33 | * | planetis[m] joined #nim |
11:09:07 | FromDiscord | <inv> I think probably yes, but maybe there are some meanings why it was not passed |
11:17:04 | FromGitter | <timotheecour> @inv indeed, seems like just a bug (and likewise with a few other cases in this file), PR welcome |
11:21:54 | * | NimBot joined #nim |
11:24:13 | * | taprack quit (Ping timeout: 264 seconds) |
11:31:39 | * | reversem3 joined #nim |
11:38:14 | * | planetis[m] joined #nim |
11:38:15 | planetis[m] | PMunch: imo rsReadData should save the read bytes into result and rest of the procs would use that |
11:38:23 | planetis[m] | just like other stream implementations |
11:40:24 | PMunch | Instead of doing it the other way round like I do? |
11:41:07 | PMunch | I just felt that was the more natural way of doing it when I wrote it. One that reads data, and one that reads data and updates the position |
11:41:16 | PMunch | Seems like a pretty obvious composition |
11:41:29 | PMunch | Instead of one that reads and updates, and one that reads, updates, and resets the position |
11:42:50 | planetis[m] | Well that way, you can fix reading '\0' more easily, but I guess this is only one way to do it |
11:43:14 | PMunch | Why would that be easier? |
11:45:12 | * | lf joined #nim |
11:45:36 | * | lf is now known as Guest25945 |
11:52:01 | narimiran | PMunch: planetis[m]'s way indeed fixes his example |
11:52:58 | PMunch | Yes, but it doesn't work in the general case if you use setPosition |
11:53:22 | PMunch | What he does is basically an incorrect version of returning the actual amount |
11:53:38 | PMunch | It only works correctly for the s.pos == oldPos branch |
11:53:53 | PMunch | Or oldLen I think the variable is called |
11:55:41 | narimiran | true, i'll try to see if i can make it generally correct |
12:04:28 | * | rockcavera joined #nim |
12:11:57 | * | GitterIntegratio joined #nim |
12:11:57 | * | jaens[m] joined #nim |
12:11:57 | * | leorize[m] joined #nim |
12:11:57 | * | lytedev[m] joined #nim |
12:11:57 | * | unclechu joined #nim |
12:11:57 | * | Avatarfighter[m] joined #nim |
12:11:57 | * | lnxw37d4 joined #nim |
12:11:58 | * | xigoi[m] joined #nim |
12:11:58 | * | MTRNord1 joined #nim |
12:11:58 | * | juanfra__ joined #nim |
12:11:58 | * | Avahe[m] joined #nim |
12:11:58 | * | BitPuffin joined #nim |
12:12:03 | * | JochenSchroeder[ joined #nim |
12:12:03 | * | Zoom[m] joined #nim |
12:12:04 | * | pixtum[m] joined #nim |
12:12:04 | * | j-james[m] joined #nim |
12:12:04 | * | ee7[m] joined #nim |
12:12:04 | * | Clonkk[m] joined #nim |
12:12:04 | * | VijayMarupudi[m] joined #nim |
12:12:04 | * | nikki93[m] joined #nim |
12:12:04 | * | Juno[m] joined #nim |
12:12:06 | * | dilawar_uchiha[m joined #nim |
12:12:08 | * | cmc[m] joined #nim |
12:20:02 | * | xet7 joined #nim |
12:20:23 | * | spiderstew_ quit (Ping timeout: 272 seconds) |
12:21:02 | * | spiderstew joined #nim |
12:28:03 | * | Arrrrrrrr joined #nim |
12:28:16 | * | adnan338 quit (Remote host closed the connection) |
12:30:36 | * | Guest25945 quit (Quit: Guest25945) |
12:31:12 | PMunch | Hmm, got an issue with running stuff on the ESP8266 |
12:31:32 | * | vsantana joined #nim |
12:31:36 | PMunch | It runs my loop just fine, but after the loop it seems like the garbage collector is taking too long, so the hardware reset triggers |
12:32:05 | PMunch | For that to happen it needs to run for over a second.. |
12:34:14 | * | Arrrrrrrr quit (Ping timeout: 264 seconds) |
12:34:25 | PMunch | http://ix.io/2L2M |
12:34:33 | PMunch | That's my setup ^ |
12:34:43 | * | Arrrrrrrr joined #nim |
12:34:44 | PMunch | Weirdly the reset doesn't seem to work either, it just never comes back |
12:35:06 | PMunch | Until I hard reset |
12:35:31 | PMunch | Oh wait, now the reset seems to work |
12:36:03 | PMunch | This is the output by the way: http://ix.io/2L2N |
12:36:36 | PMunch | As you can see it prints the "Solved in: 99" part, so it completes everything I have in my loop |
12:37:37 | narimiran | PMunch, planetis[m]: this seems to me like a fix: https://play.nim-lang.org#ix=2L2P |
12:38:21 | narimiran | wait, line 7 might not be correct; line 11 should be |
12:39:39 | narimiran | yeah, line 7 should be as it was before, we need to change only line 11 as shown |
12:40:08 | PMunch | What do you mean as before? |
12:40:17 | narimiran | `result = s.data.recv(s.buf[s.pos].addr, s.pos - s.buf.len + bufLen)` |
12:40:34 | PMunch | Nope |
12:40:37 | PMunch | That's not correct |
12:40:45 | PMunch | Oh wait |
12:40:51 | PMunch | I think that whole line might be wrong.. |
12:41:20 | PMunch | Basically that case is for when setPosition is put into the unread part of the buffer |
12:41:26 | narimiran | yes |
12:41:38 | PMunch | It should read all from the last read byte up to the byte requested |
12:41:46 | narimiran | oh! |
12:41:48 | PMunch | Image I sent "Hello" |
12:42:03 | PMunch | The receiver calls read(2) which puts He in the buffer |
12:42:21 | narimiran | then `s.buf[s.pos].addr` should be `s.buf[oldLen].addr` and the remaining logic also changes |
12:42:23 | PMunch | Then setPosition(4) which sets the position to where the o would go |
12:43:49 | PMunch | narimiran, correct |
12:44:23 | narimiran | PMunch: ok, let me work on that one. can you see if line 11 (when s.pos is somewhere earlier) seems correct to you? |
12:44:32 | PMunch | Basically all those recv(s.buf[s.pos]) should read to the old top of the buffer |
12:45:11 | narimiran | indeed |
12:46:07 | PMunch | Yeah that one seems correct |
12:46:39 | narimiran | `s.buf.setLen(max(s.pos + bufLen, s.buf.len))` -- this might need a change too, huh? |
12:47:13 | PMunch | No that's correct |
12:47:32 | narimiran | even if `s.pos` is set somewhere further down? |
12:47:43 | PMunch | Mhm |
12:47:44 | narimiran | (your example with setPosition(4)) |
12:48:08 | PMunch | setPosition(4) read(1) would set the buffer size to 5 |
12:48:11 | PMunch | Which is correct |
12:48:12 | narimiran | ok |
12:49:00 | PMunch | The buffer never shrinks (that's why we need the resetStream procedure) as the user can setPosition(0) at any point |
12:49:58 | PMunch | Hmm, this ESP8266 error is really weird |
12:50:26 | PMunch | I added a Serial.println("Done") manually in the generated .cpp file at the very end of my loop procedure. And that works fine |
12:50:49 | PMunch | And `loop` is called by the ESP8266 firmware.. |
12:51:37 | narimiran | PMunch: https://play.nim-lang.org#ix=2L2S - updated version |
12:53:57 | narimiran | eh, either my test example is shit, or my implementation is :) |
12:59:14 | narimiran | (found the problem) |
13:00:02 | PMunch | Yeah, that + s.pos - oldLen should be - (s.pos - oldLen) |
13:02:12 | narimiran | yeah |
13:03:16 | narimiran | but, there are corner cases (end of stream), where we need to do that a bit more differently. let me test it a bit more, before showing you |
13:03:29 | PMunch | There is? |
13:03:40 | narimiran | yep |
13:03:56 | narimiran | if you read zero, it should stay at zero |
13:04:18 | PMunch | Should it though? |
13:04:53 | PMunch | If position is smaller than end of buffer we still have data to give back |
13:05:26 | PMunch | I mean if it's larger it should obviously return 0 and not a negative number |
13:07:47 | narimiran | PMunch: here you go, together with the test i run: https://play.nim-lang.org#ix=2L32 |
13:08:21 | narimiran | both of the "unequal cases" have the same logic! |
13:08:23 | * | opal quit (Ping timeout: 240 seconds) |
13:09:17 | narimiran | and you cannot add `oldLen - s.pos` to the result unconditionally |
13:10:50 | PMunch | That won't work |
13:11:10 | PMunch | If position + bufLen is smaller than oldLen |
13:11:29 | PMunch | Basically if we have read(10) setPos(0) read(5) |
13:11:47 | PMunch | That would now call recv(10, 0) |
13:12:28 | PMunch | Which I guess might be a nop, but it would return 0 so nothing would be copied and result would be 0 |
13:21:25 | * | opal joined #nim |
13:27:17 | FromDiscord | <fwsgonzo> is it possible to add an import path to the nim invocation? |
13:27:28 | FromDiscord | <fwsgonzo> so that "import ffi" will find ffi.nim in a specific path |
13:28:10 | * | Tanger quit (Read error: Connection reset by peer) |
13:31:07 | * | Guest25945 joined #nim |
13:31:18 | FromDiscord | <fwsgonzo> I found it, it's -p=PATH |
13:37:42 | FromDiscord | <fwsgonzo> can I create comptime hash sets and trees? |
13:37:48 | * | filcuc joined #nim |
13:37:53 | FromDiscord | <fwsgonzo> for perfect hashing |
13:38:14 | FromDiscord | <fwsgonzo> I used frozen a lot with C++ (https://github.com/serge-sans-paille/frozen) |
13:48:59 | FromDiscord | <fwsgonzo> (edit) can I create compile-time hash sets and trees? |
13:53:20 | FromDiscord | <mratsim> @fwsgonzo yes you can |
13:53:53 | FromDiscord | <mratsim> Nim tables and set work at compile-time |
13:54:09 | FromDiscord | <mratsim> for example: https://github.com/mratsim/compute-graph-optim/blob/master/e07_part1_var_ADTs_tables.nim#L30-L34 |
13:54:54 | FromDiscord | <mratsim> and this state machine generator makes liberal use of compiletime hashsets and ashtables: https://github.com/mratsim/Synthesis/blob/master/synthesis/factory.nim#L35-L74 |
13:57:46 | FromDiscord | <fwsgonzo> do you use unreachable to teach the compile-time that it stops there? |
13:58:41 | FromDiscord | <mratsim> it's for the C compiler to also check that it's unreachable, and it reduces codesize as well because it won't insert a return/jump |
14:00:51 | ForumUpdaterBot | New thread by Pumpus: Acquire webcam on Windows 10, see https://forum.nim-lang.org/t/7339 |
14:04:57 | * | PMunch quit (Quit: leaving) |
14:07:39 | FromDiscord | <mratsim> @Recruit_main707 you are wanted: https://forum.nim-lang.org/t/7334#46535 |
14:11:24 | * | taprack joined #nim |
14:12:26 | FromDiscord | <fwsgonzo> is it possible to use the official hash sets at compile time? like toHashSet |
14:13:09 | FromDiscord | <fwsgonzo> I suppose that at least it's possible to create frozen containers in Nim? that's good enough for me, I'm just surveying the language |
14:13:21 | FromDiscord | <mratsim> I use the official hashsets in synthesis |
14:14:01 | mipri | !eval import sets; const t = {1: 2, 3: 4}.toHashSet; echo t |
14:14:04 | NimBot | {(3, 4), (1, 2)} |
14:14:05 | FromDiscord | <mratsim> not sure what frozen containers are. Most of Nim can work at compile-time as long as it doesn't use FFI or pointers |
14:14:31 | FromDiscord | <mratsim> I do BigInt and cryptography at compile-time |
14:14:35 | FromDiscord | <fwsgonzo> it's for perfect hashing and building other compile-structures using them |
14:14:52 | FromDiscord | <mratsim> I do compilers at compile-time 😛 |
14:15:03 | FromDiscord | <fwsgonzo> cool 😉 |
14:15:34 | FromDiscord | <mratsim> not joking, you can build a compiler for your own language in Nim macros. |
14:16:07 | FromDiscord | <fwsgonzo> I will try to make do with Nim |
14:16:22 | FromDiscord | <fwsgonzo> I'm using it for general computatin at the edge in $enterpriseproduct |
14:16:23 | FromDiscord | <mratsim> I don't think there is a language that even come close to Nim in terms of compile-time capabilities. |
14:16:32 | FromDiscord | <fwsgonzo> (edit) "I'm using it for general computatin at the edge in $enterpriseproduct ... " added "so cycles count" |
14:16:36 | FromDiscord | <mratsim> including D and C++ |
14:17:13 | FromDiscord | <fwsgonzo> perhaps, but I can do crazy things like handle C calling convention using template arguments in C++ |
14:17:40 | FromDiscord | <fwsgonzo> auto [i, f, counter, t] = vm.sysargs<int, float, uint64_t, struct test> (); |
14:17:43 | FromDiscord | <mratsim> calling convention is a runtime thing |
14:17:44 | FromDiscord | <fwsgonzo> (edit) "auto" => "`auto" | "();" => "();`" |
14:17:57 | FromDiscord | <mratsim> and Nim can use C++ tricks just fine |
14:18:13 | FromDiscord | <fwsgonzo> it's also runtime to frozen.contains(item) |
14:18:37 | FromDiscord | <fwsgonzo> but C++ has some extra oomph with parameter packs and lambda fols |
14:18:38 | FromDiscord | <fwsgonzo> (edit) "fols" => "folds" |
14:18:49 | FromDiscord | <mratsim> this is an example to wrap C++ initalizer lists: https://github.com/SciNim/flambeau/blob/master/flambeau/raw_bindings/tensors.nim#L318 |
14:20:06 | FromDiscord | <fwsgonzo> https://github.com/fwsGonzo/libriscv/blob/master/lib/libriscv/machine_vmcall.hpp#L4-L25↵↵^ there I am using a lambda fold to place all the correct types in the correct registers for a call |
14:21:06 | FromDiscord | <fwsgonzo> so ints go into integer registers, floats into FP regs and structs get pushed on the stack and then the resulting address in an integer register |
14:22:09 | * | waleee-cl joined #nim |
14:22:09 | filcuc | is there a way to display the nim code for a NimNode |
14:22:13 | FromDiscord | <mratsim> C++ is limited to work with assembly and registers |
14:22:15 | filcuc | just for debugging a macro output |
14:22:15 | FromDiscord | <mratsim> https://github.com/mratsim/constantine/blob/master/constantine/arithmetic/assembly/limbs_asm_montred_x86_adx_bmi2.nim#L142 |
14:22:28 | FromDiscord | <mratsim> You can have an assembler in Nim macro |
14:22:38 | FromDiscord | <mratsim> @filcuc: echo myNode.repr |
14:22:51 | FromDiscord | <mratsim> treerepr and toStrLit are also useful |
14:23:07 | FromDiscord | <fwsgonzo> yes I dont doubt that the compile time features are stronger |
14:23:38 | FromDiscord | <mratsim> when you need low-level stuff, you don't need tricks, you can make inline assembly very convenient. |
14:23:56 | FromDiscord | <fwsgonzo> I don't see much inline functions in regular nim code, are they lacking features? |
14:24:23 | FromDiscord | <mratsim> inline functions as {.inline.}? |
14:24:33 | FromDiscord | <fwsgonzo> no, lambdas, like for custom sorting of a container |
14:24:43 | FromDiscord | <mratsim> closures you mean |
14:25:00 | FromDiscord | <mratsim> you can use templates like mapIt to avoid the function call overhead |
14:25:26 | FromDiscord | <mratsim> but the closure syntax is a bit noisy that's true, but it does work, you'll see it in networking library |
14:25:39 | FromDiscord | <mratsim> you have "onConnect" "onDrop" things |
14:25:46 | FromDiscord | <fwsgonzo> right |
14:26:50 | FromDiscord | <mratsim> you can also pass them to C: https://github.com/mratsim/trace-of-radiance/blob/master/trace_of_radiance/io/mp4.nim#L116-L150 |
14:29:03 | filcuc | another one...is there a way fields associated to a type. Usually this can be done for procs. A workaround/idea is to declare globals and add procs associated to the type for returning those globals |
14:29:08 | filcuc | is this the way to go? |
14:30:54 | * | Guest25945 quit (Quit: Guest25945) |
14:31:03 | * | opal quit (Ping timeout: 240 seconds) |
14:31:11 | * | Guest25945 joined #nim |
14:31:53 | * | opal joined #nim |
14:31:58 | FromDiscord | <mratsim> @filcuc, I'm not sure what you mean by fields associated to a type |
14:32:11 | FromDiscord | <mratsim> like "foo: int" |
14:32:15 | FromDiscord | <fwsgonzo> right, you can pass closures as long as they are .cdecl. ? |
14:32:22 | FromDiscord | <mratsim> yes |
14:32:38 | FromDiscord | <fwsgonzo> ill have to remember that |
14:32:43 | FromDiscord | <mratsim> and push checks:off, and gcsafe to ensure no GC and Nim checks |
14:33:05 | FromDiscord | <mratsim> otherwise if you use Nim ints inside it might want to throw. |
14:35:56 | * | taprack quit (Ping timeout: 240 seconds) |
14:36:52 | FromDiscord | <mratsim> @fwsgonzo My assembler as macro is pretty simple and should be easily adaptable to Riscv5: https://github.com/mratsim/constantine/blob/master/constantine/primitives/macro_assembler_x86.nim#L431-L650 |
14:37:18 | filcuc | mratsim i mean: given a type T writing something like T.foo |
14:37:24 | filcuc | where foo could be a string |
14:38:42 | FromDiscord | <mratsim> @filcuc, does that inspire you? https://github.com/status-im/nim-cookbook/blob/master/dynamic_approximating_dynamic_types.nim#L35-L38 |
14:38:47 | FromDiscord | <fwsgonzo> you mean for binary translation? |
14:38:52 | filcuc | ...sorry for the stupid questions but i'm really rusty with Nim..it's been a while |
14:40:17 | filcuc | mratsim i don't see something like `type Machine = object` and somewhere `Machine.foo`...am i missing something? |
14:40:31 | FromDiscord | <mratsim> @fwsgonzo I mean it seems like you need to carefully maniuplate the stack and registers of a Riscv5 machine. |
14:40:43 | FromDiscord | <VVX7> sent a code paste, see https://paste.rs/z3e |
14:41:24 | FromDiscord | <VVX7> so I just want to confirm if I need to build bearssl for my target first and then cross-compile, or if nim should do this magically |
14:41:51 | FromDiscord | <mratsim> @filcuc, this is an example of using the `.` and `.=` operators to do Something.foo |
14:41:57 | FromDiscord | <mratsim> that something can be a T |
14:42:33 | FromDiscord | <mratsim> @VVX7 Bearssl should be built magically |
14:43:07 | filcuc | mratsim...mh i fill stupid...but isn't `a` and instance of an Action istead of the type itself? |
14:43:30 | filcuc | mratsim my idea was to use typedesc in practice |
14:43:33 | FromDiscord | <mratsim> sure but you can change the template `.`(a: type Action) |
14:43:41 | FromDiscord | <mratsim> instead of a: Action |
14:44:08 | filcuc | ah didn't knew the syntax (a: type Foo) |
14:44:11 | filcuc | :) |
14:44:12 | FromDiscord | <mratsim> @VVX7 can you check if it uses a submodule? you might be missing the submodule |
14:44:18 | FromDiscord | <VVX7> @mratsim thanks, now to figure out why it thinks the library isn't there |
14:44:59 | FromDiscord | <mratsim> @VVX7 https://github.com/status-im/nim-bearssl/tree/master/bearssl |
14:45:25 | FromDiscord | <mratsim> we use bearssl as a git submodule so git submodule update --init --recursive handles that for us |
14:45:52 | FromDiscord | <mratsim> I think nimble is supposed to do the submodules as well cc @dom96 |
14:45:54 | FromDiscord | <VVX7> innstalling from nimble I can see that it pulled the csources |
14:46:01 | FromDiscord | <mratsim> ah |
14:46:51 | FromDiscord | <VVX7> and I can compile the same nim file on linux to an ELF,, but it complains the file is not there when the target is windows |
14:47:37 | FromDiscord | <mratsim> we test on windows though: https://github.com/status-im/nim-json-rpc/blob/master/.appveyor.yml |
14:49:39 | * | abm joined #nim |
14:58:00 | FromDiscord | <inv> I am a bit confised: I am trying to make a PR, doing ./koch test, and I see that it tests my local Nim code, not from the folder I cloned to fix bug |
14:58:11 | FromDiscord | <inv> Could you please let me know how to avoid it ? |
14:58:31 | FromDiscord | <inv> (edit) "?" => "and test local-dir-nim only?" |
14:58:37 | FromDiscord | <inv> (edit) "confised:" => "confused:" |
14:59:24 | FromDiscord | <inv> (edit) removed "local" | "code," => "code from HOME," |
15:01:03 | * | opal quit (Ping timeout: 240 seconds) |
15:03:01 | FromDiscord | <mratsim> echo $PATH and check if you didn't override stuff? |
15:04:38 | FromDiscord | <inv> @mratsim pretty sure I did not, But I was not sure I have to overrite it |
15:04:47 | FromDiscord | <inv> (edit) "overrite" => "overwrite" |
15:04:59 | saem | Did you install Nim via choosenim |
15:05:03 | saem | ? |
15:05:03 | FromDiscord | <mratsim> you don't have to |
15:05:10 | * | opal joined #nim |
15:06:02 | saem | If so, you need to tell choosenim to use your local repo as the Nim install |
15:06:51 | saem | This and more is covered in the complier build instructions. |
15:08:34 | FromDiscord | <Recruit_main707> @mratsim thanks for the ping |
15:09:03 | saem | Which are briefly covered in the readme and then more detailed ones are linked from there. I bumped into some walls myself at first and made a PR to docs to make it a little easier. So keep at it, inv. |
15:17:52 | * | PMunch joined #nim |
15:19:18 | PMunch | Hmm, my ESP8266 runs out of memory when I run some Nim code on it |
15:19:44 | PMunch | Or rather the Nim code runs fine, but it takes up all the memory and the ESP code crashes when it tries to get some more |
15:19:59 | PMunch | (I'm using ARC by the way) |
15:20:31 | PMunch | The strange thing is that looking at the C code it appears to do the right thing and call free at the end of the procedure |
15:21:34 | narimiran | was that pun intended? |
15:21:49 | PMunch | Huh? |
15:21:52 | PMunch | Which one? :P |
15:21:56 | narimiran | i use ARC, btw |
15:22:05 | PMunch | Haha, no that wasn't intentional |
15:22:29 | narimiran | we should use that one officially! :D |
15:24:49 | FromDiscord | <inv> saem, I just jumped to Running Tests on the page: https://nim-lang.github.io/Nim/contributing.html |
15:25:35 | FromDiscord | <inv> and nothing about choosenim there |
15:26:11 | FromDiscord | <Enimatek> is there a way to do something like `var list: seq[typed] ` and have an array-kind that is .add()-ble ? except for varargs that is predefined i can't seem to find a solution for this |
15:26:34 | FromDiscord | <Rika> wdym? seq typed? |
15:26:35 | PMunch | Hmm changing from "for line in grid: serialPrintLn($line)" to "for i in 0..grid.high: serialPrintLn($grid[i])" everything works fine |
15:26:50 | FromDiscord | <Rika> you cannot have a heterogeneous seq |
15:26:55 | FromDiscord | <Enimatek> a seq that can be filled with all kinds of stuff |
15:27:05 | FromDiscord | <Rika> no, impossible |
15:27:07 | disruptek | i've had hetero seqs many times. |
15:27:17 | PMunch | <_< |
15:27:19 | FromDiscord | <Rika> unless you do what in rst land is called boxing i think |
15:27:27 | mipri | use OO or variant types. |
15:27:29 | FromDiscord | <jken> sent a code paste, see https://play.nim-lang.org/#ix=2L3Q |
15:27:47 | FromDiscord | <Rika> jken its not even a good solution imo |
15:28:02 | FromDiscord | <mratsim> @Rika Rust Box = putting on the heap. Nim ref T == Rc[Box[T]] in Rust |
15:28:04 | FromDiscord | <Enimatek> problem is, the exec of sql has a varargs[typed] input |
15:28:06 | FromDiscord | <jken> I am learning 🤷♂️ |
15:28:18 | PMunch | Shouldn't you theoretically be able to store an "ref object of RootObj" in a seq as pointers and get them out and read their types? |
15:28:21 | FromDiscord | <Rika> now everything is scattered everywhere in memory |
15:28:22 | PMunch | Those store types right? |
15:28:25 | FromDiscord | <Rika> i see, thanks |
15:28:46 | FromDiscord | <mratsim> @Enimatek it's a compile-time sequence, in the compiler everything is an AST node so it technically has the same type. |
15:28:50 | PMunch | Enimatek, that is because it's a macro |
15:29:01 | FromDiscord | <jken> @Rika I was working on an ECS, and was only concerned about fragmentation in the seqs themselves, not fragmentation of list locations in memory |
15:29:06 | FromDiscord | <jken> but you are right |
15:29:27 | FromDiscord | <Rika> yeah it can be a problem in the common applications for a seq |
15:30:07 | saem | @inv those docs could probably use a minor improvement reminding first timers to go read the complier development set up docs. |
15:30:17 | FromDiscord | <Rika> solution here would be to make whatever youre using a macro as well, or if that doesnt fit what you need then maybe manual work will 😉 |
15:30:58 | * | Guest25945 quit (Quit: Guest25945) |
15:31:27 | Oddmonger | what is the best way to extract a line in a buffer ? regex ? |
15:31:32 | * | Guest25945 joined #nim |
15:31:41 | FromDiscord | <Enimatek> hm, ok, thnx, im not familliar with marcros so i will see how that works for me, else i can use .exec 'unsafe' but i'd rather not |
15:31:41 | saem | Beyond that the complier isn't a simple project, so I would perhaps adjust your expectations slightly in that you're like not going to be able to jump to a subsection and have sufficient context to succeed without prior knowledge which it far too large to cover/reference each time. |
15:32:30 | FromDiscord | <inv> Fk Yeah, I am Nim contributor 🙂 https://github.com/nim-lang/Nim/pull/16612 |
15:32:31 | disbot | ➥ jsonutils: fromJson forward opt param fix |
15:32:52 | FromDiscord | <mratsim> not merged yet |
15:32:53 | FromDiscord | <mratsim> :p |
15:33:12 | FromDiscord | <inv> @mratsim you know how to destroy the day 🙂 |
15:33:20 | saem | LoL |
15:33:39 | FromDiscord | <inv> I am going to try to backport it into 1.4 |
15:33:43 | saem | I've made one or two myself, you're well on your way |
15:35:33 | FromDiscord | <inv> I have a question, If it will in in dev branch - will it appear in 1.4.x later? |
15:35:33 | saem | Anyhow, I had to choosenim path/to/my/git/local/repo so my pathing behaved. It sounded like you might be having the same issue. |
15:35:37 | * | filcuc quit (Ping timeout: 264 seconds) |
15:35:50 | FromDiscord | <fwsgonzo> there is nothing special about db_sqlite, right? so I can use ":memory:" for an in-memory database? |
15:36:02 | FromDiscord | <Rika> will whoever managed nim-lang/packages reject my pr to add my package if it has no tests? |
15:36:09 | FromDiscord | <Rika> manages not ed |
15:36:10 | disruptek | no. |
15:36:17 | disruptek | gonzo: yes. |
15:36:47 | FromDiscord | <fwsgonzo> nvm, db_sqlite seems to include dlfcn.h which is a bad sign 😉 |
15:37:07 | FromDiscord | <Rika> what is wrong with whatever dlfcn.h is? |
15:37:45 | FromDiscord | <fwsgonzo> its for linuxs dynamic loader/linker, and this is in a VM, there's no dlopen here |
15:37:56 | FromDiscord | <fwsgonzo> but I can embed sqlite myself |
15:40:23 | FromDiscord | <mratsim> @fwsgonzo: you can use this code for sqlite3 as a in-memory KVstore: https://github.com/status-im/nim-eth/blob/master/eth/db/kvstore_sqlite3.nim#L344 |
15:40:56 | FromDiscord | <mratsim> it's a wrapper around this sqlite3 package into a single C file: https://github.com/arnetheduck/nim-sqlite3-abi |
15:41:38 | FromDiscord | <fwsgonzo> oh nice |
15:42:49 | ^Q-Master^ | I've updated my https://github.com/Q-Master/packets.nim. Comments are welcome. |
15:46:08 | FromDiscord | <andeee> Could someone help me with fixing this error? I've also tried to do strVal(n) but there is an error for that as well. I'm working on some code written by someone else from 2 years ago. Thanks https://media.discordapp.net/attachments/371759389889003532/796404238707589160/unknown.png |
15:46:24 | Oddmonger | i'me trying to do some string extraction, but i'm not accustomed to nim regex, and i don't understand the problem here: https://play.nim-lang.org/#ix=2L3Y |
15:46:53 | FromDiscord | <Rika> andeee maybe `$n`? |
15:47:21 | FromDiscord | <Rika> i do not remember how macros worked back in 0.18 (even though i used nim briefly then) |
15:47:39 | FromDiscord | <andeee> i get `type mismatch: got <string> but expected 'NimNode = ref NimNodeObj'` for bot $n and n.strVal() |
15:47:40 | disruptek | repr n |
15:47:47 | Oddmonger | forget the previous and use this one, without the typo: https://play.nim-lang.org/#ix=2L3Z |
15:49:06 | FromDiscord | <andeee> ok nevermind, i made it a template instead of a macro |
15:49:26 | FromDiscord | <andeee> maybe the old macros became templates in the meantime? |
15:49:46 | disruptek | oddmonger: use nre |
15:50:23 | FromDiscord | <Rika> andeee doubt that, maybe this use case for a macro no longer applies |
15:50:59 | Oddmonger | disruptek: nre"…" , in the regex string definition ? I get the same strange error ( missing closing bracket) |
15:51:07 | mipri | Oddmonger: https://play.nim-lang.org/#ix=2L42 |
15:51:38 | Oddmonger | ah ok, i see |
15:51:42 | disruptek | no, the nre stdlib package. ideally, use nitely's pure-nim regex. |
15:51:54 | FromDiscord | <Rika> mipri why would the backslashes in the re"" be interpreted raw though i do wonder |
15:52:17 | FromDiscord | <Rika> i know re"" is raw |
15:52:21 | Oddmonger | thank you mipri, and i have now a look on nre package |
15:52:23 | disruptek | i don't think they are anchored by default but i could be wrong. |
15:53:09 | Oddmonger | anyway, returned seq is still empty ^^' |
15:53:20 | mipri | https://nim-lang.org/docs/manual.html#lexical-analysis-generalized-raw-string-literals - and before that, raw string literals. \" isn't a special escape. It's just \ and then the end of the string literal. |
15:53:38 | disruptek | oddmonger: nre example of match here: |
15:53:41 | disruptek | !repo bump |
15:53:42 | disbot | https://github.com/disruptek/bump -- 9bump: 11a tiny tool to bump nimble versions 🍻 15 19⭐ 2🍴 7& 1 more... |
15:53:47 | FromDiscord | <Rika> i know they are raw |
15:53:53 | disruptek | search for `crazy spaces`. |
15:54:02 | FromDiscord | <Rika> i just wonder why backslashes before quotes wouldnt be a special case |
15:54:30 | mipri | Oddmonger: https://play.nim-lang.org/#ix=2L44 |
15:55:34 | mipri | manual: it's like this. you: but shouldn't something else be the case? \ isn't interpreted at all, so \" can't be, and or else you'd then need some way to express a literal \" in your string, needing \\, which means you have to interpret \ again. |
15:56:19 | disruptek | you're blowin' my mind right now. |
15:57:17 | mipri | there is another way to do it: `discard match(buffer, re".*name:""([^""]+).*", extract)`, doubling the internal " |
15:57:41 | Oddmonger | in short, \ is a regular char in re, and not in nre ? (looking at «crazy spaces» from disruptek ) |
15:58:00 | mipri | what I'd really prefer is some way to have an arbitrary delimeter for strings, like Perl/Ruby q{}, or Rust's r####""####, or D's q"blah |
15:58:23 | Oddmonger | [[ ]] in Lua |
15:59:38 | Oddmonger | thank you btw for the answer ,it was not so easy |
15:59:52 | * | taprack joined #nim |
16:00:35 | * | lritter joined #nim |
16:01:00 | mipri | it's certainly unfortunate that syntax highlighting doesn't follow how raw strings actually work. |
16:01:35 | Oddmonger | and now, why seq[string] returns empty , and array[1,string] is ok, that's another mysterii |
16:03:08 | mipri | https://play.nim-lang.org/#ix=2L4b |
16:03:18 | disruptek | syntax highlighting does follow raw strings. |
16:04:58 | mipri | disruptek: https://play.nim-lang.org/#ix=2L4c <- that's highlighted as one contiguous string literal. The string ends at the first " and another one starts at the second ", and the 'internal' [ in the gap causes a syntax error as it's unmatched. |
16:05:43 | FromDiscord | <andeee> noob stupid question, how do i convert from an int to a csize_t, I've tried to do .toU16 cause from what i know the csize is an unsigned int but still get complaints |
16:05:46 | disruptek | i don't consider the playground, period. |
16:05:59 | disruptek | x.csize_t |
16:05:59 | mipri | it's the same in vim. |
16:06:06 | disruptek | nope. |
16:06:48 | FromDiscord | <andeee> dirsuptek, that was easy 🤦♂️, thanks |
16:07:05 | disruptek | mipri: see the nimTripleQuote syntax identifier. |
16:07:06 | Oddmonger | ah seq must be initialized… but shouldn't the match function raise an exception with an empty seq ? |
16:07:20 | disruptek | oddmonger: yes; it's annoying. i complained about it. |
16:07:27 | FromDiscord | <Rika> im not a fan of the custom string delimiter idea |
16:07:31 | mipri | no, the seq is initialized. it's just zero-length, so the group isn't saved. |
16:07:40 | FromDiscord | <Rika> can become confusing since i sometimes code with no highlighting |
16:10:44 | mipri | Oddmonger: this is a mistake you make once, and then you learn how re works, and then you don't need it again. Doesn't seem like a good candidate for a permanent runtime cost. |
16:11:58 | mipri | nim-regex lets you have a RegexMatches object that accepts as many groups as are in the regex, so no need to care about the size in two places. It also stores indices there instead of always copying into the matches array. |
16:23:36 | * | taprack quit (Ping timeout: 256 seconds) |
16:26:25 | * | letto quit (Ping timeout: 240 seconds) |
16:26:29 | * | letto_ joined #nim |
16:27:32 | * | habamax joined #nim |
16:28:48 | * | taprack joined #nim |
16:31:19 | * | Guest25945 quit (Quit: Guest25945) |
16:31:34 | * | Guest25945 joined #nim |
16:35:56 | * | taprack quit (Ping timeout: 240 seconds) |
16:38:16 | * | filcuc joined #nim |
16:42:31 | * | taprack joined #nim |
16:44:38 | * | filcuc quit (Ping timeout: 256 seconds) |
16:46:12 | disruptek | HEARTS AND MINDS |
16:46:25 | disruptek | i'm looking at you, rika. |
16:47:49 | Zevv | ooh living on the edge. code with no highlighting |
16:49:45 | FromDiscord | <Randall> How can I test a function with `{.compileTime.}` that throws an exception (which is expected behaviour). Should I eliminate the exception from the function, and return a different result? |
16:50:01 | disruptek | use my testes; go on, use them. |
16:50:04 | disruptek | !repo testes |
16:50:05 | disbot | https://github.com/disruptek/testes -- 9testes: 11a small unittest framework with decent support 🔴🟡🟢 15 24⭐ 1🍴 7& 29 more... |
16:50:17 | disruptek | see the `expect:` template. |
16:50:22 | disruptek | Zevv: today is a cps day. |
16:51:12 | FromDiscord | <mratsim> 😄 |
16:51:50 | FromDiscord | <mratsim> @Randall you like to live dangerously |
16:52:04 | FromDiscord | <mratsim> maybe to try except |
16:52:07 | FromDiscord | <mratsim> do |
16:52:21 | FromDiscord | <Randall> Yeah, trying to do some parsing at compile time, but things like `doAssertRaises` cannot handle this use case |
16:52:42 | FromDiscord | <Rika> disruptek sorry for having a lower iq recently |
16:52:49 | disruptek | file a bug report if my testes don't fit. |
16:52:55 | FromDiscord | <mratsim> the thing is, {.compileTime.} function don't work in a static block and I think try/except won't catch at compile-time unless in a static block |
16:53:02 | disruptek | your needs, i mean. |
16:53:44 | FromDiscord | <Randall> I'll see if disruptek's testes work as expected. |
16:54:44 | FromDiscord | <Randall> @mratsim it's not happening in a static block, but in a macro. So the macro parses some ast stuff which yields some strings I'd like to parse |
16:54:48 | * | fputs joined #nim |
16:55:16 | FromDiscord | <mratsim> I think try except work in macro but in macros I try to use bool. |
16:55:45 | FromDiscord | <Randall> Considering this function is supposed to return a seq, it might just return an empty seq and check on that |
16:55:48 | FromDiscord | <mratsim> just do all your processing in a proc, the macro should only convert an input to nimnode |
16:57:36 | FromDiscord | <Randall> sent a code paste, see https://play.nim-lang.org/#ix=2L4A |
16:58:59 | FromDiscord | <Randall> (edit) "https://play.nim-lang.org/#ix=2L4A" => "https://play.nim-lang.org/#ix=2L4B" |
16:59:36 | * | hnOsmium0001 joined #nim |
16:59:52 | FromDiscord | <mratsim> use parseutils, it returns a bool |
17:00:08 | FromDiscord | <mratsim> regex at compile-time is asking for troubles |
17:00:25 | FromDiscord | <Randall> I'm not using regex |
17:02:25 | FromDiscord | <Randall> What I meant by regex, is that the `router` macro should compile to a `proc match(path: string): Route` that is effectively a parser based on the route definitions. |
17:02:51 | FromDiscord | <Randall> (edit) "What I meant by ... regex," added "unrolled" |
17:04:42 | Zevv | disruptek: never skip cps day |
17:04:48 | FromGitter | <HJarausch_gitlab> How to disable *genSym* in a macro? ⏎ If have ``` ⏎ result = quote do: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5ff5edb0d5f4bf2965cd5c46] |
17:04:54 | disruptek | but i must. |
17:05:02 | FromDiscord | <Enimatek> hm macros and sequences with untyped stuff is not needed, db_sqlite also has a way to prepare the insert statement and slowly add all data with bindParam.. pfew.. was reading about macro's but its maybe a step too far for a nimmer of 2 weeks 😛 |
17:05:24 | disruptek | today's problem is that break-in-while isn't managing to emit the actual splat proc. |
17:06:11 | Zevv | I'll try to peek in today, but I'm totally done for for now. Work & home schooling is a utter PITA |
17:06:19 | disruptek | i feel you. |
17:06:27 | disruptek | i'm sure this is something simple. |
17:06:31 | Zevv | Now I will just eat my dinner, drink beer and stare at the wall |
17:07:00 | * | haxscramper joined #nim |
17:07:07 | FromDiscord | <Randall> Is it expected that `nimble install` doesn't update the `requires` in the nimble file? |
17:07:08 | disruptek | i'm trying to milk the elation from last night's election. |
17:07:12 | disruptek | yes. |
17:07:31 | mipri | yeah, nimble install is completely indepedent of the .nimble in the current directory you're in |
17:07:49 | FromDiscord | <lqdev> sent a code paste, see https://play.nim-lang.org/#ix=2L4F |
17:08:10 | mipri | it also wouldn't make sense for it to update that file. The code's actual version requirements don't change |
17:08:23 | FromGitter | <haxscramper> @HJarausch_gitlab either annotate `as EXC` with `{.inject.}` if syntax allows this, or generate identifier for `EXC` outside of `quote` do via `ident "EXC"` |
17:08:45 | FromDiscord | <jken> I also assumed nimble worked like npm when I started with nim |
17:09:06 | FromDiscord | <Randall> I'd prefer nothing work like npm, but yeah i expected similar results |
17:09:19 | disruptek | suckers. |
17:10:00 | FromDiscord | <jken> disruptek, is nimph technically closer to npm? With local deps and lock files? |
17:10:04 | FromDiscord | <Randall> Where's my 100k lines lockfile of json? |
17:11:26 | FromDiscord | <Rika> and the black hole called node_modules? |
17:11:57 | disruptek | jken: i hope not. |
17:12:35 | FromDiscord | <jken> I suppose I should just try it out |
17:12:36 | disruptek | local deps and lockfiles don't define npm; the ridiculous tree is its defining characteristic. |
17:12:53 | FromGitter | <HJarausch_gitlab> Thanks to you both, @lqdev and @haxscramper ! |
17:13:00 | disruptek | jken: are you on linux? |
17:13:16 | FromDiscord | <jken> I guess my question should have been "will nimph be more in-line with what I already expect from a package manager coming from a JS background" |
17:13:22 | FromDiscord | <jken> disruptek, yeah |
17:13:29 | disruptek | you should try it. |
17:14:04 | haxscramper | I want to take an arbutrary piece of nim code and annotate each ast element with information about symbol definitions, similarly to https://code.woboq.org/qt5/qtcanvas3d/src/imports/qtcanvas3d/activeinfo3d_p.h.html#68 - I thought of using nimsuggest (either as a library or by copying high-level implementation details) to do this - I can parse, then use line/column position of each parsed node to get all necessary information. Note that |
17:14:04 | haxscramper | I need to annotate all entries in **original** source file, so just adding own pass after `sempass` is not an option |
17:14:17 | disruptek | nimph is more about reseting expectations of what package management is and is not. |
17:14:32 | haxscramper | Is going with nimsuggest a good idea in this case, or I'd better dig another part of compiler? |
17:14:52 | disruptek | you don't need to use it except to measure your environment or try to fix it to match your declarative compiler configuration. |
17:15:43 | FromDiscord | <mratsim> @haxscramper, push a custom pragma |
17:15:53 | haxscramper | I need to write a tool that does that |
17:16:01 | disruptek | i dunno why you'd bother with nimsuggest. |
17:16:05 | FromDiscord | <mratsim> {.push mycustompragma.} |
17:16:14 | FromDiscord | <mratsim> done |
17:16:14 | haxscramper | That is for documentation generator, it must be a standalone tool that requires no code modifications |
17:16:53 | haxscramper | I want to extract standalone usage examples for all unit tests |
17:16:59 | FromDiscord | <mratsim> then gorge the whole Nim file, push a custom pragma, generate a new temp file |
17:17:02 | haxscramper | And put this in documentation alongside each proc |
17:17:09 | disruptek | scramper: the compiler has compiler-as-api tests that demonstrate really trivial use. |
17:17:35 | FromDiscord | <mratsim> and complain about dev tooling doc tooling on the tracker, and ping @himu |
17:17:57 | FromDiscord | <mratsim> I'm tired of spending hours fighting doc generation :/ |
17:18:54 | haxscramper | mratsim: me too |
17:19:48 | haxscramper | disruptek: there is `compilerapi` test, but this one is for nimscript. Can you tell me specific test you have in mind, or you just generally remember we had something like this |
17:20:08 | haxscramper | But not specific file/name/whatever |
17:20:25 | disruptek | it's a general memory, but if you want a simpler use, you could start with dust. |
17:20:33 | disruptek | !repo dust |
17:20:34 | disbot | https://github.com/disruptek/dust -- 9dust: 11DUST is Unattended Syntax Truncation 15 6⭐ 1🍴 7& 1 more... |
17:20:35 | haxscramper | yes, that's what I started with |
17:21:00 | haxscramper | And I already have custom sempass working, but as I said earlier that's only part of what I need |
17:21:16 | disruptek | my first thought was two passes; one pre-sem and one post-sem. |
17:21:22 | disruptek | but i'm not sure you really need two. |
17:22:07 | disruptek | i had an introspection hack once in which i was doing two passes. 🤷 |
17:22:16 | haxscramper | Well, to be fair, ultimately I wanted to somehow inject directly /in/ sempass to log all template/macro instantiations |
17:22:26 | haxscramper | s/log/store information about/ |
17:22:46 | haxscramper | But that is not something that has good effort/gain ratio, so I've put it aside for now |
17:23:09 | haxscramper | before-sempass is basically just plain unexpanded/uncompiled ast |
17:23:25 | haxscramper | right? |
17:23:28 | disruptek | yes. |
17:23:58 | disruptek | the idea is that you plant seeds and see how they've grown post-sem. |
17:24:34 | haxscramper | seeds? |
17:25:30 | haxscramper | Well, I get general idea, but not sure if I know what exactly do I need to do this |
17:25:43 | FromDiscord | <Randall> @disruptek testes doesn't seem to like my comptime code. Tests fail with "compile failed" using the `expect` macro. |
17:25:43 | disruptek | i was just injecting comments and then unpacking them later; they are fairly safe from rewrites. |
17:26:05 | disruptek | randall: can you gimme a repro in an issue? |
17:26:18 | FromDiscord | <Randall> I'll check if I can make a repo real quick |
17:26:22 | disruptek | aight, thanks. |
17:26:42 | haxscramper | disruptek: alright, I will keep this option in mind, though this is hacky has hell |
17:26:52 | disruptek | yes. |
17:27:25 | disruptek | it was back when i was trying to fix async. |
17:29:14 | FromDiscord | <Meowz> Is there some easy way to statically link `pcre64.dll` if a tool uses `re` for example? |
17:29:35 | disruptek | no. |
17:30:14 | FromDiscord | <Meowz> Aw |
17:30:31 | * | Vladar quit (Remote host closed the connection) |
17:30:50 | FromDiscord | <Randall> sent a code paste, see https://play.nim-lang.org/#ix=2L4S |
17:31:38 | disruptek | what does it do in a block? same thing? |
17:31:38 | FromDiscord | <CodeHz> You cannot statically link dll( |
17:32:02 | FromDiscord | <Randall> Wrapping the expect in a block still fails |
17:32:11 | disruptek | okay, i will create an issue. thanks. |
17:32:36 | FromDiscord | <Randall> tho I do run it with testament |
17:32:45 | disruptek | doesn't matter. |
17:33:27 | FromDiscord | <Randall> If you send me link I'll add the failure message |
17:33:40 | disruptek | !issues expect testes compile time |
17:33:40 | disbot | no results 😢 |
17:33:51 | disruptek | https://github.com/disruptek/testes/issues/28 |
17:33:51 | disbot | ➥ make expect work for compile-time if possible |
17:35:59 | * | Vladar joined #nim |
17:39:18 | ForumUpdaterBot | New thread by VVX7: Error cross-compiling json-nim-rpc, see https://forum.nim-lang.org/t/7340 |
17:40:03 | FromDiscord | <Randall> The manual mentions `out T` but doesn't specify it's usage anywhere: https://nim-lang.org/docs/manual.html#overloading-resolution-overloading-based-on-var-t-slash-out-t↵Is this the same as just `var T`, or is there some distinction? |
17:40:17 | disruptek | pretend `out` doesn't exist. |
17:40:25 | FromDiscord | <Randall> What `out`? |
17:40:54 | disruptek | it's not really implemented. |
17:41:30 | FromDiscord | <Randall> Will it be? What was the intended purpose that distinguishes it from var? |
17:42:28 | disruptek | good question. the difference is in initialization logic, like result. |
17:43:06 | disruptek | the problem with out vars is that they entice people into implementing yet another API in addition to returning a result or mutating the input. |
17:43:13 | disruptek | this is annoying. |
17:44:31 | FromDiscord | <Randall> That was kind of my next question. Since I cannot test my comptime function, I figured I might change the result to something like `func parsePath(path: string, success: bool): seq[RoutePart] {.compileTime.}` (or just remove the `compileTime` and live with it. |
17:44:48 | FromDiscord | <Randall> Or just return empty `seq` in case of failure and have the caller handle it |
17:44:52 | FromDiscord | <haxscramper> For now you can us it to crash compiler |
17:45:11 | FromDiscord | <haxscramper> The only use I could find for it |
17:45:27 | FromDiscord | <Randall> I prefer `macros.error` for that, but give a completely random node as second argument so the cause can never be found |
17:45:46 | disruptek | the usual idiom is `func foo(x: var): bool` |
17:46:05 | disruptek | as in hasKeyOrPut, containsOrIncl, etc. |
17:46:05 | haxscramper | !eval func foo(x: var): bool |
17:46:06 | NimBot | Compile failed: /usercode/in.nim(1, 6) Error: implementation of 'in.foo(x: var) [declared in /usercode/in.nim(1, 6)]' expected |
17:46:14 | disruptek | shhh. |
17:46:24 | haxscramper | !eval func foo(x: var): bool = discard |
17:46:26 | NimBot | <no output> |
17:46:30 | FromDiscord | <Randall> So basically swap the bool and seq's positions |
17:47:19 | disruptek | it could save you a seq alloc, maybe, so... yes. |
17:48:13 | FromDiscord | <Randall> Thanks. I've never programmed in a non-memory-managed language so that'll all take a while for me to learn |
17:59:48 | * | Jesin joined #nim |
18:15:03 | FromDiscord | <Clyybber> Araq: ping |
18:15:33 | reversem3 | I created a header string for my file like this . var box1_header = "Date: \t\t\tHostname: \t\tCPU" |
18:17:10 | reversem3 | since this is going to be run all the time , I need a conditional to look for this string in the file before appending to it. can I use if box1_header notin statFile: ? |
18:17:39 | reversem3 | How can I check for that header in the file before appending to it? |
18:21:42 | * | krux02 quit (Remote host closed the connection) |
18:23:37 | * | hmmm joined #nim |
18:31:04 | saem | When taking about nimsuggest do you really mean suggest, because the former is really just the interface |
18:31:24 | * | Guest25945 quit (Quit: Guest25945) |
18:34:17 | haxscramper | saem: I meant `nimsuggest.nim`, at least at the time of writing my original question |
18:34:33 | haxscramper | But now I narrowed it down to `sysFromInfo`/`findNode` |
18:35:12 | haxscramper | Though I'm still in process of figuring things out |
18:37:38 | saem | `markUsed` seems like it's called in all the places you care about? |
18:39:39 | saem | The debugger helped a bit at times double edged sword |
18:40:17 | disruptek | i use s-words, f-words, and even some c-words from time to time. |
18:47:53 | FromDiscord | <Balen> Does the options module have a template that unwraps an option, getting its value but returns none from the calling scope if the option is none? If not, which I think is the case, would it be useful? |
18:49:00 | haxscramper | You mean something like `mapIt` for `options`? |
18:49:15 | haxscramper | No, it is not implemented |
18:50:02 | FromDiscord | <Rika> ??? https://nim-lang.org/docs/options.html#map%2COption%5BT%5D%2Cproc%28T%29_2 |
18:50:28 | FromDiscord | <Rika> is this what you mean |
18:50:43 | mipri | the key text there is "but returns none from the calling scope if the option is none" |
18:51:07 | FromDiscord | <Rika> does this not return none? |
18:51:10 | FromDiscord | <Balen> sent a code paste, see https://play.nim-lang.org/#ix=2L5h |
18:51:15 | FromGitter | <awr1> @Balen there isn't to my knowledge but it would be very easy to implement. See `{.inject.}` |
18:51:18 | mipri | the key text of the key text is "from the calling scope" |
18:51:18 | FromDiscord | <Balen> if x is none, it'll return none from foo instead of throwing |
18:51:22 | mipri | it's control flow. |
18:51:33 | FromGitter | <awr1> e.g. as `tables.withValue` uses it |
18:51:33 | FromGitter | <awr1> https://github.com/nim-lang/Nim/blob/version-1-4/lib/pure/collections/tables.nim#L606 |
18:52:26 | FromDiscord | <Balen> Yeah I know it's easy to implement but I thought it'd be common to be in the module. |
18:52:31 | FromDiscord | <Rika> i dont think it woul |
18:52:33 | FromDiscord | <Rika> d |
18:54:43 | reversem3 | do I have to convert a var holding a string using if logic to check if a string is present in a file? |
18:55:04 | reversem3 | any examples someone can point me to? |
18:56:31 | FromGitter | <awr1> what are you suggesting |
18:56:36 | FromDiscord | <Balen> do you mean if you have to read a file's content into a string to check if a substring is present in file? |
18:56:42 | * | haxscram` joined #nim |
18:56:58 | FromGitter | <awr1> like do you want to find if a string is present in a file without gathering up the file's contents into a string? |
18:57:49 | reversem3 | meaning read a string from a file , use if logic to see if it exists |
18:57:49 | FromGitter | <awr1> It's easier to do it if you gather it up into a string but I can understand if you want to forego the extra allocation if you have no need for the total-file string |
18:58:16 | * | haxscramper quit (Ping timeout: 246 seconds) |
18:58:34 | disruptek | withValue sucks. |
18:58:36 | reversem3 | I have a header in a file that i want to check if it exists so I don't keep writing another header |
18:59:26 | ForumUpdaterBot | New thread by JohnAD: Usefulness of a BPMN compiler package for Nim?, see https://forum.nim-lang.org/t/7341 |
18:59:33 | reversem3 | Do I have to read the actual number of chars https://nim-lang.org/docs/io.html |
19:00:08 | FromGitter | <awr1> `withValue`'s needing of a pointer is meh |
19:00:26 | FromGitter | <awr1> if you are fine with copying the whole file into a string |
19:00:37 | FromGitter | <awr1> `import strutils; let idx = path.open.readAll.find(target)` |
19:01:58 | FromGitter | <awr1> If you don't want to copy the entire file into a string you have to roll up your own solution using `std / streams` |
19:02:00 | reversem3 | now the target has to be a string right ? I am using a var that holds the header string and then I write that string using the var into a file |
19:02:24 | FromGitter | <awr1> Yes, target is the string you're searching for. |
19:02:42 | FromGitter | <awr1> idx is -1 if it can't find anything iirc |
19:02:48 | FromDiscord | <andeee> sent a code paste, see https://play.nim-lang.org/#ix=2L5o |
19:03:08 | FromGitter | <awr1> i wish enum macro-nodes supported doc comments |
19:03:14 | reversem3 | ok , and thats really the only way right ? I can't just use ngrep to find it ? |
19:04:09 | FromGitter | <awr1> That is the laziest way. You can use regex if you want |
19:04:48 | FromGitter | <awr1> Or roll your own solution using `streams` if you don't want to make a string out of the whole file |
19:05:10 | reversem3 | "Date: \t\t\tHostname: \t\tCPU:" thats the string |
19:05:22 | FromDiscord | <Balen> so it doesn't span more than one line |
19:05:42 | FromDiscord | <Balen> using streams should be trivial, you should do that |
19:06:01 | FromDiscord | <andeee> sent a code paste, see https://play.nim-lang.org/#ix=2L5p |
19:06:47 | FromDiscord | <mratsim> the symbol must be visible at the template invocation site |
19:07:16 | FromDiscord | <mratsim> not where the template is defined (for untyped template) |
19:07:46 | FromDiscord | <mratsim> so make sure the module that calls asd, imports the module that defines someType |
19:08:00 | FromDiscord | <andeee> ahh ok makes sense yeah |
19:08:01 | FromDiscord | <mratsim> or reexport it from the module that defines template |
19:09:14 | FromDiscord | <andeee> how do i reexport? |
19:09:26 | FromDiscord | <mratsim> import foo↵export foo |
19:09:39 | FromDiscord | <andeee> amazing, thanks |
19:11:27 | ForumUpdaterBot | New thread by Svtz: Failed trying to wrap macro in another macro, see https://forum.nim-lang.org/t/7342 |
19:13:04 | FromDiscord | <lqdev> or, add `bind someType` to your template |
19:13:15 | FromDiscord | <lqdev> it's the exact problem `bind` is supposed to solve |
19:15:49 | reversem3 | awr1 - this is what I'm trying to do https://play.nim-lang.org/#ix=2L5t |
19:16:00 | reversem3 | If you wouldn't mind taking a look |
19:17:11 | reversem3 | I haven't put the if logic into it yet |
19:21:08 | * | JustASlacker joined #nim |
19:21:22 | * | tane joined #nim |
19:23:16 | reversem3 | What if I just did this: |
19:23:17 | * | reversem3 sent a long message: < https://matrix.org/_matrix/media/r0/download/matrix.org/gWsdRQcWfKxlqkMpVrBAARye/message.txt > |
19:23:29 | reversem3 | since its the first line anyway ? |
19:24:01 | FromDiscord | <Avatarfighter> Yo yo o7 everyone |
19:26:38 | PMunch | Hi @Avatar |
19:29:36 | * | greenfork quit (Remote host closed the connection) |
19:29:57 | * | greenfork joined #nim |
19:30:07 | FromGitter | <awr1> it would be `let idx = statFile.readAll.find("Date: \t\t\tHostname: \t\tCPU:") ` |
19:30:26 | FromGitter | <awr1> or well |
19:30:27 | FromGitter | <awr1> hm |
19:30:34 | FromGitter | <awr1> I don't actually know what file you're reading from |
19:30:44 | * | fputs quit (Quit: WeeChat 3.0) |
19:31:02 | reversem3 | statFile.txt |
19:31:03 | * | fputs joined #nim |
19:33:17 | FromGitter | <awr1> You would need to add `fmRead` too |
19:35:08 | * | Guest25945 joined #nim |
19:39:04 | reversem3 | Yeah I have to fix something because now it won't write unless there is something already in the file |
19:39:25 | disruptek | HOW DO IT KNOW? |
19:45:13 | * | habamax quit (Ping timeout: 264 seconds) |
19:50:18 | * | matthias[m]2 joined #nim |
19:53:34 | ForumUpdaterBot | New thread by Adnan: Unable to use HashSet for my type, see https://forum.nim-lang.org/t/7343 |
19:54:14 | * | clemens3 quit (Quit: brb) |
19:54:32 | haxscram` | New users getting clobbered to death by compilation errors |
19:54:56 | Zevv | why was there never a generic hash[T: object]() proc that just does a fieldpairs |
19:55:00 | Zevv | that would make a lot of people happy |
19:56:20 | haxscram` | I guess because this naturally drags need for `==` and case objects later on. Though this would still solve the problem partially |
19:56:54 | disruptek | == is already impl for objects afaik. |
19:57:02 | haxscram` | Not for case objects, no |
19:57:11 | disruptek | bananas. |
19:57:32 | haxscram` | And for case objects it gives cryptic error message without even showing type of the objects that it tried to compare |
19:57:43 | disruptek | Zevv: someone the whiles aren't resuming from the goto stack. |
19:57:54 | disruptek | s/someone/somehow/. should be another easy fix. |
19:58:05 | disruptek | your tests only have 3 failures now, iirc. |
19:58:10 | Zevv | nice nice |
19:58:27 | disruptek | i think they are all the same little bug. |
19:58:34 | Zevv | likely |
19:58:44 | Zevv | but someone made 73 commits with the tests broken |
19:58:46 | Zevv | that's what you get, right |
19:58:57 | disruptek | it has been pretty easy going so far. |
19:59:09 | Zevv | hey, there's party in DC. hope they do wear their masks |
19:59:22 | disruptek | my tests are way more fux0red. |
19:59:29 | Zevv | hehe |
19:59:42 | Zevv | start low & simple |
19:59:47 | disruptek | i guess the good news is that we don't seem to have any more blockers for tzevv. |
19:59:53 | FromDiscord | <Clyybber> disruptek: Indeed bananas, I was reminded of that today too |
20:00:26 | disruptek | we probably need a little more comfort in macros.nim for case objects. |
20:00:33 | disruptek | some convenience procs. |
20:01:05 | * | haxscram` left #nim ("ERC (IRC client for Emacs 27.1)") |
20:01:37 | * | haxscramper joined #nim |
20:01:55 | disruptek | my assignment shim doesn't compile. hmmph. |
20:08:31 | reversem3 | damn ok I can why you use readAll.find("string") |
20:09:02 | reversem3 | all if statements have to have a bool correct ? |
20:12:18 | haxscramper | Yes on second. First - this will work, but `readAll` reads whole file into memory |
20:12:54 | FromDiscord | <Randall> Is there a pragma for a proc/func that enforces that it be called with names for each param? (`function(param1=value1, ...)`) |
20:13:06 | haxscramper | `for line in lines("yourFile"): if "string" in line:` will give you what you need without reading whole file, because `lines()` is an iterator which does not read whole file at once |
20:13:52 | haxscramper | At least if I remember how it works correctly **and** you search for a line that does not contain newline breaks (which seems to be the case for your string) |
20:14:08 | reversem3 | oh I will try that thanks |
20:14:18 | haxscramper | Randall: just make param non-defaulted? |
20:14:39 | haxscramper | Or you specifically need `name=value`, and not just `value`? |
20:14:53 | FromDiscord | <Randall> I mean that `function(value1)` should fail while `function(param1=value1)` should be ok |
20:15:26 | PMunch | I think you need a macro for that |
20:15:39 | haxscramper | No, there is not such thing for a functio, but you could write your own macro that declares second layer of indirection that will check for `ExprEqExpr` AST being passed |
20:15:42 | PMunch | I mean you could write a macro that works as a pragma you can attach to any procedure |
20:16:23 | Zevv | tzevv looks good disruptek, nice work |
20:16:44 | FromDiscord | <Randall> I think that'd be a good macro exercise sometime |
20:16:50 | haxscramper | Or you can write macro that enforces this at callsite, if you accept `typed` ast you can even inspect definition of the proc and provide error messages for that |
20:17:18 | haxscramper | Or take untyped and just check for `a=b` pattern |
20:18:54 | * | NimBot joined #nim |
20:18:56 | reversem3 | hmm so it compiles find but then crashes on run |
20:19:06 | FromDiscord | <Randall> Always hate seeing code like `someProc(true, true, false, 'wow')` |
20:19:13 | reversem3 | Bad file descriptor . Thats a new one |
20:21:55 | reversem3 | https://play.nim-lang.org/#ix=2L5R |
20:22:07 | disruptek | Zevv: gotta beat the dog and then i'll look at the missing goto. |
20:22:21 | * | Arrrrrrrr quit (Quit: Arrrrrrrr) |
20:23:04 | PMunch | I hope that is a euphemism.. |
20:24:06 | PMunch | @Randall, it could be done pretty easily by just wrapping the procedure in a macro that verifies that all arguments are ExprEqExpr and passes it on to the underlying procedure |
20:26:09 | disruptek | you only want to validate params with defaults. |
20:26:20 | disruptek | would be nice to auto-rename deprecated param names, though. |
20:26:40 | disruptek | (because params without defaults may be optionally named in calls) |
20:34:57 | * | Guest25945 quit (Quit: Guest25945) |
20:35:28 | * | Guest25945 joined #nim |
20:42:21 | * | Guest94576 joined #nim |
20:42:45 | * | Guest94576 quit (Client Quit) |
20:45:58 | * | hmmm quit (Quit: WeeChat 3.0) |
20:49:01 | * | narimiran quit (Quit: leaving) |
20:55:14 | * | JustASlacker quit (Ping timeout: 264 seconds) |
20:56:06 | FromDiscord | <Recruit_main707> why are .rst files so weird... |
20:59:19 | disruptek | otherwise there'd be nothing interesting to talk about in #nim. |
20:59:26 | * | haxscramper quit (Remote host closed the connection) |
21:02:08 | PMunch | disruptek, well we'd still have case-insensitivity :P |
21:02:23 | PMunch | @Recruit_main707, what do you mean "weird" |
21:06:13 | * | greenfork quit (Ping timeout: 264 seconds) |
21:07:27 | FromDiscord | <Anonymous Poet> you can statically link the pcre code though ... pass `--define: usePcreHeader --passL: "/usr/lib/x86_64-linux-gnu/libpcre.a"` when you're compiling (the path is the standard when installing on ubuntu 20.04 via `apt-get install libpcre3-dev -y`) |
21:23:28 | * | vsantana quit (Quit: vsantana) |
21:24:08 | FromDiscord | <Recruit_main707> PMunch, https://github.com/RecruitMain707/NimFlatbuffers/blob/master/README.rst↵those 2 rows are the same, but one is separated correctly, and the other one isnt |
21:25:15 | PMunch | Which two rows? |
21:25:28 | PMunch | The "Wont do | Nested namespaces" bit? |
21:26:35 | FromDiscord | <Recruit_main707> yes |
21:28:22 | FromDiscord | <Randall> sent a code paste, see https://play.nim-lang.org/#ix=2L6i |
21:29:11 | PMunch | @Recruit_main707, that's because the last line of ===== is contiguous |
21:29:18 | PMunch | You need to break it up like the top one |
21:29:22 | PMunch | https://gist.github.com/javiertejero/4585196#tables |
21:30:05 | PMunch | Or just remove it completely I think |
21:31:23 | PMunch | @Randall, give me sec |
21:35:11 | FromDiscord | <Randall> Oh, I think it's possible with varargs. |
21:35:14 | * | Guest25945 quit (Quit: Guest25945) |
21:35:33 | * | Guest25945 joined #nim |
21:35:47 | FromDiscord | <Randall> sent a code paste, see https://play.nim-lang.org/#ix=2L6l |
21:35:58 | FromDiscord | <Randall> (edit) "https://play.nim-lang.org/#ix=2L6l" => "https://play.nim-lang.org/#ix=2L6m" |
21:37:39 | FromDiscord | <Meowz> How do I get the start of a slice object? |
21:40:57 | FromDiscord | <Meowz> sent a code paste, see https://play.nim-lang.org/#ix=2L6n |
21:40:58 | FromDiscord | <Meowz> I want `6` to be more precise |
21:42:41 | PMunch | https://play.nim-lang.org/#ix=2L6p |
21:43:22 | PMunch | @Meowz, myslice.low? |
21:43:48 | PMunch | myslice.a |
21:43:53 | FromDiscord | <Randall> Otherwise, quite hacky, you could use slice.a |
21:44:05 | PMunch | Yeah low didn't work: https://play.nim-lang.org/#ix=2L6q |
21:44:13 | FromDiscord | <Randall> Kind of odd that low isn't defined for HSlice tho |
21:44:19 | FromDiscord | <Meowz> Thanks, was just going to use .len + 1. Whatever `.a`does 😄 |
21:44:49 | FromDiscord | <Randall> A slice is defined as an object with 2 fields: `a` and `b`, `a` being the low part of the slice |
21:44:57 | disruptek | leorize: wrt the compiler error messages from testes... what if we do the build without --run to confirm that we can compile it, and then do the same operation with --run to actually run it? the issue i'm trying to get around is the fact that i can't be certain of where the binary will end up due to custom configs, and binary location could be critical. |
21:47:25 | FromDiscord | <exelotl> > _withValue sucks_↵Yeah, though I appreciate the problem it's trying to solve |
21:48:14 | disruptek | i know, but it's really irritating that i can rarely use it because it's so lame. |
21:48:54 | disruptek | Zevv: more tests, please. 😘 |
21:49:41 | FromDiscord | <exelotl> it's unfortunately the only way we have to safely "do something with the result of a lookup" without doing the lookup twice |
21:49:58 | disruptek | yeah, but you can't use result, etc. |
21:50:13 | disruptek | it should simply be fixed. |
21:50:19 | FromDiscord | <mratsim> a, b are unfortunate names for the start and stop of a slice |
21:51:02 | Zevv | disruptek: \o/ |
21:51:10 | Zevv | I'll try to get stash/ up and running tomorrow! |
21:51:32 | Zevv | if you're bored: stash/iterator.nim complains about node having no tpe |
21:51:47 | disruptek | yeah, that's my current taste bug. |
21:52:05 | Zevv | right |
21:53:03 | FromGitter | <awr1> is there a way to render NimNode to a string of nim code |
21:53:21 | FromDiscord | <exelotl> yeah, `repr(node)` |
21:54:18 | FromGitter | <awr1> thx |
21:55:34 | * | hmmm joined #nim |
21:55:45 | disruptek | hmmm. |
21:55:47 | FromDiscord | <exelotl> there's also `treeRepr(node)` to see the tree structure, and `astGenRepr(node)` to see the nim code that you would have to write in order to produce that node |
21:56:05 | * | JustASlacker joined #nim |
21:56:25 | FromDiscord | <exelotl> (edit) "there's also `treeRepr(node)` to see the tree structure, and `astGenRepr(node)` to see the nim code that you would have to write ... in" added "(inside the macro)" |
21:57:17 | FromGitter | <awr1> yeah im familiar with treeRepr but was just looking for one that gave me what the generated Nim would theoretically look like |
21:58:01 | FromDiscord | <fwsgonzo> this might seem like a strange question but is there an absolute guarantee that if you create a var object of any kind inside a function, that this object will never (unless it's a very weird and specific object) write to .data? |
21:58:16 | FromDiscord | <fwsgonzo> (edit) "there an absolute guarantee" => "it extremely likely" |
21:58:43 | FromDiscord | <fwsgonzo> (edit) ".data?" => ".data/.bss?" |
22:02:13 | FromGitter | <awr1> Shouldn't be, unless something points to somewhere in the BSS/Data segment, the var is `{.global.}`, or the context is a compiletime procedure, in which the output of the function may potentially be in BSS/Data |
22:04:24 | * | xet7 quit (Remote host closed the connection) |
22:04:37 | FromGitter | <awr1> (more than likely compiletime procs will be statically writing to Data, but ofc this is not at runtime) |
22:07:29 | FromDiscord | <fwsgonzo> right, reading .rodata is fine so thats OK |
22:10:04 | FromDiscord | <fwsgonzo> sent a long message, see http://ix.io/2L6x |
22:11:01 | FromDiscord | <andeee> when interfacing with c code should there be any distinction made between void and void, or should I use pointer for both? |
22:12:39 | FromDiscord | <Randall> Turned out to be quite simple to disallow non-named-parameter function calls https://play.nim-lang.org/#ix=2L6z |
22:14:13 | FromGitter | <awr1> @andee not sure if typo but do you mean `void` and `void*`? |
22:14:23 | FromGitter | <awr1> *andeee |
22:14:34 | FromDiscord | <andeee> nope i mean void and voi, unfortunately 😄 |
22:14:49 | FromDiscord | <andeee> (edit) "voi," => "void," |
22:15:10 | FromDiscord | <andeee> this for example https://media.discordapp.net/attachments/371759389889003532/796502144085262427/unknown.png |
22:15:20 | FromGitter | <awr1> `void` is the same if you're talking about the return type. |
22:15:48 | FromGitter | <awr1> `void*` is `pointer` |
22:15:50 | FromDiscord | <Randall> I've never programmed C, but void pointers are different from void return type |
22:16:02 | FromDiscord | <andeee> a void pointer is a pointer to any type |
22:16:28 | FromDiscord | <andeee> and a void from what i understand is a pointer to void and is used when the thing you're passing it to needs to initialize that void in memory |
22:16:40 | FromGitter | <awr1> If you need `void*` use `pointer`, which is the typeless version of `ptr T`. |
22:16:44 | FromDiscord | <andeee> im not sure if it affects the nim code however but im a nim noob and dont know |
22:17:17 | FromDiscord | <andeee> i guess i'll just stick with pointer |
22:19:42 | FromDiscord | <mratsim> @zevv @disruptek did you have time to think about my continuations and coroutines API? |
22:19:48 | FromDiscord | <andeee> I see nim allows me to do `ptr pointer` but it just feels wrong lol |
22:20:06 | PMunch | `void *` is a pointer to any type, in Nim a `pointer` a `void **` is a pointer to a void pointer, in Nim a `ptr pointer` |
22:20:08 | FromDiscord | <mratsim> do var pointer then |
22:20:09 | * | JustASlacker quit (Ping timeout: 272 seconds) |
22:20:31 | * | taprack quit (Remote host closed the connection) |
22:20:40 | FromGitter | <awr1> `void` by itself - is just the return type that returns nothing. `void*` is a typeless pointer. You are not really supposed to be able to "dereference it", typically you cast it to something else. Unlike other pointer types in C `void*` has no actual relationship to `void` which contrasts with, say, how `int*` is a pointer to an `int`. |
22:21:38 | FromDiscord | <mratsim> ptr blackhole is the better name |
22:21:48 | FromGitter | <awr1> IMO generally avoid using `pointer` if you can help it |
22:21:57 | FromGitter | <awr1> It's there for C purposes |
22:22:53 | FromGitter | <awr1> Nim treats typed pointers (i.e. `ptr T`) as generic types so most of the need for `pointer` is not necessary |
22:23:20 | FromDiscord | <mratsim> you can even replace ptr+len is C APi by openarray |
22:23:38 | FromDiscord | <andeee> i wish i could but im interfacing with the c node api |
22:24:29 | FromDiscord | <mratsim> for example: https://github.com/status-im/nim-blscurve/blob/master/blscurve/blst/blst_abi.nim#L289-L300↵https://github.com/supranational/blst/blob/master/bindings/blst.h#L214-L230 |
22:25:48 | FromDiscord | <mratsim> btw someone knows how to wrap C++ constructor with initializer list? |
22:26:47 | * | PMunch quit (Quit: leaving) |
22:35:15 | * | Guest25945 quit (Quit: Guest25945) |
22:35:45 | * | Guest25945 joined #nim |
22:37:07 | * | krux02 joined #nim |
22:40:41 | leorize | disruptek: you can set the binary location with --outdir, no? |
22:41:36 | leorize | mratsim: initializer list should just be fancy syntax for `field = something` afaik |
22:41:53 | ForumUpdaterBot | New thread by Mratsim: Generating C++ constructor with initialization list., see https://forum.nim-lang.org/t/7344 |
22:42:37 | FromDiscord | <mratsim> sometimes it's necessary when a field is declared const, fortunately I don't have this problem yet |
22:42:48 | FromDiscord | <mratsim> I'll have to sleep on it |
22:43:24 | leorize | Zevv might know a thing or tw |
22:43:28 | leorize | two* |
22:51:04 | * | taprack joined #nim |
22:52:07 | * | Gustavo6046 quit (Ping timeout: 260 seconds) |
22:53:08 | FromDiscord | <exelotl> if I have a top level variable `var foo: int` is there a way for me to look up the sym in a macro? |
22:53:19 | FromDiscord | <exelotl> I want to know if someone passed that exact variable to the macro |
22:53:35 | * | fputs quit (Quit: WeeChat 3.0) |
22:53:57 | * | Gustavo6046 joined #nim |
22:54:58 | FromDiscord | <mratsim> the owned macro can tell you if it's a global AFAIK |
22:57:18 | * | oddp joined #nim |
22:58:03 | FromDiscord | <dom96> The IC PRs are giving me deja vu |
22:58:19 | FromDiscord | <exelotl> this works: https://play.nim-lang.org/#ix=2L6P |
22:58:25 | FromDiscord | <dom96> Is it Araq giving me a sign that I'm really in the matrix? |
22:58:49 | * | Gustavo6046_ joined #nim |
22:58:54 | * | Gustavo6046 quit (Ping timeout: 272 seconds) |
23:00:23 | * | Gustavo6046_ is now known as Gustavo6046 |
23:06:23 | * | Gustavo6046 quit (Ping timeout: 260 seconds) |
23:07:55 | FromDiscord | <exelotl> Is this a bug? https://play.nim-lang.org/#ix=2L6W |
23:07:56 | ForumUpdaterBot | New thread by Snej: NimDBX (libmdbx key/value database wrapper) now nimble-installable, whew, see https://forum.nim-lang.org/t/7345 |
23:16:40 | * | tane quit (Quit: Leaving) |
23:17:30 | FromDiscord | <ElegantBeef> Exelotl the only thing i can say for certainty is i've no clue what this does 😄 |
23:17:53 | * | oddp quit (Quit: quit) |
23:23:36 | FromDiscord | <exelotl> it should rewrite `x = 10` to `x = 10 + 1` and then not rewrite it again after that |
23:23:53 | FromDiscord | <exelotl> but it seems like the noRewrite pragma is just totally broken lol |
23:24:29 | FromDiscord | <shadow.> is there any way to like get the current day as a number 0-36(3/4)? |
23:24:34 | FromDiscord | <shadow.> or something similar |
23:24:38 | FromDiscord | <shadow.> anything dealing w calendars ig |
23:24:42 | FromDiscord | <shadow.> i can figure out the rest by myself |
23:24:53 | FromDiscord | <shadow.> (edit) "0-36(3/4)?" => "1-365?" |
23:25:38 | FromDiscord | <shadow.> im guessing times? |
23:28:01 | FromDiscord | <shadow.> yep got it |
23:30:13 | FromDiscord | <juan_carlos> I think norewrite has nothing to do with `variable` like this, that only makes a variable, I dont understand the backticks on the example. Last time I tried it was working. |
23:32:11 | * | Vladar quit (Quit: Leaving) |
23:35:27 | * | Guest25945 quit (Quit: Guest25945) |
23:35:50 | * | Guest25945 joined #nim |
23:36:35 | FromDiscord | <ElegantBeef> @shadow. https://nim-lang.org/docs/times.html#yearday%2CDateTime |
23:37:47 | * | Gustavo6046 joined #nim |
23:39:45 | FromDiscord | <shadow.> yep i got it |
23:39:48 | FromDiscord | <shadow.> now().yearday |
23:39:55 | FromDiscord | <shadow.> ty |
23:39:57 | FromDiscord | <ElegantBeef> I'm blind didnt see that |
23:40:02 | FromDiscord | <shadow.> hm? |
23:40:10 | FromDiscord | <ElegantBeef> Your original "got it" |
23:40:12 | FromDiscord | <shadow.> ohh |
23:40:14 | FromDiscord | <shadow.> its fine lol |
23:40:56 | FromDiscord | <shadow.> lol i took a little time to try rust and ive gotta say i was like "eh this isnt that bad" and then i just wrote some nim again and im like "ok nvm this is what i was missing" lmao |
23:47:45 | FromGitter | <alehander92> disruptek |
23:48:02 | FromDiscord | <exelotl> the backticks aren't important, same thing happens without them |
23:48:04 | FromGitter | <alehander92> some love from bulgaria |
23:48:07 | FromGitter | <alehander92> good nightt |
23:49:25 | FromDiscord | <juan_carlos> I think no rewrite is like for proc/func/iterator/etc maybe not for whole blocks or expressions?. |
23:55:33 | disruptek | leorize: what if the user "needs" the binary output to a specific spot in order to make the tests work? or a specific filename? |
23:56:11 | disruptek | alehander92: how did you get stuck on gitter? |
23:56:35 | leorize[m] | disruptek then they need to provide the test runner with additional metadata |
23:57:08 | disruptek | isn't that what nim.cfg or test.nim.cfg is for? |
23:57:29 | disruptek | i can do it "correctly", it's just more work. 😉 |
23:58:11 | leorize[m] | then you can make that happen :p |
23:58:32 | disruptek | hmmph. |