<< 16-12-2021 >>

00:00:03*vicecea quit (*.net *.split)
00:00:03*cornfeedhobo quit (*.net *.split)
00:00:03*dv2 quit (*.net *.split)
00:00:03*Schnouki quit (*.net *.split)
00:00:03*GreaseMonkey quit (*.net *.split)
00:00:03*Onionhammer quit (*.net *.split)
00:00:03*notchris quit (*.net *.split)
00:00:04*Jjp137 quit (*.net *.split)
00:00:04*FromDiscord quit (*.net *.split)
00:00:38*NimBot joined #nim
00:00:45*noeontheend joined #nim
00:01:28*Colt quit (Remote host closed the connection)
00:01:50*jmdaemon joined #nim
00:02:11*greaser|q joined #nim
00:03:28*Colt joined #nim
00:03:56*greaser|q quit (Changing host)
00:03:56*greaser|q joined #nim
00:03:59*greaser|q is now known as GreaseMonkey
00:04:54*nixfreaknim[m] joined #nim
00:06:48*Jjp137 joined #nim
00:07:12*cornfeedhobo joined #nim
00:16:56*bigmanbird joined #nim
00:21:18FromDiscord<huantian> is there a way to make a seq of `n` length of default vals
00:24:11FromDiscord<Rosen> In reply to @huantian "is there a way": setLen on an initialized empty seq?
00:24:24FromDiscord<Rosen> Or it needs to be in one step
00:25:14FromDiscord<impbox [ftsf]> `newSeq[type](size)`
00:25:59*bigmanbird quit (Read error: Connection reset by peer)
00:26:15FromDiscord<Rosen> You know I always had an idea that would be the way to do it but I just never tried
00:33:23*noeontheend quit (Ping timeout: 256 seconds)
00:36:35*noeontheend joined #nim
00:43:53*bigmanbird joined #nim
00:44:33FromDiscord<Elegantbeef> https://nim-lang.org/docs/sequtils.html#newSeqWith.t%2Cint%2Cuntyped
00:44:37FromDiscord<Elegantbeef> For if you want custom default value
00:55:38FromDiscord<huantian> oh neat
00:56:17*noeontheend quit (Ping timeout: 240 seconds)
00:59:01*src quit (Quit: Leaving)
01:03:18FromDiscord<Yardanico> Oh, nice, https://plugins.jetbrains.com/plugin/15128-nim/versions new minor version out, so it's in development and wasn't abandoned :)
01:23:09*dv2 joined #nim
01:28:24*bigmanbird quit (Quit: Leaving)
01:33:40*arkurious quit (Read error: Connection reset by peer)
01:34:07*arkurious joined #nim
01:39:26nrds<Prestige99> What is the `likelyProc` in system? The docs don't really explain much
01:39:45nrds<Prestige99> The definition is just `proc likelyProc(val: bool): bool {.importc: "NIM_LIKELY", nodecl, noSideEffect.}`
01:51:36FromDiscord<exelotl> I don't think `likelyProc` is to be used directly, but system defines `likely` and `unlikely`
01:51:43FromDiscord<Yardanico> yeah I think so too
01:52:15FromDiscord<exelotl> Those allow you to hint that an expression is more likely to evaluate to true than false, and the C compiler can use that information to produce better optimized assembly
01:53:01FromDiscord<Yardanico> Yeah, although it's not a good idea to use it everywhere but rather find hot paths in your code if you really want to use it
01:53:08FromDiscord<Yardanico> IMO compilers are already good at this
01:53:26FromDiscord<Yardanico> And PGO will be much better than manually adding likely/unlikely
01:55:44FromDiscord<Yardanico> And it's not that hard to do with clang, although does require a few commands currently
01:55:45FromDiscord<Yardanico> https://forum.nim-lang.org/t/6295
01:57:28FromDiscord<exelotl> I wish that likely/unlikely were pragmas though, they feel like the more appropriate construct for the job since they affect codegen
01:59:26FromDiscord<Marisol> What's nim's equivalent of map<string, dynamic>?
02:00:32FromDiscord<Yardanico> In reply to @Marisol "What's nim's equivalent of": the closest you can get is by using an object variant
02:00:59FromDiscord<Yardanico> nim is a statically compiled language, it can't have a fully "dynamic" type without considerable changes to the runtime and the language itself
02:01:22FromDiscord<Yardanico> See for example https://nim-lang.org/docs/json.html, you can use JsonNode from here or define your own
02:01:44FromDiscord<Yardanico> (if you just use JsonNode you won't deal with json at all, it's just the type)
02:03:02FromDiscord<Marisol> sent a code paste, see https://play.nim-lang.org/#ix=3Iy1
02:03:09FromDiscord<Marisol> Hmm I'll look at JsonNode
02:03:16FromDiscord<Yardanico> as I said, you can use object variants
02:03:34FromDiscord<Yardanico> JsonNode is an object variant too, it's just a little handy so that you don't have to define your own type
02:04:09FromDiscord<Marisol> Ah you're right
02:04:20FromDiscord<Marisol> Thanks, I'll look on it
02:18:27*neurocyte0132889 quit (Ping timeout: 250 seconds)
02:32:05FromDiscord<Roundlay> Wondering if anyone can point me in the direction of any of native macOS (Metal) projects written primarily in Nim? I'd kind of like to avoid Swift/C++/Zig etc. if I can, and enjoy using Nim, but am not sure if it's up to the task yet.
02:33:38FromDiscord<fenrave> In reply to @Yardanico "Oh, nice, https://plugins.jetbrains.com/plugin/1512": This plugin is alright but it has a hard time actually just finding `nim` in the system path for whatever reason, so you have to manually configure everything sometimes
02:33:49FromDiscord<Yardanico> yeah I'm not saying it's the best
02:33:54FromDiscord<fenrave> kind of defeats the point of using something like intellij
02:33:55FromDiscord<Yardanico> I still use VSCode because it actually uses nimsuggest :)
02:34:18FromDiscord<fenrave> I wonder if fleet will have better nim integration
02:34:30FromDiscord<Yardanico> well it supports LSP
02:34:33FromDiscord<Yardanico> so you can just use nimlsp with it
02:34:51FromDiscord<Yardanico> but yeah, someone will have to write a syntax highlighting plugin if fleet can't use existing definitions from other editors
02:35:36FromDiscord<fenrave> I would hope it least supports vscodes definitions given that it's supposed to be a paid(not clear on this yet) competitor
02:35:59FromDiscord<fenrave> Now all I need is a reason to use nim and to learn it further 😎
02:37:42FromDiscord<fenrave> :cryingsunglasses:
02:41:17*arkurious quit (Quit: Leaving)
02:47:44FromDiscord<huantian> I have a few random complaints with vscode nim like not being able to see the type of something in it's declaration
02:48:03FromDiscord<Yardanico> that's related to nimsuggest actually
02:48:06FromDiscord<huantian> ah
02:48:11FromDiscord<Yardanico> it doesn'
02:48:21FromDiscord<Yardanico> (edit) "doesn'" => "doesn't give the type info in the declaration"
02:49:02FromDiscord<huantian> that's mildly annoying
02:49:44FromDiscord<gogolxdong (liuxiaodong)> How to serve large file downloading with Jester?
02:58:23FromDiscord<Marisol> If it's static file just serve it via nginx
03:00:34FromDiscord<Marisol> Or if you really want to use jester for it try to put them to ./public dir
03:09:44FromDiscord<gogolxdong (liuxiaodong)> sent a code paste, see https://play.nim-lang.org/#ix=3Iyc
03:10:01FromDiscord<gogolxdong (liuxiaodong)> Is this possible with staticDir set to getCurrentDir()
03:10:59FromDiscord<gogolxdong (liuxiaodong)> file is about 7GB
03:26:43FromDiscord<XeroOl> I've got a feature / change suggest for nim
03:27:17FromDiscord<XeroOl> I just pulled a repo from the internet, and they had a config.nims file that would check for an error condition and abort
03:28:02FromDiscord<XeroOl> and it called `quit("helpful error message here")`
03:28:24FromDiscord<XeroOl> in the output of nimble, I actually missed the error message because the stack trace was in bold and the message wasn't
03:28:40FromDiscord<XeroOl> would it be possible to make that message be highlighted or bold or more emphasized in some way?
03:30:12FromDiscord<Sabena Sema> In reply to @Marisol "What's nim's equivalent of": it should be possible to write a type like C++'
03:30:15FromDiscord<XeroOl> Here's an image of the output (on discord, might not send) https://media.discordapp.net/attachments/371759389889003532/920880478159011870/unknown.png
03:30:17FromDiscord<Sabena Sema> (edit) "C++'" => "C++'s `std::any`"
03:30:32FromDiscord<XeroOl> notice how easy it is to miss the "helpful error message" for the rest of the stack trace
03:30:46FromDiscord<XeroOl> (edit) "send)" => "send to libera / gitter)"
03:30:53FromDiscord<XeroOl> (edit) "Here's an image of the output (on discord, ... might" added "it"
03:31:19FromDiscord<Sabena Sema> but, ultimately, object variants are usually used, even map<any, dynamic> in most dynamic langs are such because most dynamic langs have "any" types that have special branches for small primitive types
03:34:12FromDiscord<Sabena Sema> In reply to @XeroOl "Here's an image of": you can use the terminal package to get style codes to make that bold
03:35:03FromDiscord<Sabena Sema> something like `quit(ansiStyleCode(styleBright) & "text")`
03:35:11FromDiscord<huantian> It wouldn't be good to force boldness on all `quit()`s
03:35:23FromDiscord<Sabena Sema> oh, you'd need to reset the style too or else everything will be bold after running your program
03:35:30FromDiscord<huantian> so that wouldn't be an option, you'd have to do it manually like above
03:36:00FromDiscord<Sabena Sema> quit(string,...) is just a shortcut for echo(string); quit
03:36:00FromDiscord<XeroOl> is there a way to not print the stack trace at all?
03:36:09FromDiscord<Sabena Sema> you can write your own function that calls writeStyled then quits
03:36:55FromDiscord<XeroOl> from what I can tell there's no way to return an error code but supress the stack trace
03:38:09FromDiscord<XeroOl> it just seems strange that a message that's meant to go to the user is supressed by the noise of the stack trace in one instance
03:38:13FromDiscord<XeroOl> anyway thank you very much
03:38:36FromDiscord<XeroOl> (edit) "one" => "this"
03:45:39FromDiscord<Marisol> @Yardanico @Sabena Sema I haven't understand object variants yet but I found `std/tables`, I can do map<string, string> for now! 😆
04:06:01*supakeen quit (Quit: WeeChat 3.3)
04:06:30*supakeen joined #nim
04:25:29*noeontheend joined #nim
04:33:46FromDiscord<Sabena Sema> what's the name of that lib where you supply like patch files and it runs c2nim for you on import?
04:35:02*xet7 joined #nim
04:39:34FromDiscord<huantian> Man why does dimscord have to use snake case for attributes
04:40:07FromDiscord<huantian> there's probably some reason that I don't know but still↵kind of a pain
04:42:17*noeontheend quit (Ping timeout: 240 seconds)
04:42:37*jmdaemon quit (Ping timeout: 240 seconds)
04:43:31FromDiscord<Elegantbeef> How is it a pain?
04:47:34FromDiscord<Sabena Sema> you don't need to use snake case to refer to them if you don't want to
04:48:10FromDiscord<Sabena Sema> `m.channel_id` is the same as `m.channelId` in nim
04:48:56FromDiscord<Elegantbeef> Odd that feature is one of the most complained about, but also often unknown
04:49:07FromDiscord<Sabena Sema> heh yeah
04:49:11FromDiscord<Sabena Sema> I like it
04:49:28FromDiscord<Sabena Sema> although I also liked the old fully insensitive `TFoo`, `RFoo` thing
04:49:45FromDiscord<Sabena Sema> esp because it discouraged writing ref objects needlessly
04:49:51FromDiscord<Sabena Sema> (edit) "needlessly" => "needlessly, sorta"
04:50:12*noeontheend joined #nim
04:50:26FromDiscord<Sabena Sema> idk if vscode-nim has an option to pick which one you like
04:50:47FromDiscord<Elegantbeef> It doesnt, i did have a start of it which seemed to work
04:51:52FromDiscord<Elegantbeef> Though i think there is the view it should be configurable for your nimsuggest/compiler
04:52:10FromDiscord<Sabena Sema> I thought whitespace sensitive precedence was cool too
04:52:25FromDiscord<Sabena Sema> nim's was less out there than what Fortress did
04:52:28FromDiscord<Elegantbeef> What's that in english?
04:53:35FromDiscord<Sabena Sema> there used to be an option to make `a+b c` parse as `(a+b)c`
04:53:48FromDiscord<Elegantbeef> Ah
04:53:51FromDiscord<Sabena Sema> each power of two spaces would increase precedence by 1
04:54:04FromDiscord<Elegantbeef> Odd but interesting
04:54:32*GnuYawk quit (Quit: GnuYawk)
04:54:44FromDiscord<Rika> In reply to @Sabena Sema "there used to be": That's almost totally crazy lmao
04:54:46FromDiscord<Sabena Sema> Fortress was a sun research project (designed by Guy Steele!) and let you overload whitespace
04:54:50*GnuYawk joined #nim
04:54:58FromDiscord<Rika> That sounds like too much I don’t know
04:55:02FromDiscord<Sabena Sema> so you could have f(a, b) and f a, b etc do different things
04:55:11FromDiscord<Sabena Sema> and also you could have ab multiply a and b
04:55:18FromDiscord<Elegantbeef> That's crazy
04:55:22FromDiscord<Sabena Sema> yeah, the thing fortress did was pretty out there
04:55:28FromDiscord<Elegantbeef> Noob traps left/right 😀
04:55:37FromDiscord<Sabena Sema> but the rules weren't that bad
04:56:00FromDiscord<Elegantbeef> It makes sense, but it's pretty wacky
04:56:04FromDiscord<Sabena Sema> I mean, it's designed to allow APL style programming, but also allow you do write more structured library code
04:56:38FromDiscord<Sabena Sema> yeah, it's wacky and provokes a very strong negative reaction in most programmers
04:56:42FromDiscord<Sabena Sema> but I think it was a neat idea
04:57:19FromDiscord<Rika> It's a neat idea but it's doubtful it would be useful in reality
04:57:29FromDiscord<Sabena Sema> the idea behind nim's whitespace thing was to simplify precedence rules esp w.r.t. user defined operators
04:58:23FromDiscord<Sabena Sema> fortress had a bunch of cool stuff
04:59:23FromDiscord<huantian> In reply to @Elegantbeef "How is it a": It's a pain because I keep changing vscode's autocomplete ↵though --styleCheck:hint is helpful for when I forget
05:00:29FromDiscord<huantian> I meant to try to see if I could finish the case converter but then I died (mentally)
05:02:48*jmdaemon joined #nim
05:02:56*jmdaemon quit (Remote host closed the connection)
05:03:12*jmdaemon joined #nim
05:12:13*jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in)
05:18:02*jmdaemon joined #nim
05:19:30FromDiscord<gogolxdong (liuxiaodong)> Jester sendFile is different from how nginx does.
05:20:53FromDiscord<gogolxdong (liuxiaodong)> It seems cannot serve such large file.
05:24:06*jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in)
05:24:54*vicfred joined #nim
05:27:22*jmdaemon joined #nim
05:29:10*jmdaemon quit (Client Quit)
05:31:18*rockcavera quit (Remote host closed the connection)
06:00:32FromDiscord<Marisol> Yeah and probably no resume support. Definitely use nginx for static files, use jester to send dynamic data
06:01:12FromDiscord<spazzy> so i found another C library i could try to translate that does the same thing but its a full program instead of a single header file
06:01:30FromDiscord<spazzy> which do you think would package better
06:09:06*gshumway joined #nim
06:10:10FromDiscord<Rika> You can always convert full programs into libraries
06:13:46FromDiscord<Sabena Sema> both should be fine, c2nim isn't really designed to handle translating full programs (although it can, sorta)
06:15:06FromDiscord<spazzy> i already need to do it with futhark anyway since c2nim really doesnt like variadic macros
06:29:39FromDiscord<Sabena Sema> what's futhark?
06:31:54FromDiscord<Elegantbeef> https://github.com/pmunch/futhark a C importer
06:32:50FromDiscord<Sabena Sema> ah that's cool
06:34:02FromDiscord<spazzy> unless theres a nim equivalent i dont know about
06:34:22FromDiscord<spazzy> then i could just c2nim the header file after changing literally 3 lines and it would work fine
06:34:37FromDiscord<Sabena Sema> it's typical to have to modify headers a bit before using c2nim
06:34:52FromDiscord<spazzy> i just dont know the nim equivalent of this
06:35:13FromDiscord<spazzy> https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html
06:35:58FromDiscord<impbox [ftsf]> nim templates are similar to macros, and they can take varargs
06:37:30FromDiscord<impbox [ftsf]> (edit) "nim templates are similar to ... macros," added "C"
06:37:43FromDiscord<impbox [ftsf]> nim macros are much more powerful
06:37:56FromDiscord<spazzy> so i could probably just change
06:38:16FromDiscord<spazzy> '''#define whatever(...)'''
06:39:02FromDiscord<spazzy> (edit) "'''#define whatever(...)'''" => "sent a code paste, see https://play.nim-lang.org/#ix="
06:39:04FromDiscord<spazzy> to
06:40:00FromDiscord<spazzy> sent a code paste, see https://play.nim-lang.org/#ix=3IyM
06:40:15FromDiscord<impbox [ftsf]> no.... what is the C macro you're trying to convert to nim?
06:40:44FromDiscord<impbox [ftsf]> you'll need to use nim's template syntax https://nim-lang.org/docs/manual.html#templates
06:41:06FromDiscord<spazzy> yeah i know i just glanced at it without copying the syntax right tbh
06:42:18FromDiscord<spazzy> sent a code paste, see https://play.nim-lang.org/#ix=3IyN
06:42:34FromDiscord<spazzy> (edit) "https://play.nim-lang.org/#ix=3IyN" => "https://play.nim-lang.org/#ix=3IyO"
06:44:40FromDiscord<spazzy> or something close to that
06:44:41FromDiscord<spazzy> sent a code paste, see https://play.nim-lang.org/#ix=3IyP
06:44:49FromDiscord<Yardanico> we have `varargs` in Nim but that's mainly for C interop
06:45:00FromDiscord<Yardanico> well, actually not only for them, but yeah, it's not used often
06:45:05FromDiscord<Yardanico> but you can use them of course
06:45:15FromDiscord<spazzy> i mean im translating a c header file
06:45:25FromDiscord<impbox [ftsf]> for what purpose?
06:45:29FromDiscord<impbox [ftsf]> to wrap a c library?
06:45:33FromDiscord<spazzy> yeah
06:45:48FromDiscord<impbox [ftsf]> well you probably don't need that macro in the wrapper
06:46:02FromDiscord<spazzy> https://github.com/krychu/wfc
06:46:06FromDiscord<spazzy> it kinda relies on it
06:46:59FromDiscord<impbox [ftsf]> see that header file is not just a header
06:47:08FromDiscord<impbox [ftsf]> it's also an implementation file
06:47:14FromDiscord<spazzy> yeah
06:47:37FromDiscord<impbox [ftsf]> you only wrap the header bits
06:47:41FromDiscord<impbox [ftsf]> not the implementation bits
06:48:06FromDiscord<spazzy> which is why i was using futhark
06:48:12FromDiscord<impbox [ftsf]> all the bits inside #ifdef WFC_IMPLEMENTATION you can ignore
06:48:25FromDiscord<impbox [ftsf]> just wrap the few bits outside it
06:49:03FromDiscord<impbox [ftsf]> if you're going to wrap the implementation you may as well just reimplement it in nim
06:50:15FromDiscord<impbox [ftsf]> you only need to wrap lines 147..167
06:52:08FromDiscord<impbox [ftsf]> https://github.com/define-private-public/stb_image-Nim example of a header only c library wrapped in nim
06:52:31FromDiscord<spazzy> thats actually really convenient if i wanted to wrap the whole thing
06:52:53FromDiscord<impbox [ftsf]> though it goes a fair bit further than the minimum by making nice nimmy functions
06:53:06FromDiscord<spazzy> since the wfctool.c relies on stb_image
06:53:42FromDiscord<impbox [ftsf]> but wfctool isn't a library, so you don't need to wrap it
06:53:59FromDiscord<spazzy> yeah i know, i mean if i wanted to just rewrite the thing
07:48:27*PMunch joined #nim
07:54:57*PMunch quit (Quit: leaving)
08:01:33*PMunch joined #nim
08:56:06*Jjp137 quit (Ping timeout: 260 seconds)
09:10:01FromDiscord<Michal58> In reply to @Elegantbeef "https://github.com/pmunch/futhark a C importer": Huh I thought you people are talking about the programming language and was rather confused.
09:17:53PMunchA lot more people have heard of Futhark the programming language than I first anticipated..
09:18:24FromDiscord<Elegantbeef> rename it to "No not that Futhark"
09:20:20FromDiscord<Rika> PMunch more likely that a search yields the language first
09:20:22madpropsnever heard of it
09:21:22madpropsthat's a nice looking readme PMunch
09:21:47PMunch@Rika, yeah that makes sense. Just have to make Futhark more popular I guess :P
09:21:52PMunchmadprops, thank you :)
09:26:47FromDiscord<Michal58> In reply to @Rika "PMunch more likely that": I wasn't googling but might be the case in general
09:29:18FromDiscord<Michal58> I have futhark - the lang only as the last link on the 3rd page on Google
09:31:15PMunchWhat are you first three pages filled with? Info about the real Futhark stuff?
09:35:43madpropsi get an elder, runes, and the lang, on first page
09:36:22PMunchThe elder Futhark is just the old runic alphabet, so both those first ones are about runes
09:37:49madpropslast commit on github 2 hours ago, the lang
09:38:06PMunchOh yeah, it is an actively developed language
09:38:13PMunchJust didn't think it was that well known
09:38:40FromDiscord<Michal58> In reply to @PMunch "What are you first": Yeah basically
09:39:02FromDiscord<Michal58> In reply to @PMunch "Just didn't think it": I know it from the context free YT channel
10:31:23FromDiscord<Tanguy> Is there a way to read a file from nimscript?
10:32:28PMunchreadFile doesn't work?
10:32:44FromDiscord<Tanguy> `Error: undeclared identifier: 'copyMem'`
10:33:14FromDiscord<Tanguy> Ah, it works on devel but not on 1.2
10:33:44PMunchWorks for me on 1.2 as well..
10:34:31PMunchBut it appears to be a special `readFile` and not the one from the `os` module as I get `/tmp/test.nims(1, 8) Warning: imported and not used: 'os' [UnusedImport]` on 1.2 but not on 1.6
10:35:13FromDiscord<Tanguy> Mhh, it's broken on my script because of `import json`
10:35:13FromDiscord<Elegantbeef> Readfile isnt in os
10:35:42PMunchOh, you're right
10:35:53PMunchWhy isn't it shown as not used for 1.6 then?
10:36:22FromDiscord<Elegantbeef> Usage bug possibly??
10:36:53PMunchOr just the output flags for `nim e` have changed
10:37:49FromDiscord<Tanguy> So import json / parseJson / `from json import parseJson` breaks it↵I'm back to parsing manually I guess
10:38:21FromDiscord<Rika> Somewhat odd
10:39:01FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=3Izp indeed
10:39:52FromDiscord<Elegantbeef> The copymem error sounds like you're using a procedure that uses copymem, are you sure you've narrowed where it comes from?
10:40:02FromDiscord<Tanguy> Playground uses nimscript?
10:40:14FromDiscord<Tanguy> Oh no, const, ok
10:40:23FromDiscord<Elegantbeef> I assign an expression to a const which is done using nimscript
10:40:40FromDiscord<Elegantbeef> Or are we talking about an embedded VM?
10:41:01FromDiscord<Tanguy> A nimble file but I think that's the same as nimscript
10:41:10FromDiscord<Elegantbeef> Yea it's nimscript
10:41:18FromDiscord<Elegantbeef> Which is the same as compile time evaluation
10:41:29FromDiscord<gogolxdong (liuxiaodong)> How to convert array to string?
10:41:44FromDiscord<gogolxdong (liuxiaodong)> array/seq to string
10:42:39FromDiscord<Tanguy> sent a code paste, see https://play.nim-lang.org/#ix=3Izq
10:42:40FromDiscord<Tanguy> Must not by exactly the same then
10:43:08FromDiscord<Elegantbeef> you're compiling a nimscript ifle
10:43:31FromDiscord<Elegantbeef> Use `nim e test.nims`
10:43:42FromDiscord<Tanguy> Same
10:43:51FromDiscord<Tanguy> Oh but in your test you don't use readFile, only json
10:43:53FromDiscord<Elegantbeef> Wait `nim c .nims` evaluates it aswell i guess
10:44:07FromDiscord<Tanguy> It's readFile + import json which fails
10:44:14FromDiscord<ynfle (ynfle)> @gogolxdong with the ``$` ` operator
10:44:25FromDiscord<Elegantbeef> `Error: unhandled exception: cannot open: test.json [IOError]`
10:44:27FromDiscord<Elegantbeef> Nope
10:44:33FromDiscord<Elegantbeef> Works fine
10:45:04FromDiscord<Elegantbeef> What's your nim version?
10:45:07FromDiscord<Tanguy> 1.2.14
10:45:20FromDiscord<Tanguy> Latest and greatest 🙂
10:45:27FromDiscord<gogolxdong (liuxiaodong)> `$` converts to the format of `@[]` / `[]` string
10:45:31FromDiscord<Elegantbeef> That's not latest
10:45:33FromDiscord<Elegantbeef> Latest is 1.6
10:45:36FromDiscord<Tanguy> I know
10:45:54FromDiscord<Rika> Gogo if you want quick and dirty you can cast between them
10:45:57FromDiscord<Elegantbeef> That bug has been fixed in 1.6 if you look at the error it was cause something was using `streams` and didnt handle it for nimscript
10:45:58FromDiscord<ynfle (ynfle)> @gogolxdong So what to you want?
10:46:06FromDiscord<Rika> If you want correct you have to iterate and make a new container
10:47:08FromDiscord<gogolxdong (liuxiaodong)> string data
10:47:12FromDiscord<Elegantbeef> So i guess if you insist on using 1.2 find the PR that fixed it and request it be backported
10:47:46FromDiscord<ynfle (ynfle)> @gogolxdong Can you be more specific? I don't know what string data means. A string representation of the seq/array?
10:48:07FromDiscord<Rika> @gogolxdong did you see what I said?
10:48:15FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3Izr
10:48:23FromDiscord<Tanguy> But I don't understand why I can't repro it in the playground
10:48:40FromDiscord<Elegantbeef> What do you mean?
10:49:35FromDiscord<gogolxdong (liuxiaodong)> I found some similiar question in hisotry , some one uses arr.mapIt(char it).join
10:49:49FromDiscord<Tanguy> sent a code paste, see https://play.nim-lang.org/#ix=3Izs
10:50:08FromDiscord<Elegantbeef> Sounds like a regression with streams
10:50:29FromDiscord<Tanguy> Yeah but the playground is using the same 1.2.12 as me, no?
10:50:42FromDiscord<Elegantbeef> Thought you said you were using 1.2.14
10:50:50FromDiscord<gogolxdong (liuxiaodong)> which is better, copyMem or mapIt.join
10:50:52FromDiscord<Tanguy> I have the same issue on 1.2.12
10:50:58FromDiscord<Elegantbeef> As do i
10:51:10FromDiscord<Elegantbeef> Playground might be running arm which might behave differently?
10:51:24FromDiscord<Elegantbeef> I dont know, all i know is it's fixed in modern version so something needs backported/fixed
10:51:28FromDiscord<Elegantbeef> Anyway i need to go to sleep
10:51:46FromDiscord<Tanguy> Mhh yeah, weird. thanks
10:52:39FromDiscord<Rika> Copy is better
10:55:32PMunchgogolxdong_(liuxiaodong), if you want to convert a seq[char] to a string you can just do a cast
10:55:45FromDiscord<Rika> Am I being ignored globally or what
10:55:46PMunchIt's a bit hacky, but they are essentially the same type
10:55:56PMunch@Rika, ignored?
10:56:09PMunchOh, you already said that :P
10:56:12PMunchSorry I was AFK
10:56:14FromDiscord<Rika> In reply to @Rika "Gogo if you want": Yeah I said it a while ago
10:56:34FromDiscord<Rika> I asked because no one seemed to acknowledge that I was here lol
10:57:48PMunch!eval echo hostCPU & " is the CPU on the playground ElegantBeef"
10:57:50NimBotamd64 is the CPU on the playground ElegantBeef
11:05:21*Jjp137 joined #nim
11:08:58*toothlessgear joined #nim
11:23:13FromDiscord<krisppurg> In reply to @huantian "Man why does dimscord": True, but I did it to also match discord's snake case json fields (which is used for json.to) but also to make it look a little nicer. Then again you can write attributes as in camelCase.
11:42:28FromDiscord<ynfle (ynfle)> @gogolxdong What do you want? If you `[1, 2, 3, 4] -> "1234"`then`sequtils.mapIt` & `strutils.join` if you want `['1', '2', '3']` the you can use join with out mapIt. You can also do copymem and cast, but cast isn't stable. ie. it's an implementation detail (may apply to copymem) as well
12:06:01*supakeen quit (Quit: WeeChat 3.3)
12:06:31*supakeen joined #nim
12:06:42PMunchI still hold that we should create a wrapper for `cast[string]` and `cast[seq[char/uint8/int8/byte]]` so that if this implementation detail changes then it won't break every program who depends on this behaviour
12:39:22*pro joined #nim
12:39:29*pro quit (Client Quit)
13:15:33FromDiscord<hmmm> sent a code paste, see https://play.nim-lang.org/#ix=3IzQ
13:23:06FromDiscord<el__maco> this is correct
13:23:24FromDiscord<el__maco> its called short circuit evaluation
13:24:40FromDiscord<hmmm> sent a code paste, see https://play.nim-lang.org/#ix=3IzS
13:25:36FromDiscord<el__maco> assuming the official nim tutorial knows the semantics, the answer is yes i.e. you don't need to do that 😅
13:26:23FromDiscord<hmmm> haha let's hope, I'll let you know if the entire mess will take fire and burn out
13:27:17FromDiscord<el__maco> easy enough to verify https://play.nim-lang.org/#ix=3IzT
13:35:56*rockcavera joined #nim
13:35:56*rockcavera quit (Changing host)
13:35:56*rockcavera joined #nim
13:40:42*lumo_e joined #nim
13:50:19FromDiscord<IsaacPaul> sent a code paste, see https://play.nim-lang.org/#ix=3Ivi
13:50:41FromDiscord<IsaacPaul> with optimizations on (o2 or o3)
13:54:40FromDiscord<el__maco> the compiler would have to be extra sure thing2() absolutely does not have side effects
13:55:36FromDiscord<el__maco> that said I it wouldn't surprise me if some compilers would postpone the call
14:02:10*arkurious joined #nim
14:05:51*vicfred quit (Quit: Leaving)
14:43:37*noeontheend quit (Ping timeout: 240 seconds)
14:53:02*xet7 quit (Quit: Leaving)
15:07:20*PMunch quit (Quit: leaving)
15:18:11*pro joined #nim
15:18:45FromDiscord<eyecon> What kind of solutions do we have currently for a previously unknown number of tasks, which should run "concurrently" (suspending as in Kotlin-like coroutines or blocking) and can spawn other tasks, and which need to pass information back (not just at completion but also in between)?
15:19:13FromDiscord<eyecon> I know threadpool which spawns threads, and `Channel`s as message-passing mechanism
15:20:22FromDiscord<eyecon> Do we have maybe a similar information passing mechanism which can be used with single-threaded concurrent (async/await) code? AFAIK the channels are not designed for non-multithread applications
15:22:30FromDiscord<JSONBash> There is a project to implement a CPS runtime (https://github.com/nim-works/cps) but it is a work in progress
15:23:24FromDiscord<JSONBash> other than that, there is asyncdispatch which uses async/await
15:24:23FromDiscord<JSONBash> but I don't know of any good threaded and async solutions (would like to know one too)
15:24:41FromDiscord<JSONBash> you could look at httpbeast and see how it has implemented a threaded and async system?
15:25:27FromDiscord<eyecon> In reply to @JSONBash "There is a project": Full-blown CPS is nice for sure, let's hope it's complete soon
15:25:41FromDiscord<eyecon> In reply to @JSONBash "you could look at": Good thinking, I'll do that, thanks
15:26:20FromDiscord<eyecon> In reply to @JSONBash "other than that, there": But no way to pass information between the concurrent running paths?
15:27:03FromDiscord<exelotl> @eyecon the actual built-in language mechanism for resumable functions is "closure iterators" - this is what async/await are built on-top of
15:27:07FromDiscord<exelotl> https://nim-lang.github.io/Nim/manual.html#iterators-and-the-for-statement-firstminusclass-iterators
15:28:43*pro quit (Quit: WeeChat 3.3)
15:29:15FromDiscord<eyecon> Yes, I saw that, I think that is _almost_ CPS but not quite
15:29:47FromDiscord<eyecon> Previously I dabbled in Kotlin and this is solved really really well there
15:30:15FromDiscord<eyecon> So I'm looking for things I can put together to achieve something similar
15:30:35FromDiscord<fumamatar> sent a code paste, see https://play.nim-lang.org/#ix=3IAD
15:30:50FromDiscord<fumamatar> (edit) "https://play.nim-lang.org/#ix=3IAF" => "https://play.nim-lang.org/#ix=3IAE"
15:34:03FromDiscord<eyecon> In reply to @JSONBash "There is a project": This looks actually quite good, thanks again
15:38:13FromDiscord<can.l> In reply to @fumamatar "Sorry for interrupting you": A seq is not just a pointer (it also has fields for length and capacity), this is why simply casting a pointer to a seq will not give you a valid seq object. One solution is to use copyMem to copy your ethernet_header into the buffer. In this case no call to alloc is necessary.
15:43:15FromDiscord<fumamatar> Oh that makes sense, thank you. copyMem sounds good, would there otherwise be something analogue to a char in c?
15:44:41FromDiscord<can.l> There is ptr byte and ptr UncheckedArray[byte], but I would not recommend using it in most cases.
15:45:18FromDiscord<fumamatar> oh well that makes sense, its quite literally the same as char
15:45:29FromDiscord<fumamatar> thank you for your help, i appreciate it !
15:48:15FromDiscord<Fish-Face> why is `--gc:none` slower than `--gc:orc` ... at least to me it seems that way, benching AoC problems
15:55:31FromDiscord<exelotl> could be that gc:orc is allowing you to reuse the same block of memory that was just freed (which may be cached or something) while gc:none forces new blocks to be allocated every time
16:30:49*fputs quit (Ping timeout: 250 seconds)
16:35:23*src joined #nim
18:10:40FromDiscord<hmmm> is aoc still going? I'm not hearing updates from pmunch
18:11:15FromDiscord<hmmm> !sheerluck !updatestatus
18:14:02FromDiscord<el__maco> I thought he said he's travelling and won't be streaming
18:14:18FromDiscord<hmmm> ah ok 👍
18:14:32FromDiscord<hmmm> who is leading nim leaderboard
18:15:15*jmdaemon joined #nim
18:29:18FromDiscord<kevin> Thoughts about nesting Nim func/proc for functions only used within that proc?
18:30:22FromDiscord<kevin> sent a code paste, see https://play.nim-lang.org/#ix=3IBv
18:30:42FromDiscord<kevin> if the local proc is only used within the greater scoped proc is this a good idea
18:31:10FromDiscord<kevin> or should you just keep them in the same scope level
18:31:50FromDiscord<kevin> sent a code paste, see https://play.nim-lang.org/#ix=3IBx
18:31:59FromDiscord<kevin> (edit) "https://play.nim-lang.org/#ix=3IBx" => "https://play.nim-lang.org/#ix=3IBy"
18:33:15FromDiscord<Rosen> I like not polluting the global namespace so I'd always nest as long as I was SURE it wouldn't ever be reused in a different proc
18:35:01NimEventerNew thread by Miran: Nim 1.2.16 released, see https://forum.nim-lang.org/t/8715
18:35:42FromDiscord<exelotl> both are acceptable, I do like nested procedures though, as they can make it easier to reason about the code (when you see an unexported function at the top level you have to figure out where is it used in the file - nested procedures simplify that)
18:39:39*xet7 joined #nim
19:03:05NimEventerNew thread by Despam: Nim - shell, see https://forum.nim-lang.org/t/8716
19:05:28FromDiscord<Michal58> sent a code paste, see https://play.nim-lang.org/#ix=
19:12:42*tombrick joined #nim
19:13:59FromDiscord<Michal58> my Nim is weird
19:16:54FromDiscord<Solitude> windows has 1 mb stack limit according to stackoverflow
19:16:56FromDiscord<el__maco> aren't nim arrays on the stack? Maybe asking for 2MB is too much
19:17:01FromDiscord<Solitude> you allocate 4 mb
19:17:22FromDiscord<el__maco> 4MB yes, I forgot the int is 64 bit
19:17:53FromDiscord<Michal58> ok thanks
19:18:19FromDiscord<Michal58> I just trying my original code in the playground and it worked first time
19:18:25FromDiscord<Michal58> i lost 2 hors to that
19:18:27FromDiscord<Solitude> playground runs on linux
19:18:36FromDiscord<Solitude> which has 8 mb stack limit by default
19:18:39FromDiscord<Michal58> In reply to @Solitude "playground runs on linux": ik that's what I'm saying
19:19:16*noeontheend joined #nim
19:19:17FromDiscord<Michal58> how do I change the limit?
19:22:17FromDiscord<demotomohiro> I think you need to google "man gcc" and pass the gcc option via --passC.
19:23:06FromDiscord<demotomohiro> Or use seq instead of array.
19:25:46*krux02 joined #nim
19:26:13FromDiscord<Recruit_main707> id say once you are at 4mb you are most likely not gonna get any kind of performance improvements compared to using sequences
19:26:28FromDiscord<Recruit_main707> probably the opposite
19:35:53FromDiscord<Michal58> yeah, that makes sense
19:43:02FromDiscord<Michal58> Thank you everyone
19:54:19tombrickthis compiles and works without examining the list of children, but obviously "children" ("para5") is meant to be some sort of unchecked array of Windows. is it possible to pass in something or cast it with the existing proc signature? https://termbin.com/dkcm
19:59:41tombricki was trying to find some examples of UncheckedArray and types in similar function calls, too, without success
20:07:37*lumo_e quit (Ping timeout: 240 seconds)
20:08:19tombrickoh! i think i got it with cast[ptr UncheckedArray[Window]](children)
20:10:59FromDiscord<Michal58> Would it be possible to say the error is due to exceeding the stack size limit in the error message? @Recruit_main707 @Solitude @elmaco
20:14:12FromDiscord<Recruit_main707> idk
20:16:35*noeontheend quit (Ping timeout: 256 seconds)
20:19:36FromDiscord<Solitude> In reply to @Michal58 "Would it be possible": error message comes from os
20:20:30FromDiscord<Michal58> ok detect that at compilation time then
20:20:40FromDiscord<Michal58> at least give a warning
20:20:54FromDiscord<Michal58> ?
20:22:01FromDiscord<Solitude> ok
20:22:49*lumo_e joined #nim
20:53:20FromDiscord<analesthetist> hi, i'm quite new to the language and i'm checkout out parallelization
20:53:32FromDiscord<analesthetist> i'm trying to paralelize an iterator
20:53:58FromDiscord<analesthetist> but i think the iterators are sharing memory
20:54:43FromDiscord<analesthetist> because internally the iterator created a table and a deque
20:54:59FromDiscord<analesthetist> and weird stuff happens que running in parallel
21:32:33FromDiscord<el__maco> I'm not convinced that the compiler could give a warning for running out of stack. It probably could in trivial cases, but the trivial cases are relatively easy to figure out anyways 🤷‍♂️
21:33:14*bkay joined #nim
21:34:25*beshr quit (Ping timeout: 268 seconds)
21:34:48FromDiscord<leorize> I don't see why it could not, the compiler has to allocate this space for variables anyway, and it knows all the sizes
21:35:42FromDiscord<el__maco> yes but it doesn't know what happens at runtime
21:37:16FromDiscord<ynfle (ynfle)> Doesn't nim allocate itself?
21:40:14FromDiscord<el__maco> not sure what you mean
21:41:48FromDiscord<leorize> variables in a function are typically allocated up front
21:42:07FromDiscord<leorize> so the compiler know how much stack is necessary for a stack frame
21:42:42FromDiscord<el__maco> local variables are on stack, and you cannot allocate them ahead of time. But obviously you have to know how much space is required
21:42:48FromDiscord<leorize> now if you do recursion, then it's not detectable by the compiler, but the cost of a stack frame is definitely measurable
21:43:43FromDiscord<el__maco> when you know how much stack you need you increment or decrement the stack pointer by that amount, and whether or not you run out depends on where the stack pointer was at that moment
21:44:09FromDiscord<el__maco> this takes place at runtime, at compile time you don't know
21:44:25FromDiscord<leorize> yea but the compiler knows how much would a function need to run, like the minimum needed
21:44:38FromDiscord<el__maco> yes, but it doesn't know your call stack
21:44:51FromDiscord<el__maco> so it can only reason about the trivial case
21:45:17FromDiscord<leorize> yes, but you could easily catch a 1MiB stack frame caused by oversized variables
21:45:33FromDiscord<el__maco> 1MB can be perfectly okay, even on Windows
21:45:56FromDiscord<el__maco> though I wouldn't necessarily write such code but you know
21:47:25FromDiscord<el__maco> you could add a warning for the trivial case surely, but how useful that would be since you cannot rely on that warning at all
21:49:43FromDiscord<leorize> it can still be plenty useful, we have more warnings than most users will see
22:06:02qwr"Error: cannot 'importc' variable at compile time; F_WRLCK" -- what it actually means? i'm cross compiling and specified --cincludes:/usr/arm-linux-gnueabihf/include but this seems to not help?
22:09:21*qwr thinks it tries to use in posix_other_consts.nim var F_WRLCK* {.importc: "F_WRLCK", header: "<fcntl.h>".}: cint
22:25:29FromDiscord<Sabena Sema> in general without recursion (or mutual recursion) you can put static bounds on stack size and then prove they are met
22:26:50FromDiscord<Sabena Sema> in terms of making sure (at runtime) the program will crash fairly gracefully if you run out of stack (or run out of memory in general) you need stack probes
22:27:18FromDiscord<Sabena Sema> oh, variable length arrays/alloca with runtime size can break static proofs of stack size too
22:27:23*qwr could work around the problem by replacing F_WRLCK with 1 (that is its value), but would be interesting to know what could be the cause (cross compiling on arm64 debian for armhf...)
22:27:26FromDiscord<Sabena Sema> but can still be dealt with using probes
22:27:50FromDiscord<Sabena Sema> (historically a lot of C99 compilers just ... didn't emit correct probes for alloca, which was embarrassing and led to the feature's removal
22:27:53FromDiscord<Sabena Sema> (edit) "removal" => "removal)"
22:32:03FromDiscord<Sabena Sema> you can't just ask the OS how much "stack space" is left at runtime and compare, since the kernel does not reserve enough memory to ensure programs can successfully execute, it'll only (at best) reserve memory exactly when you ask for it
22:32:14FromDiscord<Sabena Sema> so asking "is there memory" then allocating memory is a race
22:38:00FromDiscord<Sabena Sema> anyhow, you can get stack size checks by passing `--passc:/Gs` and perhaps gcc's `-fstack-check` option
22:38:18FromDiscord<Sabena Sema> gcc appears to like, not probe every page... I'm not sure
22:38:28FromDiscord<Sabena Sema> it also probes using writes which is extremely odd
22:56:09*tombrick quit (Quit: tombrick)
23:04:10*krux02 quit (Remote host closed the connection)
23:27:51FromDiscord<huantian> looking at <https://nim-lang.org/docs/tut2.html#object-oriented-programming-object-variants>↵and wondering if there's a way to notate that a proc returns a specific variant
23:28:22FromDiscord<Elegantbeef> Using a macro you could, but nothing built in
23:28:33FromDiscord<huantian> kk
23:34:58FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=3ICC here's an example
23:41:34FromDiscord<ynfle (ynfle)> @beef, it won't help for the type system though. Just more like a sanity check
23:43:12FromDiscord<Elegantbeef> Well you could also make it check it in the type system checking all constructors of the procedure
23:44:02FromDiscord<Elegantbeef> Basically check all assignment to result at CT assuming the functions they call dont rely on importC would work
23:44:14FromDiscord<Elegantbeef> It'd be a big ol' macro to write but it's mostly doable
23:44:54FromDiscord<ynfle (ynfle)> Only if you have control over it, ie. you have control over the library if it's not your own
23:46:08FromDiscord<Elegantbeef> I dont follow
23:47:06FromDiscord<ynfle (ynfle)> Never mind. Basically to ensure that the proc from the json module returns a certain type, or to enforce that the other person knows that this type is of a certain variant
23:47:13FromDiscord<ynfle (ynfle)> Either way. It's some next level stuff
23:48:19FromDiscord<Elegantbeef> I think it's still doable with json since if anywhere in the proc call stack there is an object constructed that doesnt have your given type you stop compilation
23:48:59FromDiscord<Elegantbeef> So if you call parseJson and you annotate your proc with `kind: jInt` or w/e the kind is and it finds constructors that dont construct with that kind it'd error
23:49:32FromDiscord<leorize> maybe one of these days we can create a macro that creates an union from a representation \:p
23:50:04FromDiscord<Elegantbeef> lol
23:50:24FromDiscord<Elegantbeef> doesnt even know what that means
23:50:47FromDiscord<leorize> factor JsonNode -\> JInt, JNull, etc. automatically
23:51:14FromDiscord<leorize> and when used with `union`, for example, any combination of these types result in the `JsonNode` object, but distinct \:p
23:54:42FromDiscord<MegaIng (MegaIng)> sent a code paste, see https://paste.rs/YTD
23:56:10FromDiscord<Elegantbeef> You can put the nonref before the ref, however odd
23:57:08FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3ICF
23:57:12FromDiscord<Elegantbeef> Seems it's just an issue with the generic type definition
23:57:36FromDiscord<Elegantbeef> Dont know if you were adding more to the `obj` if not this is a good way of doing it
23:58:15FromDiscord<Elegantbeef> Oh nvm i broke the type definition like a dummy
23:58:57FromDiscord<Elegantbeef> Putting the obj before the ref solves the issue so seems like an issue with the generic cache
23:59:11FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3ICG