<< 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"
16:50:24FromDiscord<@thatrandomperson5-6310e3b26da03> I can get devl, thought i might need this, thanks!↔(@Phil)
16:51:04FromDiscord<Phil> In reply to @@thatrandomperson5-6310e3b26da03 "I can get devl,": Keep in mind that devel changes the default memory management to orc if you haven't specified it yet, that might lead to errors depending
16:51:21FromDiscord<Phil> So might be that you need to do --mm:refc
16:51:31FromDiscord<Phil> (edit) "do" => "add the" | "add the--mm:refc ... " added "flag to your compile command"
16:51:41FromDiscord<@thatrandomperson5-6310e3b26da03> \:thumbsup\:
16:55:59FromDiscord<Phil> In reply to @keks "I couldn't find a": Yeah, find is one of those things that's missing. I tend to just filter and check the remaining array.↔I've also heard good things of the "zeroAbstraction" package
16:56:16FromDiscord<Phil> (edit) "package" => "package, though I didn't make use of it yet myself."
17:05:49FromDiscord<hips> not sure if this is a normal use case, but does anyone happen to have a resource repo (or terms I can Google) that makes use of nim in a nodejs backend - I'm looking to extend a nodejs server with a nim module (without compiling to js)
17:07:10FromDiscord<Phil> I'm not sure how that'd work, nodejs code will only ever access other js code, no?
17:07:34FromDiscord<Phil> Or does JS suddenly have a way to call C procs that I dont know about?
17:08:27FromDiscord<hips> In reply to @Isofruit "I'm not sure how": I was thinking to just use the nim compiled binary
17:09:01FromDiscord<hips> alternative would be setting up a webserver in nim and have those 2 talk internally
17:09:06FromDiscord<Phil> Can node call functions on a binary?↔Or do you mean you want to write essentially something to be used from a shell and node calls the binary via shell?
17:09:36FromDiscord<Phil> (edit) "binary?↔Or" => "library file?↔Or"
17:10:30FromDiscord<hips> In reply to @Isofruit "Can node call functions": basically yes, but I'm not sure if this is practical really
17:13:41*derpydoo joined #nim
17:15:30FromDiscord<Phil> sent a long message, see http://ix.io/4mwN
17:15:51FromDiscord<Phil> Basically it should be identical, with the key difference being that you generate the so files from nim
17:18:49*azimut joined #nim
17:19:31FromDiscord<hips> sent a long message, see http://ix.io/4mwO
17:20:32FromDiscord<Phil> In reply to @hips "in my scenario I": You might need to go a bit on a search for how to generate the SO files easily in nim (I mean, you can just have it spit out the C code and compile those into SO files yourself, but that's annoying). @demotomohiro might know more on this
17:21:00FromDiscord<Phil> (edit) "In reply to @hips "in my scenario I": You might need to go a bit on a search for how to generate the SO files easily in nim (I mean, you can just have it spit out the C code and compile those into SO files yourself, ... but" added " and it's not an insane amount of work to put that into a nimble build task,"
17:21:40FromDiscord<hips> In reply to @Isofruit "You might need to": I will see if I can get this automated, don't want to hinder my dev flow :). Thanks again, having these keywords helps me out a lot :)
17:35:08FromDiscord<matrix07012> sent a code paste, see https://play.nim-lang.org/#ix=4mwU
17:36:29FromDiscord<Rika> DateTime is not a ref
17:36:33FromDiscord<Rika> obj1 is a ref
17:39:23FromDiscord<Ntsékees> sent a code paste, see https://play.nim-lang.org/#ix=4mwV
17:42:02FromDiscord<matrix07012> Can I somehow figure out if date is uninitialized?
17:42:05FromDiscord<matrix07012> oooh↔Can I somehow figure out if date is uninitialized?
17:42:07FromDiscord<matrix07012> oooh↔Can I somehow figure out if foo.date is uninitialized?
17:42:07FromDiscord<pmp-p> In reply to @Ntsékees "I'm getting an error:": ha pointer size is 4
17:42:36FromDiscord<pmp-p> In reply to @Ntsékees "I'm getting an error:": add `--cpu:wasm32` somewhere
17:43:22FromDiscord<pmp-p> (edit) "In reply to @Ntsékees "I'm getting an error:": add `--cpu:wasm32` ... somewhere" added " or -m32 dunno which one"
17:43:44FromDiscord<matrix07012> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/1069311474457137235): oooh↔Can I somehow figure out if a field is uninitialized?
17:44:30FromDiscord<matrix07012> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/1069311474457137235): oooh↔Can I somehow figure out if a field is uninitialized or initialize an object with default values?
17:46:16FromDiscord<NtsĂ©kees> > $WASICC reverse.c -o reverse.wasm↔> clang-15: error: no such file or directory: 'STANDALONE_WASM'↔> clang-15: error: no such file or directory: 'EXPORTED_FUNCTIONS=['_reverse']'↔Is that normal? đŸ€”
17:46:34FromDiscord<pmp-p> yeah that's emscripten idiomatics
17:46:42FromDiscord<NtsĂ©kees> (edit) "reverse.c" => "-Os -s STANDALONE_WASM -s EXPORTED_FUNCTIONS="['_reverse']" -Wl,--no-entry "reverse.c"" | "reverse.wasm↔>" => ""reverse.wasm"↔>"
17:46:50FromDiscord<Ntsékees> ah
17:46:50FromDiscord<pmp-p> you should do your -d:wasi section
17:47:03FromDiscord<pmp-p> and try to PR that
17:47:31FromDiscord<pmp-p> i still don't know enough of nim to do it myself, i cowardly used a bash script wrapping clang
17:52:10*derpydoo quit (Ping timeout: 268 seconds)
17:57:30FromDiscord<Phil> In reply to @matrix07012 "[Edit](https://discord.com/channels/371759389889003": You can't figure out whether an object value stems from being initialized that way or getting that value explicitly assigned from you.↔At least not with any certainty.↔You could of course assume that if a value is 0, "", false, nil that it is from being initialized, but its not technically impossible for you to have set that yourself.
17:59:43*junaid_ joined #nim
18:01:24FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mx1
18:02:32*junaid__ joined #nim
18:02:54*junaid__ quit (Client Quit)
18:03:33*junaid__ joined #nim
18:04:14*junaid___ joined #nim
18:04:40*lumo_e joined #nim
18:04:45*junaid__1 joined #nim
18:06:43FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mx2
18:07:02FromDiscord<Phil> (edit) "https://play.nim-lang.org/#ix=4mx2" => "https://play.nim-lang.org/#ix=4mx3"
18:20:08*lumo_e quit (Quit: Quit)
18:24:35*jjido joined #nim
18:29:30PMunchJust deployed my Nim/HTMX home automation dashboard :)
18:29:42PMunchIt's based on my idea of type-based web-servers
18:29:58FromDiscord<Rika> type based in what sense
18:30:07PMunchEssentially leveraging cool Nim features to have each route be tied to a type
18:30:32PMunchSo when you do `GET /something/here` that is tied to a specific type on the server
18:30:39PMunchSo that route can never return another type
18:31:27PMunchWhich also means that by changing the "Accept" header from HTML to JSON you will now get a JSON representation of that object, instead of the HTMX snippets
18:32:28PMunchThe HTMX snippets themselves are rendered with autotemplates, so each type has their own file with the template information that can access the fields of the object
18:33:13PMunchAnd of course since it's all mapped between types on the server it means that you can also call the procedure that serves a route manually
18:33:36PMunchSo with one file you have HTMX server, JSON server, and importable library all in one
18:34:05*junaid__1 quit (Quit: leaving)
18:34:24PMunchAnd if you need the result from one route in another route it's as easy as just calling the procedure, no need to actually do a reverse call on yourself and parse the result
18:35:27PMunchIt's pretty neat
18:36:14PMunchStill needs a touch of macro magic to automatically make route matchers for Jester and Prologue, but once that's done it should be ready for usage :)
18:36:35PMunchI just wanted to test it out myself on a small project first
18:55:15*Onionhammer quit (Quit: The Lounge - https://thelounge.chat)
18:57:23*luis quit (Quit: Leaving)
18:58:17FromDiscord<@thatrandomperson5-6310e3b26da03> I installed choosnim via the reccommended method for unix but bash can’t seem to find the command `choosenim`, any idea how to fix
18:58:36PMunchWhat was the recommended way you followed?
18:58:46PMunchAnd which unix are you on?
18:59:59*luis joined #nim
19:01:00*luis quit (Client Quit)
19:01:34*Onionhammer joined #nim
19:02:13FromDiscord<Require Support> add to your path
19:02:43FromDiscord<Require Support> choosenim tells you at the end of the installation
19:06:32PMunchDepending on your distro you might just be able to install choosenim through your package manager
19:14:50FromDiscord<huantian> Aren’t you on NixOS? choosenim will not work.
19:16:20*ltriant joined #nim
19:17:23FromDiscord<huantian> It’s prob not that it can’t find the binary but rather that it can’t find its dynamically linked libraries
19:21:04*ltriant quit (Ping timeout: 248 seconds)
19:22:21*pbsds8 joined #nim
19:22:40*pbsds quit (Ping timeout: 252 seconds)
19:22:40*pbsds8 is now known as pbsds
19:23:19*Onionhammer quit (Quit: The Lounge - https://thelounge.chat)
19:23:42*Onionhammer joined #nim
19:26:40FromDiscord<ShalokShalom> @thatrandomperson http://gitnim.com/ another alternative
19:48:36*luis joined #nim
19:53:38FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mxz
19:55:14FromDiscord<4zv4l> (edit) "https://play.nim-lang.org/#ix=4mxz" => "https://play.nim-lang.org/#ix=4mxA"
19:59:59*kenran joined #nim
20:12:50FromDiscord<Phil> In reply to @PMunch "Still needs a touch": Prologue and macro magic?
20:13:25FromDiscord<Phil> Just make adding things explicit with procs and you're golden đŸ˜›â†”Slap async request handling and middleware support on top of it and you've got yourself a solid framework !
20:14:23PMunchWell sure, but it requires some type information
20:14:24FromDiscord<Phil> But yeah, the idea of one route producing one specific request-object-type is a really good one
20:14:28PMunchThat's why I said macro magic
20:14:48FromDiscord<Phil> Did you handle that via a generic type?
20:15:18FromDiscord<Phil> So all the "default" information that is always same-y is handled in the general object and then it has one generic object where all the data goes in that can differ between requests?
20:15:24FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mxD
20:15:35FromDiscord<4zv4l> different from block and again ?
20:15:50*azimut_ joined #nim
20:15:56*azimut quit (Ping timeout: 255 seconds)
20:16:53PMunch@Phil, well currently I have it set up to return just my object
20:17:00PMunchOr objects rather
20:17:15FromDiscord<Phil> In reply to @4zv4l "I have my async": You get that when making a request?
20:17:18FromDiscord<Phil> Or when running it in general?
20:17:21FromDiscord<4zv4l> In reply to @Isofruit "You get that when": yes when I connect
20:17:23PMunchBut you'd probably want to wrap everything in a "ServerReply" object or something like that
20:17:25FromDiscord<4zv4l> with a client
20:17:46FromDiscord<Phil> Like just sending a GET request via postman?
20:18:00FromDiscord<4zv4l> with netcat
20:18:09FromDiscord<4zv4l> or with my async client I made yesterday
20:18:50PMunchWhy do you drain the async loop in act?
20:19:07FromDiscord<4zv4l> because I need to wait for the future to finish to close the socket
20:19:22PMunchWhy don't you just run act, store all the futures in a sequence, and then waitFor all the futures?
20:20:50FromDiscord<4zv4l> I see how I would add them in a seq but then I have to loop indefinitely in the sequence until all the future are done ?
20:21:09FromDiscord<4zv4l> if the loop start after one future is added and complete before the second one is added↔it wont wait
20:23:43PMunchSomething like this: https://play.nim-lang.org/#ix=4mxE
20:24:01FromDiscord<Phil> sent a long message, see http://ix.io/4mxF
20:24:07PMunchOh wait, that last await should be a waitFor
20:24:12FromDiscord<Phil> So somewhere you got blocking access to some resource somewhere
20:24:17PMunchSince main isn't async
20:24:45PMunchYou could also just do `waitFor all(futures)` instead of that loop
20:24:48FromDiscord<Phil> Oh yeah on the final root level a Future must be waitFor'd
20:26:05FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mxH
20:26:56FromDiscord<4zv4l> I was trying to see how random would those execution be↔because if I know in advance that I wanna receive and then send↔I don't need async for that
20:28:57FromDiscord<4zv4l> In reply to @Isofruit "For reference: Your OS": kind of deadlock ?
20:29:19FromDiscord<Phil> Not sure, but you're also throwing away the futures that you're adding callbacks to so I'm pretty sure they don't get executed
20:29:37FromDiscord<4zv4l> wdym throwing away ?
20:29:48FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mxK
20:30:14FromDiscord<Phil> You'll notice that I keep a reference to the futures `calledA, calledB` etc. around, just so I can await them
20:30:21FromDiscord<Phil> You immediately call "addCallback" on them
20:30:37FromDiscord<4zv4l> indeed
20:30:46FromDiscord<4zv4l> you mean the gb would just discard them ?
20:30:49FromDiscord<Phil> which syntactically will work, but you're not awaiting the futures themselves, so as far as my basic understanding of async goes their callbacks will never ever execute
20:31:16FromDiscord<4zv4l> In reply to @Isofruit "Here, this is my": I'll try doing something similar
20:31:22FromDiscord<Phil> How I understand nim's async is, that ultimately you have a chain of futures that inevitably always ends in a waitFor
20:31:39FromDiscord<Phil> You can combine them with "all", you can transform them etc.
20:32:00FromDiscord<Phil> But ultimately, that future must somehow be turned into a future that gets `waitFor` called on it somewhere outside of an async block
20:33:49FromDiscord<Phil> In my example code it's not clear, but within the "comboEcho" proc I generate another future that is implicitly linked to the future created by `all([calledA, calledB, calledC])`, since it is only returned once that future completes
20:34:08FromDiscord<Phil> That is the returned future from "comboEcho" that get's "waitFor"'d
20:34:15FromDiscord<Q-Master> Not exactly. AFAIK there's no cancellation if the socket is waiting for data, so callback might be called.
20:37:57FromDiscord<4zv4l> the `await all` what if they don't all have the same future type ?
20:41:41PMunch@4zv4l, that won't work
20:41:46PMunchall requires one type
20:42:40*jmdaemon joined #nim
20:43:13FromDiscord<Phil> Isn't too dramatic if you put 2 await statements directly after one another
20:43:36FromDiscord<Phil> Shouldn't even matter in which order, you'll still be awaiting the complection of both futures
20:45:12FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mxO
20:45:12FromDiscord<4zv4l> is this supposed to be good ?
20:45:21FromDiscord<4zv4l> I guess I did something wrong again
20:45:26FromDiscord<4zv4l> still have an error like before
20:46:07PMunchYou shouldn't discard awaits..
20:46:26FromDiscord<4zv4l> why ?
20:46:43PMunchI think it explains it in the documentation
20:46:59PMunchError handling basically
20:47:55FromDiscord<4zv4l> but if I don't use the return value since it's already in the callback ?
20:50:11FromDiscord<4zv4l> even when I `echo` the return value
20:50:15FromDiscord<4zv4l> I get the exception
20:50:56FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mxS
20:54:28PMunchThat basically means something went wrong with the socket
20:55:18FromDiscord<4zv4l> where do you see that ?
20:55:41FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mxT
20:56:09FromDiscord<Phil> You make your life easier to work focussed on async-await and positioning await well, rather than focussing on callbacks
20:56:37PMunchYeah I'm not sure why you're using callbacks
20:57:01FromDiscord<Phil> Though I'm not 100% how to do it "properly", because I don't think the above actually does anything async other than that it sends 2 requests in parallel (recvLine and send)
20:57:03PMunchBut the error is that the socket didn't return EWOULDBLOCK or EAGAIN which are expected from async sockets, but rather something else
20:57:16FromDiscord<4zv4l> because I guess sometimes `send` will be executed before `recv` and I wanna see that↔without the callback I think they'll always be executed in the same order right ?
20:58:19FromDiscord<4zv4l> the client has no issue tho↔so idk why the server has an issue
20:58:37FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mxV
21:01:53FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mxW
21:03:12FromDiscord<4zv4l> In reply to @Isofruit "For now, this works": this one works indeed
21:03:30*ltriant joined #nim
21:03:51*kenran quit (Remote host closed the connection)
21:04:50FromDiscord<Require Support> is there a websockets lib that isnt async đŸ€”
21:05:39*Qaziquza joined #nim
21:06:40QaziquzaHi! Been a while. I used to be Pyautogui by name. Getting back into using Nim after a while. Can anyone recommend a refresher resource? I used to know Nim pretty well.
21:07:17PMunchOh hi Qaziquza, welcome back
21:07:33PMunchNot sure what kind of thing you're thinking of
21:07:35QaziquzaGlad to be!
21:07:51QaziquzaI'm looking for something like a list of Nim's features with quick examples.
21:08:00QaziquzaSo as to run through them and refresh myself.
21:08:26FromDiscord<Elegantbeef> https://learnxinyminutes.com/docs/nim/
21:08:28PMunchSomething like explainxinyminutes?
21:08:36PMunchAh, learnxinyminutes it was
21:08:41QaziquzaMy thanks, yes, exactly.
21:08:44PMunchFelt wrong typing it out
21:08:49FromDiscord<Elegantbeef> Pmunch is too slow!
21:09:03PMunchI'm drinking drinks and flying rockets in KSP :P
21:09:30FromDiscord<Phil> The most prestigious of space programs
21:09:32FromDiscord<Elegantbeef> Ah ksp, i seen that new juno game and was tempted
21:09:35FromDiscord<Elegantbeef> It has codeblock programming
21:09:54PMunchOh yeah I saw that one
21:10:01PMunchRebranded from simplerockets 2
21:10:09PMunchLooked interesting indeed
21:10:23PMunchBut KSP 2 comes out in under a month
21:10:24FromDiscord<Elegantbeef> Yea the fun part is apparently the career mode is fun
21:10:36PMunchMight have to grab that one as well
21:10:40FromDiscord<Elegantbeef> True but KSP is probably more than 20CAD
21:11:09PMunchActually the reason why I wrote my protobuf library was to use it to program rockets with KSP
21:11:35FromDiscord<Elegantbeef> the fun part about trying to fix a bug in wine and having 0 clue about the proper way to fix a bug
21:11:36PMunchThere was a mod somewhere which just opened a server to send commands to, but the Python library was super clunky
21:11:51PMunchThe answer is obviously more wine
21:11:59PMunchWhat're you trying to run?
21:12:18FromDiscord<Elegantbeef> `sendmsg` is raising a `EINVAL` which should mean the send buffer is too large, but i check it and it's 4 bytes
21:12:30FromDiscord<Elegantbeef> Trying to fix spellforce3
21:12:42FromDiscord<Ntsékees> @pmp-p: I've finally managed to make it work with emcc; for getting `reverse` to be exported I had to add the pragma ` {.exportc.}` to avoid name mangling.
21:12:46FromDiscord<Elegantbeef> I had a bodge fix that made it so single player skirmish could work, but i wanted to try to properly fix it
21:13:39FromDiscord<Elegantbeef> If you're like me and want to export all exported procedures https://github.com/beef331/wasm3/blob/master/src/wasm3/exporter.nim#L1-L19 might work for oyu
21:14:15FromDiscord<Elegantbeef> Though I disable `-sERROR_ON_UNDEFINED_SYMBOLS=0`
21:14:22FromDiscord<NtsĂ©kees> (edit) "mangling." => "mangling.↔(Credit to Mratsim for having pointed this out to me in the Nim forum.)"
21:14:25FromDiscord<Elegantbeef> Actually that's for import
21:15:13PMunchHave you tried running it under Proton?
21:15:18FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mxY
21:15:22FromDiscord<Elegantbeef> But yea pmunch this wine bug is fun cause it makes no sense
21:15:23FromDiscord<Elegantbeef> Of course pmunch
21:15:40FromDiscord<Elegantbeef> There is an issue with wine inside of a wine dll
21:15:49FromDiscord<Elegantbeef> I've found the cause and i have a 'functioning' workaround
21:15:53PMunchI'm actually currently running KSP under Proton because there's a memory leak in the Linux version..
21:16:01PMunchWorks surprisingly well
21:16:13FromDiscord<Elegantbeef> `sendmsg` raises a `EINVAL` which is supposed to mean `The sum of the iov_len values overflows an ssize_t.` but.... it's clearly only 4 bytes
21:19:14FromDiscord<4zv4l> In reply to @Isofruit "For now, this works": but so there are never pending operation since you await every async call right ?
21:20:42FromDiscord<Phil> In the way I wrote it above? No, it's basically sync code.↔You can move the await blocks so that you first do both your calls to generate the futures, so that both futures can start running in parallel, and then await both futures.↔At that point you'll have 2 async operations running side-by-side
21:21:10FromDiscord<4zv4l> like here then ?
21:21:11FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mxZ
21:21:17FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4my0
21:22:06FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4my1
21:22:54FromDiscord<Phil> I had my hand over the enter button before you sent yours so I hadn't compared them yet, give me a sec
21:23:19*Qaziquza quit (Quit: Connection closed)
21:23:31FromDiscord<Phil> Both work and essentially do the same, though yours centered around callbacks rather than awaits
21:23:42FromDiscord<4zv4l> even like this
21:23:44FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4my2
21:23:44FromDiscord<4zv4l> I get the error
21:23:49FromDiscord<4zv4l> even when commenting all callback
21:23:51FromDiscord<4zv4l> I get the error
21:25:18FromDiscord<Phil> Hmmm I don't, strange
21:25:24FromDiscord<4zv4l> makes no sense to me
21:25:25FromDiscord<4zv4l> đŸ„ș
21:25:31FromDiscord<Phil> Like, I just used my version and replaced the act proc
21:25:45FromDiscord<Phil> Nim version 1.6.10 for you I assume?
21:25:56FromDiscord<4zv4l> yes
21:25:58FromDiscord<4zv4l> 1.6.10
21:26:02FromDiscord<4zv4l> how about yours ?
21:26:09FromDiscord<Phil> One sec, take a look at my main proc
21:26:09FromDiscord<4zv4l> In reply to @Isofruit "Like, I just used": did it work ?
21:26:21FromDiscord<Phil> I fiddled around there and waitFor'd the individual calls
21:27:02FromDiscord<Phil> Which I don't think is sensible, but it gets stuff to work
21:27:11FromDiscord<4zv4l> with your main
21:27:12FromDiscord<4zv4l> it works
21:27:19FromDiscord<4zv4l> with my main, it does not
21:27:59*luis quit (Quit: Leaving)
21:29:41FromDiscord<Phil> Yeah, but that is mostly because I essentially don't have them work in parallel there, the loop and the entire proc-chain behind the act proc runs in sync due to the way I set that code up
21:30:02FromDiscord<4zv4l> the act is async↔but the main is sync
21:30:18FromDiscord<Phil> That's fine
21:30:49FromDiscord<Phil> That's why you're using waitFor instead of await
21:31:08FromDiscord<Phil> I don't quite get why the combining of futures and waitforing that appears to be so problematic
21:31:08FromDiscord<4zv4l> why if I wait for `act` outside of the loop suddenly it's not good
21:32:58FromDiscord<4zv4l> maybe
21:33:01*ehmry quit (Ping timeout: 252 seconds)
21:33:08FromDiscord<4zv4l> because the 5 sockets are `accepting` at the same time ?
21:33:18FromDiscord<4zv4l> when a client connects it doesn't know what to do ?
21:33:39FromDiscord<4zv4l> I've no idea
21:33:43*ehmry joined #nim
21:33:50FromDiscord<Phil> I mean, the code-structure is confusing to me
21:34:08FromDiscord<Phil> You are setting the futures for the server acting up before your server gets anything to act on
21:34:23FromDiscord<Phil> These futures from act are instantiated and exist before any request comes in
21:34:54FromDiscord<Phil> In my mental model futures make sense for an operation where you are the initiator and are waiting for something to finish
21:35:16FromDiscord<Phil> That doesn't map cleanly to what this code does, which is waiting for something to happen and then to perform an operation
21:35:34FromDiscord<Phil> Could by I'm not fully understanding futures there but this feels incorrect
21:36:01FromDiscord<4zv4l> In reply to @Isofruit "In my mental model": so like the connection must be done before I start `act` ?
21:36:43FromDiscord<Phil> I think in general you receive a request in "sync-land" from which you spawn an async operation that is to be executed and takes care of the request
21:37:24FromDiscord<Phil> How you set that up with a Socket, no idea, haven't worked with a socket, but it's the idea that you should remain capable of spawning a second request-handler while the first one is being handled that's important.
21:37:37FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4my6
21:37:52FromDiscord<4zv4l> without spawning a thread per client
21:37:55FromDiscord<Phil> let me skim through some of those socket docs
21:39:19FromDiscord<Phil> Did you take a look at the example in the asyncnet lib?
21:39:20FromDiscord<Phil> https://nim-lang.org/docs/asyncnet.html
21:40:01FromDiscord<4zv4l> yeah that's what I'm trying to do now
21:40:05FromDiscord<Phil> There they listen, then in an endless while loop they await for a connection to be created.↔That connection is a request from a client, so the socket spawns you a new thing to do and act on
21:40:07FromDiscord<4zv4l> accept the client in the main loop
21:40:12FromDiscord<4zv4l> then throw them in the async proc
21:40:39FromDiscord<Phil> The `accept` proc seems to me like a key part since that's your starting event that a user is doing something
21:46:35FromDiscord<keks> how does one resize a sequence, eg. setting it to zero?
21:46:46FromDiscord<Elegantbeef> `setLen(0)`
21:48:42FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4my7
21:48:46FromDiscord<4zv4l> @Phil this works
21:48:48FromDiscord<4zv4l> xD
21:49:11FromDiscord<keks> In reply to @Elegantbeef "`setLen(0)`": I'm too used to googling solutions for Python which doesn't work with a less popular language. Thanks!
21:49:27FromDiscord<Phil> Yeah, see, that one makes more sense to me.↔I'd argue you should have a "while true" in there instead of a for-loop, but maybe that works still
21:49:42FromDiscord<4zv4l> you mean to get infinite client ?
21:50:08FromDiscord<4zv4l> here that was so after my client script (which connect 5 times async) would terminate afterward
21:50:08FromDiscord<Elegantbeef> https://nim-lang.org/docs/theindex.html is a good friend keks
21:51:13FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4my8
21:52:10FromDiscord<Phil> To ensure you only handle 5 clients at a time you could count clients currently being handled in a var outside the whileloop.↔Every client you get, you first accept them, then increment the counter, then do your operation and to the future that that operation returns you, you add a callback that decrements the counter
21:53:01FromDiscord<4zv4l> In reply to @Isofruit "To ensure you only": using `{.threadvar.}` pragma then ?
21:53:04FromDiscord<Phil> And you add an if-check immediately after you receive a client connection that checks if your current counter limit is reached or not and just immediately reject it without performing your operation, maybe just sending back "I can't right now" and close reaction
21:53:23FromDiscord<Ducko> (sorry to disrupt) is there any known/established way to embed resources into a binary post-buildtime? can't find anything at least
21:53:28FromDiscord<4zv4l> In reply to @4zv4l "using `{.threadvar.}` pragma then": I don't understand why they use that in the doc since async is in the same thread
21:53:41*PMunch quit (Quit: leaving)
21:53:52FromDiscord<Elegantbeef> Embed post build?
21:53:59FromDiscord<Ducko> In reply to @Elegantbeef "Embed post build?": yeah
21:54:01FromDiscord<Elegantbeef> Why not `staticRead` at CT
21:54:05FromDiscord<Phil> In reply to @Ducko "(sorry to disrupt) is": Not that I'm aware of. You mean like have a binary, then add something to that binary for later retrieval?
21:54:10FromDiscord<Ducko> In reply to @Isofruit "Not that I'm aware": yes
21:54:11FromDiscord<4zv4l> In reply to @Isofruit "And you add an": all this could be avoided if the `listen(5)` would actually work xD
21:54:20FromDiscord<Ducko> In reply to @Elegantbeef "Why not `staticRead` at": for having a generic bootstrap binary
21:54:29FromDiscord<Ducko> (edit) "In reply to @Elegantbeef "Why not `staticRead` at": for having a generic bootstrap binary ... " added "capable of doing things without recompilation"
21:54:39FromDiscord<Phil> In reply to @4zv4l "all this could be": It doesn't?
21:54:41FromDiscord<4zv4l> but the os has another stack to keep client↔(if I understood correctly why it still accept more than the number in `listen()`
21:54:57FromDiscord<Elegantbeef> I dont know much about binary formats but i think you technically can just append data after a binary, but do not quote me on that
21:55:16FromDiscord<Ducko> yeah I can probably find a general way, just wondered if anyone had heard of something like it done with nim previously
21:55:35FromDiscord<Elegantbeef> Most people arent scared of multiple files
21:55:35FromDiscord<Elegantbeef> 😄
21:55:41FromDiscord<Ducko> aha
21:55:46FromDiscord<4zv4l> > The backlog argument defines the maximum length to which the queue of pending connections for sockfd may grow. If a connection request arrives when the queue is full, the client may receive an error with an indication of ECONNREFUSED or, if the underlying protocol supports retransmission, the request may be ignored so that a later reattempt at connection succeeds.
21:55:57FromDiscord<4zv4l> the part `if the underlying protocol supports retransmission` I don't get it
21:56:46FromDiscord<4zv4l> of
21:56:48FromDiscord<4zv4l> (edit) "of" => "oh"
21:56:50FromDiscord<4zv4l> > The backlog argument provides a hint to the implementation which the implementation shall use to limit the number of outstanding connections in the socket's listen queue.↔> ↔> Current versions of the Linux kernel round it up to the next highest power of two, with a minimum of 16. The revelant code is in reqsk_queue_alloc().
21:56:53FromDiscord<4zv4l> probably why
21:57:09FromDiscord<4zv4l> minimum of 16
22:02:55*junaid_ quit (Remote host closed the connection)
22:02:55*junaid___ quit (Remote host closed the connection)
22:02:55*junaid__ quit (Remote host closed the connection)
22:08:47FromDiscord<Phil> Huh, odd
22:08:54FromDiscord<Phil> Like, why would you limit it like that?
22:09:30FromDiscord<Phil> But then again, the people that actually understand what they're doing would likely be asking what the heck you're supposed to be doing with less than 16
22:18:30FromDiscord<4zv4l> In reply to @Isofruit "To ensure you only": to avoid doing this manually ? xD
22:33:04FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4myd
22:33:31FromDiscord<4zv4l> https://media.discordapp.net/attachments/371759389889003532/1069384824298676224/image.png
22:33:41FromDiscord<4zv4l> I didn't think it would skip the callback
22:34:09FromDiscord<4zv4l> looking at the code of it↔it replaces the callback
22:46:19*jjido quit (Quit: My laptop has gone to sleep. ZZZzzz
)
22:53:06*Mister_Magister quit (Ping timeout: 268 seconds)
22:55:24*Mister_Magister joined #nim
23:46:28FromDiscord<Piqueiras> is there a way to make this work? from a to z and add space char https://media.discordapp.net/attachments/371759389889003532/1069403180795965480/image.png
23:47:59FromDiscord<Elegantbeef> Nope arrays have to have contiguous indices
23:49:03FromDiscord<Piqueiras> damn
23:50:45FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4myk
23:51:51*xaltsc joined #nim
23:52:56FromDiscord<Elegantbeef> Luckily you only need the `[]` and `[]=` operators, you then can implement a `toOpenArray` template to convert to `openarray[int]` and be merry
23:53:25FromDiscord<Elegantbeef> I assume you're making a character count table
23:56:08FromDiscord<Piqueiras> could say
23:56:11FromDiscord<Piqueiras> experimenting https://media.discordapp.net/attachments/371759389889003532/1069405632916107284/image.png
23:57:20FromDiscord<Elegantbeef> Interesting 😄