00:13:39 | FromDiscord | <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:48 | FromDiscord | <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:12 | FromDiscord | <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:31 | FromDiscord | <Elegantbeef> It'd produce a string which is passable into `openarray[char]` |
00:18:40 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mtt |
00:18:51 | FromDiscord | <Elegantbeef> Worth noting that a `CountTable` for `char`s is a bit silly |
00:23:58 | FromDiscord | <keks> oh ignore me, I had an unrelated bug.. |
00:25:34 | FromDiscord | <keks> regarding the CountTable for chars - I guess one can just directly do counting in an array. |
00:26:45 | FromDiscord | <Elegantbeef> Yep |
00:27:12 | FromDiscord | <Elegantbeef> `array[char, int]` is much faster than `CountTable` if we're only worried about ascii characters |
00:27:55 | FromDiscord | <Elegantbeef> Otherwise you use `CountTable[Rune]` and get utf8 support đ |
00:32:18 | FromDiscord | <keks> either way is probably fine for AOC day 6 đ |
01:10:15 | FromDiscord | <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:14 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/lua/blob/master/src/lua52.nim#L27 |
01:13:03 | FromDiscord | <spoon> renamed to liblua5.2.so, same error |
01:13:27 | FromDiscord | <spoon> is there a more updated lua library i should be using? |
01:14:01 | FromDiscord | <Elegantbeef> Your search features work aswell as anyone elses |
01:14:41 | FromDiscord | <spoon> i've searched before, just checking for suggestions |
01:31:15 | * | lumo_e joined #nim |
01:46:21 | FromDiscord | <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:01 | FromDiscord | <Elegantbeef> It does work |
01:47:12 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mtI |
01:48:46 | FromDiscord | <auxym> wtf kinda magic is that colon doing D: |
01:49:19 | FromDiscord | <Elegantbeef> Method call syntax limitation |
01:49:20 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/manual.html#templates-limitations-of-the-method-call-syntax |
01:50:47 | FromDiscord | <auxym> oh damn it's just a UFCS thing. I thought it was a generics issue. Great, thanks đ |
01:59:15 | FromDiscord | <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:18 | FromDiscord | <spoon> ah, i see |
02:52:27 | FromDiscord | <spoon> is there a compiler flag i can use to get it to recognize it? |
02:52:46 | FromDiscord | <Rika> i think you can set the env.var LD_LIBRARY_PATH or something |
02:55:33 | FromDiscord | <spoon> not sure if its working, is there a way i can enable logging to view external imports? |
02:56:16 | FromDiscord | <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:48 | FromDiscord | <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:23 | FromDiscord | <pyolyokh> and, looking at nim-lang/lua, the latter's the case. |
03:01:59 | FromDiscord | <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:28 | FromDiscord | <Rika> luaex uses 5.0 or 5.1 |
03:04:13 | FromDiscord | <pyolyokh> yeah, got it to work with lua 5.1 |
03:04:14 | FromDiscord | <Rika> it imports lua not lua52 https://github.com/nim-lang/lua/blob/master/src/lua.nim#L58 |
03:05:21 | FromDiscord | <spoon> lua 5.1? |
03:05:31 | FromDiscord | <Rika> yees |
03:05:32 | FromDiscord | <Rika> (edit) "yees" => "yes" |
03:05:35 | FromDiscord | <Rika> or 5.0 |
03:05:54 | FromDiscord | <spoon> theres also lua52.nim |
03:06:52 | FromDiscord | <pyolyokh> and lua52.nim is bitrotten and won't compile with 1.6.10 or devel |
03:07:16 | FromDiscord | <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:21 | FromDiscord | <Tuatarian> Hey guys |
06:12:02 | om3ga | I made network packets parser-reassembler based on PMunch's nim-pcap bindings. |
06:14:01 | om3ga | Works well, fast, almost like our C version. I like how Nim makes coding faster |
06:16:25 | om3ga | so it took around 2-3 days, and C version used reassembly function from 3rd party lib |
07:54:53 | termer | sweet |
07:55:05 | termer | The speed of writing nim is pretty good |
07:55:19 | termer | I tend to be able to write nim at a similar speed as node.js which I'm very proficient in |
07:55:25 | termer | although lack of libraries slows down some tasks |
08:42:43 | * | ltriant joined #nim |
09:00:51 | * | jmdaemon quit (Ping timeout: 260 seconds) |
09:28:17 | FromDiscord | <pmp-p> i think the discussion may interest people using emscripten builds https://github.com/hoodmane/libffi-emscripten/pull/20 |
09:29:11 | FromDiscord | <pmp-p> ( without WASM_BIGINT 64bits parameters are split in 2x32 in exports/exports wasm tables ) |
09:29:14 | * | krux02 joined #nim |
09:30:18 | FromDiscord | <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:29 | FromDiscord | <pmp-p> @Ntsékees why would you want to load without emscripten glue the nim wasm if you used emscripten profile ? |
10:32:59 | FromDiscord | <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:19 | FromDiscord | <Ntsékees> Okay. |
10:33:53 | FromDiscord | <pmp-p> wasi will just require a handfull of function and an empty map for ENV |
10:34:02 | FromDiscord | <pmp-p> it's still human readable |
10:35:10 | FromDiscord | <pmp-p> eg a light one here https://github.com/bjorn3/browser_wasi_shim |
10:35:56 | FromDiscord | <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:36 | FromDiscord | <Ntsékees> but well |
10:36:38 | FromDiscord | <pmp-p> i guess you did emcc -o out.wasm |
10:36:47 | FromDiscord | <Ntsékees> yeah |
10:37:05 | FromDiscord | <pmp-p> that's standalone mode |
10:37:19 | FromDiscord | <pmp-p> much closer to wasi |
10:38:09 | FromDiscord | <pmp-p> but as soon as you -o to html you bring stdio in |
10:38:53 | FromDiscord | <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:08 | FromDiscord | <Ntsékees> (edit) "`--ne-entry`" => "`--no-entry`" |
10:40:08 | FromDiscord | <pmp-p> to export use `-Wl,--export-all` |
10:40:42 | FromDiscord | <pmp-p> and for reactor mode if using clang15+ then `-Wl,--no-entry -mexec-model=reactor` |
10:40:49 | FromDiscord | <Ntsékees> (`--no-entry` because my code has no `main` function) |
10:41:53 | FromDiscord | <pmp-p> main is only required if _start is called |
10:53:28 | FromDiscord | <HappySeal> Hi guys |
10:53:45 | FromDiscord | <HappySeal> How could I install faster_than_requests package? |
10:55:16 | FromDiscord | <HappySeal> Tried pip install multiple times but it just show version not found |
10:56:11 | FromDiscord | <pmp-p> try nimble install maybe ? |
10:56:31 | FromDiscord | <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:08 | FromDiscord | <pmp-p> but if it's python then : pip install git+url |
10:58:44 | FromDiscord | <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:05 | FromDiscord | <HappySeal> thanks, trying it |
10:59:23 | FromDiscord | <Ntsékees> https://media.discordapp.net/attachments/371759389889003532/1069210140428996618/test.zip |
11:00:12 | FromDiscord | <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:45 | FromDiscord | <Ntsékees> before loading view.html, I run a server with `python3 -m http.server` |
11:01:05 | FromDiscord | <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:12 | FromDiscord | <HappySeal> https://media.discordapp.net/attachments/371759389889003532/1069210595058012271/image.png |
11:01:15 | FromDiscord | <pmp-p> you will have to download , unzip |
11:01:22 | FromDiscord | <pmp-p> go into folder and do : pip install . |
11:01:23 | FromDiscord | <HappySeal> I tried run on colab, but not working |
11:01:38 | FromDiscord | <pmp-p> (edit) "go into folder and do : pip install . ... " added " (from where the setup.py is located )" |
11:02:18 | FromDiscord | <HappySeal> In reply to @pmp-p "go into folder and": let me have a look |
11:03:06 | FromDiscord | <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:16 | FromDiscord | <HappySeal> đ Could not find setup or dependency files |
11:03:32 | FromDiscord | <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:47 | FromDiscord | <HappySeal> oh, I see, let me try it |
11:05:28 | FromDiscord | <HappySeal> btw, is there any alternatives like request post but much faster? |
11:08:21 | FromDiscord | <HappySeal> strange |
11:08:22 | FromDiscord | <HappySeal> https://media.discordapp.net/attachments/371759389889003532/1069212400714272788/image.png |
11:08:55 | FromDiscord | <pmp-p> In reply to @HappySeal "": did you use `pip install .` |
11:09:41 | FromDiscord | <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:50 | FromDiscord | <Ntsékees> sent a code paste, see https://play.nim-lang.org/#ix=4muL |
11:11:03 | FromDiscord | <HappySeal> In reply to @pmp-p "did you use `pip": I tried to run setup script in colab, but it returned error |
11:11:14 | FromDiscord | <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:10 | FromDiscord | <demotomohiro> If you want to use Nim on google colab: https://github.com/demotomohiro/nim4colab |
11:45:43 | FromDiscord | <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:24 | FromDiscord | <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:25 | FromDiscord | <pmp-p> emcc is really not happy with --noentry |
12:09:10 | FromDiscord | <planetis> See treeform's emscripten tutorial |
12:15:13 | * | luis joined #nim |
12:16:00 | FromDiscord | <pmp-p> In reply to @planetis "See treeform's emscripten tutorial": what for ? |
12:17:47 | FromDiscord | <pmp-p> seems to me that @Ntsékees is trying to make a javascript/wasm callable library not an app |
12:18:39 | FromDiscord | <planetis> And it still has a main? |
12:18:59 | FromDiscord | <pmp-p> it should not, but emcc can be real stubborn sometimes |
12:19:11 | FromDiscord | <pmp-p> wasm-ld will look for it |
12:19:19 | FromDiscord | <Ntsékees> I've not figured how to implement main(). I get errors on redefinition of `main`. |
12:19:42 | FromDiscord | <pmp-p> In reply to @Ntsékees "I've not figured how": same there |
12:19:56 | FromDiscord | <pmp-p> while wasi sdk has no such problem |
12:20:15 | * | ltriant quit (Ping timeout: 248 seconds) |
12:20:25 | FromDiscord | <planetis> I cannot open the zip but can you try --noMain\:off |
12:21:15 | FromDiscord | <pmp-p> In reply to @planetis "I cannot open the": yeah nailed it |
12:22:21 | FromDiscord | <pmp-p> sent a code paste, see https://play.nim-lang.org/#ix=4mv2 |
12:22:25 | FromDiscord | <pmp-p> thx @planetis |
12:22:41 | FromDiscord | <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:15 | FromDiscord | <planetis> But that wasn't a library it just loaded the shared library from java and run main |
12:25:22 | FromDiscord | <Ntsékees> sent a long message, see http://ix.io/4mv5 |
12:25:45 | FromDiscord | <Ntsékees> (edit) "long message," => "code paste," | "http://ix.io/4mv5" => "https://play.nim-lang.org/#ix=4mv6" |
12:25:58 | FromDiscord | <pmp-p> nah just remove that main, and add the noMain swtich to your .nims |
12:26:06 | FromDiscord | <Ntsékees> Ah |
12:26:09 | FromDiscord | <pmp-p> (edit) "swtich" => "switch" |
12:26:49 | FromDiscord | <pmp-p> i used it too on wasi but i missed it |
12:30:50 | FromDiscord | <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:56 | FromDiscord | <Ntsékees> (edit) "accept" => "accepts" |
12:31:41 | FromDiscord | <pmp-p> yes because _reverse is for the js trampoline |
12:31:53 | FromDiscord | <pmp-p> while your wasm export would be "reverse" |
12:33:02 | FromDiscord | <pmp-p> haha libstandalonewasm.a has a hard dependancy on main() |
12:33:34 | * | krux02 quit (Remote host closed the connection) |
12:33:41 | FromDiscord | <pmp-p> personnaly i'll stick to wasi đ |
12:33:58 | FromDiscord | <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:45 | FromDiscord | <pmp-p> tbh emscripten is only usefull for an app or if you need to dlopen() |
12:35:19 | * | krux02 joined #nim |
12:35:21 | FromDiscord | <Ntsékees> I chose Emscripten because it was the only one I had found usage examples with Nim |
12:35:24 | FromDiscord | <pmp-p> wasi build is smaller and super easy to test with numerous wasi runtimes around |
12:38:56 | FromDiscord | <Ntsékees> Could you show me which command line you use for telling Nim to use WASI as its backend? |
12:42:29 | FromDiscord | <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:52 | FromDiscord | <keks> sent a long message, see http://ix.io/4mvd |
12:51:48 | FromDiscord | <keks> (edit) "long message," => "code paste," | "http://ix.io/4mvd" => "https://play.nim-lang.org/#ix=4mve" |
12:52:08 | FromDiscord | <keks> (edit) "https://play.nim-lang.org/#ix=4mve" => "https://play.nim-lang.org/#ix=4mvf" |
13:15:39 | FromDiscord | <leorize> nope but there's a trick that don't involves proc |
13:15:46 | FromDiscord | <auxym> In reply to @keks "Is it possible to": yes, using a a block |
13:15:54 | FromDiscord | <auxym> if I'm understanding correctly |
13:16:42 | FromDiscord | <leorize> though for your case a `find`-like proc is probably better |
13:16:49 | FromDiscord | <auxym> here, pmunch's excellent article: https://peterme.net/tips-and-tricks-with-implicit-return-in-nim.html |
13:17:03 | FromDiscord | <leorize> if you want to build a seq, see `sugar.collect` |
13:18:51 | PMunch | @auxym, thank you :) |
13:19:40 | PMunch | @keks, it's possible without the proc wrapper, but if you want an early return it's not very much more convenient |
13:20:26 | FromDiscord | <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:57 | PMunch | Looks a bit like this: https://play.nim-lang.org/#ix=4mvm |
13:22:53 | FromDiscord | <leorize> byaddr is a temporary workaround for the lack of views in nim |
13:22:54 | FromDiscord | <leorize> they should be deprecated by the time views are a thing |
13:24:41 | FromDiscord | <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:36 | FromDiscord | <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:36 | FromDiscord | <planetis> If you need an alias just write an .alias template. Though its not always the same |
14:17:03 | FromDiscord | <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:26 | FromDiscord | <pmp-p> (edit) "--sysroot=" => "--sysroot=${WASI_SDK_PATH}/share/wasi-sysroot" |
14:20:26 | FromDiscord | <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:14 | PMunch | For % you just have to define a `proc \`%\`(x: DateTime): JsonNode` I believe |
14:24:09 | FromDiscord | <Phil> (Mandatory disclaimer from me that jsony is faster and imo easier to deal with) |
14:34:33 | FromDiscord | <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:37 | FromDiscord | <auxym> http://nim-lang.github.io/Nim/enumutils.html#items.i%2Ctypedesc%5BT%5D |
14:35:40 | FromDiscord | <matrix07012> Thanks, that's probably betterâ”And can you iterate over object attributes?â”(@Phil) |
14:37:48 | FromDiscord | <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:12 | FromDiscord | <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:38 | FromDiscord | <matrix07012> Nim objectsâ”(@Phil) |
14:39:16 | FromDiscord | <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:30 | FromDiscord | <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:12 | FromDiscord | <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:22 | FromDiscord | <matrix07012> I want to use it to modify the dataâ”(@Phil) |
14:42:50 | FromDiscord | <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:21 | FromDiscord | <matrix07012> Yepâ”(@Phil) |
14:43:24 | FromDiscord | <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:06 | FromDiscord | <matrix07012> Thanks, that should work. I must have missed it when scrolling through docs |
14:46:54 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mvT |
14:47:46 | FromDiscord | <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:26 | FromDiscord | <Require Support> is there a way to represent a pointer as an int in nim? |
14:48:27 | * | krux02 joined #nim |
14:48:40 | PMunch | @Require_Support, yes |
14:49:29 | FromDiscord | <Require Support> In reply to @PMunch "@Require_Support, yes": help is needed đ |
14:49:47 | PMunch | Oh |
14:49:55 | PMunch | `cast[int](somePtr)` |
14:50:04 | FromDiscord | <Require Support> oh... |
14:50:49 | FromDiscord | <matrix07012> Thanks for the reminder, I would have forgotten and used if đ
â”(@Phil) |
14:50:52 | PMunch | You might also want to check out: https://github.com/kaushalmodi/ptr_math |
14:51:05 | * | krux02 quit (Remote host closed the connection) |
14:51:17 | FromDiscord | <Require Support> yep, imported already. Thanks kind soul |
14:51:44 | FromDiscord | <@thatrandomperson5-6310e3b26da03> https://nim-lang.org/docs/importutils.html Not working, i still canât acess the private feild |
14:51:47 | FromDiscord | <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:26 | FromDiscord | <matrix07012> Oh, yeah I doâ”(@Phil) |
14:54:39 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mvV |
14:56:50 | FromDiscord | <matrix07012> This won't work at runtime though? |
14:56:54 | FromDiscord | <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:20 | FromDiscord | <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:33 | FromDiscord | <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:57 | FromDiscord | <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:46 | FromDiscord | <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:43 | FromDiscord | <@thatrandomperson5-6310e3b26da03> Thanks!â”(@Phil) |
15:01:19 | FromDiscord | <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:08 | FromDiscord | <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:08 | FromDiscord | <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:37 | FromDiscord | <Phil> sent a long message, see http://ix.io/4mwh |
15:39:27 | FromDiscord | <Duskhorn The Eclipsed> oh, cool |
15:39:30 | FromDiscord | <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:33 | FromDiscord | <Phil> https://nim-lang.org/blog/2020/10/15/introduction-to-arc-orc-in-nim.html |
15:39:58 | FromDiscord | <Duskhorn The Eclipsed> so ORC is ARC but with a lightweight "GC" that only checks for cycles? |
15:40:44 | FromDiscord | <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:49 | FromDiscord | <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:52 | FromDiscord | <Duskhorn The Eclipsed> (at least, to me) |
15:41:24 | FromDiscord | <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:27 | FromDiscord | <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:40 | FromDiscord | <Phil> (edit) "fully deterministic" => "fully deterministic" | "automatically" => "automatically" | "destructors" => "destructors" |
15:41:47 | FromDiscord | <Duskhorn The Eclipsed> oh I see now, "the compiler" |
15:41:53 | FromDiscord | <Duskhorn The Eclipsed> gotcha, thank you! |
15:42:18 | * | ltriant joined #nim |
15:43:54 | FromDiscord | <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:39 | FromDiscord | <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:11 | FromDiscord | <Phil> But I do webdev, not gamedev, so other folks might have something else to say about that. |
15:46:52 | FromDiscord | <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:10 | FromDiscord | <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:01 | FromDiscord | <Duskhorn The Eclipsed> In reply to @frobnicate "A classic could be": yeah true! Actually, doubly linked lists for example |
15:52:08 | FromDiscord | <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:23 | FromDiscord | <Duskhorn The Eclipsed> In reply to @jtv "Yes they happen all": true, that's kinda painful. But thanks! |
15:59:05 | FromDiscord | <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:13 | FromDiscord | <@thatrandomperson5-6310e3b26da03> I still canât acess private feilds from httpclient, i tried importutils and some macro magic, neither worked. |
16:29:29 | FromDiscord | <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:53 | FromDiscord | <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:26 | FromDiscord | <@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:46 | FromDiscord | <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:51 | FromDiscord | <@thatrandomperson5-6310e3b26da03> What do you mean? Im trying setting the private fieldâ”(@Phil) |
16:42:11 | FromDiscord | <Phil> Why not set it when you create the client? |
16:42:18 | FromDiscord | <@thatrandomperson5-6310e3b26da03> Oh, nvm, the lib will probably need to read from it but i will not |
16:44:20 | FromDiscord | <@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:33 | FromDiscord | <Phil> Ahhh check, I'll play around a bit |
16:46:21 | FromDiscord | <Phil> Well, it works under 1.9.1, but not under 1.6.10 |
16:47:03 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mwC |
16:47:15 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4mwC" => "https://play.nim-lang.org/#ix=4mwD" |
16:50:24 | FromDiscord | <@thatrandomperson5-6310e3b26da03> I can get devl, thought i might need this, thanks!â”(@Phil) |
16:51:04 | FromDiscord | <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:21 | FromDiscord | <Phil> So might be that you need to do --mm:refc |
16:51:31 | FromDiscord | <Phil> (edit) "do" => "add the" | "add the--mm:refc ... " added "flag to your compile command" |
16:51:41 | FromDiscord | <@thatrandomperson5-6310e3b26da03> \:thumbsup\: |
16:55:59 | FromDiscord | <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:16 | FromDiscord | <Phil> (edit) "package" => "package, though I didn't make use of it yet myself." |
17:05:49 | FromDiscord | <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:10 | FromDiscord | <Phil> I'm not sure how that'd work, nodejs code will only ever access other js code, no? |
17:07:34 | FromDiscord | <Phil> Or does JS suddenly have a way to call C procs that I dont know about? |
17:08:27 | FromDiscord | <hips> In reply to @Isofruit "I'm not sure how": I was thinking to just use the nim compiled binary |
17:09:01 | FromDiscord | <hips> alternative would be setting up a webserver in nim and have those 2 talk internally |
17:09:06 | FromDiscord | <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:36 | FromDiscord | <Phil> (edit) "binary?â”Or" => "library file?â”Or" |
17:10:30 | FromDiscord | <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:30 | FromDiscord | <Phil> sent a long message, see http://ix.io/4mwN |
17:15:51 | FromDiscord | <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:31 | FromDiscord | <hips> sent a long message, see http://ix.io/4mwO |
17:20:32 | FromDiscord | <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:00 | FromDiscord | <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:40 | FromDiscord | <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:08 | FromDiscord | <matrix07012> sent a code paste, see https://play.nim-lang.org/#ix=4mwU |
17:36:29 | FromDiscord | <Rika> DateTime is not a ref |
17:36:33 | FromDiscord | <Rika> obj1 is a ref |
17:39:23 | FromDiscord | <Ntsékees> sent a code paste, see https://play.nim-lang.org/#ix=4mwV |
17:42:02 | FromDiscord | <matrix07012> Can I somehow figure out if date is uninitialized? |
17:42:05 | FromDiscord | <matrix07012> ooohâ”Can I somehow figure out if date is uninitialized? |
17:42:07 | FromDiscord | <matrix07012> ooohâ”Can I somehow figure out if foo.date is uninitialized? |
17:42:07 | FromDiscord | <pmp-p> In reply to @Ntsékees "I'm getting an error:": ha pointer size is 4 |
17:42:36 | FromDiscord | <pmp-p> In reply to @Ntsékees "I'm getting an error:": add `--cpu:wasm32` somewhere |
17:43:22 | FromDiscord | <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:44 | FromDiscord | <matrix07012> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/1069311474457137235): ooohâ”Can I somehow figure out if a field is uninitialized? |
17:44:30 | FromDiscord | <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:16 | FromDiscord | <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:34 | FromDiscord | <pmp-p> yeah that's emscripten idiomatics |
17:46:42 | FromDiscord | <NtsĂ©kees> (edit) "reverse.c" => "-Os -s STANDALONE_WASM -s EXPORTED_FUNCTIONS="['_reverse']" -Wl,--no-entry "reverse.c"" | "reverse.wasmâ”>" => ""reverse.wasm"â”>" |
17:46:50 | FromDiscord | <Ntsékees> ah |
17:46:50 | FromDiscord | <pmp-p> you should do your -d:wasi section |
17:47:03 | FromDiscord | <pmp-p> and try to PR that |
17:47:31 | FromDiscord | <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:30 | FromDiscord | <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:24 | FromDiscord | <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:43 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mx2 |
18:07:02 | FromDiscord | <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:30 | PMunch | Just deployed my Nim/HTMX home automation dashboard :) |
18:29:42 | PMunch | It's based on my idea of type-based web-servers |
18:29:58 | FromDiscord | <Rika> type based in what sense |
18:30:07 | PMunch | Essentially leveraging cool Nim features to have each route be tied to a type |
18:30:32 | PMunch | So when you do `GET /something/here` that is tied to a specific type on the server |
18:30:39 | PMunch | So that route can never return another type |
18:31:27 | PMunch | Which 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:28 | PMunch | The 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:13 | PMunch | And 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:36 | PMunch | So 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:24 | PMunch | And 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:27 | PMunch | It's pretty neat |
18:36:14 | PMunch | Still 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:35 | PMunch | I 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:17 | FromDiscord | <@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:36 | PMunch | What was the recommended way you followed? |
18:58:46 | PMunch | And 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:13 | FromDiscord | <Require Support> add to your path |
19:02:43 | FromDiscord | <Require Support> choosenim tells you at the end of the installation |
19:06:32 | PMunch | Depending on your distro you might just be able to install choosenim through your package manager |
19:14:50 | FromDiscord | <huantian> Arenât you on NixOS? choosenim will not work. |
19:16:20 | * | ltriant joined #nim |
19:17:23 | FromDiscord | <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:40 | FromDiscord | <ShalokShalom> @thatrandomperson http://gitnim.com/ another alternative |
19:48:36 | * | luis joined #nim |
19:53:38 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mxz |
19:55:14 | FromDiscord | <4zv4l> (edit) "https://play.nim-lang.org/#ix=4mxz" => "https://play.nim-lang.org/#ix=4mxA" |
19:59:59 | * | kenran joined #nim |
20:12:50 | FromDiscord | <Phil> In reply to @PMunch "Still needs a touch": Prologue and macro magic? |
20:13:25 | FromDiscord | <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:23 | PMunch | Well sure, but it requires some type information |
20:14:24 | FromDiscord | <Phil> But yeah, the idea of one route producing one specific request-object-type is a really good one |
20:14:28 | PMunch | That's why I said macro magic |
20:14:48 | FromDiscord | <Phil> Did you handle that via a generic type? |
20:15:18 | FromDiscord | <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:24 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mxD |
20:15:35 | FromDiscord | <4zv4l> different from block and again ? |
20:15:50 | * | azimut_ joined #nim |
20:15:56 | * | azimut quit (Ping timeout: 255 seconds) |
20:16:53 | PMunch | @Phil, well currently I have it set up to return just my object |
20:17:00 | PMunch | Or objects rather |
20:17:15 | FromDiscord | <Phil> In reply to @4zv4l "I have my async": You get that when making a request? |
20:17:18 | FromDiscord | <Phil> Or when running it in general? |
20:17:21 | FromDiscord | <4zv4l> In reply to @Isofruit "You get that when": yes when I connect |
20:17:23 | PMunch | But you'd probably want to wrap everything in a "ServerReply" object or something like that |
20:17:25 | FromDiscord | <4zv4l> with a client |
20:17:46 | FromDiscord | <Phil> Like just sending a GET request via postman? |
20:18:00 | FromDiscord | <4zv4l> with netcat |
20:18:09 | FromDiscord | <4zv4l> or with my async client I made yesterday |
20:18:50 | PMunch | Why do you drain the async loop in act? |
20:19:07 | FromDiscord | <4zv4l> because I need to wait for the future to finish to close the socket |
20:19:22 | PMunch | Why don't you just run act, store all the futures in a sequence, and then waitFor all the futures? |
20:20:50 | FromDiscord | <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:09 | FromDiscord | <4zv4l> if the loop start after one future is added and complete before the second one is addedâ”it wont wait |
20:23:43 | PMunch | Something like this: https://play.nim-lang.org/#ix=4mxE |
20:24:01 | FromDiscord | <Phil> sent a long message, see http://ix.io/4mxF |
20:24:07 | PMunch | Oh wait, that last await should be a waitFor |
20:24:12 | FromDiscord | <Phil> So somewhere you got blocking access to some resource somewhere |
20:24:17 | PMunch | Since main isn't async |
20:24:45 | PMunch | You could also just do `waitFor all(futures)` instead of that loop |
20:24:48 | FromDiscord | <Phil> Oh yeah on the final root level a Future must be waitFor'd |
20:26:05 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mxH |
20:26:56 | FromDiscord | <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:57 | FromDiscord | <4zv4l> In reply to @Isofruit "For reference: Your OS": kind of deadlock ? |
20:29:19 | FromDiscord | <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:37 | FromDiscord | <4zv4l> wdym throwing away ? |
20:29:48 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mxK |
20:30:14 | FromDiscord | <Phil> You'll notice that I keep a reference to the futures `calledA, calledB` etc. around, just so I can await them |
20:30:21 | FromDiscord | <Phil> You immediately call "addCallback" on them |
20:30:37 | FromDiscord | <4zv4l> indeed |
20:30:46 | FromDiscord | <4zv4l> you mean the gb would just discard them ? |
20:30:49 | FromDiscord | <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:16 | FromDiscord | <4zv4l> In reply to @Isofruit "Here, this is my": I'll try doing something similar |
20:31:22 | FromDiscord | <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:39 | FromDiscord | <Phil> You can combine them with "all", you can transform them etc. |
20:32:00 | FromDiscord | <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:49 | FromDiscord | <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:08 | FromDiscord | <Phil> That is the returned future from "comboEcho" that get's "waitFor"'d |
20:34:15 | FromDiscord | <Q-Master> Not exactly. AFAIK there's no cancellation if the socket is waiting for data, so callback might be called. |
20:37:57 | FromDiscord | <4zv4l> the `await all` what if they don't all have the same future type ? |
20:41:41 | PMunch | @4zv4l, that won't work |
20:41:46 | PMunch | all requires one type |
20:42:40 | * | jmdaemon joined #nim |
20:43:13 | FromDiscord | <Phil> Isn't too dramatic if you put 2 await statements directly after one another |
20:43:36 | FromDiscord | <Phil> Shouldn't even matter in which order, you'll still be awaiting the complection of both futures |
20:45:12 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mxO |
20:45:12 | FromDiscord | <4zv4l> is this supposed to be good ? |
20:45:21 | FromDiscord | <4zv4l> I guess I did something wrong again |
20:45:26 | FromDiscord | <4zv4l> still have an error like before |
20:46:07 | PMunch | You shouldn't discard awaits.. |
20:46:26 | FromDiscord | <4zv4l> why ? |
20:46:43 | PMunch | I think it explains it in the documentation |
20:46:59 | PMunch | Error handling basically |
20:47:55 | FromDiscord | <4zv4l> but if I don't use the return value since it's already in the callback ? |
20:50:11 | FromDiscord | <4zv4l> even when I `echo` the return value |
20:50:15 | FromDiscord | <4zv4l> I get the exception |
20:50:56 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mxS |
20:54:28 | PMunch | That basically means something went wrong with the socket |
20:55:18 | FromDiscord | <4zv4l> where do you see that ? |
20:55:41 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mxT |
20:56:09 | FromDiscord | <Phil> You make your life easier to work focussed on async-await and positioning await well, rather than focussing on callbacks |
20:56:37 | PMunch | Yeah I'm not sure why you're using callbacks |
20:57:01 | FromDiscord | <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:03 | PMunch | But the error is that the socket didn't return EWOULDBLOCK or EAGAIN which are expected from async sockets, but rather something else |
20:57:16 | FromDiscord | <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:19 | FromDiscord | <4zv4l> the client has no issue thoâ”so idk why the server has an issue |
20:58:37 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mxV |
21:01:53 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mxW |
21:03:12 | FromDiscord | <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:50 | FromDiscord | <Require Support> is there a websockets lib that isnt async đ€ |
21:05:39 | * | Qaziquza joined #nim |
21:06:40 | Qaziquza | Hi! 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:17 | PMunch | Oh hi Qaziquza, welcome back |
21:07:33 | PMunch | Not sure what kind of thing you're thinking of |
21:07:35 | Qaziquza | Glad to be! |
21:07:51 | Qaziquza | I'm looking for something like a list of Nim's features with quick examples. |
21:08:00 | Qaziquza | So as to run through them and refresh myself. |
21:08:26 | FromDiscord | <Elegantbeef> https://learnxinyminutes.com/docs/nim/ |
21:08:28 | PMunch | Something like explainxinyminutes? |
21:08:36 | PMunch | Ah, learnxinyminutes it was |
21:08:41 | Qaziquza | My thanks, yes, exactly. |
21:08:44 | PMunch | Felt wrong typing it out |
21:08:49 | FromDiscord | <Elegantbeef> Pmunch is too slow! |
21:09:03 | PMunch | I'm drinking drinks and flying rockets in KSP :P |
21:09:30 | FromDiscord | <Phil> The most prestigious of space programs |
21:09:32 | FromDiscord | <Elegantbeef> Ah ksp, i seen that new juno game and was tempted |
21:09:35 | FromDiscord | <Elegantbeef> It has codeblock programming |
21:09:54 | PMunch | Oh yeah I saw that one |
21:10:01 | PMunch | Rebranded from simplerockets 2 |
21:10:09 | PMunch | Looked interesting indeed |
21:10:23 | PMunch | But KSP 2 comes out in under a month |
21:10:24 | FromDiscord | <Elegantbeef> Yea the fun part is apparently the career mode is fun |
21:10:36 | PMunch | Might have to grab that one as well |
21:10:40 | FromDiscord | <Elegantbeef> True but KSP is probably more than 20CAD |
21:11:09 | PMunch | Actually the reason why I wrote my protobuf library was to use it to program rockets with KSP |
21:11:35 | FromDiscord | <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:36 | PMunch | There was a mod somewhere which just opened a server to send commands to, but the Python library was super clunky |
21:11:51 | PMunch | The answer is obviously more wine |
21:11:59 | PMunch | What're you trying to run? |
21:12:18 | FromDiscord | <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:30 | FromDiscord | <Elegantbeef> Trying to fix spellforce3 |
21:12:42 | FromDiscord | <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:46 | FromDiscord | <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:39 | FromDiscord | <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:15 | FromDiscord | <Elegantbeef> Though I disable `-sERROR_ON_UNDEFINED_SYMBOLS=0` |
21:14:22 | FromDiscord | <NtsĂ©kees> (edit) "mangling." => "mangling.â”(Credit to Mratsim for having pointed this out to me in the Nim forum.)" |
21:14:25 | FromDiscord | <Elegantbeef> Actually that's for import |
21:15:13 | PMunch | Have you tried running it under Proton? |
21:15:18 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mxY |
21:15:22 | FromDiscord | <Elegantbeef> But yea pmunch this wine bug is fun cause it makes no sense |
21:15:23 | FromDiscord | <Elegantbeef> Of course pmunch |
21:15:40 | FromDiscord | <Elegantbeef> There is an issue with wine inside of a wine dll |
21:15:49 | FromDiscord | <Elegantbeef> I've found the cause and i have a 'functioning' workaround |
21:15:53 | PMunch | I'm actually currently running KSP under Proton because there's a memory leak in the Linux version.. |
21:16:01 | PMunch | Works surprisingly well |
21:16:13 | FromDiscord | <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:14 | FromDiscord | <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:42 | FromDiscord | <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:10 | FromDiscord | <4zv4l> like here then ? |
21:21:11 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mxZ |
21:21:17 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4my0 |
21:22:06 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4my1 |
21:22:54 | FromDiscord | <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:31 | FromDiscord | <Phil> Both work and essentially do the same, though yours centered around callbacks rather than awaits |
21:23:42 | FromDiscord | <4zv4l> even like this |
21:23:44 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4my2 |
21:23:44 | FromDiscord | <4zv4l> I get the error |
21:23:49 | FromDiscord | <4zv4l> even when commenting all callback |
21:23:51 | FromDiscord | <4zv4l> I get the error |
21:25:18 | FromDiscord | <Phil> Hmmm I don't, strange |
21:25:24 | FromDiscord | <4zv4l> makes no sense to me |
21:25:25 | FromDiscord | <4zv4l> đ„ș |
21:25:31 | FromDiscord | <Phil> Like, I just used my version and replaced the act proc |
21:25:45 | FromDiscord | <Phil> Nim version 1.6.10 for you I assume? |
21:25:56 | FromDiscord | <4zv4l> yes |
21:25:58 | FromDiscord | <4zv4l> 1.6.10 |
21:26:02 | FromDiscord | <4zv4l> how about yours ? |
21:26:09 | FromDiscord | <Phil> One sec, take a look at my main proc |
21:26:09 | FromDiscord | <4zv4l> In reply to @Isofruit "Like, I just used": did it work ? |
21:26:21 | FromDiscord | <Phil> I fiddled around there and waitFor'd the individual calls |
21:27:02 | FromDiscord | <Phil> Which I don't think is sensible, but it gets stuff to work |
21:27:11 | FromDiscord | <4zv4l> with your main |
21:27:12 | FromDiscord | <4zv4l> it works |
21:27:19 | FromDiscord | <4zv4l> with my main, it does not |
21:27:59 | * | luis quit (Quit: Leaving) |
21:29:41 | FromDiscord | <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:02 | FromDiscord | <4zv4l> the act is asyncâ”but the main is sync |
21:30:18 | FromDiscord | <Phil> That's fine |
21:30:49 | FromDiscord | <Phil> That's why you're using waitFor instead of await |
21:31:08 | FromDiscord | <Phil> I don't quite get why the combining of futures and waitforing that appears to be so problematic |
21:31:08 | FromDiscord | <4zv4l> why if I wait for `act` outside of the loop suddenly it's not good |
21:32:58 | FromDiscord | <4zv4l> maybe |
21:33:01 | * | ehmry quit (Ping timeout: 252 seconds) |
21:33:08 | FromDiscord | <4zv4l> because the 5 sockets are `accepting` at the same time ? |
21:33:18 | FromDiscord | <4zv4l> when a client connects it doesn't know what to do ? |
21:33:39 | FromDiscord | <4zv4l> I've no idea |
21:33:43 | * | ehmry joined #nim |
21:33:50 | FromDiscord | <Phil> I mean, the code-structure is confusing to me |
21:34:08 | FromDiscord | <Phil> You are setting the futures for the server acting up before your server gets anything to act on |
21:34:23 | FromDiscord | <Phil> These futures from act are instantiated and exist before any request comes in |
21:34:54 | FromDiscord | <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:16 | FromDiscord | <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:34 | FromDiscord | <Phil> Could by I'm not fully understanding futures there but this feels incorrect |
21:36:01 | FromDiscord | <4zv4l> In reply to @Isofruit "In my mental model": so like the connection must be done before I start `act` ? |
21:36:43 | FromDiscord | <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:24 | FromDiscord | <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:37 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4my6 |
21:37:52 | FromDiscord | <4zv4l> without spawning a thread per client |
21:37:55 | FromDiscord | <Phil> let me skim through some of those socket docs |
21:39:19 | FromDiscord | <Phil> Did you take a look at the example in the asyncnet lib? |
21:39:20 | FromDiscord | <Phil> https://nim-lang.org/docs/asyncnet.html |
21:40:01 | FromDiscord | <4zv4l> yeah that's what I'm trying to do now |
21:40:05 | FromDiscord | <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:07 | FromDiscord | <4zv4l> accept the client in the main loop |
21:40:12 | FromDiscord | <4zv4l> then throw them in the async proc |
21:40:39 | FromDiscord | <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:35 | FromDiscord | <keks> how does one resize a sequence, eg. setting it to zero? |
21:46:46 | FromDiscord | <Elegantbeef> `setLen(0)` |
21:48:42 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4my7 |
21:48:46 | FromDiscord | <4zv4l> @Phil this works |
21:48:48 | FromDiscord | <4zv4l> xD |
21:49:11 | FromDiscord | <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:27 | FromDiscord | <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:42 | FromDiscord | <4zv4l> you mean to get infinite client ? |
21:50:08 | FromDiscord | <4zv4l> here that was so after my client script (which connect 5 times async) would terminate afterward |
21:50:08 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/theindex.html is a good friend keks |
21:51:13 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4my8 |
21:52:10 | FromDiscord | <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:01 | FromDiscord | <4zv4l> In reply to @Isofruit "To ensure you only": using `{.threadvar.}` pragma then ? |
21:53:04 | FromDiscord | <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:23 | FromDiscord | <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:28 | FromDiscord | <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:52 | FromDiscord | <Elegantbeef> Embed post build? |
21:53:59 | FromDiscord | <Ducko> In reply to @Elegantbeef "Embed post build?": yeah |
21:54:01 | FromDiscord | <Elegantbeef> Why not `staticRead` at CT |
21:54:05 | FromDiscord | <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:10 | FromDiscord | <Ducko> In reply to @Isofruit "Not that I'm aware": yes |
21:54:11 | FromDiscord | <4zv4l> In reply to @Isofruit "And you add an": all this could be avoided if the `listen(5)` would actually work xD |
21:54:20 | FromDiscord | <Ducko> In reply to @Elegantbeef "Why not `staticRead` at": for having a generic bootstrap binary |
21:54:29 | FromDiscord | <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:39 | FromDiscord | <Phil> In reply to @4zv4l "all this could be": It doesn't? |
21:54:41 | FromDiscord | <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:57 | FromDiscord | <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:16 | FromDiscord | <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:35 | FromDiscord | <Elegantbeef> Most people arent scared of multiple files |
21:55:35 | FromDiscord | <Elegantbeef> đ |
21:55:41 | FromDiscord | <Ducko> aha |
21:55:46 | FromDiscord | <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:57 | FromDiscord | <4zv4l> the part `if the underlying protocol supports retransmission` I don't get it |
21:56:46 | FromDiscord | <4zv4l> of |
21:56:48 | FromDiscord | <4zv4l> (edit) "of" => "oh" |
21:56:50 | FromDiscord | <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:53 | FromDiscord | <4zv4l> probably why |
21:57:09 | FromDiscord | <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:47 | FromDiscord | <Phil> Huh, odd |
22:08:54 | FromDiscord | <Phil> Like, why would you limit it like that? |
22:09:30 | FromDiscord | <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:30 | FromDiscord | <4zv4l> In reply to @Isofruit "To ensure you only": to avoid doing this manually ? xD |
22:33:04 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4myd |
22:33:31 | FromDiscord | <4zv4l> https://media.discordapp.net/attachments/371759389889003532/1069384824298676224/image.png |
22:33:41 | FromDiscord | <4zv4l> I didn't think it would skip the callback |
22:34:09 | FromDiscord | <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:28 | FromDiscord | <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:59 | FromDiscord | <Elegantbeef> Nope arrays have to have contiguous indices |
23:49:03 | FromDiscord | <Piqueiras> damn |
23:50:45 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4myk |
23:51:51 | * | xaltsc joined #nim |
23:52:56 | FromDiscord | <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:25 | FromDiscord | <Elegantbeef> I assume you're making a character count table |
23:56:08 | FromDiscord | <Piqueiras> could say |
23:56:11 | FromDiscord | <Piqueiras> experimenting https://media.discordapp.net/attachments/371759389889003532/1069405632916107284/image.png |
23:57:20 | FromDiscord | <Elegantbeef> Interesting đ |