<< 08-12-2023 >>

00:16:27*advesperacit quit ()
00:18:24FromDiscord<bostonboston> Ah no it's `nimble -flag sometask`
01:15:54FromDiscord<farklenaut> sent a code paste, see https://paste.rs/3QWm6
01:36:52FromDiscord<farklenaut> sent a code paste, see https://paste.rs/QqujZ
01:39:12FromDiscord<demotomohiro> !eval echo @[(1, 2), (3, 4), (5, 6)]
01:39:14NimBot@[(1, 2), (3, 4), (5, 6)]
01:40:45FromDiscord<farklenaut> I don't know what tuples are going in the seq initially
01:46:18FromDiscord<Elegantbeef> `var test: seq[(int, int)]`
01:46:27FromDiscord<Elegantbeef> or `newSeq[(int,int)]()`
01:47:00FromDiscord<farklenaut> huh, could've sworn I tried that
02:00:55FromDiscord<4zv4l> https://media.discordapp.net/attachments/371759389889003532/1182502030540025966/image.png?ex=6584edd5&is=657278d5&hm=da1758058d303d6fe967855a1cd2c8d52e2e3ebe2efca61983f1774d2f7e7ed9&
02:00:57FromDiscord<4zv4l> is this normal ?
02:06:56FromDiscord<Elegantbeef> Puppy 1.5.4 is over a year old now so perhaps it's a fixed bug
02:08:40FromDiscord<4zv4l> I mean↵I am not the one choosing the version to use
02:10:27FromDiscord<Elegantbeef> Right I'm just saying that perhaps the version it relies upon has a bug that has been fixed upstream so it might be "normal" although not good
02:15:55FromDiscord<4zv4l> I will add an issue to the repo↵I can clone and try for linux but can't test on windows or macos so idk whats the best↵↵an issue or pull request with only linux tested
02:19:37FromDiscord<bostonboston> For tables I know there's a `keys` iterator, is there a function that returns a seq of all keys or do I just need to use the iterator
02:21:11FromDiscord<rubythulhu> embarrassing admission: I am so confused about when I should be using `typed` vs `untyped` vs concrete types in a template
02:22:05FromDiscord<Elegantbeef> `import std/sequtils; myTable.keys.toSeq` if you want a seq
02:22:27FromDiscord<Elegantbeef> Types -\> Typed -\> Untyped
02:24:17FromDiscord<rubythulhu> I get the overall logic of concrete type first, typed second, untyped last. i don't understand the tipping points between them other than "try with X, if can't, do next X". i want to understand the underlying circumstances better
02:25:21FromDiscord<Elegantbeef> If your template wants to have ast that compiles you use a type or typed argument, if the type does not matter it's typed
02:25:33FromDiscord<Elegantbeef> `typed` is the template type equal to `auto`
02:25:59FromDiscord<Elegantbeef> The places you use `untyped` is anywhere where the type does not matter and the code you paste is not valid AST
02:26:40FromDiscord<Elegantbeef> There is no other way to solve this than to use \`untyped
02:28:34FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/bhL9n
02:34:04FromDiscord<rubythulhu> one of the examples that i'm having a hard time understanding the why of: i can define a `proc ~@(a: AType, b: BType): int = ...`, but if i want to provide alternate args, `template ~@(c: CType, D: dType): int = a(c) ~@ b(d) = ...` it always seems to fail, and i think i need to use `template ~@(c,d:untyped):untyped = a(c) ~@ b(d)` instead, but i'm not sure why
02:34:31FromDiscord<rubythulhu> (with appropriate quoting of backtics, which i cant figure out how to make discord happy with)
02:34:53FromDiscord<Elegantbeef> You should not need a template there
02:36:11FromDiscord<Elegantbeef> Works jusut fine
02:38:17FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/SSafC
02:38:42FromDiscord<rubythulhu> yeah thats what my code looks like. but if this was an operation where the added function call overhead would be too much if i want to make that optimization explicit, and a compile-time/zero-cost thing would be better, is what i'm trying to understand (whether or not i have an immediate need to)
02:39:29FromDiscord<Elegantbeef> It's better to use `{.inline.}` over a template Though without an example of the case falling apart I can only say "yep"
02:40:42FromDiscord<rubythulhu> why is it better? as i understand it, `{.inline.}` is a compiler hint, but templates are enforced before the c compiler gets involved
02:42:14FromDiscord<Elegantbeef> That's correct, but generally `inline` is sufficient and `template`s have different semantics which you have to be concerned with when using them
02:42:15FromDiscord<Elegantbeef> Whilst they guarantee inline, they also behave differently
02:44:02FromDiscord<Elegantbeef> Control flow inside of templates effects instantiation site, if they return a value it has to be an expression(no result, no return), an address cannot be taken of them. Are some of the semantics I'm talking about
02:44:28FromDiscord<Elegantbeef> Obvious stuff, but those are detractors for not using them 😄
02:44:52FromDiscord<Elegantbeef> I'd say write with `{.inline.}` if in profiling it's not sufficient move to templates
02:45:23FromDiscord<Elegantbeef> But regardless I'm no longer talking about the issue you brought up
02:45:26FromDiscord<rubythulhu> yeah i'm not thinking in practical terms, i'm trying to understand harder nim concepts with problems that could be solved with easy solutions, to understand the harder solutions
02:46:24FromDiscord<Elegantbeef> If you make a minrepro of your initial problem I'll happily explain it
02:47:10FromDiscord<rubythulhu> and even the tipping point between `{.inline.}` and `simple fully-typed template` is something i'm trying to understand better
02:48:13FromDiscord<Elegantbeef> The tipping point for me is "Can a proc actually do what I want"
02:48:15FromDiscord<Elegantbeef> If a proc can do what I want, I use a proc
02:48:16FromDiscord<Elegantbeef> A template should only be used in a place it has to be used
02:49:31FromDiscord<rubythulhu> sure yes
02:51:23FromDiscord<rubythulhu> i'm trying to teach myself to learn templates and macros better for when i hit the point that it should be used, without necessarily having a reason why it should. i want to understand the should better. using them before there's a "should" seems like a good way to accomplish that 🙂
03:10:48FromDiscord<rubythulhu> when the rule is "use templates before macros" and "use procs before templates", it is difficult to find an excuse of a problem to learn macros and templates better
03:11:36FromDiscord<JJ> it's hard to see it before you come to it, for sure. templates are generally more helpful when you want nice syntax.
03:11:46FromDiscord<JJ> you could try browsing existing nim code: https://github.com/search?q=%22template+%22++lang%3ANim&type=code
03:12:39FromDiscord<Elegantbeef> https://github.com/beef331/nimtrest/blob/master/aoc2023/day3.nim#L5-L35 one simple example of a template
03:13:59FromDiscord<rubythulhu> In reply to @omentic "it's hard to see": i always want nice syntax haha
03:18:33FromDiscord<rubythulhu> i've written a few templates, especially when playing w/ raspberry pi pico stuff earlier this year (which i should get back to that project, but its how i found and fell in love with nim), but mostly its just convenience aliases to express 3 lines of code in a single call, etc, and when i do that it's fully explicit concrete types, and just treating it like hygienic macros
03:18:45FromDiscord<michaelb.eth> In reply to @rubythulhu "when the rule is": maybe take a look at the use of templates and macros in nim-results and questionable↵https://github.com/arnetheduck/nim-results/tree/master↵https://github.com/codex-storage/questionable↵results doesn't have any macros, only templates; questionable has both
03:18:57FromDiscord<michaelb.eth> (edit) "questionable↵https://github.com/arnetheduck/nim-results/tree/master↵https://github.com/codex-storage/questionable↵results" => "questionable↵https://github.com/arnetheduck/nim-results↵https://github.com/codex-storage/questionable↵results"
03:21:50FromDiscord<rubythulhu> i suppose my quandary is: I need an example of a problem to solve that DOES justify templates/macros, without just seeing a solution. I won't learn it unless i learn how to solve it. seeing a solution won't "stick" as well
03:24:25FromDiscord<michaelb.eth> makes sense, I was thinking that results and questionable form a sort of DSL (powered by templates and macros, and procs/funcs also), so you could learn that DSL itself if you don't know it already, and then study the implementation to understand how it works, and in the process learn about templates and macros
03:40:39*edr quit (Quit: Leaving)
03:52:26FromDiscord<rubythulhu> haha DSL’s are what i’ve played most with. if anything i need to dial back on that. but yes i am learning from this chat i should probably just trust `{.inline.}`. thx y’all
03:52:53FromDiscord<Elegantbeef> Well trust your profiler 😄
03:53:33FromDiscord<rubythulhu> haha fair
03:57:22FromDiscord<odexine> In reply to @.bobbbob "a const in a": I believe so
04:00:25*xutaxkamay quit (Quit: ZNC 1.8.2+deb3.1 - https://znc.in)
04:00:45*xutaxkamay joined #nim
04:40:34FromDiscord<4zv4l> In reply to @4zv4l "": looks like manual install works
04:40:39FromDiscord<4zv4l> so idk why the script doesnt work xD
05:06:13*TheLink quit (Quit: Ping timeout (120 seconds))
05:06:32*TheLink joined #nim
05:13:44*rockcavera quit (Read error: Connection reset by peer)
05:14:27*rockcavera joined #nim
05:14:27*rockcavera quit (Changing host)
05:14:28*rockcavera joined #nim
06:52:43*emery quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.)
06:53:08*ehmry joined #nim
07:01:30FromDiscord<Phil> In reply to @rubythulhu "i suppose my quandary": 1) Context managers (e.g. to allocate a resource at the start of a block that you then automatically free at the end of a block, like a DB connection or a file handle)↵2) Pieces of Code whose types you strictly speaking know but that don't exist yet (e.g. because the user will need to generate it via a macro from you), so you can write the code now with the appropriate type and let the use
07:02:55FromDiscord<Phil> At least those are my 2 main usecases
07:03:08*advesperacit joined #nim
07:03:33FromDiscord<Elegantbeef> 1. Destructors exist
07:04:00FromDiscord<Phil> (edit) "In reply to @rubythulhu "i suppose my quandary": 1) Context managers (e.g. to allocate" => "sent" | "resource at the start of a block that you then automatically free at the end of a block, like a DB connection or a file handle)↵2) Pieces of Code whose types you strictly speaking know but that don't exist yet (e.g. because the user will need to generate it via a macro from you), so you can write the code now with the appropriate
07:04:22FromDiscord<Phil> Not for borrowing a connection or thread from a pool and to return it, at least I wouldn't put that kind of code in a destructor
07:04:45FromDiscord<Elegantbeef> Why not that's what they're there for
07:06:29FromDiscord<Phil> I feel like they should be for memory-allocation related stuff, when I use destructors for accessing a pool, then I no longer have an automated way of dealing with the memory behind it would be my thoughts.↵For all of the 5s I've thought about that approach so far
07:07:55FromDiscord<Elegantbeef> How would you "no longer have an automated way of dealing with the memory"?
07:08:53FromDiscord<Phil> When a connection goes out of scope and instead of returning it to the pool I want to deallocate it, I now have to do it manually instead of just not returning it to the pool
07:09:01FromDiscord<Elegantbeef> No you do not?
07:09:02*rockcavera quit (Remote host closed the connection)
07:09:26FromDiscord<Phil> Why not, I used the destructor to define logic that moves the connection back to the pool
07:09:50FromDiscord<Elegantbeef> The pool deallocates when it destructs
07:10:31FromDiscord<Phil> Automatically or would I need to write that also in the destructor?
07:10:40FromDiscord<Elegantbeef> I'll write an example
07:20:28FromDiscord<Elegantbeef> https://hatebin.com/hnnzfoosmk playground seems down
07:20:31FromDiscord<Elegantbeef> Well ix.io
07:21:01FromDiscord<Elegantbeef> But anyway there's an example, sadly as it says it's not really a generic solution, but a nice template around the `PooledRef` logic would be grand! 😄
07:22:25FromDiscord<Elegantbeef> We could encode the `add` procedure into the `PooledRef` so then it'd work generically for all types....
07:29:14FromDiscord<Elegantbeef> Yea it cannot be generalised in a module sadly
07:35:46FromDiscord<odexine> In reply to @isofruit "Not for borrowing a": "at least I wouldn't put that kind of code in a destructor" RAII fans would like to have a word with you
07:41:39FromDiscord<Elegantbeef> Yea that's very much the founding merits of 'RAII' and as such ARC 😄
08:03:54FromDiscord<gogolxdong666> Is Nim being remaking?
08:54:36*mahlon quit (Ping timeout: 252 seconds)
09:02:01*fallback joined #nim
09:22:31NimEventerNew question by Nate Ackerman: In Nim, how can I define a procedure with an unspecified collection of generic parameters, see https://stackoverflow.com/questions/77625542/in-nim-how-can-i-define-a-procedure-with-an-unspecified-collection-of-generic-p
09:30:00*mahlon joined #nim
09:32:07*azimut quit (Ping timeout: 240 seconds)
09:50:50om3ga cannot open file: std/paths - nim cc koch.nim - Alpine i386
09:50:58om3gastrange
10:22:38om3gathe reason is nim of version 1.6.14
10:46:10FromDiscord<piqueiras> If I define my own `==` between types now "in" and "find" will use that right?
11:00:36FromDiscord<odexine> Yes
11:08:00*Onionhammer quit (Quit: Ping timeout (120 seconds))
11:08:20*Onionhammer joined #nim
11:08:51FromDiscord<piqueiras> and, im guessing this is where templates would get useful but, how to search by key in an array of a newly defined object
11:09:59*PMunch joined #nim
11:12:19FromDiscord<odexine> I don’t see how templates would be better here, but I don’t think there’s a procedure in the standard library for that, but I haven’t refreshed my memory of it in a while so
11:12:39*Mister_Magister quit (Quit: bye)
11:14:32*Mister_Magister joined #nim
11:14:36FromDiscord<piqueiras> idk
11:14:51FromDiscord<piqueiras> default binary search would search by whole object, right?
11:15:46FromDiscord<pmunch> In reply to @gogolxdong666 "Is Nim being remaking?": What do you mean?
11:16:41PMunchpiqueiras, binary search from `std/algorithms` uses the compare procedure you pass it, so you can compare however you want
11:16:50FromDiscord<piqueiras> yea but
11:17:01FromDiscord<piqueiras> imagine I have a Person object with name and age
11:17:11FromDiscord<piqueiras> and i define == for Person with cmp person.age
11:17:19FromDiscord<piqueiras> and I have a seq of Person
11:17:25FromDiscord<odexine> No as in it takes in a compare procedure
11:17:32FromDiscord<piqueiras> oh yeah sorry
11:17:34FromDiscord<piqueiras> cmp not ==
11:17:37PMunchhttps://nim-lang.org/docs/algorithm.html#binarySearch%2CopenArray%5BT%5D%2CK%2Cproc%28T%2CK%29
11:17:45PMunchJust to make sure we're looking at the same thing :)
11:17:52FromDiscord<odexine> As in it’s passed into the function
11:18:13FromDiscord<odexine> You can pass in a separate compare function to the global compare function you have
11:18:14FromDiscord<piqueiras> should I be able to use peopleSeq.binarySearch("John") or
11:18:43FromDiscord<odexine> You can but that will use whatever compare function you defined globally
11:19:02PMunchSure, if you pass a procedure with the signature `proc (x: Person, y: string): int` to the binarySearch it would be able to compare those fields and find your person
11:19:57FromDiscord<piqueiras> Ooooh I have to define another cmp
11:20:03FromDiscord<piqueiras> between string and Person
11:20:29FromDiscord<piqueiras> oookay yea https://media.discordapp.net/attachments/371759389889003532/1182642852812050432/image.png?ex=658570fc&is=6572fbfc&hm=af8ab64d78867ff79bfad4de8e7cb5d7c59386f9e46a9e77f93e9ddb2ba7042b&
11:20:49FromDiscord<odexine> Oh I misread a little okay
11:22:01FromDiscord<piqueiras> oookay it works tyy
11:23:28PMunchYou can then of course create an overload for `binarySearch` which takes `openArray[Person]` and `string` to make it easier to use
11:25:09PMunchhttps://paste.rs/NsN50
11:52:18NimEventerNew thread by mantielero: Fmu.nim - my first FMU working with OpenModelica, see https://forum.nim-lang.org/t/10745
12:00:39*redj_ joined #nim
12:22:45*Mister_Magister quit (Quit: bye)
12:24:41*Mister_Magister joined #nim
12:32:19*Mister_Magister quit (Quit: bye)
12:34:15*Mister_Magister joined #nim
13:54:10NimEventerNew thread by vonH: Is there a guide to creating PostgreSQL extensions or dynamic libraries "xxx.so" etc in Nim?, see https://forum.nim-lang.org/t/10746
14:06:01*jmdaemon quit (Ping timeout: 276 seconds)
14:10:08*rockcavera joined #nim
14:30:25*edr joined #nim
14:59:18*PMunch quit (Quit: Leaving)
15:03:37FromDiscord<alireza0x0> guys
15:04:00FromDiscord<alireza0x0> i am writing a multi threading test and the compiler is bothering me saying the function x is not gcsafe
15:04:13FromDiscord<alireza0x0> indeed i accept a global inside it but with locks ofcourse
15:04:32FromDiscord<alireza0x0> `{.gcsafe.}:` did not help also...
15:07:59FromDiscord<bostonboston> `{.cast(gcsafe).}:` I think is the proper syntax, but repeating what beef has said this is just telling the compiler you know better
15:08:16FromDiscord<alireza0x0> i did test this as well
15:08:19FromDiscord<alireza0x0> nothing changed...
15:11:01FromDiscord<alireza0x0> its similar
15:11:08FromDiscord<alireza0x0> your example probably works because thats a int not a ref
15:11:22FromDiscord<alireza0x0> but my case is a ref, a new asyncevent loop...
15:11:36FromDiscord<alireza0x0> let me try simplfy my example to share if possible...
15:11:49FromDiscord<bostonboston> Then it's out of my scope of knowledge
15:12:51*azimut joined #nim
15:12:53FromDiscord<bostonboston> sent a code paste, see https://paste.rs/sm4Ge
15:13:08FromDiscord<alireza0x0> damn the code is a bit big and makse the chat dirty...
15:13:17FromDiscord<alireza0x0> hmm...
15:13:49FromDiscord<alireza0x0> photo probably...
15:14:12FromDiscord<michaelb.eth> you can't share ref across threads, lock doesn't help
15:14:15FromDiscord<alireza0x0> https://media.discordapp.net/attachments/371759389889003532/1182701681432080506/image.png?ex=6585a7c6&is=657332c6&hm=cf49ba000f062aee1cd9199fd4d25089148e6c0407204b00ba2dd54abb78edcf&
15:14:18FromDiscord<michaelb.eth> you'll just end up with SIGSEGV
15:14:30FromDiscord<alireza0x0> really? under orc?
15:14:33FromDiscord<michaelb.eth> yes
15:14:46FromDiscord<alireza0x0> why it would segfault its a shared heap and is global var
15:14:57FromDiscord<michaelb.eth> the reference counting isn't atomic
15:15:11FromDiscord<alireza0x0> i wrote a basic test before it i shared a ref int and increment it using therads 1000 times it did not crash
15:15:22FromDiscord<michaelb.eth> so different threads can collide when inc/dec'ing the count
15:15:37FromDiscord<alireza0x0> forexample
15:15:42FromDiscord<alireza0x0> the code was this https://media.discordapp.net/attachments/371759389889003532/1182702047829700638/image.png?ex=6585a81d&is=6573331d&hm=ca26426e281f9359a83e6a0b8482778b0c7523ab443b157732b3ba19e0354e9e&
15:15:51FromDiscord<alireza0x0> this did not carsh at all...
15:16:29FromDiscord<michaelb.eth> anyway, I'm glad it didn't crash, but you can't share ref across threads
15:16:40FromDiscord<michaelb.eth> you're just lying to the compiler with cast gcsafe
15:16:42FromDiscord<michaelb.eth> it's not safe
15:16:58FromDiscord<alireza0x0> also the refrence counting should only change inside the lock block i think
15:17:09FromDiscord<alireza0x0> because i used a pragma telling the compiler to respect my guard lock
15:17:26FromDiscord<alireza0x0> `{.guard:lockname.}`
15:17:46FromDiscord<alireza0x0> not in the example i sent here but in other file
15:18:17FromDiscord<michaelb.eth> there is an experimental feature in the compiler, atomicRef, or maybe it's atomicArc or atomicOrc, will have to check that
15:18:31FromDiscord<michaelb.eth> but it's only in the `devel` branch and... it's experimental 😄
15:18:44FromDiscord<alireza0x0> hmm...
15:19:00FromDiscord<alireza0x0> in rfcs i have read that araq dose not like the idea of atomic arc
15:19:07FromDiscord<alireza0x0> they invented something like isolated type
15:19:10FromDiscord<alireza0x0> to move things around
15:19:21FromDiscord<alireza0x0> im a beginner dont really know what is this or that
15:19:26FromDiscord<alireza0x0> but i just remembered...
15:21:22FromDiscord<michaelb.eth> rule of thumb: for multi-threading in Nim, consider message passing between threads, the design of the lang does not offer strong support for sharing across threads; it definitely is possible under some conditions, but not with `ref` types
15:22:04FromDiscord<alireza0x0> hmm🤔
15:28:02FromDiscord<michaelb.eth> if you have a global `var`, maybe it's an array/seq of object (but not ref object), you can communicate to another thread/s with ptr/addr, using locks if necessary for reads/writes that might collide↵↵that can be a decent strategy for parallelizing workloads, see e.g. araq's malebolgia
15:32:12FromDiscord<queebee> The compiler doesn't tells me at which position I'm using a wrong argument for functions. Is there some nim 2.0 version which does that? `Expected one of (first mismatch at [position]):`
15:35:08FromDiscord<michaelb.eth> In reply to @queebee "The compiler doesn't tells": is there more to the error message? if it's long, maybe copy it to a pastebin and give a link rather than pasting here
15:39:43FromDiscord<demotomohiro> sent a code paste, see https://paste.rs/Z2jt6
15:44:43*xutaxkamay_ joined #nim
15:46:16*xutaxkamay quit (Ping timeout: 255 seconds)
15:49:15FromDiscord<queebee> https://media.discordapp.net/attachments/371759389889003532/1182710488686153879/Bildschirmfoto_vom_2023-12-08_16-48-22.png?ex=6585affa&is=65733afa&hm=1aed366ba07dc89081368b43ca281325648fff2669e1fc2fe0b15bd691edaa07&
15:49:35*xutaxkamay_ quit (Read error: Connection reset by peer)
15:49:41*xutaxkamay joined #nim
15:54:32FromDiscord<queebee> oh nvm got it
16:31:40*Guest20 joined #nim
16:43:08*Guest20 quit (Quit: Client closed)
16:58:31*azimut quit (Ping timeout: 240 seconds)
18:01:41termerLOL https://forum.nim-lang.org/t/10739
18:01:56termerI don't know what compels people to make threads like that
18:10:23FromDiscord<systemonia> yikes
18:17:59FromDiscord<bostonboston> For fun
18:20:27FromDiscord<Clonkk> Drugs most likely↵(<@709044657232936960_termer=5b=49=52=43=5d>)
18:51:58*PMunch joined #nim
18:59:40PMunchAoC day 8 live now! https://twitch.tv/pmunche https://www.youtube.com/watch?v=3jY5JhTabqs
19:00:01*krux02 joined #nim
19:16:00NimEventerNew thread by geotre: Nimforum custom theme, see https://forum.nim-lang.org/t/10748
21:00:49NimEventerNew thread by giuliano: Can't trace the origin of "unlisted exception: Exception" when building a callback table, see https://forum.nim-lang.org/t/10749
21:24:44*PMunch quit (Quit: leaving)
22:06:00*advesperacit quit ()
22:30:08*arkurious joined #nim
22:45:25*Jjp137_ quit (Quit: Leaving)
23:34:43*azimut joined #nim
23:41:08*mal`` quit (Quit: Leaving)
23:46:50*mal`` joined #nim
23:49:31*jmdaemon joined #nim