<< 15-01-2025 >>

00:05:10*xaltsc joined #nim
00:38:20FromDiscord<Robyn [She/Her]> In reply to @SmaamX "Any person who worked": I'd recommend trying to follow along with tutorials on YouTube and reading the docs to find what you need
00:38:39FromDiscord<Robyn [She/Her]> also if this is your first time programming, game dev is a huge leap
00:38:51FromDiscord<Robyn [She/Her]> you'd be better off using an engine like Godot
00:51:54FromDiscord<.bobbbob> Is there a good writeup on nim's type inference?
01:55:27*tokyovigilante joined #nim
02:32:30*rockcavera quit (Remote host closed the connection)
03:25:58FromDiscord<albassort> jqt vs quickjtwt vs jwtea, which one do you guys like most
05:05:43*xet7 joined #nim
05:12:09*xet7_ joined #nim
05:15:38*xet7 quit (Ping timeout: 252 seconds)
05:16:44*xet7_ is now known as xet7
05:16:59FromDiscord<mjsdev> Is it possible to use quote outside a macro body?
05:17:22*xet7 quit (Remote host closed the connection)
05:18:34*xet7 joined #nim
05:19:06FromDiscord<Elegantbeef> @mjsdev why would you need it?
05:19:28FromDiscord<mjsdev> to parse nim
05:20:05FromDiscord<Elegantbeef> Quote is a compile time construct so it has to be used statically
05:20:43FromDiscord<Elegantbeef> It also doesn't take anything in but a body
05:21:28FromDiscord<Elegantbeef> What are you actually trying to do?
05:25:55FromDiscord<mjsdev> That's a long and complex story. But to try and simplify it, I'm trying to inject code from one file into another.
05:26:13FromDiscord<Elegantbeef> `include`
05:26:26FromDiscord<mjsdev> Not as a file...
05:26:44FromDiscord<Elegantbeef> Make it a template or a generic
05:31:00FromDiscord<mjsdev> sent a code paste, see https://play.nim-lang.org/#pasty=qqcLmzwu
05:31:57FromDiscord<Elegantbeef> Oh goody a class DSL 😄
05:33:21FromDiscord<mjsdev> sent a code paste, see https://play.nim-lang.org/#pasty=DehLfaKk
05:33:46FromDiscord<Elegantbeef> You cannot add fields to types
05:34:12FromDiscord<Elegantbeef> If a type exists it's concrete and cannot be changed
05:34:15FromDiscord<mjsdev> hook is already a field on the Command type
05:34:27FromDiscord<mjsdev> it would be a pointer
05:34:34FromDiscord<Elegantbeef> Ok
05:34:43FromDiscord<mjsdev> in this case to the closure
05:34:45FromDiscord<Elegantbeef> It's best to just write the real Nim you want
05:35:04FromDiscord<Elegantbeef> Instead of making others attempt to comprehend the DSL nonsense and vocab you designed
05:35:28FromDiscord<mjsdev> I'm not making it for others (though they're welcome to use it)
05:36:29FromDiscord<Elegantbeef> Right, but just show the code you want to be made
05:39:35FromDiscord<mjsdev> I'm not sure I follow, the first example is the code I want to be made. I want to be able to add a command to my application in that way. And I wan the "Command" functionality to be similarly defined.
05:39:52FromDiscord<mjsdev> I'll keep playing around. I'm sure there's some way I'm missing.
05:40:57FromDiscord<Elegantbeef> I mean what's your desired macro input to output
05:41:43FromDiscord<Elegantbeef> I found the best way to implement macros is to writeup what you want the user to type then what the macro should generate, this also makes it easier to ask for help as people understand what you're poking at
05:45:46FromDiscord<mjsdev> sent a code paste, see https://play.nim-lang.org/#pasty=lZUFttYI
05:46:19FromDiscord<Elegantbeef> So where are you stuck here?
05:46:49FromDiscord<mjsdev> sent a code paste, see https://play.nim-lang.org/#pasty=gBqKFXmM
05:47:09FromDiscord<mjsdev> It's kinda like meta-meta-programming 😛
05:48:17FromDiscord<mjsdev> By adding the `Hook` facet to the Command, I need to parse and modify the AST defined on its call.
05:48:43FromDiscord<Elegantbeef> This doesn't play too well with Nim's single pass style
05:49:00FromDiscord<mjsdev> (edit) "Command," => "`Command`," | "`Command`,I need to parse and modify the AST defined on its call. ... " added " Then insert that on the other."
05:49:13FromDiscord<Elegantbeef> Cause `Hook` has to add a `hook: ` to `Command` which was declared before `shape` was called
05:50:23FromDiscord<mjsdev> Shape has to add `hook:` to the Command in `Home`
05:50:36FromDiscord<mjsdev> Based on the `Hook` defined on `Command`
05:52:42FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=sCgmaXqd
05:53:04FromDiscord<mjsdev> I was trying to get away with some casted pointer solution, but ultimately I don't think it's going to work very well since I need the symbol in the target class implementing the command. You can see the current `shape` macro here:↵↵https://github.com/mattsah/mininim-core/blob/main/src/mininim.nim#L110
05:56:20FromDiscord<mjsdev> sent a long message, see https://pasty.ee/SMPFGibb
05:58:49FromDiscord<mjsdev> sent a code paste, see https://play.nim-lang.org/#pasty=UbIkWDEN
05:59:12FromDiscord<Elegantbeef> You can store AST inside of variables or use the macro cache
05:59:48FromDiscord<mjsdev> macro cache might be a good solution... the TypeID stuff I found uses that
06:00:12FromDiscord<Elegantbeef> Yea it's just a compile time table to hold AST so it'll work for forwarding information
06:00:21FromDiscord<Elegantbeef> Though this DSL will cause many headaches
06:00:44FromDiscord<Elegantbeef> Looking like implementing a type symbol but not actually will be the death of you 😄
06:02:33FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=QoLQLAZY
06:03:28FromDiscord<Elegantbeef> Then you can do a `if not(typeof(builder).getTypeId) != app.builderTypeId: raise (ref ValueError)(msg: "Incorrect pointer conversion")`
06:08:08FromDiscord<mjsdev> I'm not sure I follow that (sorry, still fairly new to Nim, and it's been probably 2 decades since I've worked with statically typed languages and this low level of code)... from the builder standpoint, the issue is effectively that it needs to be generic but I wasn't able to declare a property on an object as a generic function pointer type.
06:08:47FromDiscord<Elegantbeef> Sure, when you add the builder procedure you also store the type information, this can be the `pointer` from `getTypeInfo` or you can use the `getTypeId` 'trick' I showed
06:08:58FromDiscord<Elegantbeef> This allows you to check when you attempt to unpack it to ensure it's the same type
06:09:13FromDiscord<Elegantbeef> Since you still store what it's runtime type was
06:11:59FromDiscord<mjsdev> Does it matter though if the builder type is not explicitly defined though?
06:12:42FromDiscord<Elegantbeef> I can provide an example in a second
06:14:34FromDiscord<mjsdev> OK, appreciate it, as said, sorry if I sound a bit confused. Still very new to this lang and the last time I worked with something like this was C, 20 years ago and it was very unsafe (allowed crazy things to be done).
06:16:41FromDiscord<Elegantbeef> https://play.nim-lang.org/#pasty=qpbfotpd
06:17:04FromDiscord<Elegantbeef> This makes it much safer and prevents attempting to cast a pointer to the wrong proc
06:23:04FromDiscord<mjsdev> I see... firstly, I didn't realize proc was a type like that... secondly though, I'm not sure it works for the style I'm aiming at given it's inlined in the Delegate(builder: ...) style
06:24:15FromDiscord<Elegantbeef> You could make a `typedDecay(myProc)` where `typedDecay` returns the tuple
06:24:30FromDiscord<Elegantbeef> You are doing a lot of shenanigans
06:24:49FromDiscord<Elegantbeef> Is there anyway you could just thunk the procs under a general type
06:25:35FromDiscord<Elegantbeef> Like in my gui I have `proc()` convert to `proc(a: T, b: Y)` where it just wraps it into `proc(a: T, b: Y) = myProc()`
06:32:09FromDiscord<mjsdev> sent a long message, see https://pasty.ee/SYKEfByQ
06:32:34FromDiscord<Elegantbeef> Yes a generic type has to be statically instantiated
06:32:44FromDiscord<mjsdev> I've thought about employing more macros to do some wrapping, but believe it or not, I'm trying to keep that to a minimum
06:32:50FromDiscord<Elegantbeef> You'd need to have a \`Delegate[T]\`\` or whatever
06:33:16FromDiscord<Elegantbeef> Hey I'll judge you deeply for these type macros, but I get it 😄
06:33:49FromDiscord<Elegantbeef> The nicest thing you can probably do is instead of using `T(a: b)` do `T.create((a: b))`
06:33:58FromDiscord<Elegantbeef> Using a tuple and a proc instead of directly creating one
06:34:14FromDiscord<mjsdev> I'm just trying to make an extensible framework with a few core concepts. I know it goes against "the Nim way" probably or the way of any static/safe programming.
06:35:12FromDiscord<Elegantbeef> Heh, it's just odd as I do not see any benefit in the song and dance you're doing
06:35:25FromDiscord<mjsdev> You can read about the basic concepts on the README here: https://github.com/mattsah/mininim -- but basically, classes, shapes (and corresponding facets). Where some Facets (like `Hook`) can add additional common behavior to other facets.
06:35:41FromDiscord<mjsdev> Probably depends on the world you live in.
06:36:58FromDiscord<mjsdev> I live in very fast/frequent (mostly web) app development. I need terse, repeatable patterns and highly modular systems. PHP is my goto, but the type of stuff I'm trying to do here is child's play there given the nature of the language.
06:37:26FromDiscord<mjsdev> If I was building one big application to be maintained for 10 years, I wouldn't reach for solutions like this.
06:38:13FromDiscord<Elegantbeef> You're attempting some very dynamic stuff so it's bound to be an uphill struggle
06:38:30FromDiscord<mjsdev> Indeed, and I expected it... I first tried with Pascal
06:38:57FromDiscord<Elegantbeef> I'd say heavily lean on closures and attempt to cover your basis with a large open door
06:39:02FromDiscord<mjsdev> didn't get very far... then I thought about trying to build my own language, cause I liked Pascal so much: https://github.com/mattsah/pint
06:39:12FromDiscord<Elegantbeef> So practically make all your procedure types `proc(args: JsonNode): JsonNode`
06:39:27FromDiscord<Elegantbeef> `args: varargs[JsonNode]`
06:39:28FromDiscord<mjsdev> Also didn't get very far... I found Nim before that when I was looking for language like or inspired by Pascal
06:39:51FromDiscord<mjsdev> Then decided to take another look.
06:39:58FromDiscord<Elegantbeef> Like I wouldn't even use Nim types for this much dynamism
06:40:16FromDiscord<mjsdev> Yeah, thing with Json nodes is then you just sort of throw away typing altogether
06:40:22FromDiscord<mjsdev> looking for _something_ of a middle ground.
06:40:42FromDiscord<Elegantbeef> Well you need some common window to put everything through
06:40:45FromDiscord<Elegantbeef> So break it down into that window
06:41:39FromDiscord<mjsdev> Yeah, I'll keep ruminating a bit. Not in any super rush. Appreciate the info you have given and I'll keep some of those tricks in mind.
07:59:57*kenran joined #nim
09:04:20*beholders_eye joined #nim
09:38:14*beholders_eye quit (Ping timeout: 272 seconds)
10:10:39FromDiscord<luteva> sent a code paste, see https://play.nim-lang.org/#pasty=rbCnwzWw
10:25:20FromDiscord<Robyn [She/Her]> In reply to @luteva "How can I iterate": You can use the `static` block?
10:25:29FromDiscord<Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=QgYEuDZM
10:25:40Amun-Raluteva: https://nim-lang.org/docs/typeinfo.html#fields.i%2CAny
10:34:09FromDiscord<luteva> sent a code paste, see https://play.nim-lang.org/#pasty=RqpLRTea
10:35:04Amun-Racheck the link
10:42:39FromDiscord<luteva> oh yeah! Seems to work 😄 Thx!
10:42:52*ntat joined #nim
10:50:45*beholders_eye joined #nim
11:26:02FromDiscord<pmunch> In reply to @mjsdev "Hrm... that Nim forum": Yes, the e-mail service is down. If you want a forum user just PM me your username and e-mail and I'll set one up for you
12:17:29*tokyovigilante quit (Ping timeout: 245 seconds)
12:31:32*tokyovigilante joined #nim
12:52:54*ntat quit (Quit: Leaving)
13:48:06*ntat joined #nim
14:04:00*beholders_eye quit (Ping timeout: 252 seconds)
14:06:43*beholders_eye joined #nim
15:04:08*beholders_eye quit (Ping timeout: 252 seconds)
15:04:35FromDiscord<silme94> what does when keyword
15:05:51FromDiscord<bostonboston> ?
15:08:59*beholders_eye joined #nim
15:09:57FromDiscord<solitudesf> In reply to @silme94 "what does when keyword": https://nim-lang.org/docs/manual.html#statements-and-expressions-when-statement
15:27:51FromDiscord<Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=vqNedMvz
15:27:57FromDiscord<Robyn [She/Her]> I'll try it when I get home
16:18:15FromDiscord<Robyn [She/Her]> What was that alternative nimble pkg directory site?
16:32:28FromDiscord<saint._._.> In reply to @battery.acid.bubblegum "What was that alternative": What's kimberlite?
16:32:39FromDiscord<saint._._.> Oh is that the file you are editing? I thought it was like leetcode or something
16:38:52FromDiscord<Robyn [She/Her]> In reply to @saint._._. "Oh is that the": Yeah, it's my MC server impl project, I've decided to pick it up again
16:44:22FromDiscord<xtrayambak> In reply to @battery.acid.bubblegum "What was that alternative": https://nimpkgs.dayl.in
16:44:35FromDiscord<xtrayambak> In reply to @battery.acid.bubblegum "Yeah, it's my MC": Neat! I've been following it for a bit
16:45:35FromDiscord<xtrayambak> have ya got anything working yet? I'd love to write a minecraft server in Nim
16:51:34*kenran quit (Remote host closed the connection)
17:01:23FromDiscord<Robyn [She/Her]> In reply to @xtrayambak "https://nimpkgs.dayl.in": ty!
17:01:36FromDiscord<Robyn [She/Her]> In reply to @xtrayambak "Neat! I've been following": really? I've done nothing for months lol
17:02:06FromDiscord<Robyn [She/Her]> In reply to @xtrayambak "have ya got anything": https://github.com/Nimberite-Development/ModernNet has some utils for handling the MC protocol, tho it doesn't actually implement any packets
17:03:31FromDiscord<Robyn [She/Her]> I also have an NBT parser and serialiser but it needs a rewrite tbh
17:03:57FromDiscord<griffith1deadly> writing minecraft server in nim is fun
17:05:18FromDiscord<Robyn [She/Her]> Yeah :)
17:32:17FromDiscord<saint._._.> In reply to @battery.acid.bubblegum "Yeah, it's my MC": Mc meaning minecraft?
17:32:32FromDiscord<Robyn [She/Her]> In reply to @saint._._. "Mc meaning minecraft?": Yeah
17:32:43FromDiscord<saint._._.> Awesome
17:34:46FromDiscord<Robyn [She/Her]> Yeah but it has no work done lol
17:34:50FromDiscord<Robyn [She/Her]> or barely any, i mean
17:36:37FromDiscord<saint._._.> Ah gotcha
17:43:41*ntat quit (Quit: Leaving)
18:20:16*Artea quit (*.net *.split)
18:20:18*gshumway quit (*.net *.split)
18:20:20*ormiret quit (*.net *.split)
18:22:35*Artea joined #nim
18:22:35*gshumway joined #nim
18:22:35*ormiret joined #nim
18:22:46*Artea quit (Max SendQ exceeded)
18:34:37*Artea joined #nim
19:14:35FromDiscord<user2m> how do I read the binary data of a file like a pdf file?
19:20:42FromDiscord<michaelb.eth> In reply to @user2m "how do I read": work with the bytes in the string
19:21:00FromDiscord<michaelb.eth> (edit) "In reply to @user2m "how do I read": work with the bytes in the string ... " added "from the read file"
19:32:47FromDiscord<user2m> sent a code paste, see https://play.nim-lang.org/#pasty=SjxHhQmi
19:36:17FromDiscord<demotomohiro> https://nim-lang.org/docs/streams.html↵There are `readIntX`, `readUintX` or `readFloatX` procs in streams module for reading binary files.
19:56:37FromDiscord<user2m> sent a code paste, see https://play.nim-lang.org/#pasty=QRRRYuSp
19:57:01FromDiscord<user2m> test.txt just says "hello world"
19:58:12Amun-RaI think you really want readUInt8
20:00:15FromDiscord<user2m> goctha!
20:00:40FromDiscord<user2m> sent a code paste, see https://play.nim-lang.org/#pasty=VQLlqtBK
20:03:21Amun-Rathere's also readFile if you need to read all the data
20:03:51Amun-Rait returns data as string
20:23:34*ntat joined #nim
20:30:03FromDiscord<user2m> sent a code paste, see https://play.nim-lang.org/#pasty=mZFxmUgV
20:37:15*krux02 joined #nim
20:38:42FromDiscord<user2m> sent a code paste, see https://play.nim-lang.org/#pasty=GyPwFDee
20:45:48*beholders_eye quit (Ping timeout: 276 seconds)
20:50:28Amun-Rahttps://play.nim-lang.org/#pasty=RqNYanTH
21:04:31*beholders_eye joined #nim
21:09:10FromDiscord<user2m> In reply to @Amun-Ra "https://play.nim-lang.org/#pasty=RqNYanTH": yeah that way better...don't sheesh
21:09:33FromDiscord<user2m> don't know why I made it so complicated sheesh
21:13:48Amun-Rauser2m: that's a natural learning curve
21:14:49Amun-Raif you saw my nim code when I started… ;)
21:20:06FromDiscord<user2m> In reply to @Amun-Ra "if you saw my": Lol thankful for folks like u, @demotomohiro and @michaelb.eth !
21:21:49Amun-Rathanks! :)
21:24:30*ntat quit (Quit: Leaving)
21:29:51FromDiscord<michaelb.eth> In reply to @user2m "Lol thankful for folks": sure thing
21:30:55FromDiscord<michaelb.eth> note that casting seq[uint8] to string is not recommended, for reasons I don’t fully recall atm
21:31:14FromDiscord<michaelb.eth> you’ll want to use a helper as can be found in stew
21:32:33FromDiscord<michaelb.eth> https://github.com/status-im/nim-stew/blob/12184120a67698cb0dc45c818f4347202cabd866/stew/byteutils.nim#L252
21:51:04*beholders_eye quit (Ping timeout: 260 seconds)
22:11:11*beholders_eye joined #nim
23:01:11*beholders_eye quit (Read error: Connection reset by peer)
23:04:24*beholders_eye joined #nim
23:17:40*FromDiscord quit (Remote host closed the connection)
23:17:53*FromDiscord joined #nim
23:19:13*nyeaa49284230101 quit (Ping timeout: 248 seconds)
23:48:54*beholders_eye quit (Ping timeout: 260 seconds)
23:56:17*FromDiscord quit (Remote host closed the connection)
23:56:30*FromDiscord joined #nim