00:03:18 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4lSE |
00:16:08 | FromDiscord | <ShalokShalom> In reply to @Verdagon "one can successfully make": Do you plan on proper pattern matching? |
00:18:14 | FromDiscord | <Verdagon> yep! we actually already have that: https://vale.dev/guide/patterns |
00:18:31 | FromDiscord | <Verdagon> the only thing missing is a `match` statement to test the actual type of an incoming interface |
00:24:05 | FromDiscord | <ShalokShalom> Cool |
00:24:14 | FromDiscord | <ShalokShalom> Wish you all the best! |
00:24:22 | FromDiscord | <Verdagon> thanks =) |
00:55:49 | FromDiscord | <Hourglass> In reply to @Gumbercules "<@337101146017497109> sorry I'm not": Vale? |
00:55:53 | FromDiscord | <Hourglass> What's that? |
00:56:08 | FromDiscord | <Gumbercules> https://github.com/ValeLang/Vale |
00:59:42 | FromDiscord | <Hourglass [She/Her]> That looks cool actually! Syntax ain't my style really but it looks super neat |
01:06:10 | * | argonica joined #nim |
01:11:22 | * | argonica quit (Quit: Leaving) |
01:25:55 | FromDiscord | <Rika> Lots of activity recently huh |
01:57:16 | FromDiscord | <Gumbercules> In reply to @Rika "Lots of activity recently": lots of activity in here? |
01:57:22 | FromDiscord | <Gumbercules> or in regard to Vale? |
02:06:33 | arkanoid | what's the most idiomatic way to have seq with ref semantics? |
02:06:44 | FromDiscord | <Elegantbeef> `ref seq[T]` |
02:06:54 | arkanoid | as simple as that? |
02:06:59 | arkanoid | cool, thanks |
02:07:05 | FromDiscord | <Elegantbeef> Yes |
02:07:19 | arkanoid | I though I would have faced issues with that, not sure why |
02:09:46 | FromDiscord | <Rika> In reply to @Gumbercules "lots of activity in": Here |
02:12:35 | FromDiscord | <Gumbercules> In reply to @Rika "Here": the creator of Vale hopped in not too long ago - seemed to have had some flurry around that |
02:12:44 | FromDiscord | <Gumbercules> not sure what else went on in the past 24 hours |
02:13:23 | FromDiscord | <Gumbercules> been attempting to add indirect dispatch support to `sokol_gfx` the past few days and it's been slow and painful |
02:13:44 | FromDiscord | <Rika> When was programming not slow and painful |
02:14:02 | FromDiscord | <Gumbercules> well when you already know what you're doing, it tends to be less so |
02:14:26 | FromDiscord | <Gumbercules> I'm in one of those - I barely have any idea what I'm doing here - modes |
02:16:50 | arkanoid | have you ever tried treeform/shady? I though I was far from able to run custom algorithms on the gpu, but shady made me do it successfully. Suggested! |
02:18:05 | FromDiscord | <Gumbercules> In reply to @arkanoid "have you ever tried": I haven't used it before, primarily because I'm supporting as many rendering APIs as possible |
02:18:28 | FromDiscord | <Gumbercules> `sokol_gfx` doesn't support compute shaders out of the box, so I've plugged that hole, but indirect dispatch / drawing is still unsupported |
02:19:01 | FromDiscord | <Gumbercules> I'm implementing a terrain rendering technique which I've implemented before using BGFX - I'm still not completely sold on the idea that I need compute shader support, but it sure would be nice to have |
02:19:22 | arkanoid | Gumbercules: I've just realized I've dropped into a related topic accidentally. I wrote what I wrote without knowing the chat context! |
02:19:42 | FromDiscord | <Gumbercules> I do it all the time, so no worries at all and no need to apologize đ |
02:21:40 | arkanoid | btw, shady let you write all nim and then convert it automatically to glsl. You just need to pay attention to types as you are limited to the shared ones for the code to be ported automatically (well, it's possible to add custom types, but I have not yet experimented with it). Long story short, you can keep your nim code as nim code |
02:22:11 | FromDiscord | <Gumbercules> yeah - I already have a tool which cross compiles shader code to whatever shading language I need via spirv-cross |
02:22:16 | FromDiscord | <Gumbercules> but I can't write my shaders in Nim |
02:22:29 | FromDiscord | <Gumbercules> or run my shader code on the CPU |
02:22:42 | FromDiscord | <Gumbercules> I'm okay with this though |
02:23:08 | FromDiscord | <Gumbercules> it also provides me with reflection data for my shaders so that I can hot reload them when they change |
02:23:09 | arkanoid | doing the same here. I can run nim functions on CPU or GPU. I use the first for debugging, the second for performance. Sweet! |
02:23:24 | FromDiscord | <Gumbercules> yeah debugging shaders is definitely a pain |
02:23:35 | FromDiscord | <Gumbercules> getting easier all the time though thanks to renderdoc etc |
02:24:40 | arkanoid | you seems much more expert than me on this topic. I have no ide what spirv-cross is, nor renderdoc, nor BGFX, nor sokol_gfx |
02:25:53 | FromDiscord | <Gumbercules> https://en.wikipedia.org/wiki/Standard_Portable_Intermediate_Representation |
02:25:53 | arkanoid | Elegantbeef, and how I am supposed to (idiomatically) create a new ref seq[T]? |
02:26:04 | FromDiscord | <Gumbercules> https://github.com/KhronosGroup/SPIRV-Cross |
02:26:09 | FromDiscord | <Elegantbeef> `var a = new seq[T]` |
02:26:11 | arkanoid | new newSeq[int](30)? |
02:26:15 | FromDiscord | <Gumbercules> https://github.com/bkaradzic/bgfx |
02:26:22 | FromDiscord | <Elegantbeef> Nope |
02:26:28 | FromDiscord | <Gumbercules> https://github.com/floooh/sokol |
02:26:36 | FromDiscord | <Elegantbeef> `var a = new seq[T]; a[] = newSeq[T](size)` |
02:26:41 | FromDiscord | <Gumbercules> https://renderdoc.org/ |
02:27:59 | FromDiscord | <jtv> Is there really a good reason to use a ref instead of just placing var params where you need reference semantics? |
02:29:22 | FromDiscord | <Elegantbeef> Well there is no reason there |
02:29:25 | FromDiscord | <Elegantbeef> Nim passes seq/string by ref |
02:30:24 | FromDiscord | <Gumbercules> sometimes you need references and your only real option is `ptr`, `pointer` + `cast`, or `ref` |
02:31:20 | FromDiscord | <Gumbercules> of course, when passing arguments to functions, `var` parameters will work for non `ref` types |
02:31:24 | * | jjido quit (Ping timeout: 264 seconds) |
02:31:37 | FromDiscord | <Elegantbeef> But there generally isnt any reason to annotate `var` for pass by ref |
02:31:43 | FromDiscord | <Elegantbeef> Since nim already does that for larger types |
02:31:43 | FromDiscord | <Gumbercules> no |
02:32:01 | FromDiscord | <Gumbercules> yes - but knowing when something is passed by ref or not can be confusing |
02:32:18 | FromDiscord | <Gumbercules> and usually people figure it out through slamming heads against objects |
02:33:20 | FromDiscord | <Gumbercules> `string` and `seq` being the major offenders |
02:34:11 | FromDiscord | <Gumbercules> (edit) "and usually people figure it out through ... slamming" added "experimentation and" |
02:35:07 | FromDiscord | <Gumbercules> but yeah, I don't think I've ever found the need for a `ref seq[T]` or a `ref string` |
02:35:25 | FromDiscord | <Elegantbeef> I dont think it's that hard to figure out, but maybe i'm just wrong |
02:36:01 | FromDiscord | <Elegantbeef> If it's not annotated by `byref` and is smaller than 24 bytes(or is it sizeof(pointer) \ 3) it's by value |
02:37:01 | arkanoid | Gumbercules: thanks for all the links, I see an unknown world in front of me now. What I don't get is sokol. What's that? |
02:37:02 | FromDiscord | <Gumbercules> it's not that it's hard to figure out |
02:37:20 | FromDiscord | <Gumbercules> it's that the easy assumption is that value semantics are going to be default |
02:37:42 | FromDiscord | <Gumbercules> so people run with that assumption and figure out later it's not the case |
02:38:21 | FromDiscord | <jtv> Sure, but he wanted reference semantics, meaning mutability, where under the hood it's going to pass-by-reference but won't let him mutate. Var is generally a much more normal solution that a ref |
02:39:00 | FromDiscord | <Gumbercules> In reply to @arkanoid "<@204328759715692544>: thanks for all": Sokol is a collection of single header libraries that do various things - so there's one that offers a cross platform graphics API similar to BGFX, that would be `sokol_gfx.h` - Sokol however focuses on supporting a smaller subset of APIs than BGFX and it also has zero dependencies |
02:39:54 | arkanoid | sokol, I think it is just me that I don't see the advantage of "single header library" |
02:39:56 | FromDiscord | <Gumbercules> and it's written in C - BGFX is written in C++ and has several dependencies including it's own stdlib, and then it wraps the C++ API with a C99 API |
02:40:12 | FromDiscord | <Gumbercules> it's very easy to compile and integrate with a project would be the major upside |
02:40:26 | FromDiscord | <Gumbercules> it's also extremely easy to grok the code when there's no jumping around between header and source files |
02:40:48 | FromDiscord | <Gumbercules> Sean Barret popularized the concept with the `stb` libraries he created, like `stb-image` |
02:41:12 | FromDiscord | <Gumbercules> https://floooh.github.io/sokol-html5/index.html - are all samples made with `Sokol` |
02:41:59 | arkanoid | ok, so "single file library" seems an umbrella term used around C/C++ meaning: less but easier to manage is better than more |
02:42:34 | FromDiscord | <Gumbercules> yeah, generally it's going to be much easier to stick a single header file into a Nim application than one that utilizes a build system like CMake or Premake |
02:43:15 | FromDiscord | <Gumbercules> you can just use the `{.compile.}` and `{.passC.}` pragmas |
02:43:47 | arkanoid | Gumbercules, sure. I've been using futhark so far to get C stuff into nim (or at least to create the v0.1 of the bridge) |
02:44:10 | arkanoid | so, can I use "sokol X" as a generic search term for this kind of stuff? |
02:44:11 | FromDiscord | <Gumbercules> for instance - https://github.com/floooh/sokol-nim/blob/master/src/sokol/gfx.nim#L1211-L1212 - is how the author of sokol compiles `sokol_gfx.h` for the Nim bindings they authored |
02:44:29 | FromDiscord | <Gumbercules> In reply to @arkanoid "so, can I use": single header libraries is probably a better term |
02:44:45 | FromDiscord | <Gumbercules> I use quite a few C libraries in my code and have also done quite a bit of C++ interop with Nim, so if you ever have questions, feel free to ask! |
02:45:09 | FromDiscord | <Gumbercules> https://github.com/Tail-Wag-Games/frag/tree/master/thirdparty |
02:48:29 | arkanoid | thanks! I used to do games, but just unity + internal C#/js scripting. Was fun, but I skipped the system-level stuff spending my time there |
02:49:07 | arkanoid | I'm now recoving some of it thanks to nim. It's a gentler approach to the C/C++ world |
02:54:24 | FromDiscord | <Gumbercules> In reply to @arkanoid "I'm now recoving some": it's a very nice bridge to it too - I definitely credit a lot of my learning through Nim with being able to break into the industry and start working on games / game engines |
02:54:47 | FromDiscord | <Gumbercules> although I did do a lot of Unity and Unreal work as well, custom engine stuff was much rarer |
02:54:49 | FromDiscord | <Gumbercules> (edit) "rarer" => "rareer" |
02:54:52 | FromDiscord | <Gumbercules> (edit) "rareer" => "rarer" |
02:55:39 | arkanoid | why strformat `&` does not work in templates? |
02:56:02 | arkanoid | I'm forced to do all the concat manually if I wrap some &"{foo}" code in a template |
02:56:19 | FromDiscord | <Rika> Because templates mangle/sanitise their variable names |
02:56:30 | FromDiscord | <Rika> Which makes them not match the names in a string |
02:56:36 | FromDiscord | <Rika> (edit) "a" => "the" |
02:56:44 | arkanoid | but foo is a local variable of the template |
02:56:50 | arkanoid | not a parameter |
02:57:22 | arkanoid | thanks for the explanation, I'll concat manually |
02:57:50 | FromDiscord | <Elegantbeef> And it's not named `foo` at the end |
02:57:55 | FromDiscord | <Elegantbeef> it's `foo'gensymSomeNumberHere` |
03:19:37 | FromDiscord | <Rika> In reply to @arkanoid "but foo is a": Templates do it for both |
03:20:44 | arkanoid | got it, makes a lot of sense actually. My head still consider whatever comes with stdlib as something with supermagical powers |
03:21:00 | arkanoid | maybe is {.magic.} pragma that brings this to my head |
03:22:06 | FromDiscord | <Rika> you can disable it by putting {.inject.} on the variable iirc |
03:30:49 | * | rockcavera quit (Remote host closed the connection) |
03:40:56 | FromDiscord | <jtv> That works on a single variable, and {.dirty.} being added to the template will do it for all variables. |
03:44:18 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4lTg |
03:49:30 | FromDiscord | <Rika> `newSeq[char](1024)` -> `newString(1024)`â”`msg[0].addr` -> `msg.cstring`â”? im not too familiar anymore |
03:49:54 | FromDiscord | <Elegantbeef> `cstring` on a `string` it's not any safer it's just more explicit |
04:03:08 | FromDiscord | <Rika> Yes sure it isnât |
04:05:35 | * | azimut quit (Remote host closed the connection) |
04:06:30 | * | azimut joined #nim |
04:07:16 | FromDiscord | <ringabout> `cast[cstring]` is probably the only way. |
04:09:53 | FromDiscord | <ringabout> sent a code paste, see https://play.nim-lang.org/#ix=4lTm |
04:10:12 | FromDiscord | <ringabout> (edit) "https://play.nim-lang.org/#ix=4lTo" => "https://play.nim-lang.org/#ix=4lTn" |
04:36:38 | FromDiscord | <sOkam!> yeah newString and cstring fixed the warning |
04:36:42 | FromDiscord | <sOkam!> tyty |
04:49:47 | * | azimut_ joined #nim |
04:49:55 | * | azimut quit (Quit: ZNC - https://znc.in) |
04:53:28 | * | arkurious quit (Quit: Leaving) |
05:31:39 | * | rockcavera joined #nim |
06:14:10 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4lTD |
06:15:02 | FromDiscord | <ajusa> What do folks prefer for writing unit tests? std/unittest, unittest2, balls, asserts |
06:18:17 | FromDiscord | <pyolyokh> balls? std/unittest has a reasonable interface, but it's a little bit too magical which causes problems occasionally, like reporting warnings from the guts of unittest.nim instead of your code. unittest2 is a value-added fork of unittest, so no difference in interface. asserts don't let you see multiple failures, which might be a more useful clue to the problem than the first failure.â”I'm using std/unittest for now but I'd prefer go-st |
06:18:30 | FromDiscord | <Rika> Balls is a 3rd party library |
06:19:12 | FromDiscord | <Elegantbeef> std/unittest is sufficient for most basic code ime, but yea i'd go for balls if i had anything more elaborate |
06:19:14 | FromDiscord | <pyolyokh> since it's not `nimble search`, it's disruptek right? ... yep |
06:19:21 | FromDiscord | <Elegantbeef> Yes |
06:20:08 | FromDiscord | <pyolyokh> balls looks like it'd have my same irritations with std/unittest |
06:20:27 | FromDiscord | <ajusa> looks like balls is threaded as well? but it seems like it runs test files in parallel, rather than the units in the test |
06:26:11 | FromDiscord | <leorize> balls try not to cause warnings from internal stuff, it's pretty good tbh |
06:27:58 | FromDiscord | <leorize> the thing was originally made to test cps, which does require that it don't mess with line information so we can track down cps bugs easier. And also there's a very large incentive for it to not cause issues \:p |
06:28:26 | FromDiscord | <ajusa> seems like it is still getting updated as well - I'll try it out |
06:38:17 | * | azimut_ quit (Ping timeout: 255 seconds) |
06:49:27 | * | ltriant quit (Ping timeout: 255 seconds) |
07:15:22 | * | NimBot joined #nim |
07:15:28 | * | FromDiscord joined #nim |
07:15:50 | * | arkanoid joined #nim |
07:21:50 | * | nisstyre joined #nim |
07:32:05 | arkanoid | I have a Tensor of shape [7,100,100], I want to select an element on first dimension and get a [1,100,100] back (or just [100,100]). According to https://mratsim.github.io/Arraymancer/tuto.slicing.html it should be "myTensor[0,_,_]" but this returns a single element to me |
07:34:03 | arkanoid | also [0,_.._,_.._] returns one element |
07:34:37 | arkanoid | also [0,0.._,0.._] returns one element |
07:35:25 | arkanoid | also [0,0..^1,0..^1] returns one element |
07:42:26 | arkanoid | I give up, not sure what's wrong, but also echoing the tensor locks the process |
08:05:50 | FromDiscord | <michaelb.eth> sent a code paste, see https://play.nim-lang.org/#ix=4lTT |
08:06:35 | FromDiscord | <michaelb.eth> (edit) "https://play.nim-lang.org/#ix=4lTT" => "https://play.nim-lang.org/#ix=4lTU" |
08:07:08 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4lTV |
08:07:43 | FromDiscord | <Elegantbeef> `1..0` is an empty range which explains `@[]` |
08:07:57 | FromDiscord | <Elegantbeef> `2..0` is also empty, so should probably return `@[]` aswell |
08:08:58 | FromDiscord | <michaelb.eth> sure, just noting it's a source of confusion, doesn't bite you until it bites you, but when it does it can be maddening |
08:09:58 | FromDiscord | <Elegantbeef> Hey i was just explaining what's going on |
08:11:48 | FromDiscord | <Ntsékees> sent a code paste, see https://play.nim-lang.org/#ix=4lTW |
08:11:54 | FromDiscord | <Elegantbeef> `: seq` |
08:12:00 | FromDiscord | <Elegantbeef> Remove that, be merry |
08:12:11 | FromDiscord | <Elegantbeef> It's a `seq[(string, string)]` |
08:12:21 | FromDiscord | <Ntsékees> Okay, thanks |
08:12:35 | FromDiscord | <Ntsékees> Still, it's not what the compiler should output |
08:12:39 | FromDiscord | <Ntsékees> it crashes on that code |
08:12:44 | FromDiscord | <Elegantbeef> Of course not it's a bug |
08:13:30 | FromDiscord | <Elegantbeef> Internal errors are not meant to be user facing errors |
08:19:20 | * | azimut joined #nim |
08:32:34 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lTY |
08:33:26 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4lTY" => "https://play.nim-lang.org/#ix=4lTZ" |
09:04:33 | * | ltriant joined #nim |
09:15:47 | * | azimut quit (Ping timeout: 255 seconds) |
09:20:53 | * | kenran joined #nim |
09:20:53 | * | kenran quit (Remote host closed the connection) |
09:26:59 | FromDiscord | <Ntsékees> sent a long message, see http://ix.io/4lU6 |
09:27:20 | FromDiscord | <NtsĂ©kees> The Nim documentation mentions a type âAnyâ |
09:27:54 | FromDiscord | <Rika> use object variants |
09:28:05 | FromDiscord | <Rika> https://nim-lang.org/docs/manual.html#types-object-variants |
09:35:28 | FromDiscord | <Ntsékees> I'll look into these, thanks for the pointer. |
09:38:51 | FromDiscord | <Phil> In reply to @NtsĂ©kees "I'll look into these,": An object variant (also called union type? I'm not the best at terminology) is basically an object that based on an enum-field can have either a set of fields belonging to enum value A, B, or C.â”You can instantiate one fairly easily, you do have to deal everywhere that variant occurs though, that it might either be one or the other |
09:39:30 | FromDiscord | <Phil> (edit) "C.â”You" => "C (or however many enum options you got).â”You" |
09:40:30 | FromDiscord | <Phil> JSON parsing and XML/HTML parsing is implemented using object variants in case you're curious |
09:40:54 | FromDiscord | <Elegantbeef> > belonging to any ordinalâ”FTFY đ |
09:41:50 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4lU8 |
09:43:14 | FromDiscord | <Phil> So your second case matches anything where kind is a character between b and z? |
09:43:21 | FromDiscord | <Elegantbeef> Yes |
09:43:31 | FromDiscord | <Phil> Not sure if cursed but it kinda looks like it |
09:43:56 | FromDiscord | <Elegantbeef> Not with char but the compiler uses it for PNodes |
09:44:10 | FromDiscord | <Phil> Well I guess its better than having to redefine the same stuff when you want to match the same thing multiple times |
09:44:30 | FromDiscord | <Phil> (edit) "match" => "have" | "thing multiple times" => "fields for matching different things" |
09:44:44 | FromDiscord | <Elegantbeef> It's contrived in this case, but in some cases it's much easier to type than explicitly all branch kinds |
09:45:22 | FromDiscord | <Elegantbeef> Like imagine that was a enum, why would i write `b, c, ...` instead of `b..z` |
09:46:21 | FromDiscord | <Elegantbeef> your mileage may vary |
10:35:19 | FromDiscord | <Ntsékees> It it possible to access a variable index in a tuple? |
10:35:33 | FromDiscord | <Ntsékees> `sometuple[i]` triggers an error |
10:35:48 | FromDiscord | <NtsĂ©kees> âcannot evaluate at compile timeâ |
10:36:29 | FromDiscord | <Ntsékees> Presumably only literal indexes are allowed? |
10:38:02 | FromDiscord | <hotdog> @Ntsékees have a look at https://nim-lang.org/docs/iterators.html#fieldPairs.i%2CS%2CT |
10:38:16 | FromDiscord | <enthus1ast> sent a code paste, see https://paste.rs/pXq |
10:39:19 | FromDiscord | <enthus1ast> indicates that you use this in a compile time context, and some variable cannot be evaluated on compile timeâ”(@NtsĂ©kees) |
10:40:04 | FromDiscord | <hotdog> sent a code paste, see https://play.nim-lang.org/#ix=4lUp |
10:43:39 | FromDiscord | <Phil> In reply to @NtsĂ©kees "`sometuple[i]` triggers an error": With a code example we could tell you what's happening there đ |
10:45:13 | FromDiscord | <Ntsékees> https://media.discordapp.net/attachments/371759389889003532/1066669861075439696/image.png |
10:45:43 | FromDiscord | <Ntsékees> Maybe let is in fault? |
10:45:56 | FromDiscord | <Ntsékees> Nah, var does the same |
10:47:41 | FromDiscord | <Rika> the "variable" has to be evaluated on compile time e.g. neither let nor var |
10:47:54 | FromDiscord | <Rika> const is okay |
10:55:56 | FromDiscord | <Phil> Ah, do tuple indices require a compile-time index to ensure that no invalid index is used? |
10:55:58 | FromDiscord | <NtsĂ©kees> I had thought I could use a tuple of polymorphic tuples instead of a list of such tuples for avoiding the issue of type heterogeneity.â”I think what I'll do is instead of having callbacks in the second tuple slot, having rather strings of the form `"\ecallback_name"`, with the Escape character marking a callback function, and then using a map âšcallback_name ⊠callbackâ© in the site where the regexps are applied. |
10:57:10 | FromDiscord | <Rika> In reply to @Isofruit "Ah, do tuple indices": to ensure that the type cannot suddenly change |
10:57:51 | FromDiscord | <Phil> In reply to @NtsĂ©kees "I had thought I": Note that functions also need to have the same signature, so if function a) accepts type A and function b) accepts type B then you'll face the same type issues, because you can't have a seq of procs with different signatures.â”Unless you start storing them as pointers, at which point you'll need to cast them into their proper proc form later, which is a) dirty, b) unsafe and c) looks ugly |
10:58:10 | FromDiscord | <Phil> (edit) "signature," => "signature if you want to store them in a seq," |
10:58:40 | FromDiscord | <Ntsékees> They have the same signature, as they are all callback for the same function (`replace()` from the `nre` lib) |
10:58:52 | FromDiscord | <Ntsékees> (edit) "callback" => "callbacks" |
10:59:05 | FromDiscord | <Phil> Are they not going to accept different types as parameters? |
10:59:26 | FromDiscord | <Ntsékees> nope, only strings (since it's a regexp function) |
11:00:20 | FromDiscord | <Phil> AH, so the second element is either a string of a proc that returns a string? |
11:00:27 | FromDiscord | <Ntsékees> yep |
11:00:51 | FromDiscord | <Phil> And you can't call the proc beforehand to get the string? |
11:04:25 | FromDiscord | <NtsĂ©kees> not without dropping the whole scheme of âthe regexps to be applied to the string are stored in a sequence of tuples, and then later on they are applied in order in a loopâ |
11:05:08 | FromDiscord | <Ntsékees> which was meant to reduce repetitive code in the original Python version |
11:06:04 | FromDiscord | <Phil> Ohhhh so the function is basically an earlier iteration of "apply the regexp from this tuple to the source string" and that output is then used to apply the next regex ? |
11:06:22 | FromDiscord | <Ntsékees> exactly |
11:07:00 | FromDiscord | <Phil> Why not store a seq of regexes and write a proc that eats a string and that seq of regexes and applies it one by one? |
11:09:21 | FromDiscord | <Phil> But eh, might be more a thing if you want to refactor later down the line.â”For now you're right that you can either just generally make it tuples of `(regex, callback)` and the moments where you want it to be just a string you just define your callback as `() => "myString"` |
11:09:33 | FromDiscord | <Phil> (edit) removed "either" |
11:09:39 | FromDiscord | <Ntsékees> That's more or less what I'm doing but the sequences contains not only the input regexps, but also the output expression, which may a replacement string or a callback |
11:10:48 | FromDiscord | <Phil> (For the above JS-like callback syntax btw. import std/sugar, it enables using `=>` and `->` for defining anonymous procs) |
11:26:09 | * | clemens3 left #nim (WeeChat 2.7) |
11:32:07 | FromDiscord | <NtsĂ©kees> > Error: type mismatch: gotâ”> '(string, proc (m: RegexMatch): string{.closure, noSideEffect, gcsafe, locks: 0.})' for ... but expectedâ”> '(string, proc (m: RegexMatch): string{.noSideEffect.})'â”Looks like closures are considered a different type đ |
11:35:37 | FromDiscord | <pyolyokh> name the type of the proc that you want in this structure, and cast all the procs to it that you add |
11:43:14 | FromDiscord | <Ntsékees> Even after doing a type casting, `{.closure.}` remains there and causes a mismatch error |
11:43:56 | FromDiscord | <Ntsékees> sent a code paste, see https://play.nim-lang.org/#ix=4lUE |
11:44:38 | FromDiscord | <NtsĂ©kees> I could convert the non-closure functions into closures đ€Ș |
11:46:23 | FromDiscord | <Ntsékees> (the lambda expression is a closure because it captures the `cartouche_space` variable) |
11:46:51 | FromDiscord | <Phil> Full code example please as e.g. cartouche-space is from the outside |
11:47:35 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lUG |
11:48:03 | FromDiscord | <Phil> I assume `cartouche_space` is also compile-time? |
11:50:42 | FromDiscord | <Ntsékees> sent a code paste, see https://play.nim-lang.org/#ix=4lUH |
11:50:46 | FromDiscord | <Ntsékees> Simplified code example |
11:50:47 | FromDiscord | <pyolyokh> `Calling convention mismatch: got '{.nimcall.}', but expected '{.closure.}'.`, yeah, since the calling convention is different I guess they all have to be closures |
11:50:52 | FromDiscord | <Ntsékees> the actual code is big and noisy |
11:51:08 | FromDiscord | <Ntsékees> cartouche_space is not a constant |
11:51:21 | FromDiscord | <Ntsékees> it depends on one of the input arguments of the whole program |
11:51:38 | FromDiscord | <Ntsékees> but here for the sake of the demonstration I've set it to `" "` |
11:52:16 | FromDiscord | <Ntsékees> (edit) |
11:55:58 | FromDiscord | <Rika> Just add closure pragma to that add function I donât get it |
11:56:38 | FromDiscord | <Ntsékees> hmm when I replace `const` with `var`, `.closure.` disappears from the signature; maybe I can do a type cast now⊠|
11:57:45 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lUK |
11:58:08 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4lUK" => "https://play.nim-lang.org/#ix=4lUL" |
11:58:16 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lUM |
11:58:58 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4lUL" => "https://play.nim-lang.org/#ix=4lUN" |
11:59:09 | FromDiscord | <pyolyokh> : string |
11:59:41 | FromDiscord | <pyolyokh> `type MyProc = proc(m: RegexMatch) {.closure.}` doesn't return one |
11:59:45 | FromDiscord | <Phil> Agh, pesky return types |
12:03:01 | FromDiscord | <Phil> Yeah, straight up can't mix |
12:05:22 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lUQ |
12:06:29 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lUR |
12:07:15 | * | krux02 joined #nim |
12:08:21 | FromDiscord | <Ntsékees> that seems to work |
12:08:21 | FromDiscord | <Ntsékees> sent a code paste, see https://play.nim-lang.org/#ix=4lUT |
12:08:46 | FromDiscord | <Ntsékees> by declaring the lambdas to be closure even though they aren't |
12:09:04 | FromDiscord | <Ntsékees> (edit) "closure" => "closures" |
12:09:31 | FromDiscord | <Phil> That's fine, all you're saying is "This proc has the ability to capture stuff from its environment", that's relevant for stuff like multithreading etc. where being closures may limit you, but you're not doing multithreading so you're fine |
12:14:21 | FromDiscord | <pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4lUU |
12:17:32 | FromDiscord | <Ntsékees> Rika, Phil, pyolyokh: Thank you for your support! |
12:17:44 | FromDiscord | <Ntsékees> (afk) |
12:23:35 | * | genpaku quit (Read error: Connection reset by peer) |
12:24:43 | * | genpaku joined #nim |
12:26:02 | FromDiscord | <Phil> Just opened an issue about the sqlite behaviour with the foreign_key PRAGMA with norm.â”The fact that these checks are turned off by default and need to be turned for every connection explicitly is not ok, let's see if norm can include a fix for that. |
14:56:47 | FromDiscord | <choltreppe> When I generate docs for a nimble package, I always get "src/.." in the title for each module, no matter if I run the `nim doc` command from inside the `src` folder or not. How can I get rid of the "src/" ? (without editing each .html file) |
15:13:52 | * | azimut joined #nim |
15:30:12 | * | arkurious joined #nim |
15:34:48 | * | xet7 joined #nim |
15:36:50 | * | jkl quit (Excess Flood) |
15:40:16 | * | jkl joined #nim |
15:48:38 | FromDiscord | <hortinstein> so I am getting this issue when I try to output javascript, the closest I have found to a solution was: https://forum.nim-lang.org/t/7181 if you want to reproduce...there is a gitpod of it you can open in the browser here or clone locally: https://github.com/hortinstein/enkodo https://media.discordapp.net/attachments/371759389889003532/1066746216995631255/image.png |
15:49:22 | FromDiscord | <hortinstein> i have tried tweaking the source files and it appears to be a parser bug, any ideas on workarounds and if I need to file a bug report |
15:49:44 | FromDiscord | <hortinstein> (edit) "report" => "report? Thank you!" |
16:30:27 | FromDiscord | <sOkam!> Do you guys know of an existing solution that can add license text to every file in a project, unless that file already contains it?â”I could code a tool for it, but asking in case something already exists |
16:30:37 | FromDiscord | <sOkam!> (edit) "it?â”I" => "it? I" |
16:31:03 | FromDiscord | <leorize> reuse |
16:31:30 | FromDiscord | <leorize> https://reuse.software/ |
16:36:53 | FromDiscord | <Rika> one hell of a name |
16:38:32 | FromDiscord | <chmod222> I must be getting old, I remember the TLDs being shorter than the subdomains |
16:41:21 | FromDiscord | <Hourglass [She/Her]> How can I stop this warning from showing up? `cannot prove that it's safe to initialize 'text' with the runtime value for the discriminator 'typ'` |
16:41:40 | FromDiscord | <Hourglass [She/Her]> sent a code paste, see https://paste.rs/naZ |
16:46:15 | FromDiscord | <sOkam!> In reply to @leorize "https://reuse.software/": thats really useful. tyty! |
16:46:39 | FromDiscord | <Hourglass [She/Her]> In reply to @Hourglass, When the Hour Strikes "How can I stop": Ah it's an error |
16:47:18 | FromDiscord | <abisxir> sent a long message, see http://ix.io/4lW2 |
16:47:32 | FromDiscord | <abisxir> (edit) "http://ix.io/4lW2" => "http://ix.io/4lW3" |
16:48:09 | FromDiscord | <leorize> use `of` to check the runtime type |
16:48:10 | FromDiscord | <chmod222> Give A and B a `method` that returns their typedefs so it uses dynamic dispatch |
16:48:17 | FromDiscord | <chmod222> Or that |
16:48:35 | FromDiscord | <chmod222> Probably that |
16:48:49 | FromDiscord | <leorize> `method` that returns `typedesc` won't work since `typedesc` is compile-time |
16:49:56 | FromDiscord | <abisxir> Just the type name is enough for me, I need it for some debugging. |
16:50:36 | FromDiscord | <Phil> In reply to @leorize "`method` that returns `typedesc`": You could have a field that is the typedesc string and a method dishing that string out |
16:51:06 | FromDiscord | <Phil> But at this point you're in hacktown, population: Way too many programmers |
16:51:29 | FromDiscord | <leorize> `method typeName(x: A) = "A"; method typeName(x: B) = "B"` is a thing then |
16:52:04 | FromDiscord | <Phil> Yeah, though couldn't you just write a generic method at that point? |
16:52:15 | FromDiscord | <abisxir> That is not good, as I do not know how it will extend, a new class then I get A |
16:52:18 | FromDiscord | <Hourglass [She/Her]> In reply to @Hourglass, When the Hour Strikes "This is my code": This is very irritating and I don't know how to fix that aha |
16:52:20 | FromDiscord | <Phil> Actually, I want to try this out |
16:52:51 | FromDiscord | <leorize> generics are instantiated at the spot that you use it, so that won't workâ”(@Phil) |
16:53:04 | FromDiscord | <leorize> statically speaking it's `A` where it would be used |
16:53:35 | FromDiscord | <Rika> In reply to @Hourglass, When the Hour Strikes "This is very irritating": I will say I think there isnât enough info in your description |
16:54:09 | FromDiscord | <Rika> There is no âtextâ to be seen |
16:54:33 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lW5 |
16:54:52 | FromDiscord | <jtv> const a = $(typedesc(mytype)) should work too |
16:55:15 | FromDiscord | <Rika> đ |
16:55:17 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=4lW6 |
16:55:23 | FromDiscord | <Rika> I mean R |
16:55:23 | FromDiscord | <abisxir> sent a code paste, see https://play.nim-lang.org/#ix=4lW7 |
16:55:26 | FromDiscord | <Rika> Yes |
16:55:31 | FromDiscord | <Phil> Ah, shit... hmm |
16:55:46 | FromDiscord | <Rika> Thatâs what putting it in the sequence effectively does |
16:56:10 | FromDiscord | <Phil> Wait, how is `let x: R = A()` that invalid nim |
16:56:31 | FromDiscord | <leorize> inheritanceâ”(@Phil) |
16:56:32 | FromDiscord | <abisxir> No that is valid nim, but it will write R |
16:56:41 | FromDiscord | <Phil> I'm currently running this code through the compiler and it bombs, I'd have anticipated that it compiles |
16:57:05 | FromDiscord | <Phil> on devel |
16:57:06 | FromDiscord | <leorize> and you forgot `ref` |
16:57:46 | FromDiscord | <Phil> Yeah it needs ref to make it compile, hmm |
17:00:27 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lWa |
17:01:36 | FromDiscord | <Phil> Time to read up more on method and how nim does runtime dispatch, this smells like I implemented sth wrong |
17:02:06 | FromDiscord | <Rika> In reply to @Isofruit "Time to read up": Probably missing base method for R |
17:02:26 | FromDiscord | <Phil> Ah, just needs a base for R |
17:02:26 | FromDiscord | <Phil> yeah |
17:02:28 | FromDiscord | <leorize> you didn't make a base method |
17:02:32 | FromDiscord | <chmod222> That one works if you give it a base method |
17:02:40 | FromDiscord | <Phil> Hah, only second ! |
17:04:37 | FromDiscord | <Rika> Lol |
17:06:25 | arkanoid | to get C pointer to "var foo = array[2, uint32]", is it "cast[ptr uint32](foo[0].addr)" ? |
17:07:20 | FromDiscord | <leorize> yep, that's the most reliable method |
17:08:14 | FromDiscord | <Hourglass [She/Her]> In reply to @Rika "I will say I": Ah i sent the wrong proc, but I fixed it by using a case statement instead now |
17:09:14 | arkanoid | thanks. Then I don't know why it's not working. I have a UVec2 from https://github.com/treeform/vmath/blob/master/src/vmath.nim, that really is an array[2, uint32], I'm trying to run "glUniform2uiv(location, 2, cast[ptr GLuint](value[0].addr))" from https://github.com/nim-lang/opengl/blob/26c3e1e107d68e84b785f0143a60f87040dceae9/src/opengl/private/procs.nim, but receiving "OpenGL error: invalid |
17:09:16 | arkanoid | operation [GLerror]" |
17:10:30 | FromDiscord | <Rika> In reply to @leorize "yep, that's the most": ? Wouldnât it have been better to do foo[0].addr even if theyâre equivalent for this data type |
17:22:45 | arkanoid | found the issue https://github.com/treeform/vmath#vector-and-matrix-representation-and-benchmarks |
17:26:34 | FromDiscord | <chmod222> Just make sure foo.len \> 0 |
17:26:35 | FromDiscord | <chmod222> If it is a seq |
17:26:36 | FromDiscord | <chmod222> Otherwise foo[0].addr will segfault |
17:26:36 | FromDiscord | <chmod222> Shit, I really should learn to read before typing |
17:27:57 | arkanoid | is it possible to print symbol all known aliases of a type? |
17:39:56 | arkanoid | is the any difference between unsafeAddr and addr ? |
17:40:09 | FromDiscord | <chmod222> In Nim 2.0, no |
17:40:16 | arkanoid | in 1.6.10? |
17:40:22 | FromDiscord | <chmod222> In Nim 1.6, unsafeAddr works on `let` vars, addr does not |
17:40:54 | arkanoid | makes sense! thanks |
17:41:05 | arkanoid | so I've a var here, and both works, so I can't see the difference |
17:42:40 | FromDiscord | <chmod222> Yep, exactly |
17:43:03 | FromDiscord | <chmod222> Make it a `let` and `addr` will raise an error for now |
17:43:16 | FromDiscord | <Ntsékees> Is there an available UTF8 slice function or should I write mine? |
17:44:00 | FromDiscord | <Ntsékees> i.e. an equivalent to the byte string `s[i..j]` expressions |
17:44:04 | Amun-Ra | unsafeAddr is "unsafe" because you need to make sure C function that takes it as an argument not to ever write to it |
17:45:42 | FromDiscord | <jtv> You mean one that slices on codepoint instead of by byte, right? You have to scan all the way up to the start of the slice anyway, so thereâs not much advantage over just using toRunrs or runes() |
17:46:11 | FromDiscord | <sOkam!> When would someone prefer strscans over parseutils?â”Don't they do exactly the same thing, in essence? Or am i misunderstanding something đ€ â”_Usecase is parsing a game level file format_ |
17:48:41 | FromDiscord | <jtv> The fact that UTF strings arenât fixed size means that you lose the constant time indexing, you have to scan from the front (or back if youâve already counted codepoints) |
17:49:08 | Amun-Ra | strscans is closer to regex |
17:50:06 | FromDiscord | <sOkam!> what does that mean? |
17:51:55 | FromDiscord | <jtv> I was answering @Ntsékees |
17:52:09 | FromDiscord | <jtv> I donât know anything about strscans |
17:52:40 | Zevv | Oskam!: check npeg. but i'm biased. |
17:52:53 | Amun-Ra | I also use parseutils; strscans is "higher" level module |
17:53:42 | FromDiscord | <jtv> I generally just write my own parsing; itâs usually clearer, faster and less error prone than anything that looks like line noise đ |
17:55:23 | * | rockcavera joined #nim |
17:57:31 | FromDiscord | <sOkam!> @zevv gold https://media.discordapp.net/attachments/371759389889003532/1066778650369855488/image.png |
17:58:39 | FromDiscord | <sOkam!> In reply to @Amun-Ra "I also use parseutils;": higher level meaning, in this case? |
17:59:01 | FromDiscord | <sOkam!> (edit) "In reply to @Amun-Ra "I also use parseutils;": ... highermean," added "what does" | "meaning," => "mean," |
18:00:44 | FromDiscord | <jtv> In reply to @sOkam! "<@693957322375954512> gold": Thatâs because friends peer pressure each other into bad behavior đ |
18:01:49 | FromDiscord | <sOkam!> KEWK |
18:01:54 | FromDiscord | <sOkam!> (edit) "KEWK" => "KEKW" |
18:03:08 | FromDiscord | <Phil> In reply to @jtv "Thatâs because friends peer": All I'm pressuring people into is making their packages that I use nim 2.0 compatible! I resent that statement ! đ |
18:11:15 | Amun-Ra | sOkam!: as in 'parsing capabilities' |
18:26:28 | FromDiscord | <sOkam!> In reply to @Amun-Ra "sOkam!: as in 'parsing": so strscans is gonna be simpler to write, because its higher level? |
19:22:04 | FromDiscord | <hotdog> In reply to @hortinstein "so I am getting": @hortinstein it doesn't work because `serEncObj` is a generic. Ideally jsffi would give you a nicer error message so you could file an issue about that |
19:40:54 | * | azimut quit (Remote host closed the connection) |
19:43:18 | FromDiscord | <hortinstein> In reply to @hotdog "<@169298166506586113> it doesn't work": awesome! Thank you i just fixed it! |
19:51:00 | FromDiscord | <hotdog> In reply to @hortinstein "awesome! Thank you": Glad to hear it đ |
19:58:00 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4lX1 |
19:58:02 | FromDiscord | <Phil> Is this another issue along the lines of "generics don't actually exist"? |
19:58:08 | FromDiscord | <Phil> (edit) "Is" => "Was" |
19:58:37 | FromDiscord | <Phil> Can't you just do file.lines.toSeq? |
19:58:55 | FromDiscord | <Phil> Lines should be an iteratable and toSeq should work on those |
19:59:13 | FromDiscord | <sOkam!> yea lines is an iterable. didn't know toseq converts iterators, ty |
20:32:58 | FromDiscord | <Ntsékees> Is it possible to test the value of a generic type parameter within the body of a type-generic procedure? |
20:34:13 | FromDiscord | <amadan> sent a code paste, see https://play.nim-lang.org/#ix=4lXe |
20:34:44 | FromDiscord | <Ntsékees> Ah; I had tried with `if` but it didn't work. Now I remember that `when` is comparable to C `#ifdef`, somewhat. |
20:34:58 | FromDiscord | <Ntsékees> (edit) "`#ifdef`," => "`#if`," |
20:35:16 | FromDiscord | <Ntsékees> Thanks. |
20:54:55 | FromDiscord | <pjhenning> sent a code paste, see https://play.nim-lang.org/#ix=4lXj |
20:55:16 | FromDiscord | <pjhenning> (edit) |
20:55:46 | FromDiscord | <pjhenning> (edit) "https://play.nim-lang.org/#ix=4lXj" => "https://play.nim-lang.org/#ix=4lXk" |
20:56:42 | FromDiscord | <pjhenning> Whoops whould be `importcpp` instead of `importc` |
21:06:15 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4lXl |
21:08:55 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4lXo |
21:28:57 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4lXt |
21:30:40 | FromDiscord | <sOkam!> (edit) "https://play.nim-lang.org/#ix=4lXt" => "https://play.nim-lang.org/#ix=4lXu" |
21:32:43 | FromDiscord | <amadan> Basically means you are calling a C function in some code that runs at cmopile time.â”Do you call `getAppFilename()` or `getAppDir()` in some compile time code anywhere? |
21:33:29 | FromDiscord | <sOkam!> oh, yeah i am. let me see if it fixes it |
21:34:01 | FromDiscord | <sOkam!> oh, good catch. that was it, ty |
21:34:16 | FromDiscord | <sOkam!> well, a stack trace would have been nice at least đ |
22:10:40 | FromDiscord | <Ntsékees> sent a code paste, see https://play.nim-lang.org/#ix=4lXC |
22:11:25 | FromDiscord | <Ntsékees> Unfortunately with these it's a bit tedious to find which part of the code is responsible |
22:11:50 | FromDiscord | <Ntsékees> (the last time it happened it was due to an incorrect type declaration) |
22:31:44 | FromDiscord | <Phil> I mean, as per the usual without code or anything it's a bit difficult to conclude anything ^^' |
22:31:55 | FromDiscord | <Phil> (edit) "anything" => "any kind of minimal example" |
22:45:23 | FromDiscord | <lithiumfrost> sent a code paste, see https://play.nim-lang.org/#ix=4lXM |
22:45:52 | FromDiscord | <lithiumfrost> https://learn.microsoft.com/en-us/windows/win32/api/wincred/nf-wincred-credenumeratea |
22:47:06 | FromDiscord | <Ntsékees> sent a code paste, see https://play.nim-lang.org/#ix=4lXN |
22:47:58 | FromDiscord | <Ntsékees> sent a code paste, see https://play.nim-lang.org/#ix=4lXO |
22:48:11 | FromDiscord | <Ntsékees> It's the last `else:` with the `raise` statement that causes the crash |
22:48:24 | FromDiscord | <Ntsékees> it's odd, because it did work at one point earlier |
22:48:39 | FromDiscord | <Ntsékees> (but I've probably made modifications in the meantime) |
22:49:28 | FromDiscord | <Ntsékees> since the crash involves macros, it might be due to `fmt` |
22:51:13 | FromDiscord | <Ntsékees> It's `$T`. Yet I seem to remember that it worked at one point. |
22:51:30 | FromDiscord | <Ntsékees> (even though I wasn't sure it could work) |
22:51:56 | FromDiscord | <Elegantbeef> Why an exception |
22:52:35 | FromDiscord | <Elegantbeef> This should be `{.error: fmt"your string here".}` |
22:53:23 | FromDiscord | <Elegantbeef> But even then why not `T: seq[Rune] or string` |
22:53:26 | FromDiscord | <Ntsékees> OK. (I'm new to Nim.) |
22:53:43 | FromDiscord | <Elegantbeef> There you go |
22:53:44 | FromDiscord | <Ntsékees> In reply to @Elegantbeef "But even then why": I do suspect that this should have been the normal way to proceed |
22:54:27 | FromDiscord | <Ntsékees> I used an exception as a hasty measure |
22:55:10 | FromDiscord | <Elegantbeef> Yea i wasnt really grilling you, just bad lead up to an explanation |
23:00:48 | * | anddam joined #nim |
23:03:39 | * | rockcavera quit (Ping timeout: 260 seconds) |
23:03:49 | anddam | howdy |
23:05:36 | FromDiscord | <4zv4l> is it me or the example code in https://github.com/krisppurg/dimscordâ”doesn't work ? |
23:06:17 | FromDiscord | <4zv4l> I get this |
23:06:19 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4lXU |
23:06:54 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4lXV |
23:07:00 | FromDiscord | <4zv4l> I didn't change anything except the token |
23:09:17 | FromDiscord | <4zv4l> my bad, apparently I have to change something on the bot dashboard |
23:11:58 | FromDiscord | <Phil> In reply to @NtsĂ©kees "OK. (I'm new to": Don't worry, I only learned of that one roughly 12 months after starting to learn the language, so with that particular feature you're ahead of the curve đ |
23:13:37 | FromDiscord | <Phil> As a sidenote, I have decided I'm not sure I really like the fact that the converter feature exists |
23:16:04 | FromDiscord | <sOkam!> In reply to @Isofruit "As a sidenote, I": how so? because of the abstraction? |
23:16:17 | FromDiscord | <Phil> Code clarity is king |
23:16:35 | FromDiscord | <Phil> If there is a converter that implicitly gets called, I can no longer with certainty quickly say what code has run when |
23:16:39 | FromDiscord | <Phil> Only after some detective work |
23:17:09 | FromDiscord | <sOkam!> if you don't know the project, agreed. or if you spam converters all over |
23:17:26 | FromDiscord | <sOkam!> but for a few sparse things, they are really helpful |
23:17:53 | FromDiscord | <Elegantbeef> Converters are lovely if used properly |
23:17:58 | FromDiscord | <sOkam!> using an enum as an int natively iwthout having to cast it back to ord, for example, is one of those for me |
23:18:28 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4lXX |
23:18:30 | FromDiscord | <Elegantbeef> Boom we have a 'weak distinct' |
23:18:45 | FromDiscord | <sOkam!> whats lent? |
23:18:50 | FromDiscord | <Elegantbeef> But it really depends on what you're doing, some people misuse them and it ruins the sanctity of type safety |
23:18:52 | FromDiscord | <Elegantbeef> A borrow |
23:18:57 | FromDiscord | <Phil> For the most part I just haven't seen the usecase.â”Or rather where there would be a usecase, I've decided to prefer the approach norm went with:â”Having a dedicated proc name.â”In Snorlogue those are for example "toFormField" and "toModelValue" |
23:19:06 | FromDiscord | <sOkam!> i mean, what is a borrow? same Q |
23:19:10 | FromDiscord | <sOkam!> đ |
23:19:20 | FromDiscord | <Elegantbeef> It reuses the memory without copying if possible |
23:19:30 | FromDiscord | <sOkam!> so like a ref of sorts? |
23:19:42 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4lXY |
23:19:56 | FromDiscord | <Elegantbeef> It's a pointer to the memory that is ensured it's not mutated, and is copied if required |
23:20:49 | FromDiscord | <Elegantbeef> Borrowing is memory that is safely reused, ensuring the pointer does not dangle or is not mutate(unless we look at view types 'var T' semantics) |
23:22:08 | FromDiscord | <sOkam!> In reply to @Isofruit "For the most part": for me, personally, if thats evidently going to be the case all the time, then calling it manualy all the time becomes a pain |
23:22:33 | FromDiscord | <sOkam!> but i hate long verbose code, so it might be more helpful if you are fine with that, or even seek it |
23:22:55 | FromDiscord | <Phil> In reply to @sOkam! "for me, personally, if": I'd rather call it manually and see it explicitly in the code then have to remember and have to think that this happens |
23:23:14 | FromDiscord | <sOkam!> if you have to remember it, then the usecase is not appropiate |
23:23:32 | FromDiscord | <sOkam!> its for those situations (imo at least) where the behavior is extremely obvious |
23:23:35 | FromDiscord | <Phil> I want my brain to need to supply as little additional information as possible to understand the code in front of me |
23:23:52 | FromDiscord | <Phil> And that excludes pretty much all implicit call stuff |
23:24:13 | FromDiscord | <sOkam!> yeah same. but sometimes is obvious and used a lot, so explicit becomes a pain to have to write all the time |
23:24:14 | FromDiscord | <Phil> Same reason why I'm not a gigantic fan of Jester's DSL for setting up routes and stuff |
23:24:43 | FromDiscord | <sOkam!> if its not obvious, then its not a task for a converter |
23:25:41 | FromDiscord | <Phil> Eh, I'll take the writing pain, I've had to deal with worse anyway and the important part in the end is reading, not writing, so I tend to optimize for that. |
23:26:20 | FromDiscord | <sOkam!> write/read, same thing. but i see your point |
23:26:59 | FromDiscord | <Phil> And I'm not sure I could see any non-obvious thing here for useage.â”In the end you'll see that you're passing type A to a proc that eats type B and you forgot or are unaware that there's a converter for that imported from a different module |
23:27:22 | FromDiscord | <sOkam!> for me reading `verboseThingName.NameOfTheThing.ThingToUse` its just as painful to read (or more) than it is to write. Even if autocompletion can make it bearable |
23:27:37 | FromDiscord | <Elegantbeef> I think type safety is very important and misusing converters can break that down easil |
23:27:41 | FromDiscord | <Elegantbeef> easily even |
23:28:15 | FromDiscord | <sOkam!> yeah, which is why i mentioned its helpful for a few cases where its hella obvious and easy to track. if its not obvious, its not for a converter |
23:28:40 | FromDiscord | <sOkam!> (imo, ofc) |
23:28:59 | FromDiscord | <Phil> In reply to @sOkam! "for me reading `verboseThingName.NameOfTheThing.Thi": Yes-ish, unless I'm writing a sequtils block that beef will dislike me for because it copies a lot, I'd not write that either, I'd split it over 2 lines |
23:29:36 | FromDiscord | <sOkam!> oh, you cannot split that example. i was referring to the vulkan style of naming things |
23:29:37 | FromDiscord | <Phil> Because if you're having names that long then you need more shorter names |
23:29:47 | FromDiscord | <Elegantbeef> The anti-javaâ”(@Phil) |
23:30:02 | FromDiscord | <sOkam!> where the enum and the component both contain what the thing itself is, so its duplicated everywwhere |
23:30:33 | FromDiscord | <Phil> In reply to @Elegantbeef "The anti-java (<@180601887916163073>)": Look, java gets a bad rep that is totally unfounded. It's not just a bad language. It also has a borderline insane community ! |
23:30:57 | FromDiscord | <Phil> The latter is far more egregious to me than java as a language tbh |
23:31:49 | FromDiscord | <Phil> Though that one is also quite annoying to deal with, but not as annoying as "Custom-Abstraction-Layer 526 just for parsing JSON and inserting it into a Mongo database" |
23:33:59 | FromDiscord | <Phil> In reply to @sOkam! "where the enum and": I don't think I understand that one, if the first 2 lines are just an enum, then couldn't you shorten that with `let myoption = verboseThingName.NameOfTheThing`? |
23:34:12 | FromDiscord | <Phil> Basically assign the explicit enum into a variable? |
23:35:45 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lY6 |
23:36:22 | FromDiscord | <Elegantbeef> Ah nice you occasionally use type annotations, then also dont |
23:36:48 | FromDiscord | <Phil> I mean, in the upper example I can see what the type is, it's on the right hand side |
23:36:53 | FromDiscord | <sa-code> Hey y'all |
23:37:04 | FromDiscord | <Phil> In the lower lines I can't infer that without knowing what getPathParams returns |
23:37:16 | FromDiscord | <Phil> Cheers |
23:37:36 | FromDiscord | <Phil> (edit) "returns" => "returns, and that would mean looking it up, which I dislike" |
23:37:48 | FromDiscord | <Phil> I'm not perfect at enforcing that on myself either, but I try |
23:40:24 | FromDiscord | <sOkam!> In reply to @Isofruit "I don't think I": in this case it could be something acting on a pure enumâ”the thing to notice is how everything is duplicated, and in reality it should be `verbose.thing.use` |
23:42:17 | FromDiscord | <sOkam!> verbose code tends to be the opposite of that, and explicit verbose name everything, even if to name `One` you have to say `YouKnowThatNumberThatIsFirstAndWeAlwaysCallOne`â”Overexagerating a crap ton, but i was referring to that in a more normal person way than this silly+harsh example đ |
23:43:22 | FromDiscord | <sOkam!> if its obvious, and its always a number, and its always called one, just saying `One` should be enoughâ”which is why i was saying that sometimes converters can be good, in that they make the obvious obvious |
23:43:54 | FromDiscord | <sa-code> I'm looking at the aws sdk for cpp - I've heard interop it easy to do but I've never done it before. How would I call this code from nim? https://docs.aws.amazon.com/sdk-for-cpp/v1/developer-guide/examples-s3-objects.html |
23:44:49 | FromDiscord | <Elegantbeef> You'd use the `{.importcpp.}` pragma to import the types and procedures you need |
23:45:05 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-importcpp-pragma |
23:47:36 | FromDiscord | <demotomohiro> In reply to @sa-code "I'm looking at the": If you want to learn how to call C++ functions from Nim: https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-importcpp-pragma |
23:47:59 | FromDiscord | <sa-code> In reply to @Elegantbeef "You'd use the `{.importcpp.}`": Thanks, but the top of that example says `# Horrible example of how to interface with a C++ engine ... ;-)` đ |
23:49:35 | FromDiscord | <sOkam!> @sa-code just a friendly reminder that "easy" in this interoperability context will depend very heavily on your background and experience. its only easy because the interface is simple, but if you don't know what you are doing it won't be easy. so dont feel dumb if you are currently on that side of the learning process |
23:51:44 | FromDiscord | <sa-code> Maybe it's too late to not feel dumb. |
23:51:50 | FromDiscord | <sOkam!> đ |
23:52:42 | FromDiscord | <sa-code> I've never used or inter-oped with cpp before and I was sorta using this as a way to learn how to do that |