<< 13-11-2024 >>

00:58:55*alexdaguy joined #nim
01:28:32*lucasta quit (Quit: Leaving)
01:55:18*alexdaguy quit (Quit: aa)
02:01:10*tiorock joined #nim
02:01:10*tiorock quit (Changing host)
02:01:10*tiorock joined #nim
02:01:10*rockcavera is now known as Guest3156
02:01:10*Guest3156 quit (Killed (zirconium.libera.chat (Nickname regained by services)))
02:01:10*tiorock is now known as rockcavera
02:01:10*rockcavera quit (Remote host closed the connection)
02:05:14*rockcavera joined #nim
02:14:47*thomasross joined #nim
03:06:53*rockcavera quit (Remote host closed the connection)
03:28:47ftajhiibubbly_avocado_86424 thanks for that
03:31:55*thomasross quit (Remote host closed the connection)
03:57:45*lx12ucy joined #nim
03:58:02lx12ucyis there a better way to clear the terminal other than `let clear = execCmd("clear")`
03:59:48FromDiscord<Elegantbeef> `clearScreen` is a dependency based solution
04:00:06FromDiscord<Elegantbeef> You also could just write the ansi code sequence to stdout
04:02:50lx12ucythats a good idea, i like that
04:10:13FromDiscord<odexine> note that the behaviour would be terminal dependent
04:10:28FromDiscord<odexine> Some terminals don’t clear the scroll back buffer
04:25:06*SchweinDeBurg quit (Quit: WeeChat 4.5.0-dev)
04:30:10lx12ucygot it
04:31:07lx12ucyis it possible to load yaml file with nimyaml with comments and change the values without overwriting the whole file?
04:32:02*SchweinDeBurg joined #nim
05:05:15FromDiscord<riku5543> Is async code not GC safe? (exact message is "host" is not GC-safe as it calls 'hostNimAsyncContinue')
05:07:23FromDiscord<Elegantbeef> You're accessing global memory which makes it not gcsafe
05:08:27FromDiscord<riku5543> Ah is it because the async proc itself is using global memory? That makes sense I suppose.
05:09:05FromDiscord<riku5543> Yeah that fixed it
05:44:33FromDiscord<riku5543> It finally happened 👀 https://media.discordapp.net/attachments/371759389889003532/1306132572308246528/mVzKWNY.png?ex=67358e40&is=67343cc0&hm=2632768263aefce6d41ff6ea38e8e1f8efab82b5f1cd13e1772d73a3ee38a7d7&
07:28:07*PMunch joined #nim
09:20:16FromDiscord<arm_3_d> Is dynamic libs a good way to provide extension for modular Nim desktop app? Is there more native to nim options available? Trying to build analogy to java desktop app where multiple extra jars an be loaded in runtime depending on configuration.
09:34:01PMunchDynamic libs is kinda the only way to do it
09:35:47PMunchYou could compile Nim to WASM and load WASM plugins, you could use NimScript, heck you could even run the programs separately and either use an RPC or share memory via mmap (at least on Linux), but if you want to load native modules with full integration into your programs then dynamic libraries is the way to go.
09:37:53FromDiscord<arm_3_d> yeah, just kinda sad to use FFI for it
09:43:51PMunchYou don't have to use FFI for it
09:44:03FromDiscord<Robyn [She/Her]> In reply to @arm_3_d "Is dynamic libs a": WASM :>
09:44:03FromDiscord<arm_3_d> sent a code paste, see https://play.nim-lang.org/#pasty=qSYOPVlx
09:44:15FromDiscord<Robyn [She/Her]> You also get yummy sandboxing
09:44:19PMunchAs long as you link both programs with nimrtl then you can freely share Nim-managed memory across the dynamic bridge
09:45:10FromDiscord<arm_3_d> WASM is also one of the options, but I still wasn't able to find a runtime which works on old platforms 🙂 WinXP is my curse
09:45:16FromDiscord<Robyn [She/Her]> In reply to @arm_3_d "WASM is also one": wasm3?
09:45:17PMunchYeah that seems like a pretty common setup @arm_3_d
09:45:31FromDiscord<Robyn [She/Her]> Beef has a wrapper for it on his Github
09:45:44PMunchProbably won't run on WinXP though..
09:45:48PMunchWhy are you using WinXP?
09:45:55FromDiscord<Robyn [She/Her]> Though, it's an interpreter which isn't gonna outdo a runtime
09:45:59FromDiscord<Robyn [She/Her]> In reply to @PMunch "Probably won't run on": huh? why?
09:45:59FromDiscord<arm_3_d> Retail POS terminals
09:46:01FromDiscord<Elegantbeef> Well wasm3 not wasm 😄
09:46:03PMunchI mean apart from it being one of the best Windows versions :P
09:46:08FromDiscord<arm_3_d> java is too heavy for potato POS terminals
09:46:11FromDiscord<Robyn [She/Her]> In reply to @Elegantbeef "Well wasm3 not wasm": i said wasm3
09:46:30FromDiscord<Elegantbeef> Ah didn't see that message
09:46:39FromDiscord<arm_3_d> you mean https://github.com/wasm3/wasm3 ?
09:47:00FromDiscord<Elegantbeef> Wasm3 is a pure C VM so it might just work on winxp 😄
09:47:40FromDiscord<Elegantbeef> Part of it's goal was to be used with embedded
09:47:53FromDiscord<Robyn [She/Her]> In reply to @arm_3_d "you mean https://github.com/wasm3/wasm3 ?": That's the C source, Beef has https://github.com/beef331/wasm3
09:48:18FromDiscord<Robyn [She/Her]> which wraps it and has some higher level bindings too, not higher by much though, I believe
09:48:38FromDiscord<Elegantbeef> It has some high level auto marshalling stuff
09:48:50FromDiscord<arm_3_d> Yeah. tried Beef's, had some issues compiling using NIm 2.2.0, didnt dig deep enought though
09:49:02FromDiscord<Elegantbeef> You didn't make an issue
09:50:07FromDiscord<arm_3_d> Will check one more time just to be sure and will fill an issue. Thanks
09:50:11FromDiscord<Elegantbeef> Ah a nice C gen issue
09:54:29FromDiscord<nimaoth> @arm_3_d If you want to try wasmtime (not sure if it works on XP) I created a wrapper for that (https://github.com/Nimaoth/nimwasmtime)
09:56:15FromDiscord<arm_3_d> In reply to @nimaoth "<@107466914392969216> If you": Wasmtime is written in Rust as I understand. Rust dropped XP long time ago. Didn't try to run though.
09:57:29FromDiscord<nimaoth> oh well, nvm then ^^
10:03:38FromDiscord<Elegantbeef> `const void` ah yes C can go burn in a pit
10:05:22FromDiscord<nnsee> In reply to @lx12ucy "is there a better": on linux, it'd be `stdout.write "\x1b[H\x1b[2J\x1b[3J"`
10:06:31FromDiscord<nnsee> `[H` moves the cursor to the beginning of the line ("home"), `[2J` clears the screen, and `[3J` clears the scrollback
10:08:18FromDiscord<Elegantbeef> So many silly type issues that are not really type issues in my wasm3 bindings
10:08:47FromDiscord<Elegantbeef> I give up on these more aggressive C pointer changes
10:13:59*beholders_eye joined #nim
10:25:33FromDiscord<Robyn [She/Her]> In reply to @nimaoth "<@107466914392969216> If you": oooh fun
10:52:28Amun-Ra"\e" is more readable than "\x1b"
10:54:24FromDiscord<nnsee> i forgot that was an option
11:45:42*beholders_eye quit (Ping timeout: 246 seconds)
12:09:32*beholders_eye joined #nim
12:40:59*alexdaguy joined #nim
12:52:19*beholders_eye quit (Ping timeout: 252 seconds)
13:23:25*ntat joined #nim
13:27:47*beholders_eye joined #nim
13:42:52FromDiscord<angelsdust> sent a code paste, see https://play.nim-lang.org/#pasty=JjsAxtfX
13:43:18FromDiscord<nnsee> can you post the full error?
13:44:12FromDiscord<angelsdust> sent a code paste, see https://play.nim-lang.org/#pasty=CozqFJAf
13:44:57FromDiscord<nnsee> why are you doing `system.uint8`?
13:45:16FromDiscord<angelsdust> Tried normal uint8() too, didnt seem to change anything it was a desperate move lol
13:46:15FromDiscord<angelsdust> sent a code paste, see https://play.nim-lang.org/#pasty=XvxbJrvD
13:51:08FromDiscord<k0ts> have you imported tables?
13:51:23FromDiscord<angelsdust> Yes
13:51:35FromDiscord<angelsdust> wait
13:51:41FromDiscord<k0ts> waiting
13:51:46FromDiscord<angelsdust> Right so you need to import tables when you want to set the value
13:51:53FromDiscord<k0ts> yes
13:51:59FromDiscord<k0ts> procs are not type-bound
13:52:00FromDiscord<angelsdust> I did not know that
13:52:15FromDiscord<angelsdust> It worked, thanks
13:52:31FromDiscord<nnsee> i was confused as to why it was working for me lol
13:52:42FromDiscord<nnsee> assume you'd already imported tables
13:52:47FromDiscord<nnsee> (edit) "assume" => "assumed"
13:54:09FromDiscord<nnsee> @angelsdust out of curiosity, any particular reason you're going that route and not something like this? https://git.dog/xx/nim-chip8/src/branch/master/src/cpu.nim#L301
13:54:37FromDiscord<angelsdust> Seperation of concerns + single responsibility for files
13:54:52FromDiscord<angelsdust> So CPU file has Opcode table from Opcodes file which uses instructions from Instructions file
13:56:00*alexdaguy quit (Quit: WeeChat 4.4.3)
13:56:09FromDiscord<angelsdust> Now the CPU knows nothing about opcodes or instructions and just runs whatever is in the table or spew an error
13:56:17FromDiscord<angelsdust> (edit) "spew" => "spews"
13:56:27FromDiscord<nnsee> sure
13:56:39FromDiscord<nnsee> just my immediate thought was that maybe the table lookup would be expensive
13:56:54FromDiscord<angelsdust> Tables are O(1) lookup no?
13:57:01FromDiscord<angelsdust> (edit) "Tables" => "(Hash-)Tables"
13:57:13FromDiscord<nnsee> ¯\_(ツ)_/¯
13:57:14FromDiscord<nnsee> maybe
13:57:23FromDiscord<nnsee> i'm talking out of my ass here right now
13:57:58FromDiscord<angelsdust> It is fine lol
13:58:03FromDiscord<nnsee> and it's genuine curiosity (that maybe your method is better), not criticism or anything
13:58:08FromDiscord<angelsdust> Most of this is synthetic programming sugar
14:01:05FromDiscord<k0ts> since there are only a few possible uint8s, `array[uint8, OpcodeFunc]` could work
14:01:42FromDiscord<angelsdust> I actually wonder, are arrays O(n) lookup?
14:02:00FromDiscord<k0ts> er im pretty sure it's constant time
14:02:07PMunchYeah arrays are O(1)
14:02:18FromDiscord<k0ts> it's just a pointer offset
14:02:24FromDiscord<k0ts> no hash needed
14:02:27PMunchLinked lists are O(n)
14:02:34FromDiscord<angelsdust> Yeah, so it is potato potato. Take it array is faster than table?
14:02:52FromDiscord<angelsdust> for init/memory footprint et. al.
14:02:52PMunchYeah it'll be slightly faster
14:03:02FromDiscord<k0ts> in this case, since there are not that many possible keys and your values are small, probably
14:03:15FromDiscord<angelsdust> Hell yeah, saving those cycles :doggo:
14:03:27PMunchMostly determined by the time of your `hash` function, the time of the `==` function, and any cache miss/hit stuff
14:07:01PMunchIf you have a big distance between keys the `array` will be very large though
14:08:35FromDiscord<angelsdust> Refactored to array, do arrays initialize by default with nil's?
14:08:42FromDiscord<k0ts> yes
14:08:48PMunchWith default values
14:08:55PMunchWhich are zeros for number types
14:08:55FromDiscord<k0ts> which for procs is nil
14:09:25FromDiscord<angelsdust> What's the best way to check the index exists in an array?
14:09:44FromDiscord<k0ts> the index always exists, you could check if the value is not nil or something
14:09:57FromDiscord<k0ts> ^ if it's within bounds
14:10:07FromDiscord<angelsdust> ah I had a logic issue :MenheraTeehee:
14:10:41PMunchWhat are you actually trying to achieve here by the way?
14:10:42FromDiscord<angelsdust> Forgot a return in an exit check so it tried to execute nil lol
14:10:51FromDiscord<angelsdust> Eventually a gameboy emulator
14:11:17FromDiscord<angelsdust> But for now a OpcodeTable which I can call whenever in order to assure the CPU never needs to know about Opcodes or Instructions
14:11:31PMunchRight
14:11:44PMunchAn array indexed by an enum is probably the way to go then
14:12:40FromDiscord<angelsdust> Hmm, think enum is overkill tho I get where it comes from as it removes magic numbers
14:13:06PMunchOverkill? On runtime it's exactly the same
14:13:15PMunchAnd on compile-time it's just clearer what's going on
14:14:59FromDiscord<k0ts> you can also save space in your array if you have much fewer than 256 opcodes
14:16:36FromDiscord<angelsdust> In reply to @PMunch "And on compile-time it's": True, I was thinking in the sense of all opcodes are hex already, so having a 200+ entry enum is a lot but it prolly is best to do
14:23:08FromDiscord<enthus1ast.> i'm playing with malebolgia, i want to build a simple threaded proxy server, and have an issue to isolate Socket.↵I `acceptAddr` a connection and want to give the client socket to a spawn. But the error i get is: `tasks.nim(133, 20) Error: expression cannot be isolated: client` any idea how this should be done?
14:24:23FromDiscord<enthus1ast.> https://play.nim-lang.org/#pasty=aqkzzAIF
14:27:42FromDiscord<enthus1ast.> maybe i could just store the sockets in a a table in the main thread, and access this table in pump
14:43:08FromDiscord<double_spiral> Is it possible to typecast objects/structs
15:01:16*ntat_ joined #nim
15:01:34*ntat quit (Ping timeout: 260 seconds)
15:11:43FromDiscord<enthus1ast.> sent a code paste, see https://play.nim-lang.org/#pasty=RMlQCeJi
15:18:01*ntat_ quit (Quit: Leaving)
15:18:20*ntat joined #nim
15:25:18FromDiscord<demotomohiro> https://nim-lang.org/docs/manual.html#statements-and-expressions-type-casts↵`cast` is unsafe as it just do bitwise copy.
15:27:29FromDiscord<demotomohiro> `proc toFoo(x: Baa): Foo = Foo(ii: x.ii)` is safe.
15:36:47FromDiscord<angelsdust> What is better to use `import` or `include` for making use of code from a different file?
15:38:35FromDiscord<zumi.dxy> `import` is cleaner
15:38:45FromDiscord<zumi.dxy> `include` only in situations where you have to `include`
15:39:29FromDiscord<angelsdust> Check, is there some way to have includes resolve? e.g. in tests if I want to include an enum I now have to `import ../src/enums/foo/bar/file`
15:40:37FromDiscord<zumi.dxy> that's the way to do it isn't it?
15:41:41FromDiscord<angelsdust> Would be cool if like the `project.nimble` `srcDir` could be used as a base so I get clean imports like `enums/foo/bar/file` I take `$srcDir/foo/bar/file` too
15:44:09FromDiscord<zumi.dxy> You could add `--path` to the compiler invocation or to a `nim.cfg`↵https://nim-lang.org/docs/nimc.html↵↵so you can then include `src` and do `import enums/foo/bar/file`
15:57:10FromDiscord<angelsdust> That worked, nice
16:32:41FromDiscord<TFed> so how to make this ref object?↵(@aethrvmn_32073)
16:33:15FromDiscord<TFed> sent a code paste, see https://play.nim-lang.org/#pasty=KURyJZex
16:33:35FromDiscord<TFed> sent a code paste, see https://play.nim-lang.org/#pasty=tccYDlJm
16:34:08FromDiscord<TFed> sent a code paste, see https://play.nim-lang.org/#pasty=RzugsTcI
16:35:41FromDiscord<TFed> i don't know how to use `ref`
16:37:24FromDiscord<solitudesf> whats the issue?
16:40:02FromDiscord<TFed> how to make new Pack? that can be ref-ed
16:40:54FromDiscord<TFed> sent a code paste, see https://play.nim-lang.org/#pasty=UlzTdpQW
16:41:01FromDiscord<solitudesf> `new Pack`. the issue in your snippet is `ref Pack`. Pack is already ref.
16:42:13FromDiscord<solitudesf> also, in your original issue, you just wanted to mutate Pack. you shouldn't use ref for mutability, you should use `var` parameters.
16:42:32FromDiscord<TFed> oh, so setPath will nicely update Pack's content, cuz Pack is already ref?
16:42:33FromDiscord<TFed> that's good
16:42:37FromDiscord<TFed> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/1306298163828625428): oh, so setPath will nicely update Pack's content, cuz Pack was already ref?
16:42:55FromDiscord<TFed> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/1306298163828625428): oh, so setPath() will nicely update Pack's content, cuz Pack was already ref?
16:43:51FromDiscord<TFed> Yup, it works
16:43:57FromDiscord<TFed> sent a code paste, see https://play.nim-lang.org/#pasty=YmlrQvVI
16:44:54FromDiscord<TFed> i have updated object's attribute from function, that's what i wanted
16:45:19FromDiscord<solitudesf> yeah, you dont need ref for that
16:58:55*lucasta joined #nim
18:21:53*lucasta quit (Quit: Leaving)
18:23:24FromDiscord<fabric.input_output> is there some builtin way to unroll a loop?
18:33:44FromDiscord<bosinski2023> In reply to @fabric.input_output "is there some builtin": afaik no, but ive seen a macro on nimble,
18:33:57FromDiscord<bosinski2023> (edit) "nimble," => "nimble called "unroll""
18:48:46FromDiscord<fabric.input_output> hmm ok thanks
18:49:17FromDiscord<fabric.input_output> how safe is it to `cast[int](value)` when `value: set[SomeEnum]`
18:49:56FromDiscord<fabric.input_output> I want to make a set of flags and turn those into an integer cuz that's what the function I'm using accepts
18:53:16FromDiscord<solitudesf> In reply to @fabric.input_output "how safe is it": if you set enums size to 8, then its safe.
18:54:07FromDiscord<fabric.input_output> what if it's 10 enum variants?
18:56:35FromDiscord<solitudesf> In reply to @fabric.input_output "what if it's 10": size is set with size pragma, if you want to ensure that size does not depend on count.
19:00:39FromDiscord<fabric.input_output> just wanna know if it will turn into a bitwise or of all the 1 shifted left by the variants in the set's ordinal value
19:02:27FromDiscord<solitudesf> In reply to @fabric.input_output "just wanna know if": it will do what you expect. i assume you're passing some flags to c side?
19:03:57FromDiscord<fabric.input_output> yeah
20:08:41*disso-peach joined #nim
20:34:24FromDiscord<Elegantbeef> @arm_3_d Well I just released 0.1.13 of wasm3 so do see if it compiles now
20:41:35*xaltsc quit (Quit: WeeChat 4.4.1)
20:47:57FromDiscord<fabric.input_output> how does one get the js typed arrays in js target?
20:51:02FromDiscord<Elegantbeef> Find a module which imports them, otherwise import them yourself
20:51:37*rockcavera joined #nim
20:53:57FromDiscord<Elegantbeef> I assume without checking Nim specialises `seq[T]` where `T` has a corresponding typed array
20:54:57FromDiscord<Elegantbeef> Ah it does not
20:56:59FromDiscord<fabric.input_output> it doesn't cuz seq is resizable and typed arrays are
20:57:06FromDiscord<fabric.input_output> it works with `array` tho
20:57:34FromDiscord<Elegantbeef> I mean you can easily make an abstraction to make a typed array resiable
20:58:07FromDiscord<fabric.input_output> I don't really need that
20:58:40FromDiscord<Elegantbeef> Well my response was not you as in you but as in someone implementing `seq[T]`
20:59:46FromDiscord<Elegantbeef> Seems a lot of people have wrapped JS arrays, but no one has made a standalone package
20:59:58FromDiscord<morgan (ping with reply)> ok so i just had an idea, i think i will need to have some sort of interpreted ast for math and logic for something im working, and im wondering if it's possible to convert some nim to ast and then store that ast to then be interpreted at runtime?
21:00:06FromDiscord<morgan (ping with reply)> seems like it should be possible
21:00:14FromDiscord<Elegantbeef> Just embed the Nim VM
21:00:23FromDiscord<morgan (ping with reply)> oh i could do that too
21:03:35FromDiscord<morgan (ping with reply)> the goal is to define cards in a deckbuilder using nim to combine the various inputs and add to whatever state variables, and then be able to display that, be able to run that on direct moves (possibly with some rewriting), and be able to run that with my simd/swar/loop stuff for ai to evaluate all board placements and multiple timelines
21:04:05FromDiscord<Elegantbeef> Let me continue shilling wasm for scripting here
21:04:06FromDiscord<morgan (ping with reply)> (yes also displaying the code, it's hacking themed and having code display at least as an option alongside text would fit the theme)
21:04:20FromDiscord<morgan (ping with reply)> that could also work
21:04:57FromDiscord<morgan (ping with reply)> the main like, heavy usage requirement is for the ai, since parallel timelines and entire board evaluation increase compute needed
21:06:22FromDiscord<morgan (ping with reply)> tho it might just be modifying it to do that calculation in a loop over the board, im not sure it itself would need to do any piece specific bit manipulation
21:11:29FromDiscord<morgan (ping with reply)> the goal of defining cards with just a bit of nim code is that rather than needing to modify anything, i just write up some code for the card and then it can do that new card. and also maybe some ast fuzzer that can generate random bits of math and ast and look at the stats (is it place piece and gain 10k points, that's bad, it needs to be like positive but not always a guaranteed win)
21:19:44FromDiscord<double_spiral> Is there a built in proc to set a value of a bit at a certain position
21:21:14FromDiscord<double_spiral> something like `assert 0b0000_0000.setBitAt(2, true) == 0b0000_0100`
21:27:34FromDiscord<bosinski2023> In reply to @double_spiral "something like `assert 0b0000_0000.setBitAt(2,": yep, find that in module `bitops`..
21:27:48FromDiscord<Elegantbeef> https://nim-lang.org/docs/bitops.html#setBits.m%2Ctyped%2Cvarargs%5Btyped%5D
21:27:53*ntat quit (Quit: Leaving)
21:49:10*xaltsc joined #nim
21:53:24*beholders_eye quit (Ping timeout: 260 seconds)
22:58:12*rockcavera quit (Remote host closed the connection)
22:59:57*lucasta joined #nim
23:01:00*rockcavera joined #nim
23:21:31*alice quit (Ping timeout: 252 seconds)
23:26:26*alice joined #nim
23:31:07*alice quit (Ping timeout: 244 seconds)
23:38:32*disso-peach quit (Quit: Leaving)
23:49:44*alice joined #nim