<< 21-07-2023 >>

00:00:02*jmd_ quit (*.net *.split)
00:00:02*zgasma quit (*.net *.split)
00:00:02*pbsds quit (*.net *.split)
00:00:03*Lord_Nightmare quit (*.net *.split)
00:00:03*oddish quit (*.net *.split)
00:00:03*om3ga quit (*.net *.split)
00:00:14*oddish joined #nim
00:02:02*Lord_Nightmare joined #nim
00:03:15*om3ga joined #nim
00:10:17*zgasma joined #nim
00:12:46*jmd_ joined #nim
00:43:55*Jjp137 quit (Ping timeout: 240 seconds)
00:44:43*Jjp137 joined #nim
01:02:14*jmd_ quit (Ping timeout: 260 seconds)
01:36:29*jmd_ joined #nim
02:12:21*rockcavera quit (Remote host closed the connection)
02:35:06*xet7 joined #nim
03:40:05NimEventerNew Nimble package! clibard - Command line interface for Google Bard, see https://github.com/thisago/clibard
04:52:09FromDiscord<terrygillis> does nim have something similar to wrapper classes in java?
04:53:21FromDiscord<terrygillis> types Integer, Boolean etc. for primitives int, bool accordingly
04:53:37FromDiscord<Elegantbeef> It doesnt need them so nope
04:54:54FromDiscord<terrygillis> i making something like a table, and if the key doesn’t exist the value returned is nil
04:55:01FromDiscord<terrygillis> but this would work for primitives
04:55:10FromDiscord<Elegantbeef> `import std/options`
04:55:46FromDiscord<terrygillis> ah thanks
05:02:08FromDiscord<terrygillis> actually another case\: a generic priority queue PQ[T], the deleteMax() function would set the last item in the internal seq to nil (internalSeq[size] = nil) after it has been deleted (possibly to be garbage collected), but doing so isn’t possible if it’s PQ[int] because the internal is seq[int]. Is it possible to write object using generics without having to write separately for cases with primitive types?
05:02:51FromDiscord<Elegantbeef> `reset internelSeq[size]`
05:03:07FromDiscord<Elegantbeef> or `internalSeq[size] = default(T)` where `T` is your generic parameter
05:03:56FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4B5T
05:04:16FromDiscord<Elegantbeef> But that's a micro optimisation
05:04:32FromDiscord<terrygillis> thanks very much
05:05:33FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/tIrCi
05:05:59FromDiscord<Elegantbeef> This way complex types such as objects are 0'd incase their fields have GC'd memory
05:06:04FromDiscord<Elegantbeef> Typetraits is really missing a `hasGcedMemory`
05:28:23FromDiscord<enthus1ast> I share a mmap between two processes (on linux). What do you think is a good way to syncronize access to this shared memory? I was looking into semaphores, but i found them actually quite unreliable (the processes have to remove the file on exit, the counting up and down is quite confusing to be honest...) Can i use the mmap itself to lock access? ↵Could i use a process shared mutex? Could i even use a mutex that is initialized on th
05:34:48FromDiscord<Elegantbeef> Could you not use Nim's destructors to get around the having to remove the file, and solve the counting up/down?
05:40:25FromDiscord<enthus1ast> i tried with ctrl c exit hook but it somehow was not working, no idea why (yet)
05:41:27FromDiscord<enthus1ast> and when i killed the processes randomly, and restarted them, i got a deadlock
05:41:40FromDiscord<enthus1ast> so they work but its a little naah
05:42:08FromDiscord<Elegantbeef> It does seem there is a 'unamed semaphore'
05:43:03FromDiscord<enthus1ast> yeah but this is afaik for inter thread
05:43:14FromDiscord<enthus1ast> idk i could do this on the mmap
05:43:42FromDiscord<enthus1ast> but the mmap i have to call sync on and this also sounds a little wonky to be honest
05:43:53FromDiscord<Elegantbeef> Are you using the mmap for IPC?
05:44:00FromDiscord<enthus1ast> yes
05:44:26FromDiscord<Elegantbeef> I personally go for sockets for IPC
05:44:50FromDiscord<Elegantbeef> Unless you need the data shared and persistent of course
05:44:50FromDiscord<enthus1ast> yeah this is what i currently do
05:45:08FromDiscord<enthus1ast> but i wanted to explore more options
05:45:20FromDiscord<enthus1ast> the good thing about the mmap is, that it also gives me persitence
05:45:45FromDiscord<enthus1ast> persistence
05:46:00FromDiscord<Elegantbeef> Well I'd setup destructors for the semaphores and ensure you do not have `quit` in your program, then there's an issue of when you terminate the process
05:46:22FromDiscord<Elegantbeef> The terminating of the process is an odd thing to resolve I guess
05:47:29FromDiscord<Elegantbeef> I guess you could add a signal handle for terminate
05:47:33FromDiscord<Elegantbeef> handler\
05:48:39FromDiscord<enthus1ast> it seems weird that the (potential dying) process itself must do os level cleanup
05:49:16FromDiscord<enthus1ast> sockets are much better suited for this acutally
05:49:36FromDiscord<Elegantbeef> Well given the point of a semaphore there isnt really a good way to get rid of it
05:50:45FromDiscord<Elegantbeef> If you think about it a program could setup a semaphore to use in other programs that open and close from any number of other processes. So the OS doesnt really know when to get rid of it
05:51:29FromDiscord<enthus1ast> i basically have 1 + n processes, one process is the service that is a daemon on top of some kind of datastore, then i have clients that query (and also maybe fill) the data↵in essence this should be a new "locate"
05:51:50FromDiscord<enthus1ast> but with the difference that the data is updated live
05:52:07FromDiscord<Elegantbeef> Yea sounds like a producer/consumer setup
05:53:56FromDiscord<enthus1ast> currently my testing client looks like this \:)vim `ncat 127.0.0.1 4445 | fzf`
05:54:05FromDiscord<enthus1ast> \`\`\`vim \`ncat 127.0.0.1 4445 \| fzf\`\`\`\`
05:54:15FromDiscord<enthus1ast> ugh, you get it i guess
05:55:38NimEventerNew question by Emilia Qtless: Translation in Happyx, see https://stackoverflow.com/questions/76735435/translation-in-happyx
05:57:49FromDiscord<enthus1ast> to initially fill the locate db i can do this for now\: find /home/ \| socat stdin tcp-connect\:127.0.0.1\:4444
05:58:47FromDiscord<enthus1ast> then currently the daemon listens to fanotify callbacks to keep the index fresh
05:59:28FromDiscord<enthus1ast> for now the newly found data is not streamed to the fzf client, but on a new call its there
06:00:33FromDiscord<enthus1ast> fanotify works recursive for the whole filesystem(s) and its quite fast
06:03:12FromDiscord<Elegantbeef> I'm still reading about the semaphore api myself, seems not too bad assuming you have proper error handling implemented
06:04:28FromDiscord<Elegantbeef> Spawning process destroys the semaphore, then opens it again. Handle errors in children processes by decrementing the semaphore if they do not properly exit. Child processes watch the correct signals and decrement the semaphore.
06:04:50FromDiscord<Elegantbeef> With destructors and using Nim's `guard` annotation could have a nifty system
06:08:27FromDiscord<Elegantbeef> Yea there's a `unhandledExceptionHook` you can use
06:08:39FromDiscord<Elegantbeef> So in theory this shouldnt be too bad to handle
06:08:50FromDiscord<enthus1ast> guard annotation?
06:09:15FromDiscord<Elegantbeef> It's a pragma you can use to make a variable require a `{.locks: [lockName].}: code here`
06:09:20FromDiscord<Elegantbeef> Generally used for multi threading
06:09:46FromDiscord<enthus1ast> ah
06:09:59FromDiscord<enthus1ast> https://nim-lang.org/docs/manual_experimental.html#guards-and-locks-guards-and-the-locks-section
06:10:15FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4B63
06:12:40FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/XhFu5
06:12:43FromDiscord<Elegantbeef> And like that you've now made it relatively safe 😄
06:13:38FromDiscord<Elegantbeef> Your daemon would inside of it's exit procs likely should kill all the children processes and destroy the semaphore
06:14:11FromDiscord<enthus1ast> there are no childs on the classical sense
06:14:19FromDiscord<enthus1ast> so they're not started by the daemon
06:14:38FromDiscord<enthus1ast> but by the user(s) that use the daemon in from a shell command
06:15:06FromDiscord<Elegantbeef> Ah that's a slight issue of course
06:15:50FromDiscord<Elegantbeef> Hopefully this gives you ideas for semaphores if you want to continue using them and I'm not avoiding being productive for nothing 😛
06:16:03FromDiscord<enthus1ast> haha
06:16:54FromDiscord<enthus1ast> yes i still consider them, sharing memory would be the fastest way of access and it would be nice if the tool i build is fast
06:17:15FromDiscord<Elegantbeef> oh nice semaphores are actually wrapped in the stdlib's posix module
06:17:24FromDiscord<enthus1ast> yes
07:11:09*ntat joined #nim
07:49:29*azimut joined #nim
07:58:26FromDiscord<youssefbs> sent a code paste, see https://play.nim-lang.org/#ix=4B6e
08:00:38FromDiscord<demotomohiro> It become compile error if `const index = 2` instead of `var index = 2`.
08:01:30FromDiscord<Elegantbeef> Nim does not do value narrowing so it's a runtime error only
08:06:17FromDiscord<youssefbs> am testing the safety of the language's memory management for embedded systems. I want to make sure if it's possible to get an error at compile time using the keyword `var`
08:08:16FromDiscord<youssefbs> Is there a website where I can find the best practices for coding with Nim to help avoid making errors ?
08:09:17FromDiscord<ringabout> In reply to @youssefbs "am testing the safety": There is an article comparing Nim's safety with other languages => https://uploads.peterme.net/nimsafe.html
08:11:22FromDiscord<ringabout> In reply to @youssefbs "Is there a website": Firstly you can read the official guides. And https://status-im.github.io/nim-style-guide/ provides some maybe-useful advice.
08:12:02FromDiscord<youssefbs> Thanks
09:10:36*ntat quit (Quit: leaving)
09:23:19FromDiscord<bung8954> sent a code paste, see https://play.nim-lang.org/#ix=
09:23:25FromDiscord<bung8954> sent a long message, see http://ix.io/4B6n
09:24:53NimEventerNew post on r/nim by qtless: Extended Request Models In HappyX, see https://reddit.com/r/nim/comments/155ivac/extended_request_models_in_happyx/
09:38:07FromDiscord<bung8954> why conflict? the proc defined as `proc sel_registerName(str: cstring): SEL {.cdecl, importc.}`
09:39:16FromDiscord<jmgomez> try using `nodecl`
09:45:32FromDiscord<bung8954> it causes -Wimplicit-function-declaration
09:48:23FromDiscord<jmgomez> is `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/objc.h:` included where it causes it?
09:51:52FromDiscord<bung8954> the proc pragma have used three versions `cdecl, importc` , `cdecl` , `{.pragma: objcimport, cdecl, importc, dynlib: OBJC_LIB_NAME.}` https://github.com/bung87/objc_runtime/blob/548b33470c7c865278ed8d7116fbce4083bbbccf/src/objc_runtime.nim
09:52:50FromDiscord<bung8954> (edit) "`cdecl, importc`" => "`{cdecl}`, `{importc" | "`cdecl`" => "cdecl}`"
09:54:24FromDiscord<bung8954> well, I manually run my program during changes dependencies, confirm that works, now come to this error, dont know what's the cause
09:55:34FromDiscord<bung8954> if I dont explicitly use dynlib, it linked by `{.passL: "-framework Foundation".}` right ?
09:58:37FromDiscord<bung8954> In reply to @jmgomez "is `/Applications/Xcode.app/Contents/Developer/Plat": it should included, it's mapping to the c function
10:05:19FromDiscord<demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4B6r
10:07:11*sagax quit (Ping timeout: 264 seconds)
10:18:16FromDiscord<bung8954> i think it's just name conflict
10:20:20FromDiscord<bung8954> weird thing is my library main program runs fine, when it used in other program face this error
10:29:40FromDiscord<bung8954> I remove `passc: "-DOBJC_OLD_DISPATCH_PROTOTYPES=1 -x objective-c"` now works, previousely it works fine on my intel MBP
11:23:40*anotherfhp joined #nim
11:23:50*MightyJoe quit (Ping timeout: 260 seconds)
11:24:08*cyraxjoe joined #nim
11:38:04*anotherfhp quit (Quit: Leaving)
12:29:55*anotherfhp joined #nim
12:31:50*anotherfhp quit (Client Quit)
12:48:46*lucasta joined #nim
13:38:29FromDiscord<gogolxdong666> Why does parseJson {"ConfigureMsgRecive":"1"} result in{"ConfigureMsgRecive":"{"}
13:38:44FromDiscord<gogolxdong666> (edit) "{"ConfigureMsgRecive":"1"}" => "`{"ConfigureMsgRecive":"1"}`" | "in{"ConfigureMsgRecive":"{"}" => "in `{"ConfigureMsgRecive":"{"}`"
13:38:46*jmd_ quit (Ping timeout: 245 seconds)
13:43:28FromDiscord<Andreas> In reply to @gogolxdong666 "Why does parseJson `{"ConfigureMsgRecive":"1"}`": try `parseJson "{\"ConfigureMsgRecive\":1}"` - works for me..
13:47:13FromDiscord<gogolxdong666> runes:{"ConfigureMsgRecive":"1"} string:{"ConfigureMsgRecive":"1"} json:{"ConfigureMsgRecive":"{"}
13:47:40FromDiscord<gogolxdong666> sent a code paste, see https://paste.rs/BVrLT
13:48:30FromDiscord<gogolxdong666> var res = waitFor response.getBodyBytes()↵var runes = toRunes cast[seq[char]](res)↵var str = cast[string](res)↵echo "runes:", runes," ", runes.len , " string:", str , " json:", parseJson str
14:01:09FromDiscord<Andreas> sent a code paste, see https://play.nim-lang.org/#ix=4B71
14:01:57FromDiscord<Andreas> (edit)
14:08:13FromDiscord<nnsee> sent a code paste, see https://play.nim-lang.org/#ix=4B75
14:13:23FromDiscord<gogolxdong666> `proc getBodyBytes(response: HttpClientResponseRef): Future[seq[byte]] {.async.}`
14:17:13FromDiscord<gogolxdong666> I want parseJson returns {"ConfigureMsgRecive":"1"}
14:21:59FromDiscord<Andreas> In reply to @gogolxdong666 "I want parseJson returns": and what type is ` {"ConfigureMsgRecive":"1"}` supposed to be ? a `string` or `tuple` or `JsonNode`? because itseems to be a `array[1, tuple(string, string)]` ?
14:23:12FromDiscord<gogolxdong666> means quote the string manually to have it parsed by json?
14:24:55FromDiscord<nervecenter> sent a code paste, see https://play.nim-lang.org/#ix=4B78
14:29:15FromDiscord<nervecenter> sent a code paste, see https://play.nim-lang.org/#ix=4B79
14:30:28FromDiscord<bostonboston> `high(float) ` should return inf correct?
14:30:53FromDiscord<demotomohiro> !eval echo float.high
14:30:58NimBotinf
14:31:21FromDiscord<griffith1deadly> in latest devel same
14:31:51FromDiscord<bostonboston> is there also a function that will return the highest real number a float can represent
14:32:54FromDiscord<Andreas> @gogolxdong666 Is this `{"ConfigureMsgRecive":"{"}` the `Future[ seq[byte] ]` from your response ? if so, then its incomplete or broken ..
14:33:28FromDiscord<Andreas> (edit) "@gogolxdong666 Is this `{"ConfigureMsgRecive":"{"}` the `Future[ seq[byte] ]` from your response ? if so, then its incomplete or broken .. ... " added "you cannot parse this to JSON."
14:34:39FromDiscord<gogolxdong666> response is {"ConfigureMsgRecive":"1"}
14:35:33FromDiscord<gogolxdong666> var res = waitFor response.getBodyBytes()↵ var str = cast[string](res)↵ var escaped = strutils.escape str↵ echo parseJson escaped
14:35:47FromDiscord<gogolxdong666> (edit) "response.getBodyBytes()↵ var" => "response.getBodyBytes()↵var" | "cast[string](res)↵ var" => "cast[string](res)↵var" | "str↵ echo" => "str↵echo"
14:36:15FromDiscord<gogolxdong666> "{\"ConfigureMsgRecive\":\"1\"}"↵"{\"ConfigureMsgRgRgRgRgRgRg"
14:36:42FromDiscord<gogolxdong666> (edit) "var res = waitFor response.getBodyBytes()↵var str = cast[string](res)↵var escaped = strutils.escape str↵echo parseJson escaped" => "sent a long message, see http://ix.io/4B7a"
14:37:07FromDiscord<gogolxdong666> https://media.discordapp.net/attachments/371759389889003532/1131958038996197416/image.png
14:42:38FromDiscord<Andreas> sent a code paste, see https://play.nim-lang.org/#ix=4B7d
14:43:34FromDiscord<michaelb.eth> `let str = string.fromBytes res`
14:44:17FromDiscord<michaelb.eth> I’m not sure cast is a good idea for getting the string from the bytes
14:44:32FromDiscord<Andreas> (edit) "https://play.nim-lang.org/#ix=4B7d" => "https://play.nim-lang.org/#ix=4B7f"
14:45:18FromDiscord<Andreas> In reply to @michaelb.eth "I’m not sure cast": true, casting is never a good idea 🙂
14:50:10FromDiscord<gogolxdong666> Is there such a proc fromBytes
14:50:17FromDiscord<gogolxdong666> (edit) "fromBytes" => "string.fromBytes"
14:58:49FromDiscord<terrygillis> sent a code paste, see https://play.nim-lang.org/#ix=4B7j
14:59:29FromDiscord<michaelb.eth> In reply to @gogolxdong666 "Is there such a": stew/byteutils
15:00:24*rockcavera joined #nim
15:01:05FromDiscord<michaelb.eth> https://github.com/status-im/nim-stew/blob/master/stew/byteutils.nim#L256-L263
15:02:33FromDiscord<terrygillis> I tried `var i = 1` and `demo(i)` would work but is there some way to pass in without assigning to a variable?
15:05:06FromDiscord<gogolxdong666> the same
15:08:11FromDiscord<demotomohiro> @terrygillis using var parameter means you can modify the argument and caller can get a written value.↵Passing a literal value to var parameter doesn't make much sense.
15:10:30FromDiscord<terrygillis> what if i still want to use that func to modify the arguments for other cases but just in this particular one i just want to conveniently pass in the literal. Is there a way around this? What is the idiomatic way in Nim for this case?
15:11:50FromDiscord<bostonboston> It it's just this one time I would declare the var
15:11:58FromDiscord<gogolxdong666> sent a code paste, see https://play.nim-lang.org/#ix=4B7o
15:18:08FromDiscord<Andreas> sent a code paste, see https://play.nim-lang.org/#ix=4B7r
15:18:50FromDiscord<demotomohiro> @terrygillis Use a temporary variable or create a overloaded proc:↵https://nim-lang.github.io/Nim/manual.html#overload-resolution-overloading-based-on-var-t
15:20:02FromDiscord<bostonboston> ^
15:20:23FromDiscord<gogolxdong666> https://media.discordapp.net/attachments/371759389889003532/1131968918630715472/image.png
15:32:31FromDiscord<terrygillis> sent a code paste, see https://play.nim-lang.org/#ix=4B7t
15:33:19FromDiscord<terrygillis> idk if it's just me but this does not seem very elegant or am I getting anything wrong?
15:45:04FromDiscord<demotomohiro> var parameter is used for return value to caller and not used for just modifying parameter.↵In Nim, parameter is immutable in default.↵Parameter is usually doesn't need to be modified and modifying it makes code less readable in large code.↵If you need a new value from the parameter, just create a new local variable.
15:45:48FromDiscord<demotomohiro> In rust, variables are immutable in default.
15:52:49FromDiscord<michaelb.eth> In reply to @terrygillis "idk if it's just": it’s helping you by insisting that you think more clearly about the footguns you’re carrying around
15:56:27FromDiscord<michaelb.eth> mutable state being the root of all evil, and all that
15:56:53FromDiscord<terrygillis> sent a code paste, see https://paste.rs/8Cl05
15:57:26FromDiscord<bostonboston> If I have a tuple `foo = (seq[T], seq[T])` can I do something like `for x, y in foo`
15:57:27FromDiscord<terrygillis> Mind, I'm a beginner to both Rust and Nim.
15:58:10FromDiscord<bostonboston> (edit) "foo`" => "foo:`"
16:04:10*ntat joined #nim
16:06:23FromDiscord<bostonboston> Or is `for bar in zip(foo[0], foo[1]):` my best option
16:21:05FromDiscord<arathanis> im seeing you can define tasks in `config.nims`. is there a way to invoke them without using nimble?
16:30:20FromDiscord<mohamed> is there any way to build nim sdl for android
16:38:23FromDiscord<terrygillis> After searching for a while, I came across something that mentions ‘sink’ which seems to solve my problem instead of ‘var’. But the docs and examples I found are pretty sparse. It seems new and not fully documented yet.
16:38:52FromDiscord<arathanis> In reply to @terrygillis "After searching for a": what is it you are trying to accomplish exactly?
16:43:49FromDiscord<demotomohiro> @terrygillis sink is not for modifying parameter.
16:44:04FromDiscord<ambient3332> sent a code paste, see https://paste.rs/Vv9Pd
16:45:15FromDiscord<arathanis> i agree w/ you @ambient3332
16:45:40FromDiscord<arathanis> in nim, `var` is indicating you intend for any mutations on this variable to exit the scope of the function call as well
16:45:45FromDiscord<arathanis> doesn't make sense to call it on a constant
16:46:27FromDiscord<arathanis> i think they want to use the incoming number in a mutable way, even if it is an int-lit? I don't think it works that way though. id argue the design needs to be adjusted
16:46:56FromDiscord<ambient3332> Even the Rust function doesn't actually return the mutated value, but creates another one
16:47:17FromDiscord<ambient3332> ...in the return field
16:47:23*lucasta quit (Quit: Leaving)
16:47:30FromDiscord<arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4B81
16:47:33FromDiscord<terrygillis> I just want to pass in a value that is to be modified inside the function but produces no side effects for the outside variable passed in. But doing ‘proc demo(a\: int)’ would require a reassignment ‘var a = a’ inside, which is pretty ugly.
16:47:34FromDiscord<arathanis> then they can mutate it further to their heart's content
16:47:46FromDiscord<arathanis> In reply to @terrygillis "I just want to": use my example
16:50:26FromDiscord<terrygillis> I mean for example ‘proc demo(a, b, c\: int)’ and I want to mutate a, b, c within the proc only without declaring any other variables both inside and outside of proc (passed by value)
16:51:14FromDiscord<arathanis> what is the algorithm in question?
16:51:39FromDiscord<ambient3332> var ta, tb, tc = a, c, b etc
16:52:05FromDiscord<ambient3332> playing tricks with the function signature is a good way to shoot yourself in the foot
16:53:07FromDiscord<arathanis> id like to see what the alg. is and what kind of mutations are necessary for executing the function
16:53:12*jmdaemon joined #nim
16:54:03FromDiscord<terrygillis> yeah i think that’s the reassignment i’m talking about and it’s pretty tiring and unnecessary and ugly, that’s what i tried to say. ‘sink’ seems to be the solution but the docs is almost non-existent and it doesn’t seem to be used anywhere.↵(@ambient3332)
16:54:36FromDiscord<ambient3332> You're worrying about side effects, yet are very happy to push side effect window out of the inside of the function ...
16:56:00FromDiscord<ambient3332> Especially talking about Rust, where things are immutable on default and the entire language is very explicit about mutation, memory and state
16:57:12FromDiscord<ambient3332> (edit) "on" => "by"
16:58:04FromDiscord<terrygillis> yes but rust doesn’t require redeclaring ‘let a = a’ if the parameter is clearly marked with “mut”
16:58:34FromDiscord<arathanis> what are you doing that requires mutating the parameters of the procedure without exposing those mutations outside the procedure call?
17:00:44FromDiscord<demotomohiro> @terrygillis here is document about sink:↵https://nim-lang.github.io/Nim/destructors.html
17:01:31FromDiscord<terrygillis> it’s not something really significant really, it’s just i find it tiring having to reassigning parameters or declaring new local variables that are the same as parameters that I don’t really need to keep inside the proc just for local mutations again and again
17:01:36FromDiscord<ambient3332> sent a code paste, see https://play.nim-lang.org/#ix=4B86
17:02:25FromDiscord<terrygillis> yes but you still have to declare ‘var foo = 5’ outside even though it’s not needed↵(@ambient3332)
17:02:38FromDiscord<ambient3332> In reply to @terrygillis "yes but you still": You can't mutate a variable that does not exist
17:03:00FromDiscord<terrygillis> passing in a literal 5 is not allowed
17:03:00FromDiscord<terrygillis> in rust passing in a literal 5 can work just fine
17:03:17FromDiscord<terrygillis> even if it’s marked mut
17:04:23FromDiscord<ambient3332> True, but I don't know why it does that. 1 is constant and can't be mutated
17:05:43FromDiscord<demotomohiro> I think mut in your Rust code only allow modifying parameter but it doesn't modifying the given argument.
17:06:33FromDiscord<ambient3332> Implicit conversion is something I didn't expect Rust would be doing here
17:06:47FromDiscord<terrygillis> It’s just a really minor thing that saves some time of not having to reassign or create new variables.
17:06:54FromDiscord<terrygillis> “If it cannot be proven to be the last usage of the location, a copy is done instead and this copy is then passed to the sink parameter.”
17:07:24FromDiscord<terrygillis> yes sink seems to be the right use case for this but nobody is using it, aren’t they?
17:08:24FromDiscord<terrygillis> can i try this on the nim playground yet or is it only in devel?
17:08:30FromDiscord<nervecenter> Passing a mutable reference into a new context is not a "minor thing"
17:08:34FromDiscord<nervecenter> That's a footgun ready to blow
17:10:56FromDiscord<demotomohiro> Rust's mut parameter is different from Nim's var parameter:↵https://wandbox.org/permlink/UHLEn7iY91Uv8Tr2↵Rusts mut parameter doesn't modify given variable.
17:11:15FromDiscord<nervecenter> So it creates a new, mutable copy?
17:11:27FromDiscord<arathanis> in rust i think the equivalent to Nim's `var` is `mut&` for mutable reference?
17:11:31FromDiscord<arathanis> In reply to @nervecenter "So it creates a": yes
17:11:45FromDiscord<arathanis> rust lets you mark a function parameter as mutable but still scoped to the function
17:12:04FromDiscord<nervecenter> That is very...subtle
17:13:25FromDiscord<terrygillis> and ‘sink’ maybe nim’s equivalent to that↵(@arathanis)
17:13:27FromDiscord<arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4B8a
17:13:47FromDiscord<arathanis> In reply to @terrygillis "and ‘sink’ maybe nim’s": sink is just a fun way of making surprise copies 😎
17:14:05FromDiscord<demotomohiro> In reply to @terrygillis "“If it cannot be": sink and move are created to avoid copying large memory. Not equivalent to mut in Rust.
17:14:20FromDiscord<ambient3332> Only use I've had for sink is making sure there's no copy
17:14:36FromDiscord<arathanis> i honestly dont find myself writing functions that need to mutate their parameters unless i need the mutation to be visible outside the function
17:14:57FromDiscord<ambient3332> In reply to @arathanis "i honestly dont find": Arrays are one obvious usecase
17:16:56FromDiscord<demotomohiro> Modifying a parameter looks like reusing a variable for different things.↵Copying a parameter to a new local variable looks better for me.
17:18:53FromDiscord<terrygillis> but doing it over and over again for parameters that I don’t need to keep inside the the proc can get tiring for me quickly↵(@demotomohiro)
17:19:39FromDiscord<ambient3332> In reply to @terrygillis "but doing it over": I don't know what kind of code you write but this was never an issue for me
17:19:39FromDiscord<arathanis> sink is probably not what you want, redesigning what you are trying to do might be the way
17:21:28FromDiscord<sreagle> In reply to @arathanis "i honestly dont find": That's exactly what I'm thinking the whole time - what use case is there, were I need to mutate a parameter _without_ the outside seeing it? Maybe terrygilles wants more like automatic copies for all the input params, so they don't need to declare them manually to play around? Well, I prefer control over what I want created instead, even if I have to type a little more... Just my 2 cents!
17:22:30FromDiscord<demotomohiro> It seems you can use sink parameter like Rust's mut parameter:↵https://play.nim-lang.org/#ix=4B8d
17:23:36FromDiscord<terrygillis> yeah maybe it’s just me being a bit too lazy \:))↵(@sreagle)
17:23:43*junaid_ joined #nim
17:24:38FromDiscord<arathanis> also unless something has changed, sink will make surprise copies
17:24:43FromDiscord<arathanis> so probably dont do that
17:24:53FromDiscord<arathanis> its a bit of footgun
17:24:56FromDiscord<arathanis> a foot supersoaker
17:25:19FromDiscord<arathanis> In reply to @sreagle "That's exactly what I'm": im wth you, this waas exactly my thoughts
17:25:23FromDiscord<arathanis> (edit) "wth" => "with"
17:27:55FromDiscord<terrygillis> also sometimes i find naming things a bit hard. what would be your renaming scheme for these cases. e.g the parameters are (a, size, tree) what name would you use when redeclared inside the body of the proc?
17:28:20FromDiscord<arathanis> can you give an example of the procedure and what it does to help us think about naming?
17:28:39FromDiscord<terrygillis> renaming things as is (reassigning) makes code look weird though
17:28:50FromDiscord<terrygillis> i mean in the case presented above
17:29:03FromDiscord<terrygillis> redeclaring to mutate locally
17:29:12FromDiscord<ambient3332> I don't think it's common to mutate integers from function parameters
17:32:00FromDiscord<terrygillis> like in the signature there’s (time\: string, size\: int) and in the body name it mutatedTime and mutatedSize?
17:32:44FromDiscord<ambient3332> You would have to give a full example to have any clarity on this, I think
17:33:25FromDiscord<ambient3332> A piece of code that actually does something
17:34:21FromDiscord<michaelb.eth> In reply to @terrygillis "it’s not something really": shadowing declarations is "the way" in Nim if you want to change the arguments being passed, but with the mutation not exposed outside the proc's/func's scope, and you want to use the same name/s
17:35:33FromDiscord<michaelb.eth> sent a code paste, see https://play.nim-lang.org/#ix=4B8g
17:36:20FromDiscord<michaelb.eth> only use a `var` parameter if the mutation must be exposed outside of the proc's scope
17:37:04FromDiscord<terrygillis> yeah i’m a bit lazy and find that tiring so i started this long insignificant conversation. have to get used to it then↵(@michaelb.eth)
17:38:14*zaher joined #nim
17:42:42FromDiscord<that_dude.> sent a code paste, see https://play.nim-lang.org/#ix=4B8l
17:43:50FromDiscord<that_dude.> ah I think it's the other way around
18:12:00FromDiscord<0xrh0d4m1n> guys, how could be a good way to manage `user-defined` types? I mean, when you have an application with hundreds of modules, and it start to get hard to manage the types... any tips?
18:16:16*cyraxjoe quit (Ping timeout: 245 seconds)
18:16:50*cyraxjoe joined #nim
18:25:01*cyraxjoe quit (Ping timeout: 245 seconds)
18:25:15FromDiscord<ambient3332> sent a code paste, see https://play.nim-lang.org/#ix=4B8u
18:25:26FromDiscord<ambient3332> (edit) "https://play.nim-lang.org/#ix=4B8u" => "https://play.nim-lang.org/#ix=4B8v"
18:27:21FromDiscord<0xrh0d4m1n> macro + varargs cool, thx for the tip
18:29:45*cyraxjoe joined #nim
18:36:37FromDiscord<takemichihanagaki3129> In reply to @ambient3332 "Well I did "lazyvars"": First time hearing about lazy vars, what are them and what's the usage?↵I'm curious now. 😅
18:36:59FromDiscord<takemichihanagaki3129> (edit) "what's" => "what're" | "usage?↵I'm" => "usages?↵I'm"
18:37:21FromDiscord<ambient3332> sent a code paste, see https://play.nim-lang.org/#ix=4B8y
18:37:51FromDiscord<takemichihanagaki3129> In reply to @ambient3332 "A really dumb way": I see.
18:38:43FromDiscord<takemichihanagaki3129> It's pretty useful if your parameters are constants...
18:39:01FromDiscord<djazz> why does it work? arent they already declared?
18:39:32FromDiscord<ambient3332> it creates new local variables from the constants in the function signature
18:39:32FromDiscord<djazz> have I been doing var x2 = x all in vain? XD
18:44:59FromDiscord<exelotl> yep xD
19:45:08*oisota5 joined #nim
19:45:59*xet7 quit (Read error: Connection reset by peer)
19:46:09*hexeme_ joined #nim
19:49:03*ntat quit (Quit: leaving)
19:49:31FromDiscord<ambient3332> Anyone care to explain what the hell this is? https://github.com/nim-lang/Nim/blob/devel/lib/core/macros.nim#L1571 (customPragmaNode)
19:51:46ehmryambient3332:­ that is for attaching pragma annotations to stuff like types
19:52:21FromDiscord<ambient3332> I guess I'm not supposed to understand it
19:52:46ehmryyou want an example?
19:53:47FromDiscord<ambient3332> Well I'm trying to make a custom pragma which attaches a piece of AST into the start of the function. Where the custom code is made according to the function signature, I just thought it would be something that would help me do that
19:54:14*henrytill quit (*.net *.split)
19:54:15*oisota quit (*.net *.split)
19:54:15*hexeme quit (*.net *.split)
19:54:15*oisota5 is now known as oisota
19:57:48ehmrythat would be useful if you are defining a function/proc and then passing it through a macro that would check for the presence of a custom pragma
20:01:50*henrytill joined #nim
20:02:15FromDiscord<Elegantbeef> The most common use case is serialisation in my experience
20:02:21ehmryright
20:02:32FromDiscord<Elegantbeef> Mark a field `{.unserialised.}` or do `{.jsonName: "bleh".}`
20:02:56*xet7 joined #nim
20:19:10FromDiscord<ambient3332> sent a code paste, see https://play.nim-lang.org/#ix=4B98
20:46:00NimEventerNew post on r/nim by Robert_Bobbinson: Default Trait Implementation in Nim? [Rust related], see https://reddit.com/r/nim/comments/155znb1/default_trait_implementation_in_nim_rust_related/
20:48:46FromDiscord<voidwalker> how does choosenim work with nimble pkginstalls between different versions ? I notice I can use the pkg I installed on -devel with stable, even though it is only in the pkgs2 folder. If I install the pkg again while on nim stable, it will use that version instead ?
20:50:35FromDiscord<Elegantbeef> Nimble is how it works
20:50:45FromDiscord<Elegantbeef> Nimble 0.13 should not use pkgs2 but nimble 0.14 should
20:50:50FromDiscord<Elegantbeef> Nimble 0.14 is used in devel+
20:51:12FromDiscord<voidwalker> Also, trying to use this lib: https://github.com/juancarlospaco/nim-openstreetmap/blob/6979215809e0959e02c2e4311cd1616cc6974190/src/openstreetmap.nim#L69C12-L69C12 - loadXML from xmlparser module expects a file path, not the xml string. Can't believe they would have release a non working version, so maybe I need loadXML from someplace else ?
20:51:59FromDiscord<voidwalker> yikes, so what happens if I use them both ?
20:53:05FromDiscord<Elegantbeef> Nimble 0.14 I think looks in pkgs2 then pkgs1
20:53:34FromDiscord<voidwalker> oh, then I should be safe with both
20:56:12FromDiscord<voidwalker> sent a code paste, see https://paste.rs/sB241
20:56:16FromDiscord<voidwalker> why does it go to nim-1.6.14 folder at the end ? :\
20:56:27FromDiscord<voidwalker> ah nevermind
20:56:46FromDiscord<voidwalker> I had the 1.6.14 file opened
20:57:51FromDiscord<voidwalker> Anyways, any clue what's up with that openstreetmap lib ?
20:57:55FromDiscord<voidwalker> @juan_carlos maybe ? : )
21:00:27FromDiscord<Elegantbeef> It was modified 4 years ago, perhaps it used to return a xml in the response body
21:01:15FromDiscord<Elegantbeef> Wait I'm daft
21:01:36FromDiscord<Elegantbeef> 4 years ago would've been right before 1.0 so `loadXml` certainly took a filepath back then aswell
21:04:05FromDiscord<voidwalker> strange, that first time I installed it, it asked me for some packages like xmldom/xmldomparser ? i installed those and I got it working, but then I was confused about everything, so I nuked the .nimble folder and started from scratch, now I get this
21:04:52FromDiscord<voidwalker> last update is from 2022, i installed it with @#head
21:05:13FromDiscord<voidwalker> oh, in 2022 they added donation info lol
21:07:34FromDiscord<voidwalker> https://github.com/nim-lang/graveyard/blob/cca4055a063e2469de820495ec403a0c11ba837f/xmldomparser/src/xmldomparser.nim#L142
21:08:04FromDiscord<voidwalker> yeah I think it got it from here, no idea what triggered the missing xmldomparser notification, I don't get it now
21:08:32FromDiscord<Elegantbeef> Nimble is a fantastic package manager 😛
21:09:22FromDiscord<voidwalker> it's almost fine
21:10:15FromDiscord<voidwalker> I just wanted to see what kind of data you get from openstreetmap, I will try to use the other readonly API, I don't want to edit osm data anyway
21:10:38FromDiscord<voidwalker> can't imagine how you would do that programatically?
21:11:10FromDiscord<Elegantbeef> No clue
21:31:55FromDiscord<JJ> oh hey, i was reading through it and just noticed that nim made the stack overflow survey this year!
21:31:56FromDiscord<JJ> https://survey.stackoverflow.co/2023/
21:32:26FromDiscord<JJ> i think this is its first year
21:46:16*junaid_ quit (Remote host closed the connection)
21:49:42FromDiscord<Elegantbeef> I believe you're right
21:49:52FromDiscord<Elegantbeef> It's all downhill from here
22:01:35*zgasma quit (Quit: leaving)
22:18:04NimEventerNew question by epilif3sotnas: What is the equivalent of Java&#39;s protected attributes in Nim?, see https://stackoverflow.com/questions/76741539/what-is-the-equivalent-of-javas-protected-attributes-in-nim
22:38:11FromDiscord<uninnocent> how do I read and set file icons in nim?
22:40:14FromDiscord<Elegantbeef> Assuming you mean giving the ".exe" an icon on windows, you fight with vcc
22:40:29FromDiscord<Elegantbeef> Guess you can use mingw aswell
22:41:29FromDiscord<Elegantbeef> https://stackoverflow.com/a/708382/15200657
22:46:30FromDiscord<uninnocent> In reply to @Elegantbeef "Assuming you mean giving": yeah
22:47:15*cyraxjoe quit (Quit: No Ping reply in 180 seconds.)
22:47:40*cyraxjoe joined #nim
23:00:03FromDiscord<uninnocent> In reply to @Elegantbeef "Assuming you mean giving": I meant like editing existing file icons not compiling with one
23:00:34FromDiscord<uninnocent> For example, getting the icon off of example1.exe, and giving it to example2.exe so they both now have the same icon
23:05:14FromDiscord<Elegantbeef> Look how to do it in C/C++ i guess
23:21:25FromDiscord<bostonboston> Is `is` not an alias for `==`
23:30:17FromDiscord<nervecenter> Pretty sure `is` denotes identity (reference address, etc.) and `==` denotes value equality (regardless of identity or address)
23:30:33FromDiscord<turtlebasket> ^
23:31:16FromDiscord<nervecenter> (edit) "Pretty sure `is` denotes identity ... (reference" added "equality"
23:39:17FromDiscord<bostonboston> Makes sense, it just felt natural to try and use is/isnot in conditionals