00:34:04 | FromDiscord | <Arathanis> What are best practices for initializing a `{.threadvar.}`? |
00:44:14 | FromDiscord | <leorize> don't forget to initialize it \:p |
00:53:50 | sforman | I've got an array[0..63, char] and I'm passing it to a proc that expects openArray[int8 | uint8] and it's a type mismatch. I have two questions: 1) Why? It would seem to me to be compatible types, no? and 2) What would be a good way to make it work? I can change the type I'm passing, but is there a nice way to tell Nim to cast the array or something? |
00:54:33 | * | derpydoo joined #nim |
00:55:59 | FromDiscord | <leorize> use `toOpenArrayByte` to convert it |
00:56:25 | FromDiscord | <leorize> sent a code paste, see https://play.nim-lang.org/#ix=4myA |
00:56:29 | FromDiscord | <leorize> the indices are inclusive fwiw |
00:57:47 | FromDiscord | <Elegantbeef> Nim is very strongly typed so `char` and `byte` are not interopable đ |
00:58:37 | FromDiscord | <Elegantbeef> A trick you can do is make an `openarray[char]` overload that then does the `toOpenArrayByte` if you have a lot of calls of this proc |
01:05:39 | sforman | ah, many thanks! That was just the thing. |
01:13:45 | FromDiscord | <demotomohiro> Or change that proc parameter type from `openArray[int8 | uint8]` to `openArray[char | int8 | uint8]` if possible. |
01:26:36 | sforman | no can do, it's file.writeBytes() |
01:27:16 | FromDiscord | <Elegantbeef> `writeChars` |
01:28:30 | sforman | well now I feel dumb. I can see it there in the manual page-- now that you pointed it out. Sorry for the noise. |
02:02:35 | FromDiscord | <@thatrandomperson5-6310e3b26da03> curl https://nim-lang.org/choosenim/init.sh -sSf \| shâ”(<@709044657232936960_=50=4dunch=5b=49=52=43=5d>) |
02:08:44 | FromDiscord | <Tuatarian> I think the `{.cursor.}`pragma is just unusable |
02:09:20 | FromDiscord | <Tuatarian> I keep running into absurd segfaults that are pretty clearly not the fault of my code |
02:15:54 | FromDiscord | <Elegantbeef> are you using devel or 1.6.10? |
02:20:30 | * | azimut_ quit (Quit: ZNC - https://znc.in) |
02:21:06 | * | azimut joined #nim |
02:22:39 | FromDiscord | <huantian> In reply to @@thatrandomperson5-6310e3b26da03 "curl https://nim-lang.org/choosenim/init.sh -sSf \|": yeah that wont' work with nixos |
02:23:35 | FromDiscord | <Elegantbeef> Nothing ever works with nixos đ |
02:23:57 | FromDiscord | <Rika> Beef just because youâre too inept to use it doesnât mean nothing works on it |
02:23:58 | FromDiscord | <Rika> Smh |
02:24:40 | FromDiscord | <Elegantbeef> That implies i've attempted to |
02:40:16 | FromDiscord | <Tuatarian> I've tried both devel and 1.6.10, they're both unstable, though devel seems a bit better |
02:46:16 | FromDiscord | <Elegantbeef> It's practically a `ptr` so it's not like it can be that wrong |
03:00:53 | FromDiscord | <Tuatarian> It's mostly the refcounter breaking |
03:01:03 | FromDiscord | <Tuatarian> I'm getting issues where it's decrementing past 0 |
03:01:11 | FromDiscord | <Tuatarian> Among other things |
03:01:23 | FromDiscord | <Elegantbeef> Single thread? |
03:01:29 | FromDiscord | <Tuatarian> Yes |
03:03:26 | FromDiscord | <Elegantbeef> This sounds like you're using cursor incorrectly |
03:04:08 | FromDiscord | <Elegantbeef> IE you're using it to point to a resource that does not outlive the `cursor` so it frees and now you have a freed block of memory you're pointing at |
03:05:11 | FromDiscord | <Elegantbeef> You arent manually decrementing the `cursor`'s ref count are you? |
04:01:26 | * | rockcavera joined #nim |
04:03:54 | * | rockcavera quit (Remote host closed the connection) |
04:04:34 | * | arkurious quit (Quit: Leaving) |
07:13:28 | FromDiscord | <civbag> i see the limit of omitting parenthese lol https://media.discordapp.net/attachments/371759389889003532/1069515674998816858/image.png |
07:17:12 | FromDiscord | <Rika> Do goes outside of the parentheses |
07:17:14 | FromDiscord | <Elegantbeef> Command syntax's limitation is documented |
07:18:03 | FromDiscord | <Rika> The second to the last filter would work had you not an echo statement |
07:19:03 | FromDiscord | <civbag> ah i see. tysm |
07:19:28 | FromDiscord | <civbag> i just tried the nim by example |
07:19:31 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/manual.html#procedures-command-invocation-syntax |
07:35:08 | * | PMunch joined #nim |
07:36:29 | * | kenran joined #nim |
07:52:34 | FromDiscord | <ShalokShalom> In reply to @Elegantbeef "Nothing ever works with": ab-so-lutely |
07:53:52 | FromDiscord | <ShalokShalom> In reply to @Elegantbeef "Most people arent scared": đ± |
08:04:39 | * | kenran` joined #nim |
08:06:24 | * | kenran quit (Ping timeout: 248 seconds) |
08:54:54 | FromDiscord | <Require Support> any reviews on mastering nim book? |
09:17:58 | * | PMunch quit (Quit: Leaving) |
09:41:53 | * | azimut quit (Ping timeout: 255 seconds) |
10:27:22 | * | jmdaemon quit (Ping timeout: 252 seconds) |
10:51:21 | * | jmdaemon joined #nim |
10:53:25 | * | derpydoo quit (Ping timeout: 256 seconds) |
11:09:38 | Amun-Ra | how to check if module was imported in current scope? |
11:15:03 | FromDiscord | <Phil> In reply to @Amun-Ra "how to check if": First ugly hack idea that comes to mind is trying to access an exported member from that module ala `modulename.member` and use `compiles` to check if that works or not. |
11:16:10 | FromDiscord | <Phil> Though you need to know with which name that module is available, so if somebody aliases that thing from "potato" to "fries" you're getting false despite the module and its symbols strictly speaking being available.â”So you could instead also just check if `member` is available, but that screws you if any of the other modules use `member` as a symbol |
11:16:17 | FromDiscord | <Phil> (edit) "symbol" => "symbol, so that's not great either" |
11:16:52 | FromDiscord | <Phil> (edit) "Though you need to know with which name that module is available, so if somebody aliases that thing from "potato" to "fries" ... you'refrom" added "and exports it while you're expecting to get the module "potato"," | "and exports it while you're expecting to get the module "potato",you're getting false ... despite" added "from the `compiles` check" |
11:17:21 | FromDiscord | <Phil> (edit) "available.â”So" => "available.â”â”So" | "use" => "available in your context export a" | "as a" => "" |
11:18:59 | Amun-Ra | Phil: declared() does not work the way I thought it does; I use when compiles "import module" (that's because each of them ends with {.fatal.} on invalid target) |
11:19:53 | Amun-Ra | hmm, compiles "modulename.function" is better, thanks |
11:31:29 | * | xet7 quit (Remote host closed the connection) |
12:10:38 | FromDiscord | <Phil> er... how do you convert a seq[byte] to a string? |
12:11:02 | FromDiscord | <Phil> Because I made an array of the chars 'a', 'b' and 'c' and converted them to bytes, I kinda want to cast that to a 'abc' string |
12:24:59 | FromDiscord | <ringabout> sent a code paste, see https://play.nim-lang.org/#ix=4mAa |
12:25:15 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mAb |
12:25:25 | FromDiscord | <ringabout> I'm not sure whether it works reliably. |
12:25:35 | FromDiscord | <ringabout> In reply to @Isofruit "Thanks! Next question, is": Yeah |
12:25:53 | FromDiscord | <ringabout> (edit) "Yeah" => "Yeah, it is" |
12:26:13 | FromDiscord | <Phil> That explains why that particular set of argon2 bindings no longer works that I'm playing around with |
12:27:01 | FromDiscord | <Phil> so argon2_bind is officially unuseable with anything resembling non-ancient nim |
12:27:40 | FromDiscord | <ringabout> In reply to @ringabout "I'm not sure whether": Anyway https://github.com/nim-lang/Nim/issues/14810 |
12:28:23 | FromDiscord | <ringabout> https://github.com/Clonkk/bytesequtils |
12:29:53 | FromDiscord | <ringabout> (edit) "https://github.com/Clonkk/bytesequtils ... " added "is comparatively reliable." |
12:30:32 | FromDiscord | <turbo> sent a code paste, see https://play.nim-lang.org/#ix=4mAd |
12:32:56 | FromDiscord | <ringabout> You might catch `Defect` in this case using `except CatchableErrors, Defect`. |
12:35:21 | FromDiscord | <turbo> Yeah, I'm using that now. But that brings up the question whether I should just expect internal std assertions to fail with uncatchable errors? That seem ... bug-ish to me |
12:44:45 | FromDiscord | <Phil> Aaaaaand argon2_highlevel also uses shallow |
12:46:06 | FromDiscord | <Phil> Oh FFS, argon2 lib also uses shallow, what is it with that thing |
12:58:20 | * | PMunch joined #nim |
13:03:57 | FromDiscord | <demotomohiro> I wrapped argon2 with header pragma and without using shallow. |
13:06:13 | FromDiscord | <demotomohiro> https://github.com/P-H-C/phc-winner-argon2â”It is not hard to wrap manually as there are not many functions, types and constants you would need to wrap. |
13:30:45 | FromDiscord | <demotomohiro> https://github.com/P-H-C/phc-winner-argon2/blob/master/include/argon2.hâ”All constants, types and functions to use argon2 are declared in argon2.h |
13:39:41 | FromDiscord | <Ayano> !eval echo s |
13:39:44 | NimBot | Compile failed: /usercode/in.nim(1, 6) Error: undeclared identifier: 's' |
13:40:50 | FromDiscord | <Rika> ? |
13:40:59 | * | jmdaemon quit (Ping timeout: 252 seconds) |
13:59:01 | FromDiscord | <Hamid_Bluri> sent a code paste, see https://play.nim-lang.org/#ix=4mAq |
14:00:39 | FromDiscord | <demotomohiro> !eval type Fn = proc (data: seq[Fn]); echo Fn |
14:00:43 | NimBot | Compile failed: <no output> |
14:00:50 | FromDiscord | <Hamid_Bluri> compiler crashes |
14:09:20 | FromDiscord | <demotomohiro> sent a code paste, see https://paste.rs/srT |
14:13:08 | FromDiscord | <Hamid_Bluri> sent a code paste, see https://play.nim-lang.org/#ix=4mAu |
14:14:15 | Amun-Ra | file bug report |
14:14:29 | FromDiscord | <Rika> Yeah sounds like a bug that that works but not the other |
14:14:37 | FromDiscord | <Nerve> sent a code paste, see https://play.nim-lang.org/#ix=4mAv |
14:14:42 | FromDiscord | <Nerve> x isn't being defined as a type, but a variable |
14:15:10 | FromDiscord | <Rika> In reply to @Nerve "x isn't being defined": The data parameter would need the data type though |
14:15:38 | FromDiscord | <Nerve> Oh I see it's a cyclical definition |
14:15:55 | FromDiscord | <Hamid_Bluri> In reply to @Nerve "Should probably use `var": nope doesn't make any difference |
14:16:00 | FromDiscord | <Hamid_Bluri> still crashes |
14:53:25 | FromDiscord | <I have 50GB of gay porn on my PC> s there a workaround for currentSourcePath returning .cache garbage instead of the original file when I use nim run? |
14:53:43 | FromDiscord | <I have 50GB of gay porn on my PC> and can "nimble run" use cache like "nim r"? |
14:54:03 | FromDiscord | <I have 50GB of gay porn on my PC> another question - is there a workaround for asyncdispatch's ugly exception dumps? |
15:15:41 | * | PMunch quit (Quit: Leaving) |
15:27:05 | * | arkurious joined #nim |
15:28:09 | * | derpydoo joined #nim |
16:04:32 | FromDiscord | <arkanoid> talking to C library, when should I use c2nim, and when should I use futhark? |
16:10:07 | * | kenran` quit (Remote host closed the connection) |
16:30:30 | FromDiscord | <I have 50GB of gay porn on my PC> what https://media.discordapp.net/attachments/371759389889003532/1069655857077440654/image.png |
16:31:06 | FromDiscord | <I have 50GB of gay porn on my PC> a'ight.. https://media.discordapp.net/attachments/371759389889003532/1069656006436593724/image.png |
16:37:05 | FromDiscord | <I have 50GB of gay porn on my PC> does anyone know why the template from stdlib doesn't see the other template right above it (when my code calls terminal.styledEcho) |
16:40:32 | FromDiscord | <Phil> I haven't done terminal stuff, sorry |
16:40:58 | FromDiscord | <Phil> In reply to @arkanoid "talking to C library,": Pmunch , when use c2nim when futhark đ |
16:41:01 | FromDiscord | <Nerve> Do the `dynlibOverride` compilation options only mean that you wish to manually specify a dynamic library file instead of using the system library paths? Or does it force static linking? Are there any relatively completely instructions anywhere for forcing and ensuring static compilation? |
16:41:51 | arkanoid | Phil, it's a general question, I already use both, but I'm trying to figure out what the community does. |
16:42:24 | FromDiscord | <Phil> ~~I use neither, I don't wrap C-libs or what little I wrap is individual functions~~ |
16:44:37 | FromDiscord | <Phil> In reply to @Nerve "Do the `dynlibOverride` compilation": Based on the docs here: https://nim-lang.org/docs/nimc.html#dynliboverrideâ”I'd think using dynliboverride in combination with `passL` is what ensures static compilation |
16:48:48 | FromDiscord | <halc> What's really the cost of inheritance if I'm not using methods and essentially just use it as a nicer-looking composition? |
16:49:02 | FromDiscord | <mratsim> In reply to @halc "What's really the cost": Your soul and your unborn son |
16:49:28 | FromDiscord | <halc> Those don't worry me so much |
16:49:51 | FromDiscord | <Phil> Your time in debugging the obscure control flow in the future |
16:50:05 | FromDiscord | <jtv> None from a runtime perspective. The only 'cost' is dynamic dispatch, which doesn't occur if you're not using methods, and isn't particularly high anyway |
16:50:08 | FromDiscord | <mratsim> well if you don't use methods there is no control flow |
16:50:41 | FromDiscord | <Phil> Fair point, but at that point why use inheritance, since you now have the fields you want to have split between two files |
16:50:43 | FromDiscord | <mratsim> the questions then is why not use generics? |
16:50:47 | FromDiscord | <Phil> (edit) "Fair point, but at that point why use inheritance, since you now have the fields you want to have ... split" added "in an object" |
16:51:04 | FromDiscord | <Phil> Yeh, generics with a concept seem better use here |
16:52:05 | FromDiscord | <halc> Perhaps, but it doesn't feel great that I have to copy paste the same fields for all the objects |
16:52:07 | FromDiscord | <Phil> Like, I use inheritance in that capacity because norm forces my hand there and it's "only" the `id` field, so I can live with that , but whenever I controlled the code myself I avoided it |
16:52:42 | FromDiscord | <jtv> Each has their place. OO is overused, but definitely reasonable to use for simple specialization |
16:54:22 | FromDiscord | <Phil> Kind of, in my case for example I'm not really all that happy that norm enforces usage of inheritance because now I can't use norm e.g. with "views" that just don't have an id field |
16:54:42 | FromDiscord | <Phil> Or with SQL tables from a different application where the primary key field isn't called "id" |
16:56:01 | FromDiscord | <Phil> So while inheritance was nice there to give a guarantee for what seems like an obvious standard everything should have that is used in that context, it also put unnecessary roadblocks up for the less obvious usecases |
16:56:41 | FromDiscord | <Phil> Which is why I developed the tendency to not want to have inheritance in nim to get me "guarantees" that a type fulfills certain requirements |
16:56:58 | FromDiscord | <Phil> (edit) "to get me" => "for the purposes of getting" |
16:57:01 | FromDiscord | <halc> I don't have any attachment to OOP, just in this case I like that in comparison to composition, I can simply write `objA.doSomething()` rather than `objA.objB.doSomething()` |
16:57:04 | FromDiscord | <tfp> is there an ADT library that doesn't have the limitation Patty has (where each variant of the ADT can't share a field name?) |
16:57:08 | FromDiscord | <tfp> > A limitation of the variant macro is that field names must be unique across branches (that is, different variants cannot have two fields with the same name). This is actually a limitation of Nim. |
16:58:15 | * | oprypin quit (Read error: Connection reset by peer) |
16:58:23 | * | oprypin joined #nim |
16:59:17 | FromDiscord | <Phil> In reply to @halc "I don't have any": Hmm information hiding like that is not specifically something I associate as an "OOP"-thing.â”In nim you'd achieve that for example by just defining a `doSomething` for A and making objB a private field on objA. |
16:59:26 | FromDiscord | <Phil> (edit) "private" => "non-exported" |
17:00:05 | FromDiscord | <tfp> In reply to @halc "I don't have any": if u want that syntax, it's called delegation |
17:00:16 | FromDiscord | <Phil> But maybe my definitions are out of whack there as what concept is supposed to belong to OOP and what doesn't is always a bit wobbly to me |
17:00:18 | FromDiscord | <tfp> there's some crates for it in rust, dunno if nim has one |
17:02:07 | FromDiscord | <halc> In reply to @Isofruit "Hmm information hiding like": Sure, but that means writing a bit of extra code, even if it's just a one line definition. Just feel that semantically, inheritance would be better here. |
17:03:49 | FromDiscord | <Phil> I'm lacking a bit of code-context why inheritance solves that particular issue without dynamic dispatch (since you stated you weren't using methods), so given that I can't say much on the matter |
17:04:35 | FromDiscord | <Rika> Thereâs probably a library that simulates inheritance with composition since it is common to do so iirc |
17:05:06 | FromDiscord | <Phil> In reply to @tfp "is there an ADT": Have you checked other nimble packages that you'd find search for ADT? |
17:06:41 | FromDiscord | <halc> Not using methods yeah, but it's still nice that I only need to write one proc for the parent object and it works for all the child objects, statically |
17:07:23 | FromDiscord | <halc> Like sure I could do the same with composition, but I can't help but feel a bit silly to write the extra boilerplate just to avoid inheritance |
17:08:46 | FromDiscord | <tfp> In reply to @Isofruit "Have you checked other": nothing else really looks usable |
17:08:54 | FromDiscord | <tfp> maybe gara |
17:13:40 | FromDiscord | <ShalokShalom> In reply to @tfp "is there an ADT": that's more a limitation towards object variantsâ”â”patty and other libraries are simply macros, who compile down to them |
17:13:58 | FromDiscord | <ShalokShalom> if I understand you right then there is something in the making |
17:15:59 | FromDiscord | <ShalokShalom> @tfp https://nim-lang.org/blog/2022/12/21/version-20-rc.html |
17:17:06 | FromDiscord | <ShalokShalom> {.experimental: "overloadableEnums".}â”â”to use them in the stable version |
17:24:39 | FromDiscord | <Phil> For a second I thought that meant an enum that you could add options to |
17:31:14 | FromDiscord | <tfp> oh awesome, i'll check that out |
17:31:17 | FromDiscord | <tfp> thanks! |
17:36:43 | arkanoid | I have a C++ lib that provides C api via "extern C". Futhark works with C source only. Is there a way to convert a C++ header file that is all "extern C" into a C header file to feed futhark? |
17:41:27 | FromDiscord | <tfp> In reply to @ShalokShalom "if I understand you": weird, i still get the error in patty |
17:41:31 | FromDiscord | <tfp> i think patty itself might be throwing it |
17:41:41 | FromDiscord | <tfp> probably because it hasn't been updated to support overloadable enums |
17:41:44 | FromDiscord | <tfp> let's see |
17:43:37 | FromDiscord | <Phil> In reply to @tfp "probably because it hasn't": TBF, nim 1.9.1 is the devel compiler, that's not yet a stable version |
17:44:00 | FromDiscord | <tfp> well patty also hasn't been updated in 2 years, so idk |
17:44:05 | FromDiscord | <Phil> I've been in the process of updating several webdev dependencies to be compatible with nim2 for example over the last week |
17:44:16 | FromDiscord | <tfp> but the example they post with the annotation works |
17:44:19 | FromDiscord | <tfp> just not with patty |
17:44:34 | FromDiscord | <tfp> and i also can't find the string for the error in patty, so i guess maybe it's actually just generating code differently than i expect |
17:44:55 | FromDiscord | <Phil> macro magic |
17:45:18 | FromDiscord | <Phil> One of the reasons they are to be used sparingly whenever possible |
17:47:46 | FromDiscord | <Phil> In reply to @demotomohiro "https://github.com/P-H-C/phc-winner-argon2/blob/mas": The main issue I have with wrapping argon is that I now need to understand argon |
17:47:59 | FromDiscord | <Phil> At least to some degree |
18:02:50 | FromDiscord | <Ntsékees> sent a code paste, see https://play.nim-lang.org/#ix=4mD8 |
18:02:54 | FromDiscord | <@thatrandomperson5-6310e3b26da03> Is there any way to set the timeout of a http request? I tried timeout but i donât think it works |
18:02:56 | FromDiscord | <Ntsékees> (edit) "https://play.nim-lang.org/#ix=4mD8" => "https://paste.rs/rYb" |
18:03:14 | FromDiscord | <tfp> https://media.discordapp.net/attachments/371759389889003532/1069679197636792320/image.png |
18:03:44 | FromDiscord | <tfp> so this is the code that patty generates, it's a bit different than the enum declarations related to overloadableEnums |
18:03:56 | FromDiscord | <tfp> this throws "nimtest.nim(12, 9) Error: attempt to redefine: 'n'" |
18:06:15 | FromDiscord | <tfp> oh i see |
18:06:43 | FromDiscord | <tfp> that feature overloadableEnums isn't actually for enum fields i guess? |
18:07:59 | FromDiscord | <Elegantbeef> It's not for object variant fields, it's only for enum fields |
18:08:52 | FromDiscord | <I have 50GB of gay porn on my PC> fileExists returns false by design for sockets. how am I supposed to do a check for a socket file then? |
18:09:42 | FromDiscord | <tfp> In reply to @Elegantbeef "It's not for object": is there another way to do what i'm trying to do? i need to build types that represent types in a shader |
18:10:13 | FromDiscord | <tfp> so i wanted something like rust-style enums `ShaderType::Matrix(4, 4, ShaderType::Float32)` for a 4x4 matrix, for example |
18:10:31 | FromDiscord | <tfp> this is WGSL where things like `vector<array<n, f32>>` are valid |
18:10:36 | FromDiscord | <Elegantbeef> Nim doesnt allow sharing fields so make a property |
18:10:47 | FromDiscord | <Ntsékees> sent a code paste, see https://play.nim-lang.org/#ix=4mDa |
18:10:57 | FromDiscord | <Elegantbeef> No clue why you need field names to be shared though |
18:11:15 | FromDiscord | <tfp> well i wanted array to have `n` for len and matrix to have `n, m` for dimensions |
18:11:39 | FromDiscord | <tfp> đ but between that and not allowing recursive object variants i can't figure out a good solution |
18:11:48 | FromDiscord | <I have 50GB of gay porn on my PC> In reply to @I have 50GB of gay porn on my PC "fileExists returns false by": bump |
18:11:52 | FromDiscord | <tfp> which makes sense-- i figure rust probably has the same limitation |
18:11:55 | FromDiscord | <Elegantbeef> You can have recursive object variants |
18:12:05 | FromDiscord | <Elegantbeef> Assuming they're `ref` |
18:12:07 | FromDiscord | <tfp> hmm, patty didn't like it but i didn't try with raw object variants |
18:12:08 | FromDiscord | <tfp> ah |
18:12:14 | FromDiscord | <tfp> yeah that's probably it |
18:12:34 | FromDiscord | <Elegantbeef> Nim's object variants and Rust's enums do work differently |
18:13:16 | FromDiscord | <Elegantbeef> Nim's object variants are a tagged union of a fixed size and do not rely on pattern matching to unpack. Which means fields names cannot be reused as there is no static enforcement to reason where `n` is |
18:13:40 | FromDiscord | <Elegantbeef> I think rust uses pointers to distance the enum type to the union |
18:15:55 | FromDiscord | <tfp> i'm pretty sure rust enums are on the stack and have a fixed size |
18:16:04 | FromDiscord | <tfp> they're probably pretty similar under the hood |
18:16:23 | FromDiscord | <Elegantbeef> I could've sworn someone mentioned pointer indirection talking aobut them earlier |
18:16:33 | FromDiscord | <Elegantbeef> Guess this is what i get for trusting information |
18:16:38 | FromDiscord | <tfp> trust me bro!! |
18:16:51 | FromDiscord | <leorize> shameless plug\: https://github.com/alaviss/union |
18:17:01 | FromDiscord | <leorize> it doesn't have nice looking builder like patty, though |
18:18:13 | FromDiscord | <tfp> i figure i'll just get away with using ref for recursion and just use `len` instead of `n` for the array variant |
18:18:27 | FromDiscord | <tfp> union looks cool but i've already built so much with patty |
18:18:36 | FromDiscord | <I have 50GB of gay porn on my PC> so there is no obvious way to check if a file exists, just because it's a socket? |
18:19:22 | FromDiscord | <tfp> try fstat from the posix package? |
18:19:26 | FromDiscord | <leorize> what does that even mean lol |
18:19:38 | FromDiscord | <leorize> but `os.fileExists`, uh, exists |
18:19:42 | FromDiscord | <tfp> on unix sockets are files |
18:19:43 | FromDiscord | <tfp> afaik |
18:19:54 | FromDiscord | <tfp> fstat should be able to pick up on them and will probably even return different flags for them |
18:20:12 | FromDiscord | <tfp> i'm not sure how portable it is across OS's, but your issue sounds posix only anyway |
18:21:02 | FromDiscord | <leorize> note that filename/path is a property of the file system |
18:21:32 | FromDiscord | <leorize> if you own a file handle, it exists, but it's not guaranteed to have a name |
18:26:44 | FromDiscord | <I have 50GB of gay porn on my PC> In reply to @tfp "try fstat from the": thanks, seems to work |
18:27:37 | FromDiscord | <tfp> np, sorry for flooding the chat and hiding your message :^) |
18:33:39 | FromDiscord | <I have 50GB of gay porn on my PC> I'm surprised the nimsuggest memory leak seems to still be here after all this time |
18:34:00 | FromDiscord | <leorize> no one ever fixed it |
18:34:19 | FromDiscord | <I have 50GB of gay porn on my PC> might be scaring out some newcomers, when their PC becomes unusable just because they opened a text editor |
18:35:04 | FromDiscord | <tfp> i never noticed anything |
18:35:11 | FromDiscord | <tfp> i have 6k LoC in nim rn |
18:35:32 | FromDiscord | <tfp> i did notice one issue where i was getting a leak but i figured it was my own fault because i did a crazy macro |
18:35:46 | FromDiscord | <Elegantbeef> Nah nimsuggest is fun |
18:36:12 | FromDiscord | <Elegantbeef> If you do not have a project setup "properly" editors tend to dispatch a suggest per file which makes it just slam your PC |
18:36:18 | FromDiscord | <leorize> that's never a reason to leak \:pâ”(@tfp) |
18:37:11 | FromDiscord | <leorize> there's langserver that could probably fix the project problem |
18:37:40 | FromDiscord | <tfp> i mean it was a really crazy macro |
18:37:51 | FromDiscord | <tfp> like it would load up a file and keep track of a counter |
18:37:54 | FromDiscord | <Elegantbeef> Yea until we get IC it's probably the best experience |
18:38:11 | FromDiscord | <Elegantbeef> If the compiler could compile it, the tooling should support it |
18:38:18 | FromDiscord | <tfp> if nim gets IC and cyclic imports i would throw rust in the toilet |
18:38:28 | FromDiscord | <Elegantbeef> when |
18:38:36 | FromDiscord | <Elegantbeef> Both are planned to be added |
18:38:47 | FromDiscord | <leorize> hopefully in less than 5yrs |
18:39:08 | FromDiscord | <tfp> i was kind of hoping someone would port ORC to rust |
18:39:14 | FromDiscord | <Elegantbeef> It'll never happen leo! |
18:39:31 | FromDiscord | <tfp> https://github.com/artichoke/cactusref |
18:39:35 | FromDiscord | <Elegantbeef> Orc doesnt fit with rust |
18:39:38 | FromDiscord | <tfp> well there is this which is basically that lol |
18:39:42 | FromDiscord | <tfp> i think it fits pretty well |
18:39:49 | FromDiscord | <tfp> like very few objects have to actually use refcounting imo |
18:40:17 | FromDiscord | <Elegantbeef> But it's not orc cause it lacks the features that make orc good đ |
18:40:42 | FromDiscord | <tfp> well some optimizations i'm sure |
18:40:48 | FromDiscord | <Elegantbeef> Though i guess that i'm just saying i think Nim's move semantics are superior |
18:41:00 | FromDiscord | <tfp> wdym |
18:41:07 | FromDiscord | <tfp> i haven't used move semantics yet |
18:41:21 | FromDiscord | <tfp> i plan on doing a second pass over my codebase and optimizing that kinda stuff eventually |
18:41:25 | FromDiscord | <leorize> rust is leagues ahead of him in that department |
18:41:54 | FromDiscord | <Elegantbeef> I prefer Nim's move semantics that trust the programmer as it makes life a easier |
18:42:05 | FromDiscord | <Elegantbeef> a bit easier\ |
18:42:12 | FromDiscord | <tfp> ye the main reason i'm picking nim is because i think the borrow checker is overkill |
18:42:18 | FromDiscord | <tfp> i think memory safety via refcounting is the better play |
18:42:23 | FromDiscord | <Elegantbeef> Like if you cannot move in Nim it doesnt error it copies |
18:42:23 | FromDiscord | <tfp> for > 90% of programs |
18:42:42 | * | azimut joined #nim |
18:44:29 | FromDiscord | <I have 50GB of gay porn on my PC> i liked rust's tooling and error messages |
18:44:59 | FromDiscord | <I have 50GB of gay porn on my PC> too bad you have to drink the manual memory managemennt koolaid to use it |
18:49:22 | FromDiscord | <Elegantbeef> To be fair if you do `a.add` it does copy |
18:49:48 | FromDiscord | <leorize> accidental CoW? \:p |
18:58:38 | FromDiscord | <Elegantbeef> It did benefit the compiler's speed |
18:58:38 | FromDiscord | <Elegantbeef> Technically the compiler required a `shallowCopy` or a `{.cursor.}` with orc |
19:07:23 | * | Guest11 joined #nim |
19:10:00 | * | Guest11 quit (Client Quit) |
19:17:14 | * | byanka quit (Ping timeout: 260 seconds) |
19:24:11 | FromDiscord | <ShalokShalom> In reply to @Isofruit "For a second I": i was also confused about the name |
19:28:47 | arkanoid | damn, futhark exported all C functions as procs starting with capital letter, such as "proc Clientinit*". I can call this as "Clientinit" but not as "clientInit". Where's the case insensitivity? |
19:31:10 | FromDiscord | <pyolyokh> Nim style insensitivity starts after the first letter, but you can change the name that Nim sees. |
19:32:32 | arkanoid | pyolyokh, what do you mean? |
19:33:04 | FromDiscord | <pyolyokh> which part are you asking about? |
19:33:17 | FromDiscord | <pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4mDH |
19:33:18 | arkanoid | the second |
19:33:28 | arkanoid | "I can change what nim sees" |
19:33:47 | FromDiscord | <pyolyokh> that's an example of it. Nim's PUTS refers to C ABI "puts" |
19:34:13 | arkanoid | well, sure, but that would mean editing the autogenerated nim api, adding a manual step after an automatic one |
19:34:28 | arkanoid | well, I', solve it with the hammer "proc [A-Z]" |
19:34:44 | FromDiscord | <pyolyokh> or, writing a program to do that, adding an automatic step after an automatic one. If you're using a tool and it doesn't generate what you want, that's about it. |
19:35:55 | arkanoid | "proc [A-Z]" -> "proc \L$1" done |
19:36:04 | FromDiscord | <pyolyokh> you could also keep the capital letter in your wrapper. maybe people familiar with futhark will expect it |
19:38:58 | arkanoid | is char == uint8 == byte ? |
19:39:14 | FromDiscord | <pyolyokh> yes. |
19:40:21 | arkanoid | if C code says cuchar, nim warns about deprecation and to use 'char' or 'uint8' |
19:40:52 | arkanoid | would you replace cuchar with char or uint8? |
19:41:21 | arkanoid | (and why the warning doesn't say byte?) |
19:41:24 | * | kenran joined #nim |
19:42:52 | arkanoid | I mean, double deprecation https://nim-lang.org/docs/system.html#cuchar |
19:44:00 | FromDiscord | <pyolyokh> byte's defined in system.nim as just an alias for uint8 |
19:44:28 | FromDiscord | <pyolyokh> yeah, to avoid the deprecation and not use a silly word like 'cuchar', I'd just use uint8 |
19:44:37 | FromDiscord | <pyolyokh> or 'char', if it's text |
19:46:45 | * | ehmry quit (Ping timeout: 260 seconds) |
19:47:42 | * | ehmry joined #nim |
19:51:01 | arkanoid | k |
19:53:22 | * | ehmry quit (Ping timeout: 252 seconds) |
19:56:29 | * | ehmry joined #nim |
20:00:36 | Amun-Ra | or byte, less typing |
20:00:59 | Amun-Ra | I have to make a test case for: /usr/lib/nim/system/basic_types.nim(16, 16) Error: internal error: symbol has no generated name: true |
20:11:03 | * | junaid_ joined #nim |
20:22:29 | FromDiscord | <ShalokShalom> In reply to @tfp "well patty also hasn't": maybe open an issue or simply use the manual syntax |
20:23:06 | FromDiscord | <ShalokShalom> https://github.com/ShalokShalom/fsharp-nim/blob/master/dev-aspect.nim#L17 |
20:29:29 | FromDiscord | <Ducko> is there a way I can only include some code at build-time if a flag is present? |
20:29:36 | FromDiscord | <Ducko> (edit) "is there a way I can only include some code at build-time if a ... flag" added "custom" |
20:30:19 | FromDiscord | <pyolyokh> `when defined(flag): code` |
20:31:17 | FromDiscord | <Ducko> thanks! |
20:35:00 | * | jmdaemon joined #nim |
20:37:49 | FromDiscord | <Piqueiras> By the way, are binary trees implemented in standard libs? |
20:38:54 | FromDiscord | <mratsim> In reply to @Piqueiras "By the way, are": lThere are b-trees in Nim-lang/fusion repo iirc. And Nim internally uses AVL trees IIRC. ANd I'm sure yhou can find many trees in Rosetta Code |
20:39:54 | FromDiscord | <Piqueiras> but not in a standard import I guess |
20:47:22 | FromDiscord | <Ducko> what's the best way to prepend (a static value) to a seq? |
20:47:43 | FromDiscord | <Elegantbeef> `myConst & mySeq` |
20:48:19 | FromDiscord | <Ducko> oh cool, didn't know you could just concat consts, thanks |
20:53:07 | FromDiscord | <Ducko> sent a code paste, see https://play.nim-lang.org/#ix=4mDX |
20:53:56 | FromDiscord | <Ducko> (edit) "https://play.nim-lang.org/#ix=4mDX" => "https://play.nim-lang.org/#ix=4mDY" |
20:54:06 | FromDiscord | <Elegantbeef> > This function uses poEvalCommand by default for backwards compatibility. Make sure to pass options explicitly. |
20:54:32 | FromDiscord | <Ducko> oh, it still had the args option so I presumed they worked together, oops |
20:55:06 | FromDiscord | <Ducko> thanks! |
20:56:23 | * | kenran quit (Remote host closed the connection) |
21:32:01 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mE7 |
21:32:14 | FromDiscord | <Elegantbeef> `type RandRange = 1..100` |
21:32:52 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mE9 |
21:32:58 | FromDiscord | <4zv4l> or panic |
21:33:00 | FromDiscord | <Elegantbeef> No it'd error at line 2 |
21:33:11 | FromDiscord | <Elegantbeef> It's not a saturated type |
21:33:16 | FromDiscord | <Elegantbeef> It's a range type |
21:34:37 | FromDiscord | <4zv4l> no way to make sure that the variable will `always` be in range ? |
21:34:46 | FromDiscord | <Elegantbeef> Not without making your own type |
21:35:24 | FromDiscord | <4zv4l> how can I do that ? |
21:37:07 | FromDiscord | <4zv4l> In reply to @4zv4l "is it possible to": isn't it like making a type already ? |
21:37:20 | FromDiscord | <Elegantbeef> No that's a subrange type in Nim |
21:37:28 | FromDiscord | <Elegantbeef> I'm talking about making your own saturated type |
21:39:12 | FromDiscord | <4zv4l> In reply to @Elegantbeef "`type RandRange = 1..100`": also is there a way of making this one `distinct` to avoid issue with proc arguments ? |
21:39:28 | FromDiscord | <Elegantbeef> `type RandRange = distinct 1..100` |
21:39:40 | FromDiscord | <Elegantbeef> It's technically distinct already but implicitly converts |
21:39:49 | FromDiscord | <Elegantbeef> So things like `+` and friends use the `int` operators |
21:39:57 | FromDiscord | <4zv4l> In reply to @Elegantbeef "`type RandRange = distinct": I get an error with this |
21:39:59 | FromDiscord | <4zv4l> `Error: type expected, but got: 1` |
21:40:30 | FromDiscord | <Elegantbeef> `type RandRange = distinct range[1..100]` |
21:40:51 | FromDiscord | <Elegantbeef> Or `type RandRange = distinct (1..100)` |
21:40:53 | FromDiscord | <4zv4l> In reply to @Elegantbeef "I'm talking about making": I don't know much about thatâ”is it possible to do that in Nim ? |
21:42:29 | * | junaid_ quit (Remote host closed the connection) |
21:42:42 | FromDiscord | <Elegantbeef> There's a start |
21:42:46 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mEb |
21:46:27 | FromDiscord | <4zv4l> thank you so muchâ”and so those things happened under the hood for example with `uint8` ? |
21:46:32 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mEd |
21:46:55 | FromDiscord | <Elegantbeef> unsigned integers dont have overflow protection in nim |
21:47:00 | FromDiscord | <Elegantbeef> So nothing happens under the hood |
21:47:16 | FromDiscord | <Elegantbeef> If you do 255u8 + 1 it just overflows due to how base 2 math works |
21:47:34 | FromDiscord | <Elegantbeef> 127i8 + 1 errors cause nim has overflow checks on integers |
21:47:53 | FromDiscord | <4zv4l> oh indeed |
21:47:57 | FromDiscord | <4zv4l> it panics with `int8` |
21:53:34 | FromDiscord | <4zv4l> I guess there would be a way to make a macro or something to automatically run `toSaturated` when the left variable is of type `Saturated` ? |
21:54:02 | FromDiscord | <Elegantbeef> you could use `:=` or similar to assign it |
21:54:52 | FromDiscord | <Elegantbeef> You cannot define a generic converter |
21:57:54 | * | derpydoo quit (Remote host closed the connection) |
22:00:44 | FromDiscord | <Elegantbeef> Does work though |
22:00:46 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mEi |
22:00:59 | FromDiscord | <Elegantbeef> But you need to emit a converter for each concrete saturated number |
22:01:38 | FromDiscord | <Elegantbeef> Also i guess saturated isnt correct |
22:01:42 | FromDiscord | <Elegantbeef> This should be wrapped |
22:01:44 | FromDiscord | <Elegantbeef> Saturated is clamped |
22:03:08 | FromDiscord | <4zv4l> the converter will automatically be called if I understand correctly ? |
22:03:09 | FromDiscord | <leorize> saturated is the technical term afaict |
22:03:10 | FromDiscord | <Elegantbeef> Or more obviously Modular đ |
22:03:22 | FromDiscord | <Elegantbeef> Saturated explicitly clamps leo, modulo wraps |
22:03:41 | FromDiscord | <Elegantbeef> Modular or Modulo i should say |
22:03:41 | FromDiscord | <leorize> oh yea I misread |
22:04:07 | FromDiscord | <Elegantbeef> Converters are user defined implicit converters yes |
22:04:21 | FromDiscord | <Elegantbeef> They only convert to concrete types tohugh |
22:04:24 | FromDiscord | <Elegantbeef> though\ |
22:04:35 | FromDiscord | <Elegantbeef> So you cannot use the else branch as much as it looks like you should |
22:04:40 | FromDiscord | <leorize> why are you not using range types beef? |
22:04:59 | FromDiscord | <Elegantbeef> Cause `1..2` is a slice |
22:05:15 | FromDiscord | <Elegantbeef> So when you do `Type[1..2]` it gets a `Slice` not a `range` |
22:05:21 | FromDiscord | <leorize> put a `range[]` on it \:p |
22:05:27 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mEl |
22:05:41 | FromDiscord | <Elegantbeef> Ah yes that's what we need mot hideous code leorize! |
22:05:48 | FromDiscord | <Elegantbeef> more hideous\ |
22:05:50 | FromDiscord | <leorize> range is a lot safer when you can afford it \:p |
22:06:13 | FromDiscord | <leorize> nothing a template can't fix |
22:06:31 | FromDiscord | <Elegantbeef> Well there is no difference afaict though between using range or a slice in my saturated/modulo code |
22:07:01 | FromDiscord | <Elegantbeef> I guess you get extra safety, but given that you need to saturate/modulo all values after operations it's on you if you fuck it up |
22:07:10 | FromDiscord | <leorize> when you use a range, any f-up is caught by the compiler |
22:07:22 | FromDiscord | <leorize> I mean, it'd be nice if we never f-up our code \:p |
22:07:46 | FromDiscord | <Elegantbeef> I like the juxtaposition of you censoring yourself mere seconds after I did not |
22:08:26 | FromDiscord | <leorize> I typed that so much my phone just suggest it now |
22:18:57 | FromDiscord | <4zv4l> is it possible to get the `min` and `max` value from a range type ? |
22:19:31 | FromDiscord | <Elegantbeef> `high` and `low` |
22:21:52 | FromDiscord | <4zv4l> thanks ! |
22:39:36 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4mEt |
22:39:57 | FromDiscord | <Elegantbeef> `prev = curr` |
22:40:07 | FromDiscord | <sOkam!> srs? that simple? |
22:40:10 | FromDiscord | <Elegantbeef> The issue is that you're not doing `mySeq[0].addr` |
22:40:18 | FromDiscord | <Elegantbeef> Yes seq/strings are value types |
22:40:29 | FromDiscord | <sOkam!> I'm usiing some cpp code as reference, so I can imagine all patterns im using are severely non-nim |
22:40:40 | FromDiscord | <sOkam!> ah i see |
22:41:00 | FromDiscord | <Elegantbeef> Even if they were not you could do `mySeq[0..^1]` |
22:41:05 | FromDiscord | <Elegantbeef> So many ways to copy a seq đ |
22:41:13 | FromDiscord | <Elegantbeef> `@mySeq.toOpenArray(0, mySeq.high)` |
22:41:52 | FromDiscord | <Elegantbeef> But yea you want `prev[0].addr.copyMem(prev[0].addr, curr.len)` after doing `prev.setLen(curr.len)` |
22:42:04 | FromDiscord | <Elegantbeef> Not that it's the "the way" just educating |
22:42:51 | FromDiscord | <sOkam!> kk |
22:43:06 | FromDiscord | <sOkam!> if the len is already set for this frame, that setlen wouldn't be needed i assume |
22:45:12 | FromDiscord | <Elegantbeef> Well unless you wanted a useless call |
22:45:48 | FromDiscord | <Elegantbeef> `setLen` doesnt shrink if that's what you're indirectly asking |
22:46:28 | FromDiscord | <Elegantbeef> To shrink an array you need to tell nim to reallocate by either using `a[b..c]` or `newSeqOfCap` `= @[]` or any other combination |
22:47:16 | FromDiscord | <sOkam!> i was more worried about waste of time than anything, since its done each frame |
22:47:38 | FromDiscord | <Elegantbeef> It's a simple if statement |
22:51:31 | FromDiscord | <Ntsékees> Is there a command line switch for allowing undefined symbols in compilation? I.e. symbols that would be instantiated from an external source? `{.importc.}` doesn't seem to be enough. |
22:52:10 | FromDiscord | <Ntsékees> I'm tring to figure out how to import Javascript functions into a Nim-compiled webassembly. |
22:52:42 | FromDiscord | <Ntsékees> Apparently, for the Go language they just declare the function's prototype without writing its body and it seems to be enough. |
22:55:19 | FromDiscord | <pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4mEv |
22:55:56 | FromDiscord | <pyolyokh> with the 'exportc' doing nothing but ensuring that `hello` isn't optimized out of the result |
22:57:26 | FromDiscord | <NtsĂ©kees> Ah, the error âundefined symbolâ is thrown at me from the Wasm linker, so it's not exactly the fault of Nim⊠|
23:00:45 | FromDiscord | <Ntsékees> I've found how to make it accept undefined symbols. Problem solved it seems. |
23:02:29 | FromDiscord | <jtv> Should write a tutorial when you're done đ |
23:33:20 | FromDiscord | <auxym> this looks pretty neat as an alternative to choosenim, asdf and co: https://tea.xyz/ in case anyone wants to package nim for it đ |
23:41:45 | * | derpydoo joined #nim |