<< 18-08-2021 >>

00:01:30madpropsok got something
00:01:35madpropsgetTime() - initTime(seconds, 0)
00:23:10*beshr quit (Ping timeout: 240 seconds)
00:26:42*xet7 quit (Read error: Connection reset by peer)
00:27:18*xet7 joined #nim
00:43:56*arkurious quit (Quit: Leaving)
00:48:52madpropsanything that could be improved here? https://dpaste.org/APJg
00:53:28madpropscleaned it up a bit
00:53:35madpropsless repetition
01:06:01madpropssomething that i haven't seen is a var that turns into a let when assigned
01:06:11madpropsdon't know of a prog lang that does it
01:06:19madpropsmaybe it's hard to implement
01:09:08FromDiscord<Elegantbeef> You can emulate that behaviour using a block
01:10:11FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=3wjv for instance
01:11:08madpropsor an if/else similarly right ?
01:11:47madpropsfor some reason some if/else block assigning wasn't working
01:12:02madpropsif something: "somestring"
01:12:04FromDiscord<Elegantbeef> Yes all expressions can return a value
01:12:22FromDiscord<Elegantbeef> you need all branches to have a returned value
01:12:31madpropsoh maybe I was missing an else
01:12:45FromDiscord<Elegantbeef> Probably
01:26:14FromDiscord<j-james> Can someone explain what the `{. bycopy .}` pragma does in more detail?
01:27:40FromDiscord<Elegantbeef> Instead of doing reference passing optimizations it always copies the object afaik
01:28:46FromDiscord<Elegantbeef> In Nim objects are often passed by hidden references which is more efficient, but you may not when interacting with something that doesnt know that it's a copy
01:30:04FromDiscord<j-james> That makes a lot of sense, thanks
01:30:51FromDiscord<j-james> Off the top of your head, can you think of any cases where one or the other could cause issues?
01:36:28FromDiscord<Elegantbeef> Presently writing an example \:D
01:41:52FromDiscord<Elegantbeef> here is a bit of a contrived issue but https://play.nim-lang.org/#ix=3wjJ
01:42:21FromDiscord<Elegantbeef> Do to forcing the compiler to emit a `doThing(SomeThing)` it mismatches with `doThing(SomeThing)`
02:29:56FromDiscord<eliyanov> Hello everyone, I'm new here
02:31:58FromDiscord<Elegantbeef> Hello
02:32:07FromDiscord<eliyanov> I have a quick question\: if I write `stream.readData(value.unsafeAddr, sizeof(value))` where stream is a FileStream and value is a string, how is the function able to deserialize a string of any length?
02:33:30FromDiscord<Elegantbeef> It isnt, it writes the data at the pointer
02:34:02FromDiscord<Elegantbeef> For serializing a string you'd want to write `len` followed by the data of the string, though you may want to look at frosty, or flatty for binary serialization
02:34:57FromDiscord<Elegantbeef> So in the case of a string it'll write probably `len, dataAddress`
02:35:46FromDiscord<eliyanov> I'm seeing behavior where I write a string to the binary file and that line given is able to deserialize the whole thing.
02:36:03FromDiscord<Elegantbeef> Cause the string is still in memory so it's stil lvalid
02:36:04FromDiscord<Elegantbeef> Cause the string is still in memory so it's stil valid
02:37:11*TakinOver joined #nim
02:38:31FromDiscord<eliyanov> Screen Shot 2021-08-17 at 9.38.00 PM.png https://media.discordapp.net/attachments/371759389889003532/877380915523891210/Screen_Shot_2021-08-17_at_9.38.00_PM.png
02:38:39FromDiscord<eliyanov> Even in this example?
02:39:12*rockcavera quit (Remote host closed the connection)
02:40:23FromDiscord<Elegantbeef> yea `dat` is likely not freed by by the end of main
02:41:13FromDiscord<eliyanov> Oh the unsafe pointers are the issue maybe
02:41:45FromDiscord<Elegantbeef> Well to prove my point https://play.nim-lang.org/#ix=3wjR
02:41:59FromDiscord<Elegantbeef> The character array isnt written
02:42:42FromDiscord<eliyanov> Yeah that makes sense, thanks for the help
02:50:04FromDiscord<Elegantbeef> If interested this is what my suggestion was https://play.nim-lang.org/#ix=3wjS
02:50:47FromDiscord<Elegantbeef> But frosty/flatty make this serialization super easy if you want something already all together 😀
02:56:37FromDiscord<j-james> What is the difference between `uint32` and `uint32_t`?
02:58:22FromDiscord<j-james> Particularly in a wrapping-C context
02:59:07FromDiscord<Elegantbeef> Nim's uint32 is the same as uint32\_t
03:14:46*xet7 quit (Remote host closed the connection)
03:35:37*kayabaNerve_ is now known as kayabaNerve
03:35:41*xet7 joined #nim
03:56:37*kayabaNerve quit (Remote host closed the connection)
04:01:10*kayabaNerve joined #nim
04:06:01*supakeen quit (Quit: WeeChat 3.2)
04:06:30*supakeen joined #nim
04:40:42FromDiscord<creonico> How can I use nim in web-assembly?
04:42:04FromDiscord<Elegantbeef> Emscripten https://github.com/treeform/nim_emscripten_tutorial
04:47:28FromDiscord<creonico> Does nim not have a standard wasm compilation?
04:50:05FromDiscord<Elegantbeef> Emscripten would be the "standard"
05:37:16FromDiscord<impbox [ftsf]> nim can compile to js, not wasm directly
05:37:28FromDiscord<impbox [ftsf]> if you want wasm, compile to c then use emscripten
05:50:30*xet7 quit (Remote host closed the connection)
05:57:15*xet7 joined #nim
06:02:57FromDiscord<Chiggy> Can anyone confirm me if this is a good way to continue fetching a url until a response if received? Coz the server sometimes breaks connection or something. https://media.discordapp.net/attachments/371759389889003532/877432360273068042/unknown.png
06:03:40NimEventerNew thread by Alexeypetrushin: Why `using` not working? Bug?, see https://forum.nim-lang.org/t/8341
06:03:51FromDiscord<Chiggy> (I didnt know of python's `pass` pass equivalent in nim)
06:03:55FromDiscord<Chiggy> (edit) "nim)" => "nim so I just used discard)"
06:04:49FromDiscord<impbox [ftsf]> might want to check the exception type
06:05:00FromDiscord<impbox [ftsf]> and probably wait a little between attempts
06:07:37FromDiscord<Chiggy> from what I have noticed, it seems to be protocol error always (I have only seen 5 times as of now) https://media.discordapp.net/attachments/371759389889003532/877433534699171880/unknown.png
06:08:00FromDiscord<impbox [ftsf]> are you reusing the client for multiple requests?
06:08:04FromDiscord<Chiggy> no
06:08:20FromDiscord<Chiggy> I just make one request each time my code runs
06:08:37FromDiscord<Chiggy> my code runs every minute
06:10:37FromDiscord<Chiggy> In reply to @impbox "and probably wait a": ig thats good? https://media.discordapp.net/attachments/371759389889003532/877434290831515648/unknown.png
06:12:11FromDiscord<impbox [ftsf]> i guess so, you may as well make it while true: since raw_content could be "" it'll still break
06:12:51FromDiscord<impbox [ftsf]> you might want to create your client inside the loop
06:12:56FromDiscord<impbox [ftsf]> so if it fails you get a new client
06:13:10FromDiscord<impbox [ftsf]> i've had issues with reusing httpclients before
06:13:22FromDiscord<Chiggy> In reply to @impbox "i guess so, you": Huh? The api will never return an empty string
06:13:29FromDiscord<Chiggy> In reply to @impbox "i've had issues with": h ok
06:13:30FromDiscord<Chiggy> (edit) "h" => "oh"
06:13:36FromDiscord<impbox [ftsf]> @Chiggy how do you know?
06:13:46FromDiscord<impbox [ftsf]> they might update the API
06:13:58FromDiscord<Chiggy> my friend is hosting the api
06:14:20FromDiscord<Chiggy> but yeah while true will work too
06:14:30FromDiscord<Chiggy> (edit) "my friend is hosting the api ... " added "so I will know if anything changes at all"
06:14:39FromDiscord<impbox [ftsf]> ok
06:15:41FromDiscord<j-james> Should I use `cint` for all of `int16, int32, uint32_t` when wrapping C code?
06:15:51FromDiscord<impbox [ftsf]> nope
06:16:07FromDiscord<impbox [ftsf]> only use cint for int in c
06:16:24FromDiscord<Elegantbeef> cint is the platform dependant C integer type
06:16:30FromDiscord<j-james> Are the rest fine as they are?
06:16:35FromDiscord<Elegantbeef> The others are fixed size so map to Nim fine
06:17:10FromDiscord<impbox [ftsf]> from my understanding cint in nim == int in c
06:17:19FromDiscord<Elegantbeef> actually isnt cint not platform dependant but completely user configurable?
06:17:39FromDiscord<impbox [ftsf]> and cuint in nim == unsigned int in c
06:18:17FromDiscord<Elegantbeef> Yea i just dont recall if `int` in C is user definable size 😀
06:18:30FromDiscord<impbox [ftsf]> i guess it's up to the compiler
06:18:35FromDiscord<Elegantbeef> I know atleast one data type somewhere is configurable, just dont recall what
06:19:46FromDiscord<Elegantbeef> Anywho this is way off the point, if there is a bitsize in the name it's safe to use the nim variant
06:22:28*PMunch joined #nim
06:25:18*Vladar joined #nim
07:38:00FromDiscord<enthus1ast> https://nimble.directory/ heavily suffers from crosstalk issue, go on and hit ctrl + r a few times, it is completely broken some times, sometimes it delivers the logo on the "/" route...
07:39:23FromDiscord<KnorrFG> sent a code paste, see https://play.nim-lang.org/#ix=3wkP
07:40:04FromDiscord<enthus1ast> https://nimble.directory/ heavily suffers from crosstalk issues, go on and hit ctrl + r a few times, it is completely broken some times, sometimes it delivers the logo on the "/" route... (OK some are 429s)
07:44:10FromDiscord<Clonkk> you need before\_install / after\_install
07:46:55FromDiscord<Clonkk> Basically if you have `task b, "b":...`, you can define `before b` and `after b` (no underscore actually), this works with `install` and \`\`develop tasks as well in the nimble file↵(@KnorrFG)
07:47:46FromDiscord<KnorrFG> so, setting flags in a 'before install' will make install respect those flags for compilation?
07:50:19FromDiscord<Clonkk> For linkage, you use`after install` to install external library and then link in Nim code using pragma
07:50:36FromDiscord<KnorrFG> ok, ill try, thanks
07:51:46FromDiscord<Clonkk> Sadly, Nimble doesn't have a way to handle shared libraries properly
07:56:03*tdc joined #nim
08:25:37*max22- joined #nim
09:07:13FromDiscord<tandy> with object variants (https://nim-lang.org/docs/manual.html#types-object-variants)
09:07:25FromDiscord<tandy> can you have an object which has both types?
09:08:20FromDiscord<Rika> “Both”?
09:08:36FromDiscord<Rika> Both of what’s
09:08:43FromDiscord<Rika> (edit) "what’s" => "what?"
09:08:54FromDiscord<Elegantbeef> presently there is no reuse of the trees so you need repetitive branches if they arent identical
09:09:03FromDiscord<tandy> sent a code paste, see https://play.nim-lang.org/#ix=3wlh
09:09:14FromDiscord<Elegantbeef> no you cannot
09:09:16FromDiscord<tandy> hmm
09:09:23FromDiscord<tandy> i guess i dont need enums then
09:10:11FromDiscord<Elegantbeef> why are you using `Option[seq[Track]]`?
09:10:38FromDiscord<Elegantbeef> Seems redundant when you can just check the length, but might just be me
09:10:46*flynn quit (Read error: Connection reset by peer)
09:11:29FromDiscord<tandy> hmm i thought it would be easier to initialise
09:11:32FromDiscord<tandy> u might be right tho
09:11:35FromDiscord<Rika> It would be harder
09:11:53*flynn joined #nim
09:12:03FromDiscord<Rika> Unless an empty sequence is different from your none type, there is no reason to use option here
09:12:16FromDiscord<tandy> true
09:12:38FromDiscord<Elegantbeef> same could be said about the strings
09:14:14FromDiscord<Elegantbeef> Assuming `""` is unwanted it's the same s `Option[string]`
09:14:34FromDiscord<tandy> hmm
09:14:37FromDiscord<tandy> what really is the use of options then hahah
09:15:02FromDiscord<Elegantbeef> For types that dont have this information
09:15:22FromDiscord<Elegantbeef> integers, returned value objects, and so forth
09:16:00FromDiscord<Elegantbeef> For instance https://nim-lang.org/docs/nre.html#match%2Cstring%2CRegex%2Cint
09:16:22FromDiscord<Elegantbeef> It's equivlent to a `(bool, RegexMatch)` but it's an API which encourages checking the former
09:16:31FromDiscord<tandy> oh i remember why im using options
09:16:38FromDiscord<tandy> in some places anyway
09:17:01FromDiscord<tandy> im using jsony and when converting my types to json i discard empty options
09:17:42FromDiscord<Elegantbeef> Cant you do the same just with the `""` and `len > 0`, or do you not want hooks?
09:19:21FromDiscord<tandy> i was using hooks yeah
09:19:27FromDiscord<tandy> il look into it thanks
09:20:28FromDiscord<tandy> are there plans to add reuse?
09:21:07FromDiscord<Elegantbeef> https://github.com/nim-lang/RFCs/issues/368 yes
09:21:25FromDiscord<tandy> the reason i was look at enums for this was because i want to have a user url which will be either last.fm/user/{} or listenbrainz.org/user/{}
09:22:09FromDiscord<Elegantbeef> sure but couldnt that just be an enum for `service` and then a `token: string`?
09:23:46FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3wlk
09:23:55FromDiscord<Elegantbeef> Seems like it covers the same(yes i got lazy)
09:24:54FromDiscord<tandy> i dont get what service does in this case? also does this mean that i cant have a user for both services (for now) ?
09:25:07FromDiscord<tandy> is it like a toggle switch kinda
09:25:11FromDiscord<Elegantbeef> No, it just tells you in other code where you want to connect
09:25:17FromDiscord<Rika> If you want you can probably make it a set
09:25:36FromDiscord<Rika> So you can have a user of one or both (but it also means you can have a user of none so)
09:25:52FromDiscord<tandy> tbh i need to think of a better way to abstract this, because some users may have accounts on both but with different usernames
09:26:03FromDiscord<Rika> Then just make multiple users
09:26:24FromDiscord<tandy> yeah but i wanted to have them abstracted as one user on my spa
09:26:33FromDiscord<tandy> for convenienc
09:26:38FromDiscord<Elegantbeef> Ok so that's not difficult
09:27:00FromDiscord<Rika> Then use one User type and another linking type (maybe “ExternalUser)
09:27:02FromDiscord<Elegantbeef> `services: set[Service]` `userNames: array[Service, string]`
09:27:11FromDiscord<Rika> Then have a sequence in User of Externals
09:28:07FromDiscord<Rika> In reply to @Elegantbeef "`services: set[Service]` `userNames: array[Service,": You think too much in game programming style smh
09:28:19FromDiscord<tandy> lol
09:28:28FromDiscord<Elegantbeef> Was that directed to me?
09:28:36FromDiscord<Rika> Who else
09:28:44FromDiscord<Elegantbeef> Just making sure 😛
09:31:25FromDiscord<tandy> i settled on this
09:31:34FromDiscord<tandy> sent a code paste, see https://play.nim-lang.org/#ix=3wln
09:31:50FromDiscord<Rika> You don’t need those to be ref objects by the way
09:31:54FromDiscord<Elegantbeef> Now time to bike shed the ref
09:32:00FromDiscord<Rika> It seems wasteful
09:32:12FromDiscord<Elegantbeef> A pointer to a list of pointers is just fun!
09:32:44FromDiscord<Rika> Beef would probably get an aneurysm when he sees what JsonNode looks like
09:32:46FromDiscord<tandy> oh ok lol, i wasnt really sure what it did and just kept it from other project (lol)
09:32:49FromDiscord<Rika> I kid, he already has
09:32:59FromDiscord<Elegantbeef> I know what it looks like
09:33:08FromDiscord<Elegantbeef> Ref is if you want a reference(managed pointer)
09:33:10FromDiscord<Rika> See second message
09:33:55FromDiscord<Elegantbeef> Rika i'm not good at anything i can atleast pretend I know better than others!
09:35:34FromDiscord<Elegantbeef> Also ref's give you `nil` so you dont really need `Option[SomeRef]`
09:36:04FromDiscord<Elegantbeef> since `ref bool` and `Option[bool]` are practically the same if you're not looking for reference semantics
09:36:41FromDiscord<tandy> oh thats neat
09:36:43FromDiscord<tandy> so options is redundant \:?)
09:37:12FromDiscord<Elegantbeef> It's got it's purpose, just you have to know when/where to use it
09:37:34FromDiscord<tandy> but with this, why would i not just use ref?
09:37:53FromDiscord<Elegantbeef> one is heap allocated, the other is not
09:38:20FromDiscord<Rika> They are different
09:38:25FromDiscord<Rika> They have different behaviours
09:39:19FromDiscord<Elegantbeef> Yea i'm mostly just talking about interaction and the fact both give n + 1 values
09:39:49FromDiscord<Elegantbeef> They're different, but in the case of a `ref object` and a `option[ref object]` there isnt much difference unless `nil` means something to you
09:41:24FromDiscord<Elegantbeef> Actually they're identical now that i think about it for pointers the option doesnt use `has` it's just `val != nil`
09:58:17FromDiscord<tandy> when i dont use a ref object i cant do `new(result)`
10:00:58FromDiscord<tandy> oh you dont need to do that at all
10:31:33FromDiscord<ericdp> is there a nim equivalent to elixir's doctest ? ( https://elixir-lang.org/getting-started/mix-otp/docs-tests-and-with.html tldr comments that could be feeded to the repl are unit tests)
10:41:12FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3wlM
10:42:11FromDiscord<ericdp> thanks
10:45:34FromDiscord<System64 ~ Flandre Scarlet> How can I make my binding more Nim-friendly please? (or is it already?)
10:48:13FromDiscord<hamidb80> ?!
10:48:52FromDiscord<haxscramper> define "more Nim-friendly"
10:50:00FromDiscord<System64 ~ Flandre Scarlet> Something like a Nim program↵'cause my binding looks like more a C thing no?
10:50:24FromDiscord<hamidb80> where are your bindings?
10:51:03FromDiscord<haxscramper> In reply to @System64 "Something like a Nim": You can start by removing this `tLN_` garbage prefix from all definitions
10:51:05FromDiscord<haxscramper> as a start
10:51:49FromDiscord<haxscramper> and instead use `proc normalName(): {.importcpp: "C name".}`
10:52:04FromDiscord<System64 ~ Flandre Scarlet> why cpp?
10:52:11FromDiscord<haxscramper> importc
10:52:12FromDiscord<System64 ~ Flandre Scarlet> I don't use C++
10:52:20FromDiscord<System64 ~ Flandre Scarlet> ah alright
10:52:36FromDiscord<System64 ~ Flandre Scarlet> so importc, not importcpp?
10:55:17FromDiscord<tandy> i just realised, how will i index the sequence though? how will i know which service is which index?↵(@Rika)
10:55:51FromDiscord<haxscramper> In reply to @System64 "so importc, not importcpp?": Yes
10:56:15FromDiscord<Rika> In reply to @tandy "i just realised, how": The one beef sent uses the enum as the index
10:56:22FromDiscord<Rika> You can do that using arrays
10:58:19FromDiscord<System64 ~ Flandre Scarlet> but if I remove the tLN prefix won't people be confused from where does it come?
11:00:13FromDiscord<haxscramper> Then don't change wrappers at all, because someone might be confused by something somewhere, and you surely don't want that, right?
11:00:32FromDiscord<tandy> but the enum isnt a string, and array index has to be an ordinal type?↵(@Rika)
11:00:40FromDiscord<tandy> \`services\\: array[ServiceUser, Service]\`
11:00:45FromDiscord<Rika> Enums are ordinal
11:01:18FromDiscord<PsychoClay> what does `Error: 'sources' is of type <openArray[string]> which cannot be captured as it would violate memory safety,` mean?
11:01:34FromDiscord<haxscramper> you have a closure that tries to access `var` variable
11:01:35FromDiscord<tandy> oh my ordering is wrong
11:02:47FromDiscord<haxscramper> In reply to @PsychoClay "what does `Error: 'sources'": If closure does not outlive its environment, you can do `import std/decls; var sources {.byaddr.} = actualSources`
11:03:43FromDiscord<PsychoClay> but sources is a proc arg
11:03:58FromDiscord<haxscramper> it is a mutable proc arg?
11:04:03FromDiscord<PsychoClay> no
11:04:17FromDiscord<haxscramper> can you give a code example?
11:04:36FromDiscord<PsychoClay> sent a code paste, see https://play.nim-lang.org/#ix=3wlT
11:07:55FromDiscord<PsychoClay> i just turned it into a seq
11:07:56FromDiscord<haxscramper> with imports please
11:08:16FromDiscord<haxscramper> well, I guess it has something to do with async transformations
11:08:50FromDiscord<haxscramper> something somewhere created some kind of maybe closure iterator that theoretically had the capability of producing some kind of error that looked somewhat like yours
11:14:44*stkrdknmibalz quit (Ping timeout: 268 seconds)
11:37:07federico3@Araq @dom96 did you get my email?
11:42:22*pro joined #nim
11:43:46arkanoidis it possible to "annotate" type attribute with custom pragma and read back that info at runtime?
11:43:57FromDiscord<System64 ~ Flandre Scarlet> @haxscramper Is it better? https://media.discordapp.net/attachments/371759389889003532/877518176307535912/Tilengine_copy.nim
11:44:55FromDiscord<haxscramper> https://nim-lang.org/docs/nep1.html#introduction-naming-conventions just read style guide
11:51:28arkanoidis it possible to get the module a symbol come from at compile time?
11:54:46FromDiscord<haxscramper> You mean like `getType().getParentModuleSym()`? No, this is not possible
12:03:04*max22- quit (Ping timeout: 256 seconds)
12:04:07arkanoidk
12:05:33arkanoidif I do $myXmlNode the output string is everything but a well formatted xml string
12:06:02*supakeen quit (Quit: WeeChat 3.2)
12:06:32*supakeen joined #nim
12:14:38FromDiscord<haxscramper> what is wrong exactly?
12:24:01*rockcavera joined #nim
12:24:01*rockcavera quit (Changing host)
12:24:01*rockcavera joined #nim
12:25:24*NeoCron joined #nim
12:31:07*arkurious joined #nim
12:33:23FromDiscord<System64 ~ Flandre Scarlet> ah yeah good to know↵And should I turn my bindings into more OOP thing?
12:34:07FromDiscord<haxscramper> I would first recommend actually using them for something, and writing required helper procs as you go
12:35:09FromDiscord<haxscramper> Because it is clear you don't quite understand yourself what can you improve, and neither does anyone who haven't used your library, so
12:36:22FromDiscord<System64 ~ Flandre Scarlet> yeah true
12:39:03FromDiscord<System64 ~ Flandre Scarlet> also, does nim have objects procedure? (like a method in a class in Java or classmethod in Python)
12:44:53PMunchYou mean methods?
12:45:35FromDiscord<System64 ~ Flandre Scarlet> Yeah
12:46:23FromDiscord<System64 ~ Flandre Scarlet> And also instance méthods (you have to instanciate the class to use the méthod)
12:49:49*max22- joined #nim
12:55:54arkanoideverytime I have to write a function that may return nothing but of ref type, I'm unsure if it is more nim like to return nil or nothing(MyRefType)
12:56:36FromDiscord<haxscramper> what you mean by "nim like"
12:56:58arkanoidnim stdlib doesn't use Option
12:57:21arkanoidso it suggests that returnin nil is the way to go
12:57:22FromDiscord<haxscramper> and? you are not writing stdlib module, right?
12:57:41FromDiscord<haxscramper> stdlib does not use option due to multiple reasons
12:57:47FromDiscord<haxscramper> For example araq does not like option
12:58:32FromDiscord<haxscramper> is that good enough of a reason for you to change how you write code or what? Use I would use option
12:58:37FromDiscord<haxscramper> `none(T)`
12:59:42FromDiscord<haxscramper> another reason why stdlib does not use option, is that it was added 6 years ago
12:59:49FromDiscord<haxscramper> while stdlib is 10+ year old
13:00:21arkanoidthe point that the creator of the language doesn't like it AND is not used in stdlib is a STRONG suggestion that it is not the nim way
13:00:35FromDiscord<haxscramper> NO IT IS NOT
13:00:57FromDiscord<haxscramper> ffs, I just can't understand why you would want to do it like this
13:01:10FromDiscord<haxscramper> does your code benefit from Option or not?
13:01:32FromDiscord<haxscramper> there is no "STRONG" suggestion for anyting, we are not Go/V,
13:01:38FromDiscord<haxscramper> write code how you think is good
13:01:40arkanoidpossibly, yes, I'm writing a parser, so your hint is VERY valuable
13:02:32FromDiscord<haxscramper> now we are talking about something more specific. For a parser I would much rather raise than return nil, and nim parser does not return `nil` for empty nodes, instead it returns `nnkEmpty()`
13:02:59FromDiscord<haxscramper> Do you parse xml or custom AST?
13:03:35arkanoidparsing xml. Still trying to turn a wsdl document into nim modules
13:05:45FromDiscord<haxscramper> Then it all depends on what exactly you are parsing - like if failure is a possibility or not?
13:05:52FromDiscord<haxscramper> or is it an exceptional case
13:06:22FromDiscord<haxscramper> and if you immediately return result of the `<can fail>` and put it somewhere else you can return `Empty()`
13:08:02arkanoidit is actually an error when it returns none, but I'm writing an helper function and not sure if the error should be raised there, helper function should just say "none"
13:36:32*tdc_ joined #nim
13:39:39*tdc quit (Ping timeout: 268 seconds)
13:47:32FromDiscord<dom96> In reply to @federico3 "<@413679055897100289> <@132595483838251008> did you": we replied to the draft security issue
13:47:57federico3I saw that.
13:49:45FromDiscord<dom96> In reply to @arkanoid "the point that the": doesn't the fact that it's in the stdlib imply that the creator at least thinks it's a valuable construct? FWIW I use it a lot in my libraries and would have used it in the stdlib if it was added earlier.
14:04:41*PMunch quit (Quit: Leaving)
14:10:41FromDiscord<konsumlamm> araq has said on multiple occasions that he doesn't really like it though
14:31:32*pro quit (Quit: WeeChat 3.2)
14:36:08*pro joined #nim
14:37:56*pro quit (Client Quit)
14:41:11*idf joined #nim
14:42:12*max22- quit (Ping timeout: 245 seconds)
14:47:14FromDiscord<Rika> Well why
14:54:12FromDiscord<haxscramper> I think I'm doing something wrong in the benchmark, because I doubt handwritten vtable implementation would be slower than `case of`
14:56:34FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3wmI
15:11:15arkanoiddom96: thanks for the feedback
15:30:01*beshr joined #nim
15:35:40*Gustavo6046 quit (Ping timeout: 240 seconds)
15:35:41*Gustavo6046_ joined #nim
15:36:00*Vladar quit (Quit: Leaving)
15:37:37*perro joined #nim
15:37:44*Gustavo6046_ is now known as Gustavo6046
15:38:55FromDiscord<mratsim> In reply to @haxscramper "<@!570268431522201601> I wrote a": you might not be doing something wrong. My bench machine was only a dual core from 2015, I can retry your code
15:40:16FromDiscord<haxscramper> Yes, if you could, it would be awesome. You also need to have https://github.com/haxscramper/hack/blob/master/testing/nim/c_interop/cpp_tests/cxx_opcodes.hpp and https://github.com/haxscramper/hack/blob/master/testing/nim/c_interop/cpp_tests/nim.cfg to compile this
15:41:27FromDiscord<mratsim> https://media.discordapp.net/attachments/371759389889003532/877577941846994975/unknown.png
15:41:44FromDiscord<mratsim> `nim cpp -d:danger -r --hints:off --warnings:off --verbosity:0 testing/nim/c_interop/cpp_tests/switch_vs_dispatch.nim`
15:42:45FromDiscord<mratsim> on i9-9980XE overclocked at 4GHz, 18 cores, I closed VScode and my browser cause they tend to wakeup CPU at odd times.
15:44:04FromDiscord<mratsim> methods in the past were multidispatch though
15:44:19FromDiscord<mratsim> note: test done on Nim 1.4.6
15:45:08FromDiscord<mratsim> I think Nim at the time was 0.19.6 or 0.20 something
15:45:21FromDiscord<mratsim> might be worth trying with that version
15:45:22FromDiscord<haxscramper> sent a code paste, see https://paste.rs/4jX
15:47:17FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3wmV
15:50:42FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3wmW
15:51:03FromDiscord<xflywind> Maybe you should also test ref object with attributes
15:51:17FromDiscord<xflywind> it maybe generate a bit slow code.
15:51:41FromDiscord<xflywind> sent a code paste, see https://play.nim-lang.org/#ix=3wmY
15:52:16*max22- joined #nim
16:16:17arkanoidhow can I fill a Table[string,string] or a StringTableRef at compile time?
16:16:56FromDiscord<konsumlamm> ref objects can't currently be constructed at compile time
16:21:07arkanoidno way to have a const table anywhere?
16:22:46FromDiscord<konsumlamm> shouldn't a normal `Table` work?
16:22:57FromDiscord<konsumlamm> just like you'd define anything else at compile time
16:24:58FromDiscord<konsumlamm> i.e. make the table a `const` (if you don't need to change it at runtime) or initialize it in a `static:` block
16:31:19arkanoidkonsumlamm seems easy but I'm trying to building a const table via a recursive function and it doesn't like it
16:37:09FromDiscord<hamidb80> hey
16:37:17FromDiscord<hamidb80> when i install a package using nimble
16:37:23FromDiscord<hamidb80> with specified hash
16:37:34FromDiscord<hamidb80> nim can't find it
16:38:20FromDiscord<hamidb80> for example it installed `print@#head`
16:38:32FromDiscord<hamidb80> nim is looking for `print-1.0.0`
16:38:42FromDiscord<hamidb80> and can't find it
16:38:58FromDiscord<hamidb80> (edit) "it installed" => "i install "
16:39:33FromDiscord<hamidb80> @treeform are you around?
16:40:16FromDiscord<hamidb80> i think you didn't update your package info
16:42:01FromDiscord<treeform> where?
16:42:37FromDiscord<hamidb80> in `print.nimble`
16:42:58FromDiscord<hamidb80> print 1.0.0 still has that bug that you fixed in head
16:43:01FromDiscord<hamidb80> (edit) "head" => "`head`"
16:43:17FromDiscord<hamidb80> and nimble automacally downaloads print 1.0.0
16:43:31FromDiscord<hamidb80> (edit) "print 1.0.0" => "`print-1.0.0`"
16:43:46FromDiscord<hamidb80> when i enter `nimble install print`
16:44:13FromDiscord<treeform> ok
16:44:18FromDiscord<treeform> which bug?
16:44:36FromDiscord<hamidb80> https://github.com/treeform/print/issues/11
16:45:21FromDiscord<treeform> oh yeah
16:45:22FromDiscord<hamidb80> maybe updating version in `print.nimble` to 1.0.1 fixes this issue
16:45:25FromDiscord<treeform> will cut new version now
16:46:24FromDiscord<treeform> done https://github.com/treeform/print/releases/tag/1.0.1
16:46:49FromDiscord<hamidb80> In reply to @hamidb80 "nim is looking for": but it's super wierd
16:50:06FromDiscord<treeform> what do you mean?
16:50:41FromDiscord<treeform> thank you for reporting the bug btw
16:51:13FromDiscord<Erik L> Hello, any ideas what to do to prevent nimsuggest to go to 100% cpu usage in Mac Os and VS Code?
16:51:28arkanoidSOLVED!
16:51:35arkanoidups, sorry for the caps
16:51:48*xet7 quit (Remote host closed the connection)
16:52:25*xet7 joined #nim
16:53:03FromDiscord<hamidb80> In reply to @treeform "what do you mean?": issue fixed after you released a new version 😕
16:53:06FromDiscord<hamidb80> (edit) "In reply to @treeform "what do you mean?": ... issue" added "the"
16:54:34FromDiscord<treeform> In reply to @Erik L "Hello, any ideas what": Disable it 😦
16:58:03FromDiscord<jseb> excuse me, how to declare `uSeconds` for uSleep ? I've imported `posix` and tried `uSleep(0)` , `uSleep(0.uSeconds)` , `uSleep(cast[uSeconds](0))` _(doh)_ . But compiler keeps telling me _undeclared identifier uSeconds_
16:59:09FromDiscord<Rika> capital U
16:59:14FromDiscord<Rika> Useconds
16:59:30FromDiscord<jseb> omg
17:48:30arkanoidis it possible to cast a global let variable into something that doesn't trigger effects?
17:48:48arkanoidI need an escape hatch not on a proc but on a variable
17:59:52FromDiscord<Elegantbeef> the `{.noSideEffect.}:` works regardless if the side effect comes from a global variable or a function https://play.nim-lang.org/#ix=3wnu
18:00:09FromDiscord<undersquire> why cant you use func in parameters?
18:00:16FromDiscord<undersquire> i see no reason why u cannot
18:01:07FromDiscord<Elegantbeef> It's not a limitation of idea but implementation, you'll need to use `proc(){.noSideEffect.}` until `func` is allowed
18:01:56FromDiscord<deech> Is there a sense for how stable `views` are right now? I keep up with `devel` wanted to get a feel for whether any projects are using them extensively.
18:09:00FromDiscord<krisppurg> Is there in any way I could reduce memory usage in nim, I am compiling with ORC, but it still is not as that as effective? https://media.discordapp.net/attachments/371759389889003532/877615074494267392/unknown.png
18:09:10FromDiscord<undersquire> In reply to @Elegantbeef "It's not a limitation": ye, just curious as it has an error message saying it cant be used here, but just saw no reason for why
18:13:14FromDiscord<Yardanico> In reply to @krisppurg "Is there in any": You can try debugging with things like heaptrack to see where does it allocate all that memory
18:13:18FromDiscord<Yardanico> Is it open source?
18:13:34FromDiscord<krisppurg> You mean my code?
18:15:23FromDiscord<Yardanico> Yeah
18:16:33FromDiscord<krisppurg> Nope, I was going to make it open source, but then I thought setting it up with git would be a problem because of where I would push changes
18:16:56FromDiscord<krisppurg> but I send it here
18:17:18FromDiscord<krisppurg> (edit) "but I send it here ... " added "if i am allowed to"
18:18:03FromDiscord<Yardanico> Well you can try heaptrack yourself
18:18:21FromDiscord<Yardanico> Is the usage high because you think ORC isn't collecting something it should?
18:18:24FromDiscord<Yardanico> What about refc?
18:18:29FromDiscord<krisppurg> How do I debug with heaptrack?
18:18:37FromDiscord<krisppurg> Well sort of high
18:19:03FromDiscord<krisppurg> https://media.discordapp.net/attachments/371759389889003532/877617605718974474/unknown.png
18:25:28FromDiscord<leorize> @krisppurg\: try `-d:useMalloc`
18:25:44FromDiscord<Yardanico> also --debugger:native
18:25:48FromDiscord<Yardanico> and then just run heaptrack on your binary
18:26:10NimEventerNew thread by Alexeypetrushin: Why `except` doesn't catch `SIGSEGV: Illegal storage access. (Attempt to read from nil?)`?, see https://forum.nim-lang.org/t/8342
18:26:29FromDiscord<leorize> Nim's allocator doesn't return the memory to the OS most of the time
18:26:48FromDiscord<leorize> also if you're using asyncdispatch, then memory inflation is a known side-effect
18:27:03FromDiscord<Yardanico> well, but he's comparing it to refc which uses 2x less memory
18:28:12FromDiscord<leorize> it's fairly unstable. Araq#0647 had been talking about how he thinks views design still need a few revisions↵(@deech)
18:30:40*max22- quit (Ping timeout: 256 seconds)
18:35:48FromDiscord<krisppurg> be right back im trying to install gdb (which is used for heaptrack), but for some reason my download speed is slow
18:37:11FromDiscord<Yardanico> change mirrors? :P
18:46:48madpropsif c not in a_bowels:
18:46:52madpropswhat's wrong with this?
18:47:09madprops"expected: ':', but got: 'keyword not'"
18:49:07madpropsoh there's notin
18:49:36FromDiscord<Yardanico> there's no "not in" in nim, you have to use notin
18:49:55FromDiscord<Yardanico> or you can also write it as "not_in" as nim's case insensitivity rules apply to keywords as well
18:50:04FromDiscord<Yardanico> so p_R_o_C is the same as proc :)
18:50:08FromDiscord<Yardanico> now you have to live with that knowledge
18:51:18madpropsis there a reason why notin exists?
18:51:29FromDiscord<Yardanico> because nim is not python :P
18:51:54madpropsi guess it makes compilation parsing easier
18:58:49FromDiscord<undersquire> isnt notin a function?
18:58:58FromDiscord<undersquire> (edit) "function?" => "function defined by stdlib?"
18:59:28FromDiscord<undersquire> sent a code paste, see https://play.nim-lang.org/#ix=3wnM
19:00:03FromDiscord<Elegantbeef> it's some sugar that does `not(x in y)`
19:00:48FromDiscord<Elegantbeef> But yes it's in the stdlib
19:02:08FromDiscord<undersquire> so is `in` right?
19:02:18FromDiscord<undersquire> at this point everything is a function 😉
19:02:25FromDiscord<undersquire> (which is honestly really cool(
19:02:27FromDiscord<undersquire> (edit) "cool(" => "cool)"
19:02:31FromDiscord<Elegantbeef> well they're templates but yes
19:02:56FromDiscord<Elegantbeef> They're all operators though hence the infix abillities
19:03:28FromDiscord<undersquire> yeah
19:03:38FromDiscord<undersquire> In reply to @Elegantbeef "well they're templates but": yeah i meant that Xd
19:10:55*max22- joined #nim
19:11:37madpropsso I'm trying to have a random seed for sample selectio
19:11:37madpropsvar r_gen = initRand(int(epochTime()))
19:11:58madpropsis there way to have that be in milliseconds ... or is there a better way to produce a "unique" rng?
19:12:36FromDiscord<Yardanico> ehm
19:12:39FromDiscord<Yardanico> random by default uses time already
19:12:55FromDiscord<Yardanico> ah, you want a stateful random seed generator
19:13:15FromDiscord<Yardanico> @madprops see how randomize does it - https://github.com/nim-lang/Nim/blob/version-1-4/lib/pure/random.nim#L627
19:13:32madpropsi don't reallly need the seed. but using random wasn't giving out random results, it seems to use some sort of default seed
19:13:47FromDiscord<Yardanico> you need to call `randomize()` first
19:13:58FromDiscord<Yardanico> that will initialize the global rng state
19:14:17FromDiscord<Yardanico> but if you don't need a global state, you can just use the code from the link I gave
19:14:52madpropsah i see
19:16:44FromDiscord<Yardanico> but generally you can use any seed you want, just remember to not use random for cryptographic purposes
19:20:48FromDiscord<deech> Is there a `compiles(...)` like thing that also captures the suggestions and error message that would have been printed to stderr? Same with `typeof(...)`.
19:21:36FromDiscord<Yardanico> don't think so
19:21:45FromDiscord<Yardanico> i think you'll have to write a compiler plugin or something if you want this functionality
19:28:03FromDiscord<Yardanico> or if you code is self-contained, you can do it the dirty way and write the code to the nim file, run nim compiler on it and capture the result :D
19:28:51FromDiscord<deech> Would be useful I think, something like `compilesWithSuggestions` which outputs candidates and which argument failed to match in some structured way, maybe even a Nim object.
19:30:47FromDiscord<undersquire> i mean couldnt u just use execCmd or wtever it is and call the nim compiler and just get the result as a string?
19:30:58FromDiscord<undersquire> you would have to manually parse the result information though
19:31:33FromDiscord<undersquire> https://nim-lang.org/docs/osproc.html#execProcess%2Cstring%2Cstring%2CopenArray%5Bstring%5D%2CStringTableRef%2Cset%5BProcessOption%5D
19:31:41FromDiscord<undersquire> why was that so long tf
19:32:26FromDiscord<Yardanico> In reply to @undersquire "i mean couldnt u": that requires the code to be self-contained
19:32:37FromDiscord<Yardanico> and deech is asking to do that on compile-time which is a bit more complicated
19:32:50FromDiscord<Yardanico> In reply to @undersquire "why was that so": because it encodes the name of the proc along with all arguments
19:33:09FromDiscord<undersquire> In reply to @Yardanico "and deech is asking": oh
19:33:10FromDiscord<Yardanico> so the browser can jump right to it
19:33:17FromDiscord<undersquire> ah ok
19:33:22FromDiscord<Yardanico> anyway, execProcess wouldn't work at compile-time
19:33:37FromDiscord<undersquire> u cant use it in a static context can you?
19:33:40FromDiscord<undersquire> or no
19:34:01FromDiscord<Yardanico> In reply to @Yardanico "anyway, execProcess wouldn't work": ^
19:34:02FromDiscord<undersquire> sent a code paste, see https://play.nim-lang.org/#ix=3wnW
19:34:12FromDiscord<undersquire> ye k
20:20:28*supakeen quit (Remote host closed the connection)
20:20:42arkanoiddo you know if someone has already built a macro that given a type builds it's init? I mean a proc where all the object's attributes are layed horizontally as proc parameters just like an init
20:20:53*supakeen joined #nim
20:24:59FromDiscord<Elegantbeef> Apparently my construct macro does, not that i remember including that https://github.com/beef331/constructor#construct
20:25:25FromDiscord<Elegantbeef> All required though, cause if you want them optional, use the object constructor syntax
20:27:40arkanoidgreat! thanks beef!
20:33:04FromDiscord<undersquire> In reply to @Elegantbeef "Apparently my construct macro": this is really cool!
20:34:40*beshr quit (Ping timeout: 240 seconds)
21:24:00*tdc_ quit (Ping timeout: 268 seconds)
21:25:16NimEventerNew Nimble package! notcurses - A low-level Nim wrapper for Notcurses: blingful TUIs and character graphics, see https://github.com/michaelsbradleyjr/nim-notcurses
21:25:50*kayabaNerve quit (Ping timeout: 268 seconds)
21:49:19FromDiscord<undersquire> wow i never realized how close nim syntax is to pascal
21:49:25*max22- quit (Quit: Leaving)
21:51:10FromDiscord<Yardanico> In reply to @undersquire "wow i never realized": yeah, nim is quite influenced by pascal, in fact nim's compiler was written in Object Pascal in the past before being rewritten in Nim itself
21:51:24FromDiscord<undersquire> lol htats pretty cool
21:51:48FromDiscord<undersquire> Nim feels like modern pascal now after comparing the two
21:51:58FromDiscord<undersquire> (edit) "two" => "syntax's"
21:53:09FromDiscord<tandy> why does seq.add() need to have a var string?
21:53:21FromDiscord<Yardanico> huh?
21:55:11FromDiscord<tandy> im trying to add a parameter from a proc into a seq
21:55:40FromDiscord<tandy> oh
21:55:41FromDiscord<Yardanico> but it doesn't need to be a var string, can you show the full error and the code?
21:55:44FromDiscord<tandy> wait i think i know why
21:56:01FromDiscord<tandy> its the seq which im adding it to
21:56:07FromDiscord<tandy> can i pass by reference in nim?
21:56:14FromDiscord<Yardanico> use `var`
21:56:27FromDiscord<Yardanico> https://nim-lang.org/docs/manual.html#procedures-var-parameters
21:57:05FromDiscord<tandy> nice that works
21:57:17FromDiscord<Yardanico> also, you don't usually need to optimize pass-by-reference yourself, Nim will pass by reference if it thinks that it's better for performance
21:57:22FromDiscord<Yardanico> `var` in parameters is used for mutability
21:58:06*byanka joined #nim
21:58:24FromDiscord<tandy> i see, that makes sense
22:09:22FromDiscord<treeform> In reply to @Ayy Lmao "Has anyone gotten pixie": I remember having this problem with visual studio, I think we fixed it, but maybe the problem is back, you can just disable the SIMD with -d:pixieNoSimd and that should make it compile.
22:10:11FromDiscord<Elegantbeef> I assume tandy you got confused by the mismatch error message?
22:10:28FromDiscord<tandy> yepp
22:10:59FromDiscord<Elegantbeef> I should add that `Atleast one mismatch due to a parameter not being mutable`
22:11:58FromDiscord<tandy> that would be much clearer
22:12:11FromDiscord<Elegantbeef> Well it'd still say the mismatches, but it'd give more concise errors
22:12:18FromDiscord<Elegantbeef> Though i think there are other PR's that also help
22:39:09*NeoCron quit (Remote host closed the connection)
22:44:41*kayabaNerve joined #nim
23:08:04FromDiscord<Ayy Lmao> In reply to @treeform "I remember having this": Yeah I am able to compile it with `-d:pixieNoSimd` on visual studio
23:10:53*stkrdknmibalz joined #nim
23:13:28FromDiscord<treeform> We are able to use simd with visual studio
23:13:39FromDiscord<treeform> maybe your nimsimd package is old?
23:13:52FromDiscord<treeform> maybe your visual studio is older or newer then what we use?
23:37:27FromDiscord<Ayy Lmao> @treeform It seems to be specifically when compiling to c++ for me
23:38:39FromDiscord<Ayy Lmao> The errors have the note `note: Conversion from 'void' to pointer to non-'void' requires an explicit cast`
23:47:27madpropswhat's wrong here? s &= &"{i + 1}) {s}"
23:48:20madpropsoh wait
23:48:59FromDiscord<Elegantbeef> You found out nothing was wrong 😀
23:51:12madpropsI have a question though
23:51:20madpropsif I do.. var new_array: seq[string]
23:51:33madpropswithout initializing it, I can still add stuff to it later, why is that?
23:51:43madpropsi mean why is specifying the type enough
23:51:48FromDiscord<Elegantbeef> Cause nim seq's and string's are not nilable
23:52:13FromDiscord<Elegantbeef> As such they're 0 init'd to a usable sequence
23:53:09FromDiscord<konsumlamm> ig by 0 init'd you mean they're initialized to an empty seq/string
23:53:49FromDiscord<Elegantbeef> Yea didnt mean 0 init'd but yea
23:54:02FromDiscord<Elegantbeef> just they're init'd to something usable which reduces errors
23:54:07madpropsi see