00:05:10 | * | xaltsc joined #nim |
00:38:20 | FromDiscord | <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:39 | FromDiscord | <Robyn [She/Her]> also if this is your first time programming, game dev is a huge leap |
00:38:51 | FromDiscord | <Robyn [She/Her]> you'd be better off using an engine like Godot |
00:51:54 | FromDiscord | <.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:58 | FromDiscord | <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:59 | FromDiscord | <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:06 | FromDiscord | <Elegantbeef> @mjsdev why would you need it? |
05:19:28 | FromDiscord | <mjsdev> to parse nim |
05:20:05 | FromDiscord | <Elegantbeef> Quote is a compile time construct so it has to be used statically |
05:20:43 | FromDiscord | <Elegantbeef> It also doesn't take anything in but a body |
05:21:28 | FromDiscord | <Elegantbeef> What are you actually trying to do? |
05:25:55 | FromDiscord | <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:13 | FromDiscord | <Elegantbeef> `include` |
05:26:26 | FromDiscord | <mjsdev> Not as a file... |
05:26:44 | FromDiscord | <Elegantbeef> Make it a template or a generic |
05:31:00 | FromDiscord | <mjsdev> sent a code paste, see https://play.nim-lang.org/#pasty=qqcLmzwu |
05:31:57 | FromDiscord | <Elegantbeef> Oh goody a class DSL 😄 |
05:33:21 | FromDiscord | <mjsdev> sent a code paste, see https://play.nim-lang.org/#pasty=DehLfaKk |
05:33:46 | FromDiscord | <Elegantbeef> You cannot add fields to types |
05:34:12 | FromDiscord | <Elegantbeef> If a type exists it's concrete and cannot be changed |
05:34:15 | FromDiscord | <mjsdev> hook is already a field on the Command type |
05:34:27 | FromDiscord | <mjsdev> it would be a pointer |
05:34:34 | FromDiscord | <Elegantbeef> Ok |
05:34:43 | FromDiscord | <mjsdev> in this case to the closure |
05:34:45 | FromDiscord | <Elegantbeef> It's best to just write the real Nim you want |
05:35:04 | FromDiscord | <Elegantbeef> Instead of making others attempt to comprehend the DSL nonsense and vocab you designed |
05:35:28 | FromDiscord | <mjsdev> I'm not making it for others (though they're welcome to use it) |
05:36:29 | FromDiscord | <Elegantbeef> Right, but just show the code you want to be made |
05:39:35 | FromDiscord | <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:52 | FromDiscord | <mjsdev> I'll keep playing around. I'm sure there's some way I'm missing. |
05:40:57 | FromDiscord | <Elegantbeef> I mean what's your desired macro input to output |
05:41:43 | FromDiscord | <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:46 | FromDiscord | <mjsdev> sent a code paste, see https://play.nim-lang.org/#pasty=lZUFttYI |
05:46:19 | FromDiscord | <Elegantbeef> So where are you stuck here? |
05:46:49 | FromDiscord | <mjsdev> sent a code paste, see https://play.nim-lang.org/#pasty=gBqKFXmM |
05:47:09 | FromDiscord | <mjsdev> It's kinda like meta-meta-programming 😛 |
05:48:17 | FromDiscord | <mjsdev> By adding the `Hook` facet to the Command, I need to parse and modify the AST defined on its call. |
05:48:43 | FromDiscord | <Elegantbeef> This doesn't play too well with Nim's single pass style |
05:49:00 | FromDiscord | <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:13 | FromDiscord | <Elegantbeef> Cause `Hook` has to add a `hook: ` to `Command` which was declared before `shape` was called |
05:50:23 | FromDiscord | <mjsdev> Shape has to add `hook:` to the Command in `Home` |
05:50:36 | FromDiscord | <mjsdev> Based on the `Hook` defined on `Command` |
05:52:42 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=sCgmaXqd |
05:53:04 | FromDiscord | <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:20 | FromDiscord | <mjsdev> sent a long message, see https://pasty.ee/SMPFGibb |
05:58:49 | FromDiscord | <mjsdev> sent a code paste, see https://play.nim-lang.org/#pasty=UbIkWDEN |
05:59:12 | FromDiscord | <Elegantbeef> You can store AST inside of variables or use the macro cache |
05:59:48 | FromDiscord | <mjsdev> macro cache might be a good solution... the TypeID stuff I found uses that |
06:00:12 | FromDiscord | <Elegantbeef> Yea it's just a compile time table to hold AST so it'll work for forwarding information |
06:00:21 | FromDiscord | <Elegantbeef> Though this DSL will cause many headaches |
06:00:44 | FromDiscord | <Elegantbeef> Looking like implementing a type symbol but not actually will be the death of you 😄 |
06:02:33 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=QoLQLAZY |
06:03:28 | FromDiscord | <Elegantbeef> Then you can do a `if not(typeof(builder).getTypeId) != app.builderTypeId: raise (ref ValueError)(msg: "Incorrect pointer conversion")` |
06:08:08 | FromDiscord | <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:47 | FromDiscord | <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:58 | FromDiscord | <Elegantbeef> This allows you to check when you attempt to unpack it to ensure it's the same type |
06:09:13 | FromDiscord | <Elegantbeef> Since you still store what it's runtime type was |
06:11:59 | FromDiscord | <mjsdev> Does it matter though if the builder type is not explicitly defined though? |
06:12:42 | FromDiscord | <Elegantbeef> I can provide an example in a second |
06:14:34 | FromDiscord | <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:41 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#pasty=qpbfotpd |
06:17:04 | FromDiscord | <Elegantbeef> This makes it much safer and prevents attempting to cast a pointer to the wrong proc |
06:23:04 | FromDiscord | <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:15 | FromDiscord | <Elegantbeef> You could make a `typedDecay(myProc)` where `typedDecay` returns the tuple |
06:24:30 | FromDiscord | <Elegantbeef> You are doing a lot of shenanigans |
06:24:49 | FromDiscord | <Elegantbeef> Is there anyway you could just thunk the procs under a general type |
06:25:35 | FromDiscord | <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:09 | FromDiscord | <mjsdev> sent a long message, see https://pasty.ee/SYKEfByQ |
06:32:34 | FromDiscord | <Elegantbeef> Yes a generic type has to be statically instantiated |
06:32:44 | FromDiscord | <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:50 | FromDiscord | <Elegantbeef> You'd need to have a \`Delegate[T]\`\` or whatever |
06:33:16 | FromDiscord | <Elegantbeef> Hey I'll judge you deeply for these type macros, but I get it 😄 |
06:33:49 | FromDiscord | <Elegantbeef> The nicest thing you can probably do is instead of using `T(a: b)` do `T.create((a: b))` |
06:33:58 | FromDiscord | <Elegantbeef> Using a tuple and a proc instead of directly creating one |
06:34:14 | FromDiscord | <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:12 | FromDiscord | <Elegantbeef> Heh, it's just odd as I do not see any benefit in the song and dance you're doing |
06:35:25 | FromDiscord | <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:41 | FromDiscord | <mjsdev> Probably depends on the world you live in. |
06:36:58 | FromDiscord | <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:26 | FromDiscord | <mjsdev> If I was building one big application to be maintained for 10 years, I wouldn't reach for solutions like this. |
06:38:13 | FromDiscord | <Elegantbeef> You're attempting some very dynamic stuff so it's bound to be an uphill struggle |
06:38:30 | FromDiscord | <mjsdev> Indeed, and I expected it... I first tried with Pascal |
06:38:57 | FromDiscord | <Elegantbeef> I'd say heavily lean on closures and attempt to cover your basis with a large open door |
06:39:02 | FromDiscord | <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:12 | FromDiscord | <Elegantbeef> So practically make all your procedure types `proc(args: JsonNode): JsonNode` |
06:39:27 | FromDiscord | <Elegantbeef> `args: varargs[JsonNode]` |
06:39:28 | FromDiscord | <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:51 | FromDiscord | <mjsdev> Then decided to take another look. |
06:39:58 | FromDiscord | <Elegantbeef> Like I wouldn't even use Nim types for this much dynamism |
06:40:16 | FromDiscord | <mjsdev> Yeah, thing with Json nodes is then you just sort of throw away typing altogether |
06:40:22 | FromDiscord | <mjsdev> looking for _something_ of a middle ground. |
06:40:42 | FromDiscord | <Elegantbeef> Well you need some common window to put everything through |
06:40:45 | FromDiscord | <Elegantbeef> So break it down into that window |
06:41:39 | FromDiscord | <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:39 | FromDiscord | <luteva> sent a code paste, see https://play.nim-lang.org/#pasty=rbCnwzWw |
10:25:20 | FromDiscord | <Robyn [She/Her]> In reply to @luteva "How can I iterate": You can use the `static` block? |
10:25:29 | FromDiscord | <Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=QgYEuDZM |
10:25:40 | Amun-Ra | luteva: https://nim-lang.org/docs/typeinfo.html#fields.i%2CAny |
10:34:09 | FromDiscord | <luteva> sent a code paste, see https://play.nim-lang.org/#pasty=RqpLRTea |
10:35:04 | Amun-Ra | check the link |
10:42:39 | FromDiscord | <luteva> oh yeah! Seems to work 😄 Thx! |
10:42:52 | * | ntat joined #nim |
10:50:45 | * | beholders_eye joined #nim |
11:26:02 | FromDiscord | <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:35 | FromDiscord | <silme94> what does when keyword |
15:05:51 | FromDiscord | <bostonboston> ? |
15:08:59 | * | beholders_eye joined #nim |
15:09:57 | FromDiscord | <solitudesf> In reply to @silme94 "what does when keyword": https://nim-lang.org/docs/manual.html#statements-and-expressions-when-statement |
15:27:51 | FromDiscord | <Robyn [She/Her]> sent a code paste, see https://play.nim-lang.org/#pasty=vqNedMvz |
15:27:57 | FromDiscord | <Robyn [She/Her]> I'll try it when I get home |
16:18:15 | FromDiscord | <Robyn [She/Her]> What was that alternative nimble pkg directory site? |
16:32:28 | FromDiscord | <saint._._.> In reply to @battery.acid.bubblegum "What was that alternative": What's kimberlite? |
16:32:39 | FromDiscord | <saint._._.> Oh is that the file you are editing? I thought it was like leetcode or something |
16:38:52 | FromDiscord | <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:22 | FromDiscord | <xtrayambak> In reply to @battery.acid.bubblegum "What was that alternative": https://nimpkgs.dayl.in |
16:44:35 | FromDiscord | <xtrayambak> In reply to @battery.acid.bubblegum "Yeah, it's my MC": Neat! I've been following it for a bit |
16:45:35 | FromDiscord | <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:23 | FromDiscord | <Robyn [She/Her]> In reply to @xtrayambak "https://nimpkgs.dayl.in": ty! |
17:01:36 | FromDiscord | <Robyn [She/Her]> In reply to @xtrayambak "Neat! I've been following": really? I've done nothing for months lol |
17:02:06 | FromDiscord | <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:31 | FromDiscord | <Robyn [She/Her]> I also have an NBT parser and serialiser but it needs a rewrite tbh |
17:03:57 | FromDiscord | <griffith1deadly> writing minecraft server in nim is fun |
17:05:18 | FromDiscord | <Robyn [She/Her]> Yeah :) |
17:32:17 | FromDiscord | <saint._._.> In reply to @battery.acid.bubblegum "Yeah, it's my MC": Mc meaning minecraft? |
17:32:32 | FromDiscord | <Robyn [She/Her]> In reply to @saint._._. "Mc meaning minecraft?": Yeah |
17:32:43 | FromDiscord | <saint._._.> Awesome |
17:34:46 | FromDiscord | <Robyn [She/Her]> Yeah but it has no work done lol |
17:34:50 | FromDiscord | <Robyn [She/Her]> or barely any, i mean |
17:36:37 | FromDiscord | <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:35 | FromDiscord | <user2m> how do I read the binary data of a file like a pdf file? |
19:20:42 | FromDiscord | <michaelb.eth> In reply to @user2m "how do I read": work with the bytes in the string |
19:21:00 | FromDiscord | <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:47 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#pasty=SjxHhQmi |
19:36:17 | FromDiscord | <demotomohiro> https://nim-lang.org/docs/streams.html↵There are `readIntX`, `readUintX` or `readFloatX` procs in streams module for reading binary files. |
19:56:37 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#pasty=QRRRYuSp |
19:57:01 | FromDiscord | <user2m> test.txt just says "hello world" |
19:58:12 | Amun-Ra | I think you really want readUInt8 |
20:00:15 | FromDiscord | <user2m> goctha! |
20:00:40 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#pasty=VQLlqtBK |
20:03:21 | Amun-Ra | there's also readFile if you need to read all the data |
20:03:51 | Amun-Ra | it returns data as string |
20:23:34 | * | ntat joined #nim |
20:30:03 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#pasty=mZFxmUgV |
20:37:15 | * | krux02 joined #nim |
20:38:42 | FromDiscord | <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:28 | Amun-Ra | https://play.nim-lang.org/#pasty=RqNYanTH |
21:04:31 | * | beholders_eye joined #nim |
21:09:10 | FromDiscord | <user2m> In reply to @Amun-Ra "https://play.nim-lang.org/#pasty=RqNYanTH": yeah that way better...don't sheesh |
21:09:33 | FromDiscord | <user2m> don't know why I made it so complicated sheesh |
21:13:48 | Amun-Ra | user2m: that's a natural learning curve |
21:14:49 | Amun-Ra | if you saw my nim code when I started… ;) |
21:20:06 | FromDiscord | <user2m> In reply to @Amun-Ra "if you saw my": Lol thankful for folks like u, @demotomohiro and @michaelb.eth ! |
21:21:49 | Amun-Ra | thanks! :) |
21:24:30 | * | ntat quit (Quit: Leaving) |
21:29:51 | FromDiscord | <michaelb.eth> In reply to @user2m "Lol thankful for folks": sure thing |
21:30:55 | FromDiscord | <michaelb.eth> note that casting seq[uint8] to string is not recommended, for reasons I don’t fully recall atm |
21:31:14 | FromDiscord | <michaelb.eth> you’ll want to use a helper as can be found in stew |
21:32:33 | FromDiscord | <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 |