<< 17-08-2021 >>

00:06:01NimEventerNew post on r/nim by thprogramador: Lua extended by Nim or vice-versa, see https://reddit.com/r/nim/comments/p5sh3n/lua_extended_by_nim_or_viceversa/
00:17:17*justsomeguy joined #nim
00:30:13FromDiscord<System64 ~ Flandre Scarlet> I have a question, can a 64-bits Nim program interop with a 32-bits C lib please? I know Java doesn't and C# can. No idea for C and C++
00:30:18FromDiscord<System64 ~ Flandre Scarlet> (edit) "for" => "about"
00:40:36madpropshow can I avoid this imprecision? https://play.nim-lang.org/#ix=3wdW
00:41:49FromDiscord<Elegantbeef> I believe devel has better round triped string'd floats
00:47:35madpropsnvm I'll just cut the decimals to 2 or less characters
00:49:57madpropswait no this is bad. 2 gets turned into 1999999999
00:50:18madpropsoh i'll just round
00:53:04madpropsnot sure that works
00:53:15madpropsseems it's expected I use string format for this
00:53:27madpropsbut i get 1.1999999 instead of 1.2
00:53:28FromDiscord<Elegantbeef> Well like i said devel has better round trip float stringification
00:53:39madpropswhat do you mean by devel?
00:54:07FromDiscord<Elegantbeef> the development branch on the github
00:54:33FromDiscord<Elegantbeef> Actually i code be wrong about it, still might be an umerged PR
00:54:34FromDiscord<Elegantbeef> Actually i could be wrong about it, still might be an umerged PR
01:02:30madpropsor, is there a way to get decimals without resorting to strings?
01:02:35madpropslike get 2 in 1.2
01:03:13madpropsoh there's `splitDecimal`
01:03:22madprops"Breaks x into an integer and a fractional part."
01:05:11justsomeguyDoesn't Nim have rational or fixed point numbers that you can use?
01:05:52madpropsdoes it?
01:05:59madpropssplitdecimal is not working well
01:06:08madprops0.2 turns into 1.9999999
01:06:12madpropswhen i echo it
01:06:22madprops(after multiplying it)
01:06:44FromDiscord<Elegantbeef> I mean that's to be expected, floats are floats afterall
01:07:29madpropsyeah a round fixes it
01:08:09FromDiscord<Elegantbeef> I've never really needed this round trip accuracy, so i'm just here going "Yep" 😛
01:10:25madpropsheh
01:12:09*arkurious quit (Quit: Leaving)
01:48:06*_KurtGodel_ joined #nim
01:51:10*_KurtGodel quit (Ping timeout: 240 seconds)
01:52:33madpropsended up making this function https://play.nim-lang.org/#ix=3we9
01:54:07*justsomeguy quit (Quit: WeeChat 3.2)
02:05:20madpropsto this library https://github.com/madprops/numberstring
02:59:22*pch_ is now known as pch
03:16:08FromDiscord<gogolxdong (liuxiaodong)> Is there any up-to-date GMP library
03:35:10*rockcavera quit (Remote host closed the connection)
03:51:23madpropshow can I make the index appear here: for i, c in 'a'..'z':
03:51:34madpropsusing pair doesn't seem to work
03:53:35FromDiscord<Yardanico> use enumerate
03:55:23FromDiscord<Yardanico> https://nim-lang.org/docs/enumerate.html
03:55:36FromDiscord<Yardanico> it basically creates the loop index itself and increments it
03:56:02FromDiscord<Yardanico> it's the same as doing var i = 0 and incrementing it in a loop just nicer
03:56:07madpropsthe question is
03:56:11madpropshow do I import it?!
03:56:16madpropsi think i've been through this before
03:56:20madpropsit had some weird import method
03:57:30FromDiscord<Yardanico> not weird, just the more modern way
03:57:40FromDiscord<Yardanico> it's preferable you import all std modules this way :)
03:57:41FromDiscord<Yardanico> import std/enumerate
03:57:46FromDiscord<Yardanico> import std/strutils
03:58:00madpropsthere we go
03:58:00FromDiscord<Yardanico> or for multiple modules at the same time - import std/[strutils, enumerate]
03:58:19madpropsstd modules are 99% of what i import
03:58:23madpropsso it's gonna be full of std/
03:58:45madpropsbut namespacing is good
04:01:29FromDiscord<Yardanico> you can also span this import over multiple lines
04:01:35FromDiscord<Yardanico> also, you can import packages from nimble via import pkg/package
04:01:40FromDiscord<Yardanico> or import pkg/[package1, package2]
04:06:01*supakeen quit (Quit: WeeChat 3.2)
04:06:31*supakeen joined #nim
04:20:58madpropsi see
04:21:44madpropsand local modules without a keyword right?
04:23:37madpropshmm weird
04:23:44madpropsrunning an integration test is getting cached
04:23:54madpropsi modify the file and the changes are not reflected
04:27:20madpropsI had to add --forceBuild:on
04:29:38madpropsdangerous stuff, if it makes me think the tests pass when they don't
04:33:55FromDiscord<PsychoClay> what does it mean if file.writeLine throws an IndexDefect?
04:35:58FromDiscord<Yardanico> In reply to @madprops "dangerous stuff, if it": that's really weird
04:36:42FromDiscord<Yardanico> In reply to @PsychoClay "what does it mean": can you show a bit more code?
04:37:01FromDiscord<PsychoClay> i forgot to add fmWrite
07:12:09NimEventerNew thread by Jasonfi: A look at Dart's null safety syntax, see https://forum.nim-lang.org/t/8333
08:09:49*flynn quit (Remote host closed the connection)
08:10:56*flynn joined #nim
08:16:22*max22- joined #nim
08:35:08*max22- quit (Remote host closed the connection)
08:35:35*max22- joined #nim
09:07:02FromDiscord<Chiggy> How can I check if a number is between 2 numbers? I tried `50 <= num <= 70` but this doesnt work. And neither does `num in 50..70`. Why didnt the 50..70 fail?
09:07:06FromDiscord<Chiggy> (edit) "didnt" => "did"
09:07:39FromDiscord<Chiggy> ofc I can do `5- <= 50 and num <= 70` but I wanted to know if there was another way
09:07:52FromDiscord<Chiggy> (edit) "`5-" => "`50" | "50" => "num"
09:09:07FromDiscord<Elegantbeef> !eval 10 in 5..15
09:09:08NimBotCompile failed: /usercode/in.nim(1, 4) Error: expression 'contains(5 .. 15, 10)' is of type 'bool' and has to be used (or discarded)
09:09:16FromDiscord<Elegantbeef> !eval echo 10 in 5..15
09:09:18NimBottrue
09:10:07FromDiscord<Elegantbeef> The issue is your num isnt the same type as the range
09:10:37FromDiscord<Elegantbeef> ie if it's a int8 you need to do `yourVar in 50i8..70i8`
09:10:52FromDiscord<Chiggy> sent a code paste, see https://play.nim-lang.org/#ix=3wfl
09:10:53FromDiscord<Chiggy> um
09:11:34FromDiscord<Elegantbeef> That works
09:11:46FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=3wfm
09:12:22*PMunch joined #nim
09:14:29FromDiscord<Chiggy> then something must be wrong in my code
09:15:08FromDiscord<Chiggy> this is my code↔` if ( now_timestamp - player_last_seen in SECONDS-10..SECONDS+10 ) and (player_server == server) and (parseInt(nv) >= SECONDS):`
09:15:16FromDiscord<Chiggy> now_timestamp is epochTime()
09:15:25FromDiscord<Chiggy> and player_last_seen is a float
09:15:35FromDiscord<Chiggy> wait could that be the issue
09:16:03FromDiscord<Elegantbeef> Well the error message should say the issue
09:16:20FromDiscord<Chiggy> https://media.discordapp.net/attachments/371759389889003532/877118634823135252/unknown.png
09:17:59FromDiscord<Elegantbeef> yea right there "but expression is of type int"
09:18:28FromDiscord<Chiggy> how do I convert my player_last_seen which is something like 100.1234 to just 100
09:19:07FromDiscord<Elegantbeef> You can just do `int(val)` or checkout https://nim-lang.org/docs/lenientops.html
09:19:21FromDiscord<Elegantbeef> The latter will make more operations work float + int without question, which might be handy for what seems to be a game
09:19:55FromDiscord<Chiggy> nah its not a game
09:20:02FromDiscord<Chiggy> but thanks forr the docs link
09:20:27FromDiscord<Elegantbeef> float -\> int conversion truncates the decimal so `-1.9.int == -1` and `int(1.9) == 1`
09:52:59FromDiscord<Chiggy> is there a way I can shorten this : `table[server]["Players"][nk] = $(parseInt(table[server]["Players"][nk]) + SECONDS)`↔`table[server]["Players"][nk]` is a integer in string format. Just need to add to it and convert it to string again. Is there a concise / faster method?
09:53:32*Guest3138 joined #nim
09:54:50*Vladar joined #nim
09:55:02PMunchHmm, can't think of anything of the top of my head
09:55:56PMunchI mean you could maybe do `template nk: untyped = table[server]["Players"][nk]; nk = $(nk.parseInt + SECONDS)` but I'm not sure if that'll work
09:56:49FromDiscord<Chiggy> hmm ok
09:57:16FromDiscord<haxscramper> this is a single encounter of this, or you have multiple conversions like this?
09:57:47FromDiscord<Chiggy> just one more encounter
09:57:49FromDiscord<haxscramper> you can do `mgetOrPut` and move `parseInt(...) + SECONDS` part into proc
09:57:57FromDiscord<Chiggy> https://media.discordapp.net/attachments/371759389889003532/877129111657676820/unknown.png
09:58:04FromDiscord<haxscramper> if it is one instance then I would not bother
10:04:02PMunchCould you try to put that template thing outside that if statement and see if it works? You would reduce all that by quite a bit if it did, but mostly I'm just curious :P
10:04:33FromDiscord<Chiggy> yeah sure
10:05:20PMunchBy the way, Nim typically uses 2 spaces instead of 4 for indentation. It works with 4 as well, but if you want to write code following the convention you should switch to 2
10:05:31FromDiscord<Chiggy> oh
10:05:33FromDiscord<Chiggy> didnt know that
10:05:41FromDiscord<Chiggy> btw nk is already a string
10:05:42PMunchIt looks a bit odd at first, but once you get used to it 4 spaces looks like a massive waste :P
10:05:47FromDiscord<Chiggy> should I change template name?
10:05:52PMunchAh, yes
10:06:09PMunchI just wasn't sure what to call that thing
10:06:14FromDiscord<Chiggy> https://media.discordapp.net/attachments/371759389889003532/877131193345273866/unknown.png
10:06:33FromDiscord<Chiggy> like so?
10:06:37PMunchThe untyped is supposed to be on the same line, it's the return type of the template
10:06:46FromDiscord<Chiggy> oh
10:06:57PMunchIt's really `template nkt(): untyped = <body>`
10:07:18FromDiscord<Chiggy> like so? https://media.discordapp.net/attachments/371759389889003532/877131464095961098/unknown.png
10:07:20PMunchSimilar to a proc, but a template instead. And you can omit the parenthesis
10:07:53PMunchThe ; was just to split it into a newline
10:07:58FromDiscord<Chiggy> ok
10:08:52PMunchhttp://ix.io/3wfy/nim
10:08:54PMunchLike that
10:09:11FromDiscord<Chiggy> yeah it seems to work
10:09:43PMunchNice, wasn't sure if it would work to assign to it through a template
10:10:01FromDiscord<Chiggy> https://media.discordapp.net/attachments/371759389889003532/877132144886054922/unknown.png
10:10:56PMunchOh woops, that paste didn't go right
10:11:08FromDiscord<Chiggy> yeah the code works
10:11:20FromDiscord<Chiggy> In reply to @PMunch "Oh woops, that paste": huh?
10:11:47PMunchMy ix.io paste was intended to be a longer snippet
10:11:57FromDiscord<Chiggy> oh lol
10:12:17PMunchAh, that wasn't quite what I was thinking
10:12:22FromDiscord<Chiggy> anyways your template code seems to work
10:12:51PMunchIf you just do the template, then `nkt = $(nkt.parseInt + SECONDS)` in your if/else statement
10:13:29PMunchIf you share the same stuff from your image as text (for example via play.nim-lang.org) then I can show you what I mean
10:14:13FromDiscord<Chiggy> btw, I am currently using `nim c -r file.nim` to compile. I assume its compiling in debug mode rn? and if I compile for release, should I expect any speed boost?
10:14:27FromDiscord<Yardanico> yes
10:14:45FromDiscord<Yardanico> but it depends on what you do - if it's number crunching or some calculations, then it'll be much faster, if it's IO - don't expect a big boost
10:14:46PMunchYes, that is debug mode by default, and yes adding `-d:release` will very likely give you a speed boost
10:14:54FromDiscord<Yardanico> -d:release if a safe release mode (with runtime checks enabled)
10:15:10FromDiscord<Yardanico> -d:danger is d:release + all runtime checks disabled, use it when you don't care about runtime errors or stuff
10:15:27FromDiscord<Yardanico> or when you just want to run some program one time and not host it on a server to run 24/7 :P
10:18:10*xet7 joined #nim
10:19:28*beshr quit (Ping timeout: 256 seconds)
10:20:47NimEventerNew thread by Ingo: Server Sent Events?, see https://forum.nim-lang.org/t/8334
10:21:36FromDiscord<Chiggy> In reply to @Yardanico "or when you just": Lol
10:21:49FromDiscord<Yardanico> so yeah, -d:release is fine for must stuff
10:21:52FromDiscord<Yardanico> (edit) "must" => "most"
10:21:54PMunchMaybe something like this should be put in sugar? https://play.nim-lang.org/#ix=3wfA
10:22:34FromDiscord<Chiggy> In reply to @Yardanico "but it depends on": My program is actually pretty simple.↔fetch json from api - roughly 4-6 seconds↔then shit ton of playing around with tables.↔total time on debug mode is around 10 to 12 seconds
10:22:44FromDiscord<Yardanico> then go ahead with -d:danger
10:22:45FromDiscord<Chiggy> (edit) "tables.↔total" => "tables. (10-12 - 4-6)↔total"
10:22:50FromDiscord<Yardanico> (edit) "then go ahead ... with" added "and try it"
10:22:55FromDiscord<Chiggy> (edit) "4-6)↔total" => "4-6 = 6 seconds) ↔total"
10:23:00FromDiscord<Chiggy> um ok
10:23:39FromDiscord<Chiggy> whoa
10:23:49FromDiscord<Chiggy> total time reduces to 6 seconds
10:23:53FromDiscord<Yardanico> yeah
10:23:57FromDiscord<Chiggy> out of which 5 seconds was to fetch
10:24:05FromDiscord<Chiggy> https://media.discordapp.net/attachments/371759389889003532/877135689450405958/unknown.png
10:24:07FromDiscord<Yardanico> the biggest "optimization" that -d:release or -d:danger do is opt:speed
10:24:14FromDiscord<Yardanico> that argument just passes -O3 to the C compiler
10:24:33FromDiscord<Yardanico> whereas the default debug mode compiles without C compiler optimizations, for a faster compilation time
10:25:01FromDiscord<Yardanico> also you might want to try -d:danger --gc:orc to see if ORC is faster for you
10:25:09FromDiscord<Chiggy> whats orc
10:25:11FromDiscord<Yardanico> (it's a newer GC, the default is refc but it's being phased out)
10:25:43FromDiscord<Yardanico> if you want to know more, you can read↔https://nim-lang.org/blog/2020/12/08/introducing-orc.html↔https://nim-lang.org/blog/2020/10/15/introduction-to-arc-orc-in-nim.html
10:26:25FromDiscord<Chiggy> also, one more qurstion. I am currently devving on my laptop (windows). I want to be able to run this code on a vps (ubuntu most likely), so I will have to install nim on it, then compile my code on it?
10:26:30FromDiscord<Chiggy> (edit) "qurstion." => "question."
10:27:12PMunchNah you can cross-compile
10:27:16FromDiscord<Yardanico> if you have win10, then you can compile in wsl
10:27:18FromDiscord<Chiggy> In reply to @Yardanico "also you might want": took 6.4 seconds
10:27:27FromDiscord<Chiggy> In reply to @Chiggy "": this took 6.3
10:27:34FromDiscord<Chiggy> (edit) "In reply to @Chiggy "": this took 6.3 ... " added "(d:danger only)"
10:27:37FromDiscord<Yardanico> well you can't compare time just from a single line :P
10:27:41FromDiscord<Chiggy> true
10:27:43FromDiscord<Yardanico> since network speed isn't constant
10:27:53FromDiscord<Chiggy> yeah this time fetch did take more time
10:27:54FromDiscord<Yardanico> but yeah, you can just continue using just -d:danger
10:28:02FromDiscord<Yardanico> but --gc:orc will become the default in the future
10:28:08PMunchYou could also cache your JSON response :P
10:29:40FromDiscord<Chiggy> In reply to @PMunch "You could also cache": Its different everytime so
10:29:51FromDiscord<Chiggy> My code will be running once every minute
10:30:21PMunchAh I see
10:32:02FromDiscord<Chiggy> Does anyone know if I can create JSONs using jsony
10:32:23FromDiscord<Yardanico> nah
10:32:30FromDiscord<Yardanico> well, yes
10:32:31FromDiscord<Yardanico> you can :P
10:32:42FromDiscord<Chiggy> huh?
10:32:49FromDiscord<Yardanico> https://media.discordapp.net/attachments/371759389889003532/877137884212260904/unknown.png
10:33:10FromDiscord<Chiggy> hmm
10:33:23FromDiscord<dom96> If it's just to create JSON strings then why not just use the stdlib?
10:33:52FromDiscord<Chiggy> yeah that was the plan was just curious to know if jsony has something for it
10:49:42FromDiscord<haxscramper> jsony is faster
10:50:07FromDiscord<haxscramper> and it does not have do two allocations for `T -> JsonNode -> string`
10:50:48FromDiscord<haxscramper> So for serialization I think it makes sense to use it instead of the stdlib
11:00:56*Lord_Nightmare quit (Quit: ZNC - http://znc.in)
11:04:16FromDiscord<Chiggy> sent a code paste, see https://play.nim-lang.org/#ix=3wfF
11:05:58FromDiscord<haxscramper> You can have either `"Table"` or `"Server"` fields in json?
11:06:24FromDiscord<Yardanico> In reply to @Chiggy "ok I am almost": well, if you want to use jsony, you'll need to createa custom type I think
11:06:30FromDiscord<Yardanico> (edit) "createa" => "create a"
11:06:38FromDiscord<haxscramper> You can just add `table: Option[string]` and `serve: Option[string]`
11:06:51FromDiscord<haxscramper> There is no `"Table"` in your json examples
11:07:04FromDiscord<Chiggy> by Table I meant just the `{}` part
11:07:17FromDiscord<Chiggy> In reply to @Yardanico "well, if you want": yes I am trying to do this with jsony
11:07:33FromDiscord<Yardanico> but apart from that it's pretty easy to do
11:07:45FromDiscord<Yardanico> loop over your tables, populate your objects and then serialize them
11:07:48*Lord_Nightmare joined #nim
11:09:23FromDiscord<haxscramper> In reply to @Chiggy "by Table I meant": So value can be either just server name or full table with multiple fields?
11:09:46FromDiscord<Chiggy> huh? I didnt get your question
11:09:53FromDiscord<Chiggy> also which table are we talking about. 1 or 2
11:14:07FromDiscord<Chiggy> I think I got it
11:14:30*tdc joined #nim
11:15:09FromDiscord<Chiggy> yeah I got it working
11:15:36FromDiscord<Chiggy> just that field names are wrong lol. I suppose I will have to write a hook? https://media.discordapp.net/attachments/371759389889003532/877148651082895370/unknown.png
11:16:21FromDiscord<Yardanico> well you can change the field names in the object definition itself I think
11:16:31FromDiscord<Yardanico> since nim itself doesn't care about camelCase vs snake_case
11:16:38FromDiscord<Chiggy> How can I define `Last Seen tho`
11:16:41FromDiscord<Chiggy> (edit) "Seen tho`" => "Seen` tho"
11:16:46FromDiscord<Yardanico> ah, like that
11:16:54FromDiscord<Yardanico> hmm
11:17:06FromDiscord<Chiggy> I suppose since toJson returns a string, I can just do a replace
11:17:15FromDiscord<Chiggy> on the whole string
11:17:19FromDiscord<Yardanico> that won't be the best for performance :P
11:17:20FromDiscord<Yardanico> you can try https://github.com/treeform/jsony#proc-renamehook-can-be-used-to-rename-fields-at-run-time
11:18:20*arkurious joined #nim
11:19:02FromDiscord<Chiggy> Ok I lemme see
11:20:07FromDiscord<Yardanico> just make a renameHook proc with a simple case statement inside
11:32:57NimEventerNew thread by Haxscramper: Change error message position using `{.line.}` pragma , see https://forum.nim-lang.org/t/8335
11:34:56FromDiscord<Chiggy> In reply to @Yardanico "you can try https://github.com/treeform/jsony#proc-": turns out I was already using a rename hook
11:35:15FromDiscord<Chiggy> that was affecting my names
11:37:32*max22- quit (Ping timeout: 245 seconds)
11:38:58FromDiscord<Chiggy> ok I am doing something wrong
11:39:10FromDiscord<Chiggy> https://media.discordapp.net/attachments/371759389889003532/877154585175814144/unknown.png
11:39:22FromDiscord<Chiggy> the upper `of`s are for when I parse a json
11:39:36FromDiscord<Chiggy> the below ones are supposed to be when I am writing
11:39:50FromDiscord<Chiggy> and this is how I write https://media.discordapp.net/attachments/371759389889003532/877154752494968912/unknown.png
11:40:01FromDiscord<Chiggy> where https://media.discordapp.net/attachments/371759389889003532/877154798149963796/unknown.png
11:40:10FromDiscord<Chiggy> ¯\_(ツ)_/¯
11:40:30*PMunch quit (Read error: Connection reset by peer)
11:41:06*PMunch joined #nim
12:06:02*supakeen quit (Quit: WeeChat 3.2)
12:06:29*audiophile_ joined #nim
12:06:54*supakeen joined #nim
12:16:17*rockcavera joined #nim
12:16:17*rockcavera quit (Changing host)
12:16:17*rockcavera joined #nim
12:17:54FromDiscord<Chiggy> looks like jsony doesnt use the rename hook on toJson ? https://media.discordapp.net/attachments/371759389889003532/877164329810673700/unknown.png
12:18:13*max22- joined #nim
12:20:20audiophile_anything cool in nim in the last 6 months?
12:25:54FromDiscord<Rika> u
12:33:17audiophile_aww
12:51:32*pro joined #nim
12:53:00*pro quit (Client Quit)
12:55:09PMunchLast 6 months? Well NimConf 2021 happened :)
13:04:38FromDiscord<tandy> can you do list comprehensions in nim?
13:05:04FromDiscord<Clonkk> https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers#List-Comprehensions
13:05:22FromDiscord<tandy> ty
13:05:28PMunchDamn, did you have that already in your clipboard or something?
13:05:58FromDiscord<Clonkk> I have the Nim wiki in the favorite bar in Firefox \:D
13:06:20PMunchAha :P
13:06:22FromDiscord<Clonkk> Bookmark I think it's called
13:21:16audiophile_PMunch you were working on a nim interpreter iirc?
13:26:07PMunchI was?
13:31:44FromDiscord<KJ> is there a clean way to reverse a sequence?
13:32:05FromDiscord<Clonkk> https://nim-lang.org/docs/algorithm.html#reverse%2CopenArray%5BT%5D%2CNatural%2CNatural
13:33:28FromDiscord<KJ> thank you, looks like exactly what I am looking for
13:35:23PMunchHmm, my server appears to be completely borked..
13:35:25PMunchThat's fun
13:41:11FromDiscord<Rika> Nice
13:41:23FromDiscord<Rika> Did you perhaps forget to pay
13:52:54PMunchI have it for free at the university, so I have never paid for it :P
13:58:54*PMunch quit (Quit: Leaving)
13:59:19NimEventerNew thread by Samsamros: Simple connection GET using httpclient does not work when compiled to js, see https://forum.nim-lang.org/t/8336
15:10:06*audiophile joined #nim
15:12:08FromDiscord<Chiggy> What can I do so its `{}` instead of `{:}` ? https://media.discordapp.net/attachments/371759389889003532/877208175240151070/unknown.png
15:13:10*audiophile_ quit (Ping timeout: 240 seconds)
15:13:17*audiophile is now known as audiophile_
15:13:24FromDiscord<haxscramper> nothing. `$` shows `:` for empty table
15:13:39FromDiscord<haxscramper> You can reimplement own string conversion function if you want
15:13:55FromDiscord<Chiggy> hmm ok
15:16:54*audiophile_ quit (Quit: Default Quit Message)
15:21:53*stkrdknmibalz quit (Quit: WeeChat 3.0.1)
15:51:05*beshr joined #nim
15:54:07*Guest3138 quit (Quit: Konversation terminated!)
15:58:05FromDiscord<konsumlamm> `{}` already is the empty set, so the empty table is `{:}` instead
16:15:40NimEventerNew thread by Kalbhairab: Puzzle questions and solutions, see https://forum.nim-lang.org/t/8338
16:31:01FromDiscord<Chiggy> How do I compile for ubuntu 18.04 (I am on windows 10)
16:32:41FromDiscord<PsychoClay> wsl maybe
16:32:43FromDiscord<Clonkk> You can just work in WSL Ubuntu 18.04
16:32:49FromDiscord<Clonkk> It's probably the simplest way
16:33:16FromDiscord<Chiggy> Lol I don't remember me manually installing nim on wsl ubuntu https://media.discordapp.net/attachments/371759389889003532/877228597323128832/unknown.png
16:33:53FromDiscord<Ayy Lmao> How would you go about converting a tuple to an array, and raising an exception when the tuple doesn't have all the same data types? For some reason I'm struggling on this.
16:34:56FromDiscord<undersquire> u can convert a tupe to an array but idk how to account for inconsistent data types
16:35:09FromDiscord<undersquire> (edit) "u can convert a tupe to an array ... but" added "using ptr"
16:37:06FromDiscord<Ayy Lmao> In reply to @undersquire "u can convert a": How would you write a function that converts a tuple to an array with the type of the first field of the tuple?
16:37:56FromDiscord<undersquire> let me attempt at an example one sec
16:39:34*audiophile_ joined #nim
16:39:53*audiophile_ quit (Client Quit)
16:40:42*audiophile_ joined #nim
16:44:32FromDiscord<Clonkk> sent a code paste, see https://play.nim-lang.org/#ix=3wh4
16:45:02FromDiscord<undersquire> nvm clonkk's solution is better than mine XD
16:45:39FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=3wh5
16:45:59FromDiscord<Ayy Lmao> Not sure if it's completely sound but seems to work in the cases I've tried. Maybe it can be better
16:47:35FromDiscord<Clonkk> Depends what's your goal for non-homogenuous tuple. Like do oyu want to automatically convert element to your first element is a float ? DO you want a run time error ?
16:48:10FromDiscord<Clonkk> My solution will simply not compile if your tuple is not homogenuous
16:50:54FromDiscord<Ayy Lmao> In reply to @Clonkk "Depends what's your goal": Actually converting to the first element sounds pretty good. Not compiling seems better than a runtime error.
16:51:02madpropsis there a shortcut for: & " " & ?
16:51:09madpropsor is using strformat the only option
16:52:20arkanoidwhat's the best way to delete all xml elements with particular tag?
16:53:12arkanoidxmltree module provides only https://nim-lang.org/docs/xmltree.html#delete%2CXmlNode%2CNatural that deletes given parent and index
16:53:29arkanoidthat forces to do weird loop to delete them all
16:54:51FromDiscord<Rika> Loop backwards
16:55:21FromDiscord<Rika> That way deleting a node doesn’t change index
16:55:30arkanoidbut is it possible to iterate an iterator backwards?
16:55:39arkanoidI mean XmlNode items
16:56:10FromDiscord<Rika> Get child count and get child with the index?
16:57:54arkanoidI really like overengineering things! Your solution is too simple
16:57:56arkanoid:D
16:57:58arkanoid.. thanks
16:58:44FromDiscord<Rika> If you really want the reverse iterator just make it with the index thing I said I don’t know
16:58:55FromDiscord<Rika> (edit) "said" => "said,"
17:00:50FromDiscord<leorize> there aren't any way
17:00:51FromDiscord<leorize> you can just do a `for idx in countdown(node.len - 1, 0)` though
17:04:13arkanoidyeah I've already implemented the recursive countdown thing
17:25:06*Onionhammer joined #nim
17:37:28FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=3wht
17:48:45*Onionhammer quit (Ping timeout: 258 seconds)
18:19:59FromDiscord<tandy> how do you escape a " in a string in nim?
18:21:26FromDiscord<haxscramper> `\"`
18:21:41FromDiscord<haxscramper> Or `r"raw string lit""eral"`
18:21:54*max22- quit (Ping timeout: 272 seconds)
18:22:40FromDiscord<haxscramper> or `"""raw string lit"eral"""`
18:23:34FromDiscord<tandy> i did this but when i echo the string it shows up
18:23:59FromDiscord<tandy> trying this now
18:25:39FromDiscord<haxscramper> !eval echo "raw string lit"eral"
18:25:41NimBotCompile failed: /usercode/in.nim(1, 26) Error: closing " expected
18:25:53FromDiscord<haxscramper> !eval echo "raw string lit"eral"
18:25:55NimBotCompile failed: /usercode/in.nim(1, 26) Error: closing " expected
18:25:58FromDiscord<haxscramper> wtf
18:26:17FromDiscord<tandy> !eval echo """ test " wow """
18:26:19NimBot test " wow
18:26:33FromDiscord<haxscramper> yes, matrix is being extra smart with `\"`
18:26:53FromDiscord<tandy> reee
18:27:06FromDiscord<haxscramper> sent a code paste, see https://paste.rs/9P8
18:27:41FromDiscord<tandy> hm
18:29:49madpropsis there way to check if a char is a number?
18:30:19FromDiscord<haxscramper> \`ch in '0' .. '9'
18:30:29madpropsah nice
18:40:29*xet7 quit (Remote host closed the connection)
18:41:29*xet7 joined #nim
18:59:38*max22- joined #nim
19:03:58*stkrdknmibalz joined #nim
19:14:30FromDiscord<PsychoClay> for some reason orc keeps killing my threads 😩 no exceptions or anything
19:15:13FromDiscord<Yardanico> In reply to @PsychoClay "for some reason orc": orc can't "kill threads" :P
19:15:38FromDiscord<PsychoClay> well when i use the default gc they dont die
19:25:31madpropsis it not possible to have very big ints? int64(10000000000000000000)
19:27:16FromDiscord<Yardanico> it is possible
19:28:07FromDiscord<Yardanico> ah wait
19:28:14FromDiscord<Yardanico> your number is out of int64 range, it's not possible obviously :)
19:28:27madpropssaw some int128 but it's for compiler use only
19:28:30FromDiscord<Yardanico> nim doesn't support arbitrary precision integers by default, and "int64" is clearly a 64-bit integer
19:28:38FromDiscord<Yardanico> In reply to @madprops "saw some int128 but": there are libs like https://github.com/status-im/nim-stint
19:40:15NimEventerNew thread by Cnerd: Wrapping cpp code, see https://forum.nim-lang.org/t/8339
19:40:19*xet7 quit (Remote host closed the connection)
19:42:37*xet7 joined #nim
19:47:11*_KurtGodel_ quit (Read error: Connection reset by peer)
19:47:33*_KurtGodel_ joined #nim
19:49:04*xet7 quit (Quit: Leaving)
19:56:18FromDiscord<RattleyCooper> is it possible to get the string result of `execShellCmd`? It doesn't appear to write results to `stdout` or anything like that. `osproc` procs only work on binaries like exes and whatnot (`dir` throws an error saying command is not found on windows when using `osproc`).
19:57:01FromDiscord<RattleyCooper> `execCmdEx` works on binaries but not commands like `dir`
19:58:14FromDiscord<RattleyCooper> (edit) "`execCmdEx` works on binaries but not ... commands" added "system"
19:58:34FromDiscord<demotomohiro> I think you can call command like `dir` with `osproc` procs by using `poEvalCommand`.
19:58:48FromDiscord<RattleyCooper> You would think that would be the case but it's not
19:59:18madpropsnot sure how im using strformat wrong here https://play.nim-lang.org/#ix=3wim
19:59:54FromDiscord<RattleyCooper> In reply to @demotomohiro "I think you can": even with `poEvalCommand` I get the error: `"Requested command not found: \'dir\'. OS error:`
20:00:23madpropsthe first one doesn't work, the second one does
20:01:57FromDiscord<RattleyCooper> `strformat` has syntax like `fmt"{var1}, {var2}, {var3}"`
20:03:30FromDiscord<Yardanico> In reply to @RattleyCooper "even with `poEvalCommand` I": can you show the code you're using to use execShellCmd?
20:03:42FromDiscord<Yardanico> I think I know why it's failing
20:04:30FromDiscord<demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=3wip
20:04:34FromDiscord<Yardanico> yeah, exactly, maybe he missed poUsePath
20:04:42FromDiscord<Yardanico> also no need for cmd /c :P
20:05:26FromDiscord<Yardanico> ah wait, maybe it's different on windows
20:05:34FromDiscord<Yardanico> on linux it's an actual binary, seems like it's not on windows?
20:05:50FromDiscord<Yardanico> also @RattleyCooper if you just need to know the current directory, you don't need to use osproc
20:05:56FromDiscord<RattleyCooper> Well `execShellCmd` doesn't take any `po` options
20:05:58FromDiscord<enthus1ast> does one know how to catch a compile time exception?
20:06:00FromDiscord<Yardanico> https://nim-lang.org/docs/os.html#getCurrentDir
20:06:30FromDiscord<RattleyCooper> No, not looking for cwd, I actually need to issue system commands
20:06:37FromDiscord<RattleyCooper> And get the result
20:07:09FromDiscord<RattleyCooper> I am testing with @demotomohiro's example really quick
20:07:28FromDiscord<haxscramper> Inside of a macro you can just use `try/catch`
20:07:29FromDiscord<haxscramper> Outside of a macro or inside?
20:07:31FromDiscord<RattleyCooper> My original command was `var procRes = execCmdEx(theCommand, options={poEvalCommand, poUsePath})`
20:07:39FromDiscord<haxscramper> But when macro is expanded there is no way
20:07:51FromDiscord<enthus1ast> i want to use doAssertRaises in a test
20:07:57FromDiscord<enthus1ast> outside a macro
20:08:21FromDiscord<haxscramper> you want to check whether macro actually gives and error on invalid input?
20:08:27FromDiscord<enthus1ast> yes
20:08:39FromDiscord<haxscramper> no, there is no way to test it using only code
20:08:43FromDiscord<haxscramper> you might use `testament` for this, and check for compilation output
20:08:50FromDiscord<enthus1ast> i could mybe testament
20:08:51FromDiscord<enthus1ast> yes
20:08:52FromDiscord<enthus1ast> \:)
20:09:19FromDiscord<haxscramper> https://nim-lang.org/docs/testament.html I thin `nimout:` is what you need
20:09:33FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3wiq
20:09:45FromDiscord<haxscramper> or errmgs
20:12:21FromDiscord<enthus1ast> i'm thinking, if macro exceptions are not catchable it might be a bad idea to throw them at all
20:13:08FromDiscord<enthus1ast> on the other side, it is a non recoverable error
20:14:31FromDiscord<haxscramper> I do throw exceptions in macros, because it allows for more natural code in the macro implementation
20:14:32FromDiscord<haxscramper> just raise things
20:14:40FromDiscord<enthus1ast> yes
20:14:57FromDiscord<haxscramper> I've also added helper tools for exceptions that allow me to actually produce adequate error messages
20:15:06FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3wit
20:15:23FromDiscord<RattleyCooper> @demotomohiro , @Yardanico, thanks for the tips! Got it working. It needed the `cmd /c` prefixed to the command. That was the piece I was missing.
20:15:42FromDiscord<haxscramper> I get stacktrace and actually error that shows what the fuck is wrong in the code, and no just "\<line\>\:\<column\> \<someone messed up something here\>"
20:15:51FromDiscord<enthus1ast> oh nice [haxscramper](https://matrix.to/#/@haxscramper:matrix.org)
20:15:51FromDiscord<haxscramper> And `error` had some troubles with that
20:16:33*tdc quit (Ping timeout: 248 seconds)
20:18:34madpropsso apparently what goes inside vars in &"{...}" is not evaluated with the currernt imports, but from the strformat namespace, if that's make sense. so i have to calculate some stuff beforehand
20:27:12FromDiscord<Yardanico> that's not exactly true, strformat's macro expands in your current invocation site
20:27:14FromDiscord<Yardanico> afaik
20:27:59madpropsi had to precalculate some variables though, or else it failed "no parseInt" it would say
20:28:18madpropsso Im guessing it had no access to strutils ?
20:29:06madpropsi'll run a quick test
20:29:48madpropsah weird it works in the playground
20:32:55madpropsoh i forgot one little detail
20:32:59FromDiscord<enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=3wiy
20:33:14madpropsit only wouldn't work in the integration test
20:33:28FromDiscord<enthus1ast> strange my (matrix) element always renders nim code blocks super strange
20:34:16FromDiscord<enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=3wiz
20:35:53*Vladar quit (Quit: Leaving)
20:35:53FromDiscord<enthus1ast> it is the\: `errormsg` and the `file`
20:38:15FromDiscord<haxscramper> In reply to @Yardanico "that's not exactly true,": it cannot bind symbols from the surrounding scope
20:38:48FromDiscord<haxscramper> or rather, it injects idents, while symbol might be a gensym so they are considered different
20:41:03madpropsif I run the integration test, it fails here: `return &"{numberwords(parseInt(split[0]))} point {numberwords(parseInt(split[1]))}"`
20:41:11madpropsbut if I run it inside the file itself it works fine
20:43:37madpropsit's this known, or should I make a forum thread?
20:44:51FromDiscord<haxscramper> it fails how exactly?
20:45:06madpropsit complains parseInt doesn't exist
20:45:17FromDiscord<haxscramper> You can make a multifile example in https://wandbox.org/
20:45:26FromDiscord<haxscramper> try importing parseutils?
20:45:26madpropsok
20:45:55madpropsoh i thought it would use strutils for that
20:45:56FromDiscord<haxscramper> it might have something to do with binding rules ... do you have strformat in genric/template/macro-expanded-code?
20:46:16FromDiscord<haxscramper> it is from strutils ... anyway, I meant to just import module with parseInt
20:46:46madpropsstrutils has parseint
20:46:59madpropsimporting parseutils doesn't change it
20:47:12madpropsi'll try making the files example
21:10:04*xet7 joined #nim
21:18:30FromDiscord<chicken mcnuggets> hi there im a nubie at nim and was wondering when to use a ref object and when to use a pointer object
21:18:39FromDiscord<chicken mcnuggets> (edit) "use" => "create"
21:18:44FromDiscord<chicken mcnuggets> (edit) "use" => "create"
21:20:18FromDiscord<Yardanico> In reply to @chicken mcnuggets "hi there im a": wdym "pointer object"?
21:20:38FromDiscord<chicken mcnuggets> something like this
21:20:44FromDiscord<chicken mcnuggets> sent a code paste, see https://paste.rs/YUc
21:20:47FromDiscord<Yardanico> this is a stack (value) object, not a pointer one
21:21:00FromDiscord<chicken mcnuggets> ohoh could u elaborate
21:21:27FromDiscord<enthus1ast> `` is nim's export marker
21:21:30FromDiscord<zidsal> @enthus1ast I am late too the party it is possible to test for macro throwing exceptions I do it
21:21:43*max22- quit (Remote host closed the connection)
21:21:54FromDiscord<Yardanico> In reply to @enthus1ast "`*` is nim's export": ah, forgot that some people might mistake it for this
21:22:02FromDiscord<Yardanico> yeah, in nim is not a pointer marker, it's an export marker
21:22:06FromDiscord<chicken mcnuggets> Ohhh
21:22:06FromDiscord<tandy> is there sugar for \`& " " &\` when combining strings like in python with \`, \`?
21:22:09FromDiscord<chicken mcnuggets> i see
21:22:12FromDiscord<Elegantbeef> It works like `public` in other languages
21:22:22FromDiscord<zidsal> never mind you've already worked it out
21:22:28FromDiscord<Yardanico> and usually you use a value object unless you need shared ownership or a recursive object
21:22:37FromDiscord<Yardanico> also see https://forum.nim-lang.org/t/3869
21:23:21FromDiscord<chicken mcnuggets> can you explain what an export marker is lol
21:23:31FromDiscord<chicken mcnuggets> like it can be exported?
21:23:32FromDiscord<chicken mcnuggets> LOL
21:23:32FromDiscord<Yardanico> as elegant beef said
21:23:36FromDiscord<Yardanico> public in other languages
21:23:37FromDiscord<chicken mcnuggets> ohh
21:23:39FromDiscord<chicken mcnuggets> gotcha
21:23:46FromDiscord<Yardanico> have you read first two nim tutorials?
21:23:57FromDiscord<Yardanico> also https://narimiran.github.io/nim-basics/ is useful
21:24:03FromDiscord<chicken mcnuggets> ty
21:25:05FromDiscord<haxscramper> In reply to @zidsal "<@!551349731532603393> I am late": do you have an example?
21:25:15FromDiscord<haxscramper> I would much rather prefer to know how to do this
21:25:18FromDiscord<zidsal> yup so I've only got it to work with testament
21:25:32FromDiscord<zidsal> is my test
21:25:34FromDiscord<zidsal> sent a code paste, see https://play.nim-lang.org/#ix=3wiT
21:25:50FromDiscord<haxscramper> oh, well, I thought it is something built-in
21:26:00FromDiscord<zidsal> sent a code paste, see https://play.nim-lang.org/#ix=3wiU
21:26:16*max22- joined #nim
21:26:20FromDiscord<zidsal> na it would be hard to build it in, if it errors at compile time! I'm just glad there is a way to do it
21:26:56FromDiscord<zidsal> (edit) "na it would be hard to build it in, if it errors at compile time! ... I'm" added "(how can you compile the test to run it if the macro errors at compliation)"
21:28:39FromDiscord<zidsal> I should prob make a pr to update the testament doc's as that wasn't document anywhere I had to dig through the testament code to find it as I was convinced there must be a way this is tested for the compiler project
21:30:23FromDiscord<haxscramper> Well, technically it is in the documentation, but considering they literally go like "the doc is not full, go dig in the source code, good luck"
21:36:35NimEventerNew thread by Lecale: Nim for UI Automation, see https://forum.nim-lang.org/t/8340
21:53:07*Pyautogui joined #nim
21:58:50*Pyautogui quit (Quit: Connection closed)
22:07:42*max22- quit (Quit: Leaving)
22:17:20FromDiscord<enthus1ast> also for async code, usually my "class" object in async code is a ref, since var cannot be captured↔(@Yardanico)
22:37:32*audiophile_ quit (Ping timeout: 245 seconds)
22:42:21*Gustavo6046 joined #nim
22:42:31Gustavo6046Good evening! :)
22:42:46Gustavo6046I've been interested in Nim lately, seeing how it compares to Rust and yet also how simple it also is.
22:43:10Gustavo6046https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers I'd like to point out that Python _does_ have fixed-size types, in its *ctypes* standard module. Though they're more often used for C bindings, which is fair.
22:55:27*flynn quit (Read error: Connection reset by peer)
22:56:34*flynn joined #nim
23:04:35*Onionhammer joined #nim
23:12:55FromDiscord<Yardanico> you can modify this wiki, it's not an official resource but rather user-contributed
23:51:58madpropswhat is the common equivalent of comparing datetimes in js like Date.now () - somedate in nim? Should I instantiate Time objects and compare those?
23:52:28madpropsalso is the standard to use milliseconds or other?
23:57:40FromDiscord<dom96> use the times module
23:57:43*systemds1cks is now known as systemdsucks
23:59:07madpropsI'm trying: int64(getTime().seconds) - seconds