<< 29-01-2023 >>

00:13:39FromDiscord<voidwalker> So the other dillema, how to associate each key string with an encode and decode proc. As some might be parsed as integers or floats, others left as is, the original string, and others treated as enums.
00:14:48FromDiscord<voidwalker> I'm thinking to make a single enum for all value variants, as I think they are less than 256. And they'd be stored as a byte anyway in sql, even if just boolean
00:16:12FromDiscord<keks> Hi! I have a code like so: `let data = readFile("input.txt")[0..<size].toSeq.toCountTable` which only works because of the added `toSeq`. Why doesn't slicing of strings produce an `openArray`?
00:17:31FromDiscord<Elegantbeef> It'd produce a string which is passable into `openarray[char]`
00:18:40FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mtt
00:18:51FromDiscord<Elegantbeef> Worth noting that a `CountTable` for `char`s is a bit silly
00:23:58FromDiscord<keks> oh ignore me, I had an unrelated bug..
00:25:34FromDiscord<keks> regarding the CountTable for chars - I guess one can just directly do counting in an array.
00:26:45FromDiscord<Elegantbeef> Yep
00:27:12FromDiscord<Elegantbeef> `array[char, int]` is much faster than `CountTable` if we're only worried about ascii characters
00:27:55FromDiscord<Elegantbeef> Otherwise you use `CountTable[Rune]` and get utf8 support 😄
00:32:18FromDiscord<keks> either way is probably fine for AOC day 6 😄
01:10:15FromDiscord<spoon> trying the example from nim-lang/lua and it gives `could not import: luaL_loadbuffer`↔i have lua 5.4 and lua 5.4 devel installed under fedora, but copied liblua52.so into the working directory
01:11:14FromDiscord<Elegantbeef> https://github.com/nim-lang/lua/blob/master/src/lua52.nim#L27
01:13:03FromDiscord<spoon> renamed to liblua5.2.so, same error
01:13:27FromDiscord<spoon> is there a more updated lua library i should be using?
01:14:01FromDiscord<Elegantbeef> Your search features work aswell as anyone elses
01:14:41FromDiscord<spoon> i've searched before, just checking for suggestions
01:31:15*lumo_e joined #nim
01:46:21FromDiscord<auxym> Is there any way to get something like this to work? https://play.nim-lang.org/#ix=4mtG Or am I asking too much of Nim's type system?
01:47:01FromDiscord<Elegantbeef> It does work
01:47:12FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mtI
01:48:46FromDiscord<auxym> wtf kinda magic is that colon doing D:
01:49:19FromDiscord<Elegantbeef> Method call syntax limitation
01:49:20FromDiscord<Elegantbeef> https://nim-lang.org/docs/manual.html#templates-limitations-of-the-method-call-syntax
01:50:47FromDiscord<auxym> oh damn it's just a UFCS thing. I thought it was a generics issue. Great, thanks 👍
01:59:15FromDiscord<Rika> In reply to @spoon "trying the example from": Current directory is not part of search path for dynamic library unlike in windows
02:11:49*nyeaa4928423 quit (Ping timeout: 252 seconds)
02:15:32*nyeaa4928423 joined #nim
02:51:18FromDiscord<spoon> ah, i see
02:52:27FromDiscord<spoon> is there a compiler flag i can use to get it to recognize it?
02:52:46FromDiscord<Rika> i think you can set the env.var LD_LIBRARY_PATH or something
02:55:33FromDiscord<spoon> not sure if its working, is there a way i can enable logging to view external imports?
02:56:16FromDiscord<pyolyokh> if ldd shows that it's trying to dynamically link the library, you can pass `-Wl,-rpath=.` to the linker when you compile it, to hard-code . as a search path
02:56:48FromDiscord<pyolyokh> if ldd doesn't show that, then nim's trying to load it
02:58:20*xet7 quit (Ping timeout: 248 seconds)
03:01:23FromDiscord<pyolyokh> and, looking at nim-lang/lua, the latter's the case.
03:01:59FromDiscord<pyolyokh> an example of a way to override that is ` nim c --dynlibOverride:lua --passL:'/usr/lib/liblua5.2' luaex` , but sinc e that doesn't compile, that module's probably made for an even older version of Lua
03:03:28FromDiscord<Rika> luaex uses 5.0 or 5.1
03:04:13FromDiscord<pyolyokh> yeah, got it to work with lua 5.1
03:04:14FromDiscord<Rika> it imports lua not lua52 https://github.com/nim-lang/lua/blob/master/src/lua.nim#L58
03:05:21FromDiscord<spoon> lua 5.1?
03:05:31FromDiscord<Rika> yees
03:05:32FromDiscord<Rika> (edit) "yees" => "yes"
03:05:35FromDiscord<Rika> or 5.0
03:05:54FromDiscord<spoon> theres also lua52.nim
03:06:52FromDiscord<pyolyokh> and lua52.nim is bitrotten and won't compile with 1.6.10 or devel
03:07:16FromDiscord<spoon> welp
03:11:47*xet7 joined #nim
03:37:04*ltriant quit (Ping timeout: 248 seconds)
03:47:36*lumo_e quit (Quit: Quit)
05:02:24*oisota quit (Ping timeout: 260 seconds)
05:02:34*krydos quit (Ping timeout: 268 seconds)
05:06:51*arkurious quit (Quit: Leaving)
05:12:20*krydos joined #nim
05:22:52*oisota joined #nim
05:23:29*Jjp137 quit (Ping timeout: 255 seconds)
05:23:48*Jjp137 joined #nim
05:31:21FromDiscord<Tuatarian> Hey guys
06:12:02om3gaI made network packets parser-reassembler based on PMunch's nim-pcap bindings.
06:14:01om3gaWorks well, fast, almost like our C version. I like how Nim makes coding faster
06:16:25om3gaso it took around 2-3 days, and C version used reassembly function from 3rd party lib
07:54:53termersweet
07:55:05termerThe speed of writing nim is pretty good
07:55:19termerI tend to be able to write nim at a similar speed as node.js which I'm very proficient in
07:55:25termeralthough lack of libraries slows down some tasks
08:42:43*ltriant joined #nim
09:00:51*jmdaemon quit (Ping timeout: 260 seconds)
09:28:17FromDiscord<pmp-p> i think the discussion may interest people using emscripten builds https://github.com/hoodmane/libffi-emscripten/pull/20
09:29:11FromDiscord<pmp-p> ( without WASM_BIGINT 64bits parameters are split in 2x32 in exports/exports wasm tables )
09:29:14*krux02 joined #nim
09:30:18FromDiscord<pmp-p> (edit) "exports/exports" => "imports/exports"
10:02:54*jjido joined #nim
10:04:28*PMunch joined #nim
10:25:59*azimut quit (Ping timeout: 255 seconds)
10:32:29FromDiscord<pmp-p> @Ntsékees why would you want to load without emscripten glue the nim wasm if you used emscripten profile ?
10:32:59FromDiscord<pmp-p> if you want to get rid of emsdk loader, then don't compile with it, and use something like wasi-sdk instead
10:33:19FromDiscord<Ntsékees> Okay.
10:33:53FromDiscord<pmp-p> wasi will just require a handfull of function and an empty map for ENV
10:34:02FromDiscord<pmp-p> it's still human readable
10:35:10FromDiscord<pmp-p> eg a light one here https://github.com/bjorn3/browser_wasi_shim
10:35:56FromDiscord<Ntsékees> What is odd is that I compiled the C equivalent code with emcc as well and it did work without the Ecmascript glue code
10:36:36FromDiscord<Ntsékees> but well
10:36:38FromDiscord<pmp-p> i guess you did emcc -o out.wasm
10:36:47FromDiscord<Ntsékees> yeah
10:37:05FromDiscord<pmp-p> that's standalone mode
10:37:19FromDiscord<pmp-p> much closer to wasi
10:38:09FromDiscord<pmp-p> but as soon as you -o to html you bring stdio in
10:38:53FromDiscord<Ntsékees> I couldn't make the same exact command line work with Nim because I've not yet managed to export my function. It tells me to use `--ne-entry` but it doesn't seem to work (but maybe it's just that I haven't figured how to pass it to emcc through the Nim compiler?)
10:39:08FromDiscord<Ntsékees> (edit) "`--ne-entry`" => "`--no-entry`"
10:40:08FromDiscord<pmp-p> to export use `-Wl,--export-all`
10:40:42FromDiscord<pmp-p> and for reactor mode if using clang15+ then `-Wl,--no-entry -mexec-model=reactor`
10:40:49FromDiscord<Ntsékees> (`--no-entry` because my code has no `main` function)
10:41:53FromDiscord<pmp-p> main is only required if _start is called
10:53:28FromDiscord<HappySeal> Hi guys
10:53:45FromDiscord<HappySeal> How could I install faster_than_requests package?
10:55:16FromDiscord<HappySeal> Tried pip install multiple times but it just show version not found
10:56:11FromDiscord<pmp-p> try nimble install maybe ?
10:56:31FromDiscord<pmp-p> pip sounds very pythonic for a nim pkg
10:58:05*jjido quit (Quit: My laptop has gone to sleep. ZZZzzz
)
10:58:08FromDiscord<pmp-p> but if it's python then : pip install git+url
10:58:44FromDiscord<pmp-p> In reply to @HappySeal "How could I install": try pip install git+https://github.com/juancarlospaco/faster-than-requests
10:59:05*jjido joined #nim
10:59:05FromDiscord<HappySeal> thanks, trying it
10:59:23FromDiscord<Ntsékees> https://media.discordapp.net/attachments/371759389889003532/1069210140428996618/test.zip
11:00:12FromDiscord<Ntsékees> Here's my test code, along with the command lines I use in the `.sh` files (along with the `.nims` for Nim)
11:00:45FromDiscord<Ntsékees> before loading view.html, I run a server with `python3 -m http.server`
11:01:05FromDiscord<pmp-p> In reply to @HappySeal "How could I install": ouch i found the page on pypi, but sadly that package is not well packaged
11:01:12FromDiscord<HappySeal> https://media.discordapp.net/attachments/371759389889003532/1069210595058012271/image.png
11:01:15FromDiscord<pmp-p> you will have to download , unzip
11:01:22FromDiscord<pmp-p> go into folder and do : pip install .
11:01:23FromDiscord<HappySeal> I tried run on colab, but not working
11:01:38FromDiscord<pmp-p> (edit) "go into folder and do : pip install . ... " added " (from where the setup.py is located )"
11:02:18FromDiscord<HappySeal> In reply to @pmp-p "go into folder and": let me have a look
11:03:06FromDiscord<pmp-p> (edit) "you will have to download ... ," added "https://files.pythonhosted.org/packages/f0/9b/f392487c0ddb086aad681a781fbb1da4fcd2761920d20cfae18ecb724e67/faster_than_requests-21.03.03.zip"
11:03:16FromDiscord<HappySeal> 😂 Could not find setup or dependency files
11:03:32FromDiscord<pmp-p> i see it but in that zip https://files.pythonhosted.org/packages/f0/9b/f392487c0ddb086aad681a781fbb1da4fcd2761920d20cfae18ecb724e67/faster_than_requests-21.03.03.zip
11:03:47FromDiscord<HappySeal> oh, I see, let me try it
11:05:28FromDiscord<HappySeal> btw, is there any alternatives like request post but much faster?
11:08:21FromDiscord<HappySeal> strange
11:08:22FromDiscord<HappySeal> https://media.discordapp.net/attachments/371759389889003532/1069212400714272788/image.png
11:08:55FromDiscord<pmp-p> In reply to @HappySeal "": did you use `pip install .`
11:09:41FromDiscord<pmp-p> In reply to @Ntsékees "": yeah it see you should use wasi-sdk for standalone instead of emcc it is way faster and durable
11:09:50FromDiscord<Ntsékees> sent a code paste, see https://play.nim-lang.org/#ix=4muL
11:11:03FromDiscord<HappySeal> In reply to @pmp-p "did you use `pip": I tried to run setup script in colab, but it returned error
11:11:14FromDiscord<pmp-p> i don't know colab
11:21:56*jjido quit (Quit: Textual IRC Client: www.textualapp.com)
11:22:19*jjido joined #nim
11:43:10FromDiscord<demotomohiro> If you want to use Nim on google colab: https://github.com/demotomohiro/nim4colab
11:45:43FromDiscord<pmp-p> In reply to @Ntsékees "As I said, with": also you cannot use -ldl with standalone mode, dlfcn is implemented in emscripten html javascript glue
11:46:24FromDiscord<pmp-p> either go emscripten or wasi, in beetween is a moving target
11:53:38*jjido quit (Quit: My laptop has gone to sleep. ZZZzzz
)
12:01:25FromDiscord<pmp-p> emcc is really not happy with --noentry
12:09:10FromDiscord<planetis> See treeform's emscripten tutorial
12:15:13*luis joined #nim
12:16:00FromDiscord<pmp-p> In reply to @planetis "See treeform's emscripten tutorial": what for ?
12:17:47FromDiscord<pmp-p> seems to me that @Ntsékees is trying to make a javascript/wasm callable library not an app
12:18:39FromDiscord<planetis> And it still has a main?
12:18:59FromDiscord<pmp-p> it should not, but emcc can be real stubborn sometimes
12:19:11FromDiscord<pmp-p> wasm-ld will look for it
12:19:19FromDiscord<Ntsékees> I've not figured how to implement main(). I get errors on redefinition of `main`.
12:19:42FromDiscord<pmp-p> In reply to @Ntsékees "I've not figured how": same there
12:19:56FromDiscord<pmp-p> while wasi sdk has no such problem
12:20:15*ltriant quit (Ping timeout: 248 seconds)
12:20:25FromDiscord<planetis> I cannot open the zip but can you try --noMain\:off
12:21:15FromDiscord<pmp-p> In reply to @planetis "I cannot open the": yeah nailed it
12:22:21FromDiscord<pmp-p> sent a code paste, see https://play.nim-lang.org/#ix=4mv2
12:22:25FromDiscord<pmp-p> thx @planetis
12:22:41FromDiscord<planetis> Or in similar situation where main is necessary i used switch("clang.options.linker", "-shared ") instead of --app\:lib
12:22:53*luis_ joined #nim
12:24:15FromDiscord<planetis> But that wasn't a library it just loaded the shared library from java and run main
12:25:22FromDiscord<Ntsékees> sent a long message, see http://ix.io/4mv5
12:25:45FromDiscord<Ntsékees> (edit) "long message," => "code paste," | "http://ix.io/4mv5" => "https://play.nim-lang.org/#ix=4mv6"
12:25:58FromDiscord<pmp-p> nah just remove that main, and add the noMain swtich to your .nims
12:26:06FromDiscord<Ntsékees> Ah
12:26:09FromDiscord<pmp-p> (edit) "swtich" => "switch"
12:26:49FromDiscord<pmp-p> i used it too on wasi but i missed it
12:30:50FromDiscord<NtsĂ©kees> OK, now it compiles and view.html accept it except that it fails getting the `reverse` function. I again get the error `emcc: error: undefined exported symbol: "_reverse" [-Wundefined] [-Werror]`↔I'll try `switch("passL", "-Wl,--export-all")` instead

