00:01:37 | FromDiscord | <Ayy Lmao> I guess I'm just confused what something like `emscripten_run_script` actually does. |
00:02:54 | FromDiscord | <Elegantbeef> Invoke js inside the web browserrs JS runtime? |
00:03:03 | FromDiscord | <Ayy Lmao> Are you saying it would be up to the runtime to provide that functionality? |
00:03:51 | FromDiscord | <Ayy Lmao> I guess I'm asking what parts of the api are runtimes specifically expected to provide? |
00:03:52 | FromDiscord | <Elegantbeef> Of course it's not apart of wasm |
00:04:12 | FromDiscord | <Elegantbeef> Anything that's not standard wasm that you want to use natively |
00:04:32 | FromDiscord | <Ayy Lmao> In reply to @Elegantbeef "Anything that's not standard": How can I tell what's not standard wasm? |
00:04:39 | FromDiscord | <Ayy Lmao> I'm not sure where to go to find out |
00:06:09 | FromDiscord | <Ayy Lmao> I'm guessing `emscripten_run_script`, `EM_JS` and `EM_ASM` are all non standard things. |
00:08:49 | FromDiscord | <Ayy Lmao> Are things like for instance getting gamepad events browser only? |
00:09:33 | * | derpydoo joined #nim |
00:18:20 | FromDiscord | <Elegantbeef> Why would one even want to arbitrarily evaluate JS when using wasm natively |
00:18:23 | FromDiscord | <Elegantbeef> You can compile js to wasm, so just do that then load that as a wasm module |
00:18:57 | FromDiscord | <Elegantbeef> I'm 99% certain that aside from basic things like allocating there is nothing in wasm |
00:19:03 | FromDiscord | <Elegantbeef> It's just a VM afterall |
00:25:12 | FromDiscord | <Andreas> `1 (32 bytes) ROOT LEAK: <malloc in pushtest95stack_u1344 0x7fc70ec04100> [32]`↵howto find the one-and-only last 32-byte leak ? Is there any tooling or besides valgring - which i can't use on osx, but the `leaks`-tool is ok - or stright to the debugger ? |
00:25:28 | FromDiscord | <Andreas> (edit) "valgring" => "valgrind" |
00:25:39 | FromDiscord | <Andreas> (edit) "stright" => "straight" |
00:25:43 | FromDiscord | <Elegantbeef> did you compile with `--debugger:native --d:useMalloc`? |
00:26:10 | FromDiscord | <Andreas> In reply to @Elegantbeef "did you compile with": only `-d:useMalloc`, will try the debugger |
00:28:27 | * | jmdaemon quit (Ping timeout: 250 seconds) |
00:28:31 | FromDiscord | <Ayy Lmao> In reply to @Elegantbeef "Why would one even": I'm using that and a combination of some other emscripten functions to abstract an operating system window so code that runs in Windows runs in the browser as well. I was just curious how much of that is expected to run in different runtimes but it's seeming like that's something that would need to be implemented on a per runtime basis. |
00:28:50 | FromDiscord | <Elegantbeef> Well yea 😄 |
00:29:16 | FromDiscord | <Ayy Lmao> I just wasn't sure if wasm provided some sort of general interface for events or something. |
00:30:28 | FromDiscord | <Elegantbeef> In my usages of wasm I have 0 procedures except those that I want to interact with the host machine |
00:31:52 | FromDiscord | <Andreas> In reply to @Elegantbeef "In my usages of": What about WASI - whatever that is - can one compile nim->WASI ? |
00:31:58 | FromDiscord | <Ayy Lmao> So basically wasm is a list of abstract computer instructions that the runtime decides what to do with? |
00:35:11 | FromDiscord | <Ayy Lmao> In reply to @Andreas "What about WASI -": You'd probably be interested in this https://github.com/beef331/wasm3 |
00:36:15 | FromDiscord | <Andreas> In reply to @Ayy Lmao "You'd probably be interested": that look freakin awsome 8=)) |
00:43:25 | FromDiscord | <Elegantbeef> WASI is just the libc of wasm |
00:43:36 | FromDiscord | <Elegantbeef> It's a standardisation of procedures one can implement and support |
00:44:27 | FromDiscord | <arkanoid> is it possible to get an error when using ARC but importing a lib that would require ORC? |
00:44:57 | FromDiscord | <Elegantbeef> With a WASI enabled runtime you can use things like stdout or sockets just fine |
00:45:04 | FromDiscord | <Elegantbeef> `when not defined(orc)` i think |
00:45:09 | FromDiscord | <Elegantbeef> Or use the `compilersettings` module |
00:46:00 | FromDiscord | <arkanoid> no, I need the other way around. I want to stay on ARC, but I'm importing external modules that I don't know if they require ORC or not |
00:46:09 | FromDiscord | <Andreas> In reply to @Elegantbeef "It's a standardisation of": its the `exit ticket` from VS-Code to Zed or Lapce -> cos'VS-Code gives me 85-% shit i don't need, but no symbol-view - i mean it 2020. no symbol-outline WTF |
00:46:31 | FromDiscord | <Elegantbeef> Kate has symbol view 😛 |
00:47:00 | FromDiscord | <Andreas> In reply to @Elegantbeef "Kate has symbol view": ohhh, thx , i'll take a look.. |
00:49:22 | * | hernan_ is now known as hernan |
00:54:00 | * | LuxuryMode quit (Quit: Connection closed for inactivity) |
00:56:07 | FromDiscord | <Elegantbeef> Do you even own your PCc if you cannot open a program |
00:56:49 | * | disso_pch quit (Quit: Leaving) |
00:57:15 | FromDiscord | <Andreas> In reply to @Elegantbeef "Do you even own": no, but its ridiculus i mean VS-Code is proven MALWARE - phones home, prbly. uses my camera.. never had any complains fom macOS |
00:57:45 | FromDiscord | <Elegantbeef> FOSS has this issue that it cannot pay for that gold star |
00:57:53 | FromDiscord | <Elegantbeef> I mostly kid |
00:59:02 | FromDiscord | <Andreas> In reply to @Elegantbeef "I mostly kid": ok, some security-setting later my OS-Master allows me to try - but KAte crashes ... |
01:02:14 | FromDiscord | <!&luke> How can I get the current time in Unix millis |
01:02:26 | FromDiscord | <Andreas> `std/times` |
01:02:52 | FromDiscord | <Andreas> (edit) "`std/times`" => "`import std/times`" |
01:02:55 | FromDiscord | <!&luke> Yea that was a dumb question |
01:03:01 | FromDiscord | <!&luke> I realized after I sent it |
01:03:14 | FromDiscord | <Andreas> In reply to @ripluke "Yea that was a": but a quick answer |
01:03:19 | FromDiscord | <!&luke> Yea |
02:34:48 | FromDiscord | <emanresu3> what are the drawbacks of using `--mm=orc -d:useMalloc` instead of nim's defaults? |
02:35:08 | FromDiscord | <Elegantbeef> `-d:useMalloc` uses malloc instead of Nim's allocation strategy which behaves differently |
02:35:26 | FromDiscord | <Elegantbeef> Nim's allocator is pretty good afaik |
02:35:37 | FromDiscord | <emanresu3> is there an example showcasing this? |
02:37:02 | FromDiscord | <Elegantbeef> Huh? |
02:39:11 | FromDiscord | <emanresu3> like a snippet of code somewhere that show when one shouldn't use one or the other |
02:39:12 | FromDiscord | <Elegantbeef> You should use malloc for embedded or in places you cannot use Nim's default allocator |
02:39:12 | FromDiscord | <Elegantbeef> Such as debugging |
02:42:03 | FromDiscord | <emanresu3> oh, I found this\: https://github.com/nim-lang/Nim/issues/18612 |
02:55:35 | FromDiscord | <Elegantbeef> What about it |
02:57:22 | FromDiscord | <emanresu3> it's some benchmarks using -d\:useMalloc |
03:07:05 | * | Batzy quit (Ping timeout: 240 seconds) |
04:09:25 | * | xet7 quit (Ping timeout: 240 seconds) |
04:13:08 | * | oldpcuser joined #nim |
04:33:17 | FromDiscord | <Graveflo> sent a code paste, see https://play.nim-lang.org/#ix=4x8R |
04:36:46 | FromDiscord | <Elegantbeef> `(var MyObject or ref MyObject)` |
04:39:35 | FromDiscord | <Graveflo> yep that works thanks |
04:55:58 | * | ntat joined #nim |
05:08:56 | NimEventer | New thread by alexeypetrushin: Why fmt doesn't work?, see https://forum.nim-lang.org/t/10237 |
05:16:55 | NimEventer | New Nimble package! measures - General purpose measuring units datatypes with integrated conversions and definitions., see https://github.com/energy-nim/measures |
05:17:28 | FromDiscord | <mratsim> sent a code paste, see https://play.nim-lang.org/#ix=4x8V |
05:20:48 | * | oldpcuser quit (Remote host closed the connection) |
05:52:14 | FromDiscord | <Elegantbeef> I swear if they write an forum post then delete their post after I'm going to find them and break their keyboard |
06:29:44 | * | PMunch joined #nim |
06:30:18 | * | rockcavera quit (Remote host closed the connection) |
07:41:05 | FromDiscord | <Andreas> winter |
07:58:05 | FromDiscord | <pmunch> The RST parser is a bit silly, you need a line with text on it after the quote.↵(@mratsim) |
07:58:44 | FromDiscord | <pmunch> Are you talking about old posts being necro-bumped but without any new comments? |
07:59:40 | FromDiscord | <pmunch> That's because bots or spammers post to the topic and their posts are not accepted by a moderator |
08:00:53 | PMunch | We've had a new influx of GPT-fueled spam, stuff that looks more like a real post than "xx6969xx buy my dick bluing pills for ultimate flight control :emojivomit:" |
08:01:24 | PMunch | But they don't seem to quite understand the context of the discussion, and they tend to share links to completely random things |
08:08:41 | PMunch | For example in this thread they helpfully shared a link to an animal care website (or at least one that looked like one, didn't actually click the link): https://forum.nim-lang.org/t/9287 |
08:09:26 | PMunch | The text at least seemed to be somewhat related to polymorphism |
08:21:24 | * | PMunch quit (Quit: leaving) |
08:46:40 | FromDiscord | <Elegantbeef> No pmunch i mean the posts that get created then deleted after either realising their failure or solving the issue |
08:49:29 | FromDiscord | <Elegantbeef> like 3/4 of alex's posts there get deleted shortly after posting |
09:07:03 | FromDiscord | <voidwalker> What would you use if you need to comply with a rate limiter on a certain website you're building a client for ? Some sort of queue with timers so that all methods that call to that website are put in and executed at the right time so as not to go over the rate limit (i don't know what the rate is yet |
09:07:03 | FromDiscord | <voidwalker> (edit) "yet" => "yet)" |
09:07:03 | FromDiscord | <voidwalker> this maybe ? https://github.com/jackhftang/taskqueue.nim |
09:07:03 | FromDiscord | <chmod222> Really depends on the specific way the rate limit is enforced, but I like the simplicity of token buckets |
09:07:03 | FromDiscord | <voidwalker> it's nr. actions per some time window, I don't know the values yet |
09:18:58 | FromDiscord | <chmod222> It's almost as annoying as the people who are very obviously and incometently creating malware and asking all the relevant steps to do so as separate threads |
09:19:44 | FromDiscord | <Elegantbeef> "How do i write a program that tracks key inputs"↵"How do i send data to a server" |
09:20:17 | FromDiscord | <chmod222> "How do I take a screenshot and send it over the network"↵"How do I execute commands and send the response back over a socket" |
09:40:19 | FromDiscord | <voidwalker> Haha I noticed those too, but didn't wanna say anything |
09:41:34 | FromDiscord | <voidwalker> well since nim is already the "malware" language, we should just make a library for trojans to use : P |
09:44:34 | FromDiscord | <chmod222> I'm just waiting for "How do I encrypt all files and display a full screen window" |
09:49:22 | * | beholders_eye joined #nim |
10:18:09 | FromDiscord | <arkanoid> let's say I want to write Nim software for hard-realtime (bare metal).↵I have two questions\:↵- which compiler options should I pick, in general↵- if I use ORC but a I don't make use of any reference "loop", does it behave 1\:1 like ARC? On the other hand, if I make use of reference loops but I use ARC, will I receive any kind of warning at compilation time? |
10:38:12 | FromDiscord | <cmc> sent a long message, see https://paste.rs/AfDv0 |
10:40:19 | FromDiscord | <cmc> sent a long message, see http://ix.io/4x9K |
10:41:48 | FromDiscord | <cmc> Is anyone aware of a utility library for getting sub-sections of tables, similar to `sequtils.filter`? |
10:42:56 | * | PMunch joined #nim |
10:44:20 | FromDiscord | <arkanoid> interesting! thanks. But it does focus on my questions.↵But it helps me adding two more\:↵- can I disable heap completely to fail compilation if I try to put alloc in my code↵- is there an existing allocator to get the pre-allocated chunk of memory thing |
10:47:46 | FromDiscord | <arkanoid> you mean nim tables module, or generic table (like a tensor) |
10:58:50 | FromDiscord | <mratsim> In reply to @arkanoid "interesting! thanks. But it": There was "regions" but just use malloc and manual memory management |
11:27:16 | FromDiscord | <Andreas> In reply to @arkanoid "interesting! thanks. But it": there is `fusion/pool` which - in the version im working on - is now lock-free, since Nims alligator recently became lock-free, too. I'm working on lock-free versions of Stack/Set/Table which will all use the threadsafe Pool to operate.. |
11:27:51 | FromDiscord | <Andreas> (edit) "In reply to @arkanoid "interesting! thanks. But it": there is `fusion/pool` which - in the version im working on - is now lock-free, since Nims alligator recently became lock-free, too. I'm working on lock-free versions of Stack/Set/Table which will all use the threadsafe Pool to operate.. ... " added "its all and everything heap-alloced" |
11:28:20 | PMunch | I hate when my alligators have locks |
11:56:37 | FromDiscord | <cmc> Preferably anything with a table-like interface |
11:57:38 | FromDiscord | <cmc> If you use gc\:none, you will receive a warning for all implicit heap allocations.I |
11:59:37 | FromDiscord | <arkanoid> what do you have to store into the table? have you considered arraymancer/datamancer? |
12:01:22 | FromDiscord | <cmc> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/1113436122383650816): If you use gc\:none, you will receive a warning for all implicit heap allocations. I'm not sure how to convert it to errors but it could be enough.As for a finished memory allocator in Nim, I'm not aware of one- you could look for the SuperCollider audio synthesizer system codebase and search the codebase for the RTAlloc function to have an example |
12:01:34 | FromDiscord | <mratsim> In reply to @Andreas "there is `fusion/pool` which": I'm definitely calling my allocator package alligator |
12:02:43 | FromDiscord | <mratsim> In reply to @cmc "[Edit](https://discord.com/channels/371759389889003": @cmc#0000 there is an option for warnings as errors |
12:03:29 | FromDiscord | <arkanoid> great name, actually↵(@mratsim) |
12:09:37 | FromDiscord | <voidwalker> mratsim or anyone else, any suggestions on what async task queuer lib to use ? I want to time http requests to a URL so they don't hit a rate limit |
12:25:04 | FromDiscord | <abisxir> Guys is there something like Semaphore in nim? |
12:25:20 | * | ntat_ joined #nim |
12:25:37 | * | ntat quit (Ping timeout: 240 seconds) |
12:27:12 | FromDiscord | <cmc> Thanks!!↵The operations on datamancer are pretty much what I'm looking for- some kind of more minimalistic version would also do fine. But I need it to accept arbitrary table-like objects that support arbitrary keys and values, or at least stack-based ones. The normal use-case would be an int key and an object value, or a string or float key and an int value. Basically bolting a little bit of data access onto key value storage. |
12:28:59 | FromDiscord | <arkanoid> datamancer/arraymancer are suited for data science, not sure if they fit your target |
12:29:03 | * | ntat_ quit (Client Quit) |
12:29:23 | * | ntat joined #nim |
12:29:40 | * | ntat quit (Client Quit) |
12:29:56 | * | ntat joined #nim |
13:06:35 | * | derpydoo quit (Read error: Connection reset by peer) |
13:12:18 | FromDiscord | <Andreas> i have a mutual dependency between module-A and module-B - A Pool needs a Stack, which in-turn needs a Pool ? Howto deal with that scenario ? there was a compiler-switch, that i cannot remebr ?? |
13:18:33 | FromDiscord | <least antisemitic pole> i think this proc is too easy to be confused with strformat's `&` https://media.discordapp.net/attachments/371759389889003532/1113456484358029362/image.png |
13:19:23 | FromDiscord | <least antisemitic pole> even worse, the editor coloring assumes `&` to be strformat and colors the string to make it even more surprising |
13:23:28 | FromDiscord | <least antisemitic pole> I can't even find information about this "jstrutils" module in the manual |
13:29:06 | FromDiscord | <least antisemitic pole> should I expect karax to keep up with calling redraw() every animation frame? |
13:29:20 | FromDiscord | <least antisemitic pole> seems like I need to to achieve what I want |
13:29:31 | * | derpydoo joined #nim |
13:30:36 | FromDiscord | <cmc> Yeah in principle what I want is a sub-set of datamancer, but simpler and usable with any table or table-like.Filter table by callback, in-place, return-copy or iterator- basically sequtils for tables.The basics shouldn't be too hard to roll myself but I'd love something somewhat more widely used, if it exists. |
13:32:45 | FromDiscord | <mratsim> In reply to @voidwalker "mratsim or anyone else,": https://github.com/status-im/nim-chronos/blob/master/chronos/ratelimit.nim |
13:33:19 | FromDiscord | <mratsim> In reply to @abisxir "Guys is there something": Semaphore? Is that the synchronization object or something else? |
13:34:25 | FromDiscord | <mratsim> Async semaphores in 29 lines of code: https://github.com/mratsim/constantine/blob/d996ccd/helpers/pararun.nim#L21-L50 |
13:45:32 | * | progranner joined #nim |
13:46:56 | FromDiscord | <voidwalker> @mratsim thanks but that only works with chronos, right ? |
14:00:21 | * | PMunch quit (Quit: Leaving) |
14:26:59 | * | rockcavera joined #nim |
14:30:34 | FromDiscord | <abisxir> In reply to @mratsim "Semaphore? Is that the": Like a lock with a capacity, lock is a semaphore with capacity one. |
14:31:59 | FromDiscord | <abisxir> In reply to @mratsim "Async semaphores in 29": Interesting 🤔 |
14:56:28 | * | psydruid joined #nim |
14:56:48 | FromDiscord | <etra> In reply to @mratsim "Async semaphores in 29": noob question, what is the `_: type AsyncSemaphore` for? |
15:00:18 | FromDiscord | <Rika> require that you type `AsyncSemaphore.new` instead of just `new` |
15:00:31 | FromDiscord | <etra> aaah I see |
15:06:56 | FromDiscord | <sOkam!> @cmc I extracted the memory allocator of id-tech3, which is one of the best I've ever seen.↵Should be easy enough to either port or just wrap with nim https://github.com/heysokam/idtech3-modules/tree/master/src/mem |
15:10:33 | * | pharonix71 quit (Remote host closed the connection) |
15:11:00 | * | pharonix71 joined #nim |
15:20:09 | FromDiscord | <chmod222> Any way to specify / assert that a given "M\: proc" has some specific calling convention? |
15:20:22 | FromDiscord | <chmod222> Parameters/return can be anything, but it must be {.nimcall.} |
15:23:19 | FromDiscord | <chmod222> Actually, that doesn't seem to be my problem, so nevermind on that front |
15:34:22 | * | progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
15:34:52 | * | progranner joined #nim |
15:35:47 | FromDiscord | <chmod222> Okay, new question\: Is there a way to tell nim explicitely to infer a generic argument? I have a `proc registerMethod[T, M](callable: M)` and for some reason I cannot manage to get my macro to generate the correct `registerMethod[MyType, PType](procToRegister)` because no matter what I do, `PType` and whatever `procToRegister` gets inferred to always contradict, but if I move the `T` into a `typedesc[T]` and call it via `registerMethod( |
15:35:59 | * | progranner quit (Client Quit) |
15:36:24 | FromDiscord | <chmod222> I'd like to call `registerMethod[T, _](procToRegister)` instead because all other procs already use the `[T]` and I hate inconsistency |
15:37:13 | FromDiscord | <chmod222> And `registerMethod[T, typeOf procToRegister](procToRegister)` also doesn't work |
15:38:43 | FromDiscord | <mratsim> In reply to @voidwalker "<@570268431522201601> thanks but that": no, that file imports asyncdispatch not chronos |
15:39:07 | FromDiscord | <mratsim> In reply to @voidwalker "<@570268431522201601> thanks but that": ah you mean the rate limiter, you can adapt it, there is nothing tied to chronos |
15:39:07 | FromDiscord | <voidwalker> huh ? `import ../chronos` |
15:39:19 | FromDiscord | <mratsim> In reply to @voidwalker "huh ? `import ../chronos`": I was on the asyncSemaphore stuff |
15:39:33 | FromDiscord | <arkanoid> what?!↵(@sOkam!) |
15:39:40 | FromDiscord | <arkanoid> impressive |
15:39:54 | FromDiscord | <voidwalker> yeah okay, I wanted something ready to use. I'm thinking this is quite a common use case, when one wants to build http/api clients that obey rate limits |
15:40:51 | FromDiscord | <voidwalker> I'm thinking if I should maybe start to just use chronos instead of asyncdispatch.. |
15:41:04 | FromDiscord | <voidwalker> This situation when I need something that depends on chronos comes up far too often lately |
15:41:20 | FromDiscord | <mratsim> In reply to @sOkam! "@cmc <@210739784761475072> I extracted": they didn't document the high level algo/features |
15:41:28 | FromDiscord | <voidwalker> but then I won't be able to use asyncdispatch stuff :\ |
15:41:52 | FromDiscord | <voidwalker> this split is not good for nim |
15:42:56 | FromDiscord | <mratsim> In reply to @voidwalker "but then I won't": maybe `-d:asyncBackend=chronos` can allow you to use chronos with async lib? |
15:43:14 | FromDiscord | <voidwalker> oh I forgot about that thing |
15:43:51 | FromDiscord | <arkanoid> what's the difference between importing asyncdispatch/chronos, or using compiler switch? |
15:44:40 | FromDiscord | <mratsim> In reply to @voidwalker "this split is not": the issue is that the stdlib should have a way to use your own implementation. Ideally it only standardize interfaces for stuff that are too complex to maintain internally |
15:45:21 | FromDiscord | <mratsim> async is a core need of Status, too many stuff to fix and add. The compiler and stdlib are in a totally different timeframe for this. |
15:46:15 | FromDiscord | <mratsim> In reply to @arkanoid "what's the difference between": This is pretty old but that explains why we created Chronos back in 2019 after trying to workaround or fix asyncdispatch: https://github.com/status-im/nim-chronos/wiki/AsyncDispatch-comparison |
15:50:07 | FromDiscord | <arkanoid> I know chronos as I already use it for some toy project, my question was exclusively about import vs compiler switch |
15:54:18 | FromDiscord | <etra> what's the tldr of the difference between chronos and asyncdispatch? |
15:55:49 | FromDiscord | <deech> This is probably a tall order but is there any way to define lifetime hooks in a separate module? I can do this with `include` but I'd rather `import`. |
16:02:29 | FromDiscord | <demotomohiro> @chmod222 This might help: https://internet-of-tomohiro.netlify.app/nim/faq.en.html#procedures-how-to-get-a-pointer-to-a-generic-procedure-or-a-procedure-with-type-class-parametersqmark |
16:03:23 | FromDiscord | <chmod222> Thanks, I'll have a read. I solved it using `callable: auto` for now which also works |
16:03:30 | FromDiscord | <chmod222> But of course it leads straight into another problem |
16:03:44 | FromDiscord | <chmod222> "cannot cast to a non concrete type\: " \`proc (salad\: typedesc[SomeType], a\: int, b\: float, c\: String)' |
16:04:25 | FromDiscord | <chmod222> I have to convert a naked pointer that went through C land back into my function pointer |
16:04:37 | FromDiscord | <chmod222> It's not a closure so there's no env to consider, but it simply will not work |
16:09:06 | FromDiscord | <demotomohiro> procs with `auto` parameters or return type are generic procs.↵procs with typedesc parameters are also generic procs.↵And you cannot get a pointer to a generic proc.↵You need to instanciate generic proc to get a pointer. |
16:11:17 | FromDiscord | <sOkam!> In reply to @mratsim "they didn't document the": they docummented nothing :notlikethis: |
16:11:33 | FromDiscord | <sOkam!> its the curse of quake engines, really |
16:12:00 | FromDiscord | <chmod222> Thanks, now I know what I need to work around |
16:12:01 | FromDiscord | <chmod222> Alright, that is good to know. I knew `auto` implies generic, but I thought `typedesc` would be handled differently, but that makes sense |
16:12:13 | FromDiscord | <chmod222> And I was wondering why it was always this particular function that's causing issues and not my other, "non static" one |
16:14:56 | FromDiscord | <mratsim> In reply to @deech "This is probably a": i think the compiler creates an error when =destroy is not in the same module as the type, |
16:15:14 | FromDiscord | <chmod222> It does, yes |
16:16:02 | FromDiscord | <mratsim> In reply to @etra "what's the tldr of": one is "easy" because it's in the stdlib, the other is battle-tested, running on thousands if not 10s of thousands of machines 24/7 with billions at stake and huge reputational risk. |
16:17:13 | FromDiscord | <mratsim> And despite having hundreds/thousands futures and timers firing left and right, it manages to use 2x less memory than the Go and Rust softwares that offer the same service. |
16:18:17 | FromDiscord | <deech> sent a code paste, see https://play.nim-lang.org/#ix=4xbh |
16:19:08 | FromDiscord | <mratsim> can you move the from B import nil below the type declaration? |
16:19:18 | FromDiscord | <voidwalker> mratsim, know of any project that can use both asyncdispatch/chronos with compiler flag ? I'm having trouble figuring out how to use this. Do I import just asyncdispatch, or chronos? or both ? |
16:19:37 | FromDiscord | <mratsim> In reply to @voidwalker "mratsim, know of any": no idea sorry |
16:20:28 | FromDiscord | <sOkam!> are the `=destroy` etc hooks usable with gc:none? or are they an arc/orc exclusive thing? |
16:20:58 | FromDiscord | <mratsim> In reply to @sOkam! "are the `=destroy` etc": use gc:destructors if you want =destroy and nothing else. |
16:21:11 | FromDiscord | <mratsim> but gc:arc with no ref types is equivalent |
16:21:19 | * | progranner joined #nim |
16:21:34 | FromDiscord | <sOkam!> In reply to @mratsim "but gc:arc with no": you mean arc but not using refs? |
16:21:40 | FromDiscord | <mratsim> yes |
16:21:48 | FromDiscord | <sOkam!> oh |
16:21:52 | FromDiscord | <mratsim> no refs and no exceptions is like none |
16:22:01 | FromDiscord | <sOkam!> oh didnt know that |
16:22:12 | FromDiscord | <sOkam!> i guess thats what beef tried to tell me a while back |
16:22:12 | FromDiscord | <mratsim> none and destructors are basically superceded by arc |
16:22:27 | FromDiscord | <deech> In reply to @mratsim "can you move the": `module B` can't see the `A` type. |
16:22:29 | FromDiscord | <mratsim> Nim memory management is per type. |
16:22:52 | FromDiscord | <mratsim> In reply to @deech "`module B` can't see": well in that case you need them all in same datatypes.nim file |
16:24:12 | FromDiscord | <sOkam!> In reply to @mratsim "Nim memory management is": so i understand gc:destructors are for ref types only? |
16:25:36 | FromDiscord | <deech> In reply to @mratsim "well in that case": That's what I'm doing now. Nim also has package objects (https://nim-lang.org/docs/manual_experimental.html#package-level-objects) but they are experimental and I was hoping there was a simpler solution. Thanks for your help! |
16:26:48 | FromDiscord | <jmgomez> In reply to @deech "That's what I'm doing": didnt try it out, but include may also work |
16:26:50 | FromDiscord | <mratsim> In reply to @sOkam! "so i understand gc:destructors": no, destructors are for value objects, including seq and strings |
16:26:54 | FromDiscord | <etra> In reply to @mratsim "one is "easy" because": hmm, if a dependency uses `asyncdispatch`, would that means I'd have some sort of mixed runtimes? |
16:27:17 | FromDiscord | <mratsim> if you use destructors I'm not really sure what is done for your ref objects, maybe nothing |
16:27:54 | FromDiscord | <mratsim> basically the idea is that when you need absolute control over memory you used none, if you want some control you used destructors |
16:28:13 | FromDiscord | <mratsim> but arc gives you that AND ref types. |
16:28:31 | FromDiscord | <jmgomez> In reply to @mratsim "one is "easy" because": out of curiosity are you referring to nimbus? |
16:29:01 | FromDiscord | <mratsim> In reply to @etra "hmm, if a dependency": maybe not with `-d:asyncBackend=chronos` |
16:29:06 | FromDiscord | <mratsim> In reply to @jmgomez "out of curiosity are": yes |
16:55:28 | * | beholders_eye quit (Ping timeout: 248 seconds) |
17:10:43 | FromDiscord | <voidwalker> is this https://nim-lang.org/docs/db_common.html gone in nim devel ? |
17:30:02 | * | progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
17:31:47 | * | progranner joined #nim |
18:01:28 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4xbI |
18:01:54 | FromDiscord | <sOkam!> tried {} and [], but they seem to be rejected |
18:01:57 | * | progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
18:02:54 | * | progranner joined #nim |
18:02:55 | * | progranner quit (Client Quit) |
18:03:46 | * | beholders_eye joined #nim |
18:03:48 | FromDiscord | <demotomohiro> `Groups()`? |
18:05:21 | FromDiscord | <chmod222> Doesn't Nim zero initialize anything unless inhibited with {.noinit.}? |
18:10:34 | FromDiscord | <sOkam!> In reply to @demotomohiro "`Groups()`?": doesn't work. it says that object constructors require an object type |
18:10:45 | * | progranner joined #nim |
18:13:31 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4xbN |
18:15:46 | FromDiscord | <sOkam!> oh haven't tried `default()` yet, let me check |
18:15:58 | FromDiscord | <demotomohiro> In reply to @chmod222 "Doesn't Nim zero initialize": Yes, Nim do so. I think @sOkam! wants simple expression like `[]` that has type `Groups`. |
18:16:13 | FromDiscord | <sOkam!> yeah exactly |
18:18:19 | * | progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
18:19:31 | FromDiscord | <sOkam!> default works, yep, tyty |
18:20:42 | * | progranner joined #nim |
18:21:14 | FromDiscord | <chmod222> Ahh, I see |
18:39:18 | FromDiscord | <deech> Is there a way to have a macro generate import and export statements? |
18:41:05 | FromDiscord | <chmod222> sent a code paste, see https://play.nim-lang.org/#ix=4xbS |
18:43:13 | FromDiscord | <deech> Huh, thanks! I was looking all around for some kind of `nnkImport` ast type. Does that splice itself into the module scope as though it was written manually? |
18:43:27 | FromDiscord | <chmod222> You can also go raw with nnkImportStmt, yes |
18:43:34 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4xbT |
18:43:44 | FromDiscord | <chmod222> for a/b/c |
18:43:46 | FromDiscord | <chmod222> sent a code paste, see https://play.nim-lang.org/#ix=4xbU |
18:44:01 | FromDiscord | <chmod222> dumpAstGen is immensly useful, yes |
18:44:24 | * | progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
18:44:24 | FromDiscord | <deech> Dammit, I could have sworn I tried that and `dumpAstGen` errored out! Sorry for the noise, thanks for the help! |
18:45:45 | * | junaid_ joined #nim |
18:45:47 | * | beholders_eye quit (Ping timeout: 265 seconds) |
18:46:10 | * | progranner joined #nim |
18:47:29 | * | beholders_eye joined #nim |
18:54:37 | FromDiscord | <chmod222> I believe dumpAstGen is the one function in the world that can never error out |
19:06:45 | FromDiscord | <Graveflo> I'm reading some code that I'm sure at one time worked, but for me it doesn't. I seems that they are using `assert` and `==` for comparison of two refs. This only works for me when I de-reference. That is a bit annoying that `==` is so dumb. Is there an explanation for this? |
19:07:16 | FromDiscord | <Elegantbeef> refs are pointers, pointer comparison is an integer comparison |
19:08:06 | FromDiscord | <Graveflo> I'm reading code from your repo's README. https://github.com/beef331/constructor. Under the section "Modifying implDefaults" |
19:10:43 | FromDiscord | <Graveflo> it seems that `is` is reserved for type checks which is fine, but it would be nice to have a equivalence operator and an equality operator for just this sort of thing. |
19:11:10 | FromDiscord | <Elegantbeef> Eh, people hardly care about if a references values equal truthfully |
19:11:34 | FromDiscord | <chmod222> You could define `proc isnotnot` |
19:11:36 | FromDiscord | <Elegantbeef> if you want that you can easily write a `proc internallyEqual(a, b: ref object): bool = a == b or a[] == b[]` |
19:12:38 | FromDiscord | <Elegantbeef> For complex types with complex graphs it's a very complex calculation |
19:12:46 | FromDiscord | <Graveflo> yea thats always an option |
19:13:57 | FromDiscord | <sOkam!> gotta love the flexibility of nim ❤️ |
19:14:59 | FromDiscord | <chmod222> There is some delicious macro abuse I'm doing right now that you'd be hard pressed to do that neatly in any other language |
19:15:29 | FromDiscord | <chmod222> Although, is it abuse when they are used as intended? |
19:15:34 | FromDiscord | <Elegantbeef> well I had seen you share astgenRepr, so.... yea |
19:15:55 | FromDiscord | <jmgomez> hey @deech, the constructor feature that you wanted was merged today. Here are the docs: https://github.com/nim-lang/Nim/pull/21970↵destructors may take a bit, but in the mean time `codegenDecl` should work just fine 🙂 |
19:17:29 | FromDiscord | <chmod222> Talk about macros, any fancier way to call a function pointer with a tuple spliced into its arguments without me having to manually emit a nnkCall? |
19:18:13 | FromDiscord | <chmod222> As in, I have `proc(some: int; params: float)` and a tuple `(some: 0, params: 1.23)` |
19:18:28 | FromDiscord | <Elegantbeef> Nope |
19:18:35 | FromDiscord | <Elegantbeef> `nnkCall` is required to call anything |
19:18:42 | FromDiscord | <chmod222> Alright, my abomination stays then |
19:18:44 | FromDiscord | <chmod222> I'll make it prettier though |
19:18:53 | * | progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
19:19:05 | FromDiscord | <Elegantbeef> You can make a macro that expands it afterwords if you really wanted to |
19:19:15 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/XsHcm |
19:19:22 | * | junaid_ quit (Remote host closed the connection) |
19:19:31 | FromDiscord | <Elegantbeef> But it's hardly different |
19:19:34 | FromDiscord | <chmod222> I think I really want to, there's some stuff I'd like to do to the params with fieldPairs that would grow too unwiedly inside the macro body |
19:20:24 | FromDiscord | <Elegantbeef> You might want a `proc unpackCall(p: proc, t: tuple)` and do type checking inside an internal macro or something similar |
19:20:38 | FromDiscord | <chmod222> Some languages have a neat `apply` function for that purpose, I was just wondering if Nim had one too but if I have to build it myself, that's not too bad either |
19:28:07 | * | derpydoo quit (Read error: Connection reset by peer) |
19:46:19 | * | progranner joined #nim |
19:49:28 | * | beholders_eye quit (Ping timeout: 240 seconds) |
19:52:32 | * | progranner quit (Ping timeout: 248 seconds) |
19:53:50 | FromDiscord | <Graveflo> I've heard people talk about how nimsuggest "randomly" starts hogging CPU. That juts happened to me, but it happened as soon as I introduced a recursive infinite loop to the code. It seems like nimsuggest is missing an infinite recursion check or two |
19:55:26 | FromDiscord | <Graveflo> running the code the compiler is smart enough to break it with an error though |
19:55:55 | FromDiscord | <chmod222> Maybe it's a punishment for writing buggy code |
19:56:45 | FromDiscord | <Graveflo> well I don't make sure that every keystroke is going to be valid or "non-buggy" code. You gotta move stuff around. Not like I'm coding in ink |
19:58:10 | FromDiscord | <chmod222> I had to write code in ink in my exams way back, that was painful |
19:59:50 | FromDiscord | <Graveflo> yea I had to design a processor with SR latch memory banks and an ALU and write a program in binary that displayed Fibonacci results on on a 7 segment display on paper for an exam once |
20:01:31 | FromDiscord | <chmod222> You really learn to appreciate the backspace key |
20:02:25 | FromDiscord | <Graveflo> I might aswell be a symbiotic life form to the thing |
20:02:59 | FromDiscord | <Elegantbeef> > It seems like nimsuggest is missing an infinite recursion check or two↵Eh Nimsuggest is the compiler but has some heuristic changes internally to make it faster, but also buggier |
20:35:16 | FromDiscord | <Graveflo> so beef do you want me to PR that booboo in `constructor`s README? |
20:35:54 | FromDiscord | <Elegantbeef> Consider rereading the readme before doing such 😛 |
20:37:11 | FromDiscord | <Graveflo> i red it. Is it supposed to fail the assertion or something? |
20:38:45 | FromDiscord | <Elegantbeef> Huh? |
20:39:24 | FromDiscord | <Graveflo> sent a code paste, see https://play.nim-lang.org/#ix=4xcr |
20:39:32 | FromDiscord | <Graveflo> pulling your leg a little bit with the last one LOL |
20:40:09 | FromDiscord | <Elegantbeef> I'm confused what you're suggesting? |
20:40:34 | FromDiscord | <Elegantbeef> Oh nvm i see i'm missing a derefernece |
20:40:43 | FromDiscord | <Elegantbeef> just PR a dereference if you want to contribute |
20:40:44 | FromDiscord | <Graveflo> this assertion is not true `assert new(Thingy) == Thingy(a: 10, b: "Hmm", c: 10)` should it be this? `assert new(Thingy)[] == Thingy(a: 10, b: "Hmm", c: 10)[]` |
20:40:59 | FromDiscord | <Elegantbeef> You're right |
20:42:27 | FromDiscord | <Elegantbeef> I probably should use a CI to generate docs and use pages to host it, but I cannot be arsed |
20:42:31 | FromDiscord | <Elegantbeef> Seems like a waste of energy if you ask me 😄 |
20:43:07 | FromDiscord | <Graveflo> yea I'm sure its fine for everyone except noobs like me. Even then only a paranoid maniac would both clarifying it just to be safe |
20:43:25 | FromDiscord | <Graveflo> (edit) "both" => "bother" |
20:47:10 | * | ntat quit (Quit: Leaving) |
21:07:56 | FromDiscord | <Marcus> is it possible to set an env variable before you do a import with putEnv? Or are all the imports resolved first? |
21:12:16 | FromDiscord | <Graveflo> you could make a file that reads a variable and then another file that imports that file and try writing the variable before to see what happens |
21:15:47 | FromDiscord | <mratsim> In reply to @Graveflo "well I don't make": You should consider moving to punch cards |
21:16:35 | FromDiscord | <Graveflo> I'm not old enough to have experienced those, but I always like a good story from an old head. They all have at least one |
21:20:31 | FromDiscord | <Graveflo> In reply to @Marcus "is it possible to": Looks like if you put the call to `putEnv` in a `static` block it works |
21:20:56 | FromDiscord | <Graveflo> sent a code paste, see https://play.nim-lang.org/#ix=4xcx |
21:21:10 | FromDiscord | <Marcus> graveflo\: Neat! Thank you! |
21:23:17 | FromDiscord | <Marcus> `std/tempfiles.nim:109:10 Error: cannot evaluate at compile time: nimTempPathState` welp, didn't play well with tempfiles, but still good to know for later 🙂 |
21:24:36 | FromDiscord | <Graveflo> you could maybe use a global variable (or not if you can avoid it) and just delay the arbitration between the modules by using procs in a non-static context |
21:25:07 | FromDiscord | <Marcus> Yeah, I'm going to push the place I read the variable into a proc instead of toplevel 🙂 |
21:25:35 | FromDiscord | <Graveflo> actually not that I think about it `static` might not work at all. Its just setting the value at compile time so the variable exists before the program even runs 😦 |
21:25:44 | FromDiscord | <Marcus> yea |
21:27:55 | FromDiscord | <Graveflo> this makes me question when exactly module level code even runs |
21:28:24 | FromDiscord | <Elegantbeef> module level code runs on startup in order of first import |
21:29:39 | FromDiscord | <Marcus> Elegantbeef\: seems like the imports run before your module tho |
21:29:46 | FromDiscord | <Marcus> which makes sense |
21:29:54 | FromDiscord | <Elegantbeef> If you have imports before your module code of course |
21:30:15 | FromDiscord | <Marcus> well, I did try putting it above but it seemed to still run after |
21:30:26 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/1r00q |
21:30:51 | FromDiscord | <Elegantbeef> I guess you're right that's odd |
21:30:57 | FromDiscord | <Marcus> image.png https://media.discordapp.net/attachments/371759389889003532/1113580401705877514/image.png |
21:31:14 | FromDiscord | <Graveflo> nah its not odd the dependencies have to run first |
21:31:34 | FromDiscord | <Elegantbeef> Uhh no they dont |
21:31:56 | FromDiscord | <Elegantbeef> All top level statements can be raised to `NimMain` in import order |
21:32:42 | FromDiscord | <Graveflo> well maybe "have to" is a string word. we think about the dependents invoking the dependencies to that is the opposite direction, but module level code may be thought of as creating what the dependents are utilizing |
21:32:51 | FromDiscord | <Graveflo> what if there is initialization code in the dependency? |
21:33:07 | FromDiscord | <Elegantbeef> It'd run after the code before it run |
21:34:06 | FromDiscord | <Graveflo> oh man that one confused me. Are we saying that your example "hm" being echoed before "hello" is weird or are we agreeing that is makes sense? I'm lost LOL |
21:34:25 | FromDiscord | <Elegantbeef> Order of declaration should be how NimMain is generated |
21:35:16 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4xcD |
21:35:22 | FromDiscord | <Graveflo> but its not tho |
21:35:25 | FromDiscord | <Elegantbeef> The only issue is really cyclical dependencies on top level code I imagine |
21:35:33 | FromDiscord | <Elegantbeef> Sure, I'd argue this is a bug |
21:35:48 | FromDiscord | <Elegantbeef> I do not see there is a reason for this, I don't know |
21:35:56 | FromDiscord | <Elegantbeef> You expect code to run in the order you write it in an imperative language |
21:36:29 | FromDiscord | <Chronos [She/Her]> https://wasmer.io/posts/announcing-wasix Beef |
21:36:43 | FromDiscord | <Graveflo> I agree that is true but only if the blocks of code are segmented such that code in top level modules is only run BEFORE the import then the imports top level code is run |
21:36:50 | FromDiscord | <Graveflo> any other way and youll get in trouble |
21:37:01 | FromDiscord | <Elegantbeef> What? |
21:37:15 | FromDiscord | <Elegantbeef> You cannot have top level code before import depend on a sub module |
21:37:29 | FromDiscord | <Chronos [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4xcE |
21:37:32 | FromDiscord | <Elegantbeef> On import all top level code is added to nim main, then you go to the next statement |
21:37:50 | FromDiscord | <Graveflo> sent a code paste, see https://play.nim-lang.org/#ix=4xcF |
21:38:07 | FromDiscord | <Elegantbeef> It would run first |
21:38:19 | FromDiscord | <Elegantbeef> You have to import the module |
21:38:49 | FromDiscord | <Chronos [She/Her]> In reply to @Hourglass, When the Hour Strikes "https://wasmer.io/posts/announcing-wasix Beef": WASIX is interesting but I think it definitely wouldn't work in a scripting environment lol |
21:38:56 | FromDiscord | <Graveflo> right so if you want "hello" to come fist it's gotta be before the import, but if there is code after the import it has to run after the top level of the imported module thus a segmentation |
21:39:00 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/2PrOs |
21:39:20 | FromDiscord | <Elegantbeef> There is no issue here |
21:39:23 | FromDiscord | <Graveflo> its not bad that's what I would want. im js |
21:39:37 | FromDiscord | <Elegantbeef> Code that depends on other code has to be declared after importing that code |
21:39:48 | FromDiscord | <Graveflo> yes 😛 |
21:39:55 | FromDiscord | <Elegantbeef> What I'm suggesting makes total sense |
21:40:10 | FromDiscord | <Elegantbeef> If you put code before an import it should run before that imports code |
21:40:24 | FromDiscord | <Graveflo> yep thats why I was confused originally. I would prefer for it to work as you suggested. |
21:40:40 | FromDiscord | <Elegantbeef> So why did you argue otherwise? 😄 |
21:40:54 | FromDiscord | <Elegantbeef> I had see wasix, it doesnt interest me much 😄 |
21:41:12 | FromDiscord | <Graveflo> I was just pointing out the stipulation that would have to change in order for it to change from how it works now to how it must work to facilitate that behavior |
21:41:42 | FromDiscord | <Elegantbeef> Well I'd argue the present state is a bug and that a bugfix that breaks code is valid in Nim2.0 😄 |
21:41:55 | FromDiscord | <Graveflo> got my vote |
21:44:45 | FromDiscord | <Elegantbeef> Well i've asked in #internals so we'll see what araq says |
21:45:23 | FromDiscord | <Graveflo> I'll sacrifice a goat |
21:45:56 | FromDiscord | <Marcus> I was actually expecting it to work the way you suggest it should, Elegantbeef. |
21:46:07 | FromDiscord | <Elegantbeef> Of course you would Nim is imperative |
21:46:45 | FromDiscord | <Graveflo> I guess imports are declarative currently |
21:46:55 | FromDiscord | <Elegantbeef> But they arent |
21:47:19 | FromDiscord | <Elegantbeef> https://wandbox.org/permlink/ZzgEjgKLfPNRHeK8 |
21:47:35 | FromDiscord | <Elegantbeef> Import order matters |
21:47:47 | FromDiscord | <Elegantbeef> Where you import matters aswell |
21:48:43 | FromDiscord | <Ayy Lmao> Is there a decent way to make a procedure compatable with ref and var objects at the same time? |
21:48:49 | FromDiscord | <Elegantbeef> It seems like all top level statements are group together and added at the end of the module processing |
21:48:49 | FromDiscord | <Elegantbeef> Instead of as processed |
21:49:02 | FromDiscord | <Elegantbeef> I answered this yesterday grave you answer |
21:49:04 | FromDiscord | <Graveflo> I just asked that yesterday Ayy |
21:49:20 | FromDiscord | <Ayy Lmao> What a coincidence |
21:50:16 | FromDiscord | <Elegantbeef> Is grave not going to answer and force ayy to search?! |
21:50:31 | FromDiscord | <Elegantbeef> Real time chat is such a ephemeral resource |
21:50:44 | FromDiscord | <Graveflo> sent a code paste, see https://play.nim-lang.org/#ix=4xcK |
21:50:53 | FromDiscord | <Graveflo> I think |
21:51:03 | FromDiscord | <Elegantbeef> `(a: ref T or var T)` |
21:51:05 | FromDiscord | <Graveflo> no you said to make a generic |
21:51:11 | FromDiscord | <Graveflo> ah crap |
21:51:24 | FromDiscord | <Elegantbeef> Yes generics are how you make a procedure work with multiple types... |
21:52:09 | FromDiscord | <Graveflo> is the compiler smart enough not to bloat up the executable size if you do this often? `[]` is ugly but I'd take it over 2xing my code storage |
21:52:43 | FromDiscord | <Elegantbeef> What? |
21:52:52 | FromDiscord | <Elegantbeef> Generics are only included if instantiated |
21:53:17 | FromDiscord | <Graveflo> say you are working with both ref versions and non ref versions. Then there are two compiled versions then? |
21:53:27 | FromDiscord | <Elegantbeef> Of course they're two different types |
21:53:40 | FromDiscord | <Ayy Lmao> If you do t[].foo() every time you never instantiate the ref version though right? |
21:53:50 | FromDiscord | <Elegantbeef> Right |
21:54:01 | FromDiscord | <Graveflo> well versions of the compiled `proc`? if that is the case then `[]` should work with only one compiled version of the `proc` |
21:54:16 | FromDiscord | <Graveflo> smaller bin? |
21:54:23 | FromDiscord | <Elegantbeef> Sure you can always just make an overload that calls the var if you're anally retentive |
21:54:50 | FromDiscord | <Elegantbeef> There you go |
21:54:52 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/t0q0R |
21:55:04 | FromDiscord | <Elegantbeef> But the question was not "how do i overload" |
21:55:13 | FromDiscord | <Elegantbeef> It was "How do i make a procedure work on two types" 😛 |
21:57:23 | FromDiscord | <Elegantbeef> As nice as polymorphic procedures sound monomorphic is almost always much saner |
21:57:50 | FromDiscord | <Graveflo> so, if you have these code paths that are `var SomeObj` I feel like you aren't going to be de-referencing very often bc once you chuck it into the proc its doesn't need it anymore. I feel like `[]` might be cleaner |
21:58:00 | FromDiscord | <Graveflo> this is for `RootObj` only tho |
21:58:40 | FromDiscord | <Elegantbeef> Even though `var object or ref object` can be used identically inside the procedure you have to remember every field access in Nim has a nil reference check, and the procedure might need ref counting on any 'copies' |
21:58:54 | FromDiscord | <Elegantbeef> There isnt really a way to make a polymorphic version so 2 procedures are required |
21:59:15 | FromDiscord | <Elegantbeef> You remove the need by dereferencing insider the overload of course |
22:00:25 | FromDiscord | <Graveflo> yea that totally makes sense. So just to be clear if `myThing` has code paths through more procs that use `var int` this comes without consequence |
22:01:16 | FromDiscord | <Elegantbeef> Right operating on a field of a object being it ref or not does not have any implications on the operations |
22:01:29 | FromDiscord | <Graveflo> I love it |
22:01:50 | FromDiscord | <Elegantbeef> Nim is memory safe so accessing anything on a `ref` has memory sanity checks |
22:02:58 | FromDiscord | <Elegantbeef> So in the case of the above overload you might generate a procedure, but in reality any good C compiler will inline it |
22:03:44 | FromDiscord | <Elegantbeef> So it's likely a 0 cost abstraction in 99% of cases that doesnt cause you to manually `[]` |
22:04:19 | FromDiscord | <Elegantbeef> @Ayy Lmao\: this should answer your question right? 😛 |
22:04:43 | FromDiscord | <Ayy Lmao> In reply to @Elegantbeef "<@277645179115143178>\: this should answer": I'm having some issues actually, not sure if it's a compiler bug or something. |
22:04:52 | FromDiscord | <Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4xcQ |
22:05:02 | FromDiscord | <Ayy Lmao> Says I can't assign to baseField |
22:05:03 | FromDiscord | <Elegantbeef> `(var Foo) or (ref Foo)` |
22:05:18 | FromDiscord | <Ayy Lmao> Still doesn't work |
22:05:31 | FromDiscord | <Graveflo> or `foo: (var Foo or ref Foo)` |
22:05:47 | FromDiscord | <Ayy Lmao> No luck |
22:07:16 | FromDiscord | <Ayy Lmao> It doesn't work on the version of Nim I'm using at least |
22:07:31 | FromDiscord | <Elegantbeef> This is probably an issue with that inheritance and the generic |
22:07:37 | FromDiscord | <Graveflo> me neither. I'm trying to wrap my head around the generic object |
22:07:50 | FromDiscord | <Ayy Lmao> It's beefs insane dependency injection trick |
22:07:58 | FromDiscord | <Ayy Lmao> It's turning out to be really powerful |
22:08:33 | FromDiscord | <Elegantbeef> Just do the overload method |
22:08:54 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4xcS |
22:09:12 | FromDiscord | <Elegantbeef> It's clearly an issue with that inheritance |
22:09:39 | FromDiscord | <Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4xcT |
22:10:05 | FromDiscord | <Ayy Lmao> Like you can statically dispatch a template |
22:10:25 | FromDiscord | <Elegantbeef> callable |
22:10:30 | FromDiscord | <Ayy Lmao> In reply to @Elegantbeef "Just do the overload": I'll try it |
22:10:44 | FromDiscord | <Elegantbeef> Quit using a template there |
22:10:44 | FromDiscord | <Elegantbeef> I'll slap you |
22:11:15 | FromDiscord | <Ayy Lmao> What's wrong with a template? |
22:11:28 | FromDiscord | <Elegantbeef> In this case you are just using the template to spite me |
22:11:41 | FromDiscord | <Elegantbeef> Use a procedure unless you actually need a template |
22:11:51 | FromDiscord | <Elegantbeef> And if you need a template inside a generic procedure top it |
22:11:54 | FromDiscord | <Elegantbeef> stop it\ |
22:11:58 | FromDiscord | <Ayy Lmao> I was mainly doing it to show it was possible haha |
22:18:21 | FromDiscord | <Graveflo> sent a code paste, see https://play.nim-lang.org/#ix=4xcU |
22:19:05 | FromDiscord | <Elegantbeef> No |
22:19:08 | FromDiscord | <Elegantbeef> `Bar[Foo: Foo]` would |
22:19:17 | FromDiscord | <Elegantbeef> `Bar[Foo]` is a generic type that can have any type inside `Foo` |
22:19:40 | FromDiscord | <Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4xcV |
22:19:48 | FromDiscord | <Ayy Lmao> You can inject whatever you want for Base |
22:20:22 | FromDiscord | <Graveflo> oh so it is only really used as above. What I posted doesn't really make sense? |
22:21:04 | FromDiscord | <Graveflo> nvm `Foo` is just analogous to `T`? |
22:21:15 | FromDiscord | <Ayy Lmao> In reply to @Graveflo "nvm `Foo` is just": Yeah |
22:21:23 | FromDiscord | <Ayy Lmao> In your example it is |
22:22:13 | FromDiscord | <Graveflo> whoops ok. So it only doesn't make sense for the fact that I chose a really bad generic name. So then your code makes Foo a descendant of anything? |
22:23:39 | FromDiscord | <Ayy Lmao> In reply to @Graveflo "whoops ok. So it": Correct, you can inject the parent type and write generic procedures that use the parent type in an abstract way, then the user can inject the parent to implement functionality. |
22:24:46 | FromDiscord | <Ayy Lmao> Beef sent me down the rabbit hole of evaluating if it's a plausible way to code things. |
22:24:47 | FromDiscord | <Graveflo> very very interesting. I think I might prefer methods for something like that, but still. I like it |
22:25:06 | FromDiscord | <Ayy Lmao> I am toying around with it for GUI code. |
22:25:44 | FromDiscord | <Ayy Lmao> In reply to @Graveflo "very very interesting. I": The difference is this statically dispatches the methods. |
22:27:24 | FromDiscord | <Graveflo> yea that is basically a way cleaner way of doing generic dep injection. I've been toying with generics vs dyn dispatch recently. Obviously there are places where both shine |
22:28:43 | FromDiscord | <Graveflo> im most confused about how my generics-based code seems to run slower then method-based code. I was trying to test what the performance hit was and I guess my test is bad bc it showed generics as being slower despite their static linking |
22:29:13 | FromDiscord | <Ayy Lmao> I haven't really profiled it but I don't know why it would be slower. |
22:30:09 | FromDiscord | <Graveflo> also the compiler is quite frustrating with error messages in generics and imports are a little weird but still they are very powerful |
22:31:04 | FromDiscord | <Ayy Lmao> Yeah there is a lot of mental overhead and complications with doing it so I would avoid it when possible. |
22:35:36 | FromDiscord | <Elegantbeef> Yea my GUI erroring is always fun to run diagnostics 😄 |
22:57:19 | * | xet7 joined #nim |
23:00:02 | * | marcus quit (Remote host closed the connection) |
23:00:45 | * | marcus joined #nim |
23:04:47 | * | xet7 quit (Ping timeout: 250 seconds) |
23:17:19 | * | xet7 joined #nim |
23:18:00 | * | xet7 quit (Remote host closed the connection) |
23:59:41 | FromDiscord | <michaelb.eth> Any known tricks to improve lcov reports re: Nim code? The lines displayed as covered (or not) and the numbers reported sometimes don't make much sense. |