<< 29-07-2023 >>

00:40:35*xet7 joined #nim
00:50:12FromDiscord<eliot_c> how do i convert an MDigest[256] to a string? i'm trying to use writeFile to write the output of keccak_256.digest
00:54:09FromDiscord<Elegantbeef> What library?
00:54:38FromDiscord<eliot_c> nimcrypto sorry
00:55:08FromDiscord<Elegantbeef> Is there not a `$` defined?
00:59:43FromDiscord<eliot_c> oh thank you, i forgot you could do that
01:00:55*ajunior quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
01:11:13NimEventerNew post on r/nim by Robert_Bobbinson: Is there no easy way to delete an element by value in a Seq?, see https://reddit.com/r/nim/comments/15cewkt/is_there_no_easy_way_to_delete_an_element_by/
01:12:18*lucasta joined #nim
01:17:46FromDiscord<Elegantbeef> This nimscripter C api is actually pretty sane https://github.com/beef331/nimscripter/blob/dll/tests/lib/helloworld.c
01:18:04FromDiscord<Elegantbeef> Just added the whole getting values from nodes
01:26:19*xet7 quit (Remote host closed the connection)
02:31:17*lucasta quit (Quit: Leaving)
02:34:45*rockcavera quit (Remote host closed the connection)
02:54:00*ajunior joined #nim
02:54:53*ajunior quit (Client Quit)
03:43:38*azimut quit (Ping timeout: 240 seconds)
05:03:52*xet7 joined #nim
05:29:14FromDiscord<Phil> Waaaiiiiiit, couldn't I just... turn my constant into a pointer?
05:29:32FromDiscord<Phil> (edit) "pointer?" => "pointer and store that?"
05:29:45FromDiscord<Phil> It should be static so it should have a lifetime as long as the runtime of the entire code
05:30:20FromDiscord<Phil> Now to figure out how to get a pointer to a static value
05:32:28FromDiscord<Phil> Shit, do static values of stack types not count as having pointers?
05:43:46FromDiscord<odexine> `const` are not stored into the binary as a "variable", it is inlined into the code
05:44:09FromDiscord<odexine> idk the context tho
05:46:16FromDiscord<Elegantbeef> If it's a constant you can just `var myval {.global.} = bleh` or use codegendecl to make it static
05:47:46FromDiscord<Phil> In reply to @odexine "idk the context tho": Effectively I want to remove type information from a value that I get passed by a user and infer that type information at a later point based on what it ought to be from the context of useage
05:49:30FromDiscord<Phil> Basically I want to go around the type system
05:50:05FromDiscord<odexine> good luck have fun'
05:50:07FromDiscord<odexine> (edit) "fun'" => "fun"
05:50:32FromDiscord<Elegantbeef> don't say that type erasure is never fun
05:52:13FromDiscord<Phil> In reply to @Elegantbeef "If it's a constant": I may not be following your thought process here.↵Why make the variable global?
05:52:25FromDiscord<Phil> Or rather how does that help?
05:52:29FromDiscord<Elegantbeef> It makes it statically allocated
05:52:37FromDiscord<Elegantbeef> Therefore accessing it isnt capturing it
05:53:21FromDiscord<Phil> Ah and thus if I go the "use a callback to generate the value" route I don't have a closure
05:53:28FromDiscord<Elegantbeef> Yes
05:53:38FromDiscord<Elegantbeef> Still don't get the point of the procedure
05:53:46FromDiscord<Elegantbeef> Isnt it just a `ptr T` then
05:54:15FromDiscord<Phil> Basically, I'm doing that because I'm struggling turning a constant value into something I can access via pointer
05:55:27FromDiscord<Phil> I want the user to pass me a static value, I store a pointer to that static value, then the user generates the mapping proc and for the field that he stated he wanted the constant value to go into I generate the expression `x.fieldName = constantValue`
05:56:23FromDiscord<Elegantbeef> So use global and take the address
05:56:49FromDiscord<Phil> Oh right, might as well do that without the callback if I can just have a pointer
05:57:31FromDiscord<Elegantbeef> Though I still do not understand what you're doing
06:04:07FromDiscord<Phil> Wait, how do you follow a pointer back to its original data?
06:04:20FromDiscord<Elegantbeef> `[]` dereferences
06:04:59FromDiscord<Phil> so cast to ptr int and unref?
06:05:21FromDiscord<Phil> Because on the pointer itself I get type mismatches, one sec
06:05:29FromDiscord<Elegantbeef> Or use `copyMem` whichever is easier
06:06:05FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4BKT
06:13:59*rockcavera joined #nim
06:22:42FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4BKY
06:22:51FromDiscord<Phil> I'm not even getting a line where it errors out, just literally what I wrote
06:22:56FromDiscord<Elegantbeef> `const mapping = bleh` is invalid firstly
06:23:11FromDiscord<Elegantbeef> `global` only exists at runtime
06:23:27FromDiscord<Phil> Ahhhh, ffffffffudge
06:23:56FromDiscord<Elegantbeef> secondly a global will only exist once per procedure instantiation
06:23:58FromDiscord<Elegantbeef> you want at emplate
06:24:04FromDiscord<Phil> Okay so that's not an option then
06:24:04FromDiscord<Phil> Hmm
06:24:33FromDiscord<Phil> Like I need the Mapping() type that gets produced to be compiletime
06:24:43FromDiscord<Phil> Since I want to use it to generate code
06:25:58FromDiscord<Elegantbeef> Like I said I still don't know what you're doing
06:27:34FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4BKZ
06:28:32FromDiscord<Phil> So generate a proc that by default takes fields from B, looks for a field of identical name and type on A and transfers the value over.↵That's the core feature↵Everything else is just for edgecases, e.g. maybe B has a field that in this context you always want to have the same value
06:29:45FromDiscord<Elegantbeef> So why do you need this mapping object?
06:31:09*ntat joined #nim
06:32:15FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4BL0
06:33:45FromDiscord<Phil> sent a long message, see http://ix.io/4BL1
06:34:00FromDiscord<Phil> I use Mapping objects to give me the information for the first 4
06:34:28FromDiscord<Elegantbeef> This seems like I can just make a proc to do it for the cases it needs this manual conversion
06:34:40FromDiscord<Elegantbeef> Plus you can do `proc convert(from: typedesc[object], to: var object)`
06:34:47FromDiscord<Elegantbeef> Then you can chain these together
06:36:27FromDiscord<Phil> In reply to @Elegantbeef "This seems like I": It's more a laziness/utility thing.↵If you have 6 fields to transfer and only one needs a transformation or sth. then you need to write a 7 line proc when a simple "mapAToB and apply this proc to field6 first" is all you'd want to express
06:36:45FromDiscord<Phil> And also the problem is interesting to challenge me a bit with the edges of the nim typesystem of course
06:38:10FromDiscord<Phil> That is, in fact, a usecase you may run into with webdev where you have 1 set of datatypes that represent the data you send out and a second set of very similar datatypes that you actually use in your application.
06:38:35FromDiscord<Phil> You have the former because you may not want to send out fields with sensitive data and thus remove them from the type first before turning that into JSON
06:38:53FromDiscord<Phil> (edit) "That is, in fact, a usecase you may run into with webdev where you have 1 set of datatypes that represent the data you ... sendto" added "can" | "cansend out ... and" added "to users in the shape of JSON"
06:39:07FromDiscord<Phil> (edit) "application." => "application for business logic etc."
06:40:45FromDiscord<Elegantbeef> Right, but this can be done with a generic proc that does it all instead of whatever you're doing
06:43:18FromDiscord<Phil> The generic proc still needs mechanisms to deal with scenarios where a field on type A may need to get mapped to a field on type B with a different name.↵Or any of the other usecases I just mentioned.↵↵The reason I have these mapping objects is precisely because I couldn't figure out how to write a generic `map` proc that I can "configure" in a way to do all the things I want.
06:43:37FromDiscord<Elegantbeef> Right i just showed you how to do that name mismatch
06:44:49FromDiscord<griffith1deadly> In reply to @Elegantbeef "This nimscripter C api": what about performance? can this be used, so to speak, in game servers, in terms of a scripting engine?
06:45:31FromDiscord<Elegantbeef> I mean it's the Nim VM if you want performance use wasm
06:45:45FromDiscord<Phil> In reply to @Elegantbeef "Right i just showed": That's also the way I do it in the proc I'm generating, it's flexibly inserting all the extra bells and whistles that is the hard part
06:46:13FromDiscord<Phil> (edit) "In reply to @Elegantbeef "Right i just showed": That's also the way I do it in the ... procthat" added "map" | "I'm generating," => "that I generate via `generateMapper`"
06:47:46FromDiscord<griffith1deadly> In reply to @Elegantbeef "I mean it's the": ik, I just don't know what the overall performance is like in this NimVM, so I thought it would be appropriate to ask. sorry if that's not the case
06:48:32FromDiscord<Elegantbeef> I have no clue the performance of the NimVM, it's not great afaik
06:48:32FromDiscord<Elegantbeef> I've never benchmarked it
06:50:30FromDiscord<Phil> Last I skimmed over conversations relating to that the word was that the nimvm has somewhat python-ish runtime performance. Take that with a salt-mine sized grain of salt.
06:52:37FromDiscord<Phil> In reply to @Elegantbeef "Right i just showed": Ohhhh now I get it.↵You want to essentially write a bespoke proc to convert from any A to one specific B while I was going for a proc that can map from any A to any B (given enough mapping information)
06:53:37FromDiscord<Phil> Which would mean in that one bespoke proc you're allowed to make assumptions about B itself
06:56:10FromDiscord<Phil> Hmm I'm still struggling to see how that could solve me scenarios where I wanted to map e.g. both A1 and A2 to B, but only for A1 I needed to first double a value.↵At that point we're back to needing to provide mapping information
06:59:50FromDiscord<odexine> youre going to have to provide that information no matter which case
07:03:16FromDiscord<Phil> Yeah. I mean I've got it all working so far, even the bits with the transformation procs.↵Just the const values are giving me grief
07:03:38FromDiscord<Phil> ... Which is a smidgeon weird because I kinda thought the procs would be what would do me in
07:35:54*ajunior joined #nim
07:36:54*ajunior quit (Client Quit)
08:34:09*ajunior joined #nim
08:51:39NimEventerNew question by Jim: Nim cannot install a package, see https://stackoverflow.com/questions/76792806/nim-cannot-install-a-package
08:57:33*ntat quit (Quit: leaving)
09:00:32*disso-peach quit (Quit: Leaving)
10:16:35FromDiscord<Phil> On which paths does `nim c` actually look for packages?
10:17:19FromDiscord<Phil> Like I'm pretty sure it looks in `~/.nimble/pkgs` for packages as well as whereever the std lib is stored, but how does it know to look in ~/.nimble/pkgs?↵Hard-coded behaviour for each OS?
10:19:16FromDiscord<odexine> I think it’s written in a config file on installation with nimble?
10:21:49FromDiscord<Phil> Mostly confused becaused if I'm understanding https://nim-lang.org/docs/nimc.html#compiler-usage-search-path-handling right then it should be using $PATH, but I don't have `.nimble/pkgs` or pkgs2 on the path so that's weird.
10:22:04FromDiscord<Phil> Within .nimble I'm not seeing anything that directly hints that its the source
10:23:17FromDiscord<odexine> In reply to @isofruit "Mostly confused becaused if": It doesn’t use literal POSIX $PATH environment variable but it’s own concept of PATH
10:23:25FromDiscord<Phil> ohhhhhh
10:24:11FromDiscord<Phil> And that one you can see via nim dump, check
10:51:55FromDiscord<Phil> I think I might have just been incredibly dense earlier when it came to creating the mapping
10:52:33FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4BLQ
10:54:43FromDiscord<Phil> Works flawlessly.↵So what I'm learning is that anonymous procs are the best way to skirt around the type system if I can infer the type of the proc later
10:55:03FromDiscord<Phil> ... how likely is it that I'll be running into GC issues because of my useage on pointers, those aren't referenced right?
10:55:14FromDiscord<Phil> (edit) "referenced" => "traced"
10:55:28FromDiscord<Phil> (edit) "GC" => "GC/leaking"
11:14:56FromDiscord<terrygillis> sent a code paste, see https://play.nim-lang.org/#ix=4BLV
11:16:46FromDiscord<Phil> My interpretation of that has always been that there is a difference between how Nim treats your type in terms of when to copy etc. And how it implements them under the hood
11:17:34FromDiscord<Phil> Though that is to be taken with a grain of salt, I'm not insanely deep in the material
11:27:41FromDiscord<demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4BLY
11:31:46FromDiscord<demotomohiro> It also can be a pointer to string literal.
11:36:19FromDiscord<terrygillis> ah got it thanks.
12:42:24*Avatarfighter joined #nim
12:42:44Avatarfightero/
12:43:34FromDiscord<Phil> Cheers
12:44:07NimEventerNew Nimble package! bale - Bale.ai bot API, see https://github.com/hamidb80/bale
12:48:18*Avatarfighter left #nim (#nim)
12:50:14*azimut joined #nim
13:48:21*jmdaemon quit (Ping timeout: 245 seconds)
14:36:34FromDiscord<frobnicate> Is there a binomial distribution function in the std libs or do I have to make that myself?
14:37:19FromDiscord<odexine> Binomial coefficient yes, not sure about distribution
14:37:25FromDiscord<odexine> Not sure if they’re even related NGL
14:40:37FromDiscord<frobnicate> The coefficient is used in the distribution
15:37:44*cedb quit (Quit: WeeChat 4.0.2)
16:06:27*ntat joined #nim
16:23:25*ntat quit (Quit: leaving)
16:33:15*ced1 joined #nim
16:34:56*ntat joined #nim
16:36:22*ced1 is now known as cedb
16:51:43FromDiscord<fabricio> made a java class file parser, no doc yet though https://github.com/fabriciopashaj/javaclass
16:54:58FromDiscord<griffith1deadly> In reply to @fabricio "made a java class": what would that be for? i don't see just any readme
16:58:38*azimut quit (Ping timeout: 240 seconds)
17:15:24FromDiscord<fabricio> In reply to @griffith1deadly "what would that be": a jvm maybe idk, it was for learning purposes
18:08:53*ntat quit (Quit: leaving)
19:43:03FromDiscord<Phil> I kinda want to smosh multiple instances of types together into one big iterable of fields
19:43:13FromDiscord<Phil> (edit) "multiple" => "" | "instances of ... types" added "different"
19:43:18FromDiscord<Phil> (edit) "I kinda want to smosh instances of different types together into one big iterable of fields ... " added "for a mapping function"
19:43:33FromDiscord<Phil> I'm semi certain there are no semantics that allow for that, just would be neat
19:44:38FromDiscord<Phil> Like in terms of mapping 1 instance of A and B to 1 instance of C, the fact that A and B are separate instances really only matters in case A and B both define fields of the same name, other than that I'd just want to iterate over both of them and transfer their field values over
19:46:07FromDiscord<Phil> (edit) "Like in terms of mapping 1 instance of A and B to 1 instance of C, the fact that A and B are separate instances really only matters in case A and B both define fields of the same name, other than that I'd just want to iterate over both of them and transfer their field values over ... " added "if names match"
19:58:10*azimut joined #nim
20:36:13*jmdaemon joined #nim
20:54:55*xet7 quit (Remote host closed the connection)
21:19:38*azimut quit (Ping timeout: 240 seconds)
21:20:25*azimut joined #nim
21:46:36NimEventerNew question by me0045: Nim - Data not being able to transfer between functions using nim prologue, see https://stackoverflow.com/questions/76795577/nim-data-not-being-able-to-transfer-between-functions-using-nim-prologue
21:48:50*azimut quit (Remote host closed the connection)
21:49:17*azimut joined #nim
23:47:53FromDiscord<ajusa> Does anyone know how generic proc precedence works? I have a proc that takes [T: object] and a proc that takes [MyType]. For some reason, the first proc gets called unless I delete it, at which point the second one is called.↵↵Am I missing something about the order of the procs being declared?
23:48:13FromDiscord<ajusa> (what I'm trying to do is conceptually similar to treeform's json y)
23:48:14FromDiscord<Elegantbeef> The most specific procedure is dispatched
23:48:21FromDiscord<ajusa> (edit) "json y)" => "jsony)"
23:48:45FromDiscord<Elegantbeef> What are the actual overload
23:48:48FromDiscord<Elegantbeef> overloads\
23:49:41FromDiscord<ajusa> sent a code paste, see https://play.nim-lang.org/#ix=4BOA
23:50:07FromDiscord<Elegantbeef> Are you calling an intermediate procedure?
23:50:16FromDiscord<Elegantbeef> If so you likely left out `mixin fromRequest`
23:50:35FromDiscord<ajusa> I might be? looking up what mixing does now
23:50:55FromDiscord<ajusa> oh huh that works
23:51:38FromDiscord<ajusa> ah, I thought it was an ordering issue - mixin basically says to defer lookup of the procedure until later, leaving it "open"?
23:53:54FromDiscord<Elegantbeef> No
23:54:10FromDiscord<Elegantbeef> It says "this symbol will include this scope and instantiation scope"
23:55:58FromDiscord<Elegantbeef> In the case there is no overload inside the generic scope it tightly binds the symbol, if there are overloads it mixins the symbol
23:56:15FromDiscord<Elegantbeef> I generally am paranoid and manually mixin