12:30:56FromDiscord<Ntsékees> (edit) "accept" => "accepts"
12:31:41FromDiscord<pmp-p> yes because _reverse is for the js trampoline
12:31:53FromDiscord<pmp-p> while your wasm export would be "reverse"
12:33:02FromDiscord<pmp-p> haha libstandalonewasm.a has a hard dependancy on main()
12:33:34*krux02 quit (Remote host closed the connection)
12:33:41FromDiscord<pmp-p> personnaly i'll stick to wasi 😄
12:33:58FromDiscord<Ntsékees> I will try out WASI; too bad that I was so close to make it work >_>
12:34:29*luis quit (Quit: luis)
12:34:45FromDiscord<pmp-p> tbh emscripten is only usefull for an app or if you need to dlopen()
12:35:19*krux02 joined #nim
12:35:21FromDiscord<Ntsékees> I chose Emscripten because it was the only one I had found usage examples with Nim
12:35:24FromDiscord<pmp-p> wasi build is smaller and super easy to test with numerous wasi runtimes around
12:38:56FromDiscord<Ntsékees> Could you show me which command line you use for telling Nim to use WASI as its backend?
12:42:29FromDiscord<gibson> I've heard byaddr pragma is going away. Right now I heavily use it, like to get the reference to a value type in a table (string, or seq as value to a key). Anyone else in this boat?
12:50:52FromDiscord<keks> sent a long message, see http://ix.io/4mvd
12:51:48FromDiscord<keks> (edit) "long message," => "code paste," | "http://ix.io/4mvd" => "https://play.nim-lang.org/#ix=4mve"
12:52:08FromDiscord<keks> (edit) "https://play.nim-lang.org/#ix=4mve" => "https://play.nim-lang.org/#ix=4mvf"
13:15:39FromDiscord<leorize> nope but there's a trick that don't involves proc
13:15:46FromDiscord<auxym> In reply to @keks "Is it possible to": yes, using a a block
13:15:54FromDiscord<auxym> if I'm understanding correctly
13:16:42FromDiscord<leorize> though for your case a `find`-like proc is probably better
13:16:49FromDiscord<auxym> here, pmunch's excellent article: https://peterme.net/tips-and-tricks-with-implicit-return-in-nim.html
13:17:03FromDiscord<leorize> if you want to build a seq, see `sugar.collect`
13:18:51PMunch@auxym, thank you :)
13:19:40PMunch@keks, it's possible without the proc wrapper, but if you want an early return it's not very much more convenient
13:20:26FromDiscord<auxym> In reply to @gibson "I've heard byaddr pragma": hadn't heard that. Isn't byaddr just used to annotate types to affect how they are passed in function calls? If you want to get a pointer to anything, you can use `addr` proc which isn't going anywhere, in fact it was made more useful in v2 (by replacing `unsafeAddr`)
13:21:57PMunchLooks a bit like this: https://play.nim-lang.org/#ix=4mvm
13:22:53FromDiscord<leorize> byaddr is a temporary workaround for the lack of views in nim
13:22:54FromDiscord<leorize> they should be deprecated by the time views are a thing
13:24:41FromDiscord<gibson> In reply to @auxym "hadn't heard that. Isn't": byaddr lets you copy by reference without using a function call, so you can create a temporary alias to another variable, or in my case to a seq value in a table. I guess addr would work, and the keyword and ugly syntax of dereferncing all the time would indicate something slightly tricky is happening, which isn't a bad thing. I'm just ugly syntax averse 😉
13:29:08*krux02 quit (Remote host closed the connection)
13:30:36FromDiscord<planetis> It unsafe though. Both of them actually. If you use nim from devel [] procs return lent T I think. This does create a safe reference when used directly and not stored in a variable
13:31:36FromDiscord<planetis> If you need an alias just write an .alias template. Though its not always the same
14:17:03FromDiscord<pmp-p> In reply to @Ntsékees "Could you show me": as long as wasi-sdk clang is found in path you just need to passC/passL the --sysroot=
14:18:26FromDiscord<pmp-p> (edit) "--sysroot=" => "--sysroot=${WASI_SDK_PATH}/share/wasi-sysroot"
14:20:26FromDiscord<matrix07012> Hi, I'm just starting out with Nim and I'm not sure if there's a way to this. Is it possible to "extend" proc %\() and to() from std/json so that it is able to turn objects containing DateType into json and vice versa using a set timeformat?
14:23:14PMunchFor % you just have to define a `proc \`%\`(x: DateTime): JsonNode` I believe
14:24:09FromDiscord<Phil> (Mandatory disclaimer from me that jsony is faster and imo easier to deal with)
14:34:33FromDiscord<auxym> so I'm sort of on the fence about this: `items` in enumutils (iterator for holey enums) systematically raises 2 warnings about holey enum conversion being unsafe. I think this is sort of annoying, using an stdlib proc correctly shouldn't yield warnings. Should I report this as an issue? I'm not sure if much can be done about it except pushing warnings: off for that section of code (which I could also do in my user code).
14:34:37FromDiscord<auxym> http://nim-lang.github.io/Nim/enumutils.html#items.i%2Ctypedesc%5BT%5D
14:35:40FromDiscord<matrix07012> Thanks, that's probably better↔And can you iterate over object attributes?↔(@Phil)
14:37:48FromDiscord<Phil> In reply to @matrix07012 "Thanks, that's probably better": Over nim objects?↔Or over JSON types?↔Nim objects you can iterate over their fields both at runtime and at compiletime.↔JSON types (as used by std/json, NOT by jsony, jsony translates JSON straight into nim-types without going over an intermediary "JSON"-type like std/json does) you can only iterate over at runtime.
14:38:12FromDiscord<Phil> (edit) "runtime." => "runtime, since you can't know when writing the code which fields the JSON-string you'll receive will have."
14:38:38FromDiscord<matrix07012> Nim objects↔(@Phil)
14:39:16FromDiscord<Phil> In reply to @matrix07012 "Nim objects (<@180601887916163073>)": In that case yeah, there are multiple iterators to do so in fact depending on what data you want.↔Do you need the actual data in the fields or do you just want to check "Do you have a field of name X with type Y" ?
14:39:30FromDiscord<keks> In reply to @auxym "here, pmunch's excellent article:": Thank you everybody! I will try have a look at this article, seems super useful!
14:40:12FromDiscord<Phil> In reply to @matrix07012 "Nim objects (<@180601887916163073>)": Here's an example that I often use, though I use it mostly for compile-time stuff:↔https://nim-lang.org/docs/iterators.html#fieldPairs.i%2CS%2CT↔"Fields" is also a valid iterator, both behave pretty similarly
14:42:22FromDiscord<matrix07012> I want to use it to modify the data↔(@Phil)
14:42:50FromDiscord<Phil> In reply to @matrix07012 "I want to use": In that case runtime, you can still use fieldPairs for that.↔Are you familiar with the concept of "unrolling" a for loop?
14:43:21FromDiscord<matrix07012> Yep↔(@Phil)
14:43:24FromDiscord<Phil> Or rather, you can just use fieldPairs if you just want to get on, if you're interested in how it works I can tell you a bit about unrolled for-loops, but generally it'll work as you expect
14:45:06FromDiscord<matrix07012> Thanks, that should work. I must have missed it when scrolling through docs
14:46:54FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mvT
14:47:46FromDiscord<Phil> You will want to use `when` instead of `if` here, so that your assignment of "value = 2" isn't turned into↔`x.name = 2` on top of `x.id = 2`
14:48:26FromDiscord<Require Support> is there a way to represent a pointer as an int in nim?
14:48:27*krux02 joined #nim
14:48:40PMunch@Require_Support, yes
14:49:29FromDiscord<Require Support> In reply to @PMunch "@Require_Support, yes": help is needed 🙏
14:49:47PMunchOh
14:49:55PMunch`cast[int](somePtr)`
14:50:04FromDiscord<Require Support> oh...
14:50:49FromDiscord<matrix07012> Thanks for the reminder, I would have forgotten and used if đŸ˜…â†”(@Phil)
14:50:52PMunchYou might also want to check out: https://github.com/kaushalmodi/ptr_math
14:51:05*krux02 quit (Remote host closed the connection)
14:51:17FromDiscord<Require Support> yep, imported already. Thanks kind soul
14:51:44FromDiscord<@thatrandomperson5-6310e3b26da03> https://nim-lang.org/docs/importutils.html Not working, i still can’t acess the private feild
14:51:47FromDiscord<Phil> In reply to @matrix07012 "Thanks for the reminder,": Do you just have the name of a field as a string and want to assign to it? Because there are easier ways to generate that code than to iterate over code like this just for a value assignment
14:53:26FromDiscord<matrix07012> Oh, yeah I do↔(@Phil)
14:54:39FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mvV
14:56:50FromDiscord<matrix07012> This won't work at runtime though?
14:56:54FromDiscord<Phil> `x.id` is fundamentally a "dot" expression, so you tell the compiler "here, turn this string `"id"` into an 'identifier' `id` and glue it to the object `x` to create the expression `x.id` .↔That needs a macro because you turn "id" from a string to an 'identifier'.↔↔Then you can use that to just create a blueprint for the compiler to copy-paste for a `setField` template.
14:57:20FromDiscord<Phil> In reply to @matrix07012 "This won't work at": This requires you to know the name that you want to assign to at compile-time, yeah, but the value assignment itself will work at runtime
14:57:33FromDiscord<Phil> (edit) "In reply to @matrix07012 "This won't work at": This requires you to know the name ... that" added "of the field"
14:57:57FromDiscord<Phil> But you have the same limitation when you iterate over an object and just check if field has the name X for an assignment
14:58:46FromDiscord<Phil> You need to know what to put into the when condition (which is compile-time) for iteration over fields like this to work
15:00:43FromDiscord<@thatrandomperson5-6310e3b26da03> Thanks!↔(@Phil)
15:01:19FromDiscord<keks> In reply to @PMunch "Looks a bit like": ok this is actually a bit more code than using return directly inside of the if statement, but yes, this is what I was looking for. I think using a find-like function is indeed better
15:02:22*luis_ quit (Remote host closed the connection)
15:04:08FromDiscord<keks> In reply to @leorize "though for your case": I couldn't find a find function that takes a predicate in the standard library
15:11:06*arkurious joined #nim
15:28:08FromDiscord<Duskhorn The Eclipsed> hello I don't get how and why the ORC and ARC memory management strategies are different than a classic garbage collector. Can someone explain?
15:36:37FromDiscord<Phil> sent a long message, see http://ix.io/4mwh
15:39:27FromDiscord<Duskhorn The Eclipsed> oh, cool
15:39:30FromDiscord<Phil> Yeah, here we go, ARC is deterministic, ORC is not and cannot be. It is basically ARC with a cycle collector and only the cycle collector part is really runtime overhead.
15:39:33FromDiscord<Phil> https://nim-lang.org/blog/2020/10/15/introduction-to-arc-orc-in-nim.html
15:39:58FromDiscord<Duskhorn The Eclipsed> so ORC is ARC but with a lightweight "GC" that only checks for cycles?
15:40:44FromDiscord<Duskhorn The Eclipsed> In reply to @Isofruit "Yeah, here we go,": yes I read this but it wasn't clear Nim did ARC at compile time
15:40:49FromDiscord<Phil> Sort of, I'm pretty sure Araq would get a headache if he heard it described like that, but I barely have any idea of GC anyway and any of the folks with a better understanding like beef and rika can always feel free to pitch in, though at least beef might be asleep atm
15:40:52FromDiscord<Duskhorn The Eclipsed> (at least, to me)
15:41:24FromDiscord<Duskhorn The Eclipsed> In reply to @Isofruit "Sort of, I'm pretty": XD poor Araq, I won't give him the headache then \:)
15:41:27FromDiscord<Phil> In reply to @Duskhorn The Eclipsed "yes I read this": This line is your indicator here:↔> The main difference between ARC and Nim GCs is that ARC is fully deterministic - the compiler automatically injects destructors when it deems that some variable (a string, sequence, reference, or something else) is no longer needed.
15:41:40FromDiscord<Phil> (edit) "fully deterministic" => "fully deterministic" | "automatically" => "automatically" | "destructors" => "destructors"
15:41:47FromDiscord<Duskhorn The Eclipsed> oh I see now, "the compiler"
15:41:53FromDiscord<Duskhorn The Eclipsed> gotcha, thank you!
15:42:18*ltriant joined #nim
15:43:54FromDiscord<Phil> I'm pretty sure I could, myself, swap with my project to ARC if I wanted, I don't really have scenarios where object instance A has a ref to object instance B, which has a reference to object instance A. But if I do somewhere (or any of my dependencies) I don't want to have to deal with it and the marginal performance improvement for me just isn't worth it even risking the chance to waste time on that problem.
15:44:39FromDiscord<Phil> There's a reason ORC became the default memory management option for the upcoming nim2 release, it's pretty good, can't complain really
15:45:11FromDiscord<Phil> But I do webdev, not gamedev, so other folks might have something else to say about that.
15:46:52FromDiscord<Duskhorn The Eclipsed> In reply to @Isofruit "I'm *pretty* sure I": that's cool, I myself struggle to see trivial scenarios where you have reference cycles
15:48:10*ltriant quit (Ping timeout: 252 seconds)
15:48:10FromDiscord<frobnicate> In reply to @Duskhorn The Eclipsed "that's cool, I myself": A classic could be parent/children that point at each other
15:51:01FromDiscord<Duskhorn The Eclipsed> In reply to @frobnicate "A classic could be": yeah true! Actually, doubly linked lists for example
15:52:08FromDiscord<jtv> Yes they happen all the time. Nodes deep in a tree that point back to the parent data structure the tree is in for context
15:57:23FromDiscord<Duskhorn The Eclipsed> In reply to @jtv "Yes they happen all": true, that's kinda painful. But thanks!
15:59:05FromDiscord<Duskhorn The Eclipsed> painful as in, I didn't know it happened all the times and one has to kinda be mindful of it when using ARC and not ORC
16:08:06*luis joined #nim
16:08:37*luis quit (Client Quit)
16:08:56*luis joined #nim
16:27:13FromDiscord<@thatrandomperson5-6310e3b26da03> I still can’t acess private feilds from httpclient, i tried importutils and some macro magic, neither worked.
16:29:29FromDiscord<Phil> Yeh, basically nim tries to do as much at compile time as possible, but it doesn't force you to and grants you a way out.↔A quick google out of curiosity confirmed to me, that Rust tries to discourage it and asks you to use unsafe code-blocks to make it explicit that you're dealing with the freeing of that memory yourself.
16:29:53FromDiscord<Phil> (edit) "Yeh, basically nim tries to do as much at compile time as possible, but it doesn't force you to and grants you a way out.↔A quick google out of curiosity confirmed to me, that Rust tries to discourage it and asks you to use unsafe code-blocks to make it explicit that you're dealing with the freeing of that memory yourself. ... " added "(Based on https://stackoverflow.com/questions/20698384/what-lifetimes-do-i-use-to-create-ru
16:36:26FromDiscord<@thatrandomperson5-6310e3b26da03> > I still can’t acess private feilds from httpclient, i tried importutils and some macro magic, neither worked.↔Heres an example\: https://play.nim-lang.org/#ix=4mwx
16:40:46FromDiscord<Phil> In reply to @@thatrandomperson5-6310e3b26da03 "> I still can’t": Do you want to read from there after you set it during instantiation?
16:41:51FromDiscord<@thatrandomperson5-6310e3b26da03> What do you mean? Im trying setting the private field↔(@Phil)
16:42:11FromDiscord<Phil> Why not set it when you create the client?
16:42:18FromDiscord<@thatrandomperson5-6310e3b26da03> Oh, nvm, the lib will probably need to read from it but i will not
16:44:20FromDiscord<@thatrandomperson5-6310e3b26da03> This is just an example, where i’m actually using it i create the client beforehand and modify it multiple times.↔(@Phil)
16:44:33FromDiscord<Phil> Ahhh check, I'll play around a bit
16:46:21FromDiscord<Phil> Well, it works under 1.9.1, but not under 1.6.10
16:47:03FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mwC
16:47:15FromDiscord<Phil> (edit) "https://play.nim-lang.org/#ix=4mwC" => "https://play.nim-lang.org/#ix=4mwD"