<< 30-05-2023 >>

00:03:56*lucasta joined #nim
00:09:15FromDiscord<Chronos [She/Her]> In reply to @Elegantbeef "No real clue myself": Why not? Main issue would be making them all share a dispatched, I've done that but my usecase was just a horrible usecase anyway so it broke
00:12:40FromDiscord<Bloss> In reply to @Ayy Lmao "Hmmm, I think it's": Use `of`
00:13:07*xet7 joined #nim
00:21:01FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4x2o
00:25:06FromDiscord<demotomohiro> This compiles:
00:25:16FromDiscord<demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4x2q
00:30:13FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4x2s
00:30:15FromDiscord<etra> In reply to @Hourglass, When the Hour Strikes "Why not? Main issue": from what I read the odds are a bit better with arc/orc but still there's no implementation afaik. I gotta confess i am a bit disappointed but i understand the work on that ain't easy. I was looking to replace tokio but it seems this isn't the moment 😔
00:48:58FromDiscord<Chronos [She/Her]> Why couldn't you use channels in a single threaded environment anyway
00:49:09FromDiscord<Elegantbeef> You can but it's pointless
00:49:14FromDiscord<Elegantbeef> You're locking for no reason
00:49:28FromDiscord<Chronos [She/Her]> Fair enough
00:55:03*lucasta quit (Remote host closed the connection)
00:55:28*lucasta joined #nim
01:07:54FromDiscord<Graveflo> in the readme of beef's `constructor` package it says "`constructor` works similarly to `construct`". I searched around for `construct` but I can't find anything. what is this reference to?
01:08:05FromDiscord<Elegantbeef> An old feature
01:09:38FromDiscord<Elegantbeef> Of my macros\
01:10:20FromDiscord<Chronos [She/Her]> Hmm maybe i should look into that project
01:10:28FromDiscord<Elegantbeef> This abomination used to exist
01:10:29FromDiscord<Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/1112910870431936582/image.png
01:11:18FromDiscord<Chronos [She/Her]> Inchresting, how does it look now?
01:11:46FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4x2w
01:11:49*lucasta quit (Quit: Leaving)
01:11:52FromDiscord<Graveflo> sent a code paste, see https://play.nim-lang.org/#ix=4x2x
01:12:32FromDiscord<Elegantbeef> No clue really, you're not supposed to use anything but constant values on `=`
01:12:48FromDiscord<Chronos [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4x2y
01:14:08FromDiscord<Elegantbeef> There is a bunch of initialisation magic inside that package some of which has been formally adopted by Nim
01:15:38FromDiscord<Graveflo> also I can't find a good way to read the address that a ref is pointing to. This was my best guess but I have no idea what I'm doing with it. `cast[ptr[uint]](some_ref_variable.unsafeAddr)[]`. I think this assumes that the address is going to point to a "dumb pointer" with only a memory address at offset 0. I don't ever need to do this unless I am trying to teach myself how nim is working but I've needed it a couple times.
01:15:51FromDiscord<Elegantbeef> `cast[int](myRef)`
01:16:11FromDiscord<Elegantbeef> or just `echo myRef.repr`
01:18:41FromDiscord<Graveflo> yea.. looks right. I know I tried that cast too but for some reason it thought it didn't work and repr is even better. Thanks
01:31:32*boxuser joined #nim
02:08:04*boxuser left #nim (#nim)
02:32:20FromDiscord<emanresu3> hey nimsters in oop what is more common for nim `this` or `self`? I've seen both used in nim's source code
02:42:49FromDiscord<Elegantbeef> Neither
02:42:53*boxuser joined #nim
02:42:56FromDiscord<Elegantbeef> Stop it use descriptive field names
02:43:01FromDiscord<Elegantbeef> parameter\
02:46:28FromDiscord<emanresu3> what if the class name is already descriptive?
02:46:47*om3ga quit (Ping timeout: 268 seconds)
02:48:12FromDiscord<Elegantbeef> I mean you do you there is no defined best naming
02:48:32FromDiscord<Elegantbeef> I personally find `self` very annoying since there is no clear separation between what a procedure is for
02:49:36NimEventerNew Nimble package! simplelog - A deadly simply log package supporting very simple colorful logging., see https://github.com/sslime336/simplelog
02:50:09FromDiscord<Graveflo> doesn't the name of the proc tell you what it's for?
02:50:51FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/qPjGG
02:51:34FromDiscord<Elegantbeef> I think it's incorrect to use `self` since Nim is procedural and you are not attaching a procedure to a type, you're operating on data passed in
02:52:05FromDiscord<Elegantbeef> But like i said the answer is use whichever you prefer
02:52:29FromDiscord<emanresu3> sure, I was just asking what is more common
02:53:04FromDiscord<Elegantbeef> Well i've only seen `self` and `this` sparingly
02:53:09FromDiscord<Elegantbeef> So... neither 😄
02:53:25FromDiscord<Graveflo> I mean those procs are coupled as tightly as you can get to the type of their first parameter because the compiler will enforce the coupling through static typing. It really just comes down to how "attached" is defined
02:53:32FromDiscord<huantian> Well if it is a method, perhaps self/this is correct
02:53:46FromDiscord<huantian> Or at least admittable
02:54:00FromDiscord<Graveflo> yea thats what I was about to say. It might make sense for 'self' to mean that a function is doing OOP type things
02:54:03FromDiscord<Elegantbeef> Perhaps, I still do not see `self`/`this` often and just read it as a code smell
02:56:09FromDiscord<huantian> Easy TRM to ban it right?
02:56:12FromDiscord<huantian> 🙃
02:56:23FromDiscord<Elegantbeef> Right
03:08:15FromDiscord<that_dude> Yo elegant, does the {.this.} pragma not exist anymore? I can find it in some gh comments, but not in any documentation
03:08:27FromDiscord<Elegantbeef> I've never seen it before
03:09:26FromDiscord<that_dude> sent a code paste, see https://play.nim-lang.org/#ix=4x3x
03:09:44FromDiscord<Elegantbeef> What does that even do alias `self` to `this`?
03:09:47FromDiscord<that_dude> https://github.com/nim-lang/Nim/issues/5053
03:10:01FromDiscord<that_dude> It seem like it also messes with the scope
03:10:44FromDiscord<that_dude> `{.this.} is deprecated. Can be closed?` ah nevermind I think
03:22:46FromDiscord<kcvinker> sent a code paste, see https://play.nim-lang.org/#ix=4x3F
03:24:53FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4x3I
03:24:54FromDiscord<Elegantbeef> But why are you not using an object variant
03:26:03FromDiscord<kcvinker> I am using nim dll in another scripting langage
03:27:03FromDiscord<kcvinker> It can send a pointer to nim
03:27:34FromDiscord<kcvinker> And in nim, I want to fill some data in that pointer.
03:29:17FromDiscord<kcvinker> @ElegantBeef , If i am not using var for pValue, I cannot assign to it
03:29:49FromDiscord<Elegantbeef> Right you do not want to assign it you want to write to where it points
03:29:55FromDiscord<Elegantbeef> You do not even want to do that
03:30:01FromDiscord<Elegantbeef> It's a pointer to some memory you want to copy from it to your nim data
03:30:39FromDiscord<Elegantbeef> Unless it's represented as a `void` what you're doing is wrong
03:31:32FromDiscord<kcvinker> currently, it's just an `int` at the calling site
03:32:03FromDiscord<Elegantbeef> Then yea what you're doing is wrong
03:32:06FromDiscord<kcvinker> So let me try with `int`
03:33:07FromDiscord<kcvinker> For typed data, everything works nice
03:33:33FromDiscord<kcvinker> If i use `var int`, its okay
03:33:56FromDiscord<Elegantbeef> I mean you need to do `copyMem` to move the data to the pointer
03:34:19FromDiscord<Elegantbeef> But what's the point of `pValue = cast[ptr float](pvalue)`
03:36:07FromDiscord<kcvinker> In reply to @Elegantbeef "But what's the point": cast the pointer to hold an int value
03:36:10FromDiscord<Elegantbeef> You've now made it point to itself
03:36:27FromDiscord<Elegantbeef> that's not needed
03:36:33FromDiscord<Elegantbeef> just do `copyMem` and call it a day
03:36:39FromDiscord<kcvinker> Oh i see
03:36:59FromDiscord<kcvinker> Thank you @ElegantBeef
03:37:06FromDiscord<JJ> curious to anyone who's used npegs extensively: how on earth do you deal with capturing optional values?
03:37:10FromDiscord<Elegantbeef> You have a type erased pointer, you can just write to it's destination assuming there is enough space there
03:37:24FromDiscord<Elegantbeef> Rumour has it if you ask about npeg enough a wild zevv appears
03:37:41FromDiscord<JJ> haha
03:37:59FromDiscord<JJ> sent a code paste, see https://play.nim-lang.org/#ix=4x45
03:38:29FromDiscord<JJ> this doesn't work because code blocks are executed regardless of backtracking: yet i can't think of another way to deal with ex. `?(scheme ":")`
03:38:37FromDiscord<Elegantbeef> I only suggest npeg, never used it myself
03:39:03FromDiscord<JJ> it's nice to use when i know how to use it
03:40:41FromDiscord<JJ> pulling my hair out a bit rn b/c the codeblocks though
03:50:19FromDiscord<JJ> christ, i think this is the Big Issue unfortunately
03:50:37FromDiscord<JJ> time to make this ugly
03:53:15FromDiscord<leorize> you can also just ask Zevv on how to deal with that \:p
03:53:41FromDiscord<Elegantbeef> So leo I used your highlighting all day today
03:53:57FromDiscord<Elegantbeef> It works ok for normal code 😄
03:54:25FromDiscord<leorize> it better be \:p a lot of interesting features depends on it
03:55:08FromDiscord<leorize> rn I'm playing with injections, ie. use markdown parser on doc comments
03:55:44FromDiscord<Elegantbeef> I do have to change my themes highlighting, cause it gives some red symbols which makes me think errors
03:56:39FromDiscord<leorize> probably for stuff like templates?
03:56:58FromDiscord<Elegantbeef> Think it was field access that was shown as red for me
03:57:10FromDiscord<Elegantbeef> Hurts the brain cause my instant reaction is "That's an error"
03:57:19FromDiscord<leorize> your theme is brutal lol
03:57:34FromDiscord<Elegantbeef> It's one of the stock vim distros
03:57:50FromDiscord<Elegantbeef> Had to check it's astronvim
03:58:11FromDiscord<leorize> most vscode themes have a nvim equivalent
03:58:21FromDiscord<leorize> in case you want something else
04:00:05FromDiscord<JJ> In reply to @leorize "you can also just": i think it's basically this: https://github.com/zevv/npeg/issues/32#issuecomment-817284051
04:00:41FromDiscord<JJ> without named captures and with code blocks executing on backtracking i'm not actually sure if there's any way to deal with it, going to try some stuff first though
04:05:57*boxuser quit (Read error: Connection reset by peer)
04:09:03NimEventerNew thread by melovv: Using TCC/NLVM to compile source code in a string, see https://forum.nim-lang.org/t/10235
04:11:32*boxuser joined #nim
04:26:20FromDiscord<leorize> then I suppose you have to avoid backtracking altogether
04:26:55FromDiscord<leorize> an another trick that I could think of is to write a lexer and then use npeg to parse that
04:29:00FromDiscord<JJ> currently mangling my code so that every capture group has at most one optional statement, and then am checking the length of the capture list to determine whether or not it was matched and overwrite with the default value as necessary
04:29:19FromDiscord<JJ> i've never turned decent code into code this bad before
04:29:23FromDiscord<JJ> (edit) "bad" => "disgusting"
04:31:40FromDiscord<leorize> hmm I still can't imagine why backtracking would occur for this grammar
04:32:05FromDiscord<JJ> it's this part: `authority <- ?(>userinfo "@") hostport`
04:33:25FromDiscord<JJ> well actually a couple parts ig
04:36:18FromDiscord<leorize> try `-d:npegTrace`
04:36:36FromDiscord<leorize> that should give you something to figure the backtracking issue with
04:40:41FromDiscord<JJ> well i finished my mangling. it now "works" (by throwing all of the performance out the window)
04:40:59FromDiscord<leorize> at that point maybe just write a parser from scratch \:P
04:41:00FromDiscord<JJ> sent a code paste, see https://play.nim-lang.org/#ix=4x4b
04:41:34FromDiscord<leorize> have you tried the sample parser? https://github.com/zevv/npeg/blob/master/src/npeg/lib/uri.nim
04:41:35FromDiscord<JJ> i already have a parser from scratch, this is replacing that :-P
04:41:52FromDiscord<JJ> wait, what? haha
04:42:25FromDiscord<JJ> oh right yeah: it doesn't do captures unfortunately and captures are the problem
04:48:19FromDiscord<JJ> i think either code blocks not executing on backtraced steps or named captures / captures in optional blocks capturing default values instead of not existing would solve this. though from what i've read it seems like code blocks executing on backtraced steps might be necessary (don't know why)
04:49:04FromDiscord<leorize> a potential way out is to use a scanner in conjunction with the parser
04:50:50FromDiscord<user2m> sent a code paste, see https://play.nim-lang.org/#ix=4x4c
04:53:43FromDiscord<leorize> yea there are many unambiguous tokens, if you scan them out first the parser can potentially not backtrack as much
04:53:52FromDiscord<leorize> but I'm not entirely sure if npeg can decide tokens based on lookahead
04:54:33FromDiscord<Graveflo> In reply to @user2m "Anyone using the ImGui": platform?
04:55:11FromDiscord<user2m> In reply to @Graveflo "platform?": NVM! Just figured it out I had to compile to cpp `nim cpp -r timgui.nim`
04:55:15FromDiscord<JJ> yeah, i wanted to rewrite some simple parsers in npeg because it's cleaner / easier to be correct, but man this might have been the worst thing to rewrite
04:56:12FromDiscord<JJ> looking into the codebase now though - for something i consider absolute magic it's surprisingly little code
05:19:37*boxuser quit (Read error: Connection reset by peer)
05:30:05FromDiscord<JJ> i suppose i should ping @zevv: any tips for returning optional captures when backtracking is involved ex. in the examples above? and is deferring the execution of code blocks feasible?
05:30:50FromDiscord<JJ> oops. that was probably the wrong zevv.
05:36:59*rockcavera quit (Remote host closed the connection)
06:03:44*Jjp137 quit (Ping timeout: 248 seconds)
06:04:06*Jjp137 joined #nim
06:05:05*boxuser joined #nim
06:15:21*ntat joined #nim
06:39:12*PMunch joined #nim
06:48:21FromDiscord<Dudugz> sent a code paste, see https://play.nim-lang.org/#ix=4x4r
06:50:07FromDiscord<Elegantbeef> No
06:50:12FromDiscord<Elegantbeef> Easier to use an array or distinct types
07:02:05PMunchOr use a case statement
07:03:13*Notxor joined #nim
07:03:14FromDiscord<Dudugz> Sure
07:03:43FromDiscord<Dudugz> So procs can have different return values ​​based on which enum key was used?
07:04:09FromDiscord<Elegantbeef> What?
07:04:47FromDiscord<Dudugz> I mean, I don't want to create multiple procs for the same thing, the only thing that changes is the return value, the logic is the same just for different data.
07:05:05FromDiscord<Elegantbeef> take in a static enum use `when`
07:05:17FromDiscord<Dudugz> Sure
07:05:20*om3ga joined #nim
07:05:36*Notxor left #nim (#nim)
07:12:37FromDiscord<Rika> Static enum means compile time values only though just a heads up
07:28:28Amun-Raor have an arg of var T
07:45:18FromDiscord<System64 ~ Flandre Scarlet> Is it normal my Nim program requires thoses DLLs?↵The only dependencies I use are NimGL and ImGUI https://media.discordapp.net/attachments/371759389889003532/1113010229844639764/image.png https://media.discordapp.net/attachments/371759389889003532/1113010230058553384/image.png
07:45:47FromDiscord<leorize> if you compiled with gcc, then yes
07:46:08FromDiscord<System64 ~ Flandre Scarlet> In reply to @leorize "if you compiled with": And is it possible to statically link them?
07:47:11FromDiscord<mratsim> In reply to @System64 "And is it possible": `--dynlibOverride:mylib --passL:libmylib.a`
07:47:19FromDiscord<abisxir> Hey guys, anything ready for multiline spinner/progress in nim?
07:47:42FromDiscord<mratsim> In reply to @System64 "Is it normal my": seems like you compiled on windows via minGW?
07:47:53FromDiscord<System64 ~ Flandre Scarlet> In reply to @mratsim "seems like you compiled": I used Nim's compiler
08:17:04FromDiscord<System64 ~ Flandre Scarlet> In reply to @mratsim "seems like you compiled": Is it normal I have that? https://media.discordapp.net/attachments/371759389889003532/1113018228294295582/message.txt
08:25:02FromDiscord<System64 ~ Flandre Scarlet> Well, wouldn't it be simpler to compile with Clang instead?
08:25:09FromDiscord<System64 ~ Flandre Scarlet> btw I use the C++ backend
08:41:19PMunchHmm, did something happen with shifts, oring, xoring etc. between 0.20.0 and 0.20.2?
08:41:35PMunchThis library breaks between those two versions: https://github.com/MarcAzar/RollingHash
08:57:21FromDiscord<System64 ~ Flandre Scarlet> I tried with clang, but why it doesn't compile? https://media.discordapp.net/attachments/371759389889003532/1113028364207394836/message.txt
08:59:17FromDiscord<PMunch> Seems like you don't link it properly to something
08:59:40FromDiscord<PMunch> It complains that it is missing `imp_DragQueryFileW` and similar symbols
09:03:08FromDiscord<System64 ~ Flandre Scarlet> In reply to @PMunch "It complains that it": I don't even use this function
09:03:29PMunchWell something uses it
09:03:45PMunchUnless it's somehow always generated
09:04:06PMunchI guess something being `exportc`'d would make it always generate for example
09:04:58FromDiscord<System64 ~ Flandre Scarlet> In reply to @PMunch "Unless it's somehow always": I use NIMGL and ImGUI (from NIMGL)↵I tried with MinGW but the problem is it doesn't work on some people's computer because Windows moment
09:12:26PMunchSure it's not just a runtime dependency on some DLL?
09:13:15FromDiscord<System64 ~ Flandre Scarlet> In reply to @PMunch "Sure it's not just": The user has the DLLs
09:23:07PMunchAnd they set their path correctly?
09:23:20PMunchTheir library loading path that is
09:24:03*Nam__ quit (Read error: Connection reset by peer)
09:26:17FromDiscord<System64 ~ Flandre Scarlet> In reply to @PMunch "Their library loading path": Even if the dlls are in the same dir as the exe
09:33:03PMunchHmm, does it return an error? Have you checked it with a dynlib checker?
09:34:27FromDiscord<System64 ~ Flandre Scarlet> In reply to @PMunch "Hmm, does it return": it returns 0xC000007B↵And which dynlib checker should I use?
09:36:22PMunchI've used this tool before for this purpose: http://www.dependencywalker.com/
09:37:47PMunchThis might also be useful: https://github.com/nim-lang/Nim/issues/19713
09:43:10FromDiscord<System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4x4N
10:21:52FromDiscord<chmod222> Any way to "unpack" a seq[T] into UncheckedArray[T] so I have a pointer to some data that will not get destroyed when the seq[] goes out of scope?
10:22:25Amun-Ranot without copy
10:22:36FromDiscord<chmod222> shame
10:25:24PMunchWell..
10:25:52PMunchYou could do some trickery with pointers GC_ref and destructors
10:26:08FromDiscord<chmod222> I know I could replicate the compiler internal structure and yank the pointer out by reinterpreting the seq[]
10:26:19FromDiscord<chmod222> But I try to maintain some of my sanity
10:26:51FromDiscord<chmod222> This section of code is not a hot loop and I can stomach a copy
10:26:59FromDiscord<chmod222> Still would have been nice not to have to
10:39:15*derpydoo quit (Read error: Connection reset by peer)
11:27:07*boxuser left #nim (#nim)
12:54:32FromDiscord<System64 ~ Flandre Scarlet> Does Nim have a static version of libgcc_s_seh-1.dll and libstdc++-6.dll?
12:58:01PMunchAh, you found your missing dependencies?
12:58:03FromDiscord<jtv> @chmod It's not that hard; GC_ref it, then grab addr item[0], and there's your unchecked array, not going to out of scope until you decref it.
12:58:32PMunchThis might be of interest to you: https://scripter.co/nim-deploying-static-binaries/
13:01:55FromDiscord<System64 ~ Flandre Scarlet> In reply to @PMunch "Ah, you found your": Yeah, I needed the Nim's ones
13:02:01FromDiscord<filipemtx> have you guys used gintro with a ui file created on glade?↵I can't make it work I dunno what to do.↵I'm using this piece of the documentation
13:02:02FromDiscord<filipemtx> https://github.com/StefanSalewski/gintro#gtk-builderuser-interfaces-created-with-the-glade-tool
13:02:30FromDiscord<filipemtx> I'm able to compile the script on my windows if it is a certain type of xml
13:02:39FromDiscord<filipemtx> but when I do it from a glade ui I do, it doesn't work
13:02:43FromDiscord<filipemtx> can any1 help?
13:03:03FromDiscord<least antisemitic pole> explain to me how karax knows when to rerender on variable modification like im clinically stupid
13:03:06PMunchSystem64_~_Flandre_Scarlet, those aren't Nim-specific, it's just GCC and libc stuff
13:03:41FromDiscord<System64 ~ Flandre Scarlet> In reply to @PMunch "System64_~_Flandre_Scarlet, those aren't Nim-specif": Yeah but no idea why, but it works with those ones
13:03:48PMunchfilipemtx, wild guess is that you have to set your Glade export to use the correct Gtk version
13:03:56FromDiscord<System64 ~ Flandre Scarlet> Also Dependency Walker doesn't work for me
13:04:00PMunchI remember having issues like this with Gtk 2/3 in the past
13:04:06FromDiscord<filipemtx> hmmm
13:04:12FromDiscord<filipemtx> thanks I'm gonna take a look
13:04:22PMunchSystem64_~_Flandre_Scarlet, what do you mean doesn't work?
13:04:38FromDiscord<filipemtx> (edit) "do," => "make,"
13:04:43PMunchfilipemtx, not sure if it's the same issue, but it's a possibility
13:04:52FromDiscord<System64 ~ Flandre Scarlet> The windows error I talked about earlier
13:05:00FromDiscord<filipemtx> In reply to @PMunch "<@434491334838190082>, not sure if": ok thx!
13:05:23FromDiscord<System64 ~ Flandre Scarlet> In reply to @PMunch "System64_~_Flandre_Scarlet, what do you": Oh, Dependency Walker, the program just freezes when I load my exe
13:05:24PMunchSystem64_~_Flandre_Scarlet, dependencywalker has the same error?
13:05:36PMunchAh, that's probably not a great sign
13:05:37FromDiscord<System64 ~ Flandre Scarlet> No no, it freezes
13:05:49FromDiscord<System64 ~ Flandre Scarlet> It always did that with me
13:05:51PMunchBeen a while since I used that tool though, might be something better out there
13:06:06PMunchOn Linux I'd just use ldd or something
13:08:21FromDiscord<kcvinker> sent a code paste, see https://play.nim-lang.org/#ix=4x5n
13:09:09FromDiscord<chmod222> I have to say, I really like how Nim doesn't get in my way when I really need to play around with memory and temporarily explode the limits of the type system, in a time where most languages get more and more restrictive for good, but frustrating reasons
13:10:23FromDiscord<System64 ~ Flandre Scarlet> Nim is quite strict about types
13:11:06FromDiscord<chmod222> Putting an `UncheckedArray[T]` as the last member of a struct and leaving it up to me to correctly deal with offsetting and allocating enough space is quite generous these days
13:11:14FromDiscord<chmod222> Well yes, unless you tell it not to
13:14:26FromDiscord<Nerve> I find `JsonNode` is a very nice way to get a dynamic heterogenous data structure. I have to check types when unpacking, of course, but that advantages are sometimes too strong to care.
13:14:43FromDiscord<Nerve> Nim can be less strict when you ask and it helps you along
13:15:35PMunchkcvinker, that's definitely not the best way of doing it
13:16:21FromDiscord<kcvinker> In reply to @PMunch "<@633714482572689449>, that's definitely not": Okay. Then could you please show me how to do it ?
13:16:32PMunchWell, depending on what "it" is of course, but for most sane "it"s this would not be a good way of achieving "it"
13:16:47FromDiscord<kcvinker> Yup
13:18:14PMunchFirst of `case` over an `int` is probably not a great idea. If you have discrete actions you should prefer an enum. That `else: discard` is a bad code smell and would likely lead to issues down the road
13:18:48PMunchSecond, `var pointer` means you can edit the pointer, which you don't do. You edit what's behind the pointer, which is fine without the `var` keyword.
13:19:03FromDiscord<mratsim> In reply to @PMunch "First of `case` over": I create an "unreachable" proc for those.
13:19:19FromDiscord<kcvinker> @PMunch Okay
13:20:04*progranner joined #nim
13:20:16PMunchThird, you create a ref object only to assign it some data and use it as a pointer. This just leads to an extra copy with no benefit. I'd use `cast[ptr int32](pValue)[] = this.width` instead and drop the whole `iPtr` and `copyMem` dance.
13:20:37PMunchmratsim, an unreachable proc?
13:21:16FromDiscord<kcvinker> In reply to @PMunch "First of `case` over": Please don't mind the `case` statement. Because, I will create an enum for it and I will cover all the possible values in it.
13:23:50PMunchThat part is fine then, but the other things should be changed. Oh and you're also missing a comma in your arguments list
13:24:29FromDiscord<kcvinker> In reply to @PMunch "That part is fine": Tyoe
13:24:35FromDiscord<kcvinker> (edit) "Tyoe" => "Typo"
13:25:13FromDiscord<kcvinker> @PMunch ↵> `cast[ptr int32](pValue)[] = this.width`↵This worked like a charm. Thanks a lot 🙂
13:25:44PMunchNo problem :)
13:26:08PMunchWhat are you trying to achieve here anyways?
13:26:27FromDiscord<Dudugz> sent a long message, see http://ix.io/4x5s
13:26:39*antranigv quit (Ping timeout: 256 seconds)
13:26:41*antranigv_ joined #nim
13:27:10FromDiscord<Dudugz> (edit) "http://ix.io/4x5s" => "https://paste.rs/6Quek"
13:30:38*antranigv_ is now known as antranigv
13:31:04FromDiscord<leorize> depends on your latency requirements
13:31:25*antranigv is now known as antranigv_
13:31:52FromDiscord<Dudugz> Well, there are not many requirements, there are only two states, either the person is playing, or he is accessing information, it is not possible to do both at the same time.
13:31:59FromDiscord<Dudugz> (edit) removed "he"
13:35:11*antranigv_ is now known as antranigv
13:36:46*antranigv is now known as antranigv_
13:39:45FromDiscord<rb3.nim> sent a code paste, see https://play.nim-lang.org/#ix=4x5w
13:59:51*PMunch quit (Quit: Leaving)
14:11:07*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
14:12:47FromDiscord<leorize> personally I'd do queue management on server side rather than client side
14:13:33FromDiscord<leorize> you can't really rely on a defense in the client where the user have control
14:15:27*progranner joined #nim
14:21:25*ntat quit (Quit: Leaving)
14:21:43*ntat joined #nim
14:24:43FromDiscord<least antisemitic pole> can I hide/rename the default `result` variable in a proc?
14:25:07FromDiscord<least antisemitic pole> use case is, im writing a macro and I have no access to the external result because of overshadowing
14:25:24FromDiscord<least antisemitic pole> by the "internal" implrementation-detail proc
14:26:00*sunset joined #nim
14:30:38FromDiscord<mratsim> In reply to @PMunch "<@570268431522201601>, an unreachable proc?": something to quit with a lot of noise to ease debugging compared to discard
14:41:10FromDiscord<least antisemitic pole> how to make a types empty set? `{}` but with a type
14:47:03*antranigv_ is now known as antranigv
14:48:01FromDiscord<Nerve> `initSet`, `initOrderedSet`, `initHashSet`
14:48:29FromDiscord<Nerve> Apparently there is a generic `init`
14:50:58*sunset left #nim (#nim)
14:57:43*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
15:00:03*progranner joined #nim
15:04:55FromDiscord<Gumbercules> pretty sure this gets invoked in each module prior to any other function
15:05:03FromDiscord<Gumbercules> the "generic `init`"
15:05:20FromDiscord<Gumbercules> (edit) "prior to any other function" => "when it is loaded"
15:05:51FromDiscord<Gumbercules> maybe I'm thinking of Odin....
15:19:24*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
15:19:55FromDiscord<Dudugz> In reply to @leorize "personally I'd do queue": this is on server side :v clients should never get direct access to db
15:22:28*progranner joined #nim
16:09:05FromDiscord<cmc> Is there something like sequtils for tables? e.g. "iterate over all pairs where value-field `foo` is larger than 3".
16:09:21FromDiscord<arkanoid> why nlvm is a separate independent project, instead of being the "LLVM IR" backend of nim?
16:09:51FromDiscord<cmc> Or 'give me a sorted table of all pairs sorted by value-field foo'
16:28:10FromDiscord<juan_carlos> In reply to @arkanoid "why nlvm is a": No idea, but I seen the dude of Zig complaining about llvm breakages, memory fragmentation, performance, etc etc time to time.
16:29:11FromDiscord<juan_carlos> (edit) "time." => "time (as in not perfect silver bullet neither)."
16:29:45arkanoidjuan_carlos: seems pretty improbable, considering whole Apple works rely on it, and lots of the rest too
16:30:33FromDiscord<juan_carlos> Yeah Apple on desktop is not bug free neither.
16:30:43FromDiscord<juan_carlos> Also https://arewestackefficientyet.com
16:33:37*arkurious joined #nim
16:33:41*arkurious quit (Remote host closed the connection)
16:34:59FromDiscord<etra> In reply to @juan_carlos "Also https://arewestackefficientyet.com": but that's comparing two llvm projects, clang and rustc
16:35:06FromDiscord<etra> (edit) "llvm" => "llvm-backed"
16:35:15arkanoidjuan_carlos, this is rustc vs clang, both llvm
16:36:12FromDiscord<juan_carlos> Yep
16:36:36FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4x6a
16:36:50FromDiscord<Arathanis> (edit) "https://play.nim-lang.org/#ix=4x6a" => "https://play.nim-lang.org/#ix=4x6b"
16:58:24*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
16:59:23*progranner joined #nim
17:04:52*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
17:07:29*progranner joined #nim
17:11:37*progranner quit (Client Quit)
17:14:46*progranner joined #nim
17:17:07FromDiscord<Elegantbeef> @Arathanis\: this isnt even move semantics Nim sequences are value types
17:17:45FromDiscord<Arathanis> In reply to @Elegantbeef "<@136570191038513152>\: this isnt even": does that mean i just need to make `s` a `ref seq[int]`?
17:18:07FromDiscord<Elegantbeef> Or do the unsafe `var s = e[].s.addr` and `s[].add 42`
17:18:23FromDiscord<Elegantbeef> or you know pass `e.s` to a procedure
17:18:24FromDiscord<mratsim> _pitchfork_
17:19:06FromDiscord<Arathanis> let's do it the unsafe way to scare away the rustacians
17:19:32FromDiscord<Elegantbeef> there is `std/decls` to make it little less scary
17:19:42FromDiscord<Elegantbeef> `var s {.byaddr.} = e[].s`
17:19:50*rockcavera joined #nim
17:23:11FromDiscord<Arathanis> im gonna take a look at this lib, haven't seen it yet
17:24:13FromDiscord<Arathanis> Beef, is there a list of builtins that are value vs ref?
17:26:18*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
17:28:19*progranner joined #nim
17:29:44FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4x6m
17:30:09FromDiscord<Elegantbeef> All Nim primitives are values
17:30:58FromDiscord<Arathanis> (edit) "https://play.nim-lang.org/#ix=4x6m" => "https://play.nim-lang.org/#ix=4x6n"
17:31:25FromDiscord<Elegantbeef> When you write the variable name it expands into `tmp[]`
17:33:26FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4x6o
17:33:40FromDiscord<Arathanis> well i guess the "s2" specifically is the template
17:33:41FromDiscord<Elegantbeef> It doesnt turn it into a template
17:33:44FromDiscord<Elegantbeef> `s2` is a template
17:33:51FromDiscord<Elegantbeef> it just calls the template
17:36:36FromDiscord<Arathanis> so the return type of `{.byaddr.}` is a template and a closure that causes the identifier I assign to to be a template that expands to dereferencing the inner temp pointer
17:36:38FromDiscord<Arathanis> (edit) "pointer" => "pointer?"
17:40:26FromDiscord<Arathanis> no wait, def not a closure. tmp just is not injected so I can't reference it directly.
17:46:58FromDiscord<Arathanis> final question while I reckon how this template works.
17:47:44FromDiscord<Arathanis> so the template takes 3 params and is applied to a assignment expression. does the template mechanisms automatically unpack the 3 pieces of the assignment expression since its AST Node has 3 parts?
17:48:07FromDiscord<Arathanis> (edit) "so the template takes 3 params and is applied to a assignment expression. does the ... templatemechanism" added "compiler" | "mechanisms" => "mechanism" | "templatemechanismautomatically unpack the 3 pieces of the assignment expression since its AST Node has 3 parts? ... " added "are there any other examples of using this kind of unpacking?"
17:57:16FromDiscord<guttural666> do you guys split files like lexer.nim and lexer_types.nim to avoid circular dependencies?
17:58:15FromDiscord<mratsim> In reply to @guttural666 "do you guys split": yes
17:58:17FromDiscord<guttural666> had some problems in the past with this, where a file had to know about at least the types, but not the functionality
17:58:25FromDiscord<Arathanis> what was the alternative structure that was causing a circular dep?
17:58:30FromDiscord<Arathanis> also: yes
17:58:32FromDiscord<guttural666> In reply to @mratsim "yes": okay, so I am not insane probably 😄
18:00:01FromDiscord<guttural666> In reply to @Arathanis "what was the alternative": main -> calling db -> calling api, but api still had to know about db to be able to parse answers into valid db types
18:00:52FromDiscord<guttural666> so I did a strictly linear dependency hierarchy for the procs and was able to share the types around promiscuously
18:00:56FromDiscord<Arathanis> so db was importing api but api was importing db?
18:01:04FromDiscord<guttural666> that's it
18:01:31FromDiscord<Arathanis> or specifically, db was importing api so it could call it, and api was importing db so it knew how to coerce to db types
18:01:42FromDiscord<guttural666> exactement
18:02:37FromDiscord<guttural666> will need the same for main->lexer->parser I am pretty sure
18:03:00FromDiscord<Arathanis> lexer should not need to know anything about parser
18:03:14FromDiscord<guttural666> yeah you're right actually
18:03:15FromDiscord<Arathanis> or at least, none of the lexer/parser pairs ive ever written should.
18:03:19FromDiscord<Arathanis> lexer is just a tokenizer
18:03:24FromDiscord<guttural666> indeed
18:03:33FromDiscord<Arathanis> parser needs to know about tokens and the perhaps the lexer itself, but lexer should care at all
18:04:31FromDiscord<Graveflo> sent a long message, see http://ix.io/4x6y
18:05:45FromDiscord<Arathanis> In reply to @Graveflo "I'm trying to write": my recommendation is to just build it instead of agonizing about the design. you can always iterate on that but going back to the drawing board is going to prevent you from discovering the other things you need to figure out
18:05:58FromDiscord<Arathanis> unless that is what is currently happening, in which case, welcome to the design process 😂
18:06:17FromDiscord<Arathanis> @guttural666 id probably lift the IO out completely and put a facade between them.
18:06:18FromDiscord<guttural666> In reply to @Arathanis "my recommendation is to": probably the hardest lesson to learn in SE, just build a simple solution and iterate
18:06:38FromDiscord<Arathanis> I don't think the db and api should know about each other at all. You can have a 3rd layer that handles that for you
18:06:49FromDiscord<Arathanis> In reply to @guttural666 "probably the hardest lesson": exactly, the design will come out of trial and error
18:07:06FromDiscord<Graveflo> I certainly agree with that. I will do that too. I guess the issue is I'm not sure how I'm going to learn my lesson about this one if I am wrong. I'm not expecting it to fail
18:07:11FromDiscord<Arathanis> write that PoC, discover the unknowns, iterate forever
18:07:26FromDiscord<Arathanis> In reply to @Graveflo "I certainly agree with": decide in some kind of MVP PoC
18:07:28FromDiscord<Arathanis> and just implement it
18:07:36FromDiscord<Arathanis> some kind of base functionality
18:07:39FromDiscord<Arathanis> then iterate and expand upon it
18:07:52FromDiscord<Arathanis> you will discover if rewrites are necessary but in doing so the proper design will become clear.
18:08:09FromDiscord<guttural666> In reply to @Arathanis "write that PoC, discover": more fun as well, since you actually write stuff, most initial ideas are trash, but you can only possibly find out as you go
18:08:39FromDiscord<Arathanis> In reply to @guttural666 "more fun as well,": that is possibly the biggest benefit
18:08:50FromDiscord<Arathanis> you actually grow and learn and write code instead of feeling stuck in a rut of whiteboarding the design
18:08:55FromDiscord<Arathanis> there is a reason waterfall fell out of style
18:09:04FromDiscord<Arathanis> (edit) "there is a reason waterfall fell out of style ... " added "in favor of agile"
18:10:12FromDiscord<Arathanis> @guttural666 not facade, bridge. had to bust out the ol' Book of 4
18:10:53FromDiscord<guttural666> In reply to @Arathanis "<@375727321958580228> not facade, bridge.": yeah probably similar to model, view, controller design
18:11:22FromDiscord<guttural666> (edit) "In reply to @Arathanis "<@375727321958580228> not facade, bridge.": yeah probably similar to model, view, controller design ... " added "for GUI"
18:12:20FromDiscord<Arathanis> yeah
18:12:37FromDiscord<Arathanis> db talks to and from database, with appropriate types
18:12:41FromDiscord<Arathanis> api talks to and from api with approprioate types
18:12:51FromDiscord<Arathanis> bridge is a translation layer between the two
18:12:57FromDiscord<Arathanis> and main orechestrates
18:13:01FromDiscord<Arathanis> (edit) "orechestrates" => "orchestrates"
18:13:53FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4x6z
18:14:23FromDiscord<Arathanis> and now api and db can change independent of each other
18:14:28FromDiscord<Arathanis> decoupling 🙏
18:17:49FromDiscord<guttural666> yeah, that sounds reasonable, but if you just want the API to build and return appropriate types to the db, just outsourcing the types is pretty good as well
18:20:07FromDiscord<ieltan> sent a code paste, see https://play.nim-lang.org/#ix=4x6A
18:22:43*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
18:25:04*progranner joined #nim
18:27:53FromDiscord<guttural666> In reply to @ieltan "This template doesn't work": thinking about varargs when I see this, not sure if that is helpful
18:31:29FromDiscord<guttural666> prob not
18:32:53FromDiscord<Arathanis> im gonna assume you actually want a macro here
18:33:14FromDiscord<Arathanis> or just wait for beef to come solve the problem :]
18:34:17FromDiscord<ieltan> In reply to @guttural666 "thinking about varargs when": Nope already tried that and it doesn"t work ...
18:34:53FromDiscord<ieltan> In reply to @Arathanis "im gonna assume you": hmmm.. nevermind then ... Thanks
18:36:09FromDiscord<Arathanis> In reply to @ieltan "hmmm.. nevermind then ...": dont want to use a macro?
18:37:05*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
18:37:38FromDiscord<Elegantbeef> Why do people use templates for no reason
18:37:46FromDiscord<Elegantbeef> The simplest tool, cmon people
18:38:26FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/qNNnN
18:38:49FromDiscord<Arathanis> i had a feeling this was going to be the result, and I was about to suggest it haha
18:39:00FromDiscord<Arathanis> told you beef would show up and lay down the law
18:39:46FromDiscord<ieltan> sent a code paste, see https://play.nim-lang.org/#ix=4x6E
18:40:01FromDiscord<kcvinker> sent a code paste, see https://play.nim-lang.org/#ix=4x6F
18:40:26FromDiscord<ieltan> sent a code paste, see https://play.nim-lang.org/#ix=4x6G
18:40:28FromDiscord<Elegantbeef> What's the error?
18:40:39FromDiscord<ieltan> Thanks anyways beef
18:41:29*progranner joined #nim
18:43:01FromDiscord<Elegantbeef> @kcvinker that question above was for you
18:43:27FromDiscord<guttural666> also, probably just use an array, if it's compile time known in terms of size I guess
18:43:50FromDiscord<kcvinker> @ElegantBeef I am sorry, that was my mistake. I didn't think the whole point
18:44:11FromDiscord<kcvinker> sent a code paste, see https://play.nim-lang.org/#ix=4x6H
18:44:34FromDiscord<Elegantbeef> Jees so much possible unsafe code in this api
18:45:16FromDiscord<Arathanis> isn't `pointer` just a void pointer?
18:45:25FromDiscord<Elegantbeef> Yes
18:45:29FromDiscord<Arathanis> O_o
18:45:41FromDiscord<Elegantbeef> Exactl
18:45:53FromDiscord<Arathanis> is there a reason this is ↵- not typed as an int ptr↵- not just an var int
18:46:00FromDiscord<Arathanis> (edit) "an" => "a"
18:46:04FromDiscord<Elegantbeef> Plus `copyMem` exists
18:46:10FromDiscord<Elegantbeef> This is from a library arath
18:46:16FromDiscord<Arathanis> oh wow
18:46:22FromDiscord<Elegantbeef> So they have a type erased pointer cause C
18:46:30FromDiscord<Arathanis> 😱
18:46:31FromDiscord<kcvinker> Yes
18:47:04FromDiscord<Elegantbeef> If you're doing `cast[ptr T](pointer)[] = ....` just use copymem
18:47:10FromDiscord<Elegantbeef> It's literally the same thing but less silly
18:47:31FromDiscord<kcvinker> Oh I see. Let me check @ElegantBeef
18:48:28FromDiscord<Arathanis> what would that look like?
18:48:45FromDiscord<kcvinker> @ElegantBeef But when using `copyMem`, How do I get the address of my varibale ? `addr` & `unsafeAddr` won't work
18:49:16FromDiscord<Elegantbeef> Why don't they worrk
18:49:32FromDiscord<kcvinker> Ons second @ElegantBeef
18:49:41FromDiscord<Elegantbeef> You can quit pinging me
18:49:54FromDiscord<Elegantbeef> I have atleast one active neuron I can follow a conversation
18:50:39FromDiscord<kcvinker> In reply to @Elegantbeef "You can quit pinging": Sorry
18:51:10FromDiscord<kcvinker> Problem solved. and `unsafeAddr` worked in copyMem. My bad.
18:59:20FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4x6N
19:00:09FromDiscord<Elegantbeef> `create` is a nicer allocator
19:00:42*junaid_ joined #nim
19:09:13FromDiscord<chmod222> And with the latter you can pretend programming in ruby by pretending your int has methods\: `int.create(1)`
19:09:26FromDiscord<chmod222> If you are into that
19:09:51FromDiscord<Arathanis> i like the syntax
19:09:54FromDiscord<Arathanis> but im def not into ruby
19:11:15FromDiscord<kcvinker> sent a code paste, see https://play.nim-lang.org/#ix=4x6Q
19:11:41FromDiscord<Elegantbeef> It's not cause it's primitive it's just cause `getWcharPtr` doesnt return an address
19:12:10*ntat quit (Quit: Leaving)
19:12:39FromDiscord<Arathanis> is createShared just create but so you can share the pointer with threads?
19:12:52FromDiscord<kcvinker> sent a code paste, see https://play.nim-lang.org/#ix=4x6S
19:13:28FromDiscord<Elegantbeef> Why are you casting `p` number 1
19:13:30FromDiscord<Elegantbeef> number two that'll work just fine
19:14:00FromDiscord<Elegantbeef> It's `sizeof(LPWCHAR)` cause you want to copy the pointer not a single char
19:14:08FromDiscord<Elegantbeef> or just `sizeof(pointer)`
19:14:16FromDiscord<kcvinker> Oh i see
19:14:23FromDiscord<kcvinker> Let me try that
19:17:43FromDiscord<kcvinker> The caller expects a wchar pointer
19:18:07FromDiscord<kcvinker> So we must pass a pointer to what the caller expects.
19:18:20FromDiscord<kcvinker> So we need a pointer to wchar pointer
19:19:04FromDiscord<kcvinker> Thats why i am casting p
19:20:57FromDiscord<kcvinker> sent a code paste, see https://play.nim-lang.org/#ix=4x6W
19:21:22FromDiscord<kcvinker> See https://media.discordapp.net/attachments/371759389889003532/1113185402141024358/image.png
19:24:02FromDiscord<kcvinker> sent a code paste, see https://play.nim-lang.org/#ix=4x6Z
19:24:09FromDiscord<kcvinker> See https://media.discordapp.net/attachments/371759389889003532/1113186100270334012/image.png
19:39:15FromDiscord<arkanoid> this is interesting https://wasmer.io/posts/announcing-wasix
19:41:44FromDiscord<guttural666> does this seriously initialize tokenize on each loop pass? this should be a declaration only, not a declaration, am I wrong? https://media.discordapp.net/attachments/371759389889003532/1113190527404355604/image.png
19:42:08FromDiscord<guttural666> just yeeted it out of that while loop and now my shit works
19:42:39FromDiscord<Elegantbeef> Nim 0 inits
19:42:40FromDiscord<guttural666> (edit) "declaration," => "definition,"
19:43:02FromDiscord<Elegantbeef> It's declared inside the scope so it's lifetime is the scope
19:43:19FromDiscord<guttural666> so it resets the life time?
19:43:40FromDiscord<guttural666> i thought var was a compile time declaration only
19:43:59FromDiscord<Elegantbeef> it doesnt reset the life time, ever while loop iteration it's redeclared cause that's how code works
19:43:59FromDiscord<Elegantbeef> Is there a language with local variables are persistent across while loops
19:46:59FromDiscord<Graveflo> wdym compile time declaration? It's unlikley that `file` has a value at the time of compilation. Aren't things like `cont` and `static` for compile time?
19:47:21FromDiscord<Elegantbeef> Yea no clue what they meant by that
19:47:39FromDiscord<Graveflo> btw I meant `const` there obvi
19:47:53FromDiscord<Elegantbeef> `const tokenize: bool` makes no sense anyway
19:47:59FromDiscord<Elegantbeef> They clearly do not understand scopes
19:48:09FromDiscord<guttural666> sent a code paste, see https://play.nim-lang.org/#ix=4x73
19:48:24FromDiscord<guttural666> (edit) "https://play.nim-lang.org/#ix=4x73" => "https://play.nim-lang.org/#ix=4x74"
19:48:27FromDiscord<Elegantbeef> Yea i'm not going to conside that a real languge
19:48:31FromDiscord<Elegantbeef> 😛
19:48:33FromDiscord<guttural666> hahahaha
19:48:56FromDiscord<Elegantbeef> Like what is the point of `tokenize: bool` if you do not use the variable at runtime
19:49:22FromDiscord<guttural666> I do, just was confused about what var: type does I guess
19:49:35FromDiscord<Elegantbeef> It declares a variable that is 0initd
19:49:44FromDiscord<Elegantbeef> No different than `var tokenize = default(bool)`
19:50:19FromDiscord<guttural666> yeah, gotta yeet everything out of the loop then
19:50:28FromDiscord<guttural666> spending too much time at work
19:50:33FromDiscord<Elegantbeef> Also stop using a while loop
19:50:51FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/6LO6q
19:51:34FromDiscord<guttural666> ah, didn't even know that was possible
19:52:34FromDiscord<guttural666> okay, it just reads the amount of lines beforehand
19:55:36FromDiscord<guttural666> In reply to @Elegantbeef "it doesnt reset the": this was the important clue, thanks
20:03:22FromDiscord<guttural666> kind of like the ABAP way more, because this will always pollute the surrounding scope: https://media.discordapp.net/attachments/371759389889003532/1113195970423967875/image.png
20:04:17FromDiscord<guttural666> maybe just my brain farts
20:04:46FromDiscord<Graveflo> I'm not saying this is what you do, but some say that if a proc is doing more than one thing you should really have two procs and thus two scopes anyway
20:05:03*junaid_ quit (Remote host closed the connection)
20:05:20FromDiscord<guttural666> In reply to @Graveflo "I'm not saying this": I think this is harmful ideology
20:05:58FromDiscord<Graveflo> whats the reasoning?
20:10:52FromDiscord<guttural666> sent a code paste, see https://play.nim-lang.org/#ix=4x7c
20:13:33FromDiscord<guttural666> I just try to keep my function hierarchy as flat as possible, it's so much easier to read and reason about, not jumping around in endless call stacks like a monkey
20:13:57FromDiscord<Graveflo> yea, on this way of thinking that is my main issue with the mantra. "One thing" is ambiguous. In my mind, there is a place for accessor / mutator style code, not that your argument is specific to it, but there's no reason to overdo the concept. Perhaps its more palatable if you bar very small "things"
20:14:47FromDiscord<Graveflo> and prioritizing making your code easy to understand is certainly not a bad idea so I understand what you mean
20:15:39FromDiscord<guttural666> In reply to @Graveflo "yea, on this way": exactly, just choose a reasonable solution without confusing yourself and others just because some pattern ideologue says it is de way
20:16:58FromDiscord<guttural666> kind of what I think and what I had to learn reading my own shitty "abstracted" code
20:17:04FromDiscord<Graveflo> I like pattern ideologies though because I always read my old code and think I could have done better. Sometimes it's nice to keep certain things in mind that counter bad intuition. I expect this is more of a "me" problem then it is for most
20:17:22FromDiscord<Rika> In reply to @guttural666 "I think this is": only if you apply it to the extremes
20:17:37FromDiscord<Rika> with anything, extremes are almost always awful xd
20:18:21FromDiscord<guttural666> In reply to @Rika "only if you apply": yeah that was my point, I read a lot of code like that at work and I know people get it from books and uni and they end up writing absolute garbage code that is not readable and full of boiler plate
20:19:16FromDiscord<Rika> but is it the fault of the ideology or is it the fault of the education
20:19:28FromDiscord<guttural666> getters and setters that literally assign an int is just the tip of the iceberg
20:19:56FromDiscord<Rika> java moment
20:20:36FromDiscord<guttural666> one and the same, it's just wrong, SE should be about practical solutions to real problems, sometimes you yeet shit out of your control flow and put it in a function, because it makes sense, sometimes it's cool to be part of the control flow
20:20:53FromDiscord<guttural666> look at me talking like somebody who knows anything lol
20:21:04FromDiscord<Rika> eh no pragmatism is pretty important
20:21:13FromDiscord<guttural666> this
20:21:28FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4x7e
20:22:08FromDiscord<Rika> i forgot the difference between a block and an if true
20:22:10FromDiscord<Rika> is it the break
20:22:13FromDiscord<Rika> (edit) "is it the break ... " added "behaviour"
20:22:15FromDiscord<Elegantbeef> yes
20:22:27FromDiscord<Elegantbeef> `if true` creates a scope but does not eat a break
20:22:33FromDiscord<Rika> yummy breaks
20:22:36FromDiscord<Elegantbeef> `block` creates a scope but eats a break
20:22:40FromDiscord<Graveflo> what about `block`
20:22:45FromDiscord<Rika> tho ive never tasted a break
20:23:02FromDiscord<Elegantbeef> I assume i answered your question grave
20:23:06FromDiscord<Graveflo> yaya mb
20:23:16FromDiscord<Rika> In reply to @Rika "tho ive never tasted": kinda weird no one has since breakfast is a thing
20:23:32FromDiscord<Elegantbeef> Well it's breaking a fast
20:23:52FromDiscord<Rika> i was making an admittedly awful joke
20:24:00FromDiscord<guttural666> I'm gonna consume a token rn
20:24:00FromDiscord<Rika> come on beef stop being such a bongo
20:24:25FromDiscord<Elegantbeef> I'll always be the most annoying drum
20:24:38FromDiscord<Rika> do people regularly beat you
20:24:58FromDiscord<Elegantbeef> What do you think?
20:27:34FromDiscord<Rika> No, I don’t think
20:38:28FromDiscord<guttural666> 🤣
20:43:40FromDiscord<guttural666> @ElegantBeef will this then actually double malloc inside of a loop? or will that memset the next time the loop comes around? https://media.discordapp.net/attachments/371759389889003532/1113206111932268554/image.png
20:45:22FromDiscord<guttural666> (edit) "loop?" => "loop (meaning not reuse the memory)?"
20:47:24FromDiscord<Graveflo> I dont link the int returned from len is going to need malloc. If thats what you mean
20:48:18FromDiscord<Graveflo> but yea, unless you need to re-compute `print_from` at each iteration move it outside the loop
20:49:42FromDiscord<Graveflo> if you really want to discourage movement maybe you could declare it as `var` outside the loop and just set over top each time
20:49:50FromDiscord<Graveflo> but idk about that
20:52:28FromDiscord<guttural666> pretty sure this will let the memory go of print from at the end of the while scope and then see the "let print_from" again next time around and think "a completely new variable I have never seen, let's get some mem for this"
20:52:38FromDiscord<guttural666> at least if the compiler is naive
20:52:54FromDiscord<Elegantbeef> It's stack allocated
20:52:55FromDiscord<Elegantbeef> It doesnt matter
20:53:21FromDiscord<guttural666> malloc is 200 CPU cycles god damnit! 😄
20:53:28FromDiscord<Graveflo> right i get what you mean. Yea just pretend you are writing c and pre-declare the name... Or listen to beef bc I'm sure he's right and it doesnt matter
20:53:45FromDiscord<guttural666> pretended I wrote ABAP for too long hahaha
20:53:45FromDiscord<Elegantbeef> Stack allocated variables are not using malloc
20:53:50FromDiscord<Elegantbeef> They're statically allocated
20:54:00FromDiscord<guttural666> In reply to @Elegantbeef "Stack allocated variables are": you're right yeah
20:54:39FromDiscord<guttural666> but let pls: string would actually null out that value every loop pass
20:54:57FromDiscord<Ayy Lmao> I just ran into an insanely insidious bug using emscripten. It's hard to explain but apparently passing a ref as an argument doesn't increase the ref count while it's in scope for the function?
20:55:20FromDiscord<Elegantbeef> Sure but that's what you've decreed
20:55:23FromDiscord<Elegantbeef> If you want to reuse memory reuse it
20:55:25FromDiscord<Elegantbeef> Like what?
20:59:13FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4x7l
20:59:23FromDiscord<Ayy Lmao> If you don't do `let widget = widget` then arc collects it
21:00:55*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
21:01:27FromDiscord<etra> how do I get for HashSet to use my custom hash function? even though `hash` is exported, and I can see it gets called if I throw an exception, neither intersection nor union actually uses what I'm returning
21:02:01FromDiscord<etra> oh wait, do I need to export `==`?
21:03:24FromDiscord<guttural666> In reply to @Elegantbeef "If you want to": nulling is a cost that is not necessary, same with letting formerly stack allocated memory go and and getting a new int is right? just gonna yeet all the declarations out of the loop
21:03:55FromDiscord<etra> sent a code paste, see https://play.nim-lang.org/#ix=4x7n
21:04:16FromDiscord<etra> (edit) "https://play.nim-lang.org/#ix=4x7n" => "https://play.nim-lang.org/#ix=4x7o"
21:16:41*NimBot joined #nim
21:16:52*FromDiscord joined #nim
21:17:11FromDiscord<Graveflo> sent a code paste, see https://play.nim-lang.org/#ix=4x7x
21:17:19FromDiscord<Elegantbeef> Fixed in devel i believe
21:20:56FromDiscord<Ayy Lmao> Is using GcRef on top level refs the best way to keep them alive in emscripten? It is leading to strange and hard to debug behavior for me and I am wondering if there is a nicer way to get them to behave well.
21:21:15NimEventerNew Nimble package! nimcatapi - nimcatapi is a library that lets you easily request images from thecatapi and/or thedogapi., see https://github.com/nirokay/nimcatapi
21:23:26*marcus joined #nim
21:23:51FromDiscord<Elegantbeef> You're using arc/orc?
21:24:41FromDiscord<Ayy Lmao> Yeah, the problem is I am spawning an event loop with `emscripten_request_animation_frame_loop` and that doesn't block the program from reaching the end, so everything gets collected unless I do GcRef
21:25:02FromDiscord<Ayy Lmao> And doing GcRef on a top level ref seems to have very peculiar behavior.
21:26:43FromDiscord<Elegantbeef> Are you not calling nimmains till?
21:27:17FromDiscord<Ayy Lmao> Am I supposed to be calling NimMain in emscripten? This is a completely different thing from the plugin thing I am doing btw.
21:27:43FromDiscord<Elegantbeef> I don't know what you're doing are you writing a pure Nim emscriptin program?
21:28:03FromDiscord<Ayy Lmao> In reply to @Elegantbeef "I don't know what": Yeah essentially
21:28:29FromDiscord<Elegantbeef> I do not know why you'd need to call gcref on a global variable
21:28:55FromDiscord<Ayy Lmao> They get collected otherwise
21:29:14FromDiscord<Elegantbeef> Ok so why do they get collected?
21:29:31FromDiscord<Ayy Lmao> I guess nim thinks the program has ended, but it has not.
21:29:46FromDiscord<Ayy Lmao> Maybe I can try to get together a minimal example
21:38:20FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4x7C
21:40:43*rockcavera joined #nim
21:41:18FromDiscord<guttural666> how would I pass a slice of a seq of Tokens to a generator to generate fixed code? do I need openArray for that?
21:42:33FromDiscord<Ayy Lmao> In reply to @guttural666 "how would I pass": .toOpenArray() maybe?
21:42:36FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4x7D
21:43:00FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4x7E
21:45:28FromDiscord<guttural666> In reply to @Ayy Lmao ".toOpenArray() maybe?": pseudocode: pass the recently added tokens to the generator as a reading pointer into the seq, gimme the generated code that you fixed https://media.discordapp.net/attachments/371759389889003532/1113221664528941066/image.png
21:46:02FromDiscord<guttural666> don't even know if the "unclosed" .. just defaults to .high
21:46:17FromDiscord<Elegantbeef> `..` is invalid
21:46:31FromDiscord<Elegantbeef> Nim doesnt have postfix
21:48:08FromDiscord<guttural666> does the [start..end] actually produce a slice (not copy)? if that is correct, how do I type it on the receiving end of fix()?
21:48:20FromDiscord<guttural666> pretty sure I need openArray here
21:48:24FromDiscord<Ayy Lmao> .toOpenArray(start, end) i think
21:48:33FromDiscord<Elegantbeef> you need openArray for a non allocating slice
21:48:40FromDiscord<guttural666> excellent
21:49:35FromDiscord<Elegantbeef> Wait i'm wrong ayy misread the proc def
21:49:47FromDiscord<Ayy Lmao> So beef, `emscripten_request_animation_frame_loop` returns void so what you said doesn't work, however there is `emscripten_request_animation_frame` which does return an EM_BOOL. The thing is, you can't put it in a while loop because it blocks the program from running.
21:49:54FromDiscord<Ayy Lmao> Also the ref gets collected regardless.
21:50:11FromDiscord<Elegantbeef> Well what's happening is you're calling emscripten code and then the program terminates
21:50:21FromDiscord<Ayy Lmao> Yeah
21:50:26FromDiscord<Elegantbeef> We need to stop that terminating so there has to be a way to block/poll
21:50:26FromDiscord<Ayy Lmao> So is GcRef the answer to that?
21:50:40FromDiscord<Ayy Lmao> I haven't found a way to block and poll the program
21:50:42FromDiscord<Elegantbeef> No cause the program terminates and deallocates globals regardless of ref count
21:51:19FromDiscord<Ayy Lmao> GcRef actually seems to work but it has very sinister bugs.
21:51:47FromDiscord<Ayy Lmao> Getting it to behave like a normal nim program on desktop would be ideal.
21:53:41FromDiscord<Ayy Lmao> `emscripten_set_main_loop` might be what I'm looking for.
21:55:48FromDiscord<Elegantbeef> Given that this is for web dev I do not imagine there is a way to block
21:55:49FromDiscord<Elegantbeef> Are you using devel?
21:55:50FromDiscord<Elegantbeef> If not do try that
21:57:19FromDiscord<Ayy Lmao> I am using 1.6.12 but I'll try that if I can't figure this out.
21:59:35FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=4x7G
22:04:00FromDiscord<guttural666> I see myself alternating between this: lex.read_token() and reset_lexer(lex) quite a lot and I would kinda prefer if the language forced me to do either, what do you guys think?
22:04:39FromDiscord<Elegantbeef> Nope
22:05:22FromDiscord<guttural666> elegeant likes his freedom 😛
22:05:30FromDiscord<guttural666> (edit) "elegeant" => "elegant"
22:05:38FromDiscord<Ayy Lmao> I prefer lex.read_token() style.
22:05:47FromDiscord<Ayy Lmao> Honestly depends though
22:06:08FromDiscord<guttural666> echo pls is the best though
22:06:27FromDiscord<guttural666> would keep that and just force fix(lex) 😄
22:06:30FromDiscord<Graveflo> In reply to @guttural666 "I see myself alternating": I think thats one of those things that either grows into habit or stops seeming disjointed. I've gotten used to it in a couple of weeks
22:07:27*progranner joined #nim
22:08:20FromDiscord<guttural666> just think the more ambivalence there is in the language the worse, but also like some uses of that uniform function call syntax
22:08:50FromDiscord<guttural666> sometimes it's just a lot of noise for the eye
22:09:01FromDiscord<Ayy Lmao> `emscripten_set_main_loop` seems to be the ticket Beef. There is an argument that simulates an infinite loop and that seems to stop Nim from collecting the globals.
22:09:09FromDiscord<Graveflo> I don't think I'll ever grow to like the style insensitivity though
22:10:14FromDiscord<Ayy Lmao> I have a strong preference for camel case so I hate when I have to use snake case. I like the style insensitivity for that but it can cause problems.
22:10:18FromDiscord<Elegantbeef> I find it literally doesnt matter
22:10:51FromDiscord<guttural666> In reply to @Elegantbeef "I find it literally": it matters to your reading speed even if you think it doesn't
22:11:58FromDiscord<Graveflo> I've never had it bother me yet and since other people like it I don't really have a problem with it. Just the idea of it makes me anxious bc I think I'm going to shadow something. Coming from primarily working in python, shadowing is way more of an issue over there
22:12:04FromDiscord<guttural666> In reply to @Ayy Lmao "I have a strong": I'll stick to snake with my own stuff and just respect stdlib's style
22:13:13FromDiscord<Ayy Lmao> The only time I've had it bite me is when you are binding C code that has something like FOO and Foo and they are different things.
22:13:24FromDiscord<guttural666> I see myself using either depending on the readability of the whole thing, kinda hate it and love it at the same time
22:14:50FromDiscord<guttural666> if the thing is an important thing that does important stuff I will use thing.do() if the thing is not that important for control flow, I will use strip(string)
22:15:01NimEventerNew thread by dwhall256: Why does this operator overload fail?, see https://forum.nim-lang.org/t/10236
22:30:45*om3ga quit (Quit: Bye)
22:30:56*om3ga joined #nim
22:42:35*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
23:14:19*jmdaemon joined #nim
23:58:34FromDiscord<Ayy Lmao> What parts of emscripten are portable outside the browser? Like I'm guessing if I execute javascript it doesn't work outside the browser right?
23:59:33FromDiscord<Elegantbeef> I mean it's fine if you mirror the API in your native runtime