00:07:52 | * | ltriant joined #nim |
00:14:23 | * | ltriant quit (Ping timeout: 246 seconds) |
00:14:57 | * | ltriant joined #nim |
00:25:35 | * | ltriant quit (Ping timeout: 246 seconds) |
00:30:23 | FromDiscord | <c4ulmu> sent a code paste, see https://play.nim-lang.org/#ix=4jJV |
00:31:36 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4jJX |
00:31:44 | PMunch | New version of autotemplates out supporting case objects and inheritance :) |
00:31:54 | PMunch | https://github.com/PMunch/autotemplate |
00:32:06 | * | PMunch quit (Quit: leaving) |
00:33:12 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4jJY |
00:34:21 | FromDiscord | <c4ulmu> Yes, thank you. Both examples are working |
00:34:59 | FromDiscord | <c4ulmu> Second is easier, I agree. I will use it. But first is very helpful too |
00:35:16 | FromDiscord | <c4ulmu> I didn't know about `default` |
01:01:00 | FromDiscord | <sOkam!> sent a code paste, see https://paste.rs/0Ms |
01:01:43 | FromDiscord | <sOkam!> (edit) "https://play.nim-lang.org/#ix=4jK2" => "https://play.nim-lang.org/#ix=4jK1" |
01:02:08 | FromDiscord | <jtv> Sequences have copy semantics by default, and by using object instead of ref object, so do your data types. |
01:02:34 | FromDiscord | <sOkam!> i see, kk |
01:03:14 | FromDiscord | <jtv> sent a code paste, see https://play.nim-lang.org/#ix= |
01:04:20 | FromDiscord | <sOkam!> whats the difference between ref and ptr in this case? |
01:04:35 | FromDiscord | <sOkam!> i get that ptr is just an adress, like in C. but what is ref in this context? |
01:04:52 | FromDiscord | <jtv> In nim, pointers are for references unmanaged memory, generally to external C |
01:04:58 | FromDiscord | <Elegantbeef> `ref` in Nim is garuenteed to be heap allocated and is automatically managed |
01:05:22 | FromDiscord | <sOkam!> ic, then target for this should be using ref, yeah |
01:05:26 | FromDiscord | <jtv> Yes |
01:05:28 | FromDiscord | <Elegantbeef> Likely |
01:05:36 | FromDiscord | <Elegantbeef> Remember they're nilable though |
01:06:04 | FromDiscord | <sOkam!> what do you mean? that a ref could be pointing to nil, so you have to check for that case? |
01:06:55 | FromDiscord | <Elegantbeef> The default value of `ref T` is nil |
01:07:07 | FromDiscord | <sOkam!> kk |
01:07:45 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4jK6 |
01:08:49 | FromDiscord | <jtv> Generally yes. As Elegantbeef said, as long as you are sure that you can't have nil values. A lot of people make heavy use of the options module to help add static checking for nil state |
01:09:06 | FromDiscord | <jtv> And there's some experimental not-nil tracking you could look at |
01:09:39 | FromDiscord | <sOkam!> oh so you cannot check for nil without the options module? |
01:10:01 | FromDiscord | <jtv> You can, but you're not going to catch such errors at compile time that way |
01:12:49 | FromDiscord | <sOkam!> ah, by static you meant compile time. kk, makes sense |
01:13:34 | FromDiscord | <jtv> Yeah, that's generally going to be what people mean by static here |
01:16:15 | FromDiscord | <sOkam!> how do you define the data or a ref object? just like a regular object? |
01:16:20 | FromDiscord | <jtv> Yes |
01:16:44 | FromDiscord | <jtv> You can instantiate with: x = MyObject(field: value, field2: value2, ...) |
01:17:17 | FromDiscord | <sOkam!> what do you mean? |
01:17:44 | FromDiscord | <jtv> What language are you coming from? |
01:17:48 | FromDiscord | <sOkam!> C |
01:17:56 | FromDiscord | <sOkam!> and also translating C |
01:18:04 | FromDiscord | <sOkam!> (edit) "and also translating C ... " added "for this usecase" |
01:18:13 | FromDiscord | <jtv> So it's essentially going to malloc your object on the heap, and initialize any fields you do pass in |
01:18:27 | FromDiscord | <jtv> x = MyObject() is fine, and will set all values to the default value |
01:19:03 | FromDiscord | <sOkam!> so it behaves like `ref object of RootObj`, where you need to first say `new` so that it works? |
01:19:37 | FromDiscord | <jtv> You don't need to say new. Convention is often to add a constructor-style function called newWhatevertype() |
01:20:06 | FromDiscord | <sOkam!> yeah, but inside that newThing proc... you do create the output with new, right? at least that's what i've been doing |
01:20:09 | FromDiscord | <jtv> And adding "of RootObj" is really just adding the inheritance relationship |
01:20:20 | FromDiscord | <sOkam!> I just didn't catch that `ref object of ...` is the same as a`ref object` |
01:20:52 | FromDiscord | <jtv> Well, I'm only about 6 weeks into nim myself, but I'm pretty sure you don't need the new keyword in either circumstance |
01:21:11 | FromDiscord | <Elegantbeef> you can do `new result` |
01:21:20 | FromDiscord | <sOkam!> yeah, that's what I've been using |
01:22:02 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4jK9 |
01:22:05 | FromDiscord | <Elegantbeef> That's the same as `result = TypeThing()` |
01:22:15 | FromDiscord | <Elegantbeef> you can also just do `TypeThing(blabla: 1)` |
01:22:51 | FromDiscord | <sOkam!> yeah, i just didn't catch that ref object is just the exact same as ref object of |
01:23:22 | FromDiscord | <jtv> Well, w/o inheritance of any sort 🙂 |
01:23:31 | FromDiscord | <Elegantbeef> Well it's not the "Exact same" |
01:23:50 | FromDiscord | <Elegantbeef> They're both heap allocated but one lacks runtime type information or atleast should |
01:24:01 | FromDiscord | <sOkam!> well, but in practice you declare the thing with the same syntax, that's what i meant |
01:24:27 | FromDiscord | <Elegantbeef> Safe Nim is nice in that regard since you know all `ref T`s are heap allocated and all `T`s are stack |
01:24:55 | FromDiscord | <Elegantbeef> IE you know you shouldnt stack allocate `array[100000, int]` 😄 |
01:27:17 | FromDiscord | <sOkam!> Does nimsuggest crash all the time for you guys too? |
01:29:03 | FromDiscord | <jtv> I don't actually use it, am an old emacs greybeard :/ |
01:29:25 | FromDiscord | <Elegantbeef> Code by feel |
01:39:13 | FromDiscord | <sOkam!> how do arc/orc know when to release an object with no references left? (in simple terms, in know it must be complex) |
01:40:00 | FromDiscord | <sOkam!> i know its not the classic "stop the world" idea, but my vague understanding stops there 🙈 |
01:42:21 | FromDiscord | <Elegantbeef> reference count |
01:42:22 | FromDiscord | <jtv> My understanding, without having dug into the implementation yet, is that it's generally reference counting heap objects, but also running a collector, but only where there are cycles in those references |
01:42:56 | FromDiscord | <Elegantbeef> Arc doesnt do cyclical types |
01:42:57 | FromDiscord | <Elegantbeef> so it just checks if ref == 0 |
01:42:57 | FromDiscord | <Elegantbeef> If so it deallocs |
01:43:26 | FromDiscord | <jtv> Ah, must have confused it w/ orc. |
01:44:03 | FromDiscord | <Elegantbeef> Yea orc uses a mark and sweep algo for the deallocation of cycles |
01:44:05 | FromDiscord | <sOkam!> whats a cycle? i never understood that 🤔 |
01:44:13 | FromDiscord | <Elegantbeef> A ref that references itself |
01:44:22 | FromDiscord | <jtv> Or when objects mutually refer to each other |
01:44:27 | FromDiscord | <sOkam!> ic |
01:44:30 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/BRs |
01:44:57 | FromDiscord | <sOkam!> why would you use something like that, in practical use? |
01:45:00 | FromDiscord | <jtv> A doubly linked list |
01:45:03 | FromDiscord | <jtv> etc |
01:45:06 | FromDiscord | <jtv> It's common |
01:45:47 | FromDiscord | <jtv> I wonder how much pain it's going to cause w/ people having memory leaks they don't notice? |
01:45:59 | FromDiscord | <Elegantbeef> Orc is deafault and suggested |
01:46:42 | FromDiscord | <jtv> Cool, I thought it was going to be arc in 2.0, but given that understanding I'm glad it's orc 🙂 |
01:46:50 | FromDiscord | <Elegantbeef> And orc could be turned into a cycle collector |
01:46:58 | FromDiscord | <Elegantbeef> detector\ |
01:48:58 | FromDiscord | <jtv> I was impressed at the numbers I looked at on relative performance, especially since the CW has always been reference counting is higher overhead but amortized somewhat better since you don't have a big stop-the-world event, or what have you. |
01:52:47 | FromDiscord | <Elegantbeef> Yea though Nim generally uses less GC than javaj and firends |
01:57:58 | FromDiscord | <jtv> Yes, that's not tough, and expected given how much Nim leaves on the stack! |
01:59:05 | FromDiscord | <jtv> Hey, with concepts, do they imply mixin? I just realized I've got a case where I'm calling a function defined elsewhere that should be declared as mixin per the docs, but not getting an error (it's working) |
01:59:40 | FromDiscord | <Elegantbeef> Overloaded symbols are mixin'd by default |
02:00:13 | FromDiscord | <gabreal> Hey all, getting the following error `/Library/Developer/CommandLineTools/SDKs/MacOSX13.1.sdk/usr/include/machine/_types.h:36:2: error: architecture not supported` because of the following is failing `#if defined (i386) || defined(x86_64)` not sure how to make nim say that it wants i386 though |
02:00:29 | FromDiscord | <jtv> Ah, did that change at some point? I saw a forum thread from 3 years ago that indicated the opposite |
02:01:55 | FromDiscord | <gabreal> to add a bit of context for my issue, I am passing `--cpu:i386` so I would've thought it would've just worked |
02:06:46 | FromDiscord | <jtv> I've never tried cross-compiling w/ nim, but it's calling down to Apple's C compiler, which is going to require -target=... passed to it to. cross-compile. So def make sure you're doing whatever needs to happen for that. Just defining i386 wouldn't be enough |
02:07:51 | FromDiscord | <jtv> Generally, I haven't cross-compiled in years. It's a bit of an anti-pattern given the availability of cheap ephemeral cloud resources that are easily available from any CI/CD pipeline... |
02:13:52 | FromDiscord | <gabreal> Yeah I realize but I'm actually targeting wasm haha |
02:17:01 | FromDiscord | <sOkam!> is it good practice to use `var thing = MyType()` even for non-ref objects? |
02:20:57 | FromDiscord | <gabreal> @jtv thanks btw you got me in a better direction atm |
02:25:01 | FromDiscord | <jtv> It's always good to initialize fields of objects before you use them, instead of the implicit default initialization |
02:25:40 | FromDiscord | <jtv> In fact, I think nim 2.0 use before explicit initialization is at least going to be a warning |
02:31:45 | * | rlitp joined #nim |
02:59:30 | FromDiscord | <Bung> but that would make default constructor un available ? |
03:01:05 | FromDiscord | <Bung> it works most of time, if it dont work for you, you can add `requiresInit` pragma to the type |
03:19:04 | FromDiscord | <sOkam!> I was thinking for the "default" case, where you don't need an explicit constructor but the type might become a ref in the future... creating the variable with `var thing = MyType()`, instead of `var thing: MyType`, would avoid having to refactor any spot where the variable of that type is initialized |
03:21:18 | * | ehmry quit (Ping timeout: 272 seconds) |
03:21:28 | FromDiscord | <Elegantbeef> Well also with strict def in 2.0 it's saner |
03:21:36 | * | ehmry joined #nim |
03:31:00 | FromDiscord | <IsaacPaul> sent a code paste, see https://play.nim-lang.org/#ix=4jKj |
03:31:24 | FromDiscord | <IsaacPaul> (edit) "https://play.nim-lang.org/#ix=4jKj" => "https://paste.rs/dDD" |
03:45:35 | FromDiscord | <gabreal> Beef |
03:45:43 | FromDiscord | <gabreal> Wanna help me figure out why Nim is lying to my clang |
03:46:15 | FromDiscord | <gabreal> On Linux I can build to wasm fine but if I use the c headers that macos has then there are issues :p |
03:48:48 | FromDiscord | <Elegantbeef> `--listCmd` |
03:49:24 | FromDiscord | <<She>Horizon</Her>> Maybe you need `--platform:linux` too? Since it's like a weird linux target |
03:49:35 | FromDiscord | <<She>Horizon</Her>> But really, standalone should be used iirc |
03:49:53 | FromDiscord | <Elegantbeef> https://github.com/beef331/wasm3/blob/master/wasmsources/config.nims |
03:49:56 | FromDiscord | <Elegantbeef> Is what my config is |
03:50:12 | FromDiscord | <Elegantbeef> This is for emscripten |
03:50:59 | FromDiscord | <<She>Horizon</Her>> Ah neay |
03:51:30 | FromDiscord | <<She>Horizon</Her>> Oh wait yeah also iirc `proc main() {.importc: "NimMain()".}` needs to be done too |
03:51:47 | FromDiscord | <Elegantbeef> With orc/arc it's only needed for top level intialisation |
03:51:58 | FromDiscord | <gabreal> I can't have a main method |
03:52:06 | FromDiscord | <gabreal> I'm trying to compile for straight standalone wasm |
03:52:45 | FromDiscord | <Elegantbeef> My config removes the main |
03:53:14 | FromDiscord | <gabreal> Yeah but emscripten provides all the shimlib stuff I thought |
03:53:55 | FromDiscord | <<She>Horizon</Her>> Yeah that's what i was thinking |
03:54:06 | FromDiscord | <<She>Horizon</Her>> Emscripten doesn't like the Nim provided main for some reason |
03:54:34 | FromDiscord | <Elegantbeef> It doesnt mind it afaik |
03:54:58 | FromDiscord | <Elegantbeef> The thing is it doesnt make much since given the wasm runtime doesnt call main, and you need to explicitly do it |
03:54:58 | FromDiscord | <<She>Horizon</Her>> Remember it cried when i did it? |
03:55:15 | FromDiscord | <Elegantbeef> I really dont think emcc cares |
03:55:18 | FromDiscord | <Elegantbeef> I could be wrong |
03:55:34 | FromDiscord | <<She>Horizon</Her>> Fair, in my code i called it explicitly (to pretend it was in a shell or something) |
03:56:30 | FromDiscord | <gabreal> I've been trying to get https://github.com/yglukhov/wasmrt this working but that is a struggle lol |
03:57:13 | FromDiscord | <Elegantbeef> If you're targetting a web browser i'm mostly useless |
03:57:21 | FromDiscord | <gabreal> I'm targeting server 😉 |
03:57:27 | FromDiscord | <Elegantbeef> I only know using wasm as a portable runtime and nothing related to browser |
03:57:46 | FromDiscord | <gabreal> The portable environment I'm targeting doesn't support WASI afaik |
03:58:03 | FromDiscord | <gabreal> I'm literally just trying to make a little nim wasm binary where I export 3 methods for the vm to call into haha |
03:58:13 | FromDiscord | <Elegantbeef> So then copy my config |
03:58:45 | FromDiscord | <Elegantbeef> https://github.com/beef331/wasm3/blob/master/wasmsources/hooks.nim |
03:58:50 | FromDiscord | <Elegantbeef> Compiles with that config |
03:59:11 | FromDiscord | <Elegantbeef> https://github.com/beef331/wasm3/blob/master/tests/test1.nim#L81-L87 |
03:59:18 | FromDiscord | <Elegantbeef> Works just fine in my experience |
04:00:02 | FromDiscord | <gabreal> Going to try and get that config working 🙂 |
04:00:08 | FromDiscord | <gabreal> Do you know how I can disable all floats ? |
04:00:11 | FromDiscord | <gabreal> in nim ^ |
04:00:21 | FromDiscord | <gabreal> I can't use them in the environment I'm going for |
04:00:28 | FromDiscord | <Elegantbeef> Dont think you can |
04:00:38 | FromDiscord | <gabreal> Welp |
04:00:43 | FromDiscord | <gabreal> Praying something doesn't use it 😄 |
04:01:10 | FromDiscord | <Elegantbeef> Well most of the stdlib should work where a FPU doesnt exist |
04:01:28 | FromDiscord | <gabreal> Yeah I need to look through the stdlib to see what I can realistically use |
04:01:29 | FromDiscord | <Elegantbeef> Fairly certain araq is concerned about that but idk |
04:02:04 | FromDiscord | <gabreal> Thanks beef btw |
04:05:14 | * | arkurious quit (Quit: Leaving) |
04:14:48 | FromDiscord | <Elegantbeef> Will also note you could look at nlvm @gabreal it's stdlib doesnt support WASI presently, but it can generate wasm binaries |
04:15:07 | FromDiscord | <gabreal> unfortunately I can't do nlvm it wont compile for me I can't figure out why |
04:15:11 | FromDiscord | <gabreal> Mostly a macos issue |
04:19:03 | * | rlitp quit (Ping timeout: 260 seconds) |
04:29:02 | * | genpaku quit (Remote host closed the connection) |
04:32:06 | * | rlitp joined #nim |
04:32:42 | * | genpaku joined #nim |
05:03:07 | * | nick2 quit (Quit: WeeChat 3.7.1) |
05:31:45 | * | ltriant joined #nim |
05:38:31 | FromDiscord | <dizzyliam [they/them]> can one tell nimble to build a file using the js backend? |
05:41:37 | * | ltriant quit (Ping timeout: 268 seconds) |
05:47:42 | FromDiscord | <albassort> is there a library with more anon compatible functions |
05:48:07 | FromDiscord | <albassort> In reply to @karma_corrections "can one tell nimble": -defined js |
05:49:37 | FromDiscord | <albassort> e.g |
05:49:39 | FromDiscord | <albassort> some in js |
05:49:53 | NimEventer | New thread by archnim: Is setControlCHook still supported ?, see https://forum.nim-lang.org/t/9770 |
05:49:53 | FromDiscord | <albassort> in the nim stdlib we only have map and filter? |
05:51:12 | FromDiscord | <albassort> oh ok we have anyIt and allIt |
05:53:52 | * | rlitp left #nim (#nim) |
05:54:29 | * | ltriant joined #nim |
06:01:13 | * | ltriant quit (Ping timeout: 252 seconds) |
06:02:05 | * | rockcavera quit (Remote host closed the connection) |
06:17:29 | FromDiscord | <ronaldinio> I recently came across Nimskull, and was given the impression core maintainers are ditching in support of Nimskull -↵before realizing that was mostly misinformation. I do mean to speak ill of anyone, but it's rather ambitious and I don't↵currently see directive beyond modernization. To what capacity the efforts are worthwhile, I don't know.↵Anyone have a relationship or insight? |
06:17:44 | FromDiscord | <ronaldinio> (edit) "ill of anyone," => "ill," |
06:31:35 | termer | I saw nimskulll as well and I think the point is to make it more community and standard driven than nim |
06:32:01 | termer | that's the impression I get anyway |
06:44:02 | FromDiscord | <JeysonFlores> What is the "effect system" in Nim and what exactly does? |
06:46:50 | FromDiscord | <Elegantbeef> The effect tracking system tracks effects, these can be user defined or compiler inferred like `raises: []` |
06:46:58 | FromDiscord | <Elegantbeef> This allows you to disallow procedures with effects or that lack effects |
07:32:39 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4jKX |
07:33:02 | FromDiscord | <voidwalker> 90gb file, no space taken on disk |
07:39:25 | FromDiscord | <Prestige> neat |
07:47:58 | FromDiscord | <sOkam!> If I have a ref object containing other objects, because I want the data to be heap-alloc.... do I need to mark the containing objects also as ref, or is that done auto? |
07:48:36 | FromDiscord | <Elegantbeef> Well they're heap allocated of course, but they're not references |
07:48:38 | FromDiscord | <sOkam!> Also, does Nim heap alloc big data objects when they should be, or do they need to be marked ref instead? |
07:48:38 | FromDiscord | <Rika> Anything within the reference is gonna be stored on the heap |
07:48:42 | FromDiscord | <Elegantbeef> Think `seq[T]` it heap allocates |
07:48:51 | FromDiscord | <Rika> But will be value semantics |
07:49:00 | FromDiscord | <Elegantbeef> Nim doesnt heap allocate anything automatically |
07:49:27 | FromDiscord | <Elegantbeef> `ref int` is a heap allocated int |
07:49:32 | FromDiscord | <Elegantbeef> For instance |
07:49:37 | FromDiscord | <sOkam!> even if the data block is big? |
07:49:45 | FromDiscord | <Elegantbeef> correct |
07:49:54 | FromDiscord | <sOkam!> interesting, didn't know that |
07:49:57 | FromDiscord | <Elegantbeef> `var a: array[10000, int]` will attempt to allocate `a` on the stack\` |
07:51:02 | FromDiscord | <sOkam!> so if I have `type MyHeapType = ref object`, everything contained will be heap alloc, just by being part of the other, right? |
07:51:23 | FromDiscord | <Elegantbeef> Correct the entire point of `ref T` is to say "this is a heap allocated version of X" |
07:51:36 | FromDiscord | <sOkam!> kk makes sense |
07:51:42 | FromDiscord | <Elegantbeef> Value types will be stored at the pointer, ref types stored at their pointer |
07:52:27 | FromDiscord | <Elegantbeef> If you just think of `ref` as a pointer this is all easier |
07:53:00 | FromDiscord | <sOkam!> yeah, i guess. but i just didn't know if the contents would be also treated the same |
07:56:14 | FromDiscord | <sOkam!> what happens if I create a non-ref object inside a function that returns it, and assign the result to the contents of another ref object?↵Is the data copied or is the pointer to the data moved instead? |
07:56:49 | FromDiscord | <Elegantbeef> Non ref types are values |
07:56:50 | FromDiscord | <Rika> Copied |
07:56:58 | FromDiscord | <Rika> There are no pointers for value types |
07:56:59 | FromDiscord | <Elegantbeef> More likely moved |
07:57:13 | FromDiscord | <Rika> I guess with newer Nim it’s moved |
07:57:33 | FromDiscord | <sOkam!> starting to see the importance of move semantics, i guess |
07:58:00 | FromDiscord | <Rika> How moving |
07:58:11 | FromDiscord | <sOkam!> 😄 |
07:58:53 | FromDiscord | <Elegantbeef> Worth noting that moving value types still copies all values |
07:59:21 | FromDiscord | <Elegantbeef> Like `array[10, int]` is the same as copying |
08:00:24 | FromDiscord | <enthus1ast> That's great I had pretty much the same issues that you had with proper error lines, that's one reason nimja does not report errors↵(<@709044657232936960_=50=4dunch=5b=49=52=43=5d>) |
09:03:54 | FromDiscord | <sOkam!> Do you think this is creating the equivalent of a `ref object`, or is it actually creating a copy instead?↵https://github.com/heysokam/idtech3-modules/blob/a5cd0d55a32f27fc97799ac46095933d1453f013/src/col/c/load.c#L41-L50↵Struggling to understand if I should translate as two sequences containing ref types _(the data is already stored somewhere else in the container object)_ or if I should duplicate the data instead in some way🤔 |
09:05:57 | FromDiscord | <Elegantbeef> It's copying afaict |
09:06:15 | FromDiscord | <Elegantbeef> I could be wrong it's horribly formatted and very unreadable |
09:06:48 | FromDiscord | <sOkam!> og wasn't too much better. but let me find it just in case |
09:07:47 | FromDiscord | <Elegantbeef> Aslong as you properly use `ref` where it uses `T` it should be fine if you copy their impl |
09:07:54 | FromDiscord | <sOkam!> https://github.com/heysokam/kua/blob/c9e9220edd98daedf1f558346a1d5e25bc7e0b27/src/engine/qcommon/cm_load.c#L155-L167 |
09:08:19 | FromDiscord | <sOkam!> (edit) "https://github.com/heysokam/kua/blob/c9e9220edd98daedf1f558346a1d5e25bc7e0b27/src/engine/qcommon/cm_load.c#L155-L167" => "This is the unmodified code. I only changed the formatting↵https://github.com/heysokam/kua/blob/c9e9220edd98daedf1f558346a1d5e25bc7e0b27/src/engine/qcommon/cm_load.c#L155-L167" |
09:08:30 | FromDiscord | <sOkam!> (edit) "formatting↵https://github.com/heysokam/kua/blob/c9e9220edd98daedf1f558346a1d5e25bc7e0b27/src/engine/qcommon/cm_load.c#L155-L167" => "formatting for my other link↵https://github.com/heysokam/kua/blob/c9e9220edd98daedf1f558346a1d5e25bc7e0b27/src/engine/qcommon/cm_load.c#L155-L167" |
09:08:39 | FromDiscord | <sOkam!> (edit) "my" => "they" |
09:08:43 | FromDiscord | <sOkam!> (edit) "they" => "the" |
09:09:10 | FromDiscord | <sOkam!> In reply to @Elegantbeef "Aslong as you properly": so you mean storing a reference instead of a copy? |
09:09:44 | FromDiscord | <Elegantbeef> I mean if they use `T` you use `ref` |
09:09:58 | FromDiscord | <Elegantbeef> Or `seq` depending on whether it's an collection or pointer type |
09:11:33 | FromDiscord | <sOkam!> yeah but in this case they are using cLeaf instead of cLeaf inside the cModel type↵https://github.com/heysokam/kua/blob/c9e9220edd98daedf1f558346a1d5e25bc7e0b27/src/engine/qcommon/cm_local.h#L92-L95 |
09:12:19 | FromDiscord | <Elegantbeef> So then you use a non reference version |
09:12:54 | FromDiscord | <sOkam!> how do you ask nim to create a copy of a reference type? I have the others stored as ref |
09:12:58 | FromDiscord | <Elegantbeef> C is extremely hard to understand, so I cannot really say much |
09:13:05 | FromDiscord | <Elegantbeef> There are a few ways |
09:13:33 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4jLi |
09:13:41 | FromDiscord | <sOkam!> In reply to @Elegantbeef "C is extremely hard": that's the essence of why im porting the code. I really don't want to deal with a whole engine full of this stuff anymore 😔 |
09:13:57 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4jLj |
09:14:57 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/rOJ |
09:15:53 | FromDiscord | <Elegantbeef> Then on assignment you can do `myVal = myRef[]` |
09:16:07 | FromDiscord | <Elegantbeef> Or `myRef[] = myVal` |
09:16:17 | FromDiscord | <Elegantbeef> since dereferencing a reference is an LValue |
09:16:23 | FromDiscord | <sOkam!> kk |
09:16:42 | FromDiscord | <sOkam!> I like the latter, I guess i just need to find a good name for the non-ref type |
09:17:16 | FromDiscord | <Elegantbeef> The Nim convention is to prefix it with T |
09:17:32 | FromDiscord | <Elegantbeef> Or if the value is more common prefix the ref with P |
09:17:34 | FromDiscord | <sOkam!> T standing for type, i guess? |
09:17:51 | FromDiscord | <Elegantbeef> Yea |
09:18:03 | FromDiscord | <Elegantbeef> I know status says "always suffix a type with `ref`" |
09:18:03 | FromDiscord | <sOkam!> problem is TypeMyType doesn't make sense in my brain |
09:18:18 | FromDiscord | <Elegantbeef> Could do VMyType |
09:18:29 | FromDiscord | <Elegantbeef> or MyTypeV |
09:19:03 | FromDiscord | <sOkam!> what does V stand for? |
09:19:05 | FromDiscord | <sOkam!> value? |
09:19:10 | FromDiscord | <Elegantbeef> Yes |
09:19:39 | FromDiscord | <sOkam!> i guess the opposite of a pointer is a value... i just never thought about that i think |
09:20:10 | FromDiscord | <Elegantbeef> Well they're Value Types and Reference Types |
09:20:22 | FromDiscord | <Elegantbeef> Value Types conventionally are stack allocated and as such are copy by value |
09:20:36 | FromDiscord | <sOkam!> makes sense, yeah |
09:20:41 | FromDiscord | <Elegantbeef> Reference Types are conventionally heap allocated and as such the stack allocated part is a pointer that is copied on value |
09:22:36 | FromDiscord | <Elegantbeef> "copied on value" ah yes brain |
09:23:49 | FromDiscord | <sOkam!> Maybe I don't need to do the explicit ref type, since its only stored in the container and the container is already a ref |
09:24:33 | FromDiscord | <sOkam!> that type specifically is currently not a ref, i thought it was but seems like this one might not need to be |
09:45:01 | * | ltriant joined #nim |
09:54:49 | * | ltriant quit (Ping timeout: 252 seconds) |
10:30:18 | * | ltriant joined #nim |
10:35:03 | * | ltriant quit (Ping timeout: 260 seconds) |
11:08:31 | FromDiscord | <stisa> I'm trying to update some code I wrote a year ago or so to work with latest nim, but I am getting "Error\: system module needs\: programResult", anyone knows if something changed there? I do see a `var programResult` with some note about it being deprecated in system.nim so it should not complain about it missing |
11:20:13 | FromDiscord | <ringabout> In reply to @stisa "I'm trying to update": Have you tried "--mm:refc"? |
11:23:22 | FromDiscord | <stisa> mmh nope, I'll give that a try. I'm running 1.9.1 btw |
11:25:42 | FromDiscord | <stisa> @ringabout\: tried with refc and also threads\:off, still erroring out |
11:26:29 | FromDiscord | <stisa> sent a code paste, see https://play.nim-lang.org/#ix=4jLI |
11:29:27 | FromDiscord | <ringabout> I have no idea, It is weird. |
11:30:35 | * | jmdaemon quit (Ping timeout: 246 seconds) |
11:42:08 | * | blami joined #nim |
11:44:04 | * | PMunch joined #nim |
11:45:06 | * | xet7 quit (Quit: Leaving) |
12:04:59 | FromDiscord | <Phil> So I have a script with a nice proc inside of it for users of my library.↵`imports.nims` with the proc `testSetup()`.↵I want users to install my library and be able to execute that testSetup as part of their config.nims or their nimble tasks or whatever.↵Apparently `import myLibrary/imports` doesn't do it though, is my goal achieveable? |
12:06:08 | FromDiscord | <Phil> The script is supposed to copy all code from `/src`, modify the exported procs inside nim files to add a pragma and store it in a separate folder, from which tests then import said modified code to run tests on it (instead of directly on the source-code) |
12:06:26 | FromDiscord | <kaddkaka> sent a code paste, see https://play.nim-lang.org/#ix=4jLS |
12:06:33 | FromDiscord | <Phil> (edit) "store" => "write" | "writeit ... infolder" added "to new files" | "folder," => "folder (same folder hierarchy as `/src`)," |
12:07:13 | FromDiscord | <Phil> In reply to @kaddkaka "Do others also get": Not on the current devel branch |
12:07:26 | FromDiscord | <Phil> Neither on 1.6.10 |
12:07:43 | FromDiscord | <Phil> Neither on 1.6.0 |
12:07:51 | FromDiscord | <Phil> Oh wait, nimsuggest |
12:07:52 | FromDiscord | <Phil> Never mind |
12:08:04 | FromDiscord | <Phil> I tend to only look at the compiler and its output |
12:08:08 | FromDiscord | <kaddkaka> I get lint warning on 1.6.6 from my vim plugin |
12:09:22 | FromDiscord | <kaddkaka> How can I run nimsuggest or the linter part of it standalone? |
12:13:04 | FromDiscord | <ringabout> `nimsuggest file` |
12:14:57 | * | koltrast quit (Quit: ZNC - http://znc.in) |
12:15:05 | FromDiscord | <sOkam!> In reply to @kaddkaka "Do others also get": nimsuggest freaks out a lot for generics |
12:15:18 | * | koltrast joined #nim |
12:16:32 | FromDiscord | <sOkam!> https://media.discordapp.net/attachments/371759389889003532/1057633146255966228/image.png |
12:17:03 | FromDiscord | <kaddkaka> sent a code paste, see https://play.nim-lang.org/#ix=4jLW |
12:17:32 | FromDiscord | <kaddkaka> (edit) "https://play.nim-lang.org/#ix=4jLW" => "https://paste.rs/RaW" |
12:17:52 | FromDiscord | <kaddkaka> In reply to @sOkam! "nimsuggest freaks out a": Unfortunately 😒 |
12:18:02 | FromDiscord | <sOkam!> Code compiles and runs just fine |
12:18:20 | FromDiscord | <kaddkaka> Yes I know |
12:18:38 | FromDiscord | <sOkam!> I had a situation like this with a generic type before. Just ignore those warns I guess, since the compiler works |
12:22:14 | PMunch | @Phil, I had to do the exact same thing for Ratel |
12:23:20 | PMunch | Basically you need to make it a normal `.nim` file in your `src` directory, then you can import it into your Nimscript and use it there |
12:24:36 | FromDiscord | <Phil> In reply to @PMunch "Basically you need to": The issue I'm running into there is that I need to use stuff from the nimscript module to create directories and copy files at compile time |
12:24:47 | FromDiscord | <Phil> Can't do that with STD os |
12:26:00 | FromDiscord | <Phil> So I require access to mkdir etc in whatever file in my library that ends up containing the procs to execute all this copying etc |
12:26:50 | FromDiscord | <Phil> But I take it from that, that you can't import Nims files from a lib into Nims files from the current project? |
12:28:43 | * | ltriant joined #nim |
12:31:14 | FromDiscord | <Phil> I'm forced to do all the things at compile time because I'm parsing Nim code and that does not work otherwise |
12:32:32 | PMunch | You should be able to just have those things in your .nim file |
12:33:00 | PMunch | I don't think Nim actually does anything different with .nim and .nims file while importing them |
12:33:00 | FromDiscord | <Phil> Can I access the nimscript module in a .Nim file? |
12:33:15 | PMunch | As long as it is imported from a .nims file I believe so |
12:33:37 | * | ltriant quit (Ping timeout: 256 seconds) |
12:33:40 | FromDiscord | <Phil> It's the mkdir and cpFile procs that I really need for the most part |
12:33:43 | PMunch | I use `switch` in my Ratel imported script |
12:33:58 | FromDiscord | <Phil> Alrighty, I'll look at it later, omw to lunch |
12:58:52 | FromDiscord | <vindaar> well, you can at runtime, if you use the compiler API. So if you're really running into trouble that's going to be the way to do it. It's just quite the learning required to get to where you're currently, as it's a bit rough around the edges for a newcomer↵(@Phil) |
13:01:33 | FromDiscord | <vindaar> an alternative is to call out to your terminal to do work for you using `execCmd` or whatever it was called in nimscript (or just using `shell`, which also works in nimscript, but iirc not within `nimvm` contexts, ugh) |
13:08:22 | FromDiscord | <vindaar> right, just tested. using `shell` in a macro results in annoying "cannot importc variable at compile time" errors, sigh. I tried to fix that at some point, but couldn't figure it out |
13:08:43 | FromDiscord | <vindaar> there's even an issue about it already https://github.com/Vindaar/shell/issues/18 🤣 |
13:30:04 | PMunch | Hmm, I have completed my wind speed/direction interpolation, but to be sure I don't have any crazy values I'd like to generate a series of data and animate it or something. Any ideas for how to do this easily? |
13:38:39 | FromDiscord | <vindaar> did you see my gist about that the other day btw? |
13:38:53 | PMunch | About the wind direction stuff? |
13:38:55 | PMunch | No I did not |
13:38:58 | FromDiscord | <vindaar> yeah |
13:39:17 | FromDiscord | <vindaar> https://gist.github.com/Vindaar/1e50a8515e87058033de30b2ceb92fa5#file-weather_wind_interpolation-nim |
13:39:21 | FromDiscord | <vindaar> I pinged you about it, but guess you were offline |
13:41:09 | FromDiscord | <vindaar> for animation you could either create multiple plots like I do there for example & the create a gif or use plotly and create an animated plot. Me I usually just plot data as a PDF and use evince to view the PDF. then overwriting the plot just means evince autoloads the new PDF |
13:41:20 | FromDiscord | <vindaar> for simple stuff that's enough (but of course not if you want a real animation of something) |
13:41:54 | PMunch | Right |
13:42:06 | PMunch | But cool, that's essentially the same I ended up doing |
13:42:54 | FromDiscord | <vindaar> nice 👍️ I'm not really sure this is the best way to go about it, but it's certainly simple enough and should work well enough |
13:43:23 | PMunch | I'm using cubic spline and not 1D though |
13:43:38 | FromDiscord | <vindaar> that's fair enough of course |
13:44:05 | PMunch | Yeah, but I'm not sure how the forecast is done |
13:44:34 | PMunch | For example is wind speed the max of the next hour, the medium, or the wind speed at the top of the hour |
13:44:49 | PMunch | Currently it's treated as the last option |
13:45:11 | PMunch | But if it's e.g. max then cubic spline would be able to overshoot that value |
13:45:46 | PMunch | But it's a forecast, so it shouldn't be relied upon anyways *shrugs* |
13:49:10 | FromDiscord | <kaddkaka> Hmm, every 2nd time I reload my buffer in vim, nimsuggest seem to crash o.O `nimsuggest instance for project /home/david/projects/advent2022_nim/day12 stopped with exitcode: 139`↵How would I troubleshoot this? |
13:53:10 | FromDiscord | <Bung> https://media.discordapp.net/attachments/371759389889003532/1057657465820418068/images.jpg |
13:53:13 | FromDiscord | <Bung> for wind speed you can use a fan icon and rotate it, for direction you can use mark like this |
13:53:45 | FromDiscord | <Bung> sorry I can only find the mark with chinese |
13:54:44 | PMunch | Oh I wasn't thinking of actually using this for anything but verifying if the data was somewhat sound |
13:55:05 | PMunch | So I was more imagining just a white canvas with a black line growing in size and rotating from the center |
13:55:16 | * | blami quit (Quit: Client closed) |
13:55:27 | PMunch | Just wanted to know if there was some trivial way of making something like that in Nim nowadays |
13:56:55 | FromDiscord | <vindaar> yeah, not sure. I guess there's literature about what's commonly done in meteorology↵(<@709044657232936960_=50=4dunch=5b=49=52=43=5d>) |
13:56:57 | FromDiscord | <Bung> ok then |
13:57:22 | FromDiscord | <vindaar> I hope you came away thinking "yes, it's amazing nowadays" 🤣↵(<@709044657232936960_=50=4dunch=5b=49=52=43=5d>) |
13:58:43 | FromDiscord | <Bung> I was thought you already to display your data on LCD or other display. |
14:04:02 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4jMi |
14:04:34 | FromDiscord | <Phil> In reply to @PMunch "You should be able": (PMunch , I forgot to post my response as a response to this message) |
14:05:41 | PMunch | @vindaar, I was talking about the drawing thing :P But yes, the scientific Nim community has really put some nice packages together! Could possibly be slightly better documented though, but I guess maybe there is documentation in the doc comments that I didn't read. |
14:06:46 | PMunch | Hmm, maybe it has to be done via a macro.. |
14:06:51 | PMunch | That's what I did in Ratel |
14:06:55 | PMunch | @Phil ^ |
14:07:18 | FromDiscord | <ringabout> `include` may work. |
14:08:09 | PMunch | I have a `board "boardname"` macro which expands to some includes and other stuff |
14:08:27 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4jMj |
14:09:01 | FromDiscord | <Phil> In reply to @PMunch "Hmm, maybe it has": Which of your files should I be looking at to initiate operation "Blatant theft"? |
14:09:06 | FromDiscord | <Phil> (edit) "In reply to @PMunch "Hmm, maybe it has": Which of your ... files" added "ratel" |
14:09:26 | FromDiscord | <ringabout> sent a code paste, see https://play.nim-lang.org/#ix=4jMk |
14:09:32 | PMunch | This is the file a user would import: https://github.com/PMunch/ratel/blob/master/src/boardConf.nim |
14:10:01 | PMunch | And if you look here you can see how that is used: https://ratel.peterme.net/gettingstarted.html |
14:10:14 | FromDiscord | <vindaar> happy to hear it. Yeah, documentation is always a challenge of course, but possibly also discovery of it. not sure if you're aware of https://scinim.github.io/getting-started/ for example (which itself needs more content!)↵(<@709044657232936960_=50=4dunch=5b=49=52=43=5d>) |
14:10:27 | FromDiscord | <ringabout> In reply to @ringabout "rename?": In `test2.nims`, I included `test.nim`, which works. |
14:10:50 | FromDiscord | <Phil> In reply to @ringabout "In `test2.nims`, I included": The clue is that playground.nim uses mkdir, which is only available in the nimscript module |
14:11:00 | PMunch | @vindaar, I was not aware of that |
14:11:45 | FromDiscord | <ringabout> In reply to @Isofruit "The clue is that": https://media.discordapp.net/attachments/371759389889003532/1057662139717931059/image.png |
14:11:58 | FromDiscord | <ringabout> Yeah, making it a template works too. |
14:12:13 | FromDiscord | <ringabout> (edit) "Yeah, making it a template ... works" added "(imports)" |
14:12:32 | * | kenran joined #nim |
14:12:49 | * | kenran quit (Remote host closed the connection) |
14:13:00 | FromDiscord | <Phil> In reply to @ringabout "In `test2.nims`, I included": The overarching problem I'm trying to solve is I want to provide a script to users to copy all their source-code into another folder, but that source-code gets manipulated so that all exported procs have the `mockable` pragma attached.↵All tests then import that modified source-code and test it (with the ability to mock) instead of the actual source-code. |
14:13:07 | FromDiscord | <Phil> Hmmm I'll try template |
14:13:27 | FromDiscord | <Phil> (edit) "source-code." => "source-code.↵↵Said script should only execute upon the user demanding it." |
14:14:05 | FromDiscord | <Phil> In reply to @ringabout "": Works only as a template for me, macro throws the same issue, huh |
14:14:45 | FromDiscord | <ringabout> How did you run it? |
14:14:51 | FromDiscord | <Phil> But okay, so template does it... let's see if that makes what I actually want to do feasible |
14:15:21 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4jMn |
14:15:54 | FromDiscord | <ringabout> What about the command to run the program? |
14:16:22 | FromDiscord | <Phil> You mean the script that does the copying (including source-code modification) ? |
14:16:48 | FromDiscord | <ringabout> Did you use `nim e` to execute the nimscript? |
14:17:25 | FromDiscord | <Phil> ohhhh that might be it |
14:17:28 | * | LuxuryMode joined #nim |
14:17:56 | FromDiscord | <ringabout> sent a code paste, see https://play.nim-lang.org/#ix=4jMp |
14:18:11 | FromDiscord | <ringabout> (edit) "https://play.nim-lang.org/#ix=4jMp" => "https://play.nim-lang.org/#ix=4jMq" |
14:18:15 | FromDiscord | <Phil> sent a code paste, see https://paste.rs/SZy |
14:18:52 | FromDiscord | <Phil> both `nim c src/blubber.nims` and `nim e src/blubber.nims` works when using template, both break when using macro or proc |
14:18:55 | FromDiscord | <ringabout> (edit) "https://play.nim-lang.org/#ix=4jMq" => "https://play.nim-lang.org/#ix=4jMs" |
14:19:13 | FromDiscord | <vindaar> @Phil\: not sure if you are interested, but I just added support for `shell` in macros. |
14:19:22 | FromDiscord | <ringabout> sent a code paste, see https://play.nim-lang.org/#ix=4jMt |
14:19:36 | FromDiscord | <Phil> Why the quote do magic? |
14:20:20 | FromDiscord | <Phil> In reply to @vindaar "<@180601887916163073>\: not sure if": Nice!... What does it do though ^^' ? |
14:20:34 | FromDiscord | <vindaar> well, using `quote do` like that results in the directory being created at runtime though |
14:21:52 | FromDiscord | <vindaar> sent a code paste, see https://play.nim-lang.org/#ix=4jMw |
14:21:53 | FromDiscord | <ringabout> procs work for me too. |
14:22:01 | FromDiscord | <ringabout> procs work for me. |
14:22:21 | FromDiscord | <Phil> ... with `nim e` procs work for me as well |
14:23:41 | FromDiscord | <ringabout> If you are using `nim c`, the Nimscript file will be regarded as a Nim file. |
14:33:17 | FromDiscord | <encyclopaedia> sent a code paste, see https://play.nim-lang.org/#ix=4jMB |
14:34:13 | NimEventer | New thread by sls1005: The meaning of `do`, see https://forum.nim-lang.org/t/9772 |
14:34:29 | FromDiscord | <Phil> ~~Personally, testament is the stuff I pull out when I want to do some serious in-depth testing, not for small projects~~ |
14:35:27 | FromDiscord | <encyclopaedia> 😄 doesnt every project starts small |
14:35:40 | FromDiscord | <Phil> But as for general megatest stuff I think your best chance here is ringabout, I actually know nobody else that deals with it |
14:35:57 | FromDiscord | <Phil> Actually, Vindaar, you contributed to the Compiler, did you not? So you are also familiar with testament I bet ! |
14:37:22 | FromDiscord | <enthus1ast> does "familiar with testament" means that one uses it? |
14:37:38 | FromDiscord | <encyclopaedia> sorry, what is `ringabout` ? |
14:37:41 | FromDiscord | <Phil> In reply to @encyclopaedia "😄 doesnt every project": While that's true, it also is the kind of thing I feel like it's overkill for a decent chunk of folks.↵Every project I contributed to so far mostly uses std/unittest |
14:38:12 | FromDiscord | <enthus1ast> there is stuff that just is not possible with std/unittest |
14:38:17 | FromDiscord | <Phil> But that's in the webdev space so take it with a chunk of salt |
14:38:28 | FromDiscord | <enthus1ast> for example check for compiler errors |
14:38:36 | FromDiscord | <enthus1ast> macro error messages etc |
14:38:46 | FromDiscord | <Phil> Yeh, that's the kind of stuff I typically do not have to deal with |
14:38:46 | FromDiscord | <vindaar> only partially. I only ever run individual categories. Running all tests has never worked for me due to all sorts of dependencies (e.g. nodejs and stuff) so many tests always fail↵(@Phil) |
14:39:21 | FromDiscord | <enthus1ast> but you can totally use both unittest AND testament |
14:39:29 | FromDiscord | <Phil> sent a code paste, see https://paste.rs/Poe |
14:39:30 | FromDiscord | <encyclopaedia> In reply to @Isofruit "While that's true, it": got it. I will give a shot to unittest. The official manual states this, so I was just following that https://media.discordapp.net/attachments/371759389889003532/1057669123028570242/image.png |
14:39:35 | FromDiscord | <vindaar> testament is too clunky for me to use in normal projects anyways |
14:40:09 | FromDiscord | <ringabout> @encyclopaedia What's inside test_main? |
14:41:02 | FromDiscord | <encyclopaedia> sent a code paste, see https://play.nim-lang.org/#ix=4jMD |
14:41:13 | FromDiscord | <ringabout> Did you set the path in configs? |
14:41:43 | FromDiscord | <ringabout> Or you should use ralative imports like import ../../main |
14:41:44 | FromDiscord | <encyclopaedia> In reply to @ringabout "Did you set the": yes `switch("path", "$projectDir/../../src")` |
14:42:08 | FromDiscord | <encyclopaedia> like I said, running them individually passes the tests |
14:42:22 | PMunch | Ugh, why is the asyncdispatch module so poorly documented? |
14:44:23 | PMunch | All I want to do is run something every ten minutes.. |
14:46:16 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4jME |
14:46:36 | FromDiscord | <Phil> Does the `config.nims` file get executed before the tests of a `nimble test` command get executed? |
14:47:32 | PMunch | By the way, when you write long messages or paste code then the bridge turns it into a link and I no longer get pinged when you mention me |
14:48:03 | PMunch | But yes, that sounds right |
14:48:15 | FromDiscord | <Phil> I shall... errr.... ping you in a secondary message after I write the long one in the future then! |
14:48:26 | FromDiscord | <Phil> Problem solving in action 😎 |
14:48:41 | PMunch | And config.nims should be executed before the actual test is run, yes |
14:49:13 | FromDiscord | <Phil> Sweet!↵So in config.nims I write all the setup stuff I want to happen before all of the tests are run |
14:50:03 | PMunch | Yup |
14:50:25 | PMunch | Is this still for the mocking thing? |
14:50:50 | * | rockcavera joined #nim |
14:51:12 | FromDiscord | <ringabout> In reply to @encyclopaedia "like I said, running": Did you put your repo at the GitHub? I can investigate it a bit if it is public. |
14:55:20 | FromDiscord | <Phil> In reply to @PMunch "Is this still for": Yeah, I plan to enable 2 ways of usage |
14:55:29 | FromDiscord | <Phil> Number one is: Basically just use the pragma directly in your source code |
14:56:07 | FromDiscord | <Phil> Number two is: I copy all your source code, add the pragma myself and you test the modified copy of your source-code instead of your actual source code.↵That way you won't have to ever touch your source code to make it testable that way |
14:56:37 | FromDiscord | <encyclopaedia> In reply to @ringabout "Did you put your": here you go ↵https://gitlab.com/encyclopaedia/dir-serve-nim/-/tree/main/ |
14:58:59 | * | ltriant joined #nim |
15:01:35 | FromDiscord | <voidwalker> can I somehow "peek" at the first few bytes of a (async) socket.recv without actually consuming/removing those bytes from the buffer ? |
15:04:18 | * | ltriant quit (Ping timeout: 272 seconds) |
15:16:37 | FromDiscord | <voidwalker> first few bytes is the message length, which I need to know, to get the proper size of the rest of the message. If I read/recv those separately, I need to put it back in the message stream, for future prasing |
15:16:42 | FromDiscord | <voidwalker> (edit) "prasing" => "parsing" |
15:19:36 | FromDiscord | <ringabout> In reply to @encyclopaedia "here you go ": I don't know why the previous config doesn't work for imported modules but `switch("path", "../src")` works. |
15:22:27 | * | arkurious joined #nim |
15:22:30 | FromDiscord | <encyclopaedia> sent a code paste, see https://play.nim-lang.org/#ix=4jMV |
15:23:27 | FromDiscord | <ringabout> In reply to @encyclopaedia "that's interesting. That reverses": Works for me on Linux. |
15:23:38 | FromDiscord | <ringabout> (edit) "Linux." => "Windows." |
15:23:54 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=4jMX |
15:25:15 | FromDiscord | <encyclopaedia> In reply to @ringabout "Works for me on": ahh I see what you did there - there's no longer a `$projectDir` in config.nims. Yes, that seems to work for me as well. ↵Curious why the previous setup didnt work. Was it resolving `$projectDir` differently? But it was running from the same path both the times 😖 |
15:40:57 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4jN5 |
15:41:46 | FromDiscord | <Phil> Wait a sec.... can I not use the db_connector thingy with 1.6.10? |
15:42:32 | FromDiscord | <Phil> Hm |
15:42:52 | FromDiscord | <Phil> So I have to enable a when switch then for my db connection pool package to support both nim 1 and nim 2 |
15:44:03 | FromDiscord | <ringabout> In reply to @Isofruit "Wait a sec.... can": Btw db has moved to nimble packages on the devel branch |
15:44:21 | FromDiscord | <Phil> In reply to @ringabout "Btw db has moved": That one I understand |
15:44:36 | FromDiscord | <Phil> I was more confused that I can't use the `db_connector` package that now contains all this stuff in 1.6.10 |
15:44:47 | FromDiscord | <@thatrandomperson5-6310e3b26da03> Anyne have some good documentaion form https://nim-lang.org/docs/asyncdispatch.html ? The one provided really is not very helpful, like how would i even make and event? |
15:45:06 | FromDiscord | <ringabout> In reply to @Isofruit "I was more confused": Perhaps the version rerquirement, feel free to make a PR |
15:45:10 | FromDiscord | <Phil> Would make my life easier if I could because then I wouldn't need a `when nim version larger 1.6.10 then import db_connector, else import db_ directly" |
15:45:14 | FromDiscord | <Phil> (edit) "directly"" => "directly`" |
15:45:17 | FromDiscord | <ringabout> (edit) "rerquirement," => "requirement," |
15:46:12 | FromDiscord | <ringabout> In reply to @ringabout "Perhaps the version requirement,": https://github.com/nim-lang/db_connector/blob/e8bf89c30ead2b7fc9569469d5b572121909d13d/db_connector.nimble#L12 |
15:46:32 | FromDiscord | <ringabout> It should be changed into >= 1.6.0 I guess |
15:48:35 | PMunch | Is there an async interface for running a program and getting its output? |
15:49:07 | PMunch | I know I can probably spawn it and use addProcess or something, but I was wondering if there was a ready-made solution |
15:54:02 | PMunch | Oooh, seems like cheatfate/asynctools has asyncproc! |
15:56:33 | FromDiscord | <kaddkaka> sent a code paste, see https://play.nim-lang.org/#ix=4jN9 |
15:57:40 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4jNb |
15:57:54 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4jNb" => "https://play.nim-lang.org/#ix=4jNc" |
15:58:11 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4jNc" => "https://paste.rs/3ig" |
16:10:40 | FromDiscord | <Phil> Son of a strangled angry noises |
16:11:07 | FromDiscord | <Phil> `nimble test` will execute the code in your `config.nims` more akin to `nim c config.nims` than `nim e config.nims` |
16:13:28 | FromDiscord | <Phil> Wait no, the error message is different, it's just not finding the `testSetup.nim` file again |
16:13:41 | FromDiscord | <Phil> Importing nim files from a package shouldn't be this aggravating |
16:13:51 | FromDiscord | <Phil> (edit) "Importing nim files from a package ... shouldn't" added "into a `.nims` file" |
16:14:39 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4jNn |
16:14:39 | FromDiscord | <Phil> This works |
16:14:56 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4jNn" => "https://play.nim-lang.org/#ix=4jNo" |
16:15:09 | FromDiscord | <Phil> Now when I run `nimble test` I get `Error: cannot open file: mockingbird/testSetup` |
16:15:18 | FromDiscord | <Phil> I don't understand |
16:26:36 | NimEventer | New thread by Isofruit: Test/config.nims can't import nim file from package when executed as part of `nimble test`, see https://forum.nim-lang.org/t/9773 |
16:34:26 | FromDiscord | <kaddkaka> sent a code paste, see https://paste.rs/HYS |
16:37:24 | FromDiscord | <kaddkaka> Hmm, maybe it's not doing that ... I'm so lost T.T |
16:51:54 | FromDiscord | <Bung> try change proc to template ? |
17:06:39 | FromDiscord | <kaddkaka> @Bung I'll give it a shot |
17:22:11 | FromDiscord | <@thatrandomperson5-6310e3b26da03> What does this mean? `segmentation fault (core dumped)` |
17:22:48 | FromDiscord | <jtv> Generally it's probably going to be a null pointer dereference at runtime |
17:22:59 | FromDiscord | <jtv> i.e., you tried to use a nil value |
17:26:27 | FromDiscord | <jtv> At the OS level, a "segmentation fault" is when you attempt to access memory from your process that you don't have access to. That's generally not going to happen much in Nim, since you don't have unrestricted pointers. But there's no checking around nil because it would be a bunch of overhead, so when you've got an object that's nil you try to access, under the hood you end up trying to access memory address 0, which is what the OS is sayin |
17:46:07 | FromDiscord | <kaddkaka> In reply to @Bung "try change proc to": The proc/template didn't make a difference. Actually having a condition before adding nodes to my heapqueue made a difference! >.< 😄 |
17:49:16 | FromDiscord | <Bung> That’s good to hear |
18:04:38 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4jOd |
18:36:29 | FromDiscord | <Phil> sent a code paste, see https://paste.rs/xh1 |
19:00:33 | * | ltriant joined #nim |
19:02:44 | PMunch | Is there a way to get the Nim version in a machine-readable way? |
19:03:03 | PMunch | I know there's `dump` and `--dump.format:json`, but that still requires me to pass a Nim file.. |
19:05:36 | * | ltriant quit (Ping timeout: 272 seconds) |
19:45:24 | FromDiscord | <Solitude> In reply to @PMunch "Is there a way": ▲ ~ echo 'echo NimVersion' | nim e - 2>/dev/null↵1.9.1 |
19:46:06 | FromDiscord | <guttural666> anybody know why a lot of these bad boys were not written for in place mutation with pls(s: var string)? should be more efficient no? https://media.discordapp.net/attachments/371759389889003532/1057746285089796226/image.png |
19:47:26 | FromDiscord | <guttural666> I think most of the string manipulation procedures were written to give an output and leave the source alone, certainly more flexible but idunno |
19:47:29 | FromDiscord | <voidwalker> https://nim-lang.org/docs/sequtils.html#concat%2Cvarargs%5Bseq%5BT%5D%5D - anything like this that works on a seq[seq[T]] ? |
19:47:31 | FromDiscord | <Phil> In reply to @Solitude "▲ ~ echo": Solitude ! |
19:47:42 | FromDiscord | <Phil> Good to see you again! |
19:48:38 | FromDiscord | <Phil> In reply to @guttural666 "I think most of": It's following the functional style a bit more:↵Take stuff in, spit stuff out |
19:48:57 | FromDiscord | <voidwalker> need to unpack seq[seq[T]] in a single sequence with all elements |
19:49:01 | FromDiscord | <guttural666> In reply to @Isofruit "It's following the functional": yeah |
19:49:24 | FromDiscord | <Phil> In reply to @voidwalker "need to unpack seq[seq[T]]": Basically you just want to flatten the seq? |
19:49:30 | FromDiscord | <voidwalker> yes |
19:50:09 | FromDiscord | <Phil> Dangit I know I've seen something for this somewhere |
19:50:14 | PMunch | @Solitude, no way to get the hash though it seems.. |
19:50:52 | FromDiscord | <voidwalker> It seems like an obvious thing to have in sequtils.. it just has that concat thingie, which works on varargs |
19:51:14 | FromDiscord | <voidwalker> maybe I am missing something and I can expand seq[seq[T]] in varargs of seq[T] ? |
19:51:55 | FromDiscord | <guttural666> In reply to @PMunch "<@104136074569211904>, no way to": like your videos man, you should do more |
19:52:15 | FromDiscord | <Phil> In reply to @voidwalker "maybe I am missing": Actually, it does work |
19:52:27 | PMunch | Thank you @guttural666 :) What kind do you like the best? |
19:52:31 | FromDiscord | <Phil> sent a code paste, see https://paste.rs/Waq |
19:52:53 | FromDiscord | <Phil> I swore I saw something that called it what it is though: A flatten operator |
19:52:55 | FromDiscord | <voidwalker> oh then I am missing something in my code.. sigh |
19:53:15 | FromDiscord | <Phil> In reply to @voidwalker "oh then I am": Look at it on the bright side |
19:53:21 | FromDiscord | <Phil> You don't have weird macro bugs on generics |
19:53:36 | FromDiscord | <guttural666> In reply to @PMunch "Thank you <@375727321958580228> :)": these ones, really high quality, I really want to see CppCon level stuff on youtube https://media.discordapp.net/attachments/371759389889003532/1057748170140033104/image.png |
19:53:37 | FromDiscord | <Phil> Your life could be so much worse! |
19:53:40 | FromDiscord | <@thatrandomperson5-6310e3b26da03> Do all threads from threading close with the main thread? |
19:53:59 | FromDiscord | <guttural666> (edit) "youtube" => "youtube; think Nim needs this kinda stuff" |
20:03:51 | PMunch | @guttural666, oh right, yeah those are recorded for various conferences |
20:04:21 | FromDiscord | <guttural666> In reply to @PMunch "<@375727321958580228>, oh right, yeah": yeah, the professional ones are the best, really enjoy those and the more high level / general ones |
20:05:21 | FromDiscord | <guttural666> In reply to @PMunch "<@375727321958580228>, oh right, yeah": that's why I like CppCons stuff so much and dislike what the Zig people do all of the time, something super detailed and specific which nobody can relate to |
20:06:04 | PMunch | Anything in particular you'd like to hear such a talk on? I kinda ran out of easy topics |
20:06:53 | FromDiscord | <guttural666> anything in the back to basics track of cppcon and in the same quality, that would really help Nim imo |
20:07:07 | FromDiscord | <guttural666> in the vein of that track |
20:07:09 | FromDiscord | <Phil> In reply to @PMunch "Anything in particular you'd": Testing Strategies in nim to spread that knowledge far and wide, as apparently its somewhat of a dark "Everybody do their own" kinda thing |
20:07:42 | PMunch | Well that's the problem, I can't really talk about stuff that don't have consensus :P |
20:07:55 | PMunch | Well I guess I could do a "state of things" talk |
20:08:03 | FromDiscord | <Phil> You can give an overview over the different views and things that exist |
20:08:07 | PMunch | @guttural666, do you have a link to that track? |
20:08:13 | FromDiscord | <Phil> Or at least the more prominent ones |
20:08:31 | PMunch | The prevalent one seems to be "tests? what tests?" |
20:08:38 | FromDiscord | <Phil> When is the next talk thingy again? |
20:08:44 | FromDiscord | <guttural666> In reply to @PMunch "Well that's the problem,": https://www.youtube.com/watch?v=Bt3zcJZIalk&list=PLHTh1InhhwT4TJaHBVWzvBOYhp27UO7mI |
20:08:48 | PMunch | Talk thingy? You mean NimConf? |
20:08:56 | FromDiscord | <Phil> Yeah |
20:09:07 | PMunch | There is FOSDEM in early February, but I don't think there's any Nim talks this year :( |
20:09:42 | PMunch | And there was just a NimConf in the end of October, so you'd have to wait about another year for that :P |
20:09:43 | FromDiscord | <Phil> I would be surprised, this year lasts only for 3 more days |
20:10:03 | PMunch | Haha, I meant the next iteration of FOSDEM |
20:10:44 | FromDiscord | <Phil> Check! Okay that gives me time to hopefully to push out a first release for mockingbird and hijack your talk for propaganda of my package! |
20:10:51 | FromDiscord | <guttural666> your keyboard videos were super cool though |
20:11:04 | FromDiscord | <guttural666> although very specific, but really entertaining |
20:12:07 | FromDiscord | <voidwalker> Blah I figured out why the concat() doesn't work for my case. I got not a seq[seq[T]], but a seq[bObject], and one of the fields of bObject is the seq |
20:13:34 | FromDiscord | <Phil> what is bObject? |
20:13:41 | FromDiscord | <Phil> A variant? |
20:13:51 | FromDiscord | <voidwalker> bencodedObject. has .l field which is a seq |
20:14:11 | FromDiscord | <Phil> Ahhhh in that case you'll need to do a map call first then |
20:14:14 | FromDiscord | <voidwalker> variant, but in this specific case it's just kind: list, and.l : seq |
20:14:43 | FromDiscord | <Phil> `yourseq.map(proc-that-unpacks-seq-from-bObject).concat` |
20:16:20 | FromDiscord | <voidwalker> not sure that will work... |
20:16:22 | PMunch | @guttural666, glad you liked those. That reminds me, I completely forgot to edit down the last ones.. |
20:16:25 | FromDiscord | <Phil> Okay, time to throw myself at beefs macro to understand it and see whether I can make it work for generics |
20:17:07 | FromDiscord | <guttural666> In reply to @PMunch "<@375727321958580228>, glad you liked": Nim needs some serious video content, let's goooo |
20:17:47 | FromDiscord | <jtv> Beef''s macro for what? |
20:21:46 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4jOG |
20:22:46 | FromDiscord | <voidwalker> sent a code paste, see https://paste.rs/GJn |
20:23:18 | FromDiscord | <Phil> Don't let more experienced users of sequtils catch you, the above does a lot of copying and that will be frowned upon! |
20:23:20 | FromDiscord | <voidwalker> not sure if I can ever be a good programmer if stuff like this overflows my stack 😄 |
20:23:47 | FromDiscord | <Phil> Not by me, but I've seen people use the evil I word. "Inefficient" |
20:23:57 | FromDiscord | <voidwalker> @Phil I am writing a very naive and minimal line of code torrent library. Iteration 2, if ever, will be low level optimized.. for now I don't care, I have no idea what i am doing anyway : P |
20:24:20 | FromDiscord | <Phil> I agree with this approach, first optimize for readability, then optimize for performance as needed |
20:24:32 | FromDiscord | <voidwalker> I just care about getting to a good overall design, not implementation of specific pieces |
20:24:57 | FromDiscord | <voidwalker> trust me, I have thought about low level optimizations, and I have to ditch most used libraries for that, lol |
20:24:57 | FromDiscord | <Phil> In reply to @jtv "Beef''s macro for what?": Just posted it above. In effect (as far as I understand) it turns a proc definition into a proc being assigned to a mutable variable |
20:26:04 | FromDiscord | <guttural666> In reply to @voidwalker "<@180601887916163073> I am writing": "for now I don't care, I have no idea what i am doing anyway" that's the spirit! hahaha that's how you learn a shit load |
20:27:13 | FromDiscord | <Phil> Continuing my bit aobut the macro:↵And I'm not sure how to fix that one. I guess instead of turning it into a mutable variable it could be turned into a template that generates a mutable variable (if none already exists) and assigns it an iteration of the generic proc ? |
20:27:36 | FromDiscord | <Phil> That's just a conceptual idea, I know neither if it's feasible, nor if it's insane and how to syntactically do it I don't know either =/ |
20:28:29 | FromDiscord | <voidwalker> In reply to @guttural666 ""for now I don't": I am waiting to reach v0.1 so i can publish code, and beg everyone for help. Can't really do that before I have at least a sketch of the thing : P |
20:28:45 | FromDiscord | <voidwalker> It's taking forever though |
20:29:43 | FromDiscord | <guttural666> In reply to @voidwalker "I am waiting to": then you're far ahead of my, I'm writing a CD database app for the command line rn with a metal-archives API |
20:30:11 | FromDiscord | <guttural666> not more than 1000 LOC rn in Nim xD |
20:30:15 | FromDiscord | <voidwalker> username checks out : P |
20:31:19 | FromDiscord | <guttural666> my YAML database reading and writing from disk and searching local and metal archives databases works, so I am proud haha |
20:31:35 | FromDiscord | <voidwalker> 1000 loc for that sounds like a lot lol |
20:31:44 | FromDiscord | <voidwalker> I plan to have a whole torrent client in 1000 Loc or less |
20:31:46 | PMunch | New version of NimLSP if anyone wants to check it out. Just a tiny one, but should have some improvements :) |
20:32:11 | * | PMunch quit (Quit: leaving) |
20:32:16 | FromDiscord | <guttural666> it's 400 or so rn, I have querying local + MA db rn, saving to disk, writing to disk etc. |
20:32:36 | FromDiscord | <guttural666> lots of pretty stuff for the console, which is half of my code, formatting for console etc. |
20:33:16 | FromDiscord | <guttural666> In reply to @PMunch "New version of NimLSP": yeah and thanks for that one, totally forgot, Nim in Vim is such a great exp |
20:34:00 | FromDiscord | <guttural666> (edit) "writing to" => "loading from" |
20:35:38 | FromDiscord | <jtv> @voidwalker you need something like this? |
20:35:50 | FromDiscord | <jtv> sent a code paste, see https://paste.rs/ZSd |
20:36:02 | FromDiscord | <jtv> (edit) |
20:37:51 | NimEventer | New thread by DougT: Question about taskpools, see https://forum.nim-lang.org/t/9774 |
20:39:13 | FromDiscord | <EyeCon> sent a code paste, see https://paste.rs/k8x |
20:39:29 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4jON |
20:39:39 | * | pro joined #nim |
20:41:16 | FromDiscord | <jtv> Then you need a second type parameter and have to worry about how nested you are |
20:44:00 | FromDiscord | <voidwalker> well it was all 1 level nesting here, by design, so I got away with concat() |
20:49:53 | NimEventer | New thread by DougT: Nim 2.0 RC1 taskpools error, see https://forum.nim-lang.org/t/9775 |
21:05:18 | * | ltriant joined #nim |
21:26:10 | FromDiscord | <lenis> I wonder |
21:26:19 | FromDiscord | <lenis> what happens when you inline a recursive procedure |
21:26:23 | FromDiscord | <lenis> is that even possible? |
21:37:12 | * | LuxuryMode quit (Quit: Connection closed for inactivity) |
21:41:09 | FromDiscord | <<She>Horizon</Her>> Does Nim have a way for me to probe fields of types, and procs + their params and return type? |
21:43:29 | FromDiscord | <Phil> In reply to @Event Horizon "Does Nim have a": Define "probe", because you can iterate over the fields on a type at compile-time |
21:44:17 | FromDiscord | <Phil> As for procs, I think that may land you in macro-land |
21:45:07 | FromDiscord | <Phil> Well, "macro land" as in you'll likely need to deal with NimNodes and the like at compile-time |
21:45:16 | FromDiscord | <<She>Horizon</Her>> I'd be fine with compile time |
21:45:19 | FromDiscord | <Phil> (edit) "compile-time" => "compile-time, which can also be done in procs" |
21:47:26 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4jP2 |
21:47:46 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4jP3 |
21:49:21 | FromDiscord | <<She>Horizon</Her>> Thanks Phil! |
21:51:56 | FromDiscord | <Phil> sent a code paste, see https://paste.rs/Bev |
21:52:11 | FromDiscord | <luteva> is there any example for (nim-)lmdb or nimdbx using (ref) objects? i can't find one. a simple example would be enough.... |
21:52:27 | FromDiscord | <Phil> I'm tagging out on that one, don't even know what lmdb is |
21:52:47 | FromDiscord | <luteva> memory mapped db |
21:53:15 | FromDiscord | <ezquerra> In reply to @PMunch "New version of NimLSP": @PMunch, can nimlsp be used with VSCode? |
21:53:35 | FromDiscord | <luteva> so a (really fast!) ACID persistence storage |
21:53:59 | FromDiscord | <Phil> ... I think I'd just use sqlite in memory |
21:54:31 | FromDiscord | <Bung> @ezquerra that's for sure |
21:54:37 | FromDiscord | <luteva> it is a key value store, not an sql db. so bit like redis etc. but just the base system. |
21:55:08 | FromDiscord | <Phil> I likely would still throw up sqlite just for ease of use ^^' |
21:55:19 | FromDiscord | <ezquerra> In reply to @Bung "<@974046326088163438> that's for sure": How? Does it work in tandem with any of the existing nim extensions? Or does they replace them? |
21:55:24 | FromDiscord | <Phil> That or just use a global hashmap or sth |
21:55:35 | FromDiscord | <luteva> and yeah i think there's even a batch for sqlite to use lmdb as the storage backend to get more performance into sqlite |
21:55:38 | FromDiscord | <Bung> install vscode-nim-lsp, nimble install nimlsp, that's all |
21:56:39 | FromDiscord | <Bung> vscode-nim-lsp is a simple vscode lsp client that start nimlsp |
21:56:40 | FromDiscord | <luteva> In reply to @Isofruit "That or just use": hashmap is not a storage (and especially not an acid storage) |
21:58:00 | FromDiscord | <luteva> (edit) "In reply to @Isofruit "That or just use": hashmap is not a ... storage" added "persistant" |
21:58:30 | FromDiscord | <luteva> (edit) "In reply to @Isofruit "That or just use": hashmap is not a persistant storage (and especially not an acid storage) ... " added "sqlite in memory isn't either." |
22:04:12 | * | ltriant quit (Ping timeout: 272 seconds) |
22:08:51 | * | pro quit (Quit: pro) |
22:21:59 | FromDiscord | <jvsg> when do I need to call `NimMain` and when not? The documentation isn't really clear about this, except for it says NimMain is used to initalize internals. |
22:23:38 | FromDiscord | <Ricky Spanish> sent a code paste, see https://play.nim-lang.org/#ix=4jPa |
22:24:04 | FromDiscord | <Ricky Spanish> (edit) "https://play.nim-lang.org/#ix=4jPa" => "https://play.nim-lang.org/#ix=4jPb" |
22:26:05 | FromDiscord | <Phil> I assume that's a package outside of the stdlib? |
22:27:11 | FromDiscord | <Ricky Spanish> from here no? https://github.com/nim-lang/zip/blob/master/zip/zipfiles.nim i just want to parse a zip file withouut extracting the contents |
22:28:00 | FromDiscord | <Phil> Ah checked, can't replicate in inim on linux so not sure what the issue is there. |
22:28:26 | FromDiscord | <Ricky Spanish> ah ok atleast if its just specific to my machine can build it in docker or something so its still helpful thanks |
22:30:41 | FromDiscord | <Phil> In reply to @jvsg "when do I need": Why do you assume you ever need to call NimMain? It's not necessary for typical usecases |
22:32:52 | * | PMunch joined #nim |
22:34:17 | NimEventer | New post on r/nim by His_son: Sleep equivalent, see https://reddit.com/r/nim/comments/zxn8zh/sleep_equivalent/ |
22:47:35 | FromDiscord | <jvsg> This[0] example makes it look like calling NimMain is almost mandatory.↵[0] https://nim-lang.org/docs/backends.html#backend-code-calling-nim-nim-invocation-example-from-c↵(@Phil) |
22:48:31 | PMunch | NimMain isn't mandatory when using ARC/ORC, but it's where global variables are initialised, so it's a good idea to call it anyways |
22:48:34 | FromDiscord | <jvsg> maybe it is a relic of the past and needs to be updated? |
22:48:55 | FromDiscord | <Elegantbeef> You're not wrong↵(@Phil) |
22:48:56 | PMunch | If you don't have any global variables it is optimised away to nothing (at least in my testing on embedded devices) |
22:49:54 | FromDiscord | <jvsg> the thing is I want to pass a nim function to a certain framework written in C. So I cannot call NimMain in the framework. |
22:50:08 | PMunch | Oh right, in normal Nim code you shouldn't ever have to call it. It's only if you're doing things like being loaded from a dynamic library or have a weird entry-point |
22:51:01 | FromDiscord | <Elegantbeef> It's not the smartest but you could call a function that calls nimmain in all your code wrapped with `once` |
22:51:28 | PMunch | @jvsg how does this C framework load your code? |
22:51:55 | FromDiscord | <Phil> In reply to @Elegantbeef "You're not wrong (<@180601887916163073>)": That's not what I wanna hear beef =/↵Shit... is there maybe hope with an approach that instead of a variable turns the generic proc into a template that creates these variables? |
22:51:57 | PMunch | Do you compile your Nim code together with the framework, or is it dynamically loaded? |
22:51:59 | FromDiscord | <jvsg> dynamic library↵(<@709044657232936960_=50=4dunch=5b=49=52=43=5d>) |
22:52:23 | FromDiscord | <Phil> Like, generate a template from a macro or sth |
22:52:34 | FromDiscord | <Phil> Which I'm aware sounds incredibly cursed |
22:52:45 | PMunch | Right, most dynamic library frameworks I've seen have init/deinit procedures that they will call in your library |
22:52:59 | PMunch | @Phil, oh sweet summer child |
22:53:17 | * | ltriant joined #nim |
22:53:20 | FromDiscord | <Elegantbeef> You might be able to use a macro to do what you want |
22:53:30 | FromDiscord | <Elegantbeef> But in reality mocking/replacing generics is just pretty much impossible |
22:53:54 | FromDiscord | <Phil> I don't wanna mock the generic, I wanna mock the implementation that it spawns! |
22:54:00 | FromDiscord | <Elegantbeef> That's a generic |
22:54:08 | FromDiscord | <Elegantbeef> How would you even replace the generic |
22:54:16 | FromDiscord | <Elegantbeef> `myGenericIntInt`? |
22:54:45 | FromDiscord | <Elegantbeef> So what you could do phil is replace the procedure with a macro that has the same signature, and everytime you call that you check a macro cache for the arguements you passed |
22:54:59 | FromDiscord | <Elegantbeef> But this is dumb since it doesnt work |
22:55:16 | FromDiscord | <Elegantbeef> An overload means it falls apart |
22:57:15 | PMunch | Hmm, I should do some more work on superlog.. |
22:57:19 | PMunch | Such a promising idea |
22:57:26 | FromDiscord | <Phil> Now that just depresses me |
22:57:40 | PMunch | Had another weird idea today by the way, if anyone feels called |
22:58:36 | FromDiscord | <Phil> Trying to think my way around the problem, but I just can't quite grasp it.↵I strongly dislike the idea of this not being possible, but it looks way too much like it is 😐 |
22:58:42 | PMunch | Basically a web server router which requires that you specify the query parameters and headers and such you require and adds them to the type definition of the Request object. This way you can write more type-safe web application |
22:59:09 | PMunch | @Phil, are you still stuck on mocking things? |
22:59:27 | FromDiscord | <Phil> In reply to @PMunch "<@180601887916163073>, are you still": Same general area, different problem |
22:59:58 | FromDiscord | <Phil> Turns out the entire idea of "replace proc with a mutable variable that has been assigned a proc" dies for generics because generics are stupid and I use them a ton and I actually like them but they are still stupid |
23:00:06 | FromDiscord | <Elegantbeef> I mean it's not overly impossible |
23:00:14 | FromDiscord | <Elegantbeef> It's just that it falls apart easily |
23:00:51 | PMunch | Ah right.. |
23:01:19 | * | ltriant quit (Ping timeout: 268 seconds) |
23:01:26 | PMunch | What if you require your mocks to be registered first? |
23:01:39 | FromDiscord | <Elegantbeef> bleh we can do better |
23:02:26 | FromDiscord | <Phil> In reply to @PMunch "What if you require": At what particular point in time?↵Within the source-code?↵Within the copy of the source-code for testing? |
23:02:40 | PMunch | Just a sec |
23:02:47 | FromDiscord | <Phil> Like, if your approach is to actually write a {.mockable.} pragma into your source-code generics, that's workable |
23:03:04 | FromDiscord | <Phil> Just provide the mockable pragma with types and then you just generate explicit procs for all the specified types |
23:05:20 | FromDiscord | <Phil> sent a code paste, see https://paste.rs/qiU |
23:10:08 | PMunch | Nah, I want to do it the other way around |
23:13:47 | FromDiscord | <Elegantbeef> Here you go phil |
23:13:50 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=4jPr |
23:14:23 | FromDiscord | <Elegantbeef> Basically for a generic procedure you need to generate what i hardcoded into the macro |
23:18:14 | PMunch | I was thinking something like this: http://ix.io/4jPs |
23:18:58 | FromDiscord | <Elegantbeef> Well phil wants to mock all their code |
23:19:04 | * | ltriant joined #nim |
23:19:08 | PMunch | All of it? |
23:19:14 | FromDiscord | <Elegantbeef> all of it |
23:19:18 | PMunch | What would you do that for? |
23:19:26 | FromDiscord | <Elegantbeef> Fuck if i know |
23:19:30 | FromDiscord | <Elegantbeef> I dont even get wanting to mock any code |
23:19:49 | * | derpydoo joined #nim |
23:19:54 | PMunch | That's like taking one car for a drive and then say you've tested a completely different car |
23:20:10 | FromDiscord | <Phil> It's wanting the ability to mock whatever piece of code I want |
23:20:16 | PMunch | Well I can see mocking something like calls to an external API or something |
23:20:21 | FromDiscord | <Phil> So that I can swap out parts as I desire for individual tests |
23:20:26 | PMunch | Ah right |
23:20:31 | PMunch | That makes more sense |
23:20:37 | PMunch | My sample would achieve that |
23:21:07 | PMunch | Obviously that sample is pretty dumb, it can only read modules in the same folder, and only read top level procs, but hopefully you get the idea |
23:21:45 | PMunch | I guess you'd actually want a Table from the signature to the mocked body, and then instead of not outputting the body simply replace it |
23:27:01 | PMunch | Something along the lines of http://ix.io/4jPv |
23:33:51 | FromDiscord | <Phil> sent a long message, see http://ix.io/4jPx |
23:36:02 | PMunch | Ah right.. |
23:36:08 | PMunch | Forgot about the other modules part.. |
23:36:58 | FromDiscord | <Phil> Like, coming back to the example I wrote up yesterday (https://discord.com/channels/371759389889003530/371759389889003532/1057313408061538385):↵↵This manipulates the proc `OtherModule.otherProc` in `TestModule.nim`.↵Does this affect the code that's going to run when the proc under test in `ModuleUnderTest` will call `OtherModule.otherProc`? |
23:37:29 | PMunch | I guess for that you'd need to completely copy your project and replace them in files.. |
23:37:41 | PMunch | Because I don't think there is a way to override imports.. |
23:40:00 | PMunch | Well, I guess you could go through their imports and find the project-local ones and rewrite those on the fly.. |
23:42:41 | FromDiscord | <Phil> sent a long message, see http://ix.io/4jPy |
23:44:15 | FromDiscord | <Phil> Because you have access to an imported proc's body, right? So you should be able to rewrite that, store the rewritten `proc-under-test` in a variable and then call that stored variable in your tests |
23:44:30 | FromDiscord | <Emily Brown> https://t.me/+UcYGEjBQwa7gIPN1↵(@Phil) |
23:44:47 | FromDiscord | <Phil> In reply to @Emily Brown "https://t.me/+UcYGEjBQwa7gIPN1 (<@18060188791616307": <@&371760044473319454> scumbags |
23:44:48 | FromDiscord | <Emily Brown> https://t.me/+UcYGEjBQwa7gIPN1↵(<@709044657232936960_=50=4dunch=5b=49=52=43=5d>) |
23:44:52 | FromDiscord | <Phil> (edit) "In reply to @Emily Brown "https://t.me/+UcYGEjBQwa7gIPN1 (<@18060188791616307": <@&371760044473319454> ... scumbags" added "we got" |
23:46:19 | PMunch | @Phil, in general it's bad practice to try and parse Nim code in macros, it just never ends well |
23:46:39 | PMunch | And you'd need to handle overloading, indirection etc. etc. |
23:56:55 | FromDiscord | <Phil> I'll look deeper at all possibilities again tomorrow, bedtime has arrived |