<< 05-12-2021 >>

00:01:11*Onionhammer quit (Ping timeout: 252 seconds)
00:20:51FromDiscord<TryAngle> sent a code paste, see https://play.nim-lang.org/#ix=3H2e
00:21:08FromDiscord<Elegantbeef> "the variation"?
00:21:41FromDiscord<TryAngle> the enum variation↵e.g a, b and c
00:22:15FromDiscord<TryAngle> something like:↵assert A.c.toInt() == -8
00:22:16FromDiscord<Elegantbeef> I do not follow
00:22:21FromDiscord<Elegantbeef> ah
00:22:24FromDiscord<Elegantbeef> `ord`
00:22:38FromDiscord<Elegantbeef> I'd say "integer value" 😀
00:23:30FromDiscord<TryAngle> ah thanks 🙂
00:23:44FromDiscord<TryAngle> is there also a way to echo ints in hex format?
00:23:48FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3H2h
00:23:59FromDiscord<Elegantbeef> `import std/strutils` `toHex`
00:24:13FromDiscord<TryAngle> 👍
00:24:40FromDiscord<Elegantbeef> In Nim using holey enums is a detriment since it doesnt allow some features if the range is wide enough
00:24:48FromDiscord<el__maco> somewhat related question is there an easy way to echo floats with fewer decimal places
00:25:04FromDiscord<Elegantbeef> `import std/strutils` `formatFloat` i believe
00:25:53FromDiscord<Elegantbeef> You can also use `std/strformat` `fmt` with `{yourFloat: 2}` i believe
00:27:49FromDiscord<TryAngle> @ElegantBeef ok now a bit different, I'm using cint vor value now
00:27:57FromDiscord<TryAngle> but ord still returns int?
00:28:02FromDiscord<el__maco> ``import math,std/strutils↵echo PI.formatFloat(ffDecimal,2)``↵this seems to work, not sure about the second option
00:28:38FromDiscord<Elegantbeef> `import std/[math, strformat]; echo fmt"{PI: 2}"` 😛
00:28:48FromDiscord<Elegantbeef> Though that's not capable of being user defined or dynamic
00:29:09FromDiscord<Elegantbeef> You can just do `ord.cint`
00:30:10FromDiscord<TryAngle> thanks again 😄
00:32:25*lumo_e quit (Quit: Quit)
00:51:52FromDiscord<codic> ord always returns int
01:00:02FromDiscord<codic> sent a code paste, see https://play.nim-lang.org/#ix=3H2t
01:00:05FromDiscord<codic> why does this not build? using <https://github.com/nim-lang/cairo>
01:00:11FromDiscord<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:11FromDiscord<codic> nimble sucks I might just copy this to my project
01:11:14FromDiscord<codic> what am I doing wrong tho
01:11:48FromDiscord<Elegantbeef> What's the build error?
01:14:17FromDiscord<codic> cannot open file: cairo/cairoxlib
01:14:41FromDiscord<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:46FromDiscord<codic> which is definitely the most ideal
01:14:53FromDiscord<codic> cuz pure nim
01:15:17FromDiscord<Elegantbeef> it should be `cairoxlib` just cause of how the packaging works
01:15:27FromDiscord<Elegantbeef> not `cairo/cairoxlib`
01:16:06FromDiscord<codic> oh i see
01:16:13FromDiscord<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:17FromDiscord<codic> (x should be x11/x)
01:16:25FromDiscord<codic> so I'll just keep a local copy yea
01:17:25FromDiscord<Elegantbeef> I mean you can always fork it and maintain it for yourself
01:17:39FromDiscord<Elegantbeef> Then depend upon that instead of copying it into your project
01:18:05FromDiscord<codic> Yeah
01:21:04FromDiscord<codic> it works! https://media.discordapp.net/attachments/371759389889003532/916861694905561138/unknown.png
01:21:12FromDiscord<Elegantbeef> Congrats
01:37:31*PMunch quit (Quit: leaving)
01:41:42FromDiscord<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:28FromDiscord<codic> give up, cairo sucks
02:12:20FromDiscord<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:33FromDiscord<ynfle (ynfle)> Try https://github.com/treeform/pixie
02:16:39FromDiscord<codic> Indeed
02:16:50FromDiscord<codic> It took me 1/4 the time and I've already started making things, pixie is awesome
02:17:15FromDiscord<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:12FromDiscord<Klaufir> sent a code paste, see https://play.nim-lang.org/#ix=3H2G
02:19:36FromDiscord<codic> lol, and as I speak @treeform has released a new version of pixie
02:19:36FromDiscord<codic> epic
02:19:40FromDiscord<Elegantbeef> You should interpret it as a result
02:20:10FromDiscord<Elegantbeef> It's an expression so result = the expression
02:20:21FromDiscord<Elegantbeef> Really you can drop the `result =` assignment and it'd be the exact same logic
02:20:33FromDiscord<Klaufir> sent a code paste, see https://play.nim-lang.org/#ix=3H2H
02:20:45FromDiscord<codic> what is the syntax error
02:20:51FromDiscord<Elegantbeef> User defined code is not the same as macro generated in some cases
02:20:53FromDiscord<Klaufir> (edit) "https://play.nim-lang.org/#ix=3H2H" => "https://play.nim-lang.org/#ix=3H2I"
02:21:21FromDiscord<Klaufir> I get `test.nim(5, 5) Error: invalid indentation` for the above
02:22:27FromDiscord<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:33FromDiscord<codic> awesome!
02:22:50FromDiscord<treeform> Adding more examples is very welcome.
02:22:59FromDiscord<codic> yeah I spent too much time failing to get cairo to work properly, pixie is just wonderful
02:23:05FromDiscord<treeform> 🙂
02:23:07FromDiscord<codic> created an issue, will create a PR soon
02:23:52FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3H2K
02:24:14FromDiscord<Elegantbeef> If you look at the treeRepr of that you will see the right side of the `var name =` is a `StmtList`
02:24:46FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3H2L
02:24:47FromDiscord<Elegantbeef> Since all a statement list is really is a block of code
02:25:03FromDiscord<Klaufir> Ah, thank you
02:25:08FromDiscord<Klaufir> didn't know this was possible
02:25:34FromDiscord<Elegantbeef> `()` can be used fairly often to make Nim play nice
02:25:39*neurocyte0132889 quit (Ping timeout: 252 seconds)
02:25:46FromDiscord<codic> Indeed
02:25:46FromDiscord<Elegantbeef> Not that it's really suggested, but alas
02:25:57FromDiscord<codic> Yeah I wouldn't use result there
02:26:24FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3H2N
02:26:40FromDiscord<Elegantbeef> But yes there is 0 reason to use result unless you use the value after
02:26:56FromDiscord<Elegantbeef> Implicit results are preferred where usable
02:27:28FromDiscord<codic> that is valid??
02:27:33FromDiscord<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:37FromDiscord<Elegantbeef> Of course `=` is just an operator
02:28:54FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3H2O
02:30:13FromDiscord<Elegantbeef> Anywho the "invalid code" you're seeing is just rendering of macros back into readable code
02:30:28FromDiscord<Elegantbeef> stmtlists do not include `()` for readability reasons i assume
02:31:04FromDiscord<codic> pixie bouncy ball https://media.discordapp.net/attachments/371759389889003532/916879312601382942/unknown.png
02:31:08FromDiscord<codic> with x11 backend
02:31:16FromDiscord<Elegantbeef> Cause you very well might have nested stmtlists randomly
02:31:28FromDiscord<Elegantbeef> Nice, might have to use your reference code when i get back to goodwm
02:31:38FromDiscord<Elegantbeef> Right now i'm dumbly using sdl2 to display the image
02:33:15FromDiscord<codic> when goodwm is not good
02:33:38FromDiscord<Elegantbeef> It's never good
02:33:44FromDiscord<Elegantbeef> The name is a joke based on awesomeWm
02:35:34FromDiscord<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:14FromDiscord<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:28FromDiscord<treeform> Some things already work.
03:20:45FromDiscord<retkid> Ngl
03:21:02FromDiscord<retkid> Nim is my favorite Lang for single threaded
03:21:06FromDiscord<retkid> But
03:21:26FromDiscord<retkid> Otherwise, it’s a nightmare
03:22:16FromDiscord<retkid> It’s pretty disgusting
03:24:44FromDiscord<codic> that is an interesting way at looking at it
03:24:54FromDiscord<codic> nim's threads and async pretty cool
03:25:19FromDiscord<codic> In reply to @treeform "If you like X11": oh, so like serving the niche of x11
03:25:20FromDiscord<codic> (edit) "x11" => "sdl"
03:25:22FromDiscord<codic> very cool
03:25:27FromDiscord<codic> will try it out
03:25:29FromDiscord<retkid> asynchronous is good
03:25:37FromDiscord<retkid> But have you tried to use threads?
03:25:53FromDiscord<retkid> Not just read about it
03:26:03FromDiscord<retkid> Like actually write a ton of code in threads
03:26:06FromDiscord<Elegantbeef> I've used them
03:26:16FromDiscord<Elegantbeef> Channels + threads = happy me
03:26:24FromDiscord<retkid> Channels is cool
03:26:34FromDiscord<retkid> Until you’re afraid of it crashing randomly
03:26:37FromDiscord<retkid> Which happens
03:26:57FromDiscord<retkid> They are unstable currently
03:27:07FromDiscord<retkid> That’s basically my only critique
03:27:17FromDiscord<retkid> Without that, it would be easy
03:34:32FromDiscord<codic> I have used nim threads
03:34:46FromDiscord<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:41FromDiscord<exelotl> heyy, is there a way to reliably get the AST for a whole module?
03:54:46FromDiscord<Elegantbeef> Sadly nope
03:55:05FromDiscord<Elegantbeef> Well not in the same compiler context
03:56:42FromDiscord<exelotl> sent a code paste, see https://play.nim-lang.org/#ix=3H35
03:57:08FromDiscord<exelotl> (edit) "https://play.nim-lang.org/#ix=3H35" => "https://play.nim-lang.org/#ix=3H36"
03:57:13FromDiscord<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:59FromDiscord<exelotl> I guess I'll just have to do without symbols 🙃
03:58:24FromDiscord<Elegantbeef> Yea it sucks, was looking for something similar for nimscripter, sadly no API yet
03:59:09FromDiscord<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:35FromDiscord<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:42FromDiscord<codic> and actually 3) how can I find a font based on the font name?
04:10:20FromDiscord<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:22FromDiscord<treeform> 1) use rgba(123,123,123,123) constructor
04:13:44FromDiscord<treeform> 2) bit map fonts are not supported
04:14:10FromDiscord<treeform> Bit there are plants of .ttf pixel fonts if you want that pixel look
04:14:25FromDiscord<treeform> (edit) "Bit" => "But" | "plants" => "planty"
04:14:39FromDiscord<codic> Yeah I guess that's fair
04:15:03FromDiscord<codic> I might just use Xft and then use Pixie's stuff on top of that
04:15:20FromDiscord<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:10FromDiscord<codic> Got it
04:16:21FromDiscord<codic> Shouldn't be too hard to use fontconfig for that
04:16:23FromDiscord<treeform> 4) fonts bury can be many issues,
04:16:47FromDiscord<codic> bury?
04:17:26FromDiscord<Elegantbeef> blurry of course
04:17:37FromDiscord<codic> oh I did not realize that 🤦‍♂️
04:17:54FromDiscord<codic> It seems to not happen with Xft or cairo, only with Pixie
04:18:28FromDiscord<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:31FromDiscord<exelotl> at this rate I'm thinking I'll just have to parse the file myself :/
04:20:13FromDiscord<Rika> probably because pixie doesnt do font hinting
04:20:25FromDiscord<Rika> (and its a matter of preference as well)
04:20:36FromDiscord<Rika> i prefer "blurry fonts" since they look nicer to me
04:20:54FromDiscord<codic> Fair, they look terribly unreadable to my eyes
04:20:54FromDiscord<Elegantbeef> Yep exelotl that's the shame, i believe there is a PR that enables more information
04:21:00FromDiscord<codic> I think I'll just do Xft for text and overlay Pixie on top
04:21:57FromDiscord<Rika> if it follows system configs for fonts then 👍
04:22:33FromDiscord<codic> yeah xft follows fontconfig
04:23:09FromDiscord<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:41FromDiscord<codic> gradient titlebar with pixie https://media.discordapp.net/attachments/371759389889003532/916910677044629504/unknown.png
04:35:52FromDiscord<pyautogui> Any good JPEG lib
04:35:53FromDiscord<pyautogui> ?
04:36:24FromDiscord<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:00FromDiscord<codic> sent a code paste, see https://play.nim-lang.org/#ix=3H3h
04:38:10FromDiscord<codic> the gradient will only go so big
04:38:43FromDiscord<codic> https://media.discordapp.net/attachments/371759389889003532/916911440512843786/unknown.png
04:40:08FromDiscord<codic> (it won't go as big as attr.width.float32, but only after a certain point)
04:44:00nrds<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:23nrds<Prestige99> Hm maybe check issue trackers for the different sql libraries
04:49:39nrds<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:05FromDiscord<TryAngle> wait do procs have an implicit "result" variable?
06:01:21FromDiscord<Yardanico> yes
06:01:35FromDiscord<Yardanico> every proc with a return type has an implicit `result` variable
06:01:48FromDiscord<Yardanico> so you don't have to say `var result = 0; # get result; return result`
06:01:57FromDiscord<Yardanico> you just write `result = computation`
06:01:59FromDiscord<TryAngle> 😳
06:12:37*noeontheend quit (Ping timeout: 252 seconds)
06:58:51FromDiscord<Cypheriel> out of curiosity... is there better editor support than the one nim plugin on VSCode
06:59:02FromDiscord<Cypheriel> or are pretty much all the solutions this janky
06:59:50FromDiscord<Cypheriel> I feel like this plugin is contributing to my stress levels lol
07:00:20FromDiscord<Rika> They all depend on nimsuggest which is the main cause of problems
07:01:42FromDiscord<Cypheriel> I hear often something about some Nim LSP
07:01:48FromDiscord<Cypheriel> I'm not sure how it compares
07:02:06FromDiscord<Rika> Same issue
07:02:09FromDiscord<Rika> Depends on nimsuggest
07:02:34FromDiscord<Cypheriel> goes to show how much I know about these things
07:02:41FromDiscord<Cypheriel> (none, basically)
07:02:50FromDiscord<Rika> That’s fine
07:02:56FromDiscord<Rika> No one knows anything right off the bat
07:03:30FromDiscord<Cypheriel> I just wish I didn't feel like both me and my linter are incompetent lol
07:03:36FromDiscord<Cypheriel> I can't trust myself nor these suggestions
07:05:12FromDiscord<Rika> Dunno
07:05:29FromDiscord<Rika> I personally never really relied on suggestions being completely right
07:13:24FromDiscord<Cypheriel> Neither am I, but... that's not exactly preferable
07:21:13FromDiscord<Solitude> In reply to @Cypheriel "Neither am I, but...": trust yourself, dont let the machine tell you what to do.
07:22:20FromDiscord<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:28FromDiscord<Cypheriel> and a lot of things just do not act like I'd expect them
07:22:47FromDiscord<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:52FromDiscord<codic> What issues do you have with nimsuggest? it works pretty decently for me
07:22:58FromDiscord<codic> can you give an example?
07:23:19FromDiscord<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:40FromDiscord<Cypheriel> sometimes it just doesn't even work lol
07:24:12FromDiscord<Solitude> In reply to @Cypheriel "meanwhile, VSCode is telling": only trust compiler output about errors
07:24:22FromDiscord<Cypheriel> yeah, which I've begun to do
07:24:36FromDiscord<Cypheriel> but there's also the issue of sometimes there's absolutely no info about an error
07:24:54FromDiscord<Cypheriel> sometimes it's literally the equivalent of "Error: " and no info given
07:25:31FromDiscord<Solitude> damn, it do be like that sometimes
07:25:47FromDiscord<codic> weird, nimsuggest is pretty darn fast for me
07:26:04FromDiscord<Cypheriel> In reply to @codic "weird, nimsuggest is pretty": Perhaps it's a problem with VSCode's autosave
07:26:07FromDiscord<Cypheriel> but like
07:26:17FromDiscord<Cypheriel> I have to wait a good few seconds for the suggestions to be accurate
07:26:23FromDiscord<codic> weird
07:26:55FromDiscord<Cypheriel> things like this are quite weird as well https://media.discordapp.net/attachments/371759389889003532/916953767918829588/Screenshot_20211205_002642.png
07:27:07FromDiscord<Cypheriel> https://media.discordapp.net/attachments/371759389889003532/916953812416217089/Screenshot_20211205_002658.png
07:27:16FromDiscord<Cypheriel> like what on Earth is it doing there
07:28:22FromDiscord<Cypheriel> for reference, input and sample are defined on line 22-23
07:31:00FromDiscord<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:28FromDiscord<Solitude> yeah, you should regret it
07:31:46FromDiscord<Cypheriel> In reply to @Solitude "yeah, you should regret": hopefully for reasons other than preference >_>
08:16:57NimEventerNew 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:36kobihi
11:44:53kobia friend is having trouble connecting to the forum, who should i ask?
11:45:04kobiconnecting = registering
11:48:46FromDiscord<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:42FromDiscord<Southern_Cross_Au> hello
12:40:55FromDiscord<Southern_Cross_Au> looking for trouble shooting 😄
12:42:06kobishoot your trouble
12:42:57FromDiscord<Southern_Cross_Au> going though nim in action: Getting the following error
12:43:21FromDiscord<Southern_Cross_Au> https://media.discordapp.net/attachments/371759389889003532/917033399737253928/unknown.png
12:44:13kobido you have gcc installed? try typing gcc in the terminal
12:44:17FromDiscord<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:33FromDiscord<Southern_Cross_Au> In reply to @kobi "do you have gcc": yes
12:46:22kobiyou can see the gcc path there, with requested command not found.
12:46:48kobibut if it's in that location, maybe the error msg is hiding some other issue.
12:47:12FromDiscord<Southern_Cross_Au> I have to add the Gcc path ? ok will find it and add it
12:47:35kobiokay, cool
12:48:08kobibtw, u can use shortcuts like nim c -r yourfile.nim
12:48:32FromDiscord<Southern_Cross_Au> In reply to @kobi "btw, u can use": that was VSC doing 😄
12:48:40FromDiscord<Southern_Cross_Au> I have too many GCC's
12:48:43FromDiscord<Southern_Cross_Au> https://media.discordapp.net/attachments/371759389889003532/917034750298951690/unknown.png
12:54:10FromDiscord<dain> sent a code paste, see https://play.nim-lang.org/#ix=3H5c
12:54:37FromDiscord<dain> how do I extract a subtuple from `foo`, with the value `("brown", "fox", "jumps")`
12:54:37kobii think the one with x86_64-w64-mingw32-gcc.exe from C:/nim-1.6.0/dist/bin
12:55:28FromDiscord<Rika> In reply to @dain "why can't I index": because they can be of different types, and how would that work
12:55:41FromDiscord<dain> why would that be a problem?
12:55:45FromDiscord<dain> i want a tuple as an output
12:55:46FromDiscord<dain> not an array
12:55:52FromDiscord<Rika> i guess there can be a `[]`(tuple, static range): tuple
12:56:00FromDiscord<Rika> but i dont know if its currently possible
12:56:08FromDiscord<Rika> i mean without a macro
12:56:24FromDiscord<Rika> it probably is
12:56:46PMunchYou could easily write a macro that does [..] for tuples
12:56:57PMunchBut nothing like that exists in the standard library afaik
12:57:37kobiusually when you return a tuple from a function, you do: let (a,b,c) = procThatReturnsATrio
12:57:46kobior var (a,b,c)..
12:58:25kobithe 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:51kobiu can also access tuples with tupl[idx]
13:01:19FromDiscord<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:21kobilike an array, but slice is not implemented for it. so u don't have the .. syntax that you opted to get
13:01:32FromDiscord<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:23kobii don't think it's awkward, just not a one-liner. a foreach loop is nice and readable imo.
13:03:48FromDiscord<dain> yeah I know, I'll probably do the for loop
13:04:02kobican scan_tuple return a seq ?
13:04:31kobior if u want, you can augment the stdlib with what u want. impl the slice operation for example
13:04:50kobii am not sure it can work, but it's not hidden from your hands
13:04:57FromDiscord<dain> it has to return a tuple because the first item is always a boolean
13:05:02FromDiscord<dain> yeah I'll try writing a macro for it
13:05:28FromDiscord<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:31kobiyou can do proc scan_tuple(x:string):(bool, seq[int])
13:05:51kobiah, are they strings which u can parse?
13:06:03FromDiscord<dain> yeah
13:06:11kobiNim is not a dynamic language
13:06:39kobiu can likely use the json module to represent that
13:07:02kobiit's an object variant..
13:08:14kobibut maybe it's an overkill. what happens if u stay with strings, until the moment u need to parse into a result?
13:11:00FromDiscord<dain> what do you mean>
13:11:03FromDiscord<dain> (edit) "mean>" => "mean?"
13:11:39*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
13:14:29PMunchHaven'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:35arkanoidI'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:06kobiIsn't it always by ref in python?
13:27:53kobiI 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:03FromDiscord<Rika> python calls it "by name" afaik
13:28:07FromDiscord<Rika> or "by label"
13:28:21kobiasyncCheck, waitFor, and await.. when to use which?
13:28:22FromDiscord<Rika> waitFor is running as sync
13:28:43kobiok. what is asyncCheck for?
13:29:01FromDiscord<Rika> await + basic error handling
13:29:11FromDiscord<Rika> for procs that do not return
13:29:49FromDiscord<Rika> if you want to do parallel you do `waitFor all([torun(), torun(), torun(), torun()])` afaik
13:29:51kobiI see. but it seems that if I want to store the future and run it later on, it doesn't work.
13:29:59FromDiscord<Rika> you can do that
13:30:19FromDiscord<Rika> `let temp = toRun(); echo waitFor temp`
13:30:51kobiso in my code it already runs on the assignment.
13:31:29FromDiscord<Rika> if you do not have any `await` in your async proc then there is nothing async in the proc
13:31:34FromDiscord<Rika> and it will run like sync
13:31:43FromDiscord<Rika> and immediately run on `()`
13:32:05kobiI am just new to this, that's all :-)
13:32:13FromDiscord<Rika> no thats fine
13:35:50kobiif I use withTimeout, the first is a future[bool] and to see if it failed, i use the original future ref right?
13:36:03kobiI mean, if timeout failed, i get the bool
13:36:19kobibut if the (wrapped?) future failed, just with .failed
13:36:59kobimaybe I am missing some guide or manual. sorry for the newbie questions
13:37:12PMunchYou might be interested in this: https://peterme.net/asynchronous-programming-in-nim.html
13:37:30kobicool, PMunch thanks
13:37:46PMunchTries to go into detail about how async programming works, and how to use it in Nim
13:39:01kobiI 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:25kobiso to do that I want to pass the "user" procs or callbacks actually.
13:41:11kobion completion, on success, on failed, on timeout, the main work. all these are combined together to run as an async task.
13:41:27kobimaybe I'm starting big again
13:41:30kobi:/
13:41:41arkanoidRika, 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:01FromDiscord<Rika> wait what are you replying to
13:43:32arkanoidWell, let's reset the question and make it TL;DR; how can I track down where memory is consumed?
13:43:54FromDiscord<Rika> i dont remember answering that question
13:44:04FromDiscord<Rika> was it a few days ago
13:44:20FromDiscord<Rika> anyway there are memory profilers
13:47:47FromDiscord<dain> sent a code paste, see https://play.nim-lang.org/#ix=3H5v
13:48:06kobiRika, what is wrong here: https://play.nim-lang.org/#ix=3H5u
13:48:07FromDiscord<Rika> theres also the relatively basic trackers in https://nim-lang.org/docs/gc.html
13:48:14FromDiscord<Rika> ill look one moment
13:48:48kobiit gets executed on assignment
13:48:50FromDiscord<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:18FromDiscord<Solitude> In reply to @dain "why am I getting": that doesnt look right. where is this in the docs?
13:49:23FromDiscord<dain> https://nim-lang.org/docs/macros.html#callsslashexpressions-tuple-constructors
13:49:25FromDiscord<dain> right here
13:49:32FromDiscord<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:05FromDiscord<Rika> then `await` will wait, and then run the next part of the code
13:50:13FromDiscord<Rika> (edit) "then `await` ... will" added "on the future"
13:53:04kobiso this is not what I want.
13:53:36kobiI just want to store it, not start to run it.
13:53:38FromDiscord<razzlom> Finally made my first nim program.
13:53:50FromDiscord<razzlom> Снимок экрана от 2021-12-05 16-53-15.png https://media.discordapp.net/attachments/371759389889003532/917051140116463626/2021-12-05_16-53-15.png
13:54:12FromDiscord<razzlom> It's just bunch of echoes, but...
13:54:36FromDiscord<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:00arkanoidRika, thanks
13:55:39FromDiscord<Rika> kobi: you cant store it without running the first portion of code (before the first await)
13:56:03FromDiscord<Rika> you can prolly "hack it" by doing `await sleepAsync(0)` at the start
13:56:44FromDiscord<Rika> i dont know why you want to do that though, doing it would not improve performance or runtime
13:56:50FromDiscord<Rika> i guess to prevent stale data?
13:58:04kobihmm... so my only option is to wrap it all in a proc() = block?
13:58:28kobiwell, I want to store it in a Task type, and later run those tasks.
13:59:25FromDiscord<dom96> Why don’t you store metadata about what you want to run instead?
13:59:26kobibut when I run them, I want it to be done in parallel.
13:59:36kobihi dom
13:59:48kobiwhat do u mean?
14:00:36FromDiscord<dom96> I mean store the inputs to your function
14:00:36FromDiscord<Rika> instead of storing futures, store the parameters
14:00:41FromDiscord<Rika> then make the futures when you need them
14:00:45FromDiscord<dom96> Yeah
14:01:20kobithat's a very good idea. thank you.
14:01:29kobido u have a suggestion of a general way to do that?
14:01:45kobiwould I need to "pollute" all my code with some T generic?
14:02:17kobi(pollute because each usage also requires to mark the using proc with T)
14:02:59PMunch@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:59PMunchmacros 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:26FromDiscord<Rika> you can try to use implicit generics if you do not like using explicit ones
14:04:42FromDiscord<Rika> or just use a proxy object that holds your parameters
14:07:18kobiI think I'll use inheritance for the Task type, Task[T], task[T1,T2] etc.
14:07:50kobiwait, no, i am not sure i am thinking straight.
14:08:11FromDiscord<tandy> is there a nim code formatter?
14:08:27kobii'll need to experiment a little
14:08:29FromDiscord<dom96> kobi: I think you want to use object variants
14:09:10kobidom96, but I can't use the same field names
14:09:36FromDiscord<Rika> tandy nimpretty
14:09:37PMunch@tandy, yes nimpretty
14:10:01FromDiscord<tandy> does vscode use it automatically?
14:10:01PMunchBut depending on who you ask it's not really recommended to use it
14:10:15FromDiscord<Rika> no it does not
14:10:29FromDiscord<tandy> hmm
14:10:40FromDiscord<tandy> why not?
14:10:49PMunchIt has an unfortunate tendency to break code
14:11:13kobii think i'll just start with plain objects and casting
14:11:15FromDiscord<Solitude> In reply to @tandy "why not?": you dont need it, your code is fine
14:11:48kobiPMunch, it doesn't break code if you define --indent:2
14:11:53FromDiscord<tandy> i ran it on my test suite and no breaks \:)
14:12:21kobibut maybe u have more advanced usages with macros and all
14:12:28PMunchOh 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:19kobiI only found it get confused when the indent was not specified. it would sometimes double the spaces, for no apparent reason
14:15:21Zevvamazing how much more I enjoy PMunch sessions when his fire is lit
14:15:46PMunchHaha, guess it's time to throw another log on the fire then
14:16:07PMunchI'm about to stream day 5, and there's only embers left at the moment
14:16:20Zevvthere you go, light up indeed :)
14:17:09ZevvI planned not to bother with AOC this year, but still it's fun to do
14:17:17ZevvI'm not doing nim this year tho, sorry for that :)
14:17:53PMunchThey are quite fun :)
14:18:05PMunchWhat language has the pleasure this year?
14:18:09Zevvelixir
14:18:33FromDiscord<dain> In reply to @PMunch "<@225449938258100225>, that part of": ah thank you
14:18:39PMunchHmm, maybe I should record my fireplace to use as the "Stream is starting soon" screen instead of the test image
14:18:53FromDiscord<dain> btw what is the type for expressions like `1..10`
14:18:55PMunchAha, elixir, I've been meaning to look into that a bit more
14:19:07FromDiscord<tandy> hmm i used nimprety but it didnt realy help my long line problem haha
14:19:11FromDiscord<Rika> slice
14:19:12FromDiscord<dain> i did `echo typeof(1..10` and it just gave `int` which doesn't seem right
14:19:13FromDiscord<Rika> or hslice
14:19:16PMunch!eval echo typeof(1..10)
14:19:18NimBotint
14:19:25PMunchHuh, that is strange indeed
14:19:30FromDiscord<dain> (edit) "typeof(1..10`" => "typeof(1..10)`"
14:19:36PMunchIt should be a HSlice I believe
14:19:57ZevvPMunch: 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:57FromDiscord<tandy> oh wait it did, nvm
14:20:45Zevvand it can be pretty consise. https://raw.githubusercontent.com/zevv/aoc2021/master/lib/day05.ex
14:20:54*arkurious joined #nim
14:22:47FromDiscord<Solitude> !eval echo typeof(1..10, typeOfProc)
14:22:49NimBotHSlice[system.int, system.int]
14:23:03FromDiscord<Solitude> typeof defaults to iterators
14:23:11PMunch@Zevv, I can't be looking at day 5 before I've solved it :P
14:23:30Zevvfair enough. you can squint to just see the shape of it then :)
14:23:32Zevvi'll allow it
14:23:47PMunchI do wish Nim had a more solid multithreading story. Hopefully one day
14:24:27Zevvone day
14:25:06PMunchStream is live! https://www.twitch.tv/pmunche
14:25:20qwrcurrently its still a bit ahead of ocaml in threading ;)
14:25:32FromDiscord<tandy> nvm, it broke my code lmao
14:40:24kobidom96, what do u think: https://play.nim-lang.org/#ix=3H5J
14:40:48kobi"waitFor all" does very similar to what I want,
14:42:13FromDiscord<dain> sent a code paste, see https://play.nim-lang.org/#ix=3H5K
14:43:11FromDiscord<dain> sent a code paste, see https://play.nim-lang.org/#ix=3H5L
14:45:28FromDiscord<Yardanico> Because i is outside the quote do
14:45:39FromDiscord<Yardanico> you need to enclose it in backticks as well
14:45:59FromDiscord<dain> oooh
14:46:10FromDiscord<dain> i tried that way back and it didnt work either
14:46:22FromDiscord<dain> must have had another mistake that got fixed in the meantime and i didnt realise
14:46:41FromDiscord<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:27ZevvPMunch: "sparse map" is the word
16:06:30FromDiscord<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:48FromDiscord<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:26FromDiscord<claude> it seems to be because of the `when i is BackwardsIndex`
16:16:10FromDiscord<claude> changing it to `typeof(i) is BackwardsIndex` works
16:17:06FromDiscord<Solitude> or making foo a proc works too
16:18:58FromDiscord<dain> In reply to @claude "changing it to `typeof(i)": thank you
16:29:13FromDiscord<dain> In reply to @claude "that is probably a": what does the `{.inline.}` pragma do
16:29:41FromDiscord<claude> its just an optimization passed to the C compiler
16:31:07FromDiscord<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:10FromDiscord<dain> ah
16:34:27FromDiscord<dain> so what's the reason for defining a macro inside a `func` and then immediately invoking the macro
16:35:46FromDiscord<dain> i dont really get what's happening there
16:36:41FromDiscord<dain> how does the compiler figure out the return type of the `[]` defined on e.g. line 8
16:37:03FromDiscord<dain> or does it not have to because it's inlined?
16:42:57FromDiscord<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:08FromDiscord<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:06FromDiscord<dain> does that have any runtime overhead
16:45:13FromDiscord<Solitude> no
16:46:39*neurocyte0132889 joined #nim
16:46:39*neurocyte0132889 quit (Changing host)
16:46:39*neurocyte0132889 joined #nim
16:47:00FromDiscord<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:28smvgis 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:11FromDiscord<Schelz> Is there anyway that i can use nim with php ?
17:20:26FromDiscord<Schelz> (edit) "anyway" => "any way"
17:37:27FromDiscord<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:52FromDiscord<dain> sent a code paste, see https://play.nim-lang.org/#ix=3H6U
17:40:21smvgok thanks for the info @geekrelief
17:45:23FromDiscord<geekrelief> sent a code paste, see https://play.nim-lang.org/#ix=3H6Y
17:45:44FromDiscord<geekrelief> maybe cause `len` is a magic?
17:46:41*jjido joined #nim
17:48:28FromDiscord<geekrelief> that works too
17:48:30FromDiscord<geekrelief> sent a code paste, see https://play.nim-lang.org/#ix=3H71
17:49:29FromDiscord<geekrelief> sent a code paste, see https://play.nim-lang.org/#ix=3H72
17:50:20FromDiscord<dain> sent a code paste, see https://play.nim-lang.org/#ix=3H73
17:57:01FromDiscord<geekrelief> https://play.nim-lang.org/#ix=3H74
17:57:50FromDiscord<geekrelief> If you were to implement this without sugar, I'm not sure you could do it without macros.
17:58:32FromDiscord<dain> thanks
17:58:59FromDiscord<dain> why doesnt my way work though? can you not have anonymous generic procs?
17:59:55FromDiscord<geekrelief> good question, I don't know off hand. Not something I ever experimented with but I'm curious now.
18:02:59FromDiscord<dain> sent a code paste, see https://play.nim-lang.org/#ix=3H77
18:04:39FromDiscord<geekrelief> Weird it works on playground
18:05:47FromDiscord<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:54FromDiscord<dain> okay it works when I do `as_func(len)` but breaks when I do `len.as_func`
18:06:12FromDiscord<dain> does UFCS not work on templates?
18:06:14FromDiscord<geekrelief> hmm how do you strikethrough on discord
18:07:14FromDiscord<the cws came hme> \~~like this~~
18:08:38FromDiscord<geekrelief> thx
18:08:42FromDiscord<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:52FromDiscord<geekrelief> it does not work on templates
18:09:06FromDiscord<dain> aww that sucks
18:14:00FromDiscord<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:49FromDiscord<dain> how comes
18:17:25FromDiscord<Solitude> In reply to @dain "aww that sucks": it doesnt work in some edge cases, usually it works
18:18:12FromDiscord<dain> ya
18:18:17FromDiscord<dain> anyway thank you all for the help :)
18:22:59FromDiscord<geekrelief> In reply to @dain "how comes": Hmm maybe it's a compiler bug?
18:23:48FromDiscord<Fish-Face> sent a code paste, see https://play.nim-lang.org/#ix=3H7f
18:24:02FromDiscord<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:07FromDiscord<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:11FromDiscord<geekrelief> In reply to @Fish-Face "Can anyone spot why": code?
18:34:22FromDiscord<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:51FromDiscord<Zoom> I've asked in #internals about fixing the error msg but received no reply yet
18:35:33arkanoiddamn, the more I bench python vs nim, the more I fear python is faster
18:35:55FromDiscord<Fish-Face> sent a code paste, see https://play.nim-lang.org/#ix=3H7k
18:36:22FromDiscord<Zoom> @dain\: the recommended workaround is either an alias for a builtin or an anonymous function
18:37:07FromDiscord<Zoom> See\: https://github.com/nim-lang/Nim/issues/2172#issuecomment-304609785
18:39:19FromDiscord<Solitude> In reply to @Fish-Face "Can anyone spot why": https://nim-lang.org/docs/manual.html#types-open-arrays
18:39:23FromDiscord<Solitude> you cant nest openarrays
18:40:14FromDiscord<Fish-Face> oh rihgt
18:40:16FromDiscord<Fish-Face> right
18:40:26FromDiscord<Fish-Face> sounds like an opportunity at least for a better compile error
18:45:42*xet7 joined #nim
18:48:01FromDiscord<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:39arkanoidgeekrelief: reverse a string. pystr[::-1] seems way faster than unicode.reversed
19:00:08arkanoidwhat's the fastest way to reverse a string in nim?
19:00:30FromDiscord<Fish-Face> a C string or a unicode string...
19:00:38arkanoidI know that python str are unicode so nim's unicode.reversed should be appropriate
19:01:44FromDiscord<Fish-Face> how do you filter an iterator? e.g. I want to do `table.values.filterIt(...)`
19:02:38arkanoidFish-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:07FromDiscord<Fish-Face> I want to chain a `foldl` but I don't care too much about speed
19:03:27FromDiscord<Fish-Face> I care more about the syntax not being ugly
19:05:11FromDiscord<Fish-Face> arkanoid, can you expand on "use sequtils"? `filterIt` is in that module
19:05:55FromDiscord<Fish-Face> (the above expression does not compile, because; it fails with `undeclared field: 'values'` because values is an iterator
19:05:58FromDiscord<Fish-Face> (edit) "iterator" => "iterator)"
19:07:33FromDiscord<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:57FromDiscord<Fish-Face> bleh 😦
19:13:05FromDiscord<Fish-Face> maybe I will check it out
19:13:24FromDiscord<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:16arkanoidZoom are you sure you can't chain iterator in latest nim?
19:16:26arkanoidZoom I'm quite sure you can, let me try
19:17:19NimEventerNew thread by Geekrelief: Understanding error with generic anonymous vs auto, see https://forum.nim-lang.org/t/8680
19:17:23FromDiscord<Zoom> If I remember correctly, the only thing which take iterable for now is `toSeq`.
19:18:57FromDiscord<Zoom> Or wait, it works
19:21:16FromDiscord<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:51arkanoidactually I'm failing with the most trivial example
19:22:08arkanoidI step on this quite frequently. Sometimes I feel it's working, sometimes is not
19:24:11FromDiscord<Zoom> This is exactly my experience
19:25:36arkanoidfor example "let myList = countup(0, 1000).filterIt(it mod 2 == 0)" doesn't compile
19:28:00PMunchMight be a iterator vs. closure iterator thing
19:28:54FromDiscord<Solitude> In reply to @arkanoid "for example "let myList": because filterIt works on an openArray, not iterator
19:31:20arkanoidnow 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:26FromDiscord<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:21arkanoidwell, openArrays are still non-lazy things
19:33:40arkanoidso to unleash the iterator power you need zero functional anyway
19:34:39FromDiscord<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:50FromDiscord<geekrelief> me neither. 🙂 I just read the docs and experimented
19:37:56FromDiscord<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:08arkanoidaccording to my benchmarks nim unicode.reversed in 10x slower than python
19:39:44FromDiscord<ynfle (ynfle)> @arkanoid are you using `-d:release`?
19:42:07arkanoidynfle: have a look at the last comment in https://github.com/yglukhov/nimpy/issues/243 (just posted)
20:04:58arkanoidI'm quite surprised that there's not a string reverse function in stdlib, is there a reason for this?
20:05:46FromDiscord<Solitude> In reply to @arkanoid "I'm quite surprised that": https://nim-lang.org/docs/algorithm.html#reverse%2CopenArray%5BT%5D
20:06:56arkanoidSolitude, the inplace one might do it, but `reversed` returns a seq[char] instead of a string
20:08:47FromDiscord<Solitude> ye, probably someone faced a dilemma is it should go into strutils or in algorithm
20:11:11FromDiscord<dain> In reply to @arkanoid "I'm quite surprised that": https://qntm.org/trick
20:12:31FromDiscord<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:39arkanoiddain: https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/unicode.nim#L843
20:15:17FromDiscord<dain> omg
20:17:20arkanoiddain, the nim algorith might not be exact, but here what I'm benchmarking is pythons [::-1] vs nim unicode.reversed
20:17:50FromDiscord<ynfle (ynfle)> @arkanoid did you try in nim directly?
20:19:21arkanoidynfle writing the benchmark in such a way it reads a unicode text file instead, so that I can use it independently
20:19:39FromDiscord<ynfle (ynfle)> Ya
20:19:53FromDiscord<ynfle (ynfle)> Maybe converting to nim stuff is taking the time
20:19:57FromDiscord<ynfle (ynfle)> I don't know
20:20:31FromDiscord<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:48arkanoidsure 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:09arkanoidbasically I'm trying to understand if zero-copy interop is possible or not and on which types
20:23:04arkanoidsadly 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:44FromDiscord<ynfle (ynfle)> Just curious, which tools
20:24:21arkanoidscipy stack in general, and also scikit
20:24:51FromDiscord<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:57FromDiscord<ynfle (ynfle)> Not machine learning stuff
20:25:10FromDiscord<ynfle (ynfle)> Which stuff in scipy?
20:25:15FromDiscord<ynfle (ynfle)> For your project
20:25:49arkanoidsure, 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:30arkanoidynfle, just thinkg about pandas manipulation, or xarray ones
20:32:41arkanoidthis 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:15arkanoidso scinim is for crunching numbers, not handling datasets
20:37:53*filcuc_ joined #nim
20:43:46arkanoidI mean this https://github.com/SciNim/scinim/issues/7
20:44:01FromDiscord<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:37FromDiscord<dain> sent a code paste, see https://play.nim-lang.org/#ix=3H7Z
20:46:14FromDiscord<vindaar> it refers to the procedure and not the `int`. That the procedure is a closure
20:47:35FromDiscord<ynfle (ynfle)> You don't need 2 generics because you know the key proc has to return int
20:47:39FromDiscord<ynfle (ynfle)> https://play.nim-lang.org/#ix=3H81
20:48:05FromDiscord<ynfle (ynfle)> @dain try this ☝
20:48:05FromDiscord<dain> the `key` proc does not have to return int
20:49:15FromDiscord<ynfle (ynfle)> Then you switched the generics https://play.nim-lang.org/#ix=3H83
20:49:20FromDiscord<ynfle (ynfle)> This works
20:49:27FromDiscord<dain> yes you're right
20:49:36FromDiscord<dain> i figured it out at the same time, i needed `T` instead of `U` in the inner proc
20:50:52FromDiscord<ynfle (ynfle)> Great
20:54:04FromDiscord<dain> sent a code paste, see https://play.nim-lang.org/#ix=3H86
20:54:18FromDiscord<ynfle (ynfle)> Can you post the whole code?
20:55:27FromDiscord<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:51FromDiscord<ynfle (ynfle)> Ok
20:56:04FromDiscord<dain> oh wait hold on, the generic is still wrong
20:56:10FromDiscord<ynfle (ynfle)> too many generics I think
20:57:03FromDiscord<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:10FromDiscord<dain> In reply to @ynfle (ynfle) "too many generics I": fixed version https://play.nim-lang.org/#ix=3H8a
20:58:29FromDiscord<dain> the second-to-last line works, the last line doesn't
20:58:57FromDiscord<dain> but conceptually both of the functions are doing the same thing
20:59:35FromDiscord<ynfle (ynfle)> @pyautogui why no mm?
21:00:18FromDiscord<ynfle (ynfle)> @dain it works if you specify the type https://play.nim-lang.org/#ix=3H8c
21:00:26FromDiscord<ynfle (ynfle)> Probably too many generics.
21:01:26FromDiscord<pyautogui> For speed.
21:01:32FromDiscord<ynfle (ynfle)> Many open an issue on https://github.com/nim-lang/Nim
21:01:47FromDiscord<ynfle (ynfle)> Have you tried `--gc:arc` or `--gc:orc`?
21:02:04FromDiscord<ynfle (ynfle)> Are you using `-d:release` is your solution too slow?
21:02:15FromDiscord<pyautogui> Yes. I want the maximum of speed; --gc:arc is good, and I have all optimization on.
21:03:14FromDiscord<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:55FromDiscord<pyautogui> I guess I will just {importc} printf.
21:04:15FromDiscord<dain> In reply to @ynfle (ynfle) "@dain it works if": thank you, is this a bug or expected behavior?
21:04:24FromDiscord<dain> i.e. that it can't infer that `x` is a string
21:04:41FromDiscord<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:19FromDiscord<retkid> i would like the option to turn the gcc off and do manual memory allocation
21:27:49FromDiscord<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:00FromDiscord<retkid> make sure you have the loggers and debuggers off
21:28:05FromDiscord<retkid> and then you should start optimizing the code
21:28:36FromDiscord<retkid> all else fails, port over to C
21:28:54FromDiscord<retkid> (edit) "C" => "or use inline ASM"
21:28:59FromDiscord<retkid> (edit) "ASM" => "ASM, which is a thing in nim"
21:29:05FromDiscord<retkid> (edit) "all else fails, port over to ... or" added " C"
21:29:50FromDiscord<retkid> but before I'd do asm Id probably try to use Fortran for floating point math
21:30:45FromDiscord<retkid> iirc you also use --asm to compile to ASM code but idk how you can view it
21:30:55FromDiscord<retkid> if you can view it you can start looking for optimizations in the code itself
21:31:51FromDiscord<retkid> this is Nim's "official" priority list for optimizations
21:32:10FromDiscord<retkid> sent a long message, see http://ix.io/3H8h
21:33:28FromDiscord<Elegantbeef> If you want to have no memory manager do `--gc:non`
21:33:37FromDiscord<retkid> yes but you cant cull vars
21:33:44FromDiscord<Elegantbeef> What?
21:34:02FromDiscord<retkid> you cant remove variables from memory space?
21:34:05FromDiscord<retkid> unless im wrong
21:34:26FromDiscord<Elegantbeef> You can allocate/free memory
21:35:05FromDiscord<Elegantbeef> `var a = create(int, 300); dealloc(a)`
21:35:20FromDiscord<Elegantbeef> We just allocated 300 \ sizeof(int) bytes then freed them
21:35:33FromDiscord<retkid> hmmm
21:35:43FromDiscord<Elegantbeef> I dont even know what "removing variables from memory space" even means
21:35:59FromDiscord<retkid> how is the create proc separate from just the normal =
21:36:00FromDiscord<Elegantbeef> The stack will "free" variables on the stack as you move around, and thee heap is under your control
21:36:25FromDiscord<Elegantbeef> `create` uses the nim memory allocator and returns a `ptr int`
21:36:48FromDiscord<Elegantbeef> It's akin to doing `int a = malloc(sizeof(int) 300); free(a)` in C
21:37:10FromDiscord<pyautogui> @retkid Thanks
21:37:11FromDiscord<retkid> that makes sense
21:37:33FromDiscord<retkid> i forgot about dealloc and i tried using free(a)
21:37:37FromDiscord<retkid> (edit) "i forgot about dealloc and i tried using free(a) ... " added "but no proc"
21:37:52FromDiscord<Elegantbeef> Infact the implementation is `cast[ptr T](alloc0(sizeof(T) size))`
21:38:32FromDiscord<retkid> so, am i wrong to think that doing this would be pretty unstable given my interactions with channels?
21:38:49FromDiscord<Elegantbeef> If using arc/orc they have a shared heap so not really
21:39:00FromDiscord<Elegantbeef> Aslong as you properly guard you're fine
21:39:13FromDiscord<retkid> properly guard?
21:39:29FromDiscord<Elegantbeef> Dont allow race conditions
21:41:13FromDiscord<pyautogui> --asm is broken on Mac, I do believe.
21:41:23FromDiscord<pyautogui> Is an issue open for that?
21:42:03FromDiscord<retkid> let me make sure thats right
21:42:40FromDiscord<retkid> yea thats the right command?
21:42:56FromDiscord<retkid> https://github.com/nim-lang/Nim/issues/17139
21:43:02*noeontheend joined #nim
21:43:27FromDiscord<pyautogui> Got it.
21:43:43FromDiscord<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:04FromDiscord<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:26FromDiscord<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:20arkanoiddoes trasformation from cstring to string perform a copy?
22:50:35FromDiscord<Solitude> yes
22:50:45*Onionhammer quit (Read error: Connection reset by peer)
22:50:47arkanoidand the other way around?
22:50:53FromDiscord<Solitude> no
22:51:00arkanoidthanks
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:03FromDiscord<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:07arkanoidpassing strings from python to nim is really a pain
23:18:55nrds<Prestige99> Real question, why do that in the first place instead of just using nim?
23:28:33arkanoidPrestige, pandas and handling tabular data
23:28:55*src joined #nim
23:29:36nrds<Prestige99> we def need more data analytics libs
23:29:44FromDiscord<Elegantbeef> @rinfz\: proc is preferred unless there is a reason to always inline
23:35:48NimEventerNew thread by Gavr: Using if/case expressions as real expressions?, see https://forum.nim-lang.org/t/8681
23:35:58arkanoidPrestige 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:00nrds<Prestige99> Idk anything about python really but I'm kind of not surprised
23:46:49FromDiscord<rinfz> Ok, thanks Elegantbeef