00:02:19 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4ErI |
00:03:01 | FromDiscord | <Elegantbeef> What keyword |
00:03:09 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4ErJ |
00:03:14 | FromDiscord | <heysokam> In reply to @Elegantbeef "What keyword": `method` |
00:03:38 | FromDiscord | <Elegantbeef> Dynamic dispatch requires conversions, invalid conversions raise errors |
00:03:42 | FromDiscord | <Elegantbeef> Also do not use `inheritable` |
00:03:48 | FromDiscord | <Elegantbeef> it's `type X = object of Y` |
00:03:56 | FromDiscord | <Elegantbeef> Also you're not using `ptr T` so methods serve 0 purpose |
00:04:15 | FromDiscord | <m4ul3r> For a library, how do I generate nimble docs for all modules - can't seem to figure it out |
00:04:24 | FromDiscord | <m4ul3r> (edit) "For a ... library,nim" added "nimble" | "nimble" => "nim" |
00:04:35 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4ErK |
00:04:38 | FromDiscord | <Elegantbeef> `nim doc --project ./entry.nim` |
00:04:45 | FromDiscord | <Elegantbeef> `type X = object of RootObj` |
00:04:49 | * | krux02 quit (Remote host closed the connection) |
00:04:57 | FromDiscord | <heysokam> In reply to @Elegantbeef "`type X = object": `--mm:none` |
00:04:58 | FromDiscord | <Elegantbeef> Read the messages sokam |
00:05:05 | FromDiscord | <Elegantbeef> So what? |
00:05:09 | FromDiscord | <Elegantbeef> The hell does that matter |
00:05:15 | FromDiscord | <Elegantbeef> `RootObj` is just "this is inheritable" |
00:05:54 | FromDiscord | <heysokam> thought rootobj was part of the ref issue |
00:06:42 | FromDiscord | <heysokam> In reply to @heysokam "also, talking about inheritance.": asked this, but since it wasn't answered I just went bash my head against the trial+error wall |
00:07:05 | FromDiscord | <Elegantbeef> Inheritance works with manual memory management but you need to use `ptr` |
00:07:16 | FromDiscord | <Elegantbeef> Without pointer indirection methods are 100% pointless |
00:07:34 | FromDiscord | <heysokam> kk. but what is raising exceptions there? |
00:07:44 | FromDiscord | <Elegantbeef> No clue |
00:08:42 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4ErM |
00:08:47 | FromDiscord | <Elegantbeef> You're also not using methods properly |
00:08:48 | FromDiscord | <Elegantbeef> the base should be annotated `{.base.}` |
00:09:27 | FromDiscord | <heysokam> well i tried, and the lsp was saying that the method is not a base or something, and then that baseless methods are deprecated, and i don't understand either |
00:09:37 | FromDiscord | <heysokam> so for now i went try fix this first |
00:09:44 | FromDiscord | <Elegantbeef> Yea it's the checking |
00:10:03 | FromDiscord | <Elegantbeef> disable checking and you no longer get the exception warning |
00:10:20 | FromDiscord | <heysokam> what checking? |
00:10:28 | FromDiscord | <Elegantbeef> objChecking |
00:10:56 | FromDiscord | <Elegantbeef> With `--objChecks:off` it doesnt warn |
00:11:16 | FromDiscord | <Elegantbeef> Method dispatching requires checks and if the type information is 100% wrong it errors |
00:11:18 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4ErO |
00:11:21 | FromDiscord | <Elegantbeef> of course they do |
00:11:25 | FromDiscord | <Elegantbeef> They're assertions |
00:11:32 | FromDiscord | <Elegantbeef> Or defects rather |
00:11:39 | FromDiscord | <heysokam> but its very different if they are assertions or if they are exceptions |
00:11:46 | FromDiscord | <heysokam> assertions work on gc:none |
00:11:49 | FromDiscord | <Elegantbeef> It's not very different |
00:11:51 | FromDiscord | <heysokam> exceptions dont |
00:11:52 | FromDiscord | <Elegantbeef> They're defects |
00:12:04 | FromDiscord | <heysokam> are defects not still exceptions? |
00:12:11 | FromDiscord | <Elegantbeef> Defects use the exception mechanisms but should not be recovered from |
00:12:22 | FromDiscord | <Elegantbeef> you of course should be using `--panics:on` so they just kill the program |
00:12:24 | FromDiscord | <heysokam> but they still use GCed memory, don't they |
00:13:06 | FromDiscord | <Elegantbeef> I mean with `--panics:on` it doesnt matter if they use gc'd memory they hard crash the program |
00:13:15 | FromDiscord | <Elegantbeef> There is no try excepting out of them |
00:15:59 | FromDiscord | <heysokam> still crashing for me with --objChecks:off |
00:16:15 | FromDiscord | <Elegantbeef> Crashing? |
00:16:49 | FromDiscord | <heysokam> `Error: '(ref exceptn)(msg: message)' uses GC'ed memory [GcMem]` |
00:17:04 | FromDiscord | <heysokam> `--warningAsError:GcMem:on` |
00:17:12 | FromDiscord | <Elegantbeef> Cannot reproduce here |
00:17:25 | * | disso-peach joined #nim |
00:17:40 | * | disso-peach quit (Remote host closed the connection) |
00:18:25 | * | disso-peach joined #nim |
00:18:38 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4ErP |
00:22:27 | FromDiscord | <heysokam> i guess it was missing `base`? |
00:22:45 | FromDiscord | <Elegantbeef> No clue using methods here is still pointless |
00:22:46 | FromDiscord | <heysokam> no clue why that wasn't working and not it does |
00:22:52 | FromDiscord | <Elegantbeef> You need a pointer get runtime polymorphism |
00:23:08 | FromDiscord | <heysokam> well im just trying to understand them |
00:23:30 | FromDiscord | <heysokam> if you know a decent resource on then let me know, i would rather study than waste my time trial+error'ing 😦 |
00:23:30 | FromDiscord | <Elegantbeef> They're procedures that emit a case statement to dispatch based off runtime type information |
00:23:38 | FromDiscord | <Elegantbeef> There really isnt much to them |
00:23:49 | FromDiscord | <Elegantbeef> It's not much different to using a object variant, except you have compiler support |
00:24:13 | FromDiscord | <heysokam> ic |
00:24:37 | FromDiscord | <heysokam> will use object variants, now that you mention. they almost always fit my usecase a ton better |
00:25:19 | FromDiscord | <heysokam> so basically methods create the underlying variant type? is that all they are? |
00:30:13 | FromDiscord | <Elegantbeef> No |
00:30:16 | FromDiscord | <Elegantbeef> They create a dispatch logic to call the procedures using type information |
00:30:32 | FromDiscord | <Elegantbeef> It's just like Java or C# classes and overriding a method there |
00:32:13 | FromDiscord | <heysokam> ic ty |
00:46:38 | FromDiscord | <.maverk> what does ``format`` function do in nim ? |
00:47:22 | FromDiscord | <Elegantbeef> If only there were docs to explain what procedures did |
00:47:57 | FromDiscord | <Chronos [She/Her]> Wait you mean we don't have to sacrifice a child every time to ask Lucifer to help me understand what something does in Nim? |
00:48:10 | FromDiscord | <Elegantbeef> You don't have to but you do it anyway |
00:48:47 | FromDiscord | <Elegantbeef> What's the point in living if you don't chuck a child off a cliff every once iin a while |
00:53:03 | FromDiscord | <Chronos [She/Her]> True xD |
00:58:21 | FromDiscord | <heysokam> @ElegantBeouf found a small issue in the implementation of the todo template↵cannot be used to work on the same library that contains it, because the tests for it won't pass, since it has new contents of things that are in dev inside the lib 🙈 |
00:58:36 | FromDiscord | <heysokam> small issue, tbh. i don't mind it. just mentioning it |
00:58:45 | FromDiscord | <Elegantbeef> What? |
00:59:19 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4ErX |
00:59:58 | FromDiscord | <Elegantbeef> You do not realise how unhelpful that is |
01:00:00 | FromDiscord | <heysokam> because the todos live in a compiletime seq |
01:00:38 | FromDiscord | <heysokam> if you have test that checks for the contents literally, to assert that nothing went wrong... then add something to the list (because its the same library, so same seq) then it doesn't match |
01:01:52 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4ErY |
01:02:25 | FromDiscord | <heysokam> but just a small thing, doesn't really matter that much, so you can ignore me 🙂 |
01:02:38 | FromDiscord | <Elegantbeef> Uh huh |
01:05:51 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4Es1 |
01:06:22 | FromDiscord | <Elegantbeef> I mean it's a compile time value if you append to it any check before will not of had those values |
01:06:44 | FromDiscord | <heysokam> also, is it possible to get the function name of where the todo is called from? |
01:07:27 | FromDiscord | <Elegantbeef> If you use the previously talked about way of getting the procedure name, sure |
01:07:34 | FromDiscord | <heysokam> was trying to find what `instantiationInfo()` contains, but didn't find much other than a `magic` |
01:07:45 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/system.html#instantiationInfo%2Cint |
01:07:52 | FromDiscord | <Elegantbeef> There is no magic |
01:07:54 | FromDiscord | <Elegantbeef> It's a tuple |
01:08:21 | FromDiscord | <heysokam> oh! im blind |
01:08:26 | FromDiscord | <heysokam> #classic |
01:09:05 | FromDiscord | <heysokam> In reply to @Elegantbeef "If you use the": i have 🐠 memory, i do not recall this |
01:09:14 | FromDiscord | <heysokam> who was talking about it? I will search |
01:11:25 | FromDiscord | <Elegantbeef> https://github.com/beef331/nimtrest/wiki/Code-snippets#get-proc-name |
01:14:01 | FromDiscord | <heysokam> ty ✍️ |
01:17:36 | FromDiscord | <heysokam> why do you need to call for the owner of a dummy proc? |
01:18:07 | FromDiscord | <Elegantbeef> You need to call the owner of some symbol declared inside the procedure |
01:18:08 | FromDiscord | <Elegantbeef> A proc does not have any initialisation therefore no overhead |
01:20:26 | arkanoid | demotomohiro: late thanks |
01:20:48 | FromDiscord | <heysokam> ic |
01:21:07 | FromDiscord | <Elegantbeef> Alternatively `type A = distinct void` could be used I guess |
01:22:29 | * | lucasta_ joined #nim |
01:46:42 | arkanoid | is the "packed" pragma the default behaviour in C? |
01:46:52 | FromDiscord | <Elegantbeef> no |
01:47:23 | arkanoid | what's the alignment? is it aligned to pointer size? |
01:47:25 | FromDiscord | <Elegantbeef> Compilers layout structs in a way that makes accessing fields more efficient, packed is optimising for size over speed |
01:48:08 | FromDiscord | <etra> isn't struct order guaranteed in C? |
01:48:15 | FromDiscord | <etra> (and C++ too I believe) |
01:48:26 | FromDiscord | <etra> but yeah with packed in C you also remove alignment I believe |
01:48:31 | FromDiscord | <Elegantbeef> Order does not mean alignment garuenteed |
01:49:28 | FromDiscord | <etra> I remember fighting with that in Zig because they had packed and that was the only way to assure the field order would remain the same, idk if in Nim there's an intermediary which is not packed but order guaranteed |
01:49:35 | FromDiscord | <Elegantbeef> Alignment takes up space so fields of different sizes are offset from eachother. Order inside non packed structs can change the amount of data taken up by an object, this is important for things like `seq[T]` |
01:49:41 | FromDiscord | <Elegantbeef> I mean Nim emits C |
01:50:02 | arkanoid | https://play.nim-lang.org/#ix=4Es9 |
01:51:20 | FromDiscord | <Elegantbeef> Packing doesnt change field sizes of course |
01:51:32 | FromDiscord | <Elegantbeef> packing is hidden |
01:51:45 | arkanoid | Elegantbeef, not if you do cast |
01:51:54 | FromDiscord | <Elegantbeef> What? |
01:52:05 | arkanoid | look at the flags struct field here https://arrow.apache.org/docs/format/CDataInterface.html#structure-definitions |
01:52:06 | FromDiscord | <Elegantbeef> cast does not change field sizes |
01:52:15 | arkanoid | it is an int64_t |
01:52:24 | FromDiscord | <Elegantbeef> So what? |
01:54:03 | arkanoid | if you wrap that struct, you end up with a flag field that would naturally be a nim set of size 8 bytes, which nim can't do right now (or better you do0t have control of it) |
01:54:28 | FromDiscord | <Elegantbeef> https://github.com/MCRusher/cflags might be interested in this |
01:54:52 | FromDiscord | <Elegantbeef> It's technically a bug, but https://play.nim-lang.org/#ix=4Esb works |
01:55:06 | arkanoid | but thanks to packing, if you cast a C struct in memory to nim, it works as the flags field goes from 1 byte to 8 |
01:55:39 | FromDiscord | <Elegantbeef> Or you could just wrap the type properly and not rely on what I imagine is UB, but I do not know if it rightly is |
01:55:55 | arkanoid | UB? |
01:56:04 | FromDiscord | <Elegantbeef> Undefined behaviour |
01:58:00 | arkanoid | yeah I know that doing flags: int64 is the right thing here. I was just trying to use nim set as I always find a way to not use them lol |
01:58:32 | arkanoid | there's always something that makes me drop set in favor of something else |
01:58:50 | FromDiscord | <Elegantbeef> You also can just do `reserved = 64` |
01:59:16 | FromDiscord | <Elegantbeef> Or `63` I guess |
01:59:33 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=4Esc is a cleaner way of doing it of course |
02:00:59 | arkanoid | are enums with holes stilla thing? |
02:01:06 | FromDiscord | <Elegantbeef> Of course |
02:01:41 | arkanoid | isn't this UB anyway? I though enum with holes were kind of no-go |
02:01:47 | FromDiscord | <Elegantbeef> Nope |
02:01:53 | FromDiscord | <Elegantbeef> They're wholly supported |
02:03:01 | arkanoid | damn, this solved the problem, again. Why Elegantbeef always knows a better way |
02:04:07 | arkanoid | but now I want a convincing discussion about where enum with holes went back accepted into the nim enum society |
02:04:34 | FromDiscord | <Elegantbeef> They're bad in Nim, but they're sometimes a necessary evil |
02:05:34 | FromDiscord | <Elegantbeef> They're bad mainly cause they make things like Nim's bitsets take more memory for no real reason, and make iterating the range more of a pain |
02:05:45 | FromDiscord | <Elegantbeef> But in this case you want the bitsets to take more space and likely are not iterating or parsing them |
02:07:14 | arkanoid | sure I'm not, but my brain somehow went into no enum with holes mode for a reason, I probably read somewhere about how bad they are |
02:07:30 | arkanoid | but if they are still in nim 2.0, I think they are here to stay somehow |
02:08:11 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4Ese |
02:08:53 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4Esf |
02:09:10 | FromDiscord | <heysokam> yeah i guess |
02:09:25 | FromDiscord | <heysokam> but i do need the return |
02:09:37 | arkanoid | thanks for the help beef |
02:09:41 | FromDiscord | <heysokam> otherwise it can continue and if the last is true it is true (but should stop) |
02:09:49 | FromDiscord | <Elegantbeef> put a break in |
02:13:41 | FromDiscord | <heysokam> why not just return? |
02:14:01 | FromDiscord | <Elegantbeef> Cause of the warning |
02:14:13 | FromDiscord | <Elegantbeef> Can also disable the warning for the proc |
02:14:26 | FromDiscord | <heysokam> you can do that for specific procs? 🤔 |
02:14:55 | FromDiscord | <Chronos [She/Her]> Anyone know how good Nim is for memory when it comes to WASM? Wondering how good it'd be for wasm4 (fantasy console stuff) |
02:14:59 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4Esg |
02:15:00 | FromDiscord | <Elegantbeef> Though since it's a generic that might not work proerly |
02:16:38 | FromDiscord | <heysokam> ah gotcha |
02:53:46 | FromDiscord | <heysokam> What's the difference between an Effect and an Exception? |
02:54:01 | FromDiscord | <heysokam> Is it that Effect's include also Defects, or is it something else? |
02:54:33 | FromDiscord | <Elegantbeef> Effects are unrelated to exceptions |
02:55:02 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/manual.html#effect-system |
02:56:03 | FromDiscord | <Elegantbeef> I mean they're slightly related but overall they're not apart of it directly, `raises` allows you to disallow exceptions |
03:01:09 | FromDiscord | <heysokam> In reply to @Elegantbeef "https://nim-lang.org/docs/manual.html#effect-system": yeah i read that. i also read the 2.0 post about the changes. still don't really understand it |
03:01:29 | FromDiscord | <heysokam> as it is often the case with advanced topics in the docs/manual... they are not easily understood by my obtuse brain |
03:01:33 | FromDiscord | <Elegantbeef> You can annotate procedures to have effects, and you can disallow effects inside procedures |
03:01:48 | FromDiscord | <heysokam> but then what do exceptions have to do with that, if they are not effects? |
03:01:59 | FromDiscord | <Elegantbeef> They have no relation |
03:02:10 | FromDiscord | <Elegantbeef> effects are addition side effects on a procedure on a type level |
03:02:14 | FromDiscord | <heysokam> then why are the literally the second sentence ofthat manual? |
03:02:25 | FromDiscord | <Elegantbeef> Cause raises is apart of the effect system |
03:02:37 | FromDiscord | <Elegantbeef> `{.raises: [].}` disallows all exceptions from being raised |
03:03:13 | FromDiscord | <heysokam> what would `{.raises: [BaseEffect].}` do in contrast to that? |
03:03:51 | FromDiscord | <Elegantbeef> Nothing cause raises is apart of exception tracking |
03:04:22 | FromDiscord | <heysokam> ? |
03:04:27 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4Esn |
03:05:56 | FromDiscord | <Elegantbeef> Raises just takes an array of exceptions allowed to be raised |
03:07:26 | FromDiscord | <heysokam> Am I understanding correctly that for --mm:none I should probably just `raises: [], tags: []` every proc? |
03:07:28 | FromDiscord | <Elegantbeef> Tags are the real effect tracking part |
03:07:36 | FromDiscord | <Elegantbeef> Not empty tags |
03:07:41 | FromDiscord | <Elegantbeef> Tags are for user defined effects |
03:07:57 | FromDiscord | <heysokam> but what are effects for, of not exceptions? |
03:08:02 | FromDiscord | <heysokam> (edit) "of" => "if" |
03:08:29 | FromDiscord | <Elegantbeef> Like in the above we've disabled the used of any `IO` tagged procedure inside `no_effects_please` |
03:08:41 | FromDiscord | <Elegantbeef> Blocking specific operations inside a procedure |
03:08:58 | FromDiscord | <heysokam> so you mark them as coming from some module, for example, and disallow the use of that module inside that function? |
03:09:08 | FromDiscord | <Elegantbeef> Not from some module |
03:09:18 | FromDiscord | <Elegantbeef> Tags are type level sideeffects |
03:09:24 | FromDiscord | <heysokam> i meant for example |
03:09:31 | FromDiscord | <Elegantbeef> In the above example we stated "readLine has the side effect of IO" |
03:09:33 | FromDiscord | <heysokam> since i don't understand effects |
03:10:07 | FromDiscord | <Elegantbeef> This means later on we can go "Oh we do not want to allow any procedure that has effects" or with `forbids` we can say "We do not want any procedure that has a specific effect" |
03:10:26 | FromDiscord | <Elegantbeef> Effects are wholly for users to use and decide how to use |
03:10:42 | FromDiscord | <Elegantbeef> If you want to disable allocations in a procedure it'd make sense to mark all allocating procedures with `alloc` and disable their usage |
03:11:22 | FromDiscord | <Elegantbeef> Effects are this magical tool to annotate procedures for certain things that you care about |
03:11:44 | FromDiscord | <heysokam> In reply to @Elegantbeef "If you want to": that is a smart one |
03:12:08 | FromDiscord | <heysokam> In reply to @Elegantbeef "Effects are this magical": i see, gotta start thinking more like that 🤔 |
03:12:23 | FromDiscord | <Elegantbeef> Sadly though the stdlib does not use effects much |
03:12:46 | FromDiscord | <Elegantbeef> It'd be nifty if `cast` `copyMem` and `moveMem` had `unsafe` or similar |
03:12:56 | FromDiscord | <heysokam> definitely |
03:13:01 | FromDiscord | <Elegantbeef> Then you could just `{.forbids: [unsafe].}` |
03:13:53 | FromDiscord | <Elegantbeef> I personally have not ever used tags myself, but there are some places that it makes sense |
03:21:32 | FromDiscord | <heysokam> what is `-d:useMalloc` useful for, btw?↵any benefit to using it? |
03:21:50 | FromDiscord | <Elegantbeef> reducing binary size and also using C tooling |
03:23:20 | FromDiscord | <heysokam> what does it disable exactly? are the `create` `delete` functions allowed after disabling it? |
03:23:53 | FromDiscord | <heysokam> if those were not the names, i meant the ones were you allocate typed pointers safely |
03:24:57 | FromDiscord | <odexine> Nothing u I s disabled using that switch |
03:25:04 | FromDiscord | <odexine> (edit) "u I s" => "is" |
03:25:14 | FromDiscord | <heysokam> also, side question. any way to get information to decide if I should care about `gcsafe` pragma or not for --mm:none? |
03:25:30 | FromDiscord | <odexine> It switches out Nim’s internal allocator with Malloy |
03:25:33 | FromDiscord | <odexine> Malloc |
03:26:01 | FromDiscord | <heysokam> With a Mercurial alloy? interestings :kappa: |
03:26:02 | FromDiscord | <Elegantbeef> Mallory the Libc malloc |
03:34:06 | FromDiscord | <Elegantbeef> It occurs to me that malloy would not be mercury alloy that'd be hgalloy |
03:40:55 | FromDiscord | <odexine> :ChiguPien: |
03:43:04 | FromDiscord | <JJ> rolls off the tongue |
04:24:44 | FromDiscord | <graveflo> sent a code paste, see https://play.nim-lang.org/#ix=4EsG |
04:27:25 | FromDiscord | <Elegantbeef> The borrow pragma is pretty bad at anything really |
04:27:37 | FromDiscord | <Elegantbeef> I improved it a bit, but it just has flaws |
04:27:48 | FromDiscord | <graveflo> I figured as much. It doesn't seem all that useful either. This is just a gross workaround |
04:28:01 | FromDiscord | <Elegantbeef> https://github.com/beef331/nimtrest/blob/master/lender.nim#L222-L242 is just a smarter way of doing it imo |
04:28:48 | FromDiscord | <graveflo> sent a code paste, see https://play.nim-lang.org/#ix=4EsH |
04:29:01 | FromDiscord | <Elegantbeef> Yea I've talked about a weak distinct |
04:29:12 | FromDiscord | <Elegantbeef> The way of doing a weak distinct is to use a converter |
04:29:35 | FromDiscord | <graveflo> yea but that is sucky for a bunch of other reasons |
04:29:42 | FromDiscord | <graveflo> I'm sure I dont have to explain |
04:29:47 | FromDiscord | <Elegantbeef> Right, but it works the least worse |
04:30:20 | FromDiscord | <Elegantbeef> A weak distinct would be lovely so make an RFC and PR 😛 |
04:30:31 | FromDiscord | <Elegantbeef> Oh wait there is a PR |
04:30:31 | FromDiscord | <Elegantbeef> RFC\ |
04:30:44 | FromDiscord | <odexine> Will it be called wistinct |
04:31:10 | FromDiscord | <graveflo> In reply to @Elegantbeef "https://github.com/beef331/nimtrest/blob/master/len": Can't tell what im looking at here but I guess I'll do some digging. This isn't a "service side code has to preemptively expose for no reason" type of deal is it? Like can I made `Option` work like this without much trouble |
04:31:23 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/RFCs/issues/450 close enough to a weak distinct |
04:31:39 | FromDiscord | <graveflo> (edit) "made" => "make" |
04:31:53 | FromDiscord | <Elegantbeef> It's a declarative API to emit procedures for a given type |
04:32:10 | FromDiscord | <Elegantbeef> Instead of using the proc header you write the code and it emits a procedure that inlines what you wrote |
04:32:16 | FromDiscord | <Elegantbeef> Practically what borrow should be |
04:32:44 | FromDiscord | <odexine> Kinda funky but I’m just thinking it sure would be nice if we had something like Haskell’s type classes |
04:33:25 | FromDiscord | <Elegantbeef> That means nothing to me |
04:34:18 | FromDiscord | <odexine> Pretty much just traits IIRC but not runtime I believe? Not too sure what traits are |
04:34:27 | FromDiscord | <Elegantbeef> Traits are not runtime |
04:34:43 | FromDiscord | <Elegantbeef> Traits are just constrained generics really |
04:34:46 | FromDiscord | <odexine> I don’t know what traits are really |
04:35:17 | FromDiscord | <Elegantbeef> They're a list of procedures required for a type to match, and inside of the trait implementation only those procedures are usable on that type |
04:36:03 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4EsI |
04:36:26 | FromDiscord | <odexine> In reply to @Elegantbeef "They're a list of": Sounds like type classes then |
04:36:26 | FromDiscord | <Elegantbeef> Whoops `mSelf.get()` but anyway it's not really the most library ready code, just an idea I had eons ago |
04:36:33 | FromDiscord | <Elegantbeef> Yea they pretty much are |
04:37:52 | FromDiscord | <Elegantbeef> Nim does have half of that of course through everyones least favourite concept |
04:38:58 | FromDiscord | <odexine> I know that but I have the feeling that it is lacking somehow, yet I am unsure how |
04:39:08 | FromDiscord | <Elegantbeef> It's unchecked is really it |
04:39:22 | FromDiscord | <Elegantbeef> Concepts do not constrict you to the contract you declared |
04:43:11 | FromDiscord | <Elegantbeef> This circles around to my row typing struggles |
04:44:03 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/4AZLa |
05:00:59 | * | advesperacit joined #nim |
05:36:28 | FromDiscord | <haoyu233> https://github.com/nim-lang/Nim/pull/19652 |
05:36:35 | FromDiscord | <haoyu233> When I saw this issue, I remembered a meme I saw earlier |
05:36:57 | FromDiscord | <haoyu233> sent a long message, see http://ix.io/4EsQ |
05:37:03 | FromDiscord | <haoyu233> https://media.discordapp.net/attachments/371759389889003532/1144505701255880704/9f6886391a554035838f82654adbd18d.gif |
05:38:52 | FromDiscord | <haoyu233> (edit) "http://ix.io/4EsQ" => "http://ix.io/4EsR" |
05:49:38 | FromDiscord | <pk.kyle> bruh lol |
05:51:41 | * | lucasta_ quit (Ping timeout: 260 seconds) |
06:05:56 | * | rockcavera quit (Remote host closed the connection) |
06:40:38 | * | PMunch joined #nim |
06:55:43 | FromDiscord | <ShalokShalom (ShalokShalom)> https://rr-project.org/ |
06:55:43 | FromDiscord | <ShalokShalom (ShalokShalom)> Does anyone use that? |
07:12:38 | PMunch | Hmm, haven't seen that before. But certainly looks interesting |
07:16:55 | * | ehmry quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.) |
07:19:09 | * | ehmry joined #nim |
07:21:34 | FromDiscord | <odexine> Oh I’ve heard of it from Firefox |
07:58:22 | FromDiscord | <ShalokShalom (ShalokShalom)> The Julia CTO praises it |
07:58:24 | FromDiscord | <ShalokShalom (ShalokShalom)> Julia, the lang |
08:03:01 | * | PMunch_ joined #nim |
08:03:30 | FromDiscord | <firasuke> ok so I can't confirm my email on the forums, so I deleted my account and now I can't create a new one with the same ID kekw, who can help? |
08:04:32 | * | PMunch quit (Ping timeout: 240 seconds) |
08:06:49 | * | PMunch joined #nim |
08:07:23 | * | PMunch_ quit (Read error: Connection reset by peer) |
08:08:33 | FromDiscord | <Phil> I can't even get gdb to work, unless rr is far more idiot-proof I'm not sure on useage |
08:08:55 | FromDiscord | <Phil> (edit) "work," => "work well in vscode," |
08:09:19 | FromDiscord | <Phil> I will admit that getting a C-debugging tool me-proof is a bit of a task though |
08:10:20 | * | PMunch_ joined #nim |
08:10:48 | FromDiscord | <odexine> In reply to @isofruit "I can't even get": You use it alongside the gdb debugger |
08:10:55 | FromDiscord | <odexine> It’s not a replacement |
08:12:14 | FromDiscord | <Phil> Then oofff as that'd make a proper vscode setup even harder |
08:12:56 | * | PMunch quit (Ping timeout: 245 seconds) |
08:28:35 | FromDiscord | <haoyu233> sent a code paste, see https://play.nim-lang.org/#ix=4Etb |
08:28:56 | FromDiscord | <haoyu233> why `offsetof(ChunkObj, data)` is zero |
08:29:50 | FromDiscord | <haoyu233> sent a code paste, see https://play.nim-lang.org/#ix=4Etc |
08:30:55 | FromDiscord | <haoyu233> By looking at the generated C code, it should be 1 or something else |
08:38:40 | FromDiscord | <Elegantbeef> Cause unchecked arrays have no size |
08:39:03 | FromDiscord | <Elegantbeef> Also fields start at offset 0 |
08:39:26 | FromDiscord | <djazz> This was apparently invalid when using cpp backend and caused a runtime error: `cast[var T](pointerArg).myProc()`↵This works: `cast[ptr T](pointerArg)[].myProc()` |
08:39:39 | FromDiscord | <djazz> for a myProc that has first arg as var type |
08:39:51 | FromDiscord | <djazz> The joys of wrapping C/C++ |
08:40:05 | FromDiscord | <djazz> voidstars! |
08:40:13 | FromDiscord | <Elegantbeef> likely C++ uses `&` instead of `` causing an issue casting t o`var T` is 'wrong' |
08:40:19 | FromDiscord | <djazz> yep |
08:40:53 | FromDiscord | <djazz> g++ compiler didnt complain tho |
08:41:48 | FromDiscord | <djazz> ran into another issue where the Pico SDK toolchain causes error for conversion from `const char ` to `char ` (cstring). the const variant has no nim equivalent |
08:42:00 | FromDiscord | <djazz> https://github.com/nim-lang/Nim/issues/19588 getting the same error |
08:42:29 | FromDiscord | <djazz> @ringabout's example fails with cpp backend but only when through pico sdk |
08:43:21 | FromDiscord | <djazz> not sure what flag passed to the compiled cause the error whereas nim cpp works |
08:43:28 | FromDiscord | <djazz> compiler |
08:48:13 | * | xet7 joined #nim |
08:48:27 | * | xet7_ quit (Ping timeout: 246 seconds) |
08:53:48 | FromDiscord | <djazz> dont want to replace all importc with importcpp heh |
08:55:19 | FromDiscord | <djazz> importcpp didnt fix it |
08:59:07 | FromDiscord | <djazz> anyway, I could easily change the const char in the c++ header file since it's part of my repo xD |
09:00:51 | FromDiscord | <Elegantbeef> Just don't support C++, problem solved |
09:02:30 | FromDiscord | <djazz> compiling with cpp backend helped reveal some other compatability issues for my wrapper 😉 |
09:03:12 | FromDiscord | <Elegantbeef> more reason not to target it, it is creating more work! |
09:03:34 | FromDiscord | <djazz> more work now, less headache in the future? |
09:03:52 | FromDiscord | <Elegantbeef> Nah just more work |
09:07:28 | FromDiscord | <ringabout> In reply to @djazz "<@658563905425244160>'s example fails with": I am not really familiar with C or C++; but perhaps https://github.com/nim-lang/Nim/issues/3720#issuecomment-751622165 provides more information. |
09:09:34 | * | kenran joined #nim |
09:14:39 | FromDiscord | <haoyu233> In reply to @Elegantbeef "Also fields start at": However, in the generated C code, the offset is 1, which may cause the calculated field address error |
09:15:34 | FromDiscord | <haoyu233> I allocated 10 bytes of memory, one occupied by the `dummy` field |
09:16:16 | FromDiscord | <haoyu233> So my really available memory is 9 bytes |
09:18:24 | FromDiscord | <haoyu233> When I tried to circumvent this problem by adding the size of `offsetof(ChunkObj, data)`, I got the wrong value |
09:19:07 | FromDiscord | <Elegantbeef> The dummy field is apart of the collection |
09:20:48 | FromDiscord | <Elegantbeef> Nim avoids this by forcing a size of `1` |
09:20:50 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4Etm |
09:23:21 | FromDiscord | <haoyu233> From the generated C code, you can see that the allocated memory size is not added with sizeof(dummy) https://media.discordapp.net/attachments/371759389889003532/1144562647115780206/image.png |
09:23:39 | FromDiscord | <Elegantbeef> The issue isnt the data, the issue is the fact you have an object with only an unchecked array which has no size |
09:24:08 | FromDiscord | <Elegantbeef> Nim will insert a dummy value inside a struct with a size of 0 cause all types need atleast a size of 1 to be sensible |
09:24:26 | FromDiscord | <Elegantbeef> I was wrong with my initial statement |
09:25:10 | FromDiscord | <Elegantbeef> What you want is just a `type MyType = distinct ptr UncheckedArray[char]` |
09:25:37 | FromDiscord | <Elegantbeef> You do not want a object as objects are defined as a struct, you just want an array apparently |
09:26:09 | FromDiscord | <haoyu233> I can understand the fact that the object size you described is at least 1 |
09:27:24 | FromDiscord | <haoyu233> But this does not explain why the value of `offsetof(ChunkObj, data)` is 0 |
09:27:56 | FromDiscord | <Elegantbeef> You found an issue with the offsetOf implementation |
09:28:19 | FromDiscord | <haoyu233> sent a code paste, see https://play.nim-lang.org/#ix=4Etc |
09:28:30 | FromDiscord | <Elegantbeef> Cool I don't care about C |
09:28:35 | FromDiscord | <Elegantbeef> The issue is inside the Nim compiler |
09:28:50 | FromDiscord | <Elegantbeef> You found an issue with it, when the object has a dummy field and a unchecked array the offset is incorrect |
09:29:41 | FromDiscord | <Elegantbeef> Not that it really matters that much, but it is an issue |
09:31:36 | FromDiscord | <haoyu233> The shit code I wrote got me into this problem |
09:32:12 | FromDiscord | <Elegantbeef> Right, it's an issue. But given that pretty much no one writes this code it's not a very common issue |
09:32:32 | FromDiscord | <Elegantbeef> A object with just an unchecked array is a silly way of writing a distinct or just `ptr UncheckedArray[T]` |
09:33:08 | FromDiscord | <Elegantbeef> It does need an issue made of course |
09:36:18 | FromDiscord | <haoyu233> Ok, I'll submit the issue later |
09:37:48 | * | fallback quit (Ping timeout: 246 seconds) |
09:50:33 | NimEventer | New thread by koistinen: Using asm or intrinsic C functions from Nim, see https://forum.nim-lang.org/t/10439 |
10:08:45 | * | azimut quit (Ping timeout: 246 seconds) |
10:13:38 | * | kenran quit (Ping timeout: 256 seconds) |
10:23:03 | FromDiscord | <Phil> Huh, just realized that since prologue uses async for its controllers, you can pretty much use async effortlessly within those |
10:23:25 | FromDiscord | <Phil> (edit) "Huh, just realized that since prologue uses async for its controllers, you can pretty much use async ... effortlesslyand" added "await" | "awaiteffortlessly within those ... " added "and don't have to care about dealing with the dispatcher at all" |
10:23:39 | FromDiscord | <Phil> Nifty |
10:41:05 | FromDiscord | <System64 ~ Flandre Scarlet> is Nim's garbage collector similar to RAII? |
10:54:22 | FromDiscord | <ieltan> In reply to @sys64 "is Nim's garbage collector": `orc` is RAII + a cycle collector for leaks |
10:54:39 | FromDiscord | <ieltan> Arc is RAII without the cycle collector |
10:54:56 | FromDiscord | <System64 ~ Flandre Scarlet> Oh alright! |
10:55:10 | FromDiscord | <ieltan> (edit) "leaks" => "cycles" |
10:55:18 | FromDiscord | <ieltan> Sorry I meant cycles |
10:55:32 | FromDiscord | <ieltan> But in retrospect, ARC will leak if you have cycle so... |
10:55:40 | FromDiscord | <ieltan> (edit) "cycle" => "cycles" |
10:57:11 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @ieltan "`orc` *is* RAII +": So that means if I do Nim well enough...↵...I can do C++ / Rust without problems? |
10:59:09 | FromDiscord | <ieltan> In reply to @sys64 "So that means if": No because C++ and Rust are more than RAII, but if you do Nim well enough you could be more productive than if you were to write C++ at least while your program runs as fast |
10:59:45 | FromDiscord | <ieltan> I'm not sure about Rust though |
10:59:46 | FromDiscord | <System64 ~ Flandre Scarlet> Oh alright! |
11:00:08 | FromDiscord | <System64 ~ Flandre Scarlet> I always has been afraid of C++ |
11:00:11 | FromDiscord | <ieltan> What's your use case? |
11:00:52 | FromDiscord | <griffith1deadly> In reply to @sys64 "I always has been": c++ is like shooting yourself in the foot, and rust is something to be feared for a lifetime |
11:01:24 | FromDiscord | <System64 ~ Flandre Scarlet> I just watched a video about Rust↵and I asked some questions "Are pointers necessary in Rust? Should I care about memory management in Rust?" |
11:01:55 | FromDiscord | <odexine> In reply to @griffith1deadly "c++ is like shooting": Haha, lifetime |
11:03:37 | FromDiscord | <ieltan> My take on Rust is that it's an excellent language if you plan on making robust tooling or complex applications whereas C++ is a commonly used language for those and you will need to learn it if you want to contribute to existing libraries/apps that use it |
11:03:59 | FromDiscord | <System64 ~ Flandre Scarlet> I have some Nim projects↵A synthesizer↵A game↵And a graphics engine |
11:05:16 | FromDiscord | <griffith1deadly> nim is a good language, but without at least a basic knowledge of the low-level world of C/C++, it's going to be tight in some cases if you're trying to make a stable and high-performance application, huh |
11:07:07 | FromDiscord | <ieltan> I mean, it depends |
11:07:31 | FromDiscord | <ieltan> Why would "high-performance application" imply "low-level"? |
11:07:40 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @griffith1deadly "nim is a good": I already did a bit of C, I know what a pointer is and why they are useful |
11:08:26 | FromDiscord | <System64 ~ Flandre Scarlet> but pointers can be massive footguns |
11:08:36 | FromDiscord | <griffith1deadly> In reply to @ieltan "Why would "high-performance application"": memory management and memory leak repair, I meant. ↵developing a simple but high performance application, I have come across this more than once, and in some cases the leaks are not on my side. |
11:10:59 | FromDiscord | <ieltan> Yeah memory leaks are still going to be a thing it seems even though you would think that it's made to prevent them from happening |
11:11:04 | FromDiscord | <ieltan> Orc I mean |
11:11:32 | FromDiscord | <System64 ~ Flandre Scarlet> avoiding ref types to improve speed |
11:12:34 | FromDiscord | <griffith1deadly> you almost always have to sacrifice something, either memory or speed.. |
11:14:04 | FromDiscord | <Phil> ~~The common choice is who gives a crap about memory and disk space~~ |
11:14:24 | FromDiscord | <Phil> (edit) "who" => ""who" | "space~~" => "space"~~" |
11:14:48 | FromDiscord | <ieltan> The only way I can think of to prevent them is to make sure you don't have cyclic references and implement hooks for your weird objects (like if you're dealing with `ptr/pointer`) |
11:14:57 | FromDiscord | <Phil> In reply to @sys64 "avoiding ref types to": That'll only work as long as your object types are small.↵Once the amount of data they carry gets big that might get very meh very quickly |
11:14:59 | FromDiscord | <ieltan> I don't think there's much to be done unfortunately |
11:15:53 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @isofruit "That'll only work as": Unless you send back a reference when an user asks something to the graphics engine? |
11:15:53 | FromDiscord | <ieltan> In reply to @isofruit "That'll only work as": big objects are passed by ref anyways, might as well make it one |
11:16:07 | FromDiscord | <Phil> In reply to @ieltan "big objects are passed": Nim makes that choice under the hood at some point? |
11:16:16 | FromDiscord | <ieltan> This is one thing I dont Know if I should like or not |
11:16:20 | FromDiscord | <ieltan> In reply to @isofruit "Nim makes that choice": Yeah |
11:16:51 | FromDiscord | <ieltan> Idk if this is a good thing tbh |
11:17:04 | FromDiscord | <Phil> That seems like a thing you need stats for to evaluate:↵How often does it simplify your life vs. how often does it force you to care about the way nim abstracts it |
11:17:43 | FromDiscord | <ieltan> I know it prevent big fat copying happening but I would prefer it to be an explicit optimization, or make it so that it can only be passed by `var` param |
11:18:07 | FromDiscord | <Phil> Does it enable unexpected mutation? |
11:18:28 | FromDiscord | <ieltan> Ah, I don't think so, it would be pretty freaking bad if it did lol |
11:18:37 | FromDiscord | <Phil> In that case I think I'm fine with it |
11:19:11 | FromDiscord | <System64 ~ Flandre Scarlet> Is it possible a proc sends back a ref to something? |
11:19:28 | FromDiscord | <Phil> My main gripe with ref-types is that you can't make the data behind the ref immutable, if implicit passing by reference on nim's side doesn't suddenly enable prior immutable data to be mutable I'm alright with it |
11:19:58 | FromDiscord | <odexine> In reply to @isofruit "My main gripe with": It can’t, you still have to abide by the mutability rules |
11:20:01 | FromDiscord | <ieltan> In reply to @sys64 "Is it possible a": do you mean making a proc return `ref T` implicitly? |
11:20:58 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @ieltan "do you mean making": Yeah↵↵Like I have an array that handles palettes that are not ref↵But a proc that returns a ref of the selected palette |
11:22:00 | FromDiscord | <ieltan> Sure, just allocate with `new` and return the result contained inside of it |
11:22:23 | FromDiscord | <System64 ~ Flandre Scarlet> I will make a copy, no? |
11:22:41 | FromDiscord | <Phil> Nope, that will heap allocate and from there on your variable only contains a ref to the heap allocated data |
11:23:20 | FromDiscord | <System64 ~ Flandre Scarlet> But what if the data is stack allocated? |
11:24:09 | FromDiscord | <odexine> Then you will copy |
11:24:22 | FromDiscord | <ieltan> I'm not sure actually. Could `move`ing the stack data into the allocated heap do the trick? |
11:24:31 | FromDiscord | <Phil> Using `new` means heap allocation. |
11:24:41 | FromDiscord | <Phil> (edit) "allocation." => "allocation (for reference for System64)" |
11:25:21 | FromDiscord | <ieltan> Yes, but if the data is initially sitting on the stack you would have to copy it in the heap right? |
11:25:34 | FromDiscord | <System64 ~ Flandre Scarlet> And are seqs always heap allocated? |
11:25:36 | FromDiscord | <Phil> I would wager so |
11:25:44 | FromDiscord | <ieltan> In reply to @sys64 "And are seqs always": Yed |
11:25:44 | FromDiscord | <ieltan> Yes |
11:25:52 | FromDiscord | <Phil> In reply to @sys64 "And are seqs always": That is correct, but they behave as if they were stack allocated for you |
11:26:08 | FromDiscord | <Phil> So the semantics are as if they were stack-allocated |
11:26:20 | FromDiscord | <Phil> (edit) "So the semantics are as if they were stack-allocated ... " added "aka the semantics of value-types" |
11:26:35 | FromDiscord | <Phil> Same with strings |
11:27:13 | FromDiscord | <ieltan> The design of seq is pretty genius imo, I don't know how similar types are implemented in other languages but the way it's done in Nim is neat |
11:27:30 | FromDiscord | <odexine> In reply to @ieltan "The design of seq": I think the implementation is pretty standard |
11:27:50 | FromDiscord | <ieltan> Ah I see😶🌫️ |
11:29:44 | FromDiscord | <System64 ~ Flandre Scarlet> Is it a good choice to make Tilemap ref ? https://media.discordapp.net/attachments/371759389889003532/1144594453370257540/image.png |
11:30:04 | FromDiscord | <System64 ~ Flandre Scarlet> Tilemap is ref↵tilesets is ref |
11:30:36 | FromDiscord | <Phil> Given the size I'd make that depend on how you think about Tilemap.↵Should there always be 1 Tilemap and that tilemap is often/almost always the same Tilemap? |
11:31:28 | FromDiscord | <Phil> Because value-object-semantics you copy the same thing around a lot so you may have 3+ tilemap instances floating around in a proc if it gets longer.↵Ref-object semantics make sure those are all referring to the same thing |
11:31:31 | FromDiscord | <System64 ~ Flandre Scarlet> There is one tilemap per layer↵But the user can swap tilemaps mid-frames |
11:32:48 | FromDiscord | <System64 ~ Flandre Scarlet> Same for palettes and tilesets |
11:51:03 | FromDiscord | <ieltan> In reply to @griffith1deadly "memory management and memory": Also fwiw I found this forum post that has lots of advice wrt isolating memory leaks↵https://forum.nim-lang.org/t/8251 |
12:04:33 | FromDiscord | <slazaa> net. |
12:05:51 | * | kenran joined #nim |
12:09:49 | * | euantorano_ quit (Quit: Connection closed for inactivity) |
12:28:39 | * | rockcavera joined #nim |
13:56:38 | * | kenran quit (Remote host closed the connection) |
13:56:57 | * | kenran joined #nim |
14:00:22 | * | lucasta_ joined #nim |
14:04:03 | * | PMunch_ quit (Quit: Leaving) |
14:04:42 | * | lucasta_ quit (Ping timeout: 246 seconds) |
14:15:14 | FromDiscord | <burnysc2> Is there a simpler/shorter syntax to convert a float to uint64? Flooring, rounding, or ceiling doesn't matter to me↵Currently, I use `cast[uint64](toInt(22.4 120))` |
14:16:39 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @burnysc2 "Is there a simpler/shorter": sure↵myFloat.uint64 and that's all! |
14:17:15 | FromDiscord | <System64 ~ Flandre Scarlet> for you, it will be (22.4 120).uint64 |
14:17:34 | FromDiscord | <burnysc2> Thank you, that worked |
14:17:41 | FromDiscord | <System64 ~ Flandre Scarlet> you're welcome |
14:17:54 | FromDiscord | <System64 ~ Flandre Scarlet> btw cast[T]() is unsafe |
14:42:16 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4Eug |
14:43:35 | FromDiscord | <heysokam> In reply to @burnysc2 "Is there a simpler/shorter": Never cast↵`toInt(22.4 120).uint64` |
14:43:53 | FromDiscord | <heysokam> what you are doing there is storing the bits of the float as they are, which is wildly incorrect for a uint |
14:44:54 | FromDiscord | <heysokam> (edit) "cast↵`toInt(22.4" => "cast↵`(22.4" |
14:44:59 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4Euj |
14:45:28 | FromDiscord | <heysokam> In reply to @isofruit "Smells like you're using": its from a test |
14:45:37 | FromDiscord | <Phil> A classic for that problem is for example dates. can't have a date at compiletime |
14:46:23 | FromDiscord | <Phil> I mean that doesn't say much.↵It's calling code somewhere that runs at compiletime, how that code is called I can't predict 😛 |
14:46:39 | FromDiscord | <heysokam> i don't know either |
14:46:58 | FromDiscord | <heysokam> i was using a const from `./cfg` changed it to come from `mylib/cfg` and broke |
14:47:12 | * | fallback joined #nim |
14:47:13 | FromDiscord | <heysokam> (edit) "i was using a const from `./cfg` changed it to come from ... `mylib/cfg`" added "a const at" |
14:47:20 | FromDiscord | <Phil> Without seeing things I can't say anything here |
14:47:29 | FromDiscord | <heysokam> well i don't know what to show you |
14:47:35 | FromDiscord | <heysokam> i don't know where is the issue |
14:47:43 | FromDiscord | <heysokam> i jsut replaced the const with a nother const, and broke |
14:48:19 | FromDiscord | <Phil> Do you use readLink anywhere? |
14:49:37 | FromDiscord | <Phil> Wait, are you on a mac? |
14:50:19 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4Eul |
14:50:25 | FromDiscord | <Phil> getAppFilename() that is the thing that explodes |
14:50:31 | FromDiscord | <heysokam> its the only one i can think of that was const that requires runtime 🤔 |
14:50:33 | FromDiscord | <Phil> Because that calls getApplAux |
14:50:45 | FromDiscord | <heysokam> yeah forgot about those functions being runtime |
14:50:55 | FromDiscord | <heysokam> but the error wasn't helpful lol, i had to blindguess 🙈 |
14:51:19 | FromDiscord | <Phil> I basically worked just backwards from the os line where stuff got used |
14:51:28 | FromDiscord | <Phil> Bit more effort than usual but doable |
14:51:54 | FromDiscord | <Phil> But yeah, issue there is that at compiletime various facilities just aren't available =Z |
14:51:57 | FromDiscord | <Phil> (edit) "=Z" => "=/" |
14:52:11 | FromDiscord | <heysokam> shouldn't that at least give some sort of context, without requiring that ability to work backwards inside the inner workings of the code? |
14:52:41 | FromDiscord | <Phil> That'd be a question for internal, I'm not that deep in the compiler |
14:54:12 | * | cedb quit (Quit: WeeChat 4.0.3) |
14:57:26 | * | fireglow left #nim (puf) |
15:23:34 | FromDiscord | <ezquerra> @_araq, I'm trying to buy the kindle version of the new edition of your book. I can see it on the links that you shared in the forum, but as soon as I log in the kindle version disappears and I can only see the paperback edition. I already bought the paperback of the previous edition, that's why I want to buy the kindle version now... |
15:23:39 | FromDiscord | <ezquerra> Does anybody else have the same issue? |
15:24:05 | FromDiscord | <odexine> Might be a region thing somehow? |
15:25:23 | * | lucasta_ joined #nim |
15:27:14 | FromDiscord | <_araq> @eqzuerra I recently updated it and gave it a new cover, maybe there are some hiccups because of that |
15:27:29 | FromDiscord | <_araq> apart from that, I don't know, sorry. |
15:28:38 | FromDiscord | <ezquerra> OK, I'll try again in a little while. If somebody manages to buy that version please let me know |
15:30:29 | FromDiscord | <ezquerra> @_araq, could it be that you only uploaded the Kindle version of Germany and the US? |
15:30:44 | FromDiscord | <ezquerra> (edit) "of" => "to the" | "US?" => "US amazon stores?" |
15:34:04 | FromDiscord | <_araq> I can check but that's quite impossible |
15:48:12 | * | lucasta_ quit (Ping timeout: 252 seconds) |
15:50:18 | FromDiscord | <heysokam> @pmunch I hadn't used nimlsp since 1.16.12 or something like that↵I love that the tooltips for strformat's `&` are now giving an error notice. Back then they weren't, and its so useful to have them!↵Don't know when that got introduced, but tysm for that 🤘 |
15:51:16 | FromDiscord | <heysokam> Seems like I have been out of bounds for a while and missed quite a lot of updates 🙂 |
16:16:57 | NimEventer | New thread by bsljth: One language to rule them all., see https://forum.nim-lang.org/t/10442 |
17:07:10 | FromDiscord | <enthus1ast> which matrix client library do you use? |
17:16:59 | * | marcus quit (Remote host closed the connection) |
17:18:09 | * | marcus joined #nim |
17:24:51 | FromDiscord | <ieltan> In reply to @termer "it should absolutely be": Hi! I am curious about your experience with `views`, I've always heard it was buggy as heck |
17:24:56 | * | hernan_ is now known as hernan |
17:25:05 | FromDiscord | <ieltan> It would be greatly appreciated if you did |
17:51:05 | FromDiscord | <Chronos [She/Her]> Hey, question, what issues are there with using async and threading together? |
17:53:19 | FromDiscord | <dmisener> Quick question: How do I convert a std/paths Path back into a string? |
17:54:22 | FromDiscord | <huantian> should just be $ |
17:56:13 | FromDiscord | <dmisener> sent a long message, see http://ix.io/4Evf |
18:04:02 | FromDiscord | <dmisener> Sorry.. just checked the splitFile code and found the undocumented method "string". So echo path.string works! Obvious in hindsight. |
18:04:20 | FromDiscord | <jviega> Isn't the $ in os? |
18:04:41 | FromDiscord | <dmisener> Apparently not for Path |
18:04:50 | FromDiscord | <jviega> Hmm yeah weird |
18:07:48 | FromDiscord | <dmisener> If I define proc `$`(path: Path): string = path.string ↵that work... Looks like it was just missed??\ |
18:11:03 | FromDiscord | <enthus1ast> mhh $ for path should be in the new std/paths but its not there |
18:11:03 | FromDiscord | <enthus1ast> maybe open an github issue about this |
18:11:48 | FromDiscord | <enthus1ast> or pr \:) |
18:13:34 | FromDiscord | <heysokam> In reply to @dmisener "Quick question: How do": `thepath.string` they are just `distinct string` |
18:13:42 | FromDiscord | <heysokam> at least the last time i checked they were just that |
18:16:02 | FromDiscord | <heysokam> @dmisener @enthus1ast these are other things I found missing for paths↵https://github.com/heysokam/nstd/blob/master/src/nstd/paths.nim |
18:16:50 | FromDiscord | <enthus1ast> yes they are |
18:18:00 | FromDiscord | <heysokam> they are "missing" or they are "there"? |
18:18:40 | FromDiscord | <enthus1ast> yes they are distinct string |
18:20:25 | FromDiscord | <heysokam> In reply to @dmisener "Sorry.. just checked": btw just noticed the `undocumented method "string"` part of this message↵it is not a method, its the type itself. you can do that with any type, it just calls the internal converter of that type↵That's why its not documented, because its a feature of the lang, not exclusive to paths |
18:21:10 | FromDiscord | <Chronos [She/Her]> I'm wondering why I have an 'add condition' type and for what it'd be used for tbh |
18:21:18 | FromDiscord | <ieltan> In reply to @chronos.vitaqua "Hey, question, what issues": That's actually a pretty good question |
18:22:26 | FromDiscord | <enthus1ast> to bad that we not have used the opportunity to have a AbsolutePath and RelativPath type \:) |
18:22:29 | FromDiscord | <Chronos [She/Her]> In reply to @ieltan "That's actually a pretty": Yeah, I'm wondering why an async scheduler couldn't work together, I know refc would've made it a major issue but surely arc/orc would work better (even if they have their own challenges) |
18:23:39 | FromDiscord | <ieltan> Well, orc/arc has shared heap I think so it can be doable actually |
18:24:05 | FromDiscord | <ieltan> It's really a "you gotta know you're doing" |
18:24:10 | FromDiscord | <ieltan> thing |
18:24:29 | FromDiscord | <Chronos [She/Her]> Yeah |
18:24:42 | FromDiscord | <ieltan> There is also isolation that came out but I have no idea how to use it |
18:24:53 | FromDiscord | <dmisener> sOkam! - -Thanks for the clarfication |
18:27:58 | FromDiscord | <Chronos [She/Her]> Is there any way to check if a proc is asynchronous? |
18:31:43 | termer | check whether it returns a Future |
18:36:09 | NimEventer | New thread by DMisener: Re: std/Paths - Converting Path to string , see https://forum.nim-lang.org/t/10443 |
18:41:18 | FromDiscord | <Chronos [She/Her]> In reply to @termer "check whether it returns": Aaand how do I do that?- |
18:42:02 | FromDiscord | <Chronos [She/Her]> I'm assuming to just run it? |
18:48:49 | termer | are you checking at compile time or runtime? |
18:48:52 | termer | what are you trying to do? |
18:50:42 | FromDiscord | <Chronos [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4Evp |
18:52:11 | termer | you could create an async concept |
18:52:32 | termer | type AsyncProc = concept x: x() is Future |
18:52:58 | termer | then your isAsync can be populated at compile time as "T is AsyncProc" |
18:53:36 | FromDiscord | <Chronos [She/Her]> Yeah I can do that, thanks! |
18:53:46 | termer | Yup, no problem |
18:56:11 | FromDiscord | <Chronos [She/Her]> Tbh do I even need a new proc anymore... I think I can remove it since default values |
19:06:36 | * | kenran quit (Remote host closed the connection) |
19:27:54 | termer | that works |
19:28:48 | FromDiscord | <Chronos [She/Her]> Is there a way to catch all defects and errors? Planning on making it so I can raise an exception after all listeners have fired |
19:30:25 | termer | try: except: |
19:30:34 | * | junaid_ joined #nim |
19:30:35 | termer | This is deprecated though I think |
19:30:46 | termer | I think they both inherit from Exception |
19:30:50 | termer | you can most likely catch Exception |
19:35:26 | FromDiscord | <Chronos [She/Her]> Gucci! |
19:35:34 | FromDiscord | <Chronos [She/Her]> Wait try and except is deprecated?? |
19:37:14 | * | junaid_ quit (Remote host closed the connection) |
19:38:37 | termer | or wait |
19:38:45 | termer | I don't remember if it is |
19:39:05 | termer | there was a short period of time where there was deprecation on catching Exception |
19:43:48 | FromDiscord | <juan_carlos> In reply to @chronos.vitaqua "Wait try and except": Naked `except:` without exception is deprecated, like `except OSerror:` etc |
19:44:48 | FromDiscord | <jviega> Didn't that get undone?? |
19:52:09 | FromDiscord | <Chronos [She/Her]> Ah |
20:02:38 | FromDiscord | <Chronos [She/Her]> Tbh I don't need to catch exceptions, that's the listeners job, not mine |
20:07:02 | * | azimut joined #nim |
20:08:41 | termer | Chronos What're you doing |
20:08:56 | termer | If you're running a bunch of handlers, you need to think about whether an exception in one should halt any others from working |
20:09:17 | termer | So you should catch all exceptions |
20:11:28 | FromDiscord | <Chronos [She/Her]> I'm catching the top level exception and `echo`ing it but I'm not gonna be catching them and waiting for it all to finish to print it in a pretty way, I meant |
20:12:06 | FromDiscord | <Chronos [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4EvC |
20:13:40 | FromDiscord | <Chronos [She/Her]> I was originally going to catch them all and add them to a list and then format it into a cleaner way but, that's more effort than I need to put into it really |
20:14:15 | FromDiscord | <juan_carlos> Fire and forget |
20:16:24 | termer | If you have async handlers, just do asyncCheck on them |
20:16:30 | termer | assuming you're not waiting for them |
20:17:00 | FromDiscord | <ggaast> sent a long message, see http://ix.io/4EvD |
20:17:34 | FromDiscord | <Elegantbeef> Eh using mold did not appreciably change compile times in my experience |
20:17:48 | FromDiscord | <Elegantbeef> you also really want to do `--gcc.linkerexe="mold"` |
20:17:57 | FromDiscord | <ggaast> im on linux |
20:18:04 | FromDiscord | <Elegantbeef> Ok and? |
20:18:22 | FromDiscord | <ggaast> you also really want to do `--gcc.linkerexe="mold"` |
20:18:29 | FromDiscord | <ggaast> sorry |
20:18:53 | FromDiscord | <ggaast> figuring up how to use fluffy chat, a bit confusing |
20:19:23 | FromDiscord | <Chronos [She/Her]> In reply to @termer "If you have async": That's what I'm doing, but also I'm supporting the calling of async handlers synchronously too |
20:19:37 | FromDiscord | <Chronos [She/Her]> Unless asyncCheck works in synchronous procs which is news to me- |
20:20:08 | termer | it doesn't work that way lol |
20:20:14 | FromDiscord | <ggaast> I thought `exe` in this line refers for windows version, i will try to do it rn |
20:20:28 | FromDiscord | <Elegantbeef> No it just refers to an executable |
20:20:45 | FromDiscord | <Chronos [She/Her]> In reply to @termer "it doesn't work that": What do you mean? Calling an async event with `waitFor` is blocking, right? Which is the goal of the `fire` proc |
20:20:58 | termer | oh wait |
20:21:01 | termer | I see what you're saying |
20:21:02 | FromDiscord | <Elegantbeef> With how nim does compilation I do not think you can just use the `-f...` way of using mold |
20:21:12 | FromDiscord | <Chronos [She/Her]> Sweet :) |
20:21:48 | FromDiscord | <Elegantbeef> I used mold on compilation of the Nim compiler and like i said there was no appreciable benefit |
20:22:12 | FromDiscord | <Elegantbeef> TCC on the otherhand does give appreciable benefits in some programs |
20:22:14 | FromDiscord | <Elegantbeef> But with Nim 2.0 you need to do `--threads:off` |
20:22:26 | FromDiscord | <Chronos [She/Her]> Ah I did structure my code weirdly though, supposed to call `waitFor` on the return type of `waitFor` |
20:22:38 | FromDiscord | <Chronos [She/Her]> (edit) "`waitFor`" => "`unpackTuple`" |
20:23:05 | FromDiscord | <Elegantbeef> Most of the time compiling programs in Nim is spent in Nim presently |
20:23:21 | FromDiscord | <Elegantbeef> Hence the desire of an incremental compiler |
20:23:57 | FromDiscord | <Phil> In reply to @chronos.vitaqua "Hey, question, what issues": afaik each thread has its own scheduler, so that'd run into limitations.↵Note that I barely have an idea what I'm talking about here as I only recently started actually getting into the basics of async beyond just using the syntax |
20:24:25 | FromDiscord | <Elegantbeef> Yes each thread has it's own async runtime, so it's fine as long as you do not attempt to share futures or similar |
20:24:34 | FromDiscord | <Elegantbeef> You have to complete a future on the thread that made it |
20:24:36 | FromDiscord | <Chronos [She/Her]> In reply to @isofruit "afaik each thread has": Fair enough, though isn't it possible to make them share a scheduler? Or is `PDispatcher` different from that |
20:25:01 | FromDiscord | <Phil> ... That sounds possible... but it'd be a shared resource so definitely would require locks |
20:25:17 | FromDiscord | <Chronos [She/Her]> I remember being able to set the dispatcher from a (Nim-compiled) shared library to the dispatcher in the application loading the shared libs |
20:25:33 | FromDiscord | <Chronos [She/Her]> It barely worked half the time lmao but yeah |
20:25:43 | FromDiscord | <Elegantbeef> I seem to remember you had nothing but issues |
20:25:49 | FromDiscord | <ggaast> im worring about long comptimes, is it a problem in large scaled apps? I tryed to compile my project with happyx (just big random lib from perspective) and it took 6 seconds. |
20:25:49 | FromDiscord | <Chronos [She/Her]> In reply to @Elegantbeef "I seem to remember": Yes xD |
20:26:02 | FromDiscord | <Chronos [She/Her]> But it did occasionally |
20:26:06 | FromDiscord | <Elegantbeef> I mean there is no way of speeding up Nim's compile times presently |
20:26:16 | FromDiscord | <Elegantbeef> You can use TCC and mold, but that's not going to help much |
20:26:28 | FromDiscord | <Chronos [She/Her]> The errors where the biggest pain point really |
20:26:40 | FromDiscord | <Elegantbeef> It's not like Nim isnt relatively fast compared to Go/Rust though |
20:26:52 | FromDiscord | <Elegantbeef> Slow as hell compared to zig/odin though |
20:27:08 | FromDiscord | <Chronos [She/Her]> In reply to @Elegantbeef "You can use TCC": Iirc the LLVM project made something called `gold` as a new linker that works way faster but idk how good it actually is |
20:27:22 | FromDiscord | <Chronos [She/Her]> Also only works with stuff that LLVM for compilation |
20:27:24 | FromDiscord | <Elegantbeef> Sure, but like i said mold doesnt even help much |
20:27:53 | FromDiscord | <Elegantbeef> Like the nim compiler was only a few hundred ms faster if i recall correctly |
20:28:14 | FromDiscord | <Phil> ... I mean release compiletimes can be as long as they want and thus linker compiletimes are of secondary relevance, debug compiles is where it's at and for those you might as well not do lto |
20:28:38 | FromDiscord | <Elegantbeef> "might as well not do lto" |
20:28:41 | FromDiscord | <Elegantbeef> What a funny thing to say |
20:29:04 | FromDiscord | <Elegantbeef> Why the hell would you enable an optimisation flag for your debug program! 😄 |
20:29:24 | FromDiscord | <ggaast> Yeah, never \:) |
20:29:43 | FromDiscord | <Elegantbeef> "For extra spice I add `--objChecks: off` and randomly tick off `--boundChecks:off` just for added fun" |
20:30:41 | FromDiscord | <ezquerra> @_araq FYI I managed to buy the kindle version of the book, but I had to go through the US store |
20:30:47 | FromDiscord | <Phil> In reply to @chronos.vitaqua "Fair enough, though isn't": Just double checked with status-nim/chronos: They also don't do shared schedulers, so might either not be a good idea or hit complexity limitations etc. |
20:31:21 | FromDiscord | <ggaast> may be there is good hot-reload/bin-patching approach? I really love nim syntax, but perspective of waiting 5+ seconds after "Color" value is not much promicing for me |
20:31:34 | FromDiscord | <ggaast> after changing "Color"\\ |
20:32:01 | termer | what does --objChecks do |
20:32:01 | FromDiscord | <Phil> I'm not aware of any tbh |
20:32:17 | FromDiscord | <Elegantbeef> disables inheritance checks |
20:32:44 | FromDiscord | <Elegantbeef> You could make your own plugin system using Wasm/Dlls, you could use nimscript, otherwise there is not |
20:33:22 | FromDiscord | <Elegantbeef> Nim's HCR does not work even though it's there |
20:33:51 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/1144731387677659186/image.png |
20:33:54 | FromDiscord | <Elegantbeef> Tonnes of control termer |
20:34:05 | FromDiscord | <Elegantbeef> All can be used inside pragmas to disable for specific procedures aswell |
20:35:16 | termer | are you saying that you can use objects that don't share an inherited ancestor |
20:35:35 | termer | I've done raw casting to do hilarious things like untyped maps before |
20:35:44 | FromDiscord | <Elegantbeef> No |
20:35:58 | FromDiscord | <Elegantbeef> You use it to disable checks for a tree |
20:36:17 | termer | type checking in general? |
20:36:27 | termer | I'm not clear on what you mean |
20:36:45 | termer | or wait |
20:36:51 | termer | man, if only this was *documented* |
20:37:15 | FromDiscord | <Elegantbeef> That way you can convert a parent to a child or a unrelated child to another child |
20:37:15 | FromDiscord | <Elegantbeef> It's all in the same family tree though |
20:38:29 | termer | interesting, though I'm not sure what you could use that for |
20:38:55 | FromDiscord | <ggaast> How much time do you spend on comptimes in avarage in your projects? |
20:40:12 | FromDiscord | <ggaast> i mean in debug mode |
20:40:13 | FromDiscord | <Elegantbeef> Removing the overhead of type checking inside a procedure you know that a type is a specific branch |
20:40:23 | FromDiscord | <Elegantbeef> My game takes like 3s to compile |
20:40:32 | FromDiscord | <Chronos [She/Her]> In reply to @isofruit "Just double checked with": Hm... Fair enough |
20:40:37 | FromDiscord | <Elegantbeef> 5s from a uncached state |
20:40:55 | FromDiscord | <Chronos [She/Her]> In reply to @Elegantbeef "You could make your": I used shared libs before, went poorly- Probably because I tried doing a ton of async stuff? |
20:41:10 | FromDiscord | <Elegantbeef> No clue you do manic shit so I cannot say much |
20:41:18 | FromDiscord | <Chronos [She/Her]> Pffffff |
20:41:35 | FromDiscord | <Chronos [She/Her]> I do it for the ✨ d o p a m i n e ✨ |
20:42:02 | FromDiscord | <Elegantbeef> Well you have to use the NimRTL if you want to use GC across the barrier |
20:42:05 | FromDiscord | <Elegantbeef> I doubt you used the RTL which probably didnt help |
20:42:11 | FromDiscord | <Elegantbeef> But anyway I'm getting barked at for a walk, so I best go before it pisses down |
20:42:18 | FromDiscord | <Chronos [She/Her]> No, I used arc/orc actually |
20:42:34 | FromDiscord | <Chronos [She/Her]> Which doesn't use RTL, since only refc needs that afaik |
20:42:45 | FromDiscord | <Chronos [She/Her]> In reply to @Elegantbeef "But anyway I'm getting": Fair enough lol, have a good walk with ya dog |
20:46:36 | FromDiscord | <Elegantbeef> No the RTL is needed still to share allocator |
20:51:24 | FromDiscord | <Chronos [She/Her]> Huh? I... Actually never knew that, that's probably why it went up in flames xD |
20:52:58 | FromDiscord | <Chronos [She/Her]> I was told before it wasn't needed which is why I never bothered to figure it out tbh |
21:03:45 | * | disso-peach quit (Quit: Leaving) |
21:12:18 | * | advesperacit quit () |
21:22:58 | FromDiscord | <Andreas> sent a code paste, see https://play.nim-lang.org/#ix=4EvX |
21:23:58 | FromDiscord | <Elegantbeef> Well the second branch is not a ternary |
21:24:22 | FromDiscord | <Elegantbeef> to achieve 2 you can do `s += int(a[i] < 50) a[i]` in Nim |
21:24:22 | FromDiscord | <Andreas> the third looks like a ternary - second no idea what that is.. |
21:24:36 | FromDiscord | <Elegantbeef> Second is just C |
21:24:53 | FromDiscord | <Elegantbeef> Since C does not have a distinct 'bool' all comparisons are just integers either 0 or 1 |
21:25:25 | FromDiscord | <Elegantbeef> The third is a ternary yes, so it's not branchless afaik |
21:25:38 | FromDiscord | <Andreas> In reply to @Elegantbeef "Second is just C": that legal ? multiplying a bool with a value? |
21:25:48 | FromDiscord | <Elegantbeef> Like I said C does not have a bool |
21:25:58 | FromDiscord | <Elegantbeef> `1 < 2` is not a bool in C it's an integer |
21:26:38 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4Ew3 |
21:27:16 | FromDiscord | <Elegantbeef> I've never seen anyone use a string constant inside fmt, this is amazing 😄 |
21:27:59 | FromDiscord | <Elegantbeef> Would Strutils `%` be any cleaner |
21:28:00 | FromDiscord | <heysokam> I took it from someone here. its kinda handy for naming things and pre-defining the pattern |
21:28:03 | FromDiscord | <arathanis> In reply to @Andreas "that legal ? multiplying": literally stdbool.h https://media.discordapp.net/attachments/371759389889003532/1144745025360629910/image.png |
21:31:56 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4Ew6 |
21:32:39 | FromDiscord | <heysokam> not much of a fan of the %, since names become numbers and they become much harder to track to their corresponding pair |
21:37:14 | FromDiscord | <heysokam> sidenote:↵is `varargs[...].join()` not a thing? I thought that varargs were sequences? 🤔 |
21:37:49 | FromDiscord | <Elegantbeef> What? |
21:38:04 | FromDiscord | <Elegantbeef> `varargs[...]`? meaning? |
21:38:13 | FromDiscord | <heysokam> any varargs |
21:38:29 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4Ew7 |
21:38:48 | FromDiscord | <Andreas> In reply to @Elegantbeef "`1 < 2` is": thx - thats really amazing :: https://play.nim-lang.org |
21:38:49 | FromDiscord | <Elegantbeef> What did you try that failed? |
21:39:19 | FromDiscord | <Elegantbeef> And no varargs are not sequences they're open arrays |
21:39:25 | FromDiscord | <heysokam> `var msg :string= args.join()` |
21:40:29 | FromDiscord | <Andreas> In reply to @arathanis "literally stdbool.h": sure in C booleans are ints, but the nim-code `int( true ) == 1` surprised me.. |
21:40:47 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4Ew8 |
21:41:01 | FromDiscord | <Elegantbeef> `int(true)` is a type conversion, what's so suprising? |
21:41:14 | FromDiscord | <heysokam> In reply to @Andreas "sure in C booleans": how would you interop with C if that wasn't correct? |
21:41:22 | FromDiscord | <heysokam> how would you compile to C even |
21:41:53 | FromDiscord | <Andreas> In reply to @heysokam "how would you compile": hey, i don't compile anything - i'm the user here 😉 |
21:43:16 | FromDiscord | <heysokam> tyty |
21:43:17 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4Ew9 |
21:43:29 | FromDiscord | <Elegantbeef> Ummm acktually `nim c` is 'nim compile' so you do indeed compile! |
21:43:52 | FromDiscord | <Elegantbeef> Sokam sometimes it feels like you just drop a wrench on your keyboard and hope code works 😄 |
21:44:52 | FromDiscord | <jviega> LOL |
21:45:42 | FromDiscord | <Andreas> In reply to @heysokam "how would you interop": just, not a everday - variant, but anyway - one more question pls : how come a that a `ternary-expression` as of C or JS is to be considered 'branchless' ? Isnt it simply a disguised `if` - the compiler/cpu has to do same decision ? |
21:46:05 | FromDiscord | <Elegantbeef> It's not branchless |
21:46:18 | FromDiscord | <Elegantbeef> Sometimes it can be optimised to branchless, but it's not generally branchless |
21:46:52 | FromDiscord | <Elegantbeef> like `a ? b : -b` could be done branchless or `a ? true: false` |
21:46:53 | FromDiscord | <Andreas> In reply to @Elegantbeef "Sometimes it can be": i totally agree, sourc is here https://en.algorithmica.org/hpc/simd/masking/ |
21:47:23 | FromDiscord | <Elegantbeef> Right and that's branchless in hindsight |
21:47:40 | FromDiscord | <Elegantbeef> Since it's the exact same as the no branch |
21:47:59 | FromDiscord | <Elegantbeef> think about it if you know `a[i]` is true and `0` is false that's just `a[i] < 50 a[i]` |
21:48:10 | FromDiscord | <Elegantbeef> Since in the case a[i] \> 50 it's 0 |
21:48:20 | FromDiscord | <Elegantbeef> so the compiler can reason these shortcuts and implicitly write them |
21:48:36 | FromDiscord | <Elegantbeef> Simple ternary operations that represent branchless code can be done in a branchless way |
21:48:38 | FromDiscord | <heysokam> In reply to @Elegantbeef "Sokam sometimes it feels": truer that truth 😄 |
21:55:54 | FromDiscord | <Chronos [She/Her]> Do try except statements work for catching code ran with `asyncCheck`? |
21:56:26 | FromDiscord | <Chronos [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4Ewg |
21:56:37 | FromDiscord | <Chronos [She/Her]> (edit) "https://play.nim-lang.org/#ix=4Ewg" => "https://play.nim-lang.org/#ix=4Ewh" |
21:56:38 | FromDiscord | <Elegantbeef> I don't imagine so |
21:56:42 | FromDiscord | <Chronos [She/Her]> Ignore the `.` |
21:56:48 | FromDiscord | <Elegantbeef> Since the `asyncCheck` is not where the code is actually ran |
21:57:13 | FromDiscord | <Chronos [She/Her]> In reply to @Elegantbeef "I don't imagine so": Damn, can I make a proc that awaits the future then and run that with asyncCheck to catch any errors? |
21:58:10 | FromDiscord | <Elegantbeef> I mean same issue afaik you're not running code at the async check iirc |
21:58:39 | FromDiscord | <Andreas> sent a code paste, see https://play.nim-lang.org/#ix=4Ewk |
21:58:43 | FromDiscord | <Chronos [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4Ewl |
21:58:45 | FromDiscord | <Chronos [She/Her]> In reply to @Elegantbeef "I mean same issue": Painful |
22:00:26 | FromDiscord | <Chronos [She/Her]> Idk how to solve this- Unless there's a callback for errors...? Probably is tbh |
22:00:55 | FromDiscord | <Chronos [She/Her]> >>> Sets a callback on future which raises an exception if the future finished with an error.↵↵This should be used instead of discard to discard void futures, or use waitFor if you need to wait for the future's completion. |
22:01:03 | FromDiscord | <Chronos [She/Her]> This is what the docs say so it should be fine? |
22:02:50 | * | oisota quit (Quit: Ping timeout (120 seconds)) |
22:03:09 | * | oisota joined #nim |
22:04:24 | FromDiscord | <huantian> you can check it in the future callback but you should probably be handling your errors in the async code |
22:04:49 | FromDiscord | <huantian> just do the same thing asyncCheck does but with your own callback |
22:07:16 | FromDiscord | <pmunch> In reply to @heysokam "<@392962235737047041> I hadn't used": Not sure this is something that's been added in NimLSP, might just be a nimsuggest feature. In any case I didn't implement it so thank someone else 🙂 |
22:07:25 | FromDiscord | <Chronos [She/Her]> In reply to @huantian "you can check it": It's for my event system library, so that's not possible if someone makes faulty code really |
22:07:33 | FromDiscord | <pmunch> Glad you like NimLSP though |
22:08:02 | FromDiscord | <Chronos [She/Her]> How does https://nim-lang.org/docs/locks.html work exactly...? Not sure how to create a lock and correctly wait for the lock to be released |
22:12:00 | FromDiscord | <Elegantbeef> 'correctly wait for the lock to be released' you just do `tryAcquire` |
22:12:05 | FromDiscord | <Elegantbeef> Or `withLock` |
22:15:28 | FromDiscord | <Chronos [She/Her]> Does `withLock` do that automatically for me then? |
22:15:36 | FromDiscord | <Chronos [She/Her]> And is it fine to use in async code or is it blocking? |
22:17:01 | FromDiscord | <Elegantbeef> 'is locking blocking; |
22:17:13 | FromDiscord | <Elegantbeef> If locking wasn't blocking we'd have problems |
22:17:48 | FromDiscord | <pmunch> I mean async locks could be cool |
22:18:40 | FromDiscord | <Elegantbeef> I don't know might just be my lack of threading/async, but that seems rather pointless |
22:19:44 | FromDiscord | <Elegantbeef> "I really need to do work that is thread safe, but I can wait to do it until I get a lock" seems like such a rare situation to me |
22:20:18 | FromDiscord | <Elegantbeef> But one could reimplement `withlock` that wraps `tryacquire` in a async sleep loop to make it an async way of getting a lock I guess |
22:26:21 | FromDiscord | <burnysc2> sent a code paste, see https://play.nim-lang.org/#ix=4Ewv |
22:27:08 | FromDiscord | <griffith1deadly> In reply to @burnysc2 "I'm a bit surprised": why surprised |
22:27:55 | FromDiscord | <Elegantbeef> Nim explicitly states that fields are preferred over procedures when used in method call |
22:28:19 | FromDiscord | <burnysc2> i just accidently did that and was wondering why my variable wouldnt update (i expected the function call to be executed here)↵turns out i forgot to remove the attibute |
22:29:15 | FromDiscord | <burnysc2> In reply to @Elegantbeef "Nim explicitly states that": i mean it is neat, i just didnt expect it↵i suppose i will have to continue reading the manual :) |
22:58:55 | FromDiscord | <Andreas> the Cpp-branching-thingy is here -> https://godbolt.org/z/nj74dfGa4 i'm not exctly sure about the ternary beeing not a branch ? ↵sections .L10 - .L12 |
23:00:21 | FromDiscord | <Elegantbeef> no optimization |
23:00:45 | FromDiscord | <Andreas> ok, l3 then |
23:06:07 | FromDiscord | <Elegantbeef> Well yea you arent using s |
23:06:18 | FromDiscord | <Elegantbeef> https://godbolt.org/z/1jGd9h4Wa |
23:06:27 | FromDiscord | <Andreas> s ? whats that ? |
23:08:08 | FromDiscord | <Elegantbeef> The variable? |
23:14:16 | FromDiscord | <Andreas> In reply to @Elegantbeef "The variable?": does it make sense to send a nim-binary for comparrisson with the Cpp-thinggy ? |
23:15:07 | FromDiscord | <System64 ~ Flandre Scarlet> Did someone already written an emulator in Nim? |
23:15:08 | FromDiscord | <Elegantbeef> Why send a nim binary, just write nim code 😄 |
23:15:32 | FromDiscord | <Andreas> In reply to @Elegantbeef "Why send a nim": OMG - thats sweet |
23:38:59 | * | FromDiscord quit (Remote host closed the connection) |
23:39:12 | * | FromDiscord joined #nim |