<< 30-01-2023 >>

00:34:04FromDiscord<Arathanis> What are best practices for initializing a `{.threadvar.}`?
00:44:14FromDiscord<leorize> don't forget to initialize it \:p
00:53:50sformanI'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:59FromDiscord<leorize> use `toOpenArrayByte` to convert it
00:56:25FromDiscord<leorize> sent a code paste, see https://play.nim-lang.org/#ix=4myA
00:56:29FromDiscord<leorize> the indices are inclusive fwiw
00:57:47FromDiscord<Elegantbeef> Nim is very strongly typed so `char` and `byte` are not interopable 😄
00:58:37FromDiscord<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:39sformanah, many thanks! That was just the thing.
01:13:45FromDiscord<demotomohiro> Or change that proc parameter type from `openArray[int8 | uint8]` to `openArray[char | int8 | uint8]` if possible.
01:26:36sformanno can do, it's file.writeBytes()
01:27:16FromDiscord<Elegantbeef> `writeChars`
01:28:30sformanwell 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:35FromDiscord<@thatrandomperson5-6310e3b26da03> curl https://nim-lang.org/choosenim/init.sh -sSf \| sh↔(<@709044657232936960_=50=4dunch=5b=49=52=43=5d>)
02:08:44FromDiscord<Tuatarian> I think the `{.cursor.}`pragma is just unusable
02:09:20FromDiscord<Tuatarian> I keep running into absurd segfaults that are pretty clearly not the fault of my code
02:15:54FromDiscord<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:39FromDiscord<huantian> In reply to @@thatrandomperson5-6310e3b26da03 "curl https://nim-lang.org/choosenim/init.sh -sSf \|": yeah that wont' work with nixos
02:23:35FromDiscord<Elegantbeef> Nothing ever works with nixos 😛
02:23:57FromDiscord<Rika> Beef just because you’re too inept to use it doesn’t mean nothing works on it
02:23:58FromDiscord<Rika> Smh
02:24:40FromDiscord<Elegantbeef> That implies i've attempted to
02:40:16FromDiscord<Tuatarian> I've tried both devel and 1.6.10, they're both unstable, though devel seems a bit better
02:46:16FromDiscord<Elegantbeef> It's practically a `ptr` so it's not like it can be that wrong
03:00:53FromDiscord<Tuatarian> It's mostly the refcounter breaking
03:01:03FromDiscord<Tuatarian> I'm getting issues where it's decrementing past 0
03:01:11FromDiscord<Tuatarian> Among other things
03:01:23FromDiscord<Elegantbeef> Single thread?
03:01:29FromDiscord<Tuatarian> Yes
03:03:26FromDiscord<Elegantbeef> This sounds like you're using cursor incorrectly
03:04:08FromDiscord<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:11FromDiscord<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:28FromDiscord<civbag> i see the limit of omitting parenthese lol https://media.discordapp.net/attachments/371759389889003532/1069515674998816858/image.png
07:17:12FromDiscord<Rika> Do goes outside of the parentheses
07:17:14FromDiscord<Elegantbeef> Command syntax's limitation is documented
07:18:03FromDiscord<Rika> The second to the last filter would work had you not an echo statement
07:19:03FromDiscord<civbag> ah i see. tysm
07:19:28FromDiscord<civbag> i just tried the nim by example
07:19:31FromDiscord<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:34FromDiscord<ShalokShalom> In reply to @Elegantbeef "Nothing ever works with": ab-so-lutely
07:53:52FromDiscord<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:54FromDiscord<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:38Amun-Rahow to check if module was imported in current scope?
11:15:03FromDiscord<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:10FromDiscord<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:17FromDiscord<Phil> (edit) "symbol" => "symbol, so that's not great either"
11:16:52FromDiscord<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:21FromDiscord<Phil> (edit) "available.↔So" => "available.↔↔So" | "use" => "available in your context export a" | "as a" => ""
11:18:59Amun-RaPhil: 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:53Amun-Rahmm, compiles "modulename.function" is better, thanks
11:31:29*xet7 quit (Remote host closed the connection)
12:10:38FromDiscord<Phil> er... how do you convert a seq[byte] to a string?
12:11:02FromDiscord<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:59FromDiscord<ringabout> sent a code paste, see https://play.nim-lang.org/#ix=4mAa
12:25:15FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mAb
12:25:25FromDiscord<ringabout> I'm not sure whether it works reliably.
12:25:35FromDiscord<ringabout> In reply to @Isofruit "Thanks! Next question, is": Yeah
12:25:53FromDiscord<ringabout> (edit) "Yeah" => "Yeah, it is"
12:26:13FromDiscord<Phil> That explains why that particular set of argon2 bindings no longer works that I'm playing around with
12:27:01FromDiscord<Phil> so argon2_bind is officially unuseable with anything resembling non-ancient nim
12:27:40FromDiscord<ringabout> In reply to @ringabout "I'm not sure whether": Anyway https://github.com/nim-lang/Nim/issues/14810
12:28:23FromDiscord<ringabout> https://github.com/Clonkk/bytesequtils
12:29:53FromDiscord<ringabout> (edit) "https://github.com/Clonkk/bytesequtils ... " added "is comparatively reliable."
12:30:32FromDiscord<turbo> sent a code paste, see https://play.nim-lang.org/#ix=4mAd
12:32:56FromDiscord<ringabout> You might catch `Defect` in this case using `except CatchableErrors, Defect`.
12:35:21FromDiscord<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:45FromDiscord<Phil> Aaaaaand argon2_highlevel also uses shallow
12:46:06FromDiscord<Phil> Oh FFS, argon2 lib also uses shallow, what is it with that thing
12:58:20*PMunch joined #nim
13:03:57FromDiscord<demotomohiro> I wrapped argon2 with header pragma and without using shallow.
13:06:13FromDiscord<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:45FromDiscord<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:41FromDiscord<Ayano> !eval echo s
13:39:44NimBotCompile failed: /usercode/in.nim(1, 6) Error: undeclared identifier: 's'
13:40:50FromDiscord<Rika> ?
13:40:59*jmdaemon quit (Ping timeout: 252 seconds)
13:59:01FromDiscord<Hamid_Bluri> sent a code paste, see https://play.nim-lang.org/#ix=4mAq
14:00:39FromDiscord<demotomohiro> !eval type Fn = proc (data: seq[Fn]); echo Fn
14:00:43NimBotCompile failed: <no output>
14:00:50FromDiscord<Hamid_Bluri> compiler crashes
14:09:20FromDiscord<demotomohiro> sent a code paste, see https://paste.rs/srT
14:13:08FromDiscord<Hamid_Bluri> sent a code paste, see https://play.nim-lang.org/#ix=4mAu
14:14:15Amun-Rafile bug report
14:14:29FromDiscord<Rika> Yeah sounds like a bug that that works but not the other
14:14:37FromDiscord<Nerve> sent a code paste, see https://play.nim-lang.org/#ix=4mAv
14:14:42FromDiscord<Nerve> x isn't being defined as a type, but a variable
14:15:10FromDiscord<Rika> In reply to @Nerve "x isn't being defined": The data parameter would need the data type though
14:15:38FromDiscord<Nerve> Oh I see it's a cyclical definition
14:15:55FromDiscord<Hamid_Bluri> In reply to @Nerve "Should probably use `var": nope doesn't make any difference
14:16:00FromDiscord<Hamid_Bluri> still crashes
14:53:25FromDiscord<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:43FromDiscord<I have 50GB of gay porn on my PC> and can "nimble run" use cache like "nim r"?
14:54:03FromDiscord<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:32FromDiscord<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:30FromDiscord<I have 50GB of gay porn on my PC> what https://media.discordapp.net/attachments/371759389889003532/1069655857077440654/image.png
16:31:06FromDiscord<I have 50GB of gay porn on my PC> a'ight.. https://media.discordapp.net/attachments/371759389889003532/1069656006436593724/image.png
16:37:05FromDiscord<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:32FromDiscord<Phil> I haven't done terminal stuff, sorry
16:40:58FromDiscord<Phil> In reply to @arkanoid "talking to C library,": Pmunch , when use c2nim when futhark 😄
16:41:01FromDiscord<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:51arkanoidPhil, it's a general question, I already use both, but I'm trying to figure out what the community does.
16:42:24FromDiscord<Phil> ~~I use neither, I don't wrap C-libs or what little I wrap is individual functions~~
16:44:37FromDiscord<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:48FromDiscord<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:02FromDiscord<mratsim> In reply to @halc "What's really the cost": Your soul and your unborn son
16:49:28FromDiscord<halc> Those don't worry me so much
16:49:51FromDiscord<Phil> Your time in debugging the obscure control flow in the future
16:50:05FromDiscord<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:08FromDiscord<mratsim> well if you don't use methods there is no control flow
16:50:41FromDiscord<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:43FromDiscord<mratsim> the questions then is why not use generics?
16:50:47FromDiscord<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:04FromDiscord<Phil> Yeh, generics with a concept seem better use here
16:52:05FromDiscord<halc> Perhaps, but it doesn't feel great that I have to copy paste the same fields for all the objects
16:52:07FromDiscord<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:42FromDiscord<jtv> Each has their place. OO is overused, but definitely reasonable to use for simple specialization
16:54:22FromDiscord<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:42FromDiscord<Phil> Or with SQL tables from a different application where the primary key field isn't called "id"
16:56:01FromDiscord<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:41FromDiscord<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:58FromDiscord<Phil> (edit) "to get me" => "for the purposes of getting"
16:57:01FromDiscord<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:04FromDiscord<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:08FromDiscord<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:17FromDiscord<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:26FromDiscord<Phil> (edit) "private" => "non-exported"
17:00:05FromDiscord<tfp> In reply to @halc "I don't have any": if u want that syntax, it's called delegation
17:00:16FromDiscord<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:18FromDiscord<tfp> there's some crates for it in rust, dunno if nim has one
17:02:07FromDiscord<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:49FromDiscord<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:35FromDiscord<Rika> There’s probably a library that simulates inheritance with composition since it is common to do so iirc
17:05:06FromDiscord<Phil> In reply to @tfp "is there an ADT": Have you checked other nimble packages that you'd find search for ADT?
17:06:41FromDiscord<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:23FromDiscord<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:46FromDiscord<tfp> In reply to @Isofruit "Have you checked other": nothing else really looks usable
17:08:54FromDiscord<tfp> maybe gara
17:13:40FromDiscord<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:58FromDiscord<ShalokShalom> if I understand you right then there is something in the making
17:15:59FromDiscord<ShalokShalom> @tfp https://nim-lang.org/blog/2022/12/21/version-20-rc.html
17:17:06FromDiscord<ShalokShalom> {.experimental: "overloadableEnums".}↔↔to use them in the stable version
17:24:39FromDiscord<Phil> For a second I thought that meant an enum that you could add options to
17:31:14FromDiscord<tfp> oh awesome, i'll check that out
17:31:17FromDiscord<tfp> thanks!
17:36:43arkanoidI 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:27FromDiscord<tfp> In reply to @ShalokShalom "if I understand you": weird, i still get the error in patty
17:41:31FromDiscord<tfp> i think patty itself might be throwing it
17:41:41FromDiscord<tfp> probably because it hasn't been updated to support overloadable enums
17:41:44FromDiscord<tfp> let's see
17:43:37FromDiscord<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:00FromDiscord<tfp> well patty also hasn't been updated in 2 years, so idk
17:44:05FromDiscord<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:16FromDiscord<tfp> but the example they post with the annotation works
17:44:19FromDiscord<tfp> just not with patty
17:44:34FromDiscord<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:55FromDiscord<Phil> macro magic
17:45:18FromDiscord<Phil> One of the reasons they are to be used sparingly whenever possible
17:47:46FromDiscord<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:59FromDiscord<Phil> At least to some degree
18:02:50FromDiscord<Ntsékees> sent a code paste, see https://play.nim-lang.org/#ix=4mD8
18:02:54FromDiscord<@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:56FromDiscord<Ntsékees> (edit) "https://play.nim-lang.org/#ix=4mD8" => "https://paste.rs/rYb"
18:03:14FromDiscord<tfp> https://media.discordapp.net/attachments/371759389889003532/1069679197636792320/image.png
18:03:44FromDiscord<tfp> so this is the code that patty generates, it's a bit different than the enum declarations related to overloadableEnums
18:03:56FromDiscord<tfp> this throws "nimtest.nim(12, 9) Error: attempt to redefine: 'n'"
18:06:15FromDiscord<tfp> oh i see
18:06:43FromDiscord<tfp> that feature overloadableEnums isn't actually for enum fields i guess?
18:07:59FromDiscord<Elegantbeef> It's not for object variant fields, it's only for enum fields
18:08:52FromDiscord<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:42FromDiscord<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:13FromDiscord<tfp> so i wanted something like rust-style enums `ShaderType::Matrix(4, 4, ShaderType::Float32)` for a 4x4 matrix, for example
18:10:31FromDiscord<tfp> this is WGSL where things like `vector<array<n, f32>>` are valid
18:10:36FromDiscord<Elegantbeef> Nim doesnt allow sharing fields so make a property
18:10:47FromDiscord<Ntsékees> sent a code paste, see https://play.nim-lang.org/#ix=4mDa
18:10:57FromDiscord<Elegantbeef> No clue why you need field names to be shared though
18:11:15FromDiscord<tfp> well i wanted array to have `n` for len and matrix to have `n, m` for dimensions
18:11:39FromDiscord<tfp> 🙂 but between that and not allowing recursive object variants i can't figure out a good solution
18:11:48FromDiscord<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:52FromDiscord<tfp> which makes sense-- i figure rust probably has the same limitation
18:11:55FromDiscord<Elegantbeef> You can have recursive object variants
18:12:05FromDiscord<Elegantbeef> Assuming they're `ref`
18:12:07FromDiscord<tfp> hmm, patty didn't like it but i didn't try with raw object variants
18:12:08FromDiscord<tfp> ah
18:12:14FromDiscord<tfp> yeah that's probably it
18:12:34FromDiscord<Elegantbeef> Nim's object variants and Rust's enums do work differently
18:13:16FromDiscord<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:40FromDiscord<Elegantbeef> I think rust uses pointers to distance the enum type to the union
18:15:55FromDiscord<tfp> i'm pretty sure rust enums are on the stack and have a fixed size
18:16:04FromDiscord<tfp> they're probably pretty similar under the hood
18:16:23FromDiscord<Elegantbeef> I could've sworn someone mentioned pointer indirection talking aobut them earlier
18:16:33FromDiscord<Elegantbeef> Guess this is what i get for trusting information
18:16:38FromDiscord<tfp> trust me bro!!
18:16:51FromDiscord<leorize> shameless plug\: https://github.com/alaviss/union
18:17:01FromDiscord<leorize> it doesn't have nice looking builder like patty, though
18:18:13FromDiscord<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:27FromDiscord<tfp> union looks cool but i've already built so much with patty
18:18:36FromDiscord<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:22FromDiscord<tfp> try fstat from the posix package?
18:19:26FromDiscord<leorize> what does that even mean lol
18:19:38FromDiscord<leorize> but `os.fileExists`, uh, exists
18:19:42FromDiscord<tfp> on unix sockets are files
18:19:43FromDiscord<tfp> afaik
18:19:54FromDiscord<tfp> fstat should be able to pick up on them and will probably even return different flags for them
18:20:12FromDiscord<tfp> i'm not sure how portable it is across OS's, but your issue sounds posix only anyway
18:21:02FromDiscord<leorize> note that filename/path is a property of the file system
18:21:32FromDiscord<leorize> if you own a file handle, it exists, but it's not guaranteed to have a name
18:26:44FromDiscord<I have 50GB of gay porn on my PC> In reply to @tfp "try fstat from the": thanks, seems to work
18:27:37FromDiscord<tfp> np, sorry for flooding the chat and hiding your message :^)
18:33:39FromDiscord<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:00FromDiscord<leorize> no one ever fixed it
18:34:19FromDiscord<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:04FromDiscord<tfp> i never noticed anything
18:35:11FromDiscord<tfp> i have 6k LoC in nim rn
18:35:32FromDiscord<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:46FromDiscord<Elegantbeef> Nah nimsuggest is fun
18:36:12FromDiscord<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:18FromDiscord<leorize> that's never a reason to leak \:p↔(@tfp)
18:37:11FromDiscord<leorize> there's langserver that could probably fix the project problem
18:37:40FromDiscord<tfp> i mean it was a really crazy macro
18:37:51FromDiscord<tfp> like it would load up a file and keep track of a counter
18:37:54FromDiscord<Elegantbeef> Yea until we get IC it's probably the best experience
18:38:11FromDiscord<Elegantbeef> If the compiler could compile it, the tooling should support it
18:38:18FromDiscord<tfp> if nim gets IC and cyclic imports i would throw rust in the toilet
18:38:28FromDiscord<Elegantbeef> when
18:38:36FromDiscord<Elegantbeef> Both are planned to be added
18:38:47FromDiscord<leorize> hopefully in less than 5yrs
18:39:08FromDiscord<tfp> i was kind of hoping someone would port ORC to rust
18:39:14FromDiscord<Elegantbeef> It'll never happen leo!
18:39:31FromDiscord<tfp> https://github.com/artichoke/cactusref
18:39:35FromDiscord<Elegantbeef> Orc doesnt fit with rust
18:39:38FromDiscord<tfp> well there is this which is basically that lol
18:39:42FromDiscord<tfp> i think it fits pretty well
18:39:49FromDiscord<tfp> like very few objects have to actually use refcounting imo
18:40:17FromDiscord<Elegantbeef> But it's not orc cause it lacks the features that make orc good 😄
18:40:42FromDiscord<tfp> well some optimizations i'm sure
18:40:48FromDiscord<Elegantbeef> Though i guess that i'm just saying i think Nim's move semantics are superior
18:41:00FromDiscord<tfp> wdym
18:41:07FromDiscord<tfp> i haven't used move semantics yet
18:41:21FromDiscord<tfp> i plan on doing a second pass over my codebase and optimizing that kinda stuff eventually
18:41:25FromDiscord<leorize> rust is leagues ahead of him in that department
18:41:54FromDiscord<Elegantbeef> I prefer Nim's move semantics that trust the programmer as it makes life a easier
18:42:05FromDiscord<Elegantbeef> a bit easier\
18:42:12FromDiscord<tfp> ye the main reason i'm picking nim is because i think the borrow checker is overkill
18:42:18FromDiscord<tfp> i think memory safety via refcounting is the better play
18:42:23FromDiscord<Elegantbeef> Like if you cannot move in Nim it doesnt error it copies
18:42:23FromDiscord<tfp> for > 90% of programs
18:42:42*azimut joined #nim
18:44:29FromDiscord<I have 50GB of gay porn on my PC> i liked rust's tooling and error messages
18:44:59FromDiscord<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:22FromDiscord<Elegantbeef> To be fair if you do `a.add` it does copy
18:49:48FromDiscord<leorize> accidental CoW? \:p
18:58:38FromDiscord<Elegantbeef> It did benefit the compiler's speed
18:58:38FromDiscord<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:11FromDiscord<ShalokShalom> In reply to @Isofruit "For a second I": i was also confused about the name
19:28:47arkanoiddamn, 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:10FromDiscord<pyolyokh> Nim style insensitivity starts after the first letter, but you can change the name that Nim sees.
19:32:32arkanoidpyolyokh, what do you mean?
19:33:04FromDiscord<pyolyokh> which part are you asking about?
19:33:17FromDiscord<pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4mDH
19:33:18arkanoidthe second
19:33:28arkanoid"I can change what nim sees"
19:33:47FromDiscord<pyolyokh> that's an example of it. Nim's PUTS refers to C ABI "puts"
19:34:13arkanoidwell, sure, but that would mean editing the autogenerated nim api, adding a manual step after an automatic one
19:34:28arkanoidwell, I', solve it with the hammer "proc [A-Z]"
19:34:44FromDiscord<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:55arkanoid"proc [A-Z]" -> "proc \L$1" done
19:36:04FromDiscord<pyolyokh> you could also keep the capital letter in your wrapper. maybe people familiar with futhark will expect it
19:38:58arkanoidis char == uint8 == byte ?
19:39:14FromDiscord<pyolyokh> yes.
19:40:21arkanoidif C code says cuchar, nim warns about deprecation and to use 'char' or 'uint8'
19:40:52arkanoidwould you replace cuchar with char or uint8?
19:41:21arkanoid(and why the warning doesn't say byte?)
19:41:24*kenran joined #nim
19:42:52arkanoidI mean, double deprecation https://nim-lang.org/docs/system.html#cuchar
19:44:00FromDiscord<pyolyokh> byte's defined in system.nim as just an alias for uint8
19:44:28FromDiscord<pyolyokh> yeah, to avoid the deprecation and not use a silly word like 'cuchar', I'd just use uint8
19:44:37FromDiscord<pyolyokh> or 'char', if it's text
19:46:45*ehmry quit (Ping timeout: 260 seconds)
19:47:42*ehmry joined #nim
19:51:01arkanoidk
19:53:22*ehmry quit (Ping timeout: 252 seconds)
19:56:29*ehmry joined #nim
20:00:36Amun-Raor byte, less typing
20:00:59Amun-RaI 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:29FromDiscord<ShalokShalom> In reply to @tfp "well patty also hasn't": maybe open an issue or simply use the manual syntax
20:23:06FromDiscord<ShalokShalom> https://github.com/ShalokShalom/fsharp-nim/blob/master/dev-aspect.nim#L17
20:29:29FromDiscord<Ducko> is there a way I can only include some code at build-time if a flag is present?
20:29:36FromDiscord<Ducko> (edit) "is there a way I can only include some code at build-time if a ... flag" added "custom"
20:30:19FromDiscord<pyolyokh> `when defined(flag): code`
20:31:17FromDiscord<Ducko> thanks!
20:35:00*jmdaemon joined #nim
20:37:49FromDiscord<Piqueiras> By the way, are binary trees implemented in standard libs?
20:38:54FromDiscord<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:54FromDiscord<Piqueiras> but not in a standard import I guess
20:47:22FromDiscord<Ducko> what's the best way to prepend (a static value) to a seq?
20:47:43FromDiscord<Elegantbeef> `myConst & mySeq`
20:48:19FromDiscord<Ducko> oh cool, didn't know you could just concat consts, thanks
20:53:07FromDiscord<Ducko> sent a code paste, see https://play.nim-lang.org/#ix=4mDX
20:53:56FromDiscord<Ducko> (edit) "https://play.nim-lang.org/#ix=4mDX" => "https://play.nim-lang.org/#ix=4mDY"
20:54:06FromDiscord<Elegantbeef> > This function uses poEvalCommand by default for backwards compatibility. Make sure to pass options explicitly.
20:54:32FromDiscord<Ducko> oh, it still had the args option so I presumed they worked together, oops
20:55:06FromDiscord<Ducko> thanks!
20:56:23*kenran quit (Remote host closed the connection)
21:32:01FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mE7
21:32:14FromDiscord<Elegantbeef> `type RandRange = 1..100`
21:32:52FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mE9
21:32:58FromDiscord<4zv4l> or panic
21:33:00FromDiscord<Elegantbeef> No it'd error at line 2
21:33:11FromDiscord<Elegantbeef> It's not a saturated type
21:33:16FromDiscord<Elegantbeef> It's a range type
21:34:37FromDiscord<4zv4l> no way to make sure that the variable will `always` be in range ?
21:34:46FromDiscord<Elegantbeef> Not without making your own type
21:35:24FromDiscord<4zv4l> how can I do that ?
21:37:07FromDiscord<4zv4l> In reply to @4zv4l "is it possible to": isn't it like making a type already ?
21:37:20FromDiscord<Elegantbeef> No that's a subrange type in Nim
21:37:28FromDiscord<Elegantbeef> I'm talking about making your own saturated type
21:39:12FromDiscord<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:28FromDiscord<Elegantbeef> `type RandRange = distinct 1..100`
21:39:40FromDiscord<Elegantbeef> It's technically distinct already but implicitly converts
21:39:49FromDiscord<Elegantbeef> So things like `+` and friends use the `int` operators
21:39:57FromDiscord<4zv4l> In reply to @Elegantbeef "`type RandRange = distinct": I get an error with this
21:39:59FromDiscord<4zv4l> `Error: type expected, but got: 1`
21:40:30FromDiscord<Elegantbeef> `type RandRange = distinct range[1..100]`
21:40:51FromDiscord<Elegantbeef> Or `type RandRange = distinct (1..100)`
21:40:53FromDiscord<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:42FromDiscord<Elegantbeef> There's a start
21:42:46FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mEb
21:46:27FromDiscord<4zv4l> thank you so much↔and so those things happened under the hood for example with `uint8` ?
21:46:32FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mEd
21:46:55FromDiscord<Elegantbeef> unsigned integers dont have overflow protection in nim
21:47:00FromDiscord<Elegantbeef> So nothing happens under the hood
21:47:16FromDiscord<Elegantbeef> If you do 255u8 + 1 it just overflows due to how base 2 math works
21:47:34FromDiscord<Elegantbeef> 127i8 + 1 errors cause nim has overflow checks on integers
21:47:53FromDiscord<4zv4l> oh indeed
21:47:57FromDiscord<4zv4l> it panics with `int8`
21:53:34FromDiscord<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:02FromDiscord<Elegantbeef> you could use `:=` or similar to assign it
21:54:52FromDiscord<Elegantbeef> You cannot define a generic converter
21:57:54*derpydoo quit (Remote host closed the connection)
22:00:44FromDiscord<Elegantbeef> Does work though
22:00:46FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mEi
22:00:59FromDiscord<Elegantbeef> But you need to emit a converter for each concrete saturated number
22:01:38FromDiscord<Elegantbeef> Also i guess saturated isnt correct
22:01:42FromDiscord<Elegantbeef> This should be wrapped
22:01:44FromDiscord<Elegantbeef> Saturated is clamped
22:03:08FromDiscord<4zv4l> the converter will automatically be called if I understand correctly ?
22:03:09FromDiscord<leorize> saturated is the technical term afaict
22:03:10FromDiscord<Elegantbeef> Or more obviously Modular 😄
22:03:22FromDiscord<Elegantbeef> Saturated explicitly clamps leo, modulo wraps
22:03:41FromDiscord<Elegantbeef> Modular or Modulo i should say
22:03:41FromDiscord<leorize> oh yea I misread
22:04:07FromDiscord<Elegantbeef> Converters are user defined implicit converters yes
22:04:21FromDiscord<Elegantbeef> They only convert to concrete types tohugh
22:04:24FromDiscord<Elegantbeef> though\
22:04:35FromDiscord<Elegantbeef> So you cannot use the else branch as much as it looks like you should
22:04:40FromDiscord<leorize> why are you not using range types beef?
22:04:59FromDiscord<Elegantbeef> Cause `1..2` is a slice
22:05:15FromDiscord<Elegantbeef> So when you do `Type[1..2]` it gets a `Slice` not a `range`
22:05:21FromDiscord<leorize> put a `range[]` on it \:p
22:05:27FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4mEl
22:05:41FromDiscord<Elegantbeef> Ah yes that's what we need mot hideous code leorize!
22:05:48FromDiscord<Elegantbeef> more hideous\
22:05:50FromDiscord<leorize> range is a lot safer when you can afford it \:p
22:06:13FromDiscord<leorize> nothing a template can't fix
22:06:31FromDiscord<Elegantbeef> Well there is no difference afaict though between using range or a slice in my saturated/modulo code
22:07:01FromDiscord<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:10FromDiscord<leorize> when you use a range, any f-up is caught by the compiler
22:07:22FromDiscord<leorize> I mean, it'd be nice if we never f-up our code \:p
22:07:46FromDiscord<Elegantbeef> I like the juxtaposition of you censoring yourself mere seconds after I did not
22:08:26FromDiscord<leorize> I typed that so much my phone just suggest it now
22:18:57FromDiscord<4zv4l> is it possible to get the `min` and `max` value from a range type ?
22:19:31FromDiscord<Elegantbeef> `high` and `low`
22:21:52FromDiscord<4zv4l> thanks !
22:39:36FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4mEt
22:39:57FromDiscord<Elegantbeef> `prev = curr`
22:40:07FromDiscord<sOkam!> srs? that simple?
22:40:10FromDiscord<Elegantbeef> The issue is that you're not doing `mySeq[0].addr`
22:40:18FromDiscord<Elegantbeef> Yes seq/strings are value types
22:40:29FromDiscord<sOkam!> I'm usiing some cpp code as reference, so I can imagine all patterns im using are severely non-nim
22:40:40FromDiscord<sOkam!> ah i see
22:41:00FromDiscord<Elegantbeef> Even if they were not you could do `mySeq[0..^1]`
22:41:05FromDiscord<Elegantbeef> So many ways to copy a seq 😄
22:41:13FromDiscord<Elegantbeef> `@mySeq.toOpenArray(0, mySeq.high)`
22:41:52FromDiscord<Elegantbeef> But yea you want `prev[0].addr.copyMem(prev[0].addr, curr.len)` after doing `prev.setLen(curr.len)`
22:42:04FromDiscord<Elegantbeef> Not that it's the "the way" just educating
22:42:51FromDiscord<sOkam!> kk
22:43:06FromDiscord<sOkam!> if the len is already set for this frame, that setlen wouldn't be needed i assume
22:45:12FromDiscord<Elegantbeef> Well unless you wanted a useless call
22:45:48FromDiscord<Elegantbeef> `setLen` doesnt shrink if that's what you're indirectly asking
22:46:28FromDiscord<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:16FromDiscord<sOkam!> i was more worried about waste of time than anything, since its done each frame
22:47:38FromDiscord<Elegantbeef> It's a simple if statement
22:51:31FromDiscord<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:10FromDiscord<Ntsékees> I'm tring to figure out how to import Javascript functions into a Nim-compiled webassembly.
22:52:42FromDiscord<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:19FromDiscord<pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4mEv
22:55:56FromDiscord<pyolyokh> with the 'exportc' doing nothing but ensuring that `hello` isn't optimized out of the result
22:57:26FromDiscord<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:45FromDiscord<Ntsékees> I've found how to make it accept undefined symbols. Problem solved it seems.
23:02:29FromDiscord<jtv> Should write a tutorial when you're done 🙂
23:33:20FromDiscord<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