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" |