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:05 | NimEventer | New Nimble package! clibard - Command line interface for Google Bard, see https://github.com/thisago/clibard |
04:52:09 | FromDiscord | <terrygillis> does nim have something similar to wrapper classes in java? |
04:53:21 | FromDiscord | <terrygillis> types Integer, Boolean etc. for primitives int, bool accordingly |
04:53:37 | FromDiscord | <Elegantbeef> It doesnt need them so nope |
04:54:54 | FromDiscord | <terrygillis> i making something like a table, and if the key doesn’t exist the value returned is nil |
04:55:01 | FromDiscord | <terrygillis> but this would work for primitives |
04:55:10 | FromDiscord | <Elegantbeef> `import std/options` |
04:55:46 | FromDiscord | <terrygillis> ah thanks |
05:02:08 | FromDiscord | <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:51 | FromDiscord | <Elegantbeef> `reset internelSeq[size]` |
05:03:07 | FromDiscord | <Elegantbeef> or `internalSeq[size] = default(T)` where `T` is your generic parameter |
05:03:56 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4B5T |
05:04:16 | FromDiscord | <Elegantbeef> But that's a micro optimisation |
05:04:32 | FromDiscord | <terrygillis> thanks very much |
05:05:33 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/tIrCi |
05:05:59 | FromDiscord | <Elegantbeef> This way complex types such as objects are 0'd incase their fields have GC'd memory |
05:06:04 | FromDiscord | <Elegantbeef> Typetraits is really missing a `hasGcedMemory` |
05:28:23 | FromDiscord | <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:48 | FromDiscord | <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:25 | FromDiscord | <enthus1ast> i tried with ctrl c exit hook but it somehow was not working, no idea why (yet) |
05:41:27 | FromDiscord | <enthus1ast> and when i killed the processes randomly, and restarted them, i got a deadlock |
05:41:40 | FromDiscord | <enthus1ast> so they work but its a little naah |
05:42:08 | FromDiscord | <Elegantbeef> It does seem there is a 'unamed semaphore' |
05:43:03 | FromDiscord | <enthus1ast> yeah but this is afaik for inter thread |
05:43:14 | FromDiscord | <enthus1ast> idk i could do this on the mmap |
05:43:42 | FromDiscord | <enthus1ast> but the mmap i have to call sync on and this also sounds a little wonky to be honest |
05:43:53 | FromDiscord | <Elegantbeef> Are you using the mmap for IPC? |
05:44:00 | FromDiscord | <enthus1ast> yes |
05:44:26 | FromDiscord | <Elegantbeef> I personally go for sockets for IPC |
05:44:50 | FromDiscord | <Elegantbeef> Unless you need the data shared and persistent of course |
05:44:50 | FromDiscord | <enthus1ast> yeah this is what i currently do |
05:45:08 | FromDiscord | <enthus1ast> but i wanted to explore more options |
05:45:20 | FromDiscord | <enthus1ast> the good thing about the mmap is, that it also gives me persitence |
05:45:45 | FromDiscord | <enthus1ast> persistence |
05:46:00 | FromDiscord | <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:22 | FromDiscord | <Elegantbeef> The terminating of the process is an odd thing to resolve I guess |
05:47:29 | FromDiscord | <Elegantbeef> I guess you could add a signal handle for terminate |
05:47:33 | FromDiscord | <Elegantbeef> handler\ |
05:48:39 | FromDiscord | <enthus1ast> it seems weird that the (potential dying) process itself must do os level cleanup |
05:49:16 | FromDiscord | <enthus1ast> sockets are much better suited for this acutally |
05:49:36 | FromDiscord | <Elegantbeef> Well given the point of a semaphore there isnt really a good way to get rid of it |
05:50:45 | FromDiscord | <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:29 | FromDiscord | <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:50 | FromDiscord | <enthus1ast> but with the difference that the data is updated live |
05:52:07 | FromDiscord | <Elegantbeef> Yea sounds like a producer/consumer setup |
05:53:56 | FromDiscord | <enthus1ast> currently my testing client looks like this \:)vim `ncat 127.0.0.1 4445 | fzf` |
05:54:05 | FromDiscord | <enthus1ast> \`\`\`vim \`ncat 127.0.0.1 4445 \| fzf\`\`\`\` |
05:54:15 | FromDiscord | <enthus1ast> ugh, you get it i guess |
05:55:38 | NimEventer | New question by Emilia Qtless: Translation in Happyx, see https://stackoverflow.com/questions/76735435/translation-in-happyx |
05:57:49 | FromDiscord | <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:47 | FromDiscord | <enthus1ast> then currently the daemon listens to fanotify callbacks to keep the index fresh |
05:59:28 | FromDiscord | <enthus1ast> for now the newly found data is not streamed to the fzf client, but on a new call its there |
06:00:33 | FromDiscord | <enthus1ast> fanotify works recursive for the whole filesystem(s) and its quite fast |
06:03:12 | FromDiscord | <Elegantbeef> I'm still reading about the semaphore api myself, seems not too bad assuming you have proper error handling implemented |
06:04:28 | FromDiscord | <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:50 | FromDiscord | <Elegantbeef> With destructors and using Nim's `guard` annotation could have a nifty system |
06:08:27 | FromDiscord | <Elegantbeef> Yea there's a `unhandledExceptionHook` you can use |
06:08:39 | FromDiscord | <Elegantbeef> So in theory this shouldnt be too bad to handle |
06:08:50 | FromDiscord | <enthus1ast> guard annotation? |
06:09:15 | FromDiscord | <Elegantbeef> It's a pragma you can use to make a variable require a `{.locks: [lockName].}: code here` |
06:09:20 | FromDiscord | <Elegantbeef> Generally used for multi threading |
06:09:46 | FromDiscord | <enthus1ast> ah |
06:09:59 | FromDiscord | <enthus1ast> https://nim-lang.org/docs/manual_experimental.html#guards-and-locks-guards-and-the-locks-section |
06:10:15 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4B63 |
06:12:40 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/XhFu5 |
06:12:43 | FromDiscord | <Elegantbeef> And like that you've now made it relatively safe 😄 |
06:13:38 | FromDiscord | <Elegantbeef> Your daemon would inside of it's exit procs likely should kill all the children processes and destroy the semaphore |
06:14:11 | FromDiscord | <enthus1ast> there are no childs on the classical sense |
06:14:19 | FromDiscord | <enthus1ast> so they're not started by the daemon |
06:14:38 | FromDiscord | <enthus1ast> but by the user(s) that use the daemon in from a shell command |
06:15:06 | FromDiscord | <Elegantbeef> Ah that's a slight issue of course |
06:15:50 | FromDiscord | <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:03 | FromDiscord | <enthus1ast> haha |
06:16:54 | FromDiscord | <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:15 | FromDiscord | <Elegantbeef> oh nice semaphores are actually wrapped in the stdlib's posix module |
06:17:24 | FromDiscord | <enthus1ast> yes |
07:11:09 | * | ntat joined #nim |
07:49:29 | * | azimut joined #nim |
07:58:26 | FromDiscord | <youssefbs> sent a code paste, see https://play.nim-lang.org/#ix=4B6e |
08:00:38 | FromDiscord | <demotomohiro> It become compile error if `const index = 2` instead of `var index = 2`. |
08:01:30 | FromDiscord | <Elegantbeef> Nim does not do value narrowing so it's a runtime error only |
08:06:17 | FromDiscord | <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:16 | FromDiscord | <youssefbs> Is there a website where I can find the best practices for coding with Nim to help avoid making errors ? |
08:09:17 | FromDiscord | <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:22 | FromDiscord | <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:02 | FromDiscord | <youssefbs> Thanks |
09:10:36 | * | ntat quit (Quit: leaving) |
09:23:19 | FromDiscord | <bung8954> sent a code paste, see https://play.nim-lang.org/#ix= |
09:23:25 | FromDiscord | <bung8954> sent a long message, see http://ix.io/4B6n |
09:24:53 | NimEventer | New 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:07 | FromDiscord | <bung8954> why conflict? the proc defined as `proc sel_registerName(str: cstring): SEL {.cdecl, importc.}` |
09:39:16 | FromDiscord | <jmgomez> try using `nodecl` |
09:45:32 | FromDiscord | <bung8954> it causes -Wimplicit-function-declaration |
09:48:23 | FromDiscord | <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:52 | FromDiscord | <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:50 | FromDiscord | <bung8954> (edit) "`cdecl, importc`" => "`{cdecl}`, `{importc" | "`cdecl`" => "cdecl}`" |
09:54:24 | FromDiscord | <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:34 | FromDiscord | <bung8954> if I dont explicitly use dynlib, it linked by `{.passL: "-framework Foundation".}` right ? |
09:58:37 | FromDiscord | <bung8954> In reply to @jmgomez "is `/Applications/Xcode.app/Contents/Developer/Plat": it should included, it's mapping to the c function |
10:05:19 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4B6r |
10:07:11 | * | sagax quit (Ping timeout: 264 seconds) |
10:18:16 | FromDiscord | <bung8954> i think it's just name conflict |
10:20:20 | FromDiscord | <bung8954> weird thing is my library main program runs fine, when it used in other program face this error |
10:29:40 | FromDiscord | <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:29 | FromDiscord | <gogolxdong666> Why does parseJson {"ConfigureMsgRecive":"1"} result in{"ConfigureMsgRecive":"{"} |
13:38:44 | FromDiscord | <gogolxdong666> (edit) "{"ConfigureMsgRecive":"1"}" => "`{"ConfigureMsgRecive":"1"}`" | "in{"ConfigureMsgRecive":"{"}" => "in `{"ConfigureMsgRecive":"{"}`" |
13:38:46 | * | jmd_ quit (Ping timeout: 245 seconds) |
13:43:28 | FromDiscord | <Andreas> In reply to @gogolxdong666 "Why does parseJson `{"ConfigureMsgRecive":"1"}`": try `parseJson "{\"ConfigureMsgRecive\":1}"` - works for me.. |
13:47:13 | FromDiscord | <gogolxdong666> runes:{"ConfigureMsgRecive":"1"} string:{"ConfigureMsgRecive":"1"} json:{"ConfigureMsgRecive":"{"} |
13:47:40 | FromDiscord | <gogolxdong666> sent a code paste, see https://paste.rs/BVrLT |
13:48:30 | FromDiscord | <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:09 | FromDiscord | <Andreas> sent a code paste, see https://play.nim-lang.org/#ix=4B71 |
14:01:57 | FromDiscord | <Andreas> (edit) |
14:08:13 | FromDiscord | <nnsee> sent a code paste, see https://play.nim-lang.org/#ix=4B75 |
14:13:23 | FromDiscord | <gogolxdong666> `proc getBodyBytes(response: HttpClientResponseRef): Future[seq[byte]] {.async.}` |
14:17:13 | FromDiscord | <gogolxdong666> I want parseJson returns {"ConfigureMsgRecive":"1"} |
14:21:59 | FromDiscord | <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:12 | FromDiscord | <gogolxdong666> means quote the string manually to have it parsed by json? |
14:24:55 | FromDiscord | <nervecenter> sent a code paste, see https://play.nim-lang.org/#ix=4B78 |
14:29:15 | FromDiscord | <nervecenter> sent a code paste, see https://play.nim-lang.org/#ix=4B79 |
14:30:28 | FromDiscord | <bostonboston> `high(float) ` should return inf correct? |
14:30:53 | FromDiscord | <demotomohiro> !eval echo float.high |
14:30:58 | NimBot | inf |
14:31:21 | FromDiscord | <griffith1deadly> in latest devel same |
14:31:51 | FromDiscord | <bostonboston> is there also a function that will return the highest real number a float can represent |
14:32:54 | FromDiscord | <Andreas> @gogolxdong666 Is this `{"ConfigureMsgRecive":"{"}` the `Future[ seq[byte] ]` from your response ? if so, then its incomplete or broken .. |
14:33:28 | FromDiscord | <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:39 | FromDiscord | <gogolxdong666> response is {"ConfigureMsgRecive":"1"} |
14:35:33 | FromDiscord | <gogolxdong666> var res = waitFor response.getBodyBytes()↵ var str = cast[string](res)↵ var escaped = strutils.escape str↵ echo parseJson escaped |
14:35:47 | FromDiscord | <gogolxdong666> (edit) "response.getBodyBytes()↵ var" => "response.getBodyBytes()↵var" | "cast[string](res)↵ var" => "cast[string](res)↵var" | "str↵ echo" => "str↵echo" |
14:36:15 | FromDiscord | <gogolxdong666> "{\"ConfigureMsgRecive\":\"1\"}"↵"{\"ConfigureMsgRgRgRgRgRgRg" |
14:36:42 | FromDiscord | <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:07 | FromDiscord | <gogolxdong666> https://media.discordapp.net/attachments/371759389889003532/1131958038996197416/image.png |
14:42:38 | FromDiscord | <Andreas> sent a code paste, see https://play.nim-lang.org/#ix=4B7d |
14:43:34 | FromDiscord | <michaelb.eth> `let str = string.fromBytes res` |
14:44:17 | FromDiscord | <michaelb.eth> I’m not sure cast is a good idea for getting the string from the bytes |
14:44:32 | FromDiscord | <Andreas> (edit) "https://play.nim-lang.org/#ix=4B7d" => "https://play.nim-lang.org/#ix=4B7f" |
14:45:18 | FromDiscord | <Andreas> In reply to @michaelb.eth "I’m not sure cast": true, casting is never a good idea 🙂 |
14:50:10 | FromDiscord | <gogolxdong666> Is there such a proc fromBytes |
14:50:17 | FromDiscord | <gogolxdong666> (edit) "fromBytes" => "string.fromBytes" |
14:58:49 | FromDiscord | <terrygillis> sent a code paste, see https://play.nim-lang.org/#ix=4B7j |
14:59:29 | FromDiscord | <michaelb.eth> In reply to @gogolxdong666 "Is there such a": stew/byteutils |
15:00:24 | * | rockcavera joined #nim |
15:01:05 | FromDiscord | <michaelb.eth> https://github.com/status-im/nim-stew/blob/master/stew/byteutils.nim#L256-L263 |
15:02:33 | FromDiscord | <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:06 | FromDiscord | <gogolxdong666> the same |
15:08:11 | FromDiscord | <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:30 | FromDiscord | <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:50 | FromDiscord | <bostonboston> It it's just this one time I would declare the var |
15:11:58 | FromDiscord | <gogolxdong666> sent a code paste, see https://play.nim-lang.org/#ix=4B7o |
15:18:08 | FromDiscord | <Andreas> sent a code paste, see https://play.nim-lang.org/#ix=4B7r |
15:18:50 | FromDiscord | <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:02 | FromDiscord | <bostonboston> ^ |
15:20:23 | FromDiscord | <gogolxdong666> https://media.discordapp.net/attachments/371759389889003532/1131968918630715472/image.png |
15:32:31 | FromDiscord | <terrygillis> sent a code paste, see https://play.nim-lang.org/#ix=4B7t |
15:33:19 | FromDiscord | <terrygillis> idk if it's just me but this does not seem very elegant or am I getting anything wrong? |
15:45:04 | FromDiscord | <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:48 | FromDiscord | <demotomohiro> In rust, variables are immutable in default. |
15:52:49 | FromDiscord | <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:27 | FromDiscord | <michaelb.eth> mutable state being the root of all evil, and all that |
15:56:53 | FromDiscord | <terrygillis> sent a code paste, see https://paste.rs/8Cl05 |
15:57:26 | FromDiscord | <bostonboston> If I have a tuple `foo = (seq[T], seq[T])` can I do something like `for x, y in foo` |
15:57:27 | FromDiscord | <terrygillis> Mind, I'm a beginner to both Rust and Nim. |
15:58:10 | FromDiscord | <bostonboston> (edit) "foo`" => "foo:`" |
16:04:10 | * | ntat joined #nim |
16:06:23 | FromDiscord | <bostonboston> Or is `for bar in zip(foo[0], foo[1]):` my best option |
16:21:05 | FromDiscord | <arathanis> im seeing you can define tasks in `config.nims`. is there a way to invoke them without using nimble? |
16:30:20 | FromDiscord | <mohamed> is there any way to build nim sdl for android |
16:38:23 | FromDiscord | <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:52 | FromDiscord | <arathanis> In reply to @terrygillis "After searching for a": what is it you are trying to accomplish exactly? |
16:43:49 | FromDiscord | <demotomohiro> @terrygillis sink is not for modifying parameter. |
16:44:04 | FromDiscord | <ambient3332> sent a code paste, see https://paste.rs/Vv9Pd |
16:45:15 | FromDiscord | <arathanis> i agree w/ you @ambient3332 |
16:45:40 | FromDiscord | <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:45 | FromDiscord | <arathanis> doesn't make sense to call it on a constant |
16:46:27 | FromDiscord | <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:56 | FromDiscord | <ambient3332> Even the Rust function doesn't actually return the mutated value, but creates another one |
16:47:17 | FromDiscord | <ambient3332> ...in the return field |
16:47:23 | * | lucasta quit (Quit: Leaving) |
16:47:30 | FromDiscord | <arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4B81 |
16:47:33 | FromDiscord | <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:34 | FromDiscord | <arathanis> then they can mutate it further to their heart's content |
16:47:46 | FromDiscord | <arathanis> In reply to @terrygillis "I just want to": use my example |
16:50:26 | FromDiscord | <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:14 | FromDiscord | <arathanis> what is the algorithm in question? |
16:51:39 | FromDiscord | <ambient3332> var ta, tb, tc = a, c, b etc |
16:52:05 | FromDiscord | <ambient3332> playing tricks with the function signature is a good way to shoot yourself in the foot |
16:53:07 | FromDiscord | <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:03 | FromDiscord | <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:36 | FromDiscord | <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:00 | FromDiscord | <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:12 | FromDiscord | <ambient3332> (edit) "on" => "by" |
16:58:04 | FromDiscord | <terrygillis> yes but rust doesn’t require redeclaring ‘let a = a’ if the parameter is clearly marked with “mut” |
16:58:34 | FromDiscord | <arathanis> what are you doing that requires mutating the parameters of the procedure without exposing those mutations outside the procedure call? |
17:00:44 | FromDiscord | <demotomohiro> @terrygillis here is document about sink:↵https://nim-lang.github.io/Nim/destructors.html |
17:01:31 | FromDiscord | <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:36 | FromDiscord | <ambient3332> sent a code paste, see https://play.nim-lang.org/#ix=4B86 |
17:02:25 | FromDiscord | <terrygillis> yes but you still have to declare ‘var foo = 5’ outside even though it’s not needed↵(@ambient3332) |
17:02:38 | FromDiscord | <ambient3332> In reply to @terrygillis "yes but you still": You can't mutate a variable that does not exist |
17:03:00 | FromDiscord | <terrygillis> passing in a literal 5 is not allowed |
17:03:00 | FromDiscord | <terrygillis> in rust passing in a literal 5 can work just fine |
17:03:17 | FromDiscord | <terrygillis> even if it’s marked mut |
17:04:23 | FromDiscord | <ambient3332> True, but I don't know why it does that. 1 is constant and can't be mutated |
17:05:43 | FromDiscord | <demotomohiro> I think mut in your Rust code only allow modifying parameter but it doesn't modifying the given argument. |
17:06:33 | FromDiscord | <ambient3332> Implicit conversion is something I didn't expect Rust would be doing here |
17:06:47 | FromDiscord | <terrygillis> It’s just a really minor thing that saves some time of not having to reassign or create new variables. |
17:06:54 | FromDiscord | <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:24 | FromDiscord | <terrygillis> yes sink seems to be the right use case for this but nobody is using it, aren’t they? |
17:08:24 | FromDiscord | <terrygillis> can i try this on the nim playground yet or is it only in devel? |
17:08:30 | FromDiscord | <nervecenter> Passing a mutable reference into a new context is not a "minor thing" |
17:08:34 | FromDiscord | <nervecenter> That's a footgun ready to blow |
17:10:56 | FromDiscord | <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:15 | FromDiscord | <nervecenter> So it creates a new, mutable copy? |
17:11:27 | FromDiscord | <arathanis> in rust i think the equivalent to Nim's `var` is `mut&` for mutable reference? |
17:11:31 | FromDiscord | <arathanis> In reply to @nervecenter "So it creates a": yes |
17:11:45 | FromDiscord | <arathanis> rust lets you mark a function parameter as mutable but still scoped to the function |
17:12:04 | FromDiscord | <nervecenter> That is very...subtle |
17:13:25 | FromDiscord | <terrygillis> and ‘sink’ maybe nim’s equivalent to that↵(@arathanis) |
17:13:27 | FromDiscord | <arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4B8a |
17:13:47 | FromDiscord | <arathanis> In reply to @terrygillis "and ‘sink’ maybe nim’s": sink is just a fun way of making surprise copies 😎 |
17:14:05 | FromDiscord | <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:20 | FromDiscord | <ambient3332> Only use I've had for sink is making sure there's no copy |
17:14:36 | FromDiscord | <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:57 | FromDiscord | <ambient3332> In reply to @arathanis "i honestly dont find": Arrays are one obvious usecase |
17:16:56 | FromDiscord | <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:53 | FromDiscord | <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:39 | FromDiscord | <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:39 | FromDiscord | <arathanis> sink is probably not what you want, redesigning what you are trying to do might be the way |
17:21:28 | FromDiscord | <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:30 | FromDiscord | <demotomohiro> It seems you can use sink parameter like Rust's mut parameter:↵https://play.nim-lang.org/#ix=4B8d |
17:23:36 | FromDiscord | <terrygillis> yeah maybe it’s just me being a bit too lazy \:))↵(@sreagle) |
17:23:43 | * | junaid_ joined #nim |
17:24:38 | FromDiscord | <arathanis> also unless something has changed, sink will make surprise copies |
17:24:43 | FromDiscord | <arathanis> so probably dont do that |
17:24:53 | FromDiscord | <arathanis> its a bit of footgun |
17:24:56 | FromDiscord | <arathanis> a foot supersoaker |
17:25:19 | FromDiscord | <arathanis> In reply to @sreagle "That's exactly what I'm": im wth you, this waas exactly my thoughts |
17:25:23 | FromDiscord | <arathanis> (edit) "wth" => "with" |
17:27:55 | FromDiscord | <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:20 | FromDiscord | <arathanis> can you give an example of the procedure and what it does to help us think about naming? |
17:28:39 | FromDiscord | <terrygillis> renaming things as is (reassigning) makes code look weird though |
17:28:50 | FromDiscord | <terrygillis> i mean in the case presented above |
17:29:03 | FromDiscord | <terrygillis> redeclaring to mutate locally |
17:29:12 | FromDiscord | <ambient3332> I don't think it's common to mutate integers from function parameters |
17:32:00 | FromDiscord | <terrygillis> like in the signature there’s (time\: string, size\: int) and in the body name it mutatedTime and mutatedSize? |
17:32:44 | FromDiscord | <ambient3332> You would have to give a full example to have any clarity on this, I think |
17:33:25 | FromDiscord | <ambient3332> A piece of code that actually does something |
17:34:21 | FromDiscord | <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:33 | FromDiscord | <michaelb.eth> sent a code paste, see https://play.nim-lang.org/#ix=4B8g |
17:36:20 | FromDiscord | <michaelb.eth> only use a `var` parameter if the mutation must be exposed outside of the proc's scope |
17:37:04 | FromDiscord | <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:42 | FromDiscord | <that_dude.> sent a code paste, see https://play.nim-lang.org/#ix=4B8l |
17:43:50 | FromDiscord | <that_dude.> ah I think it's the other way around |
18:12:00 | FromDiscord | <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:15 | FromDiscord | <ambient3332> sent a code paste, see https://play.nim-lang.org/#ix=4B8u |
18:25:26 | FromDiscord | <ambient3332> (edit) "https://play.nim-lang.org/#ix=4B8u" => "https://play.nim-lang.org/#ix=4B8v" |
18:27:21 | FromDiscord | <0xrh0d4m1n> macro + varargs cool, thx for the tip |
18:29:45 | * | cyraxjoe joined #nim |
18:36:37 | FromDiscord | <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:59 | FromDiscord | <takemichihanagaki3129> (edit) "what's" => "what're" | "usage?↵I'm" => "usages?↵I'm" |
18:37:21 | FromDiscord | <ambient3332> sent a code paste, see https://play.nim-lang.org/#ix=4B8y |
18:37:51 | FromDiscord | <takemichihanagaki3129> In reply to @ambient3332 "A really dumb way": I see. |
18:38:43 | FromDiscord | <takemichihanagaki3129> It's pretty useful if your parameters are constants... |
18:39:01 | FromDiscord | <djazz> why does it work? arent they already declared? |
18:39:32 | FromDiscord | <ambient3332> it creates new local variables from the constants in the function signature |
18:39:32 | FromDiscord | <djazz> have I been doing var x2 = x all in vain? XD |
18:44:59 | FromDiscord | <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:31 | FromDiscord | <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:46 | ehmry | ambient3332: that is for attaching pragma annotations to stuff like types |
19:52:21 | FromDiscord | <ambient3332> I guess I'm not supposed to understand it |
19:52:46 | ehmry | you want an example? |
19:53:47 | FromDiscord | <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:48 | ehmry | that 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:15 | FromDiscord | <Elegantbeef> The most common use case is serialisation in my experience |
20:02:21 | ehmry | right |
20:02:32 | FromDiscord | <Elegantbeef> Mark a field `{.unserialised.}` or do `{.jsonName: "bleh".}` |
20:02:56 | * | xet7 joined #nim |
20:19:10 | FromDiscord | <ambient3332> sent a code paste, see https://play.nim-lang.org/#ix=4B98 |
20:46:00 | NimEventer | New 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:46 | FromDiscord | <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:35 | FromDiscord | <Elegantbeef> Nimble is how it works |
20:50:45 | FromDiscord | <Elegantbeef> Nimble 0.13 should not use pkgs2 but nimble 0.14 should |
20:50:50 | FromDiscord | <Elegantbeef> Nimble 0.14 is used in devel+ |
20:51:12 | FromDiscord | <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:59 | FromDiscord | <voidwalker> yikes, so what happens if I use them both ? |
20:53:05 | FromDiscord | <Elegantbeef> Nimble 0.14 I think looks in pkgs2 then pkgs1 |
20:53:34 | FromDiscord | <voidwalker> oh, then I should be safe with both |
20:56:12 | FromDiscord | <voidwalker> sent a code paste, see https://paste.rs/sB241 |
20:56:16 | FromDiscord | <voidwalker> why does it go to nim-1.6.14 folder at the end ? :\ |
20:56:27 | FromDiscord | <voidwalker> ah nevermind |
20:56:46 | FromDiscord | <voidwalker> I had the 1.6.14 file opened |
20:57:51 | FromDiscord | <voidwalker> Anyways, any clue what's up with that openstreetmap lib ? |
20:57:55 | FromDiscord | <voidwalker> @juan_carlos maybe ? : ) |
21:00:27 | FromDiscord | <Elegantbeef> It was modified 4 years ago, perhaps it used to return a xml in the response body |
21:01:15 | FromDiscord | <Elegantbeef> Wait I'm daft |
21:01:36 | FromDiscord | <Elegantbeef> 4 years ago would've been right before 1.0 so `loadXml` certainly took a filepath back then aswell |
21:04:05 | FromDiscord | <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:52 | FromDiscord | <voidwalker> last update is from 2022, i installed it with @#head |
21:05:13 | FromDiscord | <voidwalker> oh, in 2022 they added donation info lol |
21:07:34 | FromDiscord | <voidwalker> https://github.com/nim-lang/graveyard/blob/cca4055a063e2469de820495ec403a0c11ba837f/xmldomparser/src/xmldomparser.nim#L142 |
21:08:04 | FromDiscord | <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:32 | FromDiscord | <Elegantbeef> Nimble is a fantastic package manager 😛 |
21:09:22 | FromDiscord | <voidwalker> it's almost fine |
21:10:15 | FromDiscord | <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:38 | FromDiscord | <voidwalker> can't imagine how you would do that programatically? |
21:11:10 | FromDiscord | <Elegantbeef> No clue |
21:31:55 | FromDiscord | <JJ> oh hey, i was reading through it and just noticed that nim made the stack overflow survey this year! |
21:31:56 | FromDiscord | <JJ> https://survey.stackoverflow.co/2023/ |
21:32:26 | FromDiscord | <JJ> i think this is its first year |
21:46:16 | * | junaid_ quit (Remote host closed the connection) |
21:49:42 | FromDiscord | <Elegantbeef> I believe you're right |
21:49:52 | FromDiscord | <Elegantbeef> It's all downhill from here |
22:01:35 | * | zgasma quit (Quit: leaving) |
22:18:04 | NimEventer | New question by epilif3sotnas: What is the equivalent of Java's protected attributes in Nim?, see https://stackoverflow.com/questions/76741539/what-is-the-equivalent-of-javas-protected-attributes-in-nim |
22:38:11 | FromDiscord | <uninnocent> how do I read and set file icons in nim? |
22:40:14 | FromDiscord | <Elegantbeef> Assuming you mean giving the ".exe" an icon on windows, you fight with vcc |
22:40:29 | FromDiscord | <Elegantbeef> Guess you can use mingw aswell |
22:41:29 | FromDiscord | <Elegantbeef> https://stackoverflow.com/a/708382/15200657 |
22:46:30 | FromDiscord | <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:03 | FromDiscord | <uninnocent> In reply to @Elegantbeef "Assuming you mean giving": I meant like editing existing file icons not compiling with one |
23:00:34 | FromDiscord | <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:14 | FromDiscord | <Elegantbeef> Look how to do it in C/C++ i guess |
23:21:25 | FromDiscord | <bostonboston> Is `is` not an alias for `==` |
23:30:17 | FromDiscord | <nervecenter> Pretty sure `is` denotes identity (reference address, etc.) and `==` denotes value equality (regardless of identity or address) |
23:30:33 | FromDiscord | <turtlebasket> ^ |
23:31:16 | FromDiscord | <nervecenter> (edit) "Pretty sure `is` denotes identity ... (reference" added "equality" |
23:39:17 | FromDiscord | <bostonboston> Makes sense, it just felt natural to try and use is/isnot in conditionals |