<< 13-11-2023 >>

00:07:25*antranigv quit (Quit: ZNC 1.8.2 - https://znc.in)
00:08:46*antranigv joined #nim
00:09:37*krux02 quit (Remote host closed the connection)
00:51:36*antranigv quit (Quit: ZNC 1.8.2 - https://znc.in)
00:54:29*antranigv joined #nim
01:03:11*Mister_Magister quit (Quit: bye)
01:05:08*Mister_Magister joined #nim
04:20:53*pbsds quit (Quit: The Lounge - https://thelounge.chat)
04:21:36*pbsds joined #nim
05:00:43*rockcavera quit (Remote host closed the connection)
06:35:11*derpydoo quit (Ping timeout: 260 seconds)
07:07:22*advesperacit joined #nim
07:27:38*FromDiscord quit (Remote host closed the connection)
07:28:05*FromDiscord joined #nim
07:38:04*derpydoo joined #nim
07:39:10*deadmarshal_ quit (Server closed connection)
07:44:38*deadmarshal_ joined #nim
08:11:45FromDiscord<arnetheduck> In reply to @odexine "questionable has that in": that's part of `nim-results` actually
08:12:09FromDiscord<odexine> Is that so
08:12:14FromDiscord<odexine> I see
08:40:52FromDiscord<JJ> In reply to @odexine "questionable has that in": woah, i didn't know it had that
08:47:35FromDiscord<gbolahan> How do I convert type string to openarray[byte]
08:48:14FromDiscord<Elegantbeef> `toOpenArrayByte`
09:40:21*derpydoo quit (Ping timeout: 240 seconds)
10:30:55*jmdaemon quit (Ping timeout: 246 seconds)
11:16:36FromDiscord<Chronos [She/Her]> In reply to @bostonboston "I thought threadpools were": Huh? Why would they be?
11:51:28FromDiscord<241_01499> Does Araq browse discord? Well, just in case. I think float datatype was a mistake, and it should be removed from the compiler.
11:52:12FromDiscord<241_01499> Is there any argument in favor of float ? (not float32/float64 that's it).
11:52:30FromDiscord<dissolved.girl> In reply to @241_01499 "Does Araq browse discord?": What do you mean by this?
11:52:57FromDiscord<241_01499> I mean that "var i: float" shouldn't compile.
11:53:25FromDiscord<dissolved.girl> Yeah, but why?
11:53:38FromDiscord<241_01499> (edit) ""var" => "`var" | "float"" => "float`"
11:53:55FromDiscord<dissolved.girl> `float` is just an alias for `float64`, no?
11:55:53*fallback quit (Server closed connection)
11:58:38FromDiscord<241_01499> Extra officially it is an alias to float64 yes, unlike int which is an alias for cpu favored int. But it gets funnier
11:59:04FromDiscord<241_01499> type(1f) is float32
11:59:06Amun-Ra"but wait, there's more […]"
12:00:05*fallback joined #nim
12:01:16PMunch_241_01499, that's not so weird since `f` is defined in the manual as the float32 literal suffix: https://nim-lang.org/docs/manual.html#lexical-analysis-numeric-literals
12:01:55PMunch_`type(1d)` is float64
12:02:07*PMunch_ is now known as PMunch
12:02:16Amun-Rawell, 1d? TIL
12:02:52FromDiscord<241_01499> Is a definition that goes against common sense. f32 -> float32, f64 -> float32. If float (simpler identifier) is float64m then 1f (simpler suffix) should be float64
12:03:34FromDiscord<241_01499> I think that many options in the end do more harm than good.
12:04:33Amun-Rathey used postfixes from C world f(loat), d(ouble)
12:04:52PMunchIt's a bit strange, I agree. But actual errors should be picked up by the type system anyways, so it's not too horrible
12:05:28FromDiscord<241_01499> Neither rust nor zig have them. Maybe if float meant "float32" an double meant "float64", that could reduce the friction between nim and say java. But still.
12:06:02FromDiscord<nnsee> In reply to @241_01499 "Does Araq browse discord?": araq hangs around in #internals
12:07:16PMunch241_01499, what do you mean Zig doesn't have them? Zig has f16, f32, f64, f80, f128, and even c_longdouble.
12:07:42FromDiscord<241_01499> Sorry, I meant to say they don't have an alias for float64
12:09:16PMunchAh
12:10:16PMunchI think float was also intended to point to the "system native floating point type", but in the current implementation I think it's float64 everywhere
12:10:52FromDiscord<nnsee> in any case i don't think "other languages don't have this" isn't really a strong argument
12:11:46FromDiscord<nnsee> any language X is going to have features language Y doesn't, unless X is a strict sublanguage of Y
12:11:58FromDiscord<nnsee> features and behaviour
12:12:22FromDiscord<odexine> Many languages don’t have UFCS 😉
12:12:55FromDiscord<odexine> Before beef comes I’ll say okay sure it’s method call syntax or whatever the correct-ier name is
12:26:46FromDiscord<Chronos [She/Her]> Nim has aliens? 😱
12:27:59*lucasta joined #nim
12:42:45FromDiscord<kryp7on> sent a long message, see http://ix.io/4Lov
12:43:04FromDiscord<kryp7on> I asked "What is the return value of function `createFile`?"
12:43:10FromDiscord<kryp7on> he answered `In the given example, the createFile procedure does not explicitly return a value. In Nim, procedures are used for computations that do not return a result. So, the createFile procedure does not have a return value. When you use the discard statement with this procedure, you’re simply calling the procedure for its side effect (creating a file), not for a result to use.`
12:43:48FromDiscord<kryp7on> so could some human explain me what discard is used for? I get that it is when you dont need the return statement. But could you explain to me with some better example code?
12:44:06FromDiscord<Chronos [She/Her]> In simpler terms, \`discard\` is used when you want to run a proc, but want to ignore whatever it returns
12:44:22PMunchHaha, that's an extremely bad example
12:44:24PMunchThe Bing one
12:44:29Amun-Rathat was such a bad answer (bing)
12:44:47Amun-Rathere's even nothing to discard in that example
12:45:22FromDiscord<Chronos [She/Her]> sent a long message, see http://ix.io/4Low
12:45:24PMunchIn many programming languages you can call a procedure which returns something and just not assign it to a variable. In Nim that is an error, you can't run a procedure that returns something without using the returned value for something.
12:45:41FromDiscord<Chronos [She/Her]> Uh not sure how to use codeblocks on Matrix \:p
12:45:52PMunchTypically you'd assign it to a variable or just use it directly like `if someProc() == 5`
12:46:03Amun-Rayou can only ignore return values implicitely (without explicit discard) from functions marked with discardable pragma
12:46:26PMunchBut if you want to run a procedure which returns something and you really don't care about the value you can use `discard someProc()` to just throw away the return value explicitly.
12:47:57PMunchIt can also be used as a `nop` in certain scenarios. For example as the only statement in a procedure body: `proc test(x, y: int) = discard` just creates a procedure called `test` which takes two integers and does nothing.
12:48:33*edr joined #nim
12:50:00FromDiscord<kryp7on> > In Nim that is an error, you can't run a procedure that returns something without using the returned value for something.|↵when you said `without using the returned value for something.` you meant on, without assigning that return value to some variable?
12:52:15PMunchhuh?
12:54:23*rockcavera joined #nim
12:54:35FromDiscord<kryp7on> In reply to @PMunch "huh?": when you have for example function that is adding X and Y, you must finish that function with RETURN and assign that return value to variable B, right? and with discard, you use that function just for addititon and dont assign it to variable?
12:54:55FromDiscord<odexine> In reply to @kryp7on "> In Nim that": no as in "for something" where something is your work; as said, saying `if aProc() == 5` is using the value for something
12:55:20FromDiscord<odexine> it doesnt have to be a varialbe
12:55:21FromDiscord<odexine> (edit) "varialbe" => "variable"
12:56:19PMunchkryp7on, oh no, you don't have to return anything from a procedure. But if a procedure returns something the caller of the procedure must use the result in some way
12:57:50FromDiscord<kryp7on> In reply to @PMunch "<@1124352185916981328>, oh no, you": and for what is RETURN used?
12:58:03FromDiscord<kryp7on> becuase I saw procs that doesnt have RETURN, they just do something
12:58:20PMunchReturn is one way of returning things from a procedure
12:58:37PMunchHowever you also have the `result` variable and implicit returns
12:58:53FromDiscord<odexine> returning things from a procedure is useful for when you want the procedure to represent doing work that has a result
12:59:00FromDiscord<nnsee> sometimes you want to call procedures just for its side effects
12:59:05FromDiscord<nnsee> ie, a procedure that writes data to a file
12:59:07FromDiscord<odexine> In reply to @odexine "returning things from a": well, a result that's a value
12:59:13*lucasta quit (Quit: Leaving)
12:59:19FromDiscord<nnsee> or changes some global variable / state / whatever
12:59:25FromDiscord<nnsee> or operates on references passed in via arguments
12:59:49*lucasta joined #nim
13:00:12FromDiscord<nnsee> In reply to @nnsee "ie, a procedure that": this also includes `echo "whatever"` - this is writing to the standard output, which is a type of file
13:00:13FromDiscord<kryp7on> In reply to @nnsee "ie, a procedure that": thats example that I wanted to give but coldnt brainstorm. If you have proc like that, what would be return at all?
13:00:29PMunchhttps://play.nim-lang.org/#ix=4LoA
13:00:33PMunchHere's an example
13:00:51PMunchAll these three procedures do the same thing, they add x and y together and return the result
13:01:07FromDiscord<nnsee> In reply to @kryp7on "thats example that I": depends on the implementation. in c-land, it's common for the returned data to be the number of bytes written
13:01:30PMunchThen we call each of them and use their return value by passing it to `echo` to print them out, and we call each of them and explicitly throw away the returned value with the `discard` keyword
13:06:21FromDiscord<kryp7on> In reply to @PMunch "Then we call each": for `proc2` you wrote: `# The result variable is returned at the end of a procedure`↵that means that RESULT variable is always in the end, and whatever proc is doing, it finished and gives value with result?
13:06:46FromDiscord<kryp7on> I mean, tbh, I dont see difference with those 3 procs that you wrote
13:07:04FromDiscord<kryp7on> one has implicit work, 2nd has result and 3rd has return
13:07:37FromDiscord<kryp7on> why there are 3 types of it at all?
13:08:16FromDiscord<kryp7on> this is my first programming language (did python and rust a little bit), but maybe this is something with programming in general that I dont understand, not with Nim in particular
13:08:16PMunchWell they all have their uses
13:09:02PMunchAnd yes, the `result` variable is implicitly defined in every procedure which can return something, and it is returned whenever the procedure ends.
13:09:38FromDiscord<nnsee> unless `return` is used with an explicit return value
13:09:42PMunchIt's good that you don't see a difference between those three procedures, because they're all the same
13:09:57FromDiscord<kryp7on> In reply to @PMunch "And yes, the `result`": sub-question: why is return used for then?
13:10:04PMunchImplicit return is useful if you just want to write a quick one-liner
13:10:04FromDiscord<kryp7on> In reply to @PMunch "It's good that you": wow, my brain is melting haha
13:10:19FromDiscord<nnsee> In reply to @kryp7on "sub-question: why is return": well imagine trying to return in the middle of a procedure
13:10:25PMunchReturning through result is practical if you want to build your result during your procedure
13:10:35FromDiscord<nnsee> `return` immediatetly stops the execution of the procedure
13:10:49PMunchAnd explicit returning with the `return` keyword is useful for control flow reasons as it ends the procedure right then and there
13:10:51FromDiscord<nnsee> with `result`, the procedure keeps running after assigning a value to it
13:10:55FromDiscord<kryp7on> In reply to @nnsee "`return` immediatetly stops the": so its when you have `if` in the procedure for example. and if doesnt pass, you return?
13:11:06FromDiscord<nnsee> sure, that's one example
13:11:33FromDiscord<kryp7on> In reply to @PMunch "Returning through result is": and result if you want to finish procedure till the end, and you dont have something like `if` part?
13:11:55FromDiscord<kryp7on> (edit) "In reply to @PMunch "Returning through result is": and result ... if" added "is"
13:12:17FromDiscord<kryp7on> (edit) "part?" => "part to finish your procedure before the actual end?"
13:12:51PMunchHere is an example mixing result and return: https://play.nim-lang.org/#ix=4LoB
13:13:05PMunchTry to guess what it will output before running it to see if you understand how it works
13:14:33FromDiscord<nnsee> to imagine the usefulness of `result`, let's say you have a loop that operates on a range of `things` and you want to return the number of `things` you actually modified. You could set up your procedure to just call `inc(result)` every time you successfully operate on a `thing`, and nothing otherwise. When the procedure ends, the `result` and thus the return value of the procedure is the number of `things` that you operated on
13:18:14*derpydoo joined #nim
13:19:53FromDiscord<kryp7on> In reply to @nnsee "to imagine the usefulness": gotcha
13:20:00FromDiscord<kryp7on> In reply to @PMunch "Try to guess what": thanks for example, it helped a lot
13:20:06FromDiscord<kryp7on> I finally got it. Thanks to all of you guys :))
13:20:45PMunchNo problem :)
13:42:41*enyc quit (Ping timeout: 255 seconds)
13:45:23*enyc joined #nim
13:45:50*lucasta quit (Quit: Leaving)
14:12:37FromDiscord<victormihalache> sent a code paste, see https://play.nim-lang.org/#ix=4LoY
14:13:13FromDiscord<victormihalache> i need to add the Access-Control-Allow-Origin header
14:17:57FromDiscord<nnsee> In reply to @victormihalache "how can i set": https://git.dog/xx/redir/src/branch/master/src/redir.nim#L6
14:22:00FromDiscord<victormihalache> ahh got it, i have to use this call here `proc send(req: Request, code: HttpCode, body: string, headers="")` as no other allows you to set the headers
14:57:05FromDiscord<jviega> If I have an initializer for an `object` (declared `proc someInitializer(var someobj, someOptions...)`) but the object type has a variant field in it, is there a way I'm supposed to be dealing w/ that? Or should I just silence the CaseTransition warning?
14:59:38FromDiscord<odexine> CaseTransition means you're setting kind outside of the object constructor syntax i think?
14:59:45PMunchI guess `someObj = MyObject(kind: MyKind)` and then set the rest of the fields
15:00:23FromDiscord<jviega> Ah, didn't even occur to me, I'm so used to constructor syntax being for heap allocated items, thanks
15:02:17FromDiscord<jviega> esp when the guidance said, "instantiate new object instead", which kept me thinking heap, heh
15:10:29*PMunch quit (Quit: Leaving)
15:25:46FromDiscord<jviega> What's the way to test if a symbol exists statically, and can I use it in nimscript?
15:28:20FromDiscord<jviega> Particularly, trying to figure out if I can import a module or if it's missing, but "compiles(import X)" seems to return true even if X doesn't exist...
15:30:04FromDiscord<jviega> Oh no, nvm, compiles() doesn't work at all in that case
15:34:11FromDiscord<jviega> Ah got it, have to do `when (compiles do: import X):`
15:47:36FromDiscord<patitotective> Just wondering, is there a way to check generic procedures at compile time? Making tests is a bit tiresome
16:36:31FromDiscord<demotomohiro> Do you want to check existance of generic procedure or test it?
16:37:56FromDiscord<demotomohiro> If you want to test generic code, how about to write tests code under static: block?
16:53:43*m5zs7k quit (Ping timeout: 255 seconds)
16:54:20*m5zs7k joined #nim
16:56:07FromDiscord<patitotective> In reply to @demotomohiro "If you want to": That sounds great, thanks
16:59:35NimEventerNew thread by mmcol: Strange string prefix, see https://forum.nim-lang.org/t/10629
18:41:09FromDiscord<bostonboston> If I have a enum from a c library that has holes in it but want to not use a holey enum in Nim, is a valid strategy to make two enums with a converter between them? Or is this a bad idea
18:42:52FromDiscord<bostonboston> My plan was to make the converter use a case statement, tell me if that's a bad idea too
18:47:10FromDiscord<saint.___.> That sounds like it makes sense to me but idk if there is something wrong with that
19:28:38Amun-Rabostonbostom: is that enum returned from C?
19:31:57FromDiscord<bostonboston> I don't believe it ever is, and if it is it'll be my job to convert it from a byte to the relevant type
20:13:48NimEventerNew thread by mszs: Should closing a stream assign nil?, see https://forum.nim-lang.org/t/10630
21:03:02*krux02 joined #nim
22:13:54FromDiscord<user2m> Random question when try to wrap a c/c++ library do u have to compile it down to a dll (if on windows) or can u link to the header file somehow?
22:16:25FromDiscord<jviega> Well, you need there to a a library to link, AND you probably do need header files, unless you can manually provide the info needed
22:16:46FromDiscord<Chronos [She/Her]> Procrastination is horrid-
22:20:40FromDiscord<demotomohiro> In reply to @user2m "Random question when try": you can link dll/so, static link lib(.lib/.a) or C/C++ file directly using compile pragma.
22:21:55FromDiscord<demotomohiro> In reply to @user2m "Random question when try": If you want to learn how to use c/c++ libs from Nim:↵https://internet-of-tomohiro.netlify.app/nim/clibrary.en
22:36:17*Batzy joined #nim
22:36:47FromDiscord<Elegantbeef> Since Nim relies on a C(++) compiler you can include the project file using `{.compile:...}` or `{.link` or the way you would in C(++)
22:49:29FromDiscord<Chronos [She/Her]> Oof Nimsuggest is being annoying
22:50:13FromDiscord<Chronos [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4LqX
22:50:15FromDiscord<Chronos [She/Her]> Despite this being valid code
22:50:25FromDiscord<Chronos [She/Her]> Compiles and works as intended
23:00:25*advesperacit quit ()
23:00:50NimEventerNew thread by c4UlMu: Move ref variable ro thread, see https://forum.nim-lang.org/t/10632