<< 15-01-2023 >>

00:00:20FromDiscord<pyolyokh> <https://nim-lang.org/docs/manual.html#statements-and-expressions-var-statement>
00:00:35FromDiscord<MadScientistCarl> I see
00:01:39FromDiscord<Elegantbeef> All types are 0 init'd in Nim
00:02:25FromDiscord<MadScientistCarl> Hmmm
00:02:36FromDiscord<MadScientistCarl> sent a code paste, see https://play.nim-lang.org/#ix=4lf8
00:03:04FromDiscord<pyolyokh> procs have types, there are two of them in that message, and those two procs have different arguments
00:03:19FromDiscord<pyolyokh> `string` isn't `varargs[string]`
00:03:58FromDiscord<pyolyokh> the visual noise is from the <https://nim-lang.org/docs/manual.html#effect-system>
00:04:07FromDiscord<sealmove> I have a stream that is constantly being appended to. I want to read up until the last line that is available at the moment without blocking.
00:04:08FromDiscord<pyolyokh> because those can also matter, although they don't here
00:04:11FromDiscord<sealmove> How do I do it?
00:04:41FromDiscord<planetis> Something to do with the srcDir, the package needs fixing for sure.↵(@voidwalker)
00:05:08FromDiscord<voidwalker> `nimble install ffmpeg@#head ` worked
00:05:56FromDiscord<pyolyokh> In reply to @รєคɭ๓๏שє "I have a stream": use selectors <https://nim-lang.org/docs/selectors.html> or concurrency (async, futures, threads)
00:10:12*Guest1 joined #nim
00:10:29*Guest1 quit (Client Quit)
00:11:59FromDiscord<MadScientistCarl> Do I have to use a `ref` for a tagged union?
00:12:09FromDiscord<sealmove> In reply to @pyolyokh "use selectors <https://nim-lang.org/docs/selectors.": looks complicated :p will try
00:12:10FromDiscord<Elegantbeef> No
00:13:29FromDiscord<pyolyokh> the very first example at <https://nim-lang.org/docs/manual.html#types-object-variants> isn't an object ref
00:14:05FromDiscord<MadScientistCarl> Huh, I see an example with ref instead
00:14:17FromDiscord<MadScientistCarl> Oh, `Node` is not required?
00:14:20FromDiscord<Elegantbeef> I mean they can be ref
00:14:41FromDiscord<pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4lfa
00:14:42FromDiscord<Elegantbeef> It's required for the API they use since they have a mutally recursive type
00:14:55FromDiscord<Elegantbeef> It can be a node tree so it needs a ref indirection
00:15:00FromDiscord<MadScientistCarl> Ah, right
00:15:11FromDiscord<Elegantbeef> Otherwise you need infinite stack
00:15:16FromDiscord<Elegantbeef> And i think the laws of physics prevent that
00:16:19FromDiscord<MadScientistCarl> Also, just how are enums namespaced? Do I have to invent a prefix for every enum?
00:16:30FromDiscord<pyolyokh> nah, you just need refinement types, like in ATS. Then your `NodeObj(2)` can clearly only need stack space for a 2-deep tree
00:16:38FromDiscord<MadScientistCarl> I am not completely understanding how `{.pure.}` works, based on its description
00:16:49FromDiscord<Elegantbeef> They arent namespaced
00:16:54FromDiscord<pyolyokh> pure takes the name of the enum as a namespace
00:16:59FromDiscord<Elegantbeef> Use `--overloadableEnums` and be happy
00:17:10FromDiscord<Elegantbeef> Sorry `--experimental:overloadableEnums`
00:17:14FromDiscord<Elegantbeef> Or is it overridable enums
00:17:30FromDiscord<scipio> sent a code paste, see https://play.nim-lang.org/#ix=4lfb
00:18:00FromDiscord<pyolyokh> In reply to @scipio "What could be the": having a variable named `let`, normally not possible. Also variables with spaces in them. More commonly, actually, usefully: defining operators.
00:18:42FromDiscord<pyolyokh> it's also an option when you're binding a library that has an object field named 'type', and you want to stay closer to the bound API
00:19:23FromDiscord<Elegantbeef> It's used to define operators and allows calling things directly
00:19:24FromDiscord<Elegantbeef> That will be recusive
00:19:25FromDiscord<Elegantbeef> recursive\
00:19:25FromDiscord<Elegantbeef> But it also allows removing meaning from Nim keywords if you're into that horrid code
00:19:28FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4lfc
00:19:30FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/pvB
00:19:33FromDiscord<pyolyokh> <https://nim-lang.org/docs/manual.html#generics-implicit-generics> second example uses stropping to define `==`
00:19:55FromDiscord<Elegantbeef> Meh binding isnt really an argument imo
00:20:25FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4lfd
00:20:30FromDiscord<Elegantbeef> YMMV on that though
00:21:40FromDiscord<pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4lfe
00:21:56FromDiscord<scipio> @pyolyokh so basically "interoperability" is a prime usecase for stropping
00:21:57FromDiscord<pyolyokh> (edit) "https://play.nim-lang.org/#ix=4lfe" => "https://play.nim-lang.org/#ix=4lff"
00:21:58FromDiscord<Elegantbeef> I say good riddance 😛
00:22:07FromDiscord<Elegantbeef> Not really
00:22:41FromDiscord<pyolyokh> In reply to @scipio "<@803214225002463283> so basically "interoperabilit": no. Primary usecase is operators. Last example shows how it's not great for interoperability.
00:22:57FromDiscord<Elegantbeef> There's also a 'hidden' template feature of stropping
00:23:31FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4lfg
00:24:04FromDiscord<pyolyokh> I feel like that's a different thing that shares the syntax. Manual even says "backticks notation" instead of stropping
00:24:29FromDiscord<Elegantbeef> I consider it the same thing, but only cause it's parsed the same
00:24:31FromDiscord<pyolyokh> eh, although "stropping" only shows up once. Might just not be a favored term
00:25:01FromDiscord<Elegantbeef> It's lexical stropping since it removes semantics
00:25:12FromDiscord<Elegantbeef> The example of properties for instance
00:25:26FromDiscord<Elegantbeef> The compiler doesnt attempt to call `host=` or w/e
00:26:31FromDiscord<pyolyokh> ah yeah, another good example of them, `destroy=`
00:26:39FromDiscord<Elegantbeef> `=destroy` 😛
00:27:16FromDiscord<Elegantbeef> `destroy=` would be a property setter named destroy
00:27:19FromDiscord<scipio> Another question I have (while learning Nim via small assignments I give myself while reading the docs) is what would be a preferred modus operandi for structuring projects.↵↵I tend to grow one `.nim` file I notice. Also, when compiling the binary is placed in my `src/` folder, can that be changed via some configuration flag?
00:27:37FromDiscord<Elegantbeef> `--outDir` and `--out` for dir/name
00:27:54FromDiscord<Elegantbeef> The way to write Nim is to make a module for things that are module-like
00:31:29FromDiscord<pyolyokh> nimble cares about source location, nim doesn't as much. code layout's guided by↵a. files importing to a module named after the file↵b. code ordering mattering in general (have to define `foo` before you call `foo()`)↵you can put everything related to a type in a file with the type definition, or you can start to the fight the system
00:37:51FromDiscord<scipio> What would you say is the core reason why the red team community likes Nim? Would language features like stropping, UFCS, case insensitivity and meta programming be among them?
00:39:13FromDiscord<pyolyokh> is that even the case? If so, I imagine it's more that there are Python and Go books about the subject, and there are good reasons to dislike both languages (speed; verbosity)
00:39:18FromDiscord<MadScientistCarl> How do I actually use a tagged union in a proc?
00:39:27FromDiscord<pyolyokh> You use it the same as anything else
00:39:30FromDiscord<Elegantbeef> You put the type in the proc
00:39:40FromDiscord<Elegantbeef> Nim's tagged unions are not like Rust's enum
00:39:41FromDiscord<Ayano> anyway to bitshift like in java "<<"
00:39:46FromDiscord<Ayano> (edit) ""<<"" => ""<<"?"
00:39:47FromDiscord<MadScientistCarl> Yes? But how do I match on kind?
00:39:50FromDiscord<Elegantbeef> There is one type it's the name of the type
00:39:50FromDiscord<Elegantbeef> `shl`
00:39:53FromDiscord<Elegantbeef> `case kind`
00:39:54FromDiscord<cow> In reply to @scipio "What would you say": statically compiled, small binaries with no runtime required is probably a factor
00:40:07FromDiscord<cow> In reply to @Ayano "anyway to bitshift like": shl and shr
00:40:09FromDiscord<Ayano> In reply to @Elegantbeef "`shl`": that throws me a couple of errors when using it sadly
00:40:29FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4lfl
00:40:34FromDiscord<cow> In reply to @Ayano "that throws me a": what errors
00:40:35FromDiscord<Elegantbeef> Well if only the error provided diagnostics that could help solve this issue
00:40:48FromDiscord<Elegantbeef> We like seeing errors when they happen
00:40:48FromDiscord<Ayano> In reply to @cow "what errors": https://media.discordapp.net/attachments/371759389889003532/1063981036796649472/image.png
00:40:51FromDiscord<Elegantbeef> It makes it easier to help you
00:40:56FromDiscord<MadScientistCarl> Yeah, but do I just access the fields without compiler checks?
00:41:12FromDiscord<Elegantbeef> value is int
00:41:14FromDiscord<pyolyokh> In reply to @Ayano "": focus on the words like 'int', 'uint8', in that message
00:41:17FromDiscord<Elegantbeef> Yes you do
00:41:24FromDiscord<Elegantbeef> Nim doesnt have pattern matching or ADT behaviour
00:41:27FromDiscord<Elegantbeef> It has runtime checks
00:41:42FromDiscord<Ayano> In reply to @pyolyokh "focus on the words": the docs said that it could be int, so i am confused why it is not liking it
00:41:51FromDiscord<Elegantbeef> cause it's `int or int8`
00:41:59FromDiscord<Elegantbeef> You need to do `value or int(...)`
00:42:00FromDiscord<cow> you can't bitwise or an int and uint8
00:42:03FromDiscord<pyolyokh> In reply to @MadScientistCarl "Yeah, but do I": there are compiler checks. If you branch into a case the object has the appropriate variant in that case.
00:42:28FromDiscord<cow> or you need to have var value = 0'u8 if you want uint8 value
00:43:15FromDiscord<cow> but from context, you probably want to convert curByte to int first
00:43:25FromDiscord<cow> (edit) "curByte" => "(curByte...)"
00:43:27FromDiscord<huantian> In reply to @pyolyokh "there *are* compiler checks.": The compiler checks are kinda lackluster tho
00:43:54FromDiscord<pyolyokh> the point is, it's not some kind of danger mode reckless engagement with the variant.
00:43:56FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4lfm
00:44:07FromDiscord<Elegantbeef> Sure there's runtime checks aswell
00:44:08FromDiscord<Elegantbeef> So it's not like a C union
00:45:18FromDiscord<MadScientistCarl> they can't have the same name...
00:45:29FromDiscord<pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4lfo
00:45:49FromDiscord<pyolyokh> as does `a.b = "10"` in that line
00:45:58FromDiscord<Elegantbeef> Of course they cannot have the same name
00:46:02FromDiscord<Elegantbeef> Nim doesnt have pattern matching
00:46:09FromDiscord<pyolyokh> In reply to @MadScientistCarl "they can't have the": yep, variants have either shared fields or disjunct distinct fields.
00:46:35FromDiscord<pyolyokh> because in `MyVar(b: "10")` the fieldnames are the only way that Nim knows what variant you mean
00:47:16FromDiscord<Elegantbeef> Object variants are a tagged union like Rust's enums, but they're not similar implementations in the least
00:47:39FromDiscord<Elegantbeef> Nim's are closer to the bare layout
00:48:03FromDiscord<cow> they should allow fields to have the same name if they're the same type and at the same byte offset inside the object
00:48:09FromDiscord<pyolyokh> you can do the same stuff, you can't do it the same way. There are some plusses and minuses. Maybe you appreciate the explicit discriminant, maybe you wish you were writing OCaml
00:48:42FromDiscord<MadScientistCarl> Lol, if OCaml has a better C FFI I'd be using it
00:48:46FromDiscord<pyolyokh> In reply to @cow "they should allow fields": when that's the case for all variants, it's just a shared field
00:48:56FromDiscord<Elegantbeef> Rust's are a higher level abstraction that require having enforced pattern matching to function
00:49:01FromDiscord<cow> sometimes it's the case for 2 or 3, it's still annoying
00:49:50FromDiscord<Elegantbeef> It's a bit annoying cow, but atleast properties are 1 line of code and relatively simple
00:50:05FromDiscord<MadScientistCarl> Actually OCaml still doesn't have good multicore. I'd be writing Haskell instead.
00:50:38FromDiscord<pyolyokh> In reply to @MadScientistCarl "Lol, if OCaml has": I like OCaml but I worry that people aren't going to want to maintain OCaml, if I leave it when I leave a job. There have been some high-profile cases like that, and the language is clearly more esoteric even if it's no Haskell
00:51:07FromDiscord<ronaldinio> But not with Nim?
00:51:22FromDiscord<pyolyokh> not at all with Nim.
00:51:34FromDiscord<MadScientistCarl> I just wish Haskell's tooling is better.
00:51:40FromDiscord<cow> isn't nim more popular than ocaml
00:51:43FromDiscord<pyolyokh> "man I wish this were my favorite language", sure. "man this is Nim oh my god I refuse to touch it", no.
00:52:18FromDiscord<ronaldinio> Well thats the burden of ML
00:53:46FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=4lfr properties for unifying access of a field of the same name/type if anyone didnt know how
00:53:49FromDiscord<ronaldinio> You know if you write perl someone will maintain it
00:54:23FromDiscord<ronaldinio> %^}
00:54:32FromDiscord<MadScientistCarl> Well, you can always use F#
00:54:59FromDiscord<MadScientistCarl> I just don't like .Net because I never understand its package management system
00:55:45FromDiscord<<She>Horizon</Her>> Gradle took some time for me to understand in the jvm ecosystem, i refused to touch maven, and i have no idea how C# even works
00:56:09FromDiscord<cow> `dotnet add <package name>` and statically compile
00:56:09FromDiscord<Elegantbeef> I swear horizon
00:56:13FromDiscord<cow> forget about package trouble
00:56:14FromDiscord<Elegantbeef> Changing your name that much is a crime
00:56:18FromDiscord<ronaldinio> Gradle is annoying
00:57:16FromDiscord<ronaldinio> I saved an entire rewrite by changing IDE versions that support specific gradle versions etc etc
00:57:32FromDiscord<MadScientistCarl> When using `{.pure.}`, can I hide the top level definition? Otherwise what's the point of putting the enums under a namespace if it collides with top level anyways
00:57:33FromDiscord<Hourglass> Hah, Horizon just never felt like it fit me, and i grew out of Forest, sooo
00:57:47FromDiscord<Hourglass> In reply to @cow "`dotnet add <package name>`": Oh huh
00:57:55FromDiscord<Elegantbeef> Pure is no longer suggested
00:58:10FromDiscord<Hourglass> Yeah isn't it basically useless for non-compiler stuff?
00:58:11FromDiscord<cow> you can compile F# into a standalone binary with all dependencies included
00:58:15FromDiscord<Elegantbeef> It used to be a forced namespace but the semantics changed
00:58:28FromDiscord<Elegantbeef> And now it's pretty much "Hey this is only used if you have two enum fields that overlap"
00:58:29FromDiscord<cow> and I think dotnet installs dependencies locally in the project with `dotnet add`
00:58:39FromDiscord<Elegantbeef> Nim doesnt really do namespaces
00:58:39FromDiscord<Elegantbeef> It's like the antithesis to namespaces
00:59:04FromDiscord<MadScientistCarl> Well it collides with a type name
00:59:19FromDiscord<Elegantbeef> And with overloadableenums it's now further useless since we can have enums of the same name
00:59:20FromDiscord<pyolyokh> Then you have to change the name
00:59:38FromDiscord<MadScientistCarl> So `{.pure.}` is useless?
00:59:43FromDiscord<Elegantbeef> Yes
01:00:02FromDiscord<cow> the old idiomatic name way used to be prefixing with the abbreviation of the enum type iirc
01:00:06FromDiscord<Elegantbeef> Pure was changed into "Only if two enums clash are you required to use the Enum type"
01:00:16FromDiscord<Elegantbeef> Yep
01:00:17FromDiscord<pyolyokh> the stdlib is very old to excuse the design, but stuff like <https://nim-lang.org/docs/osproc.html> poEvalCommand, poThis, poThat, always works
01:00:18FromDiscord<cow> so a NodeKind enum would have elements like nkTerm, nkFactor, etc
01:00:26FromDiscord<Elegantbeef> An annoying Hungarian notation
01:00:35FromDiscord<pyolyokh> nah that's just C-style namespacing
01:00:43FromDiscord<cow> it's hungarian notation literally
01:01:03FromDiscord<pyolyokh> it might be technically hungarian notation but you're thinking beyond the namespace. Hungarian Notation can get a lot worse
01:01:15FromDiscord<cow> worse? who said it's bad
01:01:24FromDiscord<Elegantbeef> You could implement the enum in it's own module, and use it in your own model
01:01:27FromDiscord<Elegantbeef> moduel\
01:01:32FromDiscord<cow> it's clearly not bad, otherwise people wouldn't be using it
01:01:40FromDiscord<pyolyokh> I feel like it being bad is nearly a universally held position ...
01:01:50FromDiscord<cow> annoying? sure, but it solves a problem
01:01:59FromDiscord<MadScientistCarl> OK... the current limitation already makes thing very hard to find in different modules
01:02:10FromDiscord<Elegantbeef> What?
01:02:37FromDiscord<MadScientistCarl> It's really hard to not put everything in a single giant source file with an equally big type block
01:02:53FromDiscord<Elegantbeef> Enums dont depend on anything
01:02:57FromDiscord<Elegantbeef> They surely can be seperated
01:03:22FromDiscord<cow> initially it took a bit for me to learn to deal with no cyclic imports
01:03:28FromDiscord<cow> i got better at it
01:03:49FromDiscord<MadScientistCarl> Then I have a file just for the enum, one giant file to hold the actual type that use this enum, and multiple other files that implement behavior
01:04:13FromDiscord<cow> you can compose multiple types into eachother
01:04:15FromDiscord<Elegantbeef> Then change the enum name and carry one
01:04:16FromDiscord<Elegantbeef> on
01:04:25FromDiscord<Elegantbeef> Alternatively share your code and we can give suggestions
01:04:27FromDiscord<pyolyokh> if you're wanting to do that to get namespacing, that won't help unless you static import the enum module
01:04:51FromDiscord<MadScientistCarl> Well... I am in the middle of a refactor so it might not be very sharable
01:04:59FromDiscord<pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4lfu
01:05:20FromDiscord<MadScientistCarl> Ideally I would like `E.A` only, and no `A`
01:05:22FromDiscord<Elegantbeef> Sure but Nim's symbol rules means that a symbol inside this module is always selected first
01:06:24FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4lfv
01:06:35FromDiscord<Elegantbeef> That wont compile due to having no `$`
01:06:50FromDiscord<Elegantbeef> Nim very much doesnt do namespaces intentionally
01:06:55FromDiscord<Elegantbeef> So what you're after is kinda against the grain
01:08:20FromDiscord<Elegantbeef> You could also use a macro do generate this https://github.com/beef331/micros/blob/master/tests/test1.nim#L129-L149
01:08:47FromDiscord<T0lk1en> Hey if I have a parameter in a proc that is all caps. What does that mean?
01:08:54FromDiscord<Elegantbeef> It's all caps
01:09:10FromDiscord<sealmove> Hi, `StringStream(s)` errors with `invalid object conversion` (`s` is a Stream) which I find weird because I see this conversion used in `std`. What could be wrong?
01:09:15FromDiscord<cow> sent a code paste, see https://play.nim-lang.org/#ix=4lfw
01:09:19FromDiscord<cow> and the type name would be different
01:09:38FromDiscord<Elegantbeef> That defeats the purpose of enums↵(@cow)
01:09:38FromDiscord<pyolyokh> In reply to @รєคɭ๓๏שє "Hi, `StringStream(s)` errors with": you might not have the converters or whatever that std is using for them
01:09:46FromDiscord<Ayano> is "or" the bit or operator or am i missing something?
01:10:00FromDiscord<pyolyokh> In reply to @Ayano "is "or" the bit": "or" is also the bit operator
01:10:24FromDiscord<Elegantbeef> `StringStream(s)` is an invalid conversion if the object wasnt created as a `StringStream`
01:10:24FromDiscord<Elegantbeef> You cannot down cast only up cast
01:10:59FromDiscord<sealmove> In reply to @Elegantbeef "`StringStream(s)` is an invalid": oh
01:11:05FromDiscord<Elegantbeef> This does the same
01:11:08FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4lfx
01:11:11FromDiscord<cow> In reply to @Ayano "is "or" the bit": it's the bit operator if it's operating on ints, it's boolean op if it's operating on booleans
01:11:24FromDiscord<Elegantbeef> It's one of the unfortunate choices of nim
01:11:33FromDiscord<Elegantbeef> it should be like `band` and `bor` or something akin
01:11:37FromDiscord<cow> why?
01:11:48FromDiscord<Elegantbeef> Cause it makes it hard to find order of operation issues
01:11:48FromDiscord<Ayano> In reply to @cow "it's the bit operator": when i or the two ints 249 and 128 together, it still gives me 249
01:12:19FromDiscord<pyolyokh> yes, that's the correct result
01:12:22FromDiscord<Elegantbeef> You might not know binary operators
01:12:27FromDiscord<pyolyokh> were you wanting `and`?
01:12:32FromDiscord<Ayano> In reply to @pyolyokh "yes, that's the correct": nvm i am stupid
01:12:36FromDiscord<Elegantbeef> Bitwise or keeps all bits that are on
01:12:42FromDiscord<Elegantbeef> In either value
01:12:49FromDiscord<Elegantbeef> 128 and 246 both have the second last bit on
01:13:03FromDiscord<Elegantbeef> 249\
01:13:49FromDiscord<cow> In reply to @Elegantbeef "Cause it makes it": fair
01:14:21FromDiscord<cow> or should have lower precedence than most other operators tho, right
01:14:32FromDiscord<MadScientistCarl> If I use `ref object` as key to tables, does its address get hashed or its content?
01:16:35FromDiscord<cow> what you get is hash not being defined
01:17:02FromDiscord<cow> source: just tried
01:17:10FromDiscord<sealmove> why is `readAll` blocking when my stream is being appended to constantly..... Shouldn't it read up until the moment of the call, find the end of Stream, and return?
01:17:38FromDiscord<cow> In reply to @cow "what you get is": so you need to define hash() for your type before you can use it as key
01:20:27FromDiscord<Elegantbeef> Or use `-nimPreviewHasRef`
01:20:42FromDiscord<Elegantbeef> > Important\: Use -d\:nimPreviewHashRef to enable hashing refs. It is expected that this behavior becomes the new default in upcoming versions.
01:20:49FromDiscord<pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4lfA
01:21:00FromDiscord<Elegantbeef> It hashes the reference not value
01:21:10FromDiscord<Elegantbeef> Cause it should match `==` for the type
01:21:15FromDiscord<sealmove> In reply to @รєคɭ๓๏שє "why is `readAll` blocking": I don't see any blocking operation here https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/streams.nim#L261 It should break because of `readBytes == 0`...
01:21:17FromDiscord<Elegantbeef> And by default `==` is reference comparison of pointers
01:23:01FromDiscord<Elegantbeef> `readData` reads all that is there
01:23:09FromDiscord<pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4lfC
01:23:42FromDiscord<Elegantbeef> https://nim-lang.org/docs/asyncfile.html is non blocking
01:23:58FromDiscord<pyolyokh> man 2 read: `On success, the number of bytes read is returned (zero indicates end of file),`
01:24:00FromDiscord<sealmove> and the only way to avoid blocking is to call `.atEnd` before reading every single byte?
01:24:12FromDiscord<Elegantbeef> Nope
01:24:27FromDiscord<Elegantbeef> `readChar` is also likely blocking
01:24:47FromDiscord<sealmove> yes I can avoid calling it if `.atEnd` returns true
01:25:15FromDiscord<Elegantbeef> You can also just use `asyncFile`
01:25:53FromDiscord<sealmove> I can't. I am using a Stream returned from `osproc`
01:26:11FromDiscord<Elegantbeef> https://nim-lang.org/docs/asyncfile.html#newAsyncFile%2CAsyncFD
01:26:39FromDiscord<MadScientistCarl> I start to feel like Nim is a supercharged Python
01:26:46FromDiscord<sealmove> it's not a file, it's the `errorStream` of a process
01:26:47FromDiscord<pyolyokh> the streams API isn't going to change how the underlying I/O works. If you're reading from a file or a socket and you don't want to block in 99% of cases, you need a selector or concurrency or something truly awful like your own manually polling with a sleep in it. ↵And that's still not 100% of cases. For 100% of cases you need actual threads.
01:27:02FromDiscord<Ayano> my uint with the value 5 shifted 7 to the left (shl 7) equals 128, why?
01:27:04FromDiscord<Elegantbeef> https://nim-lang.org/docs/osproc.html#errorHandle%2CProcess↵(@sealmove)
01:27:14FromDiscord<Elegantbeef> Wrap around shifting
01:27:18FromDiscord<Elegantbeef> It's UB
01:27:25FromDiscord<pyolyokh> because people will do something like use ceph for the filesystem and syscalls that never, ever block, start blocking when ceph is broken
01:27:41FromDiscord<Ayano> In reply to @Elegantbeef "Wrap around shifting": is there none warp around shifting
01:28:03FromDiscord<Ayano> and even if it wraps around my output has a zero less then my input
01:28:07FromDiscord<Hourglass> In reply to @MadScientistCarl "I start to feel": Iirc it's been said it wss more based on Pascal and OCaml
01:28:30FromDiscord<Hourglass> But i see your point, what made it easy for me to adjust to is that I'm a python programmer too
01:28:59FromDiscord<Hourglass> The biggest learning curve was lack of classes but objects and how procs work more than make up for it
01:29:01FromDiscord<jtv> Beef, if I've got a static vtable, and I want to use the function in a macro, is there a Lit() equiv, or am I best off just keeping the string around to generate the call?
01:29:24FromDiscord<Elegantbeef> `Lit()`?
01:29:43FromDiscord<MadScientistCarl> Well, the dispatch rules are more like Julia
01:29:55FromDiscord<jtv> sorry meant newLit()
01:30:06FromDiscord<Elegantbeef> I dont follow the question
01:31:06FromDiscord<jtv> I've got a function pointer statically in an array. I want to generate the code to dereference it from the function pointer, not from a string with the name
01:32:02FromDiscord<Elegantbeef> What's the issue with just `myArray[myId + myProcOffset](args)` through a `.()` macro
01:32:36FromDiscord<Elegantbeef> https://nim-lang.org/docs/manual_experimental.html#special-operators-dot-operators
01:33:10FromDiscord<Elegantbeef> For traitor that's what i do to make a low cost access of the vtable
01:34:21FromDiscord<jtv> I'll check it out. I'm actually iterating through what is an array of tuples, and calling a proc to return a tree to generate some checks for each tuple. So I guess the question is really, if I've got this function pointer statically how do I get it as a nim node?
01:34:22FromDiscord<Elegantbeef> It's hard to say what to do given the little information i've got here
01:36:42FromDiscord<Elegantbeef> How do you store the data, in a macro cache?
01:37:47FromDiscord<jtv> No, I haven't actually dug into macro caches, been a while since I even ran across them, so didn't remember they existed. Just in a const array of tuples right now
01:37:52*ltriant quit (Ping timeout: 272 seconds)
01:38:14FromDiscord<Elegantbeef> So then it'd be `myConstArray.getInst`
01:38:20FromDiscord<pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4lfH
01:38:21FromDiscord<Elegantbeef> Then you select the value you want
01:38:32FromDiscord<Elegantbeef> You can just make table a const there
01:38:57FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4lfI
01:39:03FromDiscord<Elegantbeef> That statically folds in
01:39:43FromDiscord<Elegantbeef> If you look at the generated C it'll very likely just have `anonymousgenSym()` and `a = anonymousGensym`
01:41:53FromDiscord<jtv> Where is getInst declared? Not finding it in the docs
01:42:08FromDiscord<Elegantbeef> `std/macros`
01:42:18FromDiscord<Elegantbeef> Sorry `getImpl`
01:42:58FromDiscord<jtv> Ah, I'd been trying that earlier. Maybe I was doing something wrong then
01:43:05FromDiscord<jtv> Will try again
01:43:28FromDiscord<Elegantbeef> It's `getImpl` on your array that should return a const definition
01:43:31FromDiscord<Elegantbeef> You then can walk the tree to get what you want statically
01:45:49FromDiscord<jtv> Well, I was actually declaring the array as static:
01:46:09FromDiscord<jtv> sent a code paste, see https://play.nim-lang.org/#ix=4lfL
01:46:37FromDiscord<jtv> The second argument fptr, how to set that is my question
01:46:52FromDiscord<Elegantbeef> so then it'd be `newLit(x)`
01:46:52FromDiscord<Elegantbeef> It's still hard to say the best avenue
01:47:42FromDiscord<jtv> newLit(spec.fptr) should work?? I can obviously get it to work if I use a string and an ID node instead of trying to reference the function pointer
01:48:17FromDiscord<Elegantbeef> I'll be honest i'm very very uncertain what you're doing
01:48:47FromDiscord<jtv> It's fine, too hard to trim down to something small and not that important 🙂
01:48:48FromDiscord<jtv> Thanks
01:51:00FromDiscord<Girvo> In reply to @mratsim "and if you need": Yooo that's huge: not for this use-case, but as a base for writing a DSL/inline assembler for the ESP32's ULP coprocessor haha
01:52:00FromDiscord<auxym> sent a code paste, see https://play.nim-lang.org/#ix=4lfO
01:52:13FromDiscord<auxym> cannot open (apparently an empty string)
01:55:26FromDiscord<that_dude> A bit of a weird question, but I need a data type that is 4 or less bytes big but acts like a float bit with higher precision(or a smaller size). I'm working with bouncing rays off of circles. Accuracy/correctness isn't as important as precision in my case. The angle stops changing when I go by increments of 1e-16. I think I would only need to cover a range of 0-1 or 0-6.28..., afaik
01:57:19FromDiscord<that_dude> Does something like this exist?
02:01:03FromDiscord<hector> In reply to @that_dude "Does something like this": No. 4 bytes = 32 bits. 2^32 ≈ 4.29 billion or 4.29e9. You can't store more values than that in such a small range
02:02:20FromDiscord<that_dude> true, but then why can I still work with precisions of e-14 and get it to work out?
02:02:37FromDiscord<sealmove> @ElegantBeef in tried your suggestion with asynFile. well... I get a Future but this doesn't really help me since I am not trying to delegate the reading of the stream. I just want to read whatever data is availiable at that moment and continue.
02:04:34FromDiscord<hector> In reply to @that_dude "true, but then why": Your question is way too vague and you haven't provided any actual code
02:07:38FromDiscord<MadScientistCarl> Is there something like `todo` that type checks everything?
02:07:50FromDiscord<Rika> In reply to @hector "Your question is way": I think his question made sense
02:08:10FromDiscord<Rika> Note he is currently using floats
02:09:00FromDiscord<that_dude> True, I'm more asking for a poc I'm taking a look at, It's not buggy I'm just wondering if I can get more information in the data type
02:09:35FromDiscord<that_dude> but if it helps, here's what I'm looking at https://media.discordapp.net/attachments/371759389889003532/1064003380894236672/image.png https://media.discordapp.net/attachments/371759389889003532/1064003381124931624/image.png https://media.discordapp.net/attachments/371759389889003532/1064003381330460702/image.png
02:10:01FromDiscord<Rika> There was this alternative data encoding called Posits that provide nicer precision but I never ended up finishing implementing it in Nim
02:10:15FromDiscord<that_dude> In the bottom pic it's recording what circles I'm hitting in the ring
02:10:18FromDiscord<Rika> And it would naturally also be much slower because lack of hardware support iirc
02:10:20FromDiscord<that_dude> (edit) "In the bottom pic it's recording what circles I'm hitting in the ring ... " added "in the first pic"
02:10:43FromDiscord<that_dude> In reply to @Rika "There was this alternative": I'm not to concerned with speed, I'll take a look at that, thanks
02:10:54FromDiscord<Elegantbeef> Just compile the code?↵(@MadScientistCarl)
02:11:08FromDiscord<MadScientistCarl> No, it's for developing
02:11:16FromDiscord<Rika> It’s prolly much harder to implement than you think so I don’t think it’s suitable for you
02:11:26FromDiscord<Elegantbeef> `{.warning: "unimplemented X".}`
02:11:43FromDiscord<MadScientistCarl> sent a code paste, see https://play.nim-lang.org/#ix=4lfS
02:11:49FromDiscord<that_dude> I'll do string manipulations to do it if necessary lol
02:11:52FromDiscord<MadScientistCarl> Now the compiler is going to complain because `discard` doesn't have a type
02:12:09FromDiscord<MadScientistCarl> And the messages aren't helpful, because I haven't written the second `of` yet
02:12:23FromDiscord<Elegantbeef> there is no reversed inference
02:12:29FromDiscord<Elegantbeef> You just put a default value at the end
02:12:35FromDiscord<MadScientistCarl> (edit) "https://play.nim-lang.org/#ix=4lfS" => "https://play.nim-lang.org/#ix=4lfT"
02:12:52FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4lfU
02:12:57FromDiscord<Elegantbeef> then it'd be like `todo(default(myType))`
02:13:36FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4lfV
02:13:37FromDiscord<Elegantbeef> Then you could do `todo(MyType)`
02:13:49FromDiscord<Rika> IIRC you can even just pass result, and it’ll get the type from that
02:14:11FromDiscord<auxym> so... we can't exportC nim types, right?
02:14:12FromDiscord<Rika> For default I mean
02:14:23FromDiscord<Rika> In reply to @auxym "so... we can't exportC": ? I think you can
02:14:27FromDiscord<Elegantbeef> You can exportC nim types, but there isnt much point cause nim doesnt generrate a header
02:14:40FromDiscord<Elegantbeef> There iss a `--header` feature that has since been deprecated
02:14:54FromDiscord<auxym> can I exportc a nim enum to a C typedef enum?
02:15:12FromDiscord<auxym> I dont think I need a header
02:15:29FromDiscord<Elegantbeef> Like i said `exportC` doesnt do anything but give it a fixed name it doesnt generate a C style header
02:16:39FromDiscord<Rika> Huh I never thought of that, what are Nim enums compiled into
02:16:58FromDiscord<auxym> IIRC they
02:17:10FromDiscord<auxym> are compiled to some bare int
02:17:19FromDiscord<auxym> so answering my own question, no
02:17:52FromDiscord<Elegantbeef> They're the smallest sized int that makes sense
02:18:29FromDiscord<MadScientistCarl> How do I specify an iterator type?
02:18:37FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4lfW
02:18:45FromDiscord<Elegantbeef> `iterator(a: int): int`
02:19:01FromDiscord<MadScientistCarl> Can I use it in function arguments?
02:19:13FromDiscord<Elegantbeef> Yes but nim has 2 iterators
02:19:17FromDiscord<Elegantbeef> It has inline and closure
02:19:24FromDiscord<Elegantbeef> You cannot pass inline to procedures
02:19:37FromDiscord<MadScientistCarl> Can I pass something like `table.values` into functions?
02:19:43FromDiscord<Elegantbeef> Nope
02:19:47FromDiscord<Elegantbeef> Cause it's an inline iterator
02:19:57FromDiscord<Elegantbeef> You'd need like slicerator's `asClosure`
02:19:59FromDiscord<Elegantbeef> Or to use a template
02:20:15FromDiscord<Elegantbeef> It's a real shame
02:22:38FromDiscord<Elegantbeef> Or write your own closure generator
02:23:24FromDiscord<Elegantbeef> https://nim-lang.org/docs/manual.html#iterators-and-the-for-statement-firstminusclass-iterators this documents how a little down
02:23:31FromDiscord<Elegantbeef> `Closure iterators are resumable functions....`
02:34:58FromDiscord<MadScientistCarl> What's the best way to reference a sequence's last element? I am using `s[s.high]` now, but there is probablly a better one
02:35:09FromDiscord<Elegantbeef> `s[^1]`
02:35:25FromDiscord<MadScientistCarl> Is that a special index or something?
02:36:02FromDiscord<MadScientistCarl> Oh, it says backward index
02:37:01FromDiscord<Elegantbeef> `BackwardsIndex` is the type
02:39:24FromDiscord<Elegantbeef> Yep Nim's `[]` is all implemented in user space really
02:39:47FromDiscord<Elegantbeef> `a[b..c]` is just `[]` for `Slice[int]` `a[b..^c]` is a `HSlice[int, BackwardsIndex]` and so forth
03:01:55FromDiscord<MadScientistCarl> Does Nim have abstract classes, or "unimplemented" methods?
03:02:33FromDiscord<Elegantbeef> Nope
03:05:28FromDiscord<MadScientistCarl> Do I need to export inherited methods of derived classes?
03:05:43FromDiscord<Elegantbeef> Yes i think the type also needs to be exported
03:06:36FromDiscord<MadScientistCarl> Hmm, if derived class methods are private but base class ones are public, and I am not using the derived class directly, does it still work?
03:06:52FromDiscord<Elegantbeef> I dont recall
03:06:57FromDiscord<Elegantbeef> Give it a whirl is all i can say
03:12:53FromDiscord<Leftbones> Not sure where to ask this, but I can't find anything online about what it means to have a `` in a procedure definition, e.g. `proc foo(int: bar)` vs `proc foo(int: bar)`
03:13:06FromDiscord<Elegantbeef> It's an export marker
03:13:14FromDiscord<Elegantbeef> https://nim-lang.org/docs/manual.html#procedures-export-marker
03:13:20FromDiscord<Leftbones> Excellent, thank you
03:13:36FromDiscord<Leftbones> It's hard to google symbols without associating words, and I wasn't sure what words to associate
03:15:31FromDiscord<nixfreak> Means it’s a public function↵(@Leftbones)
03:15:55FromDiscord<Leftbones> That's neat, I like that.
03:16:09FromDiscord<MadScientistCarl> Apparently, derived class functions don't need to be exported
03:16:38FromDiscord<Leftbones> I wasn't aware there were "class functions" since the classes are more like structs in C?
03:16:57FromDiscord<Elegantbeef> There are methods
03:17:01FromDiscord<Elegantbeef> But mad here is calling them classes
03:17:26FromDiscord<Elegantbeef> "Derived object methods" is the nim way of saying that 😛
03:18:10FromDiscord<MadScientistCarl> Actually, you don't need to export them even if you are calling the method on a derived object directly
03:18:13FromDiscord<Leftbones> I'm used to calling them methods because of C# anyways lol
03:18:48FromDiscord<Leftbones> I'm just looking at this for now and so I assumed class methods weren't really a thing https://nim-by-example.github.io/types/objects/
03:18:59FromDiscord<Leftbones> Any more of a thing than in C, that is
03:19:06FromDiscord<Elegantbeef> Well Nim doesnt have "classes"
03:19:08FromDiscord<Elegantbeef> So they're not a thing
03:19:21FromDiscord<MadScientistCarl> Not sure if that is a good idea, but I guess this way I control access by just exporting the base methods
03:19:24FromDiscord<Elegantbeef> There are a class of procedures called `method`s that use runtime information to dispatch
03:19:39FromDiscord<MadScientistCarl> I call them classes because they have inheritance...
03:20:13FromDiscord<Elegantbeef> I get why you do, i'm just saying that they're not classes since they dont behave anything like classes
03:20:15FromDiscord<Leftbones> In reply to @MadScientistCarl "I call them classes": I get what you mean now, I just got confused for a sec
03:21:29FromDiscord<Elegantbeef> Inheriting objects dont require declaring methods inside of a scope, there is no implcit `self` parameter, everything is free standing so it feels weird to me atleast to call them classes
03:21:42FromDiscord<Elegantbeef> Since it would give the painting that they behave like C++/C#/Python classes
03:22:23FromDiscord<MadScientistCarl> I guess Nim is closer to Common Lisp than C++, then
03:22:24FromDiscord<Elegantbeef> I'm just clearing up any ambiguity, not telling you what you can and cannot say
03:22:38FromDiscord<Elegantbeef> It's closer to pascal or oberon than C++
03:22:41FromDiscord<MadScientistCarl> This just looks more like CLOS than something like C++ classes
03:22:57FromDiscord<Elegantbeef> Nim is quite literally a modern wirth language
03:23:46FromDiscord<Leftbones> I've only been writing nim for about... an hour, but I like it
03:24:08FromDiscord<Leftbones> Reminds me of C just without all the awful crap
03:25:06FromDiscord<Elegantbeef> Hey that
03:25:10FromDiscord<Elegantbeef> 's pretty much what pascal was
03:25:31FromDiscord<Leftbones> Lol I've never played around with pascal but I always liked how readable it was
03:25:33FromDiscord<Elegantbeef> A way of writing low level code without a type system that is as intelligent as a gnat
03:27:09FromDiscord<MadScientistCarl> Not sure if anyone have used Ada
03:27:24FromDiscord<Elegantbeef> I've not but i've looked at it quite a bit
03:27:37FromDiscord<MadScientistCarl> Last time I tried, it was extremely verbose to write
03:28:18FromDiscord<pyolyokh> it was physically painful to write without some editor extensions to save me from all the Words_Like_This
03:28:20FromDiscord<MadScientistCarl> Kind of feels like a 1990s Rust requiring twice as much code
03:28:35FromDiscord<pyolyokh> but apart from that it's a pretty nice language.
03:28:39FromDiscord<Elegantbeef> It's pretty much a very verbose wirth language 😄
03:29:04FromDiscord<Elegantbeef> Though older pascal variants were quite verbose
03:32:27FromDiscord<Leftbones> I have tried and failed at Rust so many times simply because of how janky the syntax can be
03:32:32FromDiscord<Leftbones> Hard to read, harder to write
03:33:12FromDiscord<MadScientistCarl> Rust syntax is not great, but still very expressive
03:33:32FromDiscord<MadScientistCarl> The only thing I don't like about Rust is how big the `target` folder becomes.
03:33:46FromDiscord<Leftbones> I just can't wrap my head around it for some reason
03:33:58FromDiscord<MadScientistCarl> I just can't use it for small tools because of this. However, big projects are excellent.
03:34:20FromDiscord<MadScientistCarl> Plus, rust-analyzer is a very good LSP
03:35:27FromDiscord<Leftbones> I do love that
03:35:29FromDiscord<Leftbones> And clippy
03:35:35FromDiscord<Leftbones> Maybe someday I'll figure it out
03:36:01FromDiscord<Elegantbeef> Just write Nim
03:37:12FromDiscord<MadScientistCarl> Not sure how Nim works in big projects
03:37:34FromDiscord<Leftbones> If someone says Nim isn't ready for production, say "You're not the boss of me" and do it anyways
03:37:36FromDiscord<MadScientistCarl> Given the limitation of module import, I expect to have great trouble
03:37:57FromDiscord<Leftbones> In reply to @Leftbones "If someone says Nim": I stole/paraphrased this from something someone said about Zig, but it applies
03:38:15FromDiscord<MadScientistCarl> I just tried Zig today. The LSP crashes 5 times per second
03:38:20FromDiscord<Elegantbeef> it's not ideal since it lacks cyclical imports, but honestly cyclical imports are a bit ass
03:38:22FromDiscord<MadScientistCarl> I will put it on hold...
03:38:42FromDiscord<Leftbones> Zig is kinda neat, only reason I haven't messed with it much is I don't feel like getting into manual memory management again
03:38:54FromDiscord<MadScientistCarl> Well, if we are talking about Go and Rust's directory-based modules, then it is not a mess
03:39:07FromDiscord<Elegantbeef> Not saying i dont feel the need for them, but sometimes people just use cyclical imports it creates tedious to follow code
03:39:43FromDiscord<MadScientistCarl> My tricky part is that, the data follow a tree structure (nice), but behavior is like a graph
03:39:52FromDiscord<MadScientistCarl> So I have to dump every type into a single file
03:40:31FromDiscord<Elegantbeef> Well one could use `include` to seperate it
03:40:37FromDiscord<MadScientistCarl> Zig can use C/C++ directly, so I can use all the C/C++ packages floating out there
03:40:42FromDiscord<Elegantbeef> Not that i really condone `include`
03:41:00FromDiscord<Leftbones> Yeah Zig being able to drop in to C/C++ makes it easier to use in big projects right away for sure
03:41:01FromDiscord<MadScientistCarl> I don't feel right putting `include` in the middle of a file
03:41:16FromDiscord<Elegantbeef> Zig cannot use C++ directly
03:41:16FromDiscord<Elegantbeef> And i mean Nim has futhark so sorta ditto here
03:41:18FromDiscord<Leftbones> In reply to @MadScientistCarl "I don't feel right": Ugh, I hate when I see that
03:41:37FromDiscord<MadScientistCarl> I tried Zig, going straight into one of the project I use to evaluate a low level language: draw a triangle
03:41:47FromDiscord<MadScientistCarl> Then the moment I import a C header, the LSP crashes
03:41:56FromDiscord<Leftbones> Ope
03:42:24FromDiscord<MadScientistCarl> I haven't drawn a triangle in Nim yet. But I will definitely do so
03:42:33FromDiscord<Leftbones> 🔺
03:42:40FromDiscord<MadScientistCarl> Nah, in Vulkan
03:43:05FromDiscord<Elegantbeef> What?
03:43:27FromDiscord<Elegantbeef> 'ope' is a response in the crash
03:43:58FromDiscord<Elegantbeef> Atleast i assume that's what they meant
03:44:17FromDiscord<pyolyokh> You missed some kind of discord only triangle image
03:44:24FromDiscord<Elegantbeef> No i got that
03:44:33FromDiscord<Elegantbeef> I dont get how that relates to anything 😄
03:44:51FromDiscord<Elegantbeef> I'm going to shutup now
03:45:02FromDiscord<pyolyokh> I think, cheating by running `echo "unicode triangle"` ?
03:45:03FromDiscord<Leftbones> Oh idk, I was just responding to talking about drawing a triangle.
03:45:14FromDiscord<Leftbones> Without using words
03:46:30FromDiscord<MadScientistCarl> I hope Nim can do it
03:46:37FromDiscord<Elegantbeef> It certainly can
03:46:45FromDiscord<Elegantbeef> I've drawn a bit more than a triangle using opengl atleast
03:46:55FromDiscord<MadScientistCarl> There is one Vulkan binding, but I don't think it covers the complete spec
03:47:02FromDiscord<Leftbones> How robust is Nim for game dev?
03:47:06FromDiscord<Elegantbeef> https://streamable.com/csyb0s
03:47:08FromDiscord<Elegantbeef> I mean it works for me
03:47:10FromDiscord<MadScientistCarl> You can use Raylib
03:47:20FromDiscord<Leftbones> Been using Raylib for a long time, so that's good
03:47:20FromDiscord<MadScientistCarl> I tried the binding, and it is good
03:47:26FromDiscord<Leftbones> More recently Raylib-cs
03:47:53FromDiscord<Elegantbeef> That video is opengl + sdl2, not raylib
03:48:01FromDiscord<Leftbones> Even more impressive
03:48:38FromDiscord<MadScientistCarl> That's great
03:49:00FromDiscord<MadScientistCarl> Does Nim have a good ECS?
03:49:06FromDiscord<Elegantbeef> Polymorph
03:49:51FromDiscord<MadScientistCarl> Hmmm, Nim's extension's indentation choices are really weird
03:52:13FromDiscord<Leftbones> What's weird about them?
03:53:12FromDiscord<MadScientistCarl> sent a code paste, see https://play.nim-lang.org/#ix=4lgc
03:54:58FromDiscord<Leftbones> Oh I haven't noticed anything like that (in vscode)
03:57:08FromDiscord<Elegantbeef> Nim pretty does a funny job formatting code
04:00:46FromDiscord<MadScientistCarl> Do nested function work the same as lambda?
04:01:09FromDiscord<MadScientistCarl> Except for the name part
04:01:54FromDiscord<Leftbones> I missed something earlier, what exactly about the import system makes Nim not ideal for large projects?
04:02:47FromDiscord<MadScientistCarl> Ordered declaration without forward declaration. This means if your types depend on each other, you need to put them all in the same block.
04:03:07FromDiscord<pyolyokh> In reply to @Leftbones "I missed something earlier,": there's no concrete advantage. You just can't organize modules across multiple files freely
04:03:13FromDiscord<MadScientistCarl> If your methods reference a whole bunch of types in a "graph" fashion, you pretty much have to put all types in the same file
04:03:14FromDiscord<pyolyokh> (edit) "advantage." => "disadvantage."
04:03:18FromDiscord<Leftbones> Ah
04:12:45FromDiscord<exelotl> In what language _can_ you have mutually dependent types in different files?
04:13:02FromDiscord<MadScientistCarl> Rust can
04:13:11FromDiscord<MadScientistCarl> Go also can, but that
04:13:26FromDiscord<MadScientistCarl> (edit) "that" => "that's because it treats directory as a package, not file"
04:14:03FromDiscord<MadScientistCarl> Even C can. You need to forward declare and use pointers, though
04:14:27*ltriant joined #nim
04:15:48FromDiscord<exelotl> Nim can do it the same as C it seems: https://nim-lang.org/docs/manual_experimental.html#package-level-objects
04:16:07FromDiscord<MadScientistCarl> That
04:16:12FromDiscord<MadScientistCarl> (edit) "That" => "That's experimental"
04:18:27FromDiscord<exelotl> Yes, but it's not gated behind a flag or anything, you can just use it. And in the future it will probably become a no-op because the language will have better support for circular imports
04:19:59FromDiscord<MadScientistCarl> That doesn't quite solve it
04:20:00*ltriant quit (Ping timeout: 272 seconds)
04:20:05FromDiscord<MadScientistCarl> Because the types are still incomplete
04:22:10FromDiscord<exelotl> You can also cheat pretty easily, just declare the troublesome field as a `pointer` and define an accessor that casts it to `ptr Foo` as soon as Foo is known
04:23:59FromDiscord<MadScientistCarl> That brings unsafe operations
04:24:20FromDiscord<MadScientistCarl> A huge source is annoying to edit, but bringing pointers might be more dangerous
04:24:51FromDiscord<T0lk1en> In reply to @MadScientistCarl "A huge source is": What is the use of manual mem management.
04:24:58FromDiscord<T0lk1en> I’m new
04:25:10FromDiscord<MadScientistCarl> Like, interfacing with C?
04:25:15FromDiscord<T0lk1en> Yeah
04:25:34FromDiscord<MadScientistCarl> Or if you need absolute performance, or if automatic mem management is not smart enough
04:26:50FromDiscord<T0lk1en> Gotcha
04:28:14FromDiscord<exelotl> In reply to @MadScientistCarl "That brings unsafe operations": If that's a concern you could abstract the pattern away behind a macro to make it safe again
04:28:52FromDiscord<MadScientistCarl> I haven't learned macros yet
04:35:18FromDiscord<exelotl> Hmm having mutually recursive ref types across module boundaries seems hard though, my idea still only works for pointers
04:35:28FromDiscord<huantian> In reply to @Elegantbeef "Nim pretty does a": beef when are we making a better nim formatter and linter
04:35:47FromDiscord<Elegantbeef> When i really care about code formatting
04:36:35FromDiscord<exelotl> I don't get why you'd need them though tbh, putting mutually recursive types in the same file seems like the correct approach
04:37:38FromDiscord<jtv> There are plenty of use cases in large systems where somewhat loosely related types end up having cycles, and not necessarily directly.
04:38:04FromDiscord<huantian> Why don’t you care about code formatting it’s super useful when people give you weirdly formatted code to fix!
04:42:18FromDiscord<Elegantbeef> Formatting isnt the top 10 things i need to fix
04:44:19FromDiscord<MadScientistCarl> How is `Option` types actually used?
04:44:37FromDiscord<MadScientistCarl> I looked at the example, there seem to be a `isSome` field but there isn't
04:44:45FromDiscord<jtv> It's a method
04:45:17FromDiscord<MadScientistCarl> OK... I forgot to import it
04:46:21FromDiscord<huantian> Mood
04:46:49FromDiscord<jtv> `https://play.nim-lang.org/#ix=4lgh
04:47:01FromDiscord<jtv> Oh you figured it out, good
04:48:17FromDiscord<MadScientistCarl> Thanks
04:48:58FromDiscord<MadScientistCarl> Huh, I can't assign a derived class object to a base field?
04:49:34FromDiscord<jtv> Sure you can, though you have to cast it to the base type I believe
04:49:47FromDiscord<Elegantbeef> You dont have to
04:49:54FromDiscord<Elegantbeef> `var parent: Parent = Child()` is valid
04:50:05FromDiscord<MadScientistCarl> I get invalid object assignment
04:50:39FromDiscord<Elegantbeef> Are you using `ref object of RootObj`?
04:50:57FromDiscord<MadScientistCarl> No, just `object of RootObj`
04:51:28FromDiscord<Elegantbeef> There's your issue
04:51:34FromDiscord<Elegantbeef> Stack based inheritance doesnt allow that
04:51:44FromDiscord<Elegantbeef> You should almost always do `ref object of`
04:52:54FromDiscord<MadScientistCarl> I guess I can also have a final object with proc fields..
04:53:34FromDiscord<MadScientistCarl> Then I never worry about ref's implications
05:06:02*azimut quit (Ping timeout: 255 seconds)
05:07:41*mikess joined #nim
05:12:59*mikess quit (Quit: leaving)
05:15:31FromDiscord<Leftbones> Anyone have ideas on how I could force illwill to let me use true color ansi escape codes?
05:16:45FromDiscord<Elegantbeef> Aside from forking it to add it, you could just quote everything you're outputting with true colour possibly
05:18:35FromDiscord<Leftbones> illwill's `write` procedure doesn't seem to want to parse the escape codes properly, depending on how I do it, I either get no change, or it prints the code as a string
05:19:16FromDiscord<Elegantbeef> Ah then seems you need to fork to add true colour support
05:19:19FromDiscord<Leftbones> I saw that std/terminal supports true color now but can't quite understand how to use it
05:19:46FromDiscord<Leftbones> illwill and terminal both use the same system for colors so I think if I could figure that out I could shoehorn it in there
05:22:53FromDiscord<Elegantbeef> Terminal doesnt support it afaik
05:23:12FromDiscord<Leftbones> Idk I found this https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/colors.nim
05:23:16FromDiscord<Elegantbeef> It just has features to enable/disable it
05:23:28FromDiscord<Leftbones> A lot more colors in there, at least.
05:23:53FromDiscord<Elegantbeef> oh yea https://nim-lang.org/docs/terminal.html#ansiForegroundColorCode%2CColor
05:24:11FromDiscord<Leftbones> Yeah I found that, haven't figured out how to use it though
05:24:22FromDiscord<Leftbones> Oh wait
05:24:40FromDiscord<Leftbones> AHA
05:24:50FromDiscord<Elegantbeef> `ansiForeGroundColorCode(colAqua) & myStr & ansiResetCode`
05:24:52FromDiscord<Leftbones> Okay, gotta pass in the color from `colors` INTO that
05:24:55FromDiscord<Leftbones> Yep, that did it
05:27:17FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4lgo
05:27:40FromDiscord<Leftbones> No such thing!
05:34:02*arkurious quit (Quit: Leaving)
05:36:04FromDiscord<Leftbones> Seems to be working, partially at least. Printing in some areas is instead giving me a large black box. It's a start though.
05:40:08FromDiscord<Leftbones> Example, first image is without calling `truecolor` at all, second is calling it just on the "Normal" text (which is printed separately from "0:0") https://media.discordapp.net/attachments/371759389889003532/1064056370506256445/image.png https://media.discordapp.net/attachments/371759389889003532/1064056370799845446/image.png
05:40:46FromDiscord<Leftbones> That might have to do with the order in which I am printing things, since I didn't put too much thought into it. I'll have to tinker a bit.
05:41:56FromDiscord<Elegantbeef> Yet another TUI text editor? 😄
05:42:05FromDiscord<Leftbones> Lol it's my go-to for when I'm tinkering with a new language
05:42:35FromDiscord<Leftbones> And yes, because there STILL isn't a perfect one! 😆
05:43:30FromDiscord<Rika> still, assuming there ever will be
05:43:46FromDiscord<Leftbones> It'll only happen if people keep trying I suppose
05:43:56FromDiscord<Leftbones> Helix is close, perhaps as close as we've been so far
05:48:07FromDiscord<Makoren> software is never perfect
05:48:10FromDiscord<Makoren> there's always something
05:48:19FromDiscord<Leftbones> Yeah it's an oxymoron for sure
05:48:38FromDiscord<Leftbones> But I like making text editors :MarioShrug:
07:23:14FromDiscord<ShalokShalom> In reply to @MadScientistCarl "There is one Vulkan": There is also a binding to Unreal 5↵https://github.com/jmgomez/NimForUE
07:23:58FromDiscord<ShalokShalom> Godot 3 used to be supported, we will see if anybody does one for 4↵↵Does that count as Vulkan binding? 😀
07:40:22*ltriant joined #nim
07:48:23*ltriant quit (Ping timeout: 268 seconds)
08:19:06*tiorock joined #nim
08:19:06*tiorock quit (Changing host)
08:19:06*tiorock joined #nim
08:19:06*rockcavera quit (Killed (copper.libera.chat (Nickname regained by services)))
08:19:06*tiorock is now known as rockcavera
08:37:13FromDiscord<Phil> So normal nim code is code that transforms via established ways of transforming expressions into standard nim node patterns that later get further compiled.↵So you have 2 elements: 1) Nim Code - 2) Standard Nim node pattern↵Macros are ways to transform non-standard nim code into those standard nim-node patterns.↵Are there valid nim node patterns that are impossible to build with normal nim code, that you can only build with macros and
08:37:37FromDiscord<Phil> (edit) removed "of transforming expressions"
08:38:37FromDiscord<Rika> gensym
08:39:07FromDiscord<Phil> Could you elaborate? I'm not sure what you mean by that
08:39:52FromDiscord<Rika> You can’t make symbols that look like gensym symbols outside of metaprogramming
08:40:03FromDiscord<Rika> Contains singular ` iirc
08:45:18FromDiscord<Phil> Huh, interesting
08:45:23FromDiscord<Elegantbeef> you can just do `var a {.gensym.} = 300`
08:45:33FromDiscord<Elegantbeef> Macros are generally only capable of what you can manually write
08:45:40FromDiscord<Elegantbeef> They just allow you to abstract that away
08:46:02FromDiscord<Elegantbeef> there are some things they can do like "access a private procedure from another module"
08:46:22FromDiscord<Elegantbeef> But to do that you have to pass them the private procedure in some way
08:46:43FromDiscord<Rika> In reply to @Elegantbeef "you can just do": Really, never seen that construct before
08:47:52FromDiscord<Elegantbeef> > fatal error\: error writing to /tmp/ccPHFJbH.s\: No space left on device↵> Uh oh playground needs to clear caches
08:48:01FromDiscord<Elegantbeef> oh it doesnt seem to work variables, might only work inside a template
08:48:36FromDiscord<untoreh> is there a way to pass build flags for each dependency in nimble file?
08:49:10FromDiscord<Elegantbeef> No
08:49:19FromDiscord<Elegantbeef> That doesnt make much sense
08:50:15FromDiscord<Elegantbeef> Yea seems like the gensym pragma only works inside a template on a procedure
08:50:51FromDiscord<Phil> In reply to @Elegantbeef "That doesnt make much": It does when 2 packages rely on the same `define` flag and you really only want one effect
08:51:04FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4lh8
08:51:27FromDiscord<Elegantbeef> What\\
08:52:28FromDiscord<Elegantbeef> "I want to build this package with -d\:ssl, but this one without" doesnt seem to be sensible to me
08:52:48FromDiscord<Elegantbeef> Or "I want to build this package with --mm\:arc and this one with --mm\:refc"
08:52:55FromDiscord<untoreh> I guess il just fork the package then
08:53:01FromDiscord<untoreh> fork everything!
08:53:05FromDiscord<Phil> More along the lines of "I want to build this packge with -d:takeShortcuts but this other package without"
08:53:22FromDiscord<Phil> And for some backass reason they both took the same custom `takeShortcuts` name
08:54:15FromDiscord<Elegantbeef> Well that's a issue + PR to fix it in a future version
08:54:29FromDiscord<Phil> Basically when different people use the same flag name for different things
08:54:51FromDiscord<Phil> Yeh, imo namespacing those may be a requirement
08:55:19FromDiscord<Elegantbeef> I think there is a whole `--define:a.b` feature in nim2.0
08:55:20FromDiscord<Phil> Like how norm specifies that enabling/disabling logging inside of it can be compiled in/out with `-d:normDebug`
08:55:23FromDiscord<Elegantbeef> Or it might be an RFC
08:55:56FromDiscord<Elegantbeef> But yes, if a define is ambiguous, it needs to be fixed
08:56:36FromDiscord<untoreh> there are packages that when installed build some cli tools can it be disabled?
08:56:40FromDiscord<Elegantbeef> Plus Nim doesnt really have libraries, it sorta does but yea
08:57:55FromDiscord<untoreh> you can do `nimble install -d` but, when you are inside a project and do `nimble build/run` it still builds them
08:58:18FromDiscord<Phil> I don't understand, you want to compile your project without compiling your dependencies in?
08:58:32FromDiscord<Elegantbeef> I dont follow either
08:58:34FromDiscord<untoreh> some dependencies build some cli tools that are not needed
08:59:09FromDiscord<Phil> That's a PR to the depdendency, asking them to provide a flag to enable/disable that CLI tool... is this nimibook?
08:59:40FromDiscord<untoreh> no leveldb
09:00:21FromDiscord<Elegantbeef> What's even the issue with building it?
09:01:02FromDiscord<Phil> Eats compile time I'd imagine, not sure how much but if you don't need to use it and have to pay the compilation-time over and over I'd imagine it gets annoying
09:01:04FromDiscord<Elegantbeef> If you're actively testing your code by running `nimble run` you're already in a place of sadness as even without any of that shit it's slow as helll
09:01:36FromDiscord<Elegantbeef> `nim c -r ./src/bleh.nim` is much quicker than calling a nimble task to build your code
09:01:59FromDiscord<Elegantbeef> Atleast in my experience i just use nim directly
09:02:04FromDiscord<untoreh> it builds a leveldbtool, but I have the library build locally, but I can't pass the path when it builds the clitool, so it fails since it looks in the system path
09:02:17FromDiscord<untoreh> I guess I just have to disable that
09:02:26FromDiscord<Phil> It is faster, to me nimble tasks were more reproducible when transferring code between machines because it installs the dependencies for you
09:02:29*kenran joined #nim
09:02:33FromDiscord<Elegantbeef> Yea then make a PR to add a define i guess
09:02:44FromDiscord<Phil> And the time difference isn't that huge when you're already waiting 30-40s either way
09:02:52FromDiscord<Elegantbeef> Phil i'm not saying dont use `nimble test` and `nimble run` to test the code
09:03:07FromDiscord<Elegantbeef> Why the fuck are you waiting 30-40s?!
09:03:08*kenran quit (Remote host closed the connection)
09:03:10FromDiscord<Elegantbeef> My game compiles in 3s
09:03:14FromDiscord<Phil> (edit) "It" => "Not using nimble tasks"
09:03:36FromDiscord<Phil> Fucktons of generics I assume
09:04:30FromDiscord<Elegantbeef> Yea a rebuild of the nim compiler isnt even 30-40s here in most cases
09:04:44FromDiscord<Elegantbeef> So you want me to look at your project 😛
09:05:08FromDiscord<Phil> Its webdev and I don't use acronym, you'll run away screaming 😛
09:05:27FromDiscord<Phil> Anyway, I need to upgrade it to work with nim 2.0, doesn't compile under 1.9.1
09:06:16FromDiscord<Elegantbeef> I'm just amazed that your project takes so long to compile, how many loc is it?
09:06:37FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lhd
09:06:58FromDiscord<Elegantbeef> for pre 2.0, yes
09:07:08FromDiscord<Phil> I want to compile under 1.9.1
09:07:20FromDiscord<Elegantbeef> well with 2.0 `addr` is the same as `unsafeaddr`
09:07:25FromDiscord<Phil> Well, have to, I make use of various lib fixes that aren't available on 1.6.10
09:08:00FromDiscord<Phil> Okay, in that case I'm confused.↵The output [0].addr line explodes with:↵`Error: expression has no address; maybe use 'unsafeAddr`
09:08:32FromDiscord<Phil> This is a part of my code where I actually do not fully understand how it works, so I'm not really sure how to fix it
09:09:06FromDiscord<Elegantbeef> Yea on 2.0 that's the same, so uhh regression
09:09:21FromDiscord<Elegantbeef> Commit?
09:09:29FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lhg
09:09:48FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lhh
09:09:49FromDiscord<Phil> Wait... that's not right
09:09:50FromDiscord<Phil> one sec
09:10:01FromDiscord<Elegantbeef> Lol
09:10:02FromDiscord<Elegantbeef> Well there's your problem
09:10:12FromDiscord<Phil> God damn I was on 1.6.10 for a brief stint to write examples for sb
09:10:25FromDiscord<Phil> Ohhhh right now I remember
09:10:53*jjido joined #nim
09:10:54FromDiscord<Phil> I use my own database pool and that one still relies on db_sqlite and the like to be available as per the usual
09:11:19FromDiscord<Phil> I'd swap to norms but norm has the same issue due to one of its dependencies
09:13:46FromDiscord<Elegantbeef> What's your projects public repo again?
09:15:06*krux02 joined #nim
09:25:41FromDiscord<Phil> Which one? The connection pool one?↵Tinypool↵The one with 11k loc that currently doesn't compile because tinypool isn't compatible with the changes made to db_sqlite and consorts?↵Nimstoryfont
09:25:59FromDiscord<Elegantbeef> The latter
09:29:54FromDiscord<Elegantbeef> Hmm with the mass usage of `implDefaults` I probably should help you by making that simpler
09:30:24FromDiscord<Elegantbeef> Doing less work on the VM with the same result would help quite a bit
09:30:53FromDiscord<Phil> Yeah I basically have fundamentally like...~25 tables or so
09:31:02FromDiscord<Phil> And I define for every one of those at least 3-5 models
09:31:11FromDiscord<Phil> All of which get implDefaults
09:31:45FromDiscord<Elegantbeef> Yea I think there might be some things I can optimise
09:39:36*rockcavera quit (Remote host closed the connection)
09:42:36FromDiscord<Phil> Though I'd repeat, given how heavily I leverage the compiler to generate dozens of modules worth of code for me via generics, I wouldn't be surprised if that's the issue
09:44:02FromDiscord<Elegantbeef> I mean generics are faster than parsing/semantically checking multiple manual versions
09:44:07FromDiscord<Elegantbeef> Atleast in theory
09:46:05FromDiscord<Phil> Yeh but this is on quite a scale.↵Like, I have ~25 tables/"mini-applications".↵I'm generating at roughly 100 loc's worth for at least half of them.↵The only thing that isn't heavily generic-infested is my de-serialization
09:46:22FromDiscord<Phil> (edit) removed "at" | "100" => "100+"
09:46:33FromDiscord<Phil> (edit) "de-serialization" => "serialization"
09:48:09FromDiscord<Elegantbeef> Hey i'm just doing my part
09:48:18FromDiscord<Phil> Actually let me correct that, I'm generatic at least 200loc worth of code, I'm scratching above 150loc just based on the controllers alone
09:48:19FromDiscord<Elegantbeef> I had some stupid code in constructor that didnt make any sense anywho
09:48:34FromDiscord<Phil> Alrighty, I mean I won't complain about free speed ups 😛
09:48:47FromDiscord<Phil> (edit) "generatic" => "generating"
09:49:02FromDiscord<Elegantbeef> `1.1.1` is out now
09:49:51FromDiscord<Phil> I'll upgrade to it once I can actually compile my project again
09:51:11FromDiscord<Elegantbeef> Yea doubt it'll help much but i was iterating all the fields twice making a collection, then adding those, so it was a shit load of useless work
09:51:25FromDiscord<Elegantbeef> Think i accidently pushed part of a feature i was intending
10:10:23FromDiscord<Phil> Curse me, I really need to set up a proper pipeline for tinypool in order to test postgres docker containers
10:11:13FromDiscord<qb> I'm wrapping a c function which iterates over the system processes. It uses a callback and I'm wondering how I could avoid the global `processList` sequence. How would someone use that function in c? https://play.nim-lang.org/#ix=4lhA
10:44:52*jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…)
10:51:58FromDiscord<pyolyokh> `arg: lm_void_t` is probably there to give you something other than a global to modify
10:52:38FromDiscord<pyolyokh> you'd just need to cast it to/from a `ptr seq[lm_process_t]` or similar
11:04:07FromDiscord<pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4lhS
11:31:24*ltriant joined #nim
11:36:44*ltriant quit (Ping timeout: 260 seconds)
11:47:48*ltriant joined #nim
11:53:17*krux02 quit (Remote host closed the connection)
11:59:23*jjido joined #nim
12:07:12FromDiscord<lignus> sent a code paste, see https://play.nim-lang.org/#ix=4li5
12:09:32FromDiscord<pyolyokh> <https://github.com/nim-lang/Nim/blob/version-1-6/lib/system.nim#L1874>
12:11:24*jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…)
12:32:47FromDiscord<planetis> In reply to @lignus "I find myself writing": why exactly? are you using case objects, distincts or refs?
12:33:20FromDiscord<planetis> there are a few that work for case objects, patty comes to mind but also newer ones.
12:37:30FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lia
12:38:15FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lib
13:01:03FromDiscord<qb> sent a code paste, see https://play.nim-lang.org/#ix=4lii
13:08:16FromDiscord<pyolyokh> sent a long message, see http://ix.io/4lim
13:08:24FromDiscord<pyolyokh> Nim procs by default have a different calling convention
13:26:03FromDiscord<qb> No luck yet. Just looked into the the rust wrapper. Seems like it's the same like we do on nim now. https://github.com/rdbo/libmem/blob/master/libmem-rs/src/lib.rs#L358
13:26:21FromDiscord<MadScientistCarl> Is it possible to change the `.Type` behavior of a distinct type?
13:26:34FromDiscord<MadScientistCarl> Like a custom constructor or something
13:30:59FromDiscord<turbo> sent a code paste, see https://play.nim-lang.org/#ix=4lit
14:17:17*ltriant quit (Read error: Connection reset by peer)
14:19:38FromDiscord<turbo> sent a code paste, see https://paste.rs/8tY
14:22:32*ltriant joined #nim
14:34:08FromDiscord<Dimi> sent a long message, see http://ix.io/4lkD
14:37:40FromDiscord<hotdog> In reply to @Dimi "Dear All, I": Try using tryRecv or peek instead of recv
14:38:54FromDiscord<Dimi> In reply to @hotdog "Try using tryRecv or": Oh thanks a lot. That's a good one indeed and I was definitely skipped that somehow
14:39:13FromDiscord<hotdog> No prob 🙂
14:42:57*azimut joined #nim
14:51:29FromDiscord<voidwalker> About the subject of reading the last line or last N bytes from a stream, without blocking. Is there any particular reason why the current length of the stream is not available in the Stream type? Otherwise, how would one attempt to achieve this, in a stream that is continuously being written to ? (errorstream of a process) ?
14:54:33FromDiscord<MadScientistCarl> Is there a constant for "max value"?
14:54:37FromDiscord<MadScientistCarl> Like max value of float
14:59:38FromDiscord<hotdog> In reply to @MadScientistCarl "Is there a constant": For ints yes it’s high(int) (or high(int32) etc)
14:59:43FromDiscord<hotdog> Floats no
14:59:55FromDiscord<MadScientistCarl> I can use `Inf` for floats,
14:59:55FromDiscord<hotdog> As they go up to +inf
14:59:59FromDiscord<hotdog> Yeah
15:00:42FromDiscord<hotdog> In reply to @voidwalker "About the subject of": What’s the usecase?
15:01:17FromDiscord<voidwalker> @hotdog trying to parse some data the ffmpeg output, which gets continually written to the stream
15:01:23FromDiscord<MadScientistCarl> Are there any machine learning packages in Nim? Even basic ones are good
15:01:27FromDiscord<voidwalker> (edit) "@hotdog trying to parse some data ... the" added "from"
15:04:22FromDiscord<voidwalker> https://nimble.directory/search?query=machine+learning -> https://github.com/can-lehmann/exprgrad
15:04:28FromDiscord<ambient> In reply to @MadScientistCarl "Are there any machine": https://github.com/mratsim/Arraymancer
15:04:58FromDiscord<voidwalker> (edit) "https://nimble.directory/search?query=machine+learning -> https://github.com/can-lehmann/exprgrad ... " added "+ https://github.com/mratsim/Arraymancer"
15:05:39FromDiscord<MadScientistCarl> Thank you
15:08:09FromDiscord<hotdog> In reply to @voidwalker "<@472459996068839424> trying to parse": Could you read the available data (if any) on each loop and add to a buffer you process separately when there is enough info?
15:08:19FromDiscord<hotdog> Or use peekLine or similar
15:08:57FromDiscord<hotdog> When you say “length of the stream” do you mean the amount of buffered-but-unread data?
15:09:02FromDiscord<voidwalker> yes
15:10:31FromDiscord<hotdog> Gotcha
15:10:41FromDiscord<voidwalker> Thing is, I don't want to continually read this stream and update the value i am looking for, I would need a thread for that, or async. I just want to read to the "end" of the stream, on demand, to get the "latest" value
15:11:01*arkurious joined #nim
15:11:17FromDiscord<hotdog> Why would you need a thread or async?
15:11:39FromDiscord<voidwalker> how else would you continually read from that stream without bloicking the main program then ?
15:13:00FromDiscord<hotdog> In reply to @voidwalker "how else would you": Read until there is no remaining data buffered then continue your main loop
15:13:31FromDiscord<voidwalker> @hotdog readAll blocks for some reason, until the stream is actually finished (process ends)
15:14:09FromDiscord<hotdog> In reply to @voidwalker "<@472459996068839424> readAll blocks for": Don’t use readAll
15:14:36FromDiscord<hotdog> Simplest would be to just read char by char until peek throws an ioerror
15:14:56FromDiscord<voidwalker> that would be terribly slow, stream could be a few megabytes
15:15:14FromDiscord<hotdog> There’s maybe a more optimal way of doing it but I can’t check right now
15:15:31FromDiscord<MadScientistCarl> How do I deal with `include` making the editor lint everything as error?
15:15:33FromDiscord<hotdog> You could also peekLine and do it line by line
15:16:26FromDiscord<voidwalker> I was thinking of doing setPos in a binary search manner, in a try except block, until I find approximately the last value ? that sounds kind of retarded though
15:16:27FromDiscord<hotdog> In reply to @MadScientistCarl "How do I deal": Which editor? You should be able to set a main entry point project file which should help
15:16:39FromDiscord<MadScientistCarl> VSCode.
15:18:55FromDiscord<hotdog> In reply to @MadScientistCarl "VSCode.": With nimsaem plug-in?
15:19:02FromDiscord<MadScientistCarl> I think so
15:19:09FromDiscord<MadScientistCarl> Ah, I think it is again declaration order
15:19:30FromDiscord<MadScientistCarl> Looks like I still have to make things modules instead of including
15:19:35FromDiscord<hotdog> In reply to @voidwalker "I was thinking of": That sounds messy. How long is the final value you need to read? Or do you just need to know the stream has ended?
15:20:01FromDiscord<hotdog> In reply to @MadScientistCarl "Looks like I still": Yeah I’d always avoid include if possible anyway
15:20:06FromDiscord<voidwalker> the value is a float, that I need to parse from a line in the stream.
15:20:14FromDiscord<MadScientistCarl> But then I can't control visibility
15:20:19FromDiscord<MadScientistCarl> Because I have to make everything public
15:20:32FromDiscord<voidwalker> (edit) "stream." => "stream (latest line, or very close to it)"
15:21:01FromDiscord<hotdog> In reply to @MadScientistCarl "Because I have to": Keep all the private stuff in a private subfolder, export your main api from top level module
15:21:08FromDiscord<hotdog> Is quite common
15:21:27FromDiscord<MadScientistCarl> But there are public types, and their fields have to be all public
15:21:46FromDiscord<MadScientistCarl> Otherwise I can't implement anything unless I put everything in one giant file
15:21:56FromDiscord<hotdog> In reply to @voidwalker "the value is a": I’d just read line by line then personally and keep a buffer of the last X lines
15:22:01FromDiscord<pyolyokh> you should really, really, really just put everything in one giant file.
15:22:22FromDiscord<MadScientistCarl> That is not going to be maintainable
15:22:51FromDiscord<pyolyokh> there's no difference to maintainability. You find large files unpleasant for some reason. Maybe slow tooling?
15:23:32FromDiscord<MadScientistCarl> It's just a pain to edit. If you have one giant file, you can look at two parts of it side by side, and that's it
15:24:38FromDiscord<pyolyokh> sure, it's a pain somehow. What it looks to me is that you're trying to trade away problems that you can easily anticipate, from large files, for much more severe problems that you're gradually become more aware of.
15:24:52FromDiscord<voidwalker> In reply to @hotdog "I’d just read line": but how do you know if you reached the "end", where the most up to date value we are searching for is ?
15:25:10FromDiscord<hotdog> In reply to @voidwalker "but how do you": Stream.atEnd()
15:25:42FromDiscord<cow> In reply to @pyolyokh "you should really, really,": not really
15:26:02FromDiscord<cow> I don't like big files either
15:26:21FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4lkV
15:26:22FromDiscord<voidwalker> never exits the loops
15:26:25FromDiscord<voidwalker> (edit) "loops" => "loop"
15:27:49FromDiscord<cow> In reply to @MadScientistCarl "But then I can't": there's an alternative pattern where for every type, you create a file with all the procs that operate on the type, make all members private, and you use your own API in the rest of the code
15:28:27*xet7 quit (Remote host closed the connection)
15:28:42FromDiscord<MadScientistCarl> OK, now that sounds a lot like a header file
15:28:48FromDiscord<cow> not really
15:28:54FromDiscord<cow> it sounds like OOP
15:29:09FromDiscord<cow> you put the type and all related behavior in a single file
15:29:11FromDiscord<hotdog> In reply to @voidwalker "never exits the loop": Hmm
15:29:22FromDiscord<MadScientistCarl> But if you can't put behavior in the module, it's like a header defining types only
15:29:47FromDiscord<cow> yeah you had some recursive import problems right
15:29:54FromDiscord<MadScientistCarl> I have to put behavior in a separate module, because it references multiple types. And that causes problems due to circular imports
15:30:12FromDiscord<cow> are you sure you can't break up behavior into multiple functions and compose them later
15:30:21FromDiscord<MadScientistCarl> I already tried very hard
15:30:30FromDiscord<cow> what problem area is this
15:30:37FromDiscord<cow> it's hard to give advice generally
15:30:46FromDiscord<MadScientistCarl> It's kind of a turn based game simulator
15:30:54FromDiscord<cow> and you have a massive type for game state?
15:31:05FromDiscord<MadScientistCarl> Pretty much all state types can interact with all other state types
15:31:21FromDiscord<MadScientistCarl> So most state would have at least some function that reference every other type of state
15:31:28FromDiscord<Saint> Is there a way for the nim compiler to only autocomplete to .nim files?
15:31:36FromDiscord<Saint> Like how cd only autocompletes to directories
15:31:42FromDiscord<MadScientistCarl> Right now I am putting all the behavior in separate modules. But that makes the type fields exposed
15:31:43FromDiscord<Saint> In zsh or bash etc
15:31:50FromDiscord<pyolyokh> In reply to @Saint "Is there a way": that's shell configuration, not something nim is doing
15:32:02FromDiscord<cow> idk, you could also leave the type fields exposed and add documentation instructing not to manipulate them
15:32:11FromDiscord<cow> some languages don't have private fields (like Dart iirc)
15:32:13FromDiscord<Saint> In reply to @pyolyokh "that's shell configuration, not": Yeah I figured but I was wondering if anyone here knows how to do it
15:32:17FromDiscord<MadScientistCarl> Yeah, that is fine, but not ideal
15:33:44FromDiscord<MadScientistCarl> I guess I can put all the accessors in the types module
15:34:33FromDiscord<MadScientistCarl> Actually no, because setters will have to be exported too
15:34:47FromDiscord<pyolyokh> In reply to @Saint "Yeah I figured but": something like `complete -f -X '!.nim' nim` for bash
15:35:02FromDiscord<Saint> Ooh gotcha thanks @pyolyokh
15:35:16FromDiscord<cow> another idea @MadScientistCarl
15:35:36FromDiscord<pyolyokh> In reply to @Saint "Ooh gotcha thanks <@803214225002463283>": biggest problem with that is that it doesn't complete directories
15:36:10FromDiscord<cow> sent a code paste, see https://play.nim-lang.org/#ix=4ll0
15:36:15FromDiscord<pyolyokh> `complete -f -o plusdirs -X '!.nim' nim` works better
15:36:30FromDiscord<cow> you could create a public type that has a private member for the type you want, and explicitly create the API that way
15:36:46FromDiscord<MadScientistCarl> I guess that will work
15:37:07FromDiscord<cow> (edit) "https://play.nim-lang.org/#ix=4ll0" => "https://play.nim-lang.org/#ix=4ll3"
15:37:35FromDiscord<cow> maybe it'll work with type PublicType = BigType too, not sure, I rarely use new names for old types
15:37:54FromDiscord<hotdog> @voidwalker https://play.nim-lang.org/#ix=4ll4
15:38:04FromDiscord<hotdog> This works as expected, echoing the lines then exiting
15:38:27FromDiscord<hotdog> So perhaps there is something else going on in your code?
15:38:46FromDiscord<voidwalker> yah but not the same thing as a real process with continuous output ?
15:39:41FromDiscord<voidwalker> also, `errs.getPosition` -> `Error: unhandled exception: cannot retrieve file position [IOError]`
15:39:57FromDiscord<hotdog> I don't really understand your problem then
15:40:20FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4ll6
15:40:30FromDiscord<voidwalker> but I can't get position :\
15:41:08FromDiscord<hotdog> In reply to @voidwalker "I was thinking to": Why?
15:41:29FromDiscord<pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4ll7
15:41:38FromDiscord<hotdog> If you just want to throw away a character, just do `discard stream.readchar`
15:41:40FromDiscord<voidwalker> so that instead of bloccking forever on readlines I get a crash if I try to set position beyond the stream length
15:42:03FromDiscord<hotdog> In reply to @voidwalker "so that instead of": Use peekline
15:42:04FromDiscord<voidwalker> to cause it to break out of the loop (= we are at "end")
15:42:06FromDiscord<hotdog> Like I said before
15:42:22FromDiscord<voidwalker> you sure peekLine is not blocking ?
15:43:07FromDiscord<hotdog> Perhaps it does, I don't remember
15:43:44FromDiscord<hotdog> Or just read into a buffer and create your own non-blocking version, reading char by char until there is nothing to read, as I said before
15:44:25FromDiscord<voidwalker> If only I could convert the Stream into a StringStream, but I can't
15:45:02FromDiscord<voidwalker> I believe reading char by char would be slow enough to be considered "blocking", even if it would work
15:45:39FromDiscord<hotdog> In reply to @voidwalker "I believe reading char": I wouldn't discount it, it's what readline does anyway..... https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/streams.nim#L1009
15:46:12FromDiscord<voidwalker> hm indeed..
15:47:59FromDiscord<voidwalker> but why can't I get the position of the errorStream ?
15:49:32FromDiscord<hotdog> Because there's no position implementation
15:49:58FromDiscord<Nerve> Question, what's the equivalent of Pythons `if name == "main":`? I'd like to prototype and test my project's modules using only that module's source, and conditionally not compiling that testing code when it isn't the main source file seems cleaner and more useful than commenting or uncommenting the bottom of the file.
15:50:04FromDiscord<Nerve> (edit) "Pythons" => "Python's"
15:50:10FromDiscord<hotdog> In reply to @Nerve "Question, what's the equivalent": when isMainModule:
15:50:23FromDiscord<Nerve> Thank you very much
15:51:36FromDiscord<voidwalker> @hotdog what is this then ? https://nim-lang.org/docs/streams.html#getPosition%2CStream
15:52:06FromDiscord<hotdog> Look at the source
15:52:09FromDiscord<hotdog> It calls `getPositionImpl`
15:52:55FromDiscord<hotdog> Which needs to be created for getposition to work
15:57:29FromDiscord<MadScientistCarl> For `Table`, is there a method for "update if has key"?
15:58:30FromDiscord<pyolyokh> no, only for the opposite logic of "update if hasn't key"
16:02:14FromDiscord<pyolyokh> without forking it and using rawGet, I think the closest you can get is using <https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/collections/tables.nim#L340> and catching the exception
16:03:34FromDiscord<Saint> I'm getting an error saying SSL not supported, but I'm including the -d:ssl flag
16:03:34FromDiscord<Saint> https://hastebin.com/nigutopuxe.yaml
16:03:47FromDiscord<Saint> sent a code paste, see https://play.nim-lang.org/#ix=
16:03:58FromDiscord<Saint> sent a code paste, see https://play.nim-lang.org/#ix=
16:04:08FromDiscord<Saint> Any idea what is going on?
16:04:24FromDiscord<Saint> I'm guessing it's something to do with my dynamically linking the library
16:04:48FromDiscord<Saint> I'm using the hot code reloading prototype feature of jester/nimja I guess
16:05:29FromDiscord<Saint> nimja's really I guess
16:05:49FromDiscord<pyolyokh> those errors definitely only fire in non-defined(ssl) paths. I imagine your hot code reloading isn't using -d:ssl in the recompile.
16:06:26FromDiscord<scipio> sent a code paste, see https://paste.rs/khO
16:06:50FromDiscord<enthus1ast> it could be that the dll that is build, does not have ssl enabled.@Saint
16:07:01FromDiscord<Saint> Hmm right
16:07:51FromDiscord<enthus1ast> it might be enough to add a .nims file with↵↵switch("define", "ssl")
16:07:56FromDiscord<pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4lld
16:08:19FromDiscord<enthus1ast> @Saint\: it must be named as the dll that is generated
16:09:02FromDiscord<Saint> I was able to get it somehow working adding the flag inside nimjas hotloading code
16:09:16FromDiscord<enthus1ast> yes thats another option
16:09:17FromDiscord<Saint> Idk if I would have to submit a pull request but theres still soemthing not working
16:09:18FromDiscord<Saint> Didn't crash though
16:09:51FromDiscord<enthus1ast> what else is not working?
16:13:43FromDiscord<enthus1ast> but yes, the compile command should be configurable.
16:28:04*jjido joined #nim
16:33:16FromDiscord<Saint> ethus1ast: My previous issue was that I was having multiple instances of my webserver running at the same time
16:33:23FromDiscord<Saint> I wouldn't get a warning that something was already listening on that port
16:33:30FromDiscord<Saint> Maybe there has to be a fix for it or something
16:34:05FromDiscord<Saint> But secondly now I'm getting some error which I assume is related to an async proc, anything I need to do to call an async proc from a non async proc other than waitFor and including std/asyncdispatch?
16:34:33FromDiscord<Saint> sent a code paste, see https://play.nim-lang.org/#ix=4lll
16:36:02FromDiscord<enthus1ast> yeah there could be a lot of reasons
16:36:29FromDiscord<enthus1ast> maybe try to compile with --gc\:orc then it might crash more accurately
16:37:10FromDiscord<Saint> I'll try that
16:37:53FromDiscord<enthus1ast> ah and also, when you do the hot code reloading, i would compile the host application and the dll with the same flags
16:38:07FromDiscord<enthus1ast> so, release/debug and the same memory management
16:38:26FromDiscord<enthus1ast> i noticed some issues when they're not the same
16:39:49FromDiscord<Saint> --gc:orc always crashes my server regardless
16:40:02FromDiscord<Saint> In reply to @enthus1ast "so, release/debug and the": SUre makes sense
16:41:28FromDiscord<Saint> Without --gc:orc and running my server with my async web call, this is the error that I get
16:41:36FromDiscord<Saint> sent a code paste, see https://play.nim-lang.org/#ix=4llo
16:41:50FromDiscord<Saint> If I run the same async function from just a regular nim file it works
16:42:33FromDiscord<Saint> Or actually maybe it doesn't hmm one sec
16:42:49FromDiscord<enthus1ast> mh
16:43:50FromDiscord<enthus1ast> does it always crash, or does it sometimes work?
16:46:22FromDiscord<enthus1ast> have a look this thread looks like the issue you have\: https://forum.nim-lang.org/t/3055
16:46:23FromDiscord<Saint> Always crasehs
16:46:52FromDiscord<pyryrin> sent a code paste, see https://play.nim-lang.org/#ix=4llr
16:47:06FromDiscord<enthus1ast> but this is stuff i do not know very well, maybe someone else have more clue
16:47:48FromDiscord<pyolyokh> In reply to @pyryrin "why isn't it printing": it knows it's a `ptr Vec3f64` so it prints the more helpful thing instead of a random number.
16:48:04FromDiscord<pyryrin> how do i get it to print an address
16:48:12FromDiscord<pyolyokh> `cast[int](a.unsafeAddr)`
16:48:30FromDiscord<pyryrin> thanks
16:50:08FromDiscord<cow> @pyryrin you can also `cast[pointer](a.unsafeAddr)` if you want 0xHEX_HERE represenation
16:53:37FromDiscord<pyryrin> sent a code paste, see https://play.nim-lang.org/#ix=4llt
16:55:33FromDiscord<pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4llu
16:57:00FromDiscord<pyryrin> i dont really want to use a tuple
17:00:54FromDiscord<Saint> enthus1ast: At least I can confirm that this is an issue with the hot reloading code, cause when I do it without it, it works
17:18:19FromDiscord<enthus1ast> @Saint\: do you do a async call in the dll?
17:19:35FromDiscord<Saint> Yeah
17:19:39FromDiscord<Saint> I do
17:19:54FromDiscord<Saint> Also any idea why I'm getting this "No uri scheme supplied." for encodeUrl
17:20:02FromDiscord<Saint> In a test file it works fine without any 'scheme'
17:20:25FromDiscord<Saint> I think its httpclient messing with it
17:22:27FromDiscord<sealmove> question about jester / async... suppose one of the routes has blocking code (let's say we have a `sleep(1000)`). Does the whole server blocks for 1 second? What happens when a new request comes in during this 1 second?
17:24:07FromDiscord<enthus1ast> @Saint\: i can reproduce it with orc
17:24:27FromDiscord<enthus1ast> yeah thats unfortunate
17:26:33FromDiscord<Saint> In reply to @enthus1ast "<@890692135827959919>\: i can reproduce": Reproduce what exactly?
17:26:44FromDiscord<Saint> That async doesn't work in a hot reload dll?
17:27:07FromDiscord<enthus1ast> i can crash it when i use orc
17:27:13FromDiscord<enthus1ast> but works with refc
17:28:49FromDiscord<Rika> In reply to @รєคɭ๓๏שє "question about jester /": blocks
17:29:06FromDiscord<Saint> In reply to @enthus1ast "but works with refc": Oh i see
17:29:08FromDiscord<Rika> request prolly dropped within the second, or queued (by socket buffer?) until it resumes perhaps
17:29:09FromDiscord<Saint> What does that mean hmm
17:29:14FromDiscord<Saint> 🤔
17:29:34FromDiscord<Saint> I figure that I'll leave out hcr since it's experimental anyways right
17:29:38FromDiscord<Saint> Thats what nimja says
17:33:38FromDiscord<enthus1ast> @Saint\: it seems to work with\: -d\:useMalloc --gc\:orc
17:33:48FromDiscord<enthus1ast> for both, the dll and the host
17:33:56FromDiscord<enthus1ast> yes
17:34:00FromDiscord<enthus1ast> its experimental
17:35:24FromDiscord<Saint> Hmm okay
17:35:32FromDiscord<Saint> I'll try that out next ethus1ast!
17:35:38FromDiscord<Saint> You're using IRC right?
17:35:49FromDiscord<enthus1ast> nope matrix
17:35:51FromDiscord<Saint> Too bad there's no autocmplete for irc usernames on Discord
17:35:52FromDiscord<Saint> Ohh
17:36:13FromDiscord<Saint> How do you get to mention my name?
17:36:29FromDiscord<Saint> @enthus1ast Does this work for higlighting?
17:36:36FromDiscord<enthus1ast> yes
17:44:14FromDiscord<Saint> Cool
17:44:42FromDiscord<Saint> Say I want to check if certain fields exist in my object (json object) and if it throws an exception I want to catch it
17:45:17FromDiscord<Saint> Whats a way for me to do like a no-op check of it? I wanted to to something like if (obj["key1"]["key2"]["key3"]: continue
17:45:21FromDiscord<Saint> And put a try catch around that
17:45:26FromDiscord<Saint> Is there a better way?
17:58:36FromDiscord<Phil> In reply to @Saint "Whats a way for": I'm only skimming into here, but do you basically want to iterate over a type and check "do you have a field of name X" ?
17:59:31FromDiscord<Phil> Because that's pretty easily doable, that's where you want to use compile time procs
17:59:36FromDiscord<Saint> In reply to @Isofruit "I'm only skimming into": Well more like I just want to do some sort of access and catch the exception
17:59:37FromDiscord<Phil> and the fieldpairs iterator
18:00:07FromDiscord<Phil> Ohhh wait, I just now read it's a json object
18:00:27FromDiscord<Phil> Does this use std/json? or does it use some custom lib?
18:00:55FromDiscord<Phil> Either way, there will be a "hasKey" proc or something equivalent. std/json has it for sure, I'd be surprised if any lib was missing it that deals with json
18:04:57FromDiscord<Saint> In reply to @Isofruit "Either way, there will": Yeah I know I can do haskey or something but for example i'd have to do multiple haskeys if I'm trying to access an object 5 layers deep
18:05:14FromDiscord<Phil> Ah and you want a comboversion?
18:05:20FromDiscord<Saint> And I'm wondering more just for general information what's a way of doing some sort of no-op executition
18:05:38FromDiscord<Saint> In python I can do if (foo['a']['b']['c']): continue
18:05:48FromDiscord<Saint> (edit) "In python I can do if (foo['a']['b']['c']): continue" => "sent a code paste, see https://play.nim-lang.org/#ix=4llW"
18:05:58FromDiscord<Saint> And then throw a try except around it
18:06:02FromDiscord<Saint> I was wondering what the equivalent would be in nim
18:06:13FromDiscord<Phil> At a glance I can't think of anything immediately.↵The route I typically go to is json-string --> nim object type immediately, I very rarely deal with a json-intermediate object type explicitly because it is annoying
18:08:56FromDiscord<Phil> And imo just the parsing into an object thing would be easier and faster to deal with in general
18:09:22FromDiscord<Phil> But then again I don't know what's forcing you to deal with JsonObject
18:11:41*xet7 joined #nim
18:18:30FromDiscord<Rika> Python pass equivalent is discard in Nim
18:18:34FromDiscord<voidwalker> does anyone know if `atEnd` ran on the errorStream of a process would never return true, if the process is a .sh file that has the commands to execute ? Or what else coud cause it
18:19:56FromDiscord<voidwalker> that way the actual thing to run is under a parent process
18:21:07FromDiscord<voidwalker> Was needed to run as .sh because it seems nim does not support running something with pipes?, like `ffmpeg -i "$1" -f yuv4mpegpipe -strict -1 - | av-scenechange -`
18:25:57FromDiscord<huantian> @Saint what if you use https://nim-lang.org/docs/json.html#overview-handling-optional-keys
18:26:12FromDiscord<huantian> With that one nil chaining thing in std
18:27:21FromDiscord<huantian> https://nim-lang.org/docs/wrapnils.html
18:29:27FromDiscord<Saint> In reply to @Rika "Python pass equivalent is": Thanks
18:29:57FromDiscord<Saint> In reply to @huantian "<@890692135827959919> what if you": Looks interesting too
18:30:06FromDiscord<Saint> Can any variable be nil in nim?
18:31:01FromDiscord<huantian> Only refs can be nil
18:31:11FromDiscord<Saint> Right
18:36:14FromDiscord<Phil> Self answered SO question from me incomiiiiiiiiing, feel free to ignore it
18:39:02FromDiscord<Phil> Man, that bot used to be a fair bit faster
18:47:06FromDiscord<enthus1ast> but you can use `options` https://nim-lang.org/docs/options.html↵(@Saint)
18:47:20FromDiscord<enthus1ast> and futures also work a little like options
18:52:58*xet7 quit (Remote host closed the connection)
18:54:38FromDiscord<Saint> Gotcha, thanks!
18:55:32FromDiscord<pyryrin> is there any convention to when to use something as a method or an ordinary function
18:55:44FromDiscord<pyryrin> (edit) "use" => "call"
18:58:17FromDiscord<enthus1ast> @pyryrin\: this is relevant https://nim-lang.org/docs/tut2.html#object-oriented-programming-dynamic-dispatch
18:59:42FromDiscord<pyryrin> yeah but sometimes you wanna call procs like methods too
19:00:12FromDiscord<cow> In reply to @pyryrin "is there any convention": it'
19:00:20FromDiscord<pyryrin> like `seq.filter(...).map(...)` instead of `filter(map(...), ...)`
19:00:33FromDiscord<cow> (edit) "it'" => "use procs when you compile time know the type, use method when you need runtime type resolution"
19:00:43FromDiscord<cow> In reply to @pyryrin "like `seq.filter(...).map(...)` instead of": oh between these it's just aesthetics really
19:00:54FromDiscord<enthus1ast> oh this, this is syntactic sugar, you can decide what is more logical to you
19:01:42FromDiscord<pyryrin> i know but i just really wish there was a convention for it
19:02:14FromDiscord<cow> it's like naming conventions, everyone has their own
19:02:37FromDiscord<pyryrin> but there is a naming convention to nim
19:03:08FromDiscord<cow> I use the method call syntax almost always
19:04:18FromDiscord<cow> In reply to @pyryrin "but there is a": oh i guess there is
19:25:37FromDiscord<Phil> I am reasonably certain that the bot informing about SO questions is broken at this point
19:25:53FromDiscord<T0lk1en> Hey guys I’m using the os module to get Params. Is there anyway to make it to where if no param is given then no error is thrown
19:26:24FromDiscord<Phil> Okay, one sec, that's quite a sentence to parse
19:27:26FromDiscord<Phil> I assume this is for linux?
19:28:20*rockcavera joined #nim
19:28:23FromDiscord<T0lk1en> Windows actually
19:28:32FromDiscord<T0lk1en> Linux machine broke rn
19:28:52FromDiscord<Phil> In that case I'ma use the simple way, why not throw the error yourself if the `paramCount` proc returns 0?
19:29:21FromDiscord<Phil> Or wait, other way around, you get an error without params and want to avoid it?
19:29:21FromDiscord<T0lk1en> So sum like try:↵Except return 0
19:29:38FromDiscord<T0lk1en> Yeah when no params are given I get an error
19:29:58FromDiscord<T0lk1en> I’m trying to get to where if params are given to use those but if none are then use some default values
19:30:16FromDiscord<T0lk1en> I think you solved it tho with the try
19:30:55FromDiscord<Phil> Ah, you mean you haven't tried a try-except block yet?
19:31:05FromDiscord<Phil> Then yeah, that's your go to
19:31:24FromDiscord<T0lk1en> Nah. It didn’t come to mind. The more I learn the more I find try blocks useful
19:31:32FromDiscord<T0lk1en> Especially when getting user input
19:32:08FromDiscord<Phil> Try-catch blocks keep making me want to have a result block
19:32:13FromDiscord<Phil> (edit) "block" => "type"
19:32:39FromDiscord<Phil> And there are kind of ways to do it in nim, but I'm not a massive fan of the solutions I've seen, doesn't feel as effortless
19:33:04FromDiscord<T0lk1en> What’s result type?
19:34:06FromDiscord<Saint> sent a code paste, see https://play.nim-lang.org/#ix=4lml
19:34:07FromDiscord<Phil> So you know how any piece of code in nim (and the majority of other languages) throw an Exception/Error if something bad occurs, like you trying to access a field on object that's nil
19:34:29FromDiscord<Phil> Actually forget the nil thing, more like receiving a json string that doesn't match to the type it should parse to
19:34:35FromDiscord<Saint> sent a code paste, see https://play.nim-lang.org/#ix=4lmm
19:35:52FromDiscord<Phil> In those scenarios I would prefer it if the proc `parseJson(jsonString)` didn't return either the parsed JSON or throw an exception.↵I would prefer it if it returned a Result-type in both scenarios.↵Result is kind of like an optional, it expresses that this value may contain the desired parsed output, but it can also contain one of several errors
19:36:38FromDiscord<Phil> And if you want to get the actual value out of the Result type, you need to also deal with what should happen if the Result is not the actual outcome you want, but with the error that may have occurred while doing the parsing
19:37:00FromDiscord<Phil> While with Exceptions, nothing inside of the code forces you to deal with them
19:37:10FromDiscord<Phil> You can just not do a try-except block and still use it all fine
19:38:09FromDiscord<Phil> In that way Result types are "annoying" to deal with because they force you to deal with the errors that may occur
19:38:35FromDiscord<Phil> But they're also great because they force you to deal with everything that can occur, no hidden exception blowing up somewhere, it's all explicit
19:39:25FromDiscord<huantian> Why not just wrap the proc that may return an exception with a result version then
19:39:56FromDiscord<Phil> It's not that it's impossible or anything in nim, the multiple result-implementations confirm that it can be done
19:40:51FromDiscord<Phil> It's just that they're either not as convenient as I'd want, or don't support providing one "Success" with multiple different possible "Failure" types that would contain the actual error itself that was thrown
19:41:43FromDiscord<Phil> Say what you want about Rust, I have a ton of gripes about the language, but focus on pattern matching and their Result-type implementation were really good ideas
19:43:43FromDiscord<huantian> I think I find results only useful when I want to handle the error↵Most of the time i just use results as weird exceptions in rust
19:52:06FromDiscord<MadScientistCarl> How do I debug a Nim program? it just exits on exception without dropping into the debugger
20:16:14FromDiscord<MadScientistCarl> Actually, does LLDB even work with Nim?
20:30:28*jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…)
20:36:02FromDiscord<T0lk1en> Hey guys how do append a file in nim. I have a variable that changes and I want to simply append a file. Not overwrite it
20:43:02FromDiscord<Kermithos> In reply to @T0lk1en "Hey guys how do": https://nim-lang.org/docs/io.html#FileMode↵you need fmAppend
20:46:55FromDiscord<Kermithos> In reply to @MadScientistCarl "Actually, does LLDB even": look into the "debugging" section of the vscode extension ↵https://marketplace.visualstudio.com/items?itemName=nimsaem.nimvscode
20:47:33*azimut_ joined #nim
20:47:53*azimut quit (Ping timeout: 255 seconds)
20:49:22FromDiscord<MadScientistCarl> It doesn't work. Breakpoints have no effect
20:51:25FromDiscord<T0lk1en> In reply to @Kermithos "https://nim-lang.org/docs/io.html#FileMode you need": Could you give an example. I’m having trouble
20:54:26FromDiscord<T0lk1en> Nvm I think I got it
21:04:11FromDiscord<Gumbercules> In reply to @MadScientistCarl "It doesn't work. Breakpoints": Yes it does... So does gdb
21:04:28FromDiscord<Gumbercules> You need to compile with debug stmbols
21:04:52FromDiscord<MadScientistCarl> I think I did
21:05:02FromDiscord<MadScientistCarl> I have d:debug and debug:native
21:07:11FromDiscord<amadan> iirc the flag is `--debugger:native` not `--debug:native`
21:08:27FromDiscord<MadScientistCarl> I have this in `config.nims`:
21:08:35FromDiscord<MadScientistCarl> sent a code paste, see https://play.nim-lang.org/#ix=4lmK
21:08:38FromDiscord<MadScientistCarl> No effect
21:11:42FromDiscord<MadScientistCarl> I changed to use nims.cfg, with no effect either
21:12:31FromDiscord<Phil> PMunch (or whoever else, I don't actually know who keeps an eye on it):↵I'm pretty sure nimeventer is dead, or at the very least has stopped reporting stuff from SO.↵Was that intentional?
21:16:08FromDiscord<MadScientistCarl> I can't get debugging to work
21:16:34FromDiscord<MadScientistCarl> I tried specifying the option through cmdline, but it has no effect either
21:16:57FromDiscord<sealmove> does `osproc` support callback for when the process finishes?
21:17:36FromDiscord<MadScientistCarl> OK, specifying directly through command line works. However, I can't get the compile options to persist, no matter what config file I edit
21:30:28FromDiscord<Nerve> So I just found out about the `nim secret` RCPL, is this a planned feature with a roadmap that needs time to finalize or is it just a curiosity? What's the progress on it?
21:37:40FromDiscord<Phil> In reply to @Nerve "So I just found": nim secret is what's being used to perform compile-time computation and macros
21:37:53FromDiscord<Phil> It is the "hidden" vm nim uses during compilation
21:38:23FromDiscord<Phil> It is also what basically enables nimscript to run, which is the subset of nim you write in `.nims` files for config purposes
21:38:36FromDiscord<Phil> So by itself it basically is already a complete feature with a clear purpose
21:38:49FromDiscord<Phil> (edit) removed "by itself" | removed "basically"
21:39:44FromDiscord<Nerve> So, not aimed at REPL-driven development, but if it works, it works, just don't expect support?
21:40:07FromDiscord<Nerve> (edit) "support?" => "support if it doesn't?"
21:40:24FromDiscord<Phil> It kind of can act like one, but if you want something that supports the full width of nim-libs you'll want to use inim
21:40:53FromDiscord<Phil> It isn't aimed to be a full REPL, it is aimed to be a script environment and for the compiler to use for compile-time stuff
21:41:12FromDiscord<Phil> And something that can act as a REPL for basic stuff is a side-effect of what it can do
21:42:07FromDiscord<Nerve> Looks like inim aims to exactly support what I'm looking for, awesome
21:42:10FromDiscord<Nerve> Thanks for the recommendation
21:42:29FromDiscord<auxym> @Nerve check out INim on nimble, works pretty well for me
21:44:08FromDiscord<Phil> In reply to @Nerve "Thanks for the recommendation": This isn't going to matter for like 95% of your stuff, but inim only kind of acts like a REPL, it isn't one under the hood.↵In actuality it adds the individual lines to a nim file, compiles it and prints the output of the latest statement back.↵That works really well, but also means if your file starts going really really really really really long your time until it reacts will go up
21:45:04FromDiscord<Phil> But due to this approach it also can also be used to write nim code just like you would in a project
21:45:17FromDiscord<Phil> (edit) removed "also" | "project" => "projec"
21:45:20FromDiscord<Phil> (edit) "projec" => "project"
21:45:45FromDiscord<Nerve> Huh. I would think incremental compilation would be a first-class feature of a compiled language that supports metaprogramming this strongly, seems like a natural fit.
21:45:53FromDiscord<ambient> notebooks are easy to convert to working program too, just saying
21:46:17FromDiscord<Phil> notebooks?
21:46:33FromDiscord<ambient> jupyter, it's basically the modern repl
21:46:43FromDiscord<Phil> Ohhhh you meant notebooks on the python side
21:46:57FromDiscord<ambient> nim works also on jupyter, it's not just python thing
21:46:58FromDiscord<Phil> I was like "Wait, we have a jupyter-alike on the nim end and I'm not aware of it?"
21:47:05FromDiscord<Phil> Huh
21:47:17FromDiscord<ambient> but like you said, it just builds a big file and compiles it
21:48:06FromDiscord<huantian> In reply to @Nerve "Huh. I would think": Eventually soon™️
21:48:16FromDiscord<Gumbercules> In reply to @MadScientistCarl "OK, specifying directly through": I'm not on my PC but when I get on later I can help
21:48:17FromDiscord<huantian> It’s on the road map for Nim 2.x
21:48:51FromDiscord<Nerve> Neat™
21:48:58FromDiscord<ambient> well incremental compilation does not mean that you can easily export and import the local environment of a program
21:49:57FromDiscord<Nerve> Yes, but sometimes just being able to compile a project, then drop into a repl so you can call modules and functions and refine new ones based on existing behavior is a godsend in and of itself
21:50:21FromDiscord<ambient> nothing prevents people from creating programs that manually (or through a macro) export and import the local environment
21:52:23FromDiscord<ambient> I don't know how easy it is to extract the local environment into a variable and move the entire thing between processes
21:55:05FromDiscord<ambient> maybe a custom pragma like {.notebook.} for variables or something like that
22:08:18FromDiscord<Elegantbeef> Where are your config files and what are their names?↵(@MadScientistCarl)
22:25:30FromDiscord<MadScientistCarl> I got it to work by pulling out the options from the function
22:26:00FromDiscord<MadScientistCarl> Finally found the documentation in the Nims page. This should be included in Nimble's doc
22:37:41FromDiscord<Saint> Does anyone use nim as a fast protoyping language or scripting language like they do with python?
22:37:49FromDiscord<Saint> I want to but having a hard time with the compile times
22:37:58FromDiscord<Saint> Rust has even slower compile times right?
22:38:28FromDiscord<Elegantbeef> I write many oneoff things in Nim
22:38:34FromDiscord<Elegantbeef> The compile times are hardly an issue
22:45:44FromDiscord<Elegantbeef> If you really want to minimise compile times you can install tcc and then do `nim c --cc:tcc -r ./myprogram.nim`
22:46:04FromDiscord<Elegantbeef> But really even with gcc or clang compile times for small programs are not substantial
22:52:56FromDiscord<Takemichi Hanagaki> In reply to @Saint "Does anyone use nim": I use it with NimScript.
22:59:10FromDiscord<Saint> Oh thanks I'll look into those
22:59:25FromDiscord<Saint> Is there a way to read a file line by line like in python
22:59:43FromDiscord<Saint> liek a for line in open('file.txt'): print(f)
23:00:25FromDiscord<Elegantbeef> There are multiple ways of doing it, the easiest is `for line in lines("file.txt"):...`
23:02:07FromDiscord<deeuu> sent a long message, see http://ix.io/4lnB
23:03:31FromDiscord<deeuu> (edit) "http://ix.io/4lnB" => "https://paste.rs/3te"
23:04:00systemdsucksmmap the file, iterate, profit
23:07:23*azimut_ quit (Ping timeout: 255 seconds)
23:09:43*azimut joined #nim
23:39:50FromDiscord<Saint> In reply to @Elegantbeef "There are multiple ways": Ty!