00:01:11 | * | Onionhammer quit (Ping timeout: 252 seconds) |
00:20:51 | FromDiscord | <TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3H2e |
00:21:08 | FromDiscord | <Elegantbeef> "the variation"? |
00:21:41 | FromDiscord | <TryAngle> the enum variation↵e.g a, b and c |
00:22:15 | FromDiscord | <TryAngle> something like:↵assert A.c.toInt() == -8 |
00:22:16 | FromDiscord | <Elegantbeef> I do not follow |
00:22:21 | FromDiscord | <Elegantbeef> ah |
00:22:24 | FromDiscord | <Elegantbeef> `ord` |
00:22:38 | FromDiscord | <Elegantbeef> I'd say "integer value" 😀 |
00:23:30 | FromDiscord | <TryAngle> ah thanks 🙂 |
00:23:44 | FromDiscord | <TryAngle> is there also a way to echo ints in hex format? |
00:23:48 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3H2h |
00:23:59 | FromDiscord | <Elegantbeef> `import std/strutils` `toHex` |
00:24:13 | FromDiscord | <TryAngle> 👍 |
00:24:40 | FromDiscord | <Elegantbeef> In Nim using holey enums is a detriment since it doesnt allow some features if the range is wide enough |
00:24:48 | FromDiscord | <el__maco> somewhat related question is there an easy way to echo floats with fewer decimal places |
00:25:04 | FromDiscord | <Elegantbeef> `import std/strutils` `formatFloat` i believe |
00:25:53 | FromDiscord | <Elegantbeef> You can also use `std/strformat` `fmt` with `{yourFloat: 2}` i believe |
00:27:49 | FromDiscord | <TryAngle> @ElegantBeef ok now a bit different, I'm using cint vor value now |
00:27:57 | FromDiscord | <TryAngle> but ord still returns int? |
00:28:02 | FromDiscord | <el__maco> ``import math,std/strutils↵echo PI.formatFloat(ffDecimal,2)``↵this seems to work, not sure about the second option |
00:28:38 | FromDiscord | <Elegantbeef> `import std/[math, strformat]; echo fmt"{PI: 2}"` 😛 |
00:28:48 | FromDiscord | <Elegantbeef> Though that's not capable of being user defined or dynamic |
00:29:09 | FromDiscord | <Elegantbeef> You can just do `ord.cint` |
00:30:10 | FromDiscord | <TryAngle> thanks again 😄 |
00:32:25 | * | lumo_e quit (Quit: Quit) |
00:51:52 | FromDiscord | <codic> ord always returns int |
01:00:02 | FromDiscord | <codic> sent a code paste, see https://play.nim-lang.org/#ix=3H2t |
01:00:05 | FromDiscord | <codic> why does this not build? using <https://github.com/nim-lang/cairo> |
01:00:11 | FromDiscord | <codic> which has cairoxlib.nim: <https://github.com/nim-lang/cairo/blob/master/src/cairoxlib.nim> |
01:07:23 | * | [R] quit (Read error: Connection reset by peer) |
01:07:30 | * | [R] joined #nim |
01:11:11 | FromDiscord | <codic> nimble sucks I might just copy this to my project |
01:11:14 | FromDiscord | <codic> what am I doing wrong tho |
01:11:48 | FromDiscord | <Elegantbeef> What's the build error? |
01:14:17 | FromDiscord | <codic> cannot open file: cairo/cairoxlib |
01:14:41 | FromDiscord | <codic> it also looks like the cairoxlib module is using the wrong imports for X11, so I'll just vendor this (and PR upstream later) until I figure out Pixie with X11 |
01:14:46 | FromDiscord | <codic> which is definitely the most ideal |
01:14:53 | FromDiscord | <codic> cuz pure nim |
01:15:17 | FromDiscord | <Elegantbeef> it should be `cairoxlib` just cause of how the packaging works |
01:15:27 | FromDiscord | <Elegantbeef> not `cairo/cairoxlib` |
01:16:06 | FromDiscord | <codic> oh i see |
01:16:13 | FromDiscord | <codic> still doesn't work because the module is broken: `/home/user/.nimble/pkgs/cairo-1.1.1/cairoxlib.nim(8, 10) Error: cannot open file: x` |
01:16:17 | FromDiscord | <codic> (x should be x11/x) |
01:16:25 | FromDiscord | <codic> so I'll just keep a local copy yea |
01:17:25 | FromDiscord | <Elegantbeef> I mean you can always fork it and maintain it for yourself |
01:17:39 | FromDiscord | <Elegantbeef> Then depend upon that instead of copying it into your project |
01:18:05 | FromDiscord | <codic> Yeah |
01:21:04 | FromDiscord | <codic> it works! https://media.discordapp.net/attachments/371759389889003532/916861694905561138/unknown.png |
01:21:12 | FromDiscord | <Elegantbeef> Congrats |
01:37:31 | * | PMunch quit (Quit: leaving) |
01:41:42 | FromDiscord | <codic> now to do something more useful than an empty rectangle |
01:53:17 | * | audiophile_ joined #nim |
01:56:41 | * | audiophile quit (Ping timeout: 252 seconds) |
01:56:49 | * | audiophile_ is now known as audiophile |
01:58:28 | FromDiscord | <codic> give up, cairo sucks |
02:12:20 | FromDiscord | <ynfle (ynfle)> try https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwiQ-NzTysv0AhVwR_EDHWmlD4MQFnoECAUQAQ&url=https%3A%2F%2Fgithub.com%2Ftreeform%2Fpixie&usg=AOvVaw3xMtM-8Yvrs8eRQaS6U3ND |
02:12:33 | FromDiscord | <ynfle (ynfle)> Try https://github.com/treeform/pixie |
02:16:39 | FromDiscord | <codic> Indeed |
02:16:50 | FromDiscord | <codic> It took me 1/4 the time and I've already started making things, pixie is awesome |
02:17:15 | FromDiscord | <codic> Finally figured out how to draw it to a X pixmap, I think I'll PR an example because that took me some time to figure out |
02:19:12 | FromDiscord | <Klaufir> sent a code paste, see https://play.nim-lang.org/#ix=3H2G |
02:19:36 | FromDiscord | <codic> lol, and as I speak @treeform has released a new version of pixie |
02:19:36 | FromDiscord | <codic> epic |
02:19:40 | FromDiscord | <Elegantbeef> You should interpret it as a result |
02:20:10 | FromDiscord | <Elegantbeef> It's an expression so result = the expression |
02:20:21 | FromDiscord | <Elegantbeef> Really you can drop the `result =` assignment and it'd be the exact same logic |
02:20:33 | FromDiscord | <Klaufir> sent a code paste, see https://play.nim-lang.org/#ix=3H2H |
02:20:45 | FromDiscord | <codic> what is the syntax error |
02:20:51 | FromDiscord | <Elegantbeef> User defined code is not the same as macro generated in some cases |
02:20:53 | FromDiscord | <Klaufir> (edit) "https://play.nim-lang.org/#ix=3H2H" => "https://play.nim-lang.org/#ix=3H2I" |
02:21:21 | FromDiscord | <Klaufir> I get `test.nim(5, 5) Error: invalid indentation` for the above |
02:22:27 | FromDiscord | <treeform> In reply to @codic "lol, and as I": Thank you for using Pixie. I am excited to report that with this new version we are now faster than Cairo in most cases we benchmark. Hope it continues to work great for you. |
02:22:33 | FromDiscord | <codic> awesome! |
02:22:50 | FromDiscord | <treeform> Adding more examples is very welcome. |
02:22:59 | FromDiscord | <codic> yeah I spent too much time failing to get cairo to work properly, pixie is just wonderful |
02:23:05 | FromDiscord | <treeform> 🙂 |
02:23:07 | FromDiscord | <codic> created an issue, will create a PR soon |
02:23:52 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3H2K |
02:24:14 | FromDiscord | <Elegantbeef> If you look at the treeRepr of that you will see the right side of the `var name =` is a `StmtList` |
02:24:46 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3H2L |
02:24:47 | FromDiscord | <Elegantbeef> Since all a statement list is really is a block of code |
02:25:03 | FromDiscord | <Klaufir> Ah, thank you |
02:25:08 | FromDiscord | <Klaufir> didn't know this was possible |
02:25:34 | FromDiscord | <Elegantbeef> `()` can be used fairly often to make Nim play nice |
02:25:39 | * | neurocyte0132889 quit (Ping timeout: 252 seconds) |
02:25:46 | FromDiscord | <codic> Indeed |
02:25:46 | FromDiscord | <Elegantbeef> Not that it's really suggested, but alas |
02:25:57 | FromDiscord | <codic> Yeah I wouldn't use result there |
02:26:24 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3H2N |
02:26:40 | FromDiscord | <Elegantbeef> But yes there is 0 reason to use result unless you use the value after |
02:26:56 | FromDiscord | <Elegantbeef> Implicit results are preferred where usable |
02:27:28 | FromDiscord | <codic> that is valid?? |
02:27:33 | FromDiscord | <Klaufir> https://discord.com/channels/371759389889003530/371759389889003532/916876307390935061↵This is how memlib (tool on windows to load dlls from memory) ensured that `memlookup` is only called once |
02:27:37 | FromDiscord | <Elegantbeef> Of course `=` is just an operator |
02:28:54 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3H2O |
02:30:13 | FromDiscord | <Elegantbeef> Anywho the "invalid code" you're seeing is just rendering of macros back into readable code |
02:30:28 | FromDiscord | <Elegantbeef> stmtlists do not include `()` for readability reasons i assume |
02:31:04 | FromDiscord | <codic> pixie bouncy ball https://media.discordapp.net/attachments/371759389889003532/916879312601382942/unknown.png |
02:31:08 | FromDiscord | <codic> with x11 backend |
02:31:16 | FromDiscord | <Elegantbeef> Cause you very well might have nested stmtlists randomly |
02:31:28 | FromDiscord | <Elegantbeef> Nice, might have to use your reference code when i get back to goodwm |
02:31:38 | FromDiscord | <Elegantbeef> Right now i'm dumbly using sdl2 to display the image |
02:33:15 | FromDiscord | <codic> when goodwm is not good |
02:33:38 | FromDiscord | <Elegantbeef> It's never good |
02:33:44 | FromDiscord | <Elegantbeef> The name is a joke based on awesomeWm |
02:35:34 | FromDiscord | <codic> https://github.com/treeform/pixie/pull/340 PR'd example |
02:35:43 | * | audiophile quit (Quit: Default Quit Message) |
02:48:04 | * | audiophile joined #nim |
02:51:31 | * | audiophile quit (Client Quit) |
03:14:14 | FromDiscord | <treeform> If you like X11 we are working on windy (which is not ready) - which will be a wrapper around win32, mac and x11 that does all of that window stuff: https://github.com/treeform/windy/ |
03:14:28 | FromDiscord | <treeform> Some things already work. |
03:20:45 | FromDiscord | <retkid> Ngl |
03:21:02 | FromDiscord | <retkid> Nim is my favorite Lang for single threaded |
03:21:06 | FromDiscord | <retkid> But |
03:21:26 | FromDiscord | <retkid> Otherwise, it’s a nightmare |
03:22:16 | FromDiscord | <retkid> It’s pretty disgusting |
03:24:44 | FromDiscord | <codic> that is an interesting way at looking at it |
03:24:54 | FromDiscord | <codic> nim's threads and async pretty cool |
03:25:19 | FromDiscord | <codic> In reply to @treeform "If you like X11": oh, so like serving the niche of x11 |
03:25:20 | FromDiscord | <codic> (edit) "x11" => "sdl" |
03:25:22 | FromDiscord | <codic> very cool |
03:25:27 | FromDiscord | <codic> will try it out |
03:25:29 | FromDiscord | <retkid> asynchronous is good |
03:25:37 | FromDiscord | <retkid> But have you tried to use threads? |
03:25:53 | FromDiscord | <retkid> Not just read about it |
03:26:03 | FromDiscord | <retkid> Like actually write a ton of code in threads |
03:26:06 | FromDiscord | <Elegantbeef> I've used them |
03:26:16 | FromDiscord | <Elegantbeef> Channels + threads = happy me |
03:26:24 | FromDiscord | <retkid> Channels is cool |
03:26:34 | FromDiscord | <retkid> Until you’re afraid of it crashing randomly |
03:26:37 | FromDiscord | <retkid> Which happens |
03:26:57 | FromDiscord | <retkid> They are unstable currently |
03:27:07 | FromDiscord | <retkid> That’s basically my only critique |
03:27:17 | FromDiscord | <retkid> Without that, it would be easy |
03:34:32 | FromDiscord | <codic> I have used nim threads |
03:34:46 | FromDiscord | <codic> I haven't written a huge ton of code, but I've written an ok amount and it works just fine for me |
03:42:22 | * | arkurious quit (Quit: Leaving) |
03:53:41 | FromDiscord | <exelotl> heyy, is there a way to reliably get the AST for a whole module? |
03:54:46 | FromDiscord | <Elegantbeef> Sadly nope |
03:55:05 | FromDiscord | <Elegantbeef> Well not in the same compiler context |
03:56:42 | FromDiscord | <exelotl> sent a code paste, see https://play.nim-lang.org/#ix=3H35 |
03:57:08 | FromDiscord | <exelotl> (edit) "https://play.nim-lang.org/#ix=3H35" => "https://play.nim-lang.org/#ix=3H36" |
03:57:13 | FromDiscord | <Elegantbeef> If you dont want symbols you can always find the file and load it yourself, but that doesnt give symbols so it's mostly pointles |
03:57:59 | FromDiscord | <exelotl> I guess I'll just have to do without symbols 🙃 |
03:58:24 | FromDiscord | <Elegantbeef> Yea it sucks, was looking for something similar for nimscripter, sadly no API yet |
03:59:09 | FromDiscord | <exelotl> I'm doing this for a documentation tool, so having the typed AST would be _nice_ but I can get by without, I guess. |
04:06:01 | * | supakeen quit (Quit: WeeChat 3.3) |
04:06:31 | * | supakeen joined #nim |
04:08:35 | FromDiscord | <codic> @treeform two questions about pixie:↵ - 1) i have a hexadecimal number which is either in the form `0xAARRGGBB` or `0xRRGGBB` (in which case AA = 255). how can I convert this to a Pixie `rgba`?↵ - 2) is there support for bitmap fonts? |
04:08:42 | FromDiscord | <codic> and actually 3) how can I find a font based on the font name? |
04:10:20 | FromDiscord | <codic> sorry for all the questions but it also seems that the fonts are a bit blurry https://media.discordapp.net/attachments/371759389889003532/916904293548822528/unknown.png |
04:13:22 | FromDiscord | <treeform> 1) use rgba(123,123,123,123) constructor |
04:13:44 | FromDiscord | <treeform> 2) bit map fonts are not supported |
04:14:10 | FromDiscord | <treeform> Bit there are plants of .ttf pixel fonts if you want that pixel look |
04:14:25 | FromDiscord | <treeform> (edit) "Bit" => "But" | "plants" => "planty" |
04:14:39 | FromDiscord | <codic> Yeah I guess that's fair |
04:15:03 | FromDiscord | <codic> I might just use Xft and then use Pixie's stuff on top of that |
04:15:20 | FromDiscord | <treeform> 3) we usually assume you have font next to your program, we don't have a way to query or load system fonts. |
04:16:10 | FromDiscord | <codic> Got it |
04:16:21 | FromDiscord | <codic> Shouldn't be too hard to use fontconfig for that |
04:16:23 | FromDiscord | <treeform> 4) fonts bury can be many issues, |
04:16:47 | FromDiscord | <codic> bury? |
04:17:26 | FromDiscord | <Elegantbeef> blurry of course |
04:17:37 | FromDiscord | <codic> oh I did not realize that 🤦♂️ |
04:17:54 | FromDiscord | <codic> It seems to not happen with Xft or cairo, only with Pixie |
04:18:28 | FromDiscord | <exelotl> In reply to @Elegantbeef "If you dont want": weh, if I use parseStmt to get the untyped AST, there's no lineinfo |
04:19:31 | FromDiscord | <exelotl> at this rate I'm thinking I'll just have to parse the file myself :/ |
04:20:13 | FromDiscord | <Rika> probably because pixie doesnt do font hinting |
04:20:25 | FromDiscord | <Rika> (and its a matter of preference as well) |
04:20:36 | FromDiscord | <Rika> i prefer "blurry fonts" since they look nicer to me |
04:20:54 | FromDiscord | <codic> Fair, they look terribly unreadable to my eyes |
04:20:54 | FromDiscord | <Elegantbeef> Yep exelotl that's the shame, i believe there is a PR that enables more information |
04:21:00 | FromDiscord | <codic> I think I'll just do Xft for text and overlay Pixie on top |
04:21:57 | FromDiscord | <Rika> if it follows system configs for fonts then 👍 |
04:22:33 | FromDiscord | <codic> yeah xft follows fontconfig |
04:23:09 | FromDiscord | <codic> so I can have all the goodies of text following your system configuration, plus gradients and svgs and all the other fancy stuff |
04:24:56 | * | audiophile joined #nim |
04:29:09 | * | audiophile_ joined #nim |
04:31:14 | * | audiophile_ quit (Client Quit) |
04:33:15 | * | audiophile quit (Ping timeout: 252 seconds) |
04:35:41 | FromDiscord | <codic> gradient titlebar with pixie https://media.discordapp.net/attachments/371759389889003532/916910677044629504/unknown.png |
04:35:52 | FromDiscord | <pyautogui> Any good JPEG lib |
04:35:53 | FromDiscord | <pyautogui> ? |
04:36:24 | FromDiscord | <pyautogui> I am wondering because I was looking at the treeform/pixie repo, and there is no JPEG output. I would like to add it. |
04:38:00 | FromDiscord | <codic> sent a code paste, see https://play.nim-lang.org/#ix=3H3h |
04:38:10 | FromDiscord | <codic> the gradient will only go so big |
04:38:43 | FromDiscord | <codic> https://media.discordapp.net/attachments/371759389889003532/916911440512843786/unknown.png |
04:40:08 | FromDiscord | <codic> (it won't go as big as attr.width.float32, but only after a certain point) |
04:44:00 | nrds | <SpaceDuck99> Has anyone done heavy database work with Nim? Just curious if there are any issues with CTE queries and/or ODBC to MSSQL |
04:47:23 | nrds | <Prestige99> Hm maybe check issue trackers for the different sql libraries |
04:49:39 | nrds | <SpaceDuck99> Thx for showing me this... I'm going to go get super high and do some Nim programming |
04:57:28 | * | noeontheend joined #nim |
05:05:05 | * | [R] quit (Remote host closed the connection) |
05:05:12 | * | [R] joined #nim |
05:40:36 | * | noeontheend quit (Read error: Connection reset by peer) |
05:41:03 | * | noeontheend joined #nim |
06:01:05 | FromDiscord | <TryAngle> wait do procs have an implicit "result" variable? |
06:01:21 | FromDiscord | <Yardanico> yes |
06:01:35 | FromDiscord | <Yardanico> every proc with a return type has an implicit `result` variable |
06:01:48 | FromDiscord | <Yardanico> so you don't have to say `var result = 0; # get result; return result` |
06:01:57 | FromDiscord | <Yardanico> you just write `result = computation` |
06:01:59 | FromDiscord | <TryAngle> 😳 |
06:12:37 | * | noeontheend quit (Ping timeout: 252 seconds) |
06:58:51 | FromDiscord | <Cypheriel> out of curiosity... is there better editor support than the one nim plugin on VSCode |
06:59:02 | FromDiscord | <Cypheriel> or are pretty much all the solutions this janky |
06:59:50 | FromDiscord | <Cypheriel> I feel like this plugin is contributing to my stress levels lol |
07:00:20 | FromDiscord | <Rika> They all depend on nimsuggest which is the main cause of problems |
07:01:42 | FromDiscord | <Cypheriel> I hear often something about some Nim LSP |
07:01:48 | FromDiscord | <Cypheriel> I'm not sure how it compares |
07:02:06 | FromDiscord | <Rika> Same issue |
07:02:09 | FromDiscord | <Rika> Depends on nimsuggest |
07:02:34 | FromDiscord | <Cypheriel> goes to show how much I know about these things |
07:02:41 | FromDiscord | <Cypheriel> (none, basically) |
07:02:50 | FromDiscord | <Rika> That’s fine |
07:02:56 | FromDiscord | <Rika> No one knows anything right off the bat |
07:03:30 | FromDiscord | <Cypheriel> I just wish I didn't feel like both me and my linter are incompetent lol |
07:03:36 | FromDiscord | <Cypheriel> I can't trust myself nor these suggestions |
07:05:12 | FromDiscord | <Rika> Dunno |
07:05:29 | FromDiscord | <Rika> I personally never really relied on suggestions being completely right |
07:13:24 | FromDiscord | <Cypheriel> Neither am I, but... that's not exactly preferable |
07:21:13 | FromDiscord | <Solitude> In reply to @Cypheriel "Neither am I, but...": trust yourself, dont let the machine tell you what to do. |
07:22:20 | FromDiscord | <Cypheriel> In reply to @Solitude "trust yourself, dont let": I'm just too new to the language to really assume I know what I'm doing, and a lot of my logic is carried over from Python |
07:22:28 | FromDiscord | <Cypheriel> and a lot of things just do not act like I'd expect them |
07:22:47 | FromDiscord | <Cypheriel> meanwhile, VSCode is telling me about errors that... really don't even exist and I have no idea where they came from or what they even mean |
07:22:52 | FromDiscord | <codic> What issues do you have with nimsuggest? it works pretty decently for me |
07:22:58 | FromDiscord | <codic> can you give an example? |
07:23:19 | FromDiscord | <Cypheriel> In reply to @codic "What issues do you": I have no idea how to qualify them at the moment, but for one thing it's usually pretty slow |
07:23:40 | FromDiscord | <Cypheriel> sometimes it just doesn't even work lol |
07:24:12 | FromDiscord | <Solitude> In reply to @Cypheriel "meanwhile, VSCode is telling": only trust compiler output about errors |
07:24:22 | FromDiscord | <Cypheriel> yeah, which I've begun to do |
07:24:36 | FromDiscord | <Cypheriel> but there's also the issue of sometimes there's absolutely no info about an error |
07:24:54 | FromDiscord | <Cypheriel> sometimes it's literally the equivalent of "Error: " and no info given |
07:25:31 | FromDiscord | <Solitude> damn, it do be like that sometimes |
07:25:47 | FromDiscord | <codic> weird, nimsuggest is pretty darn fast for me |
07:26:04 | FromDiscord | <Cypheriel> In reply to @codic "weird, nimsuggest is pretty": Perhaps it's a problem with VSCode's autosave |
07:26:07 | FromDiscord | <Cypheriel> but like |
07:26:17 | FromDiscord | <Cypheriel> I have to wait a good few seconds for the suggestions to be accurate |
07:26:23 | FromDiscord | <codic> weird |
07:26:55 | FromDiscord | <Cypheriel> things like this are quite weird as well https://media.discordapp.net/attachments/371759389889003532/916953767918829588/Screenshot_20211205_002642.png |
07:27:07 | FromDiscord | <Cypheriel> https://media.discordapp.net/attachments/371759389889003532/916953812416217089/Screenshot_20211205_002658.png |
07:27:16 | FromDiscord | <Cypheriel> like what on Earth is it doing there |
07:28:22 | FromDiscord | <Cypheriel> for reference, input and sample are defined on line 22-23 |
07:31:00 | FromDiscord | <Cypheriel> oh and another gripe, as well... I almost regret using snake_case because this plugin doesn't provide good suggestions outside of camelCase |
07:31:28 | FromDiscord | <Solitude> yeah, you should regret it |
07:31:46 | FromDiscord | <Cypheriel> In reply to @Solitude "yeah, you should regret": hopefully for reasons other than preference >_> |
08:16:57 | NimEventer | New thread by Kobi: Async with delegates, how to pass parameters?, see https://forum.nim-lang.org/t/8679 |
10:09:51 | * | krux02 joined #nim |
11:08:48 | * | jjido joined #nim |
11:44:31 | * | kobi joined #nim |
11:44:36 | kobi | hi |
11:44:53 | kobi | a friend is having trouble connecting to the forum, who should i ask? |
11:45:04 | kobi | connecting = registering |
11:48:46 | FromDiscord | <hugogranstrom> In reply to @kobi "a friend is having": @dom96 @narimiran |
12:06:01 | * | supakeen quit (Quit: WeeChat 3.3) |
12:06:31 | * | supakeen joined #nim |
12:31:14 | * | PMunch joined #nim |
12:34:39 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
12:40:42 | FromDiscord | <Southern_Cross_Au> hello |
12:40:55 | FromDiscord | <Southern_Cross_Au> looking for trouble shooting 😄 |
12:42:06 | kobi | shoot your trouble |
12:42:57 | FromDiscord | <Southern_Cross_Au> going though nim in action: Getting the following error |
12:43:21 | FromDiscord | <Southern_Cross_Au> https://media.discordapp.net/attachments/371759389889003532/917033399737253928/unknown.png |
12:44:13 | kobi | do you have gcc installed? try typing gcc in the terminal |
12:44:17 | FromDiscord | <Southern_Cross_Au> I have played with PATH several times, not sure what I did wrong. I also download the compiler from the website and distributed it into the bin and complier folders |
12:44:33 | FromDiscord | <Southern_Cross_Au> In reply to @kobi "do you have gcc": yes |
12:46:22 | kobi | you can see the gcc path there, with requested command not found. |
12:46:48 | kobi | but if it's in that location, maybe the error msg is hiding some other issue. |
12:47:12 | FromDiscord | <Southern_Cross_Au> I have to add the Gcc path ? ok will find it and add it |
12:47:35 | kobi | okay, cool |
12:48:08 | kobi | btw, u can use shortcuts like nim c -r yourfile.nim |
12:48:32 | FromDiscord | <Southern_Cross_Au> In reply to @kobi "btw, u can use": that was VSC doing 😄 |
12:48:40 | FromDiscord | <Southern_Cross_Au> I have too many GCC's |
12:48:43 | FromDiscord | <Southern_Cross_Au> https://media.discordapp.net/attachments/371759389889003532/917034750298951690/unknown.png |
12:54:10 | FromDiscord | <dain> sent a code paste, see https://play.nim-lang.org/#ix=3H5c |
12:54:37 | FromDiscord | <dain> how do I extract a subtuple from `foo`, with the value `("brown", "fox", "jumps")` |
12:54:37 | kobi | i think the one with x86_64-w64-mingw32-gcc.exe from C:/nim-1.6.0/dist/bin |
12:55:28 | FromDiscord | <Rika> In reply to @dain "why can't I index": because they can be of different types, and how would that work |
12:55:41 | FromDiscord | <dain> why would that be a problem? |
12:55:45 | FromDiscord | <dain> i want a tuple as an output |
12:55:46 | FromDiscord | <dain> not an array |
12:55:52 | FromDiscord | <Rika> i guess there can be a `[]`(tuple, static range): tuple |
12:56:00 | FromDiscord | <Rika> but i dont know if its currently possible |
12:56:08 | FromDiscord | <Rika> i mean without a macro |
12:56:24 | FromDiscord | <Rika> it probably is |
12:56:46 | PMunch | You could easily write a macro that does [..] for tuples |
12:56:57 | PMunch | But nothing like that exists in the standard library afaik |
12:57:37 | kobi | usually when you return a tuple from a function, you do: let (a,b,c) = procThatReturnsATrio |
12:57:46 | kobi | or var (a,b,c).. |
12:58:25 | kobi | the more idiomatic way is to return a sequence or array if it's of the same type, or build a type and return that object |
13:00:18 | * | xet7 quit (Remote host closed the connection) |
13:00:51 | kobi | u can also access tuples with tupl[idx] |
13:01:19 | FromDiscord | <dain> I'm doing it for AOC, I'm getting tuples from `scan_tuple` where the first element is a bool for whether the parsing succeeded, and the rest of the elements are what I want. I want to be able to just get a tuple with the first element dropped. so ideally I would write:↵↵`list_of_strings.map(x => x.scan_tuple(".....")[1..^1])` |
13:01:21 | kobi | like an array, but slice is not implemented for it. so u don't have the .. syntax that you opted to get |
13:01:32 | FromDiscord | <dain> but rn it's kind of awkward because I have to unpack it first into explicit variables |
13:02:25 | * | jjido joined #nim |
13:03:23 | kobi | i don't think it's awkward, just not a one-liner. a foreach loop is nice and readable imo. |
13:03:48 | FromDiscord | <dain> yeah I know, I'll probably do the for loop |
13:04:02 | kobi | can scan_tuple return a seq ? |
13:04:31 | kobi | or if u want, you can augment the stdlib with what u want. impl the slice operation for example |
13:04:50 | kobi | i am not sure it can work, but it's not hidden from your hands |
13:04:57 | FromDiscord | <dain> it has to return a tuple because the first item is always a boolean |
13:05:02 | FromDiscord | <dain> yeah I'll try writing a macro for it |
13:05:28 | FromDiscord | <dain> (edit) "it has to return a tuple because the first item is always a boolean ... " added "and the other items are not guaranteed to be of the same type" |
13:05:31 | kobi | you can do proc scan_tuple(x:string):(bool, seq[int]) |
13:05:51 | kobi | ah, are they strings which u can parse? |
13:06:03 | FromDiscord | <dain> yeah |
13:06:11 | kobi | Nim is not a dynamic language |
13:06:39 | kobi | u can likely use the json module to represent that |
13:07:02 | kobi | it's an object variant.. |
13:08:14 | kobi | but maybe it's an overkill. what happens if u stay with strings, until the moment u need to parse into a result? |
13:11:00 | FromDiscord | <dain> what do you mean> |
13:11:03 | FromDiscord | <dain> (edit) "mean>" => "mean?" |
13:11:39 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
13:14:29 | PMunch | Haven't had a look at todays AoC yet, but if you're not using the tuple unpacking attributes of scanTuple I think there are other tools that are more suited for parsing your input data |
13:23:35 | arkanoid | I'm experimenting nim-python interop with nimpy, but more generally I want to track down where I'm passing by copy or by reference. How can I get a proper view where I'm consuming time/memory? |
13:26:06 | kobi | Isn't it always by ref in python? |
13:27:53 | kobi | I want to run the same proc 4 times in parallel. They should run asyncly, and when they finish, continue execution. if I use waitFor, does it halt execution for all of them until the first one finishes? |
13:28:03 | FromDiscord | <Rika> python calls it "by name" afaik |
13:28:07 | FromDiscord | <Rika> or "by label" |
13:28:21 | kobi | asyncCheck, waitFor, and await.. when to use which? |
13:28:22 | FromDiscord | <Rika> waitFor is running as sync |
13:28:43 | kobi | ok. what is asyncCheck for? |
13:29:01 | FromDiscord | <Rika> await + basic error handling |
13:29:11 | FromDiscord | <Rika> for procs that do not return |
13:29:49 | FromDiscord | <Rika> if you want to do parallel you do `waitFor all([torun(), torun(), torun(), torun()])` afaik |
13:29:51 | kobi | I see. but it seems that if I want to store the future and run it later on, it doesn't work. |
13:29:59 | FromDiscord | <Rika> you can do that |
13:30:19 | FromDiscord | <Rika> `let temp = toRun(); echo waitFor temp` |
13:30:51 | kobi | so in my code it already runs on the assignment. |
13:31:29 | FromDiscord | <Rika> if you do not have any `await` in your async proc then there is nothing async in the proc |
13:31:34 | FromDiscord | <Rika> and it will run like sync |
13:31:43 | FromDiscord | <Rika> and immediately run on `()` |
13:32:05 | kobi | I am just new to this, that's all :-) |
13:32:13 | FromDiscord | <Rika> no thats fine |
13:35:50 | kobi | if I use withTimeout, the first is a future[bool] and to see if it failed, i use the original future ref right? |
13:36:03 | kobi | I mean, if timeout failed, i get the bool |
13:36:19 | kobi | but if the (wrapped?) future failed, just with .failed |
13:36:59 | kobi | maybe I am missing some guide or manual. sorry for the newbie questions |
13:37:12 | PMunch | You might be interested in this: https://peterme.net/asynchronous-programming-in-nim.html |
13:37:30 | kobi | cool, PMunch thanks |
13:37:46 | PMunch | Tries to go into detail about how async programming works, and how to use it in Nim |
13:39:01 | kobi | I am trying to build a general library for making download manager type applications. to have the convenience of queues. I am missing the async crucial mechanism, and when that is solved, the thing will be able to work. |
13:40:25 | kobi | so to do that I want to pass the "user" procs or callbacks actually. |
13:41:11 | kobi | on completion, on success, on failed, on timeout, the main work. all these are combined together to run as an async task. |
13:41:27 | kobi | maybe I'm starting big again |
13:41:30 | kobi | :/ |
13:41:41 | arkanoid | Rika, that was not what I was asking. I'm dealing with nim-python interop with nimpy. On the edge between the two languages you can pass data by marshalling/unmarshalling (so copy) or by raw buffer, but it means that the structure and management of if must be know in advance between the two sides. |
13:42:01 | FromDiscord | <Rika> wait what are you replying to |
13:43:32 | arkanoid | Well, let's reset the question and make it TL;DR; how can I track down where memory is consumed? |
13:43:54 | FromDiscord | <Rika> i dont remember answering that question |
13:44:04 | FromDiscord | <Rika> was it a few days ago |
13:44:20 | FromDiscord | <Rika> anyway there are memory profilers |
13:47:47 | FromDiscord | <dain> sent a code paste, see https://play.nim-lang.org/#ix=3H5v |
13:48:06 | kobi | Rika, what is wrong here: https://play.nim-lang.org/#ix=3H5u |
13:48:07 | FromDiscord | <Rika> theres also the relatively basic trackers in https://nim-lang.org/docs/gc.html |
13:48:14 | FromDiscord | <Rika> ill look one moment |
13:48:48 | kobi | it gets executed on assignment |
13:48:50 | FromDiscord | <Rika> In reply to @dain "why am I getting": what docs? can you show me so i can see? you're not supposed to call the enum values like that |
13:49:18 | FromDiscord | <Solitude> In reply to @dain "why am I getting": that doesnt look right. where is this in the docs? |
13:49:23 | FromDiscord | <dain> https://nim-lang.org/docs/macros.html#callsslashexpressions-tuple-constructors |
13:49:25 | FromDiscord | <dain> right here |
13:49:32 | FromDiscord | <Rika> kobi: that is correct, when you run an async proc at first it will run everything up to the first await call |
13:50:05 | FromDiscord | <Rika> then `await` will wait, and then run the next part of the code |
13:50:13 | FromDiscord | <Rika> (edit) "then `await` ... will" added "on the future" |
13:53:04 | kobi | so this is not what I want. |
13:53:36 | kobi | I just want to store it, not start to run it. |
13:53:38 | FromDiscord | <razzlom> Finally made my first nim program. |
13:53:50 | FromDiscord | <razzlom> Снимок экрана от 2021-12-05 16-53-15.png https://media.discordapp.net/attachments/371759389889003532/917051140116463626/2021-12-05_16-53-15.png |
13:54:12 | FromDiscord | <razzlom> It's just bunch of echoes, but... |
13:54:36 | FromDiscord | <konsumlamm> In reply to @dain "https://nim-lang.org/docs/macros.html#callsslashexp": those are examples of how the ASTs for tuple constructors look like, not code you can put in a macro |
13:55:00 | arkanoid | Rika, thanks |
13:55:39 | FromDiscord | <Rika> kobi: you cant store it without running the first portion of code (before the first await) |
13:56:03 | FromDiscord | <Rika> you can prolly "hack it" by doing `await sleepAsync(0)` at the start |
13:56:44 | FromDiscord | <Rika> i dont know why you want to do that though, doing it would not improve performance or runtime |
13:56:50 | FromDiscord | <Rika> i guess to prevent stale data? |
13:58:04 | kobi | hmm... so my only option is to wrap it all in a proc() = block? |
13:58:28 | kobi | well, I want to store it in a Task type, and later run those tasks. |
13:59:25 | FromDiscord | <dom96> Why don’t you store metadata about what you want to run instead? |
13:59:26 | kobi | but when I run them, I want it to be done in parallel. |
13:59:36 | kobi | hi dom |
13:59:48 | kobi | what do u mean? |
14:00:36 | FromDiscord | <dom96> I mean store the inputs to your function |
14:00:36 | FromDiscord | <Rika> instead of storing futures, store the parameters |
14:00:41 | FromDiscord | <Rika> then make the futures when you need them |
14:00:45 | FromDiscord | <dom96> Yeah |
14:01:20 | kobi | that's a very good idea. thank you. |
14:01:29 | kobi | do u have a suggestion of a general way to do that? |
14:01:45 | kobi | would I need to "pollute" all my code with some T generic? |
14:02:17 | kobi | (pollute because each usage also requires to mark the using proc with T) |
14:02:59 | PMunch | @dain, that part of the documentation is a bit confusing. Essentially those just show the data structure, it's not runnable code. You can do nnkTupleConstr.newTree(args, go, here) in order to generate a nnkTupleConstr for example. Another alternative is to use the `newX` procedures from the macros module to create them. You can use `dumpAstGen` on a block of code to get the code you need to put in a macro to generate that call. Or you can use `quote` from the |
14:02:59 | PMunch | macros module to generate these trees directly from Nim code. Another option is to use my macroutils module which will give you more or less the syntax you're already trying to use: https://github.com/PMunch/macroutils/ |
14:04:26 | FromDiscord | <Rika> you can try to use implicit generics if you do not like using explicit ones |
14:04:42 | FromDiscord | <Rika> or just use a proxy object that holds your parameters |
14:07:18 | kobi | I think I'll use inheritance for the Task type, Task[T], task[T1,T2] etc. |
14:07:50 | kobi | wait, no, i am not sure i am thinking straight. |
14:08:11 | FromDiscord | <tandy> is there a nim code formatter? |
14:08:27 | kobi | i'll need to experiment a little |
14:08:29 | FromDiscord | <dom96> kobi: I think you want to use object variants |
14:09:10 | kobi | dom96, but I can't use the same field names |
14:09:36 | FromDiscord | <Rika> tandy nimpretty |
14:09:37 | PMunch | @tandy, yes nimpretty |
14:10:01 | FromDiscord | <tandy> does vscode use it automatically? |
14:10:01 | PMunch | But depending on who you ask it's not really recommended to use it |
14:10:15 | FromDiscord | <Rika> no it does not |
14:10:29 | FromDiscord | <tandy> hmm |
14:10:40 | FromDiscord | <tandy> why not? |
14:10:49 | PMunch | It has an unfortunate tendency to break code |
14:11:13 | kobi | i think i'll just start with plain objects and casting |
14:11:15 | FromDiscord | <Solitude> In reply to @tandy "why not?": you dont need it, your code is fine |
14:11:48 | kobi | PMunch, it doesn't break code if you define --indent:2 |
14:11:53 | FromDiscord | <tandy> i ran it on my test suite and no breaks \:) |
14:12:21 | kobi | but maybe u have more advanced usages with macros and all |
14:12:28 | PMunch | Oh yeah, I didn't say that it always breaks code. But it has been known to sometimes break code, which isn't exactly great |
14:13:19 | kobi | I only found it get confused when the indent was not specified. it would sometimes double the spaces, for no apparent reason |
14:15:21 | Zevv | amazing how much more I enjoy PMunch sessions when his fire is lit |
14:15:46 | PMunch | Haha, guess it's time to throw another log on the fire then |
14:16:07 | PMunch | I'm about to stream day 5, and there's only embers left at the moment |
14:16:20 | Zevv | there you go, light up indeed :) |
14:17:09 | Zevv | I planned not to bother with AOC this year, but still it's fun to do |
14:17:17 | Zevv | I'm not doing nim this year tho, sorry for that :) |
14:17:53 | PMunch | They are quite fun :) |
14:18:05 | PMunch | What language has the pleasure this year? |
14:18:09 | Zevv | elixir |
14:18:33 | FromDiscord | <dain> In reply to @PMunch "<@225449938258100225>, that part of": ah thank you |
14:18:39 | PMunch | Hmm, maybe I should record my fireplace to use as the "Stream is starting soon" screen instead of the test image |
14:18:53 | FromDiscord | <dain> btw what is the type for expressions like `1..10` |
14:18:55 | PMunch | Aha, elixir, I've been meaning to look into that a bit more |
14:19:07 | FromDiscord | <tandy> hmm i used nimprety but it didnt realy help my long line problem haha |
14:19:11 | FromDiscord | <Rika> slice |
14:19:12 | FromDiscord | <dain> i did `echo typeof(1..10` and it just gave `int` which doesn't seem right |
14:19:13 | FromDiscord | <Rika> or hslice |
14:19:16 | PMunch | !eval echo typeof(1..10) |
14:19:18 | NimBot | int |
14:19:25 | PMunch | Huh, that is strange indeed |
14:19:30 | FromDiscord | <dain> (edit) "typeof(1..10`" => "typeof(1..10)`" |
14:19:36 | PMunch | It should be a HSlice I believe |
14:19:57 | Zevv | PMunch: I love it big time. there's smelly nooks and crannies of course, but the sheer solidity of the OTP and utter ease of multithreading and clustering is amazing. |
14:19:57 | FromDiscord | <tandy> oh wait it did, nvm |
14:20:45 | Zevv | and it can be pretty consise. https://raw.githubusercontent.com/zevv/aoc2021/master/lib/day05.ex |
14:20:54 | * | arkurious joined #nim |
14:22:47 | FromDiscord | <Solitude> !eval echo typeof(1..10, typeOfProc) |
14:22:49 | NimBot | HSlice[system.int, system.int] |
14:23:03 | FromDiscord | <Solitude> typeof defaults to iterators |
14:23:11 | PMunch | @Zevv, I can't be looking at day 5 before I've solved it :P |
14:23:30 | Zevv | fair enough. you can squint to just see the shape of it then :) |
14:23:32 | Zevv | i'll allow it |
14:23:47 | PMunch | I do wish Nim had a more solid multithreading story. Hopefully one day |
14:24:27 | Zevv | one day |
14:25:06 | PMunch | Stream is live! https://www.twitch.tv/pmunche |
14:25:20 | qwr | currently its still a bit ahead of ocaml in threading ;) |
14:25:32 | FromDiscord | <tandy> nvm, it broke my code lmao |
14:40:24 | kobi | dom96, what do u think: https://play.nim-lang.org/#ix=3H5J |
14:40:48 | kobi | "waitFor all" does very similar to what I want, |
14:42:13 | FromDiscord | <dain> sent a code paste, see https://play.nim-lang.org/#ix=3H5K |
14:43:11 | FromDiscord | <dain> sent a code paste, see https://play.nim-lang.org/#ix=3H5L |
14:45:28 | FromDiscord | <Yardanico> Because i is outside the quote do |
14:45:39 | FromDiscord | <Yardanico> you need to enclose it in backticks as well |
14:45:59 | FromDiscord | <dain> oooh |
14:46:10 | FromDiscord | <dain> i tried that way back and it didnt work either |
14:46:22 | FromDiscord | <dain> must have had another mistake that got fixed in the meantime and i didnt realise |
14:46:41 | FromDiscord | <dain> okei it works now thank you |
15:00:59 | * | Onionhammer joined #nim |
15:01:57 | * | xet7 joined #nim |
15:02:41 | * | kobi quit (Quit: Leaving) |
15:28:32 | * | notchris quit (Ping timeout: 240 seconds) |
15:29:49 | * | notchris joined #nim |
15:30:37 | * | src joined #nim |
15:32:27 | Zevv | PMunch: "sparse map" is the word |
16:06:30 | FromDiscord | <dain> sent a code paste, see https://play.nim-lang.org/#ix=3H6r |
16:08:29 | * | xet7 quit (Remote host closed the connection) |
16:12:48 | FromDiscord | <claude> that is probably a bug, if you are trying to index tuples with a slice i found this code which is one implementation https://play.nim-lang.org/#ix=3H6t |
16:14:26 | FromDiscord | <claude> it seems to be because of the `when i is BackwardsIndex` |
16:16:10 | FromDiscord | <claude> changing it to `typeof(i) is BackwardsIndex` works |
16:17:06 | FromDiscord | <Solitude> or making foo a proc works too |
16:18:58 | FromDiscord | <dain> In reply to @claude "changing it to `typeof(i)": thank you |
16:29:13 | FromDiscord | <dain> In reply to @claude "that is probably a": what does the `{.inline.}` pragma do |
16:29:41 | FromDiscord | <claude> its just an optimization passed to the C compiler |
16:31:07 | FromDiscord | <claude> if you set small enough procs to be inline the C compiler can directly embed them into the code where they're called |
16:34:10 | FromDiscord | <dain> ah |
16:34:27 | FromDiscord | <dain> so what's the reason for defining a macro inside a `func` and then immediately invoking the macro |
16:35:46 | FromDiscord | <dain> i dont really get what's happening there |
16:36:41 | FromDiscord | <dain> how does the compiler figure out the return type of the `[]` defined on e.g. line 8 |
16:37:03 | FromDiscord | <dain> or does it not have to because it's inlined? |
16:42:57 | FromDiscord | <Solitude> In reply to @dain "how does the compiler": it just looks at the type of returned value, if its the same type in all branches |
16:44:08 | FromDiscord | <Solitude> In reply to @dain "so what's the reason": because the macro is only relevant to this function, so it doesnt pollute outer namespace |
16:45:06 | FromDiscord | <dain> does that have any runtime overhead |
16:45:13 | FromDiscord | <Solitude> no |
16:46:39 | * | neurocyte0132889 joined #nim |
16:46:39 | * | neurocyte0132889 quit (Changing host) |
16:46:39 | * | neurocyte0132889 joined #nim |
16:47:00 | FromDiscord | <dain> In reply to @claude "that is probably a": btw where did you find this, is there a discussion thread I can read? |
17:05:48 | * | smvg joined #nim |
17:07:28 | smvg | is there a way of including #defines from a C header into Nim when interfacing with the language ? or do I need to add them manually in Nim ? |
17:20:11 | FromDiscord | <Schelz> Is there anyway that i can use nim with php ? |
17:20:26 | FromDiscord | <Schelz> (edit) "anyway" => "any way" |
17:37:27 | FromDiscord | <geekrelief> In reply to @smvg "is there a way": For the most part it's manual. I can't speak for other tooling, but I use nimterop and depending on the nature of the `#define` if it's a simple constant or can map to a call like expression then those can be handle kind of automatically with a little setup. But if the `#define` is like an inline function definition you have to manually convert it. |
17:38:52 | FromDiscord | <dain> sent a code paste, see https://play.nim-lang.org/#ix=3H6U |
17:40:21 | smvg | ok thanks for the info @geekrelief |
17:45:23 | FromDiscord | <geekrelief> sent a code paste, see https://play.nim-lang.org/#ix=3H6Y |
17:45:44 | FromDiscord | <geekrelief> maybe cause `len` is a magic? |
17:46:41 | * | jjido joined #nim |
17:48:28 | FromDiscord | <geekrelief> that works too |
17:48:30 | FromDiscord | <geekrelief> sent a code paste, see https://play.nim-lang.org/#ix=3H71 |
17:49:29 | FromDiscord | <geekrelief> sent a code paste, see https://play.nim-lang.org/#ix=3H72 |
17:50:20 | FromDiscord | <dain> sent a code paste, see https://play.nim-lang.org/#ix=3H73 |
17:57:01 | FromDiscord | <geekrelief> https://play.nim-lang.org/#ix=3H74 |
17:57:50 | FromDiscord | <geekrelief> If you were to implement this without sugar, I'm not sure you could do it without macros. |
17:58:32 | FromDiscord | <dain> thanks |
17:58:59 | FromDiscord | <dain> why doesnt my way work though? can you not have anonymous generic procs? |
17:59:55 | FromDiscord | <geekrelief> good question, I don't know off hand. Not something I ever experimented with but I'm curious now. |
18:02:59 | FromDiscord | <dain> sent a code paste, see https://play.nim-lang.org/#ix=3H77 |
18:04:39 | FromDiscord | <geekrelief> Weird it works on playground |
18:05:47 | FromDiscord | <geekrelief> the above link has the wrong code use this: https://play.nim-lang.org/#ix=3H78 |
18:05:53 | * | xet7 joined #nim |
18:05:54 | FromDiscord | <dain> okay it works when I do `as_func(len)` but breaks when I do `len.as_func` |
18:06:12 | FromDiscord | <dain> does UFCS not work on templates? |
18:06:14 | FromDiscord | <geekrelief> hmm how do you strikethrough on discord |
18:07:14 | FromDiscord | <the cws came hme> \~~like this~~ |
18:08:38 | FromDiscord | <geekrelief> thx |
18:08:42 | FromDiscord | <geekrelief> In reply to @dain "does UFCS not work": https://nim-lang.github.io/Nim/manual.html#templates-limitations-of-the-method-call-syntax |
18:08:52 | FromDiscord | <geekrelief> it does not work on templates |
18:09:06 | FromDiscord | <dain> aww that sucks |
18:14:00 | FromDiscord | <geekrelief> In reply to @dain "hmm .. I can": I don't think this version of `as_func` makes any sense. |
18:14:03 | * | src quit (Ping timeout: 256 seconds) |
18:14:49 | FromDiscord | <dain> how comes |
18:17:25 | FromDiscord | <Solitude> In reply to @dain "aww that sucks": it doesnt work in some edge cases, usually it works |
18:18:12 | FromDiscord | <dain> ya |
18:18:17 | FromDiscord | <dain> anyway thank you all for the help :) |
18:22:59 | FromDiscord | <geekrelief> In reply to @dain "how comes": Hmm maybe it's a compiler bug? |
18:23:48 | FromDiscord | <Fish-Face> sent a code paste, see https://play.nim-lang.org/#ix=3H7f |
18:24:02 | FromDiscord | <Fish-Face> (edit) |
18:26:07 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
18:30:14 | * | src joined #nim |
18:31:07 | FromDiscord | <geekrelief> In reply to @dain "how comes": I got this to work using `auto` which should be the same as a generic parameter type, but it doesn't work when I swap in `[T]` like `proc[T](y:T): auto = x(y)` https://play.nim-lang.org/#ix=3H7g |
18:31:38 | * | xet7 quit (Ping timeout: 252 seconds) |
18:34:11 | FromDiscord | <geekrelief> In reply to @Fish-Face "Can anyone spot why": code? |
18:34:22 | FromDiscord | <Zoom> It means that you're trying to pass a built in to procedure variable It's the same error you got earlier↵(@dain) |
18:34:51 | FromDiscord | <Zoom> I've asked in #internals about fixing the error msg but received no reply yet |
18:35:33 | arkanoid | damn, the more I bench python vs nim, the more I fear python is faster |
18:35:55 | FromDiscord | <Fish-Face> sent a code paste, see https://play.nim-lang.org/#ix=3H7k |
18:36:22 | FromDiscord | <Zoom> @dain\: the recommended workaround is either an alias for a builtin or an anonymous function |
18:37:07 | FromDiscord | <Zoom> See\: https://github.com/nim-lang/Nim/issues/2172#issuecomment-304609785 |
18:39:19 | FromDiscord | <Solitude> In reply to @Fish-Face "Can anyone spot why": https://nim-lang.org/docs/manual.html#types-open-arrays |
18:39:23 | FromDiscord | <Solitude> you cant nest openarrays |
18:40:14 | FromDiscord | <Fish-Face> oh rihgt |
18:40:16 | FromDiscord | <Fish-Face> right |
18:40:26 | FromDiscord | <Fish-Face> sounds like an opportunity at least for a better compile error |
18:45:42 | * | xet7 joined #nim |
18:48:01 | FromDiscord | <geekrelief> In reply to @arkanoid "damn, the more I": What's the benchmark doing? |
18:50:46 | * | smvg quit (Remote host closed the connection) |
18:59:39 | arkanoid | geekrelief: reverse a string. pystr[::-1] seems way faster than unicode.reversed |
19:00:08 | arkanoid | what's the fastest way to reverse a string in nim? |
19:00:30 | FromDiscord | <Fish-Face> a C string or a unicode string... |
19:00:38 | arkanoid | I know that python str are unicode so nim's unicode.reversed should be appropriate |
19:01:44 | FromDiscord | <Fish-Face> how do you filter an iterator? e.g. I want to do `table.values.filterIt(...)` |
19:02:38 | arkanoid | Fish-Face, you can use sequtils but if you have to chain more than one transformation is faster if you use zero-functional |
19:02:38 | * | xet7 quit (Remote host closed the connection) |
19:03:07 | FromDiscord | <Fish-Face> I want to chain a `foldl` but I don't care too much about speed |
19:03:27 | FromDiscord | <Fish-Face> I care more about the syntax not being ugly |
19:05:11 | FromDiscord | <Fish-Face> arkanoid, can you expand on "use sequtils"? `filterIt` is in that module |
19:05:55 | FromDiscord | <Fish-Face> (the above expression does not compile, because; it fails with `undeclared field: 'values'` because values is an iterator |
19:05:58 | FromDiscord | <Fish-Face> (edit) "iterator" => "iterator)" |
19:07:33 | FromDiscord | <Zoom> You don't chain iterators in Nim, unfortunately. I use zero\_functional for this↵(@Fish-Face) |
19:12:29 | * | jjido joined #nim |
19:12:57 | FromDiscord | <Fish-Face> bleh 😦 |
19:13:05 | FromDiscord | <Fish-Face> maybe I will check it out |
19:13:24 | FromDiscord | <Zoom> From what I'm seeing ZF is a bit fragile, especially if you start using openArrays. But it gets me 80% of the way |
19:16:16 | arkanoid | Zoom are you sure you can't chain iterator in latest nim? |
19:16:26 | arkanoid | Zoom I'm quite sure you can, let me try |
19:17:19 | NimEventer | New thread by Geekrelief: Understanding error with generic anonymous vs auto, see https://forum.nim-lang.org/t/8680 |
19:17:23 | FromDiscord | <Zoom> If I remember correctly, the only thing which take iterable for now is `toSeq`. |
19:18:57 | FromDiscord | <Zoom> Or wait, it works |
19:21:16 | FromDiscord | <Zoom> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/917130090125623337): You ~~don't~~ can chain iterators in Nim, but it's very limited, unfortunately. I use zero\_functional for this |
19:21:51 | arkanoid | actually I'm failing with the most trivial example |
19:22:08 | arkanoid | I step on this quite frequently. Sometimes I feel it's working, sometimes is not |
19:24:11 | FromDiscord | <Zoom> This is exactly my experience |
19:25:36 | arkanoid | for example "let myList = countup(0, 1000).filterIt(it mod 2 == 0)" doesn't compile |
19:28:00 | PMunch | Might be a iterator vs. closure iterator thing |
19:28:54 | FromDiscord | <Solitude> In reply to @arkanoid "for example "let myList": because filterIt works on an openArray, not iterator |
19:31:20 | arkanoid | now I am even more confused. I'm quite sure I've been using filterIt with my surprise on an interator somewhere, let me ripgrep my nim playground |
19:31:26 | FromDiscord | <Zoom> This is the main issue. Everything worked on sequences (now at least some openArrays are used) and produced a ton of intermediate collections. |
19:33:21 | arkanoid | well, openArrays are still non-lazy things |
19:33:40 | arkanoid | so to unleash the iterator power you need zero functional anyway |
19:34:39 | FromDiscord | <dain> In reply to @geekrelief "I got this to": huh I didn't even know you could use `auto` as an argument parameter, i thought it was only for return types |
19:35:50 | FromDiscord | <geekrelief> me neither. 🙂 I just read the docs and experimented |
19:37:56 | FromDiscord | <geekrelief> In my current work I don't deal with generics or auto at all, and I wonder if that's to my detriment because I rely on templates and macros a lot. |
19:39:08 | arkanoid | according to my benchmarks nim unicode.reversed in 10x slower than python |
19:39:44 | FromDiscord | <ynfle (ynfle)> @arkanoid are you using `-d:release`? |
19:42:07 | arkanoid | ynfle: have a look at the last comment in https://github.com/yglukhov/nimpy/issues/243 (just posted) |
20:04:58 | arkanoid | I'm quite surprised that there's not a string reverse function in stdlib, is there a reason for this? |
20:05:46 | FromDiscord | <Solitude> In reply to @arkanoid "I'm quite surprised that": https://nim-lang.org/docs/algorithm.html#reverse%2CopenArray%5BT%5D |
20:06:56 | arkanoid | Solitude, the inplace one might do it, but `reversed` returns a seq[char] instead of a string |
20:08:47 | FromDiscord | <Solitude> ye, probably someone faced a dilemma is it should go into strutils or in algorithm |
20:11:11 | FromDiscord | <dain> In reply to @arkanoid "I'm quite surprised that": https://qntm.org/trick |
20:12:31 | FromDiscord | <ynfle (ynfle)> @arkanoid have you test on the same string directly in nim itself without out nimpy? for `-d:danger` I got 0.042 ms |
20:12:39 | arkanoid | dain: https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/unicode.nim#L843 |
20:15:17 | FromDiscord | <dain> omg |
20:17:20 | arkanoid | dain, the nim algorith might not be exact, but here what I'm benchmarking is pythons [::-1] vs nim unicode.reversed |
20:17:50 | FromDiscord | <ynfle (ynfle)> @arkanoid did you try in nim directly? |
20:19:21 | arkanoid | ynfle writing the benchmark in such a way it reads a unicode text file instead, so that I can use it independently |
20:19:39 | FromDiscord | <ynfle (ynfle)> Ya |
20:19:53 | FromDiscord | <ynfle (ynfle)> Maybe converting to nim stuff is taking the time |
20:19:57 | FromDiscord | <ynfle (ynfle)> I don't know |
20:20:31 | FromDiscord | <ynfle (ynfle)> I just got much better results when doing it in nim natively (ie. reading in a file from the creation method that you had in that github issue comment) |
20:21:48 | arkanoid | sure but the problem I'm trying to solve is if it's worth or not switch my project from python to nim, but afaik interop is slow, so it depends on the frequency of calls |
20:22:09 | arkanoid | basically I'm trying to understand if zero-copy interop is possible or not and on which types |
20:23:04 | arkanoid | sadly scientific tools on python are strong, and I can't just dump them and rewrite in nim. Fast interop is the only way |
20:23:44 | FromDiscord | <ynfle (ynfle)> Just curious, which tools |
20:24:21 | arkanoid | scipy stack in general, and also scikit |
20:24:51 | FromDiscord | <ynfle (ynfle)> But I think your claim that unicode reversal in nim is 10x slower than python is wrong. And if it's true, it's not evident from the code in the issue |
20:24:57 | FromDiscord | <ynfle (ynfle)> Not machine learning stuff |
20:25:10 | FromDiscord | <ynfle (ynfle)> Which stuff in scipy? |
20:25:15 | FromDiscord | <ynfle (ynfle)> For your project |
20:25:49 | arkanoid | sure, but what I'm trying to get is low cost interop. What I expose in that issue is that there's no zero-copy option |
20:26:30 | arkanoid | ynfle, just thinkg about pandas manipulation, or xarray ones |
20:32:41 | arkanoid | this modules exposes numpy array <-> arraymancer Tensor interop: https://github.com/SciNim/scinim/blob/main/tests/tnumpyarrays.nim, but this is just something if you have to deal with large matrices. As soon as you have to deal with a table than contains a string col, interop stops |
20:33:15 | arkanoid | so scinim is for crunching numbers, not handling datasets |
20:37:53 | * | filcuc_ joined #nim |
20:43:46 | arkanoid | I mean this https://github.com/SciNim/scinim/issues/7 |
20:44:01 | FromDiscord | <dain> more generic proc confusion. what am I doing wrong here? https://play.nim-lang.org/#ix=3H7Y↵I'm trying to make a converter from the python style `key` method of sorting to how nim does it with a `cmp` function |
20:45:37 | FromDiscord | <dain> sent a code paste, see https://play.nim-lang.org/#ix=3H7Z |
20:46:14 | FromDiscord | <vindaar> it refers to the procedure and not the `int`. That the procedure is a closure |
20:47:35 | FromDiscord | <ynfle (ynfle)> You don't need 2 generics because you know the key proc has to return int |
20:47:39 | FromDiscord | <ynfle (ynfle)> https://play.nim-lang.org/#ix=3H81 |
20:48:05 | FromDiscord | <ynfle (ynfle)> @dain try this ☝ |
20:48:05 | FromDiscord | <dain> the `key` proc does not have to return int |
20:49:15 | FromDiscord | <ynfle (ynfle)> Then you switched the generics https://play.nim-lang.org/#ix=3H83 |
20:49:20 | FromDiscord | <ynfle (ynfle)> This works |
20:49:27 | FromDiscord | <dain> yes you're right |
20:49:36 | FromDiscord | <dain> i figured it out at the same time, i needed `T` instead of `U` in the inner proc |
20:50:52 | FromDiscord | <ynfle (ynfle)> Great |
20:54:04 | FromDiscord | <dain> sent a code paste, see https://play.nim-lang.org/#ix=3H86 |
20:54:18 | FromDiscord | <ynfle (ynfle)> Can you post the whole code? |
20:55:27 | FromDiscord | <dain> In reply to @ynfle (ynfle) "Can you post the": https://play.nim-lang.org/#ix=3H88 it's the same as before except the final line uses the `=>` sugar |
20:55:51 | FromDiscord | <ynfle (ynfle)> Ok |
20:56:04 | FromDiscord | <dain> oh wait hold on, the generic is still wrong |
20:56:10 | FromDiscord | <ynfle (ynfle)> too many generics I think |
20:57:03 | FromDiscord | <pyautogui> How is IO intended to be done with --mm:none? I am trying to use my aoc solution with --mm:none. Should I {.importc.} printf or what? |
20:58:10 | FromDiscord | <dain> In reply to @ynfle (ynfle) "too many generics I": fixed version https://play.nim-lang.org/#ix=3H8a |
20:58:29 | FromDiscord | <dain> the second-to-last line works, the last line doesn't |
20:58:57 | FromDiscord | <dain> but conceptually both of the functions are doing the same thing |
20:59:35 | FromDiscord | <ynfle (ynfle)> @pyautogui why no mm? |
21:00:18 | FromDiscord | <ynfle (ynfle)> @dain it works if you specify the type https://play.nim-lang.org/#ix=3H8c |
21:00:26 | FromDiscord | <ynfle (ynfle)> Probably too many generics. |
21:01:26 | FromDiscord | <pyautogui> For speed. |
21:01:32 | FromDiscord | <ynfle (ynfle)> Many open an issue on https://github.com/nim-lang/Nim |
21:01:47 | FromDiscord | <ynfle (ynfle)> Have you tried `--gc:arc` or `--gc:orc`? |
21:02:04 | FromDiscord | <ynfle (ynfle)> Are you using `-d:release` is your solution too slow? |
21:02:15 | FromDiscord | <pyautogui> Yes. I want the maximum of speed; --gc:arc is good, and I have all optimization on. |
21:03:14 | FromDiscord | <pyautogui> (edit) "Yes. I ... wantI" added "just" | "justwant the maximum of speed; --gc:arc is good, and I have all optimization on. ... " added "I would never use --mm:none in any sort of serious project." |
21:03:55 | FromDiscord | <pyautogui> I guess I will just {importc} printf. |
21:04:15 | FromDiscord | <dain> In reply to @ynfle (ynfle) "@dain it works if": thank you, is this a bug or expected behavior? |
21:04:24 | FromDiscord | <dain> i.e. that it can't infer that `x` is a string |
21:04:41 | FromDiscord | <dain> oh wait nvm i saw your other message |
21:06:32 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
21:26:51 | * | jjido joined #nim |
21:27:19 | FromDiscord | <retkid> i would like the option to turn the gcc off and do manual memory allocation |
21:27:49 | FromDiscord | <retkid> In reply to @pyautogui "Yes. I just want": -d:danger is a good place to start. Then start passing gcc settings over |
21:28:00 | FromDiscord | <retkid> make sure you have the loggers and debuggers off |
21:28:05 | FromDiscord | <retkid> and then you should start optimizing the code |
21:28:36 | FromDiscord | <retkid> all else fails, port over to C |
21:28:54 | FromDiscord | <retkid> (edit) "C" => "or use inline ASM" |
21:28:59 | FromDiscord | <retkid> (edit) "ASM" => "ASM, which is a thing in nim" |
21:29:05 | FromDiscord | <retkid> (edit) "all else fails, port over to ... or" added " C" |
21:29:50 | FromDiscord | <retkid> but before I'd do asm Id probably try to use Fortran for floating point math |
21:30:45 | FromDiscord | <retkid> iirc you also use --asm to compile to ASM code but idk how you can view it |
21:30:55 | FromDiscord | <retkid> if you can view it you can start looking for optimizations in the code itself |
21:31:51 | FromDiscord | <retkid> this is Nim's "official" priority list for optimizations |
21:32:10 | FromDiscord | <retkid> sent a long message, see http://ix.io/3H8h |
21:33:28 | FromDiscord | <Elegantbeef> If you want to have no memory manager do `--gc:non` |
21:33:37 | FromDiscord | <retkid> yes but you cant cull vars |
21:33:44 | FromDiscord | <Elegantbeef> What? |
21:34:02 | FromDiscord | <retkid> you cant remove variables from memory space? |
21:34:05 | FromDiscord | <retkid> unless im wrong |
21:34:26 | FromDiscord | <Elegantbeef> You can allocate/free memory |
21:35:05 | FromDiscord | <Elegantbeef> `var a = create(int, 300); dealloc(a)` |
21:35:20 | FromDiscord | <Elegantbeef> We just allocated 300 \ sizeof(int) bytes then freed them |
21:35:33 | FromDiscord | <retkid> hmmm |
21:35:43 | FromDiscord | <Elegantbeef> I dont even know what "removing variables from memory space" even means |
21:35:59 | FromDiscord | <retkid> how is the create proc separate from just the normal = |
21:36:00 | FromDiscord | <Elegantbeef> The stack will "free" variables on the stack as you move around, and thee heap is under your control |
21:36:25 | FromDiscord | <Elegantbeef> `create` uses the nim memory allocator and returns a `ptr int` |
21:36:48 | FromDiscord | <Elegantbeef> It's akin to doing `int a = malloc(sizeof(int) 300); free(a)` in C |
21:37:10 | FromDiscord | <pyautogui> @retkid Thanks |
21:37:11 | FromDiscord | <retkid> that makes sense |
21:37:33 | FromDiscord | <retkid> i forgot about dealloc and i tried using free(a) |
21:37:37 | FromDiscord | <retkid> (edit) "i forgot about dealloc and i tried using free(a) ... " added "but no proc" |
21:37:52 | FromDiscord | <Elegantbeef> Infact the implementation is `cast[ptr T](alloc0(sizeof(T) size))` |
21:38:32 | FromDiscord | <retkid> so, am i wrong to think that doing this would be pretty unstable given my interactions with channels? |
21:38:49 | FromDiscord | <Elegantbeef> If using arc/orc they have a shared heap so not really |
21:39:00 | FromDiscord | <Elegantbeef> Aslong as you properly guard you're fine |
21:39:13 | FromDiscord | <retkid> properly guard? |
21:39:29 | FromDiscord | <Elegantbeef> Dont allow race conditions |
21:41:13 | FromDiscord | <pyautogui> --asm is broken on Mac, I do believe. |
21:41:23 | FromDiscord | <pyautogui> Is an issue open for that? |
21:42:03 | FromDiscord | <retkid> let me make sure thats right |
21:42:40 | FromDiscord | <retkid> yea thats the right command? |
21:42:56 | FromDiscord | <retkid> https://github.com/nim-lang/Nim/issues/17139 |
21:43:02 | * | noeontheend joined #nim |
21:43:27 | FromDiscord | <pyautogui> Got it. |
21:43:43 | FromDiscord | <pyautogui> Must have forgotten about it. |
21:43:48 | * | src_ joined #nim |
21:44:41 | * | filcuc_ quit (Ping timeout: 252 seconds) |
21:44:42 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
21:46:04 | FromDiscord | <retkid> In reply to @Elegantbeef "Dont allow race conditions": ah. Yea I think about that a lot in my code. I try not to order threaded things based upon insertion but keep a code with it, usually in a table and then sync |
21:46:26 | FromDiscord | <retkid> ie thread[1] = FlowVar[int] |
21:46:53 | * | src quit (Ping timeout: 252 seconds) |
21:51:07 | * | src_ quit (Quit: Leaving) |
21:55:03 | * | noeontheend quit (Quit: noeontheend) |
21:55:16 | * | noeontheend joined #nim |
22:04:36 | * | jjido joined #nim |
22:06:58 | * | PMunch quit (Quit: leaving) |
22:08:20 | * | noeontheend quit (Read error: Connection reset by peer) |
22:08:42 | * | noeontheend joined #nim |
22:25:07 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
22:25:18 | * | noeontheend quit (Read error: Connection reset by peer) |
22:27:17 | * | noeontheend joined #nim |
22:50:20 | arkanoid | does trasformation from cstring to string perform a copy? |
22:50:35 | FromDiscord | <Solitude> yes |
22:50:45 | * | Onionhammer quit (Read error: Connection reset by peer) |
22:50:47 | arkanoid | and the other way around? |
22:50:53 | FromDiscord | <Solitude> no |
22:51:00 | arkanoid | thanks |
22:52:43 | * | Onionhammer joined #nim |
22:53:59 | * | noeontheend quit (Read error: Connection reset by peer) |
22:57:59 | * | noeontheend joined #nim |
22:59:54 | * | rockcavera joined #nim |
22:59:55 | * | rockcavera quit (Changing host) |
22:59:55 | * | rockcavera joined #nim |
23:06:03 | FromDiscord | <rinfz> why do the docs recommend using collect over filter, map? also, if I implement things like std::inclusive_scan from c++ is it better to use a template similar to stdlib stuff or just use a proc? |
23:06:07 | arkanoid | passing strings from python to nim is really a pain |
23:18:55 | nrds | <Prestige99> Real question, why do that in the first place instead of just using nim? |
23:28:33 | arkanoid | Prestige, pandas and handling tabular data |
23:28:55 | * | src joined #nim |
23:29:36 | nrds | <Prestige99> we def need more data analytics libs |
23:29:44 | FromDiscord | <Elegantbeef> @rinfz\: proc is preferred unless there is a reason to always inline |
23:35:48 | NimEventer | New thread by Gavr: Using if/case expressions as real expressions?, see https://forum.nim-lang.org/t/8681 |
23:35:58 | arkanoid | Prestige have a look at these results: https://play.nim-lang.org/#ix=3H8J I'm getting passing string being 22 to 98 time slower than python-to-python |
23:37:00 | nrds | <Prestige99> Idk anything about python really but I'm kind of not surprised |
23:46:49 | FromDiscord | <rinfz> Ok, thanks Elegantbeef |