<< 24-03-2023 >>

00:00:06FromDiscord<QuiteQuietQ> ok, I thought there is something similar to `setTimeout` :D... and I read the code on geeksforgeeks wrong, it is not using set timeout, nvm
00:05:01FromDiscord<Gumbercules> Oh for the JS backend yeah
00:05:15FromDiscord<Gumbercules> I figured you were referring to the C backend, apologies
00:07:59FromDiscord<BobBBob> it seems like most nim code has any custom types in one big block at the top of the code, but whats the "standard" way to organize procs after that? because usually in other languages you have method functions for a type and they all get bunched together but nim doesnt really have those so you could put them wherever
00:15:48*fallback quit (Quit: IRCNow and Forever!)
00:16:21FromDiscord<Elegantbeef> Indeed you can put them anywhere
00:16:31FromDiscord<Elegantbeef> Generally you write the code in such away that you build upon previous things
00:17:36FromDiscord<PunchCake> Sooo guys
00:17:59FromDiscord<PunchCake> I need an easy to use mobile framework for nim
00:18:11FromDiscord<Elegantbeef> Unlike other languages aside from hooks there are no concepts of type bound operations really(araq wants to change this) so there is no real enforced design requirement
00:18:12FromDiscord<PunchCake> It doesnt matter if its native or not
00:18:23FromDiscord<Elegantbeef> Your options are very limited
00:18:31FromDiscord<PunchCake> What are my options
00:18:39FromDiscord<PunchCake> I heard about wiish for nim
00:18:46FromDiscord<PunchCake> Aka why is it so hard
00:18:53FromDiscord<PunchCake> To make a cross platform app
00:18:56FromDiscord<Elegantbeef> Partly due to how mobile works, partly due to the small dev pool
00:18:57FromDiscord<Elegantbeef> nimx and fidget work iirc
00:19:41FromDiscord<PunchCake> Nimx looks very ugly
00:19:52FromDiscord<Elegantbeef> Nice
00:19:58FromDiscord<PunchCake> To the point where if I'd ship my app I'd get bitch slapped to oblivion
00:20:12FromDiscord<Elegantbeef> Cool, perhaps Nim isnt for this project
00:20:15FromDiscord<Elegantbeef> Atleast for the frontend
00:20:41FromDiscord<Elegantbeef> You could use kotlin or java for the front end and call into native Nim code
00:20:54FromDiscord<PunchCake> I dont know why is it this hard
00:21:16FromDiscord<PunchCake> Opengl can run on nearly every major os
00:21:21FromDiscord<PunchCake> Including mobile
00:21:26FromDiscord<Elegantbeef> Cause mobile devices are designed in such a way to encourage the use of specific languages
00:21:51FromDiscord<PunchCake> Welp react native is used a lot in production
00:22:00FromDiscord<PunchCake> And look at it its doing very well
00:22:07FromDiscord<Elegantbeef> You can technically use any language but you're encouraged to use JVM and Swift
00:22:31FromDiscord<Elegantbeef> It's not an easy task to replicate react unpaid
00:22:42FromDiscord<Andreas> In reply to @Elegantbeef "Cause mobile devices are": yes, IOS lingua-franca = Swift | Android= Java
00:22:45FromDiscord<PunchCake> The thing is kotlin itself is simple but the amount og complexity of the apis is insane
00:23:16FromDiscord<PunchCake> (edit) "og" => "of"
00:23:42FromDiscord<Elegantbeef> 2400 contributors and funded/developed by facebook
00:24:02FromDiscord<PunchCake> Hm yeah
00:24:15FromDiscord<PunchCake> I dont really understand why we are forced to use java for android
00:24:41FromDiscord<Elegantbeef> Ok so then time for you to make a Nim cross platform GUI for Desktop and Mobile
00:24:54FromDiscord<Elegantbeef> Cause that's the language all of their OS interaction is written in
00:25:09FromDiscord<PunchCake> I thought about it
00:25:09FromDiscord<Elegantbeef> To use other languages you have to bind to that code somehow
00:25:29FromDiscord<BobBBob> isnt there qt bindings for nim now
00:25:36FromDiscord<PunchCake> There is
00:25:39FromDiscord<Elegantbeef> Sure but QT doesnt support mobile
00:25:47FromDiscord<PunchCake> It does bro
00:25:49FromDiscord<PunchCake> Qt5
00:26:17FromDiscord<Elegantbeef> Guess i was thinking gtk
00:26:48FromDiscord<BobBBob> good luck getting it to work well on mobile though haha
00:26:52FromDiscord<Elegantbeef> If you really wanted to you could use the JNI to wrap the relevant java class you wanted
00:27:09FromDiscord<Elegantbeef> But anything is going to be much more work than just using a JVM language
00:27:26FromDiscord<PunchCake> Agreed
00:27:41FromDiscord<PunchCake> Maybe i could put in the work so other devs dont have to go through this bullshit
00:27:48FromDiscord<PunchCake> Aka take one for the team
00:28:32FromDiscord<PunchCake> Or i could just use react native its plenty fast and easy to use
00:28:54FromDiscord<BobBBob> if I remember the reason android is based around java is because back when it started it was to ensure cross platform compatibility and now theyve already got everything in java so they just have to go with it, as for apple it's just standard apple vendor lock in
00:29:13FromDiscord<Elegantbeef> It's not even really vendor lock in anymore in apple's case
00:29:27FromDiscord<Elegantbeef> Just a bit of NIH mixed with fancy ideas
00:29:39FromDiscord<PunchCake> In reply to @BobBBob "if I remember the": Idk why they didn't make their own language tailored for android
00:29:45FromDiscord<BobBBob> In reply to @Elegantbeef "Just a bit of": pssh that's what they tell you
00:30:05FromDiscord<Elegantbeef> Swift is now a cross platform language
00:30:09FromDiscord<BobBBob> In reply to @PunchCake "Idk why they didn't": i think it was originally a small independent project before getting bought (?) by google
00:30:09FromDiscord<Elegantbeef> Not that any one uses it as one
00:30:11FromDiscord<PunchCake> Nice joke
00:30:15FromDiscord<Elegantbeef> But it's totally allowed now
00:30:36FromDiscord<PunchCake> Bro fr?
00:30:47FromDiscord<PunchCake> I can use swift for cross plat dev now
00:30:57FromDiscord<Elegantbeef> Yes
00:31:08FromDiscord<PunchCake> The thing is i dont wanna support this walled garden bollocks so i dislike swift
00:31:53FromDiscord<PunchCake> And i think nimqt is the most reliable and stable bindings avaliable for qt right
00:32:42FromDiscord<Elegantbeef> If I really wanted to use Nim I'd just use either react native or a JVMlanguage / swift and call into a Nim dynamic library
00:32:56FromDiscord<Elegantbeef> Anything else is just an exuberant amount of time
00:33:16FromDiscord<PunchCake> So basically write all the logic in nim and write all the ui in js with the button callbacks
00:33:21FromDiscord<PunchCake> Sounds like a good idea
00:40:10FromDiscord<Nilts> `Error: unhandled exception: over- or underflow [OverflowDefect]`
00:40:26FromDiscord<Nilts> for `let n = Date.now()`
00:45:44FromDiscord<spoon> date.now?
00:45:53FromDiscord<spoon> this works
00:45:58FromDiscord<spoon> sent a code paste, see https://play.nim-lang.org/#ix=4rEh
00:46:13FromDiscord<Nilts> In reply to @spoon "date.now?": https://nim-lang.org/docs/jscore.html#now%2CDateLib
00:47:17*azimut quit (Ping timeout: 255 seconds)
00:48:05FromDiscord<spoon> compiling to js then?
00:48:09FromDiscord<Nilts> yes
00:51:13FromDiscord<Nilts> any ideas?
00:52:48FromDiscord<spoon> does now() from times not work with js?
00:54:06FromDiscord<Nilts> In reply to @spoon "does now() from times": it should not work from times, or depend on the js one.
00:54:22FromDiscord<Nilts> sent a code paste, see https://play.nim-lang.org/#ix=4rEj
00:57:02FromDiscord<spoon> times from stdlib does work with the js backend i just tested but if you need it for compatability...
00:57:16FromDiscord<impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=4rEk
00:59:11FromDiscord<impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=4rEl
00:59:36*derpydoo joined #nim
01:00:03FromDiscord<spoon> sent a code paste, see https://play.nim-lang.org/#ix=4rEn
01:00:05FromDiscord<spoon> what version of nim are you running?
01:00:10FromDiscord<spoon> i tested on devel
01:00:37FromDiscord<Nilts> In reply to @spoon "what version of nim": latest
01:00:54FromDiscord<Nilts> Although i cannot get devl, only head
01:00:56FromDiscord<spoon> latest release or devel?
01:01:02FromDiscord<spoon> are you using choosenim?
01:01:08FromDiscord<Nilts> In reply to @spoon "are you using choosenim?": yes
01:01:17FromDiscord<spoon> can do `choosenim devel` to get it
01:01:46FromDiscord<spoon> and `choosenim stable` if that doesn't work out
01:01:59FromDiscord<spoon> see if that fixes anything
01:02:15FromDiscord<Nilts> sent a code paste, see https://play.nim-lang.org/#ix=4rEp
01:02:21FromDiscord<spoon> missed an e
01:02:35FromDiscord<Elegantbeef> `devel` is hard to spell
01:02:50FromDiscord<impbox [ftsf]> the devel is in the details
01:02:54FromDiscord<Nilts> lol, i have been spelling it wrong this whole time
01:05:08FromDiscord<Nilts> sent a code paste, see https://play.nim-lang.org/#ix=4rEq
01:05:24FromDiscord<Nilts> Could be on a completely different line. Nim's bug reporting has done that too me.
01:05:32FromDiscord<spoon> how are you compiling it?
01:05:44FromDiscord<spoon> are you running `nim js filename.nim`?
01:06:56FromDiscord<Nilts> In reply to @spoon "are you running `nim": no other flags
01:08:03FromDiscord<spoon> hmm, are you using the function from jscore for compatibility reasons or something?
01:08:55FromDiscord<Nilts> In reply to @spoon "hmm, are you using": I am pretty sure it is the only one. And it is native, so faster ig
01:09:20FromDiscord<spoon> the one from times does work, i tested with the js backend to make sure
01:09:45FromDiscord<Nilts> In reply to @spoon "the one from times": also, I want an int, not a datetime
01:11:03FromDiscord<spoon> if you know what unit it uses there are functions to convert it into s, ms, unix time, etc
01:11:30FromDiscord<spoon> but since mine compiles i imagine the problem might be on another line
01:11:53FromDiscord<Nilts> In reply to @spoon "but since mine compiles": arg, nim's buggy error reporting
01:12:21FromDiscord<spoon> sent a code paste, see https://play.nim-lang.org/#ix=4rEr
01:12:23FromDiscord<Nilts> I just realized. It only tracks like every 5 lines for the js backend
01:12:39FromDiscord<spoon> is error reporting different for js?
01:12:53FromDiscord<Nilts> sent a code paste, see https://play.nim-lang.org/#ix=4rEs
01:13:31FromDiscord<Nilts> In reply to @spoon "is error reporting different": idk, but i have seen lots of places where it just says it is at an earlier line becuase on inaccuracy.
01:13:53FromDiscord<spoon> i've never had that problem with the c backend
01:13:54FromDiscord<spoon> hm
01:14:57*nanxiao joined #nim
01:17:23FromDiscord<Nilts> In reply to @spoon "run this snippet through": works. not devl, but works
01:17:37FromDiscord<Nilts> different machine
01:19:05FromDiscord<spoon> where is basicproc from?
01:21:08FromDiscord<Nilts> In reply to @spoon "where is basicproc from?": `type BasicProc = proc ()`
01:24:28FromDiscord<spoon> i'm getting a different error now: `Error: undeclared identifier: 'cstringArrayToSeq'`
01:29:04NimEventerNew Nimble package! embedfs - Embed directories in executables, easily, see https://github.com/iffy/nim-embedfs
01:44:26FromDiscord<Nilts> In reply to @spoon "i'm getting a different": with what code?
01:50:58FromDiscord<spoon> In reply to @not logged in "with what code?": something i imported is trying to use nativesockets which i believe doesn't work with js
01:51:49FromDiscord<spoon> apparently importing system does that
01:53:43FromDiscord<spoon> nope, it was asyncdispatch
01:53:57FromDiscord<spoon> compiled the function succesfully
02:10:07*nanxiao quit (Quit: Client closed)
02:26:43*nanxiao joined #nim
02:27:03*fallback joined #nim
03:17:22*fallback quit (Read error: Connection reset by peer)
03:24:13NimEventerNew Nimble package! yanyl - A library for using YAML with Nim, see https://github.com/tanelso2/yanyl
03:40:02*rockcavera quit (Read error: Connection reset by peer)
03:41:53*rockcavera joined #nim
03:41:53*rockcavera quit (Changing host)
03:41:53*rockcavera joined #nim
03:45:59*deadmarshal_ quit (Ping timeout: 246 seconds)
04:11:25*nanxiao quit (Quit: Client closed)
05:36:23*nanxiao joined #nim
05:55:02*advesperacit joined #nim
06:05:04FromDiscord<kubo39> what is over- or underflow errors? they seems totally different..
06:09:40FromDiscord<Elegantbeef> They're idientical some operation would have caused an integer to either go under `int.low` or above `int.high`
06:09:52FromDiscord<Elegantbeef> identical even
06:11:18FromDiscord<kubo39> i know it is overflow.
06:11:38FromDiscord<Elegantbeef> What?
06:11:57FromDiscord<Elegantbeef> Overflow is going over int.high, underflow is going under int.low
06:12:36FromDiscord<kubo39> typically underflow means floating point underflow AFAIK.
06:12:44FromDiscord<kubo39> https://en.wikipedia.org/wiki/Arithmetic_underflow
06:13:42FromDiscord<Elegantbeef> > When the term integer underflow is used, the definition of overflow may include all types of overflows, or it may only include cases where the ideal result was closer to positive infinity than the output type's representable value closest to positive infinity.
06:13:43FromDiscord<kubo39> going under int.low is also overflow
06:14:04FromDiscord<Elegantbeef> integer underflow is also an acceptable term for going below int.low
06:14:44FromDiscord<Elegantbeef> There is a whole entry about the definition and it's ambiguity
06:16:27FromDiscord<Elegantbeef> So i'd say that given colloquialisms it's fine to call below low is underflow
06:18:36FromDiscord<kubo39> oh, I've found these sentence in integer overflow page.
06:20:35FromDiscord<Elegantbeef> One of those cases when the term makes sense in the context sorta, so it's adopted as an acceptable term
06:21:06*nanxiao quit (Quit: Client closed)
06:25:32FromDiscord<kubo39> ok.
06:28:41*arkurious quit (Quit: Leaving)
07:02:06*nanxiao joined #nim
07:10:39*rockcavera quit (Remote host closed the connection)
07:17:37*kenran joined #nim
07:44:17*PMunch joined #nim
07:48:51*PMunch quit (Client Quit)
07:54:21*PMunch joined #nim
08:27:31FromDiscord<4zv4l> why isn't it valid ?
08:27:32FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4rFq
08:27:43FromDiscord<4zv4l> I get invalid control flow
08:27:54FromDiscord<4zv4l> this is the function
08:27:56FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4rFr
08:36:31PMunchYou have to have a `tmp` as the last thing in the block
08:36:36PMunchOtherwise it won't return it
08:37:06PMunchOh, and `break tmp` doesn't work like that
08:37:43PMunchTry something like this: https://play.nim-lang.org/#ix=4rFw
08:38:20PMunchThe `break X` syntax is to break out of a named block. So `break tmp` would break out of `block tmp:`
08:42:06*nanxiao quit (Quit: Client closed)
08:44:59NimEventerNew question by Elliot Cox: Which is the library for data visualization on Nim?, see https://stackoverflow.com/questions/75831559/which-is-the-library-for-data-visualization-on-nim
08:54:43*nanxiao joined #nim
09:29:36PMunchI think my obsession with inline blocks might've gone too far.. http://ix.io/4rFM/
09:37:00*deadmarshal_ joined #nim
09:41:45Zevvlooks fine to me
09:45:11*azimut joined #nim
09:52:47FromDiscord<4zv4l> In reply to @PMunch "The `break X` syntax": oh ok yeah makes sense
09:53:02FromDiscord<4zv4l> In reply to @PMunch "Try something like this:": I created a proc xD↵easier I guess
09:53:13*nanxiao quit (Quit: Client closed)
09:53:18FromDiscord<4zv4l> is there a way to access an array value like the json like if the bound is not correct, not throw an error ?
09:53:26FromDiscord<4zv4l> like I have to check around the current case
09:53:34FromDiscord<4zv4l> but if the case is at the border of the array I guess a panic
09:58:45*Notxor joined #nim
10:02:05*randomuser464876 joined #nim
10:05:50*kenran quit (Remote host closed the connection)
10:06:13*kenran joined #nim
10:41:04*nanxiao joined #nim
10:45:19FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4rGb
10:45:40FromDiscord<sOkam!> something like pairs, but pairs doesn't seem to work on iterables 🤔
10:47:47*nanxiao quit (Quit: Client closed)
10:53:55*nanxiao joined #nim
10:54:08ormiretsOkam: enumerate
10:54:15FromDiscord<amadan> Like have an incrementing index? Maybe https://nim-lang.org/docs/enumerate.html#enumerate.m%2CForLoopStmt
11:00:48FromDiscord<ieltan> sent a code paste, see https://play.nim-lang.org/#ix=4rGe
11:01:45FromDiscord<ieltan> I am on 1.6.10
11:02:17*nanxiao quit (Quit: Client closed)
11:08:01*jmdaemon quit (Ping timeout: 240 seconds)
11:11:34Amun-Raieltan: typeof Natural \n typeof 4
11:12:17Amun-RaNatural is a range
11:12:29*beholders_eye joined #nim
11:22:43NimEventerNew thread by mhComa: Why this code works?, see https://forum.nim-lang.org/t/10033
11:27:20*randomuser464876 quit (Quit: Client closed)
11:30:23FromDiscord<ieltan> sent a code paste, see https://play.nim-lang.org/#ix=4rGj
11:31:00*beholders_eye quit (Ping timeout: 252 seconds)
11:31:02FromDiscord<Yardanico> typeof of a type returns the typedesc
11:31:05FromDiscord<ieltan> In any case, how do i rewrite `4 is Natural` so it works in my usecase?
11:32:35FromDiscord<choltreppe> sent a code paste, see https://play.nim-lang.org/#ix=4rGk
11:34:38FromDiscord<Yardanico> In reply to @ieltan "In any case, how": https://forum.nim-lang.org/t/2470#62085 is an easy solution
11:34:54FromDiscord<Yardanico> `proc contains[T](a: typedesc[range], b: T): bool = b in a.low..a.high` courtesy of beef
11:35:33FromDiscord<Yardanico> then you can just do `echo 1 in Natural` because in Nim `in` operator calls `contains` overloaded for the types you're checking
11:36:32FromDiscord<Yardanico> In reply to @choltreppe "hey all, I want": You can actually do a similar thing but do it with `compiles` so that the code is checked to be side-effect free at compile-time, and then you error if it's not
11:36:45FromDiscord<Yardanico> https://forum.nim-lang.org/t/2923 for example
11:40:02FromDiscord<ieltan> In reply to @Yardanico "https://forum.nim-lang.org/t/2470#62085 is an easy": Oh man thanks !
11:40:19FromDiscord<ieltan> (This should be included in the stdlib imo)
11:43:00FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4rGm
11:43:00FromDiscord<ieltan> Ah it breaks when you feed it floats
11:43:01FromDiscord<ieltan> 😢
11:43:10FromDiscord<Yardanico> because Natural is for ints
11:43:20FromDiscord<ieltan> yeah
11:43:21FromDiscord<Yardanico> In reply to @Yardanico "something like this, although": @choltreppe try adding an `echo` inside the `checkSideEffects` and see it error out
11:43:30FromDiscord<ieltan> should check for floats ig
11:43:43FromDiscord<Yardanico> In reply to @ieltan "should check for floats": ranges can only be of one type
11:44:07FromDiscord<ieltan> In reply to @Yardanico "ranges can only be": No, i mean, in my code
11:44:21FromDiscord<Yardanico> In reply to @Yardanico "<@705152179782025308> try adding an": although making it a macro would be better so that it would show error in the place where it's used, and not in the template
11:44:24FromDiscord<choltreppe> In reply to @Yardanico "something like this, although": I actually just found a better solution for my problem :/ but thanks for your help
11:44:30FromDiscord<Yardanico> can you share it?
11:45:02FromDiscord<ieltan> Oh, what about `Positive` ?
11:45:24FromDiscord<Yardanico> what about it?
11:45:25FromDiscord<ieltan> its a range too oosp
11:45:51FromDiscord<Yardanico> In reply to @ieltan "its a range too": if you just want to check for numbers being in some range, you can just write procs that check it
11:45:59FromDiscord<Yardanico> ranges are just a short-hand for checking if a number is in the range manually
11:46:20FromDiscord<Yardanico> and for documenting needed arguments better
11:46:33FromDiscord<choltreppe> my original problem was that I wanted to assert specific variables dont get modified. so I noticed noSideeffect would be too harsh. and since I know wich vars are of interrest I can just do the good old `let x = x` showdowing inside a block trick.
11:47:54FromDiscord<ieltan> In reply to @Yardanico "if you just want": I already did that and I just want to avoid floats and negative numbers, but x.Natural takes cares of not having floats
11:48:00FromDiscord<ieltan> negatives are still a problem
11:48:19FromDiscord<Yardanico> not sure what you mean, use positive?
11:49:12FromDiscord<ieltan> Yeah i got it, thanks !
11:49:32FromDiscord<Yardanico> In reply to @ieltan "Yeah i got it,": also btw, ranges aren't some special magic, you can just define them in your own code too
11:58:53FromDiscord<sOkam!> How is ennumerate used with an iterable?
11:59:05FromDiscord<sOkam!> (edit) "ennumerate" => "enumerate"
12:12:00FromDiscord<Yardanico> In reply to @sOkam! "How is enumerate used": you just do `enumerate(iterable)`?
12:12:08FromDiscord<Yardanico> iterable should have items defined of course so it can be iterated on
12:22:44*PMunch quit (Quit: Leaving)
12:30:01*derpydoo quit (Ping timeout: 240 seconds)
12:56:24FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4rGL
12:56:47FromDiscord<sOkam!> i mean a literal iterable, not an object that can be iterated
12:57:30FromDiscord<sOkam!> enumerate seems to be working fine for strings,seq,etc... but the input is an iterable, not an object that can be iterated
13:03:08FromDiscord<konradmb> I need an aligned slice of memory, so I'm using posix\_memalign(). Then I need to free it, so I use c\_free().↵I think I'm supposed to use dealloc() in Nim, but it gives SIGSEGV when freeing. So are there any drawbacks when I use c\_free()?
13:03:54FromDiscord<spoon> are you using --mm:none?
13:04:53FromDiscord<konradmb> No, default devel, so orc
13:05:49FromDiscord<spoon> wondering if its smart enough not to insert an extra dealloc at compiletime
13:07:54FromDiscord<konradmb> Wait, what? So gc will free externally allocated memory from C?
13:08:39FromDiscord<konradmb> Or you mean to just leak?
13:11:00FromDiscord<spoon> i'd have to run benchmarks but on old memory management models i never had a problem with allocating external c anything
13:24:03FromDiscord<Gumbercules> In reply to @konradmb "Wait, what? So gc": No it won't. Use c_free.
13:24:48FromDiscord<Gumbercules> The memory wasn't allocated using Nims allocator - it doesn't have anything to do with GC.
13:28:49*nanxiao joined #nim
13:38:11FromDiscord<tandy> has anyone use nimporter with a futhark wrapped library?
13:38:11FromDiscord<tandy> has anyone used nimporter with a futhark wrapped library?
13:42:21*nanxiao quit (Quit: Client closed)
13:47:56FromDiscord<Phil> PMunch , the words of futhark have been uttered
13:48:16FromDiscord<Phil> (edit) "PMunch , ... the" added "I summon thee,"
14:04:18*beholders_eye joined #nim
14:11:18*rockcavera joined #nim
14:16:10FromDiscord<0ffh> In reply to @Isofruit "PMunch , I summon": I think @PMunch should work better, only there's two @PMunch
14:16:35FromDiscord<Phil> In reply to @0ffh "I think <@696333749570371585> should": I'm trying to reach the much more used matrix account, which reacts on mere name mentions
14:16:56FromDiscord<0ffh> In reply to @Isofruit "I'm trying to reach": Ah, I see! 👍
14:19:04*advesperacit quit (Ping timeout: 276 seconds)
14:27:29FromDiscord<Gumbercules> In reply to @konradmb "I need an aligned": It'd be really nice if we could do this in Nim
14:29:02FromDiscord<Gumbercules> I mean we can... But we either have to use mimalloc or malloc
14:29:12*jmdaemon joined #nim
14:30:11FromDiscord<Gumbercules> Nim's general purpose allocator doesn't offer any procedures related to controlling alignment
14:32:14arkanoidis it possible to make nim load dynamic libs in such a way that ldd would list them?
14:33:00FromDiscord<Yardanico> yes, you can link with them with -l C compiler option
14:33:02FromDiscord<PMunch> In reply to @Isofruit "PMunch , I summon": Who dares interrupt my slumber!
14:34:43*derpydoo joined #nim
14:35:00arkanoidYardanico, mmm weird, I'm doing that, prog works at runtime, but ldd is not listing my libfoo.so like if it gets loaded at runtime. I'm compiling with -lfoo
14:36:01FromDiscord<PMunch> In reply to @tandy "has anyone used nimporter": Haven't tried this, but I guess it should work
14:36:29FromDiscord<PMunch> Never used nimporter though, so really I have no idea
14:36:47FromDiscord<Yardanico> works here @arkanoid, although I've tried it with pcre and not a custom library
14:37:17FromDiscord<Yardanico> basically use std/re in code and then compile with `--passC:"-lpcre"` and it shows up with ldd
14:37:30FromDiscord<Yardanico> i'll try with a custom lib now as well
14:38:01arkanoidYardanico, please don't waste time on this. I'll try in a VM as it sounds weird to me too
14:38:16arkanoidthanks for the feedback
14:38:19FromDiscord<Yardanico> eh, it's not like I'm a very busy person :P
14:44:45*jmdaemon quit (Ping timeout: 255 seconds)
14:54:37FromDiscord<ajusa> In reply to @Yardanico "eh, it's not like": Merge my PR to cosmonim then 😛
14:54:48FromDiscord<Yardanico> there's a PR for it?!
14:55:00FromDiscord<Yardanico> sorry missed it
14:55:09FromDiscord<Yardanico> merged
14:55:34FromDiscord<Yardanico> lemme edit the readme so it mentions cloning recursively
14:55:50FromDiscord<ajusa> Ah forgot to add that, thanks
14:56:08FromDiscord<ajusa> The Cosmo include package makes a bunch of stuff compile out of the box thankfully
15:01:33FromDiscord<Yardanico> @ajusa looks like that stubs repo is missing a file needed for nim asyncdispatch though
15:01:38FromDiscord<Yardanico> sys/signalfd.h which I had in my stubs dir
15:02:43FromDiscord<Yardanico> hm weird, I remember cosmonim being able to compile asyncserv without stdlib patches later on, but seems like it's still the same
15:03:47FromDiscord<ajusa> In reply to @Yardanico "sys/signalfd.h which I had": Oops, I don't use async/await so I never verified that
15:04:31FromDiscord<ajusa> Easiest thing to do would be a PR to the stubs repo though
15:04:35FromDiscord<Yardanico> yeah
15:06:56FromDiscord<Yardanico> <https://github.com/fabriziobertocci/cosmo-include/pull/6>
15:11:38FromDiscord<Yardanico> btw @ajusa just curious, what projects did you use cosmopolitan for?
15:12:32FromDiscord<ajusa> In reply to @Yardanico "btw <@102899813149855744> just curious,": I was working on getting https://github.com/lovebrew/lovebrew to work with cosmonim
15:12:41FromDiscord<Yardanico> oh
15:12:44FromDiscord<ajusa> And I got it working as well locally, never made a PR
15:13:21FromDiscord<ajusa> As it's a game distributor for multiple different OS, it helps if it runs on all those OSs without issues 🙂
15:13:27FromDiscord<Yandall> sent a code paste, see https://play.nim-lang.org/#ix=4rI2
15:13:40FromDiscord<Yardanico> nope, a variable can only be of one type
15:13:45FromDiscord<Yardanico> you can use object variants though
15:13:48FromDiscord<Yardanico> (edit) "you can use object variants though ... " added "to achieve something similar"
15:15:15FromDiscord<Yardanico> something like this
15:15:17FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4rI3
15:15:28FromDiscord<Yardanico> you can make a nice constructor proc so you don't have to write the heavy object construction syntax every time
15:15:29FromDiscord<debris> sent a code paste, see https://play.nim-lang.org/#ix=4rI4
15:15:43FromDiscord<debris> (Sorry to burst in.)
15:16:16FromDiscord<Yardanico> @debris hi, is there any reason you can't just make proc overloads for each type?
15:16:38FromDiscord<Yardanico> for example you can have `proc newPoint(num: float64): FPoint = FPoint(kind: number, number: num)`
15:16:39*onetwo381 joined #nim
15:16:44FromDiscord<Yardanico> and just make more overloads for different types
15:17:05FromDiscord<Yardanico> or you can make a single proc that switches between kinds at compile-time which is essentially the same
15:17:14FromDiscord<Yardanico> with `when/elif/else`
15:17:36FromDiscord<debris> I want to be able to extend the types ad infinitum, this might not be scalable in this case↵(@Yardanico)
15:17:48FromDiscord<ringabout> See also => https://github.com/nim-lang/RFCs/issues/418#issuecomment-907698310
15:17:49FromDiscord<Yardanico> and yeah, if you always have same kind name and value, you can use a template to achieve what you wanted to achieve with a macro
15:18:19*onetwo38 quit (Ping timeout: 246 seconds)
15:18:19*onetwo381 is now known as onetwo38
15:18:39FromDiscord<Yardanico> also, I think `void` type for a variable is not something that'd work?
15:19:02FromDiscord<ringabout> Hopefully https://github.com/nim-lang/Nim/pull/21559 will be merged for v2.
15:19:07FromDiscord<Yandall> sent a code paste, see https://play.nim-lang.org/#ix=4rI5
15:19:17FromDiscord<debris> `ref void` , then? IIRC Lua uses null pointers for its `nil` value.
15:19:20FromDiscord<Yardanico> yes, see https://nim-lang.org/docs/tut2.html#object-oriented-programming-object-variants
15:19:29FromDiscord<Yardanico> In reply to @debris "`ref void` , then?": you can just do `discard` to have an empty branch
15:19:41FromDiscord<Yardanico> although then you'll need to write a specific overload for an empty value since there won't be an empty field
15:20:28FromDiscord<Yardanico> something like this maybe @debris ?
15:20:29FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4rI7
15:21:12FromDiscord<Yardanico> thanks to ufcs you can then do fancy stuff like `number.newPoint(1.0)`
15:22:37FromDiscord<debris> Oh, this is perfect! I think I'll take a look at templates some more.↵(@Yardanico)
15:22:47FromDiscord<debris> And that notation looks great too.
15:23:08FromDiscord<Yardanico> templates are "just" code substitution, you have to be careful with them because they just replace all references to the argument in their body to the argument itself
15:23:15FromDiscord<Yardanico> even if you don't write ``
15:23:29FromDiscord<Yardanico> https://nim-lang.org/docs/manual.html#templates
15:24:40FromDiscord<Yandall> @Yardanico the case statement has to use an enum? Or can I just use a string?
15:25:14FromDiscord<Yardanico> if you mean in the object itself for object variants, it has to be an ordinal type, so no strings
15:25:45FromDiscord<Yandall> Understand. Thanks
15:25:52FromDiscord<Yandall> (edit) "Understand." => "Understood."
15:40:26FromDiscord<Yardanico> @ajusa asynchttpserver does work after a bit of stdlib patching, in fact I could do the same by just defining -d:android, and then there's only one place that needs fixing - IN6_IS_ADDR_V4MAPPED not being defined in cosmopolitan https://media.discordapp.net/attachments/371759389889003532/1088849813321302126/image.png
15:40:58FromDiscord<Yardanico> I wonder if I can just define that thing myself to make the compiler happy
15:41:14FromDiscord<Yardanico> since it seems to be a simple C macro https://media.discordapp.net/attachments/371759389889003532/1088850015922954332/image.png
15:41:35FromDiscord<ajusa> Probably? Even if you have to use .emit. that'd work
15:42:23FromDiscord<Yardanico> wait actually Nim already includes a custom impl of it when -d:lwip is defined
15:42:28FromDiscord<Yardanico> https://media.discordapp.net/attachments/371759389889003532/1088850329010970755/image.png
15:42:55FromDiscord<Yardanico> although it also changes some other things so defining it is not desirable I think, but I can just copy it without modifying the stdlib, lemme try
15:44:50FromDiscord<Yardanico> although even -d:android defines some stuff, I think adding cosmLibc define to Nim would be good, but I don't know if it's worth adding more defines like that to the compiler :P
15:45:29FromDiscord<Yardanico> but yes it just works with `-d:android` and that proc impl copied with exportc
15:59:53FromDiscord<Yardanico> updated cosmonim
16:19:51FromDiscord<Nerve> In reply to @Yardanico "": Hey is that Iosevka font, or something else?
16:21:16FromDiscord<Yardanico> In reply to @Nerve "Hey is that Iosevka": yeah, Iosevka Semibold with font-weight 400
16:21:23FromDiscord<Yardanico> theme is https://marketplace.visualstudio.com/items?itemName=jackjyq.brogrammer-plus
16:21:56*azimut quit (Ping timeout: 255 seconds)
16:31:37FromDiscord<Entikan> is there something like python's defaultdict for nim?
16:35:43*arkurious joined #nim
16:35:55FromDiscord<Yardanico> In reply to @Entikan "is there something like": If you mean having default values for all keys that don't exist, I don't think so, but making one should be quite easy
16:36:14*kenran quit (Remote host closed the connection)
16:38:06FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4rIA
16:38:13FromDiscord<Yardanico> ofc you can make it always have default as a value and not as a proc
16:48:33FromDiscord<0ffh> Not bad for automatically generated code.↵I think ``d.table.getOrDefault(key,d.default) `` would be faster and less code.
16:49:07FromDiscord<Yardanico> In reply to @0ffh "Not bad for automatically": I did modify it a bit, it's not 100% copilot :) and yeah, getOrDefault should be better because it will shave off 1 extra key check
16:50:25FromDiscord<Yardanico> @0ffh there's a problem with using getOrDefault here though
16:50:37FromDiscord<0ffh> In reply to @Yardanico "I did modify it": Nevertheless, I really feel I must get myself CoPilot or something similar sooner or later.
16:50:45FromDiscord<Yardanico> since it's a proc, it always evaluates default, even if the key is in the table
16:50:53FromDiscord<Yardanico> so if the default proc does some side effects it'll bring undesirable results
16:51:37FromDiscord<Yardanico> there's https://nim-lang.org/docs/tables.html#withValue.t%2CTable%5BA%2CB%5D%2CA%2Cuntyped%2Cuntyped%2Cuntyped with which you can only have one key check, but it requires the table to be `var`
16:54:09FromDiscord<0ffh> In reply to @Yardanico "so if the default": Yeah, right! I didn't even really notice default is a proc, not just a value. 😂 ↵That's the downside to call without () in Nim I suppose, at the invocation point you can't tell a member from a method (in OO parlance).↵That's of course exactly the same issue that's also the upside... 🤔
16:55:57FromDiscord<Yardanico> In reply to @0ffh "Yeah, right! I didn't": well the code does use d.default() with parens :)
16:56:18FromDiscord<0ffh> Mine doesn't =)
16:56:41FromDiscord<0ffh> Q: What's the reason for a default proc?
16:57:27FromDiscord<0ffh> Instead of just a value, I mean.
16:57:48FromDiscord<Yardanico> because defaultdict in Python does that
16:58:23FromDiscord<Yardanico> at least one of its overloads
16:58:29FromDiscord<0ffh> Okay, I suppose "they must have a good reason" is a reason in itself.
16:58:53FromDiscord<0ffh> Not very satisfying though... 😂
17:20:16*fallback joined #nim
17:23:26FromDiscord<Entikan> In reply to @0ffh "Instead of just a": it's nice for n-sized 3d coordinates
17:23:49FromDiscord<0ffh> After looking at the examples in the Python docs, I think the reason is that it doesn't use a lot of value types.↵Imagine e.g. I gave it an empty list as the default value. When I read from an uninitialized key, I get that list. If I then modify that list, it modifies the default value.
17:24:34FromDiscord<0ffh> Similar for all kinds of Python objects.
17:25:22FromDiscord<Entikan> `voxels[iVec3(8,8,4)].add(sand)`
17:25:38FromDiscord<0ffh> You'd have the same problem in Nim with ref objects.
17:25:54FromDiscord<0ffh> In reply to @Entikan "`voxels[iVec3(8,8,4)].add(sand)`": Yeah, I see that's also a point.
17:26:19FromDiscord<Yardanico> @Entikan you have to care about performance though, I'd imagine doing this for a lot of voxels will be quite slow
17:26:57FromDiscord<Entikan> it's mostly a solution for memory, so you don't have to store giant arrays of air
17:27:08FromDiscord<Entikan> the default tile is air
17:27:09FromDiscord<0ffh> In reply to @Yardanico "<@716041936758374501> you have to": Yeah, I think it only works nicely if the voxel space is sparsely populated.
17:27:28FromDiscord<Entikan> (edit) "tile" => "tile/voxel"
17:27:53FromDiscord<Yardanico> In reply to @Entikan "it's mostly a solution": hm, then I guess you can write some custom code instead of such a type? it'd not look as pretty but it'll be custom for your needs so it shouldn't be slow
17:28:00FromDiscord<Yardanico> just getOrDefault should actually be enough for your usecase
17:28:16FromDiscord<Yardanico> voxels.getOrDefault(iVec(8, 8, 4), someStaticVarForAirTile)
17:28:27FromDiscord<Entikan> yeah that would do fine
17:28:58FromDiscord<Entikan> danke
17:30:37*jmdaemon joined #nim
17:46:33FromDiscord<Phil> Recompiling my project↵I eagerly await the day where the default gcc linker is faster than a snail
17:55:18FromDiscord<Yardanico> In reply to @Isofruit "*Recompiling my project* I": why not use mold if it's such a big project?
17:55:20FromDiscord<Yardanico> or are you using LTO?
17:55:22FromDiscord<Yardanico> (edit) "LTO?" => "LTO or something?"
17:56:00FromDiscord<Yardanico> <https://github.com/rui314/mold>
17:56:05FromDiscord<Phil> In reply to @Yardanico "or are you using": That's the one, ` --define:lto`
17:56:20FromDiscord<Yardanico> well, if you're developing something, don't use LTO for faster iteration times
17:56:31FromDiscord<Yardanico> LTO is only supposed to be used for final release builds really, and maybe for testing
17:56:32FromDiscord<Yardanico> (edit) "LTO is only supposed to be used for final release builds really, and maybe for testing ... " added "them"
17:56:47FromDiscord<Yardanico> it will slow down linking considerably for bigger projects obviously
17:56:53FromDiscord<Phil> Oh I am not, I am just mildly annoyed that doing prod builds takes like 3-5 minutes until the docker images are uploaded
17:57:00FromDiscord<Phil> Of which linking is at least 1-2 minutes
17:57:14FromDiscord<Yardanico> oh, have you tried clang's thinlto?
17:57:19FromDiscord<Phil> Nope
17:57:24FromDiscord<Yardanico> i mean it should be faster to compile and performance-wise shouldn't be too much worse
17:57:46FromDiscord<Yardanico> change `-flto` to `-flto=thin` and see if it's faster, assuming you use clang that is
17:57:52FromDiscord<Yardanico> if you use zig cc you are using clang
17:58:25FromDiscord<Phil> Nah, musl-gcc
17:58:29FromDiscord<Yardanico> :(
17:58:46FromDiscord<Yardanico> too bad :nimAngry:
18:01:16FromDiscord<Phil> Hmmmm I'm running into an.. "interesting" issue
18:01:32FromDiscord<Phil> So my webserver has 1 CPU thread available, since it is a potato as I am cheap as fuck
18:02:40FromDiscord<Phil> Now when my prologue application receives a request to reset the password of an account, it next needs to authenticate against the email-provider that I use for those purposes.↵That authentication fails, but that's fine currently, it's allowed to, I haven't updated the password yet.↵What is troubling is that during that time the entire webserver becomes unresponsive to further requests
18:02:45FromDiscord<Phil> And I don't fully understand why
18:02:56FromDiscord<Yardanico> how are you doing that authentication?
18:03:12FromDiscord<Yardanico> if it blocks it's evident (I think) that you're doing some blocking non-async operation
18:03:30FromDiscord<Phil> The authentication is most definitely blocking
18:03:33FromDiscord<Yardanico> like if you're doing newHttpClient and not newAsyncHttpClient
18:03:49FromDiscord<Phil> But what is weird is that the handler itself is an async proc, so it shouldn't call the entire server
18:04:10FromDiscord<Yardanico> well, it doesn't really matter if the handler is async, if the handler has blocking code it'll block the entire server since the whole async thing runs in a single thread
18:04:47FromDiscord<Yardanico> you really only have three solutions: 1) rewrite the code so it's truly async 2) use threading to execute blocking code in a different thread 3) live with the server blocking during auth :P
18:04:49FromDiscord<Phil> Well crap
18:05:44FromDiscord<Yardanico> how is the authentication done?
18:05:51FromDiscord<Yardanico> if it's some http requests you can just rewrite it to use the async version of the httpclient
18:06:07FromDiscord<Yardanico> smtp module in NIm also has an async version
18:06:15FromDiscord<Yardanico> (edit) "NIm" => "Nim" | "Nimalso has an async version ... " added "if you're using smtp"
18:06:17FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4rIU
18:06:21FromDiscord<Yardanico> yeah just use async smpt version :)
18:06:26FromDiscord<Yardanico> https://nim-lang.org/docs/smtp.html#AsyncSmtp
18:07:03FromDiscord<Phil> smtp was also moved out of the std lib right?
18:07:09FromDiscord<Yardanico> yeah I think
18:07:11FromDiscord<Yardanico> in devel
18:07:15FromDiscord<Phil> Trying to wrap my head around why I have an explicit require of smtp
18:07:20FromDiscord<Phil> Checks out
18:07:27FromDiscord<Yardanico> just change it to call newAsyncSmtp, and add `await` to `connect`, `startTls`, `auth`, `sendMail`
18:07:31FromDiscord<Yardanico> and it should theoretically just work
18:07:35FromDiscord<Yardanico> ah, and make the proc itself {.async.}
18:15:48FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4rIX
18:16:25FromDiscord<Phil> The proc declaration line is line 115 btw
18:16:33FromDiscord<Yardanico> the problem is "just" that you can't capture vars in async coroutines
18:16:40FromDiscord<Yardanico> you have to wrap the thing you want to mutate in a `ref`
18:16:44FromDiscord<Yardanico> and pass that to your async coroutine
18:17:08FromDiscord<Phil> But there must be a good reason for why I can't do that, what is the compiler exactly trying to protect me from here?
18:17:16FromDiscord<Yardanico> I think it's really just a limitation of the async code
18:18:19FromDiscord<Yardanico> err, not async, but general closure code
18:18:19FromDiscord<Yardanico> see e.g. <https://github.com/nim-lang/Nim/issues/17187>
18:18:46FromDiscord<Gumbercules> sent a code paste, see https://play.nim-lang.org/#ix=4rJ0
18:20:28FromDiscord<Phil> Okay how do I get the ref of that?↵I typically just do `new someConstruct` and bam, ref gained.↵I can't do `new(User)` because that'll just generate me a normal user
18:20:33FromDiscord<Phil> since User is already a ref type
18:20:41FromDiscord<Phil> Do I have to define a new type?
18:20:55FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4rJ1
18:21:31FromDiscord<Yardanico> In reply to @Gumbercules "I'm wrapping a C": I think a forum post would be better for a question like this
18:21:37FromDiscord<Gumbercules> Blah
18:21:59FromDiscord<Gumbercules> I'll create one later today - need to head to the store
18:22:07FromDiscord<Gumbercules> Figured someone might know off the top of their head, but yeah, probably wishful thinking
18:22:40FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4rJ2
18:22:45FromDiscord<Gumbercules> if I knew what exactly the `extern` keyword did in Zig I could probably figure it out on my own
18:22:53FromDiscord<Gumbercules> but besides the lame description in Zig's docs, I have no clue
18:22:59FromDiscord<Yardanico> In reply to @Isofruit "That won't run, here": you misunderstood me a bit, my example is for when your User type is not a ref
18:23:08FromDiscord<Gumbercules> I also don't understand why copying the C API type exactly doesn't produce the expected results
18:24:41FromDiscord<Phil> I think now I'm confused.↵I'm supposed to generate var ref User right, in my case User is already a ref-type (since it's a norm-model, which are ref-types)? ↵How do I get there?
18:25:34FromDiscord<Yardanico> In reply to @Isofruit "I think now I'm": no, you just get a ref User
18:25:44FromDiscord<Yardanico> the content in the refs is mutable
18:25:51FromDiscord<Yardanico> you can't modify the reference itself
18:25:58FromDiscord<Yardanico> unless you do `var ref X`
18:26:18FromDiscord<Yardanico> and in your case you only seem to need to modify the contents of it, right?
18:26:21FromDiscord<Yardanico> lemme show
18:26:44FromDiscord<Phil> Yeah, it's basically assign user the new password hash and store in db, but the async-proc (the email sender) doesn't even need that
18:27:23FromDiscord<Phil> The email sender just needs the current user, that's all.↵That user will subsequently in later procs be updated with the new password (I don't allow updating the user if I can't send you the password reset mail)
18:27:25FromDiscord<PunchCake> So guys how hard would it be to make a native gui lib in nim?
18:27:37FromDiscord<Phil> Beyond my expertise level
18:27:40FromDiscord<PunchCake> Nim lacks a native gui lib that looks good so badly
18:27:50FromDiscord<PunchCake> The only option would be qt
18:27:53FromDiscord<PunchCake> Bindings
18:28:31FromDiscord<Yardanico> In reply to @Isofruit "The email sender just": yes, so you can either just make your `User` type a `ref object`, or create `UserRef = ref User` and pass that to async procs that need to mutate the User
18:28:48FromDiscord<Yardanico> the former is simpler, it will have some overhead of dynamic allocation of course, but I doubt it's noticeable for a web app
18:29:18FromDiscord<Phil> I mean, the definition of of user is already `type User {.defaults, tableName: USER_TABLE.} = ref object of Model`
18:29:32FromDiscord<Yardanico> huh, then you don't even need to specify `var`
18:29:33FromDiscord<Phil> So it should already be a ref object
18:29:38FromDiscord<Yardanico> because you can mutate the contents of the object itself
18:29:39FromDiscord<Gumbercules> In reply to @PunchCake "So guys how hard": as hard as it would be in any other language
18:29:44FromDiscord<Yardanico> (edit) "because you can mutate the contents of the object itself ... " added "already"
18:29:58FromDiscord<PunchCake> Where can i start
18:30:04FromDiscord<Gumbercules> if you want to assess the difficulty, look at the various native windowing APIs (win32, cocoa, X)
18:30:12FromDiscord<PunchCake> I wanna contribute to this lovely language
18:30:13FromDiscord<Gumbercules> well - using something like
18:30:19FromDiscord<Yardanico> for some inspiration see <https://github.com/simonkrauter/NiGui>, it's abandoned though
18:30:26FromDiscord<Yardanico> oh, it's not abandoned, my bad
18:30:30FromDiscord<Gumbercules> https://github.com/simonkrauter/NiGui would be a good starting point
18:30:32FromDiscord<Yardanico> haha
18:30:34FromDiscord<Gumbercules> xD
18:30:47FromDiscord<Gumbercules> this library is on the right track more than any other
18:31:03FromDiscord<Yardanico> also there's <https://github.com/neroist/uing> for a wrapper of libui-ng which is a C library that wants to do the same as NiGui but for C
18:31:05FromDiscord<Gumbercules> still a LOT of work that needs doing though
18:31:08FromDiscord<PunchCake> Idk why windows doesnt use winui 3 as the native gui lib
18:31:13FromDiscord<PunchCake> Not this ugly bs
18:31:38FromDiscord<Phil> In reply to @Yardanico "because you can mutate": Yes but also I like the explicitness of var
18:32:01FromDiscord<Phil> buuut thanks to the hint I figured out how to go about it
18:32:07FromDiscord<Yardanico> just remember that `var` for refs actually incurs additional runtime overhead since it makes the reference itself mutable, so the reference is passed as a double pointer
18:32:13FromDiscord<Yardanico> of course again it's not noticeable for a web app
18:32:13FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4rJ4
18:32:51FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4rJ5
18:33:17FromDiscord<Phil> Unless it starts costing me actual milliseconds I'll always prefer explicitness over non-explicitness
18:33:39FromDiscord<Yardanico> it's just that some people might get the wrong idea and think you need to modify the reference itself since that's what it means exactly
18:34:34FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4rJ7
18:34:49FromDiscord<Phil> .... shit, I want immutable ref types
18:34:53FromDiscord<Yardanico> they exist
18:34:56FromDiscord<Yardanico> but they won't work for async procs
18:34:58FromDiscord<PunchCake> How hard would it be to bring this to nim ↵https://github.com/iced-rs/iced
18:35:04FromDiscord<PunchCake> Probably not too hard yes?
18:35:08FromDiscord<Yardanico> In reply to @Isofruit ".... shit, I want": funcs with strictFuncs does exactly that
18:35:27FromDiscord<Yardanico> <https://nim-lang.org/docs/manual_experimental.html#strict-funcs>
18:35:42FromDiscord<Phil> Yeah but then it'll screw me over when I want to start logging
18:35:47FromDiscord<Phil> As that's a side-effect
18:36:01FromDiscord<Yardanico> obviously, but you can of course cheat and mark your logging as not having a side effect
18:36:14FromDiscord<Yardanico> like <https://nim-lang.org/docs/system.html#debugEcho%2Cvarargs%5Btyped%2C%5D>
18:36:23FromDiscord<Yardanico> it's literally `echo` but marked as noSideEffect so it can used for debugging in funcs
18:37:25FromDiscord<Phil> ... maybe I should provide a "functional-logging" package that's a light wrapper over std/logging and slaps a noSideEffect pragma over all procs
18:38:12FromDiscord<Phil> God I hate how mutable ref-types are
18:38:25FromDiscord<Yardanico> but you do bring a useful point about adding a separate feature for strict immutability even for refs
18:38:39FromDiscord<Yardanico> although idk how much code that will add to the compiler
18:38:53FromDiscord<Yardanico> so that you can have strict immutability for refs without caring about side effects in general
18:40:40FromDiscord<hotdog> In reply to @Isofruit "God I hate how": I agree, it complicates the mental-model when reading Nim
18:41:01FromDiscord<hotdog> (I’m jumping into the conversation, I have no idea what the context is)
18:41:03FromDiscord<Phil> Up until 5 seconds ago I was fine because I just treated the pointers as if they were value-types
18:41:17FromDiscord<Phil> And then Yard let my world go up in flames
18:41:27FromDiscord<Yardanico> :nimRawr:
18:42:21FromDiscord<Phil> In reply to @hotdog "(I’m jumping into the": I basically just realized that in my web project whenever I used `var <SomeNormModel>` that was entirely pointless
18:42:51FromDiscord<Phil> And all the times I was like "This is nice to do, I can guarantee they won't screw around with my values in there" were me building on false hopes
18:43:08FromDiscord<Phil> "They" being me 5 days later
19:03:54FromDiscord<Phil> Well, at least that improves my understanding of ref types
19:08:57FromDiscord<TechnoRazor> sent a code paste, see https://play.nim-lang.org/#ix=4rJk
19:09:17FromDiscord<TechnoRazor> (edit) "https://play.nim-lang.org/#ix=4rJk" => "https://play.nim-lang.org/#ix=4rJl"
19:10:42FromDiscord<Phil> Unlikely to be as... I am actually not aware of anybody other than me that is actively playing around with them occasionally and I don't deal with generic types
19:11:45FromDiscord<Phil> So would be really cool if you filed an issue 😄 !↵@ringabout since that may be of interest for you as well
19:13:43FromDiscord<Yardanico> In reply to @Isofruit "So would be really": i mean he added them himself, so it is indeed interesting for him :)
19:15:27FromDiscord<Phil> On an unrelated note, I really should be looking at some service I can use to send mail emails through, using google mail has screwed me over multiple times now
19:38:43FromDiscord<ieltan> In reply to @Isofruit "I basically just realized": What's up with Norm models?
19:39:01FromDiscord<ieltan> Oh it is that they're `red object`?
19:39:05FromDiscord<Phil> In reply to @ieltan "What's up with Norm": Norm models are ref-types, and ref-types are never immutable
19:39:18FromDiscord<ieltan> (edit) "Oh ... it" added "is" | removed "is" | "`red" => "`ref"
19:39:22FromDiscord<Ayy Lmao> Would getting `Error: unhandled exception: ccgtypes.nim(197, 17) `false` mapType: tyUntyped [AssertionDefect]` be a compiler bug?
19:39:26FromDiscord<ieltan> Yeah I get it
19:39:31FromDiscord<Elegantbeef> Well ref type are immutable 😄
19:39:32FromDiscord<Yardanico> In reply to @Ayy Lmao "Would getting `Error: unhandled": any compiler crash is a compiler bug
19:39:36FromDiscord<Elegantbeef> Just the pointer is immutable not the data
19:39:45FromDiscord<Yardanico> In reply to @Elegantbeef "Just the pointer is": yeah Phil means the actual data
19:40:09FromDiscord<Elegantbeef> Looks like you've got a `tyUntyped` past semantic analysis
19:40:17FromDiscord<Elegantbeef> So that means somehow you have a `untyped` somewhere in the ast
19:40:59FromDiscord<Ayy Lmao> I was using `expandMacros` and taking that away seems to fix it thankfully.
19:42:18FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4rJx
19:42:27*rockcavera quit (Read error: Connection reset by peer)
19:42:45*rockcavera joined #nim
19:42:45*rockcavera quit (Changing host)
19:42:45*rockcavera joined #nim
19:42:55FromDiscord<Ayy Lmao> I am doing very cursed things so I guess it is understandable.
19:43:16*kenran joined #nim
19:44:52FromDiscord<PunchCake> is this the guy who made nim
19:44:53FromDiscord<PunchCake> https://github.com/Araq
19:46:36FromDiscord<Yardanico> yes
19:52:25FromDiscord<PunchCake> @treeform bro what happened to fidget?
19:52:33FromDiscord<Phil> In reply to @Elegantbeef "Just the pointer is": Given that I don't aspire to code in realms where I care to do pointer math or the like, that makes ref-types super painful
19:57:27*fallback quit (Quit: IRCNow and Forever!)
20:02:15FromDiscord<BobBBob> sent a code paste, see https://play.nim-lang.org/#ix=4rJC
20:02:19FromDiscord<BobBBob> just wondering if this is a thing, it's not important if it's not
20:02:49FromDiscord<Phil> In reply to @BobBBob "if I create an": You can define your own `[]` and `[]=` proc, aka operator overloading
20:02:57FromDiscord<Phil> well in this case it's more about defining your own operator
20:03:32FromDiscord<BobBBob> I guess that's worth it in my case
20:04:40FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4rJD
20:04:54FromDiscord<Phil> (edit) "https://play.nim-lang.org/#ix=4rJD" => "https://play.nim-lang.org/#ix=4rJE"
20:04:59FromDiscord<Yardanico> you can define the dot operator too
20:05:19FromDiscord<Yardanico> https://nim-lang.org/docs/manual_experimental.html#special-operators-dot-operators
20:05:22FromDiscord<Phil> Yeah but `x.5` seems just a smidge odd
20:05:27FromDiscord<Yardanico> true
20:05:42FromDiscord<Yardanico> ah right didn't fully read the question, yeah, `.` isn't needed here
20:05:50NimEventerNew thread by noah: Bun.sh supports nimlang, see https://forum.nim-lang.org/t/10034
20:09:17FromDiscord<BobBBob> what about something like getting x.len?
20:09:38FromDiscord<BobBBob> instead of x.s.len
20:12:59FromDiscord<BobBBob> actually I got it, thanks
20:14:47FromDiscord<Phil> The answer would've been "it works the same" 😄
20:15:00FromDiscord<Phil> since len can also just be written as a proc
20:24:01FromDiscord<Marcus> Is nim2c the best approach for wrapping a c++ lib with nim?
20:28:51FromDiscord<0ffh> @Phil About that immutable ref type you wanted. As an approximation, what about encapsulating a ref type in a distinct type that overloads ``.`` so you can read-access the object members but not write them? I know it's not the same, but it would at least approximate some of the behaviour of an immutable ref,
20:29:52FromDiscord<0ffh> (edit) "@Phil ... Aboutref." added "" | "ref," => "ref."
20:30:09FromDiscord<0ffh> (edit) "what" => "how"
20:36:12FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4rJL
20:36:44FromDiscord<Elegantbeef> I guess i should've implemented the `.` op 😄
20:42:18FromDiscord<jmgomez> sent a code paste, see https://play.nim-lang.org/#ix=4rJN
20:43:10FromDiscord<jmgomez> Just deleted my message because the scroll on discord is kinda messed up and the original of the reply appeared as the last one lol
20:44:05FromDiscord<Elegantbeef> Welcome to discord!
20:44:39FromDiscord<jmgomez> 😛
20:46:29FromDiscord<jmgomez> BTW Beef did a small video on the integration of NimVM in NUE, from the minute 9 to 10 do a small showcase in case you want to check it out
20:47:06FromDiscord<jmgomez> It mixes what we discussed the other day about replacing functions ad hoc in the vm
20:53:07FromDiscord<Elegantbeef> I see, looks good. Too bad verse exists 😛
20:56:04FromDiscord<jmgomez> yeah, that was bad timing but it wont reach UE anytime soon, the perf so far is bad and no low level interop so you need to use C++ too
20:56:52FromDiscord<jmgomez> the transactional model that they presented sounds great for their use case though
20:57:28FromDiscord<Elegantbeef> Yea i seen some funny things about it
20:57:44FromDiscord<Elegantbeef> It doesnt implement floats according to the standard so NaN == NaN
20:58:00FromDiscord<Elegantbeef> Makes sense for their design, but just a funny feature
21:02:08FromDiscord<jmgomez> didnt know that one. I planed to do a perf comparison but probably I wont even bother... it compiles to the BP VM
21:06:26FromDiscord<Elegantbeef> I do still want to see you implement that generic plugin system!
21:09:59FromDiscord<jmgomez> I probably will! Want to complete the vm integration (so you can modify the editor too fro the VM) and maybe later I hack around and editor so people dont run away when they see no editor support..
21:10:07FromDiscord<jmgomez> (edit) "and" => "an"
21:10:28FromDiscord<jmgomez> (edit) "I probably will! Want to complete the vm integration (so you can modify the ... editorvs" added "UE" | "UEeditor too fro the VM) and maybe later I hack around an editor so people dont run away when they see no ... editor" added "vs code"
21:30:03*beholders_eye quit (Ping timeout: 260 seconds)
21:38:13*cfa joined #nim
21:42:39FromDiscord<Nilts> In reply to @spoon "compiled the function succesfully": so what is the issue?
21:43:49FromDiscord<spoon> In reply to @not logged in "so what is the": it worked after i removed any libraries like asyncdispatch that referenced the nativesockets library which i believe is incompatible with js
21:44:27FromDiscord<Nilts> In reply to @spoon "it worked after i": why would you use async dispatch instead of asyncjs
21:44:53FromDiscord<spoon> i just removed the async library altogether
21:45:14FromDiscord<spoon> i mean it compiled i didnt unit test it
21:56:39FromDiscord<Nilts> sent a code paste, see https://play.nim-lang.org/#ix=4rKa
21:57:39*cfa left #nim (#nim)
22:02:04FromDiscord<Ayy Lmao> Is there a way to do expandMacros without the code needing to be valid?
22:03:44FromDiscord<Elegantbeef> `dumpTree`
22:03:50FromDiscord<Elegantbeef> `expandMacros` takes a `typed` parameter
22:03:54FromDiscord<Elegantbeef> `dumptree` takes an untyped parameter
22:04:12FromDiscord<Nilts> In reply to @Ayy Lmao "Is there a way": if the macro is yours, do result.repr
22:05:32FromDiscord<Ayy Lmao> In reply to @Elegantbeef "`dumptree` takes an untyped": Is there a way to fold it back into more readable nim code?
22:06:02FromDiscord<Elegantbeef> You can make your own macro that prints the repr
22:06:05FromDiscord<Elegantbeef> But what's the point of that
22:06:13FromDiscord<Elegantbeef> A macro that doesnt expand macros doesnt make sense
22:07:12FromDiscord<Ayy Lmao> I guess what I want is a way to see if a macro looks like it is outputting the correct result without needing the code to compile.
22:07:29FromDiscord<Ayy Lmao> But I'm not sure if that's possible.
22:08:24FromDiscord<Ayy Lmao> Basically expandMacros but untyped.
22:09:40FromDiscord<Ayy Lmao> dumpTree isn't dumping the result of the macro being unfolded
22:10:06*kenran quit (Remote host closed the connection)
22:14:12FromDiscord<spoon> In reply to @not logged in "same error same part,": it compiles
22:14:38FromDiscord<Elegantbeef> Well to have a macro expand it has to be compiled, unless you do `echo result.repr`
22:14:50FromDiscord<Nilts> In reply to @spoon "it compiles": you have to run it XD, it is a runtime error
22:15:54FromDiscord<spoon> actually no i forgot to save it
22:16:01FromDiscord<spoon> 😭 i need to fix my nvim icons
22:18:52FromDiscord<spoon> `jstt2.js(1, 37) Error: identifier expected, but got '9.1'` https://media.discordapp.net/attachments/371759389889003532/1088950085230022727/image.png
22:18:59FromDiscord<spoon> oh good, an error on the comment
22:19:19FromDiscord<Nilts> In reply to @spoon "oh good, an error": i think your ide is borken
22:19:34FromDiscord<spoon> no that was the output from `nim js`
22:19:49FromDiscord<spoon> but yes my icons are broken :^)
22:26:17FromDiscord<Ayy Lmao> In reply to @Elegantbeef "Well to have a": I guess result.repr is kind of what I'm looking for now that I think about it.
22:27:07FromDiscord<debris> sent a code paste, see https://play.nim-lang.org/#ix=4rKf
22:28:12FromDiscord<Elegantbeef> Why did you use a macro
22:28:12FromDiscord<Elegantbeef> Just make a proc
22:29:01FromDiscord<debris> Can a proc access the discovered field like that? I don't want to write it on a case-by-case basis for each single type ever.
22:29:09FromDiscord<Elegantbeef> For your `$` you need to traverse the ast
22:29:27FromDiscord<Elegantbeef> ok then use a template
22:29:41FromDiscord<Elegantbeef> Sorry not traverse the AST but the type
22:30:38FromDiscord<Elegantbeef> Also cause i'm a shill https://github.com/beef331/fungus might interest you
22:32:49FromDiscord<debris> I'm not very knowledgeable on any of this, sorry, but I'll bookmark it for once I have enough experience with strongly typed languages and their macros.↵How would I compose such a macro?
22:32:50FromDiscord<debris> I'm not very knowledgeable on any of this, sorry, but I'll bookmark it for once I have enough experience with strongly typed languages and their macros.↵How would I compose such a template?
22:33:49FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4rKh
22:33:55FromDiscord<Elegantbeef> But that's not for your `$`
22:34:18FromDiscord<Elegantbeef> You have to have case statement to traverse the type and print the string
22:34:41FromDiscord<Elegantbeef> Well get the string
22:35:00FromDiscord<debris> This I already have, yeah.
22:35:07FromDiscord<Elegantbeef> Well you had a macro 😄
22:35:12FromDiscord<debris> Ah, crap... so no way to work it backwards?
22:35:47FromDiscord<Elegantbeef> I mean the default `$` does not expect each discriminated union to be it's own type
22:35:56FromDiscord<Elegantbeef> You could make a macro that does it
22:36:08FromDiscord<Elegantbeef> Which is probably ideal
22:36:16FromDiscord<Elegantbeef> But that requires learning macros
22:36:39FromDiscord<debris> Hm. How similar are they to lisp macros?
22:37:43FromDiscord<debris> To me they seem much more capable than C's and superficially similar to lisp's, but I'm not sure how far the similarities go
22:40:14FromDiscord<Elegantbeef> They're AST based macros that are written in Nim
22:40:17FromDiscord<Elegantbeef> They're nothing like C macros
22:40:25FromDiscord<Elegantbeef> Nim's templates are more akin to C macros but still not
22:40:34FromDiscord<Elegantbeef> Cause Nim templates are dispatched based off types
22:40:42FromDiscord<Elegantbeef> But they're just code subsitution
22:40:55FromDiscord<Elegantbeef> Nim macros are inspired by lisps
22:42:04FromDiscord<debris> I see, do you think such a `$` macro would be trivial to write? If so I think I can take a crack at it on my own
22:46:27FromDiscord<Elegantbeef> Luckily since it's not a general macro it's not too complicated
22:47:17FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4rKo
22:47:44FromDiscord<Elegantbeef> You would then use `getImpl` on the enum which would be `enm: typed` in your macro and iterate it's fields to emit a `if fp.kind == ...`
22:48:00FromDiscord<Elegantbeef> https://dev.to/beef331/demystification-of-macros-in-nim-13n8 might help a tinge
22:50:56FromDiscord<Nilts> In reply to @spoon "no that was the": ik?
22:51:47FromDiscord<spoon> In reply to @not logged in "ik?": just saying it wasnt my editor
22:52:26FromDiscord<Nilts> In reply to @spoon "just saying it wasnt": so did you get the error to?
22:52:55FromDiscord<spoon> yep
22:55:43FromDiscord<spoon> so is it clearing and resetting timer every call?
22:57:22*fallback joined #nim
22:58:54FromDiscord<Elegantbeef> debris\: https://play.nim-lang.org/#ix=4rKs here's some help
23:00:01FromDiscord<debris> Crap, yeah, no way I'd have figured this out on my own, thank you. I'll accommodate it in my source.
23:00:25FromDiscord<Elegantbeef> It's typed AST so it's a bit unusual to learn
23:01:04FromDiscord<Elegantbeef> But writing enough macros makes you capable of easily moving to the compiler
23:03:30FromDiscord<Nilts> In reply to @spoon "so is it clearing": that part already works. It is the date.time part that does not
23:05:18FromDiscord<spoon> weird because it worked for me in the small echo example
23:05:48FromDiscord<Nilts> what worked/what browser are you using?
23:11:05FromDiscord<spoon> firefox, the example you gave still didn't work
23:21:34FromDiscord<spoon> In reply to @not logged in "what worked/what browser are": instead of now, i tried Date.UTC and it appears to work
23:24:36FromDiscord<Nilts> In reply to @spoon "instead of now, i": let me try
23:29:54FromDiscord<Nilts> In reply to @not logged in "let me try": no errors, but the code does not work as intended
23:30:28*Notxor quit (Remote host closed the connection)
23:31:15FromDiscord<spoon> i believe both return the current time in ms
23:33:02FromDiscord<spoon> but my question is are the last two lines of the function execute every call? if so its constantly moving the goal post
23:33:24FromDiscord<spoon> In reply to @not logged in "no errors, but the": i gtg but try indenting them inside the if statement
23:41:41FromDiscord<Nilts> In reply to @spoon "i gtg but try": clearTimeout(timer)↵ timer = setTimeout(f, timeout)↵Are not meant to be in the if statment. It is a separate runner
23:42:38FromDiscord<Nilts> ah, Date.UTC() returns NaN
23:42:45FromDiscord<Nilts> What do i do XD
23:56:23*fallback quit (Quit: IRCNow and Forever!)