<< 15-06-2023 >>

00:21:27*krux02 quit (Remote host closed the connection)
00:23:28*beholders_eye joined #nim
01:38:39*derpydoo joined #nim
01:39:09termerElegantBeef, Thanks for the info as always
01:39:20termerI hope that was at least somewhat enjoyable for others lol
01:41:17*beholders_eye quit (Ping timeout: 265 seconds)
02:26:11FromDiscord<heysokam> In reply to @termer "https://live.termer.net/": that `owncast` project looks pretty cool↵how do you get found by viewers, though?
02:29:34*derpydoo quit (Quit: derpydoo)
02:29:53FromDiscord<Elegantbeef> The fediverse 😄
02:34:54termerfediverse, yeah
02:34:54termerand the owncast directory
02:34:57termerbut mostly by posting the link on IRC
02:36:00FromDiscord<voidwalker> In reply to @michaelb.eth "per that readme, a": what is the actual syntax to get the value of a compile option like -d:opt=vaue ?
02:36:07FromDiscord<voidwalker> (edit) "-d:opt=vaue" => "-d:opt=value"
02:36:23FromDiscord<Elegantbeef> \`const op{.strDefine.} = "default"\~
02:36:48FromDiscord<voidwalker> wtf is that
02:37:20FromDiscord<Elegantbeef> `const opt{.strDefine.} = "default"` properly written
02:37:34FromDiscord<Elegantbeef> It's a pragma to say "this is a string defined variable"
02:39:24FromDiscord<voidwalker> hm I still don't get it :"\
02:39:53FromDiscord<Elegantbeef> `opt` is your option name `"default"` is the value you want to have if it's not defined
02:40:06FromDiscord<voidwalker> no I mean how to get the defined one
02:40:24FromDiscord<voidwalker> or is that special syntax
02:40:36FromDiscord<Elegantbeef> `-d:opt = value` will cause the above `opt` to be `value`
02:43:33FromDiscord<voidwalker> hmm
02:43:39FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4yfI
02:43:44FromDiscord<voidwalker> ` Error: 'import' is only allowed at top level`
02:43:48FromDiscord<Elegantbeef> `when asyncBackend == "chronos"`
02:44:08*azimut quit (Ping timeout: 240 seconds)
02:47:03FromDiscord<voidwalker> hm okay thanks, I will have to read the manual one day : )
02:48:47FromDiscord<voidwalker> well, seems like std httpclient no go with chronos. they have their own thing here: https://github.com/status-im/nim-chronos/tree/master/chronos/apps/http
02:49:42FromDiscord<Elegantbeef> Right the point of `asyncbackend` is you can in theory support any backend you want to emitting code that works with the selected one
02:50:03FromDiscord<Elegantbeef> Chronos isnt a drop in replacement afaik
02:50:44FromDiscord<voidwalker> indeed, I was curious to see if the simple await/waitFor code I have will work, but stuck on httpclient
03:10:03FromDiscord<voidwalker> welp, asyncnet is also incompatible. and this rfc was close because stale : https://github.com/nim-lang/RFCs/issues/158
03:40:52termerChronos is missing some things and works better
04:10:49FromDiscord<wrld> How can I share file locks between 2 separate programs
04:13:48FromDiscord<graveflo> what do you mean share them?
04:25:30FromDiscord<wrld> In reply to @graveflo "what do you mean": like if one program is doing something the other program can't intervene
04:26:18FromDiscord<graveflo> I know what you mean, but idk how you are using "share" in this context. You are usually looking at a predefined file path. There is nothing to share unless you read the file I guess
04:26:21FromDiscord<michaelb.eth> In reply to @wrld "like if one program": signaling over socket + state machine
04:51:10*oldpcuser quit (Quit: FreeBSD 15 and Slackware 16 will come with systemd)
05:03:57*oldpcuser joined #nim
05:04:51*oldpcuser quit (Remote host closed the connection)
05:05:23*oldpcuser joined #nim
05:21:28*ntat joined #nim
05:56:24*derpydoo joined #nim
06:09:24*rockcavera quit (Remote host closed the connection)
06:28:29*PMunch joined #nim
07:14:40*beholders_eye joined #nim
07:40:54FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4ygk
07:44:12FromDiscord<voidwalker> ahh nvm, I had a toSeq converter for an unrelated type declared in an import, and somehow it didn't like that
07:44:34FromDiscord<voidwalker> there was some rules about those but I forgot
07:44:39FromDiscord<voidwalker> (edit) "there was some rules about those but I forgot ... " added "what"
07:54:19FromDiscord<voidwalker> I need to create some sort of url query parameters templates, where I define the order and value of the keys, and the values get filled up dynamically based on the keys. Any suggestions ?
07:59:42FromDiscord<graveflo> usually the order doesn't matter but I recently had to do the same thing so I'll share with you what I had figured
08:01:45FromDiscord<graveflo> It depends on what the URL schemes you are using are doing, but most often they are behaving like functions. You give them parameters and they return some info or maybe change the state of a session that kind of thing. So this should be modeled with procs. Sounds obvious but you'd be surprised what people will over engineer to do something simple like that
08:02:18FromDiscord<graveflo> each url stream should be its own object and that object can either be or have a data structure that hold the parameters
08:02:37FromDiscord<graveflo> like I'll give you an example of one of the urls I modeled
08:02:55FromDiscord<voidwalker> the order does matter for me since I want to spoof some specific client behaviour, without leaving any unwanted fingerprints
08:03:44FromDiscord<voidwalker> like, I also need to make a toHex that can do lowecase lol. std one does uppercase, stew one does lowercase
08:03:49FromDiscord<graveflo> alright well just use an ordered datastype like a seq
08:04:10FromDiscord<graveflo> sent a code paste, see https://play.nim-lang.org/#ix=4ygo
08:04:23FromDiscord<graveflo> you dont have to overdo it with the enums and stuff but that can be what holds the data
08:05:11FromDiscord<graveflo> sent a code paste, see https://play.nim-lang.org/#ix=4ygp
08:06:07FromDiscord<graveflo> so if one of the actions your url does is to set a config, wrap the parameters in a proc and build the url with `std/uri` if you want to build the parameters over multiple functions or something just use `object` to track the key value pairs
08:07:34FromDiscord<graveflo> I think lowercase hex can be done with `fmt`
08:07:34FromDiscord<voidwalker> processing...
08:09:07FromDiscord<graveflo> oh and if you wanted to alias `seq[(string,string)]` like I did instead of make an object you might want to make it `distinct` but then you have to deal with annoying converters
08:14:07FromDiscord<graveflo> also if you arent going to have a complex uri interface you can just use the `seq` `uri` and a `proc` ofc. Having the parameters be their own object only makes sense if it is more then trivial to set up the data
08:18:19FromDiscord<voidwalker> Well, I want to define the templates either as `seq[(string,string)]` inside a const object, or maybe load them from a file with profiles, that would be better. Or maybe just seq[string] since I won't be storing any values inside the template itself (i think). Ideally we'd keep it simple like that, no extra objects.
08:18:30FromDiscord<voidwalker> (edit) "seq[string]" => "`seq[string]`"
08:19:07FromDiscord<graveflo> are these just static urls?
08:19:28FromDiscord<voidwalker> the params are static, they will be added to whatever url needs to be accessed
08:20:00FromDiscord<voidwalker> i mean the params keys, the values will change at each call
08:20:25FromDiscord<graveflo> then all you need is `uri` because you can just use `/` and `?` and build the uri from its pieces with a 1 liner whenever you want
08:20:30FromDiscord<voidwalker> I guess I can define a function to return the value for each key, but how do I bind the functions to the key value
08:22:27FromDiscord<graveflo> you can do something like use a table intead if you want to make it easier for that. If what you are doing is static enough you can just use non-seq objects to store the data. It depends.
08:23:44FromDiscord<graveflo> the basic tools for building the uri are in `std/uri` use the simplest data structure that makes sense but just know that once you use `/` and `?` I think the url wont be changing without deletions
08:24:30FromDiscord<voidwalker> a table of string, func() ?
08:25:37FromDiscord<graveflo> I would assume `[string, T]` where `T` can be converted to a string... or anything really as long as the parameters are converted to a string when its time to use `/` and `?` to build the uri
08:26:45FromDiscord<voidwalker> I remember doing this 1 year ago, after the spoonfeed of beef I think
08:27:14FromDiscord<voidwalker> looked like this
08:27:15FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4ygq
08:27:58FromDiscord<graveflo> wtf is that....
08:27:59FromDiscord<voidwalker> the proc had to be a close for some reason
08:28:22FromDiscord<voidwalker> (edit) "https://play.nim-lang.org/#ix=4ygq" => "https://play.nim-lang.org/#ix=4ygs"
08:28:25FromDiscord<voidwalker> key value table lol
08:28:54FromDiscord<voidwalker> (edit) "https://play.nim-lang.org/#ix=4ygs" => "https://play.nim-lang.org/#ix=4ygt"
08:30:26FromDiscord<graveflo> well idk what you are trying to do, but if you are just trying to keep track of parameters and then assemble them into a uri all you need is an object for the persistence, like maybe a `seq` or `table` and youll prob want to have a `proc` that handles the parameters of what you actually want to do and you can use `std/uri` to put it all together
08:30:33FromDiscord<graveflo> thats all I got
08:31:58FromDiscord<voidwalker> yeah I know how to put them together, been doing it statically so far, but I really wanted to do this client spoof feature, for which I need "query param templates"
08:34:18FromDiscord<graveflo> what is a query param template
08:40:26FromDiscord<voidwalker> `@["key1", "key2", "key3"]` basically, which gets expanded to `@[("key1", funcForKey1()), "key2", funcForKey2()), "key3", funcForKey3())]` which gets appended to url via `?`
08:42:03FromDiscord<graveflo> alright but why must it be so complicated?
08:42:26FromDiscord<voidwalker> because keys could be in different order, or some keys might be present/absent
08:44:52FromDiscord<graveflo> hmm well that certainly doesn't explain why you have a list of proc handles. Whichever way you chose to build the uris is up to you I guess. I do doubt that whatever you are doing really needs that level of dynamics.
08:49:39FromDiscord<voidwalker> well some of the values needed for the keys change all the time. edited the example above for more precision
08:51:22FromDiscord<graveflo> but when and why do they change? how do you know what to do when they change? You are just explaining state management. This is done with objects like your `seq` or a `table`.
08:51:25FromDiscord<voidwalker> I believe it's called "dispatch table"
08:53:25FromDiscord<graveflo> like if you had an asynchronous system that was dispatching signals into an event loop you might need something like that, but if you are just deciding how to build a url based off of some keys then you dont need all that
08:53:38FromDiscord<voidwalker> they ones that change can change any second. when they change, nothing will happen in regards to this url calling/template, this needs to be called at regular intervals, like 1 hour
08:53:54FromDiscord<voidwalker> (edit) "they" => "the"
08:54:11FromDiscord<voidwalker> just reporting some stats
08:57:34FromDiscord<graveflo> what is changing? elements in a list in the program that you are writing? What needs to be called at regular intervals?
08:58:33FromDiscord<graveflo> are you saying that server side data can change at any time but you are only checking it every hour?
08:59:00FromDiscord<voidwalker> some stats are changing, fields in an object I guess. the endpoint at the url(s) associated with the object need to be called at regular intervals, to report those stats, thus why I need to call functions to get the values
09:03:58FromDiscord<graveflo> okay I guess what I am saying then is when it is time to report the stats why dont you just iterate over the keys and pair then with their correct values and then call it a day
09:05:00FromDiscord<graveflo> wouldnt you just have a function that accepts a seq[string] and then processes that into a `seq[(string, string)]` bu reading the key and calculating a pair value.. then you have what you need
09:05:14FromDiscord<graveflo> (edit) "bu" => "by"
09:06:23FromDiscord<voidwalker> so a `case key of" instead of table.. where I have the appropiate function, I guess that could work as well
09:07:34FromDiscord<graveflo> you can use a table there if you want to
09:07:37FromDiscord<voidwalker> I guess that wasn't that hard : P
09:08:49FromDiscord<voidwalker> 3 hours of sleep, I guess my brai has holes
09:10:39FromDiscord<graveflo> its ok I know what you mean. I have a splitting headache
09:10:49FromDiscord<graveflo> havent been able to concentrate for like 4 hours
09:14:27FromDiscord<heysokam> sent a long message, see http://ix.io/4ygC
09:15:04FromDiscord<heysokam> basically a `seq[seq[string]]` type of loop
09:17:15FromDiscord<heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4ygE
09:17:21FromDiscord<heysokam> (edit) "https://play.nim-lang.org/#ix=4ygE" => "https://play.nim-lang.org/#ix=4ygF"
09:17:41FromDiscord<graveflo> "that each contain a list of files to build that object." what object the one that hold the list that contains ta list of files? thats recursive
09:18:06FromDiscord<heysokam> each object contains a list of files
09:18:15FromDiscord<heysokam> some are in common, others are not
09:18:50FromDiscord<heysokam> the idea is to group them, so they don't need to be explictely listed separately like 10 times _(the file is already 1500sloc)_
09:19:36FromDiscord<graveflo> so you want something like a set or table? that way you can find duplicates?
09:20:01FromDiscord<heysokam> hmmm i didn't think of using a table/set
09:20:01*beholders_eye quit (Ping timeout: 240 seconds)
09:20:36FromDiscord<graveflo> if all you are doing is looking for duplicates just add them to a set as you iterate. If they are already in the set you know its a dupe
09:20:37FromDiscord<heysokam> i was trying to do the filtering myself, and was really struggling
09:20:47FromDiscord<heysokam> but a set should do that already, didn't realize that
09:21:18FromDiscord<graveflo> its wont span all objects but you could even add them to each object and a set at the same time and have no dupes by the end of your setup
09:21:23FromDiscord<demotomohiro> I think this is what you want:https://nim-lang.org/docs/sets.html#intersection%2CHashSet%5BA%5D%2CHashSet%5BA%5D
09:21:58FromDiscord<heysokam> yea, looks like it!
09:22:16FromDiscord<heysokam> and if not, some of the other set tools should do the trick
09:47:06FromDiscord<arkanoid> sent a long message, see http://ix.io/4ygK
09:56:03FromDiscord<voidwalker> only Beef can know those, won't happen : P
09:57:15FromDiscord<demotomohiro> I dont know such resources other than Nim manual / experimental_manual.
10:02:22FromDiscord<graveflo> beef and tomohiro as well as some others have made some blog posts that you can read. I get linked interesting nim articles here but they are dark af on search engines. Basically have to get linked or use some engine that I don't know about
10:05:21FromDiscord<demotomohiro> My Nim FAQ page doesn't contains much content about typeclasses or concepts↵https://internet-of-tomohiro.netlify.app/nim/faq.en.html
10:06:18FromDiscord<demotomohiro> This question is related to typeclass: https://internet-of-tomohiro.netlify.app/nim/faq.en.html#procedures-how-to-get-a-pointer-to-a-generic-procedure-or-a-procedure-with-type-class-parametersqmark
10:25:32*derpydoo quit (Ping timeout: 240 seconds)
11:06:06*beholders_eye joined #nim
11:08:19*azimut joined #nim
11:30:48*a11e99z joined #nim
11:51:19*GreaseMonkey quit (Quit: HYDRA IRC LOL)
12:04:33FromDiscord<arkanoid> thanks a lot
12:06:11*droidrage quit (Ping timeout: 246 seconds)
12:16:09NimEventerNew thread by alexeypetrushin: Why `unsafe_addr` had to be used in StringSlice?, see https://forum.nim-lang.org/t/10274
13:00:12FromDiscord<Andreas> sent a long message, see http://ix.io/4yht
13:01:57FromDiscord<Andreas> (edit) "http://ix.io/4yht" => "http://ix.io/4yhw"
13:11:47*rockcavera joined #nim
13:13:55FromDiscord<Dale 데울> The what-now circle? Not heard that term before
13:14:19FromDiscord<Andreas> In reply to @dale8689 "The what-now circle? Not": vicious-circle - for the uninvited
13:14:41FromDiscord<Dale 데울> Ah
13:15:12FromDiscord<Dale 데울> Yeah that was my thought when seeing the complaint. Concepts are kinda new right?
13:18:36FromDiscord<Andreas> In reply to @dale8689 "Yeah that was my": yes, fresh but might become verz powerfull. for documentation and for not having to repeat oneself in coding-stuff.. I went that far this morning to try to implement part of an interface right in the concept - it prbly. not yet intended to try such, but was curious to see what happens - and it was exciting, cos' parts of it worked...
13:19:20FromDiscord<Andreas> (edit) "verz" => "very" | "verypowerfull. for documentation and for not having to repeat oneself in coding-stuff.. I went that far this morning to try to implement part of an interface right in the concept - it prbly. not yet intended to try such, but ... wasmight" added "i" | "happens" => "might happen"
13:19:39*oldpcuser quit (Read error: Connection reset by peer)
13:20:15*oldpcuser joined #nim
13:20:24FromDiscord<Dale 데울> I haven’t explored them yet. So that’s like, having a default implementation for a virtual method?
13:20:29FromDiscord<mratsim> In reply to @dale8689 "Yeah that was my": Yes they are only 6 years old
13:20:59FromDiscord<Andreas> In reply to @mratsim "Yes they are only": exactly..
13:21:45FromDiscord<Andreas> In reply to @mratsim "Yes they are only": really ? i thought 2-3 yrs 🙂
13:23:10FromDiscord<mratsim> In reply to @arkanoid "the more I program": Some advanced yet simple example: https://github.com/mratsim/constantine/blob/master/constantine/hashes.nim#L17-L38
13:25:12FromDiscord<mratsim> In reply to @Andreas "really ? i thought": At least Jan 2016: https://github.com/andreaferretti/emmy/blob/b9b02e829078f6e44f905672f0b86d2d32588611/private/structures.nim#L14-L29
13:25:40FromDiscord<Andreas> In reply to @mratsim "Some advanced yet simple": nice example, short and clear...
13:30:59FromDiscord<Andreas> In reply to @mratsim "At least Jan 2016:": maybe you know if we can get interface-contracts via concepts, so that the inference-engine takes a proc from a concept if the concrete-type lacks it ? That would save me thousends of lines of repetive stupid proc-signatures, that only differ in the name of the type..
13:44:18FromDiscord<deech> sent a code paste, see https://play.nim-lang.org/#ix=4yhI
13:44:41FromDiscord<deech> (edit) "https://play.nim-lang.org/#ix=4yhI" => "https://play.nim-lang.org/#ix=4yhJ"
13:48:02FromDiscord<arkanoid> when importing Nim or C/C++ code I always fear not doing the right thing memory wise.↵By reading best practices, it seems that passig non GCed data is much easier and less error prone than dealing with cross boundary GCed data, so I'd like to stick with this, but I actually don't know what this really means.↵↵What can be considered non GCed data, when passing objects?
13:48:51FromDiscord<Andreas> In reply to @arkanoid "when importing Nim or": hmm, anything self-allocated `ptr`.
13:50:46FromDiscord<demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4yhN
13:50:55FromDiscord<arkanoid> so the easy path is passing pointers around to manually allocated heap objects?
13:52:43FromDiscord<arkanoid> I'm not sure why there are limits for some compilation time stuff (like maxiteration) but not for others↵(@Andreas)
13:53:07FromDiscord<Andreas> In reply to @arkanoid "so the easy path": i'd say so - given it is not clear which GC-engine owns the data and is responsible for disposal, might be better to do it by hand..
13:53:16*rockcavera quit (Remote host closed the connection)
13:53:56FromDiscord<arkanoid> seems not so ergonomic
13:54:16FromDiscord<deech> In reply to @demotomohiro "I think it should": Thanks but I don't really want to make the user manually cast in order to use the API.
13:57:07FromDiscord<graveflo> In reply to @deech "Thanks but I don't": I don't think this is casting
13:58:12FromDiscord<Andreas> In reply to @deech "Thanks but I don't": thats a good point 🙂 well, just in case strange things happen - and i have great respect for ARC/ORC doing their buisness - in my case - lock-free-structures, they are just toooo good in releasing stuff, i need to keep alive for some ns. So i have do DIY all the time, cos' the collectors are black-boxes to me..
13:59:04FromDiscord<jmgomez> In reply to @deech "Thanks but I don't": you could spin a converter `converter parentToChild(c:Opt[Child]): Opt[Parent] = cast[Opt[Parent]](c)` ↵Not ideal but at least it will work with a subset of generics
13:59:13FromDiscord<demotomohiro> sent a code paste, see https://paste.rs/3ICkZ
14:00:21FromDiscord<jmgomez> (edit) "In reply to @deech "Thanks but I don't": you could spin" => "sent" | "converter `converter parentToChild(c:Opt[Child]): Opt[Parent] = cast[Opt[Parent]](c)` ↵Not ideal but at least it will work with a subset of generics" => "code paste, see https://paste.rs/EVzgF"
14:02:52FromDiscord<deech> In reply to @jmgomez "you could spin a": Haha, I try and stay away from converters. Too much implicit magic for me.
14:05:11FromDiscord<jmgomez> sent a code paste, see https://play.nim-lang.org/#ix=4yhR
14:05:43FromDiscord<deech> sent a code paste, see https://play.nim-lang.org/#ix=4yhS
14:06:18FromDiscord<jmgomez> for some reason it only works in `importc` types though
14:07:45FromDiscord<mratsim> In reply to @Andreas "maybe you know if": First question is, why not use generics?↵↵Secodn is why not use a template?
14:09:31FromDiscord<deech> @jmgomez Do you have a link to docs on `out` handy?
14:11:04FromDiscord<jmgomez> https://nim-lang.org/1.4.4/manual_experimental.html#covariance
14:14:09*PMunch quit (Quit: Leaving)
14:19:13*giga84 joined #nim
14:22:01FromDiscord<demotomohiro> In reply to @jmgomez "https://nim-lang.org/1.4.4/manual_experimental.html": There is no section "Covariance" in newer version of manual_experimental/manual.↵That feature was removed later?
14:22:49FromDiscord<jmgomez> No idea, maybe a question for #internals
14:23:16FromDiscord<arkanoid> thanks, this makes sense, but requires to assure what importes function does with the passed pointer.I'm not a system programmer and I rarely used C/C++ directly, so I'd like to ask what is considered good or bad when exposing a function, and what should a programmer consider first↵(@demotomohiro)
14:24:09*greaser|q joined #nim
14:24:23*greaser|q quit (Client Quit)
14:25:01giga84hi i am a beginner to programming in general. I am learning python and am learning nim with "nim basics" by narimiran. I have setup vscode as told by nariman but only echo "hello world" is working. When i try integers.nim (https://paste.ofcode.org/37h7ucr4jNHEAJvKqXAQaQK) i get an error in vs code. but runs well in play.nim-lang.org. What am i
14:25:01giga84doing wrong
14:26:22FromDiscord<michaelb.eth> In reply to @jmgomez "for some reason it": is `[out T]` in the manual? maybe my eyes are just missing it, trying to find it with page-search
14:26:40FromDiscord<michaelb.eth> oh hah, just saw your comment in internals
14:27:08FromDiscord<auxym> In reply to @arkanoid "thanks, this makes sense,": first, objects are not GC managed, so you won't have a problem there. second, the only problem I could see is if that C func tries to call free() on that pointer, some something like that, but that would be horribly bad practice in general. Even in C it's common to pass a pointer to a stack-allocated data
14:27:24FromDiscord<auxym> only strings, seqs and ref objects are GC-managed
14:28:37FromDiscord<arkanoid> Obviously I'm talking about heap allocated objects, not stack allocated ones
14:29:08FromDiscord<auxym> In reply to @arkanoid "Obviously I'm talking about": well is example you gave (object) is on the stack
14:30:47FromDiscord<michaelb.eth> In reply to @giga84 "hi i am a": hmm, it's working in the playground: https://play.nim-lang.org/#ix=4yi2
14:31:32FromDiscord<auxym> keeping that pointer around would generally be super bad practice even in C, like I said, because in C it's usually expected that the caller may pass in a stack-allocated var. In the general case of course, it's possible, but if that pointer needs a specific lifetime, it would be expected to be documented VERY CLEARLY in big red bold letters or something
14:31:40FromDiscord<auxym> so yeah, C sucks
14:32:25FromDiscord<Andreas> sent a long message, see http://ix.io/4yi3
14:32:44FromDiscord<arkanoid> so if a C function has a pointer arg, I can safety assume that if C programmer is following good practices is up to me to pass a stack or heap pointer, and C would not call free on it in either case, correct?
14:33:37FromDiscord<demotomohiro> sent a long message, see http://ix.io/4yi5
14:34:18*rockcavera joined #nim
14:35:12FromDiscord<demotomohiro> In reply to @arkanoid "so if a C": C functions can take both heap and stack.↵C functions can free given pointer.
14:35:42FromDiscord<demotomohiro> C functions can take both a pointer to heap and stack.
14:35:47*greaser|q joined #nim
14:39:34FromDiscord<mratsim> sent a long message, see https://paste.rs/6Pv9O
14:40:34FromDiscord<Andreas> In reply to @mratsim "Can't talk nuch: ": ic, you've done this before , thx..
14:40:37FromDiscord<arkanoid> makes sense. I think I just lack the experience with C to automatically infer what is the pattern going on, generally speaking.↵↵thanks for the feedback
14:47:45FromDiscord<demotomohiro> C functions usually takes a large struct types with pointer just in order to avoid copying arguments.↵In that case, you might be able to safely pass a pointer to objects in heap, stack or static storage.↵Some C library have a specific funtion that create an object and returns a pointer to it and other functions only takes a pointer returned from that function.
14:58:05FromDiscord<auxym> In reply to @arkanoid "so if a C": always read the docs, but yeah, that should be correct in 97% of cases
15:06:07FromDiscord<demotomohiro> sent a long message, see http://ix.io/4yiz
15:07:27giga84michaelb.eth
15:07:32giga84are you there
15:15:43*giga84 left #nim (#nim)
15:16:12FromDiscord<giga84> hi i am a beginner to programming in general. I am learning python and am learning nim with "nim basics" by narimiran. I have setup vscode as told by nariman but only echo "hello world" is working. When i try integers.nim (https://paste.ofcode.org/37h7ucr4jNHEAJvKqXAQaQK) i get an error in vs code. but runs well in play.nim-lang.org. What am i doing wrong?
15:19:29FromDiscord<heysokam> In reply to @giga84 "hi i am a": that code paste is fine. do you have anything else that you didnt paste?
15:19:42FromDiscord<heysokam> also, share the error code ifyou dont mind, otherwise its hard to predict whats wrong
15:20:09FromDiscord<heysokam> (edit) "code" => "output"
15:20:19FromDiscord<giga84> ok
15:21:10FromDiscord<giga84> i[Running] nim compile --verbosity:0 --hints:off --run "d:\nim\excerises\chap_2\integers.nim"↵d:\nim\excerises\chap_2\integers.nim(3, 1) Error: identifier expected, but got 'echo'↵↵[Done] exited with code=1 in 0.554 seconds
15:23:33FromDiscord<heysokam> In reply to @giga84 "i[Running] nim compile --verbosity:0": something is happening between the second integer definition and the echo
15:24:19FromDiscord<heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4yiW
15:25:00FromDiscord<heysokam> if that is not the case, then there is something in between those two lines that is breaking it (whether it is tab charaters, or something else)
15:25:12FromDiscord<demotomohiro> In reply to @giga84 "hi i am a": If your code compiles and runs file on Nim Playground, your code probably doesn't have problems.↵Probably there is a problem in vscode.↵But I cannot helps you as I dont use vscode.
15:25:31FromDiscord<giga84> same error
15:25:32FromDiscord<giga84> [Running] nim compile --verbosity:0 --hints:off --run "d:\nim\excerises\chap_2\integers.nim"↵d:\nim\excerises\chap_2\integers.nim(3, 1) Error: identifier expected, but got 'echo'↵↵[Done] exited with code=1 in 0.397 seconds
15:25:55FromDiscord<michaelb.eth> hmm, what do you get with `nim --version`
15:26:13FromDiscord<heysokam> !eval let one = 1; let two = 2; echo "one + two =", one + two
15:26:20NimBotone + two =3
15:26:37FromDiscord<giga84> nim -- version
15:26:43FromDiscord<giga84> sent a long message, see http://ix.io/4yj1
15:27:11FromDiscord<heysokam> try compiling manually with `nim c -r yourfile.nim`
15:27:41FromDiscord<giga84> even in windows command line i get the error
15:27:41FromDiscord<giga84> Hint: used config file 'D:\nim\nim-1.6.12_x64\nim-1.6.12\config\nim.cfg' [Conf]↵Hint: used config file 'D:\nim\nim-1.6.12_x64\nim-1.6.12\config\config.nims' [Conf]↵..........................................................↵D:\nim\excerises\chap_2\integers.nim(3, 1) Error: identifier expected, but got 'echo'
15:27:51FromDiscord<michaelb.eth> egads
15:28:05FromDiscord<heysokam> well, then you have something in between those two lines
15:28:08FromDiscord<michaelb.eth> I think something is wrong with the source file
15:28:39FromDiscord<michaelb.eth> maybe the line endings or encoding are screwed up somehow
15:29:06FromDiscord<heysokam> there must be a tab in between, most certainly
15:31:15FromDiscord<giga84> okay i figured out the problem. i opened the file in notepad and unlike python it doesn't save the edited part
15:31:39FromDiscord<giga84> so i saved it in vscode and ran it usin ctrl + alt +n
15:31:45FromDiscord<giga84> and then it worked
15:32:11FromDiscord<giga84> so every time i should save it before running it ok
15:32:40FromDiscord<giga84> thanks guys thanks soo much
15:32:42FromDiscord<michaelb.eth> friends don't let friends use notepad.exe; download notepad++ and set in the OS to use notepad++ to open plain text files, etc
15:32:57FromDiscord<michaelb.eth> https://notepad-plus-plus.org/
15:33:08FromDiscord<giga84> ok will do
15:33:21FromDiscord<giga84> thanks again
15:33:29FromDiscord<michaelb.eth> sure thing, glad you got it working
15:41:56FromDiscord<heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4yjh
15:46:14*krux02 joined #nim
15:52:22FromDiscord<faenor.> sent a long message, see http://ix.io/4yjv
16:19:05FromDiscord<michaelb.eth> are you using nimlsp or nimlangserver?
16:25:33*attah quit (Server closed connection)
16:26:55*attah joined #nim
16:48:13*tinystoat quit (Server closed connection)
16:48:22*tinystoat joined #nim
16:52:48FromDiscord<faenor.> I've tried both and neither work for me, just tried again and confirmed this. I've tried with mason/nvim of both nimlsp and nimlangserver. I've tried with nimlsp and nimsuggest on vscode, and I tried the nim plugin on jetbrains. Not sure where I'm going wrong
17:10:40*xet7 quit (Quit: Leaving)
17:12:21*xet7 joined #nim
17:12:36*ntat quit (Quit: Leaving)
17:28:17*beholders_eye quit (Quit: WeeChat 3.6)
17:30:58*a11e99z quit (Quit: Leaving)
17:32:20FromDiscord<vmawz> Can you do one-liner if else expressions in nim?
17:36:02FromDiscord<voidwalker> yessss
17:36:06FromDiscord<voidwalker> oneliners
17:36:23FromDiscord<michaelb.eth> sent a code paste, see https://play.nim-lang.org/#ix=4ykM
17:37:02FromDiscord<odexine> `if cond: exp else: exp` more of
17:55:06FromDiscord<awr1 (awr1)> sent a long message, see https://paste.rs/Zk4PF
17:57:33FromDiscord<awr1 (awr1)> i think what could be done is maybe an additional pragma that forwards doc generation in a private module X to any module Y that imports from X and re-exports X's symbols. not sure if there's a better approach
17:58:49FromDiscord<heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4ykU
17:59:17FromDiscord<wrld> How can I check if 2 of the same file aren't running?
18:00:01FromDiscord<heysokam> In reply to @wrld "How can I check": if by file you mean `process` check out `std/osproc`
18:00:16FromDiscord<auxym> sent a code paste, see https://play.nim-lang.org/#ix=4ykW
18:00:57FromDiscord<heysokam> In reply to @auxym "add your sets to": probably. but was asking more in terms of if there is varargs check already existing
18:01:08FromDiscord<wrld> In reply to @heysokam "if by file you": Nah, I meant like if the same EXE is launched twice (the current file), it kills the old one
18:01:09FromDiscord<heysokam> i can create one, but was wondering if there is one to not reinvent the wheel
18:01:18FromDiscord<heysokam> In reply to @wrld "Nah, I meant like": thats a process
18:01:41FromDiscord<awr1 (awr1)> which operating system↵(@wrld)
18:01:45FromDiscord<awr1 (awr1)> if windows, use CreateMutex()
18:02:09FromDiscord<wrld> Windows
18:06:08FromDiscord<awr1 (awr1)> yeah use CreateMutex(). if you get a mutex that already exists, you are the "new process"
18:07:15FromDiscord<wrld> In reply to @awr1 (awr1) "yeah use CreateMutex(). if": I can't seem to find it anywhere in the nim docs
18:08:00FromDiscord<awr1 (awr1)> it's a win32 API call
18:08:19FromDiscord<awr1 (awr1)> try `oldwinapi` or `winim`
18:09:52FromDiscord<wrld> sent a long message, see http://ix.io/4yl3
18:12:12FromDiscord<awr> not quite. CreateMutex() can succeed if the mutex is already created. what you want is GetLastError() after CreateMutex()
18:12:27FromDiscord<awr> and check for ERROR\_ALREADY\_EXISTS
18:16:43FromDiscord<wrld> sent a long message, see http://ix.io/4yl9
18:16:57FromDiscord<wrld> (edit) "long message," => "code paste," | "http://ix.io/4yl9" => "https://play.nim-lang.org/#ix=4yla"
18:17:53FromDiscord<awr> yup
18:17:56FromDiscord<awr> that's it
18:18:30FromDiscord<awr> actually no
18:18:31FromDiscord<wrld> It doesn't give me an error when 's in use, thoug
18:18:35FromDiscord<wrld> It just hangs
18:18:44FromDiscord<michaelb.eth> is it possible to store a NimNode instance somewhere outside of a macro?
18:18:56FromDiscord<awr> ERROR\_ALREADY\_EXISTS does not require returned handle to be nil
18:19:25FromDiscord<awr> it will return the already existing handle if it already exists
18:19:37FromDiscord<awr> what do you mean↵(@michaelb.eth)
18:19:45FromDiscord<awr> to be serialized?
18:20:02FromDiscord<wrld> Works perfectly now
18:20:07FromDiscord<wrld> sent a code paste, see https://play.nim-lang.org/#ix=4ylb
18:21:38FromDiscord<michaelb.eth> In reply to @awr "what do you mean": not necessarily serialized, but my idea is to have an object type where a field is of type NimNode; the macro returns an instance of that object type, and another macro in a separate call will do something with the NimNode
18:21:54FromDiscord<michaelb.eth> this will all be constants and compile-time stuff, for sure
18:22:18FromDiscord<awr> oh you can use `NimNodes` in procs just fine, so as long as its all in compiletime
18:25:47FromDiscord<michaelb.eth> sent a code paste, see https://play.nim-lang.org/#ix=4yld
18:26:14FromDiscord<awr> really a macro is just a proc with different parameter semantics that pastes the result NimNode to its callsite
18:26:25FromDiscord<michaelb.eth> the reason I guess is that NimNode is a ref, hmm
18:26:31FromDiscord<awr> more like a proc than a template actually, since the entire body isn't pasted
18:26:39FromDiscord<awr> did you import `std / macros`
18:26:47FromDiscord<michaelb.eth> `ref NimNodeObj`, but `NimNodeObj` isn't exported
18:26:58FromDiscord<michaelb.eth> yes, imported correctly, etc.
18:27:16FromDiscord<michaelb.eth> given that NimNodeObj isn't exported, I guess it can't work
18:27:29FromDiscord<michaelb.eth> because you can't store a `ref` in a `const`
18:28:24FromDiscord<awr> https://play.nim-lang.org/#ix=4ylg
18:28:31FromDiscord<Sebwazhere> sent a long message, see http://ix.io/4ylh
18:30:03FromDiscord<Sebwazhere> for Token on Line 11
18:30:49FromDiscord<awr> use a `let`↵(@michaelb.eth)
18:31:53FromDiscord<awr> you are already in a compile-time context
18:32:56FromDiscord<michaelb.eth> yes, that works, but doesn't meet one of my goals
18:33:05FromDiscord<awr> const is only meaningful for runtime nim because you know it's not being executed at runtime + its in static storage
18:33:28FromDiscord<michaelb.eth> no big deal, though, I can live with it
18:33:29FromDiscord<vmawz> how do you download a file to specific path
18:33:39FromDiscord<awr> not BSS but the other one
18:33:39FromDiscord<awr> data segment
18:34:12FromDiscord<awr> https://nim-lang.org/docs/httpclient.html#downloadFile%2CHttpClient%2C%2Cstring
18:35:01FromDiscord<michaelb.eth> In reply to @awr "const is only meaningful": yes, exactly
18:36:22FromDiscord<michaelb.eth> sent a code paste, see https://play.nim-lang.org/#ix=4yli
18:37:16FromDiscord<Sebwazhere> oh that fixes it, thanks!
18:42:49FromDiscord<vmawz> How do you compile a Nim program so that you can run it without any dlls?
18:42:57FromDiscord<vmawz> Like all you need is the exe.
18:44:58FromDiscord<awr> link with static libs
18:45:16FromDiscord<awr> this depends really on "what are you linking to"
18:46:45*xet7 quit (Read error: Connection reset by peer)
18:47:59FromDiscord<vmawz> Okay actually forget that, when you compile a Nim program is there any information about your machine left on the compiled program?
18:48:11FromDiscord<vmawz> Etc the compilation path
18:49:57FromDiscord<michaelb.eth> try running it through the `strings` command
18:50:30FromDiscord<michaelb.eth> hmm, not sure that's available by default on Windows, but I'm pretty sure it's availble in e.g. an MSYS2 shell
18:53:57FromDiscord<awr> `--listFullPaths:off` might affect this but it should only really affect compiler messages only now↵(@vmawz)
18:55:08FromDiscord<Prestige> Anyone using NiGui know if there's a way to have proportional layouts? Like two components side by side, I want one to take 80% of the space, and the other to take 20%. Without hard-coding sizes
18:56:01FromDiscord<JJ> so i'm putting together a comparison of memory models: what other languages use some form of optimized reference counting?
18:57:05FromDiscord<JJ> so far i have nim, koka, vale, lobster, ocaml, swift (unsure)
19:03:42FromDiscord<Andreas> In reply to @omentic "so i'm putting together": what does "optimized" mean ? put Java on the list. the JVM has some GC-strategies to choose from..
19:10:07FromDiscord<!&luke> How can I use the http client to download multiple files at once
19:12:13FromDiscord<JJ> In reply to @Andreas "what does "optimized" mean": anything other than a naive implementation with no way to elide counts, basically. will do, i was aware the jvm does ridiculous stuff for tracing gcs but i didn't know they messed around with reference counting too
19:19:24FromDiscord<!&luke> How can I concurrently download multiple files from the web in nim
19:30:20FromDiscord<JJ> i believe AsyncHttpClient from std/httpclient should work
19:33:18FromDiscord<!&luke> Do I need to use threads?
19:39:54FromDiscord<spotlightkid> you can, but you don't need to\: https://peterme.net/asynchronous-programming-in-nim.html
19:49:56FromDiscord<awr> https://play.nim-lang.org/#ix=4ylv
19:50:36FromDiscord<awr> ideally you should also close the clients but i was lazy
19:55:01FromDiscord<Chronos [She/Her]> I don't think `nim-lang/redis` supports tls, unless I'm blind
19:58:49FromDiscord<Chronos [She/Her]> Yeah, any idea how I'd use a self-signed cert?
19:59:23FromDiscord<michaelb.eth> In reply to @omentic "so i'm putting together": I think the Janet language uses reference counting for data shared between threads, but I don't know any of the details.
20:00:28FromDiscord<vmawz> My compiled program includes the full internal nim path & leaks my local username, is there an option to remove this or do i need to do it manually?
20:01:50FromDiscord<arkanoid> when creating a lib with custom data containers for custim types, I have to pick an important design decision first\: should I give the user a generic [T] interface (type classes), or should I prefer runtime type wrapper with object variants or similar solution
20:01:51FromDiscord<michaelb.eth> sent a code paste, see https://play.nim-lang.org/#ix=4yly
20:02:34FromDiscord<arkanoid> does this problem have a name, where can I read opinions and pro, cons about this?
20:09:46FromDiscord<michaelb.eth> sent a code paste, see https://play.nim-lang.org/#ix=4ylA
20:10:13FromDiscord<michaelb.eth> sent a code paste, see https://play.nim-lang.org/#ix=4ylB
20:11:31FromDiscord<awr> how would that work even
20:12:04FromDiscord<awr> the compiler wouldn't know if a given enumerator value validates
20:12:53FromDiscord<awr> you can do `when` inside objects though
20:12:59FromDiscord<arkanoid> for example Arraymancer/Datamancer uses compile time typing, while polars (rust) and pandas (python) afaik uses runtime typing.
20:17:55FromDiscord<michaelb.eth> sent a code paste, see https://play.nim-lang.org/#ix=4ylE
20:19:01FromDiscord<michaelb.eth> In reply to @arkanoid "for example Arraymancer/Datamancer uses": the author of Arraymancer recently mentioned some insights he's had about static/dynamic typing, I'll get a link
20:20:17FromDiscord<michaelb.eth> https://forum.nim-lang.org/t/10223#67808
20:28:05NimEventerNew thread by mad_toothbrush: Volatile_store codegen error ?, see https://forum.nim-lang.org/t/10275
20:54:43*def- quit (Server closed connection)
20:54:55*def- joined #nim
21:19:27*greaser|q quit (Changing host)
21:19:27*greaser|q joined #nim
21:19:51*greaser|q is now known as GreaseMonkey
21:26:52FromDiscord<taurusdaemon> Does anyone know if nim code on compiler explorer can be executed?
21:30:28FromDiscord<System64 ~ Flandre Scarlet> Is there a fixed point library for Nim?
21:32:35FromDiscord<mratsim> In reply to @arkanoid "when creating a lib": It's not exactly it but it's somewhat similar to the expression problem
21:34:09FromDiscord<mratsim> In reply to @arkanoid "does this problem have": https://eli.thegreenplace.net/2016/the-expression-problem-and-its-solutions/
21:34:52FromDiscord<mratsim> In reply to @arkanoid "for example Arraymancer/Datamancer uses": You can read my opinion here: https://forum.nim-lang.org/t/10223#67808
21:36:02FromDiscord<mratsim> Basically what do you want to make easy (adding functions,m adding types, extensible without recompiling?)↵And what are dealbreaker, like if you want deserialization with a schema in a json/yaml or another file format, you cannot use generics.
21:47:35FromDiscord<Elegantbeef> @michaelb.eth\: did you get you answer about storing nimnodes outside of macros?
21:55:42FromDiscord<arkanoid> mratsim (Mamy Ratsimbazafy)\: thanks for the answer. I didn't know about the expression problem
21:58:39FromDiscord<michaelb.eth> In reply to @Elegantbeef "<@383034029135364096>\: did you get": Sort of. I know that with `let` I can store a NimNode (that's in a field of an object) outside of a macro. But I was hoping to find a way to use `const`.
21:59:11FromDiscord<Elegantbeef> `var myNode {.compileTime.}: NimNode` is all you really can do
21:59:28FromDiscord<Elegantbeef> Or of course an object with `NimNode`
21:59:49FromDiscord<michaelb.eth> Alright, I'll give that a look.
21:59:51FromDiscord<michaelb.eth> Thanks!
22:00:04FromDiscord<arkanoid> mratsim (Mamy Ratsimbazafy)\: I see you would switch from static type to runtime types for Arraymancer. Out of curiosity, which interface would you give te user for creating Tensor for runtime typing? Would you use object variants like approach?
22:20:15FromDiscord<mratsim> In reply to @arkanoid "mratsim (Mamy Ratsimbazafy)\: I": Probably this: https://github.com/mratsim/trace-of-radiance/blob/master/trace_of_radiance/support/emulate_classes_with_ADTs.nim
22:21:15FromDiscord<mratsim> Tensors are not extended with new types in practice, like maybe brainfloat16
22:22:00FromDiscord<mratsim> Implementation procs would bw generic and wrapped in a object variant dispatch.
23:10:23FromDiscord<michaelb.eth> beef, any thoughts on what I wrote earlier about generics, enum, and object variants? I'm hoping to go from "okay this doesn't work" to understanding properly why it doesn't work
23:17:43FromDiscord<michaelb.eth> nvm, I get it now
23:19:37FromDiscord<Andreas> _Is Option[T] a Functor ?_ https://play.nim-lang.org/#ix=4ylX greeting from QA..
23:20:02FromDiscord<Andreas> (edit) "greeting" => "greetings"
23:30:41FromDiscord<Elegantbeef> @michaelb.eth I'm so good at helping just mentioning me solves problems
23:30:54FromDiscord<michaelb.eth> rubber 🦆