00:14:40 | FromDiscord | <!&luke> is it possibl to get the timezone of the person running my program |
00:23:19 | FromDiscord | <Patitotective> perhaps https://nim-lang.org/docs/times.html#local↵something in std/times should do that |
00:25:51 | FromDiscord | <Mr.Ender> 2 questions↵↵ Does discarding variables free memory↵ Should I discard a variable if I wont need it later in the program |
00:26:24 | FromDiscord | <Mr.Ender> (edit) "2 questions↵↵ Does discarding variables free memory↵ Should I discard" => "sent" | "variable if I wont need it later in the program" => "long message, see http://ix.io/4bfU" |
00:26:44 | FromDiscord | <Mr.Ender> (edit) "http://ix.io/4bfU" => "http://ix.io/4bfV" |
00:26:54 | FromDiscord | <Elegantbeef> No discard is just a Nim semantic |
00:26:55 | FromDiscord | <Elegantbeef> It does nothing but say "I dont want this value" |
00:27:09 | FromDiscord | <Mr.Ender> So discarding it wont do anything |
00:27:09 | FromDiscord | <Elegantbeef> Yes you should ddiscard values you dont need |
00:27:10 | FromDiscord | <Elegantbeef> That's the entire point of it after all |
00:27:33 | FromDiscord | <Elegantbeef> It tells Nim "I do not care about the result of this expression" |
00:27:41 | FromDiscord | <Mr.Ender> ok |
00:27:43 | FromDiscord | <Mr.Ender> thanks |
00:28:12 | FromDiscord | <Elegantbeef> Ah sorry i forgot to @Mr.Ender |
00:42:51 | FromDiscord | <Patitotective> huh does `addQuoted` replace `\n` with `\p`? |
00:43:46 | FromDiscord | <Patitotective> so on windows it adds `\r\p`? |
00:48:30 | * | arkurious quit (Quit: Leaving) |
01:10:07 | FromDiscord | <Tuatarian> is play.nim-lang.org down or is it a college wifi thing? |
01:11:02 | FromDiscord | <Elegantbeef> Still down |
01:11:14 | FromDiscord | <Tuatarian> unfortunate |
01:11:18 | FromDiscord | <Tuatarian> is Token a reserved keyword? |
01:11:24 | FromDiscord | <Elegantbeef> No |
01:11:26 | FromDiscord | <demotomohiro> !eval echo "Am I alive?" |
01:11:27 | FromDiscord | <Tuatarian> I'm declaring a type called Token and it isn't behaving properly |
01:11:55 | FromDiscord | <Tuatarian> a `seq[Token` is printing as `@[//, ex, code, :, f, (, a, ,, b, ), =, ident, f, :, ident, a, ,, ident]` |
01:12:14 | FromDiscord | <Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=4bg0 |
01:12:20 | FromDiscord | <Tuatarian> `TKind` is an enum |
01:12:26 | NimBot | Compile failed: <no output> |
01:13:32 | FromDiscord | <demotomohiro> Does your code works when you change type name `Token` to different name? |
01:13:44 | FromDiscord | <Elegantbeef> There is no `Token` in the stdlib |
01:13:47 | FromDiscord | <Elegantbeef> So... yea |
01:14:11 | FromDiscord | <Tuatarian> not sure what even could be happening here |
01:16:36 | FromDiscord | <Elegantbeef> Full code? |
01:18:05 | FromDiscord | <Tuatarian> sent a code paste, see https://paste.rs/vFV |
01:18:34 | FromDiscord | <Tuatarian> the syntax highlight breaks with the `\"` but it doesn't give a compile error |
01:18:44 | FromDiscord | <Tuatarian> (edit) "`\"`" => "`'\"'`" |
01:20:48 | FromDiscord | <demotomohiro> You are overloading `$` operator for `Token` so `seq[Token]` prints only `Token.val`. |
01:21:05 | FromDiscord | <Tuatarian> oh... |
01:21:08 | FromDiscord | <Tuatarian> got it, thanks |
01:25:32 | FromDiscord | <Tuatarian> yep that was absolutely the problem, renaming the function worked completely |
01:25:33 | FromDiscord | <Tuatarian> thanks |
01:38:14 | * | vicecea quit (Remote host closed the connection) |
01:38:43 | * | vicecea joined #nim |
02:00:17 | FromDiscord | <Patitotective> ident should accept a `newline` parameter https://nim-lang.org/docs/strutils.html#indent,string,Natural,string |
02:00:26 | FromDiscord | <Patitotective> (edit) "ident" => "indent" |
02:16:19 | FromDiscord | <Patitotective> before publishing, any suggestions beef? https://github.com/Patitotective/kdl-nim↵(apart from this blazingly fast slicing https://github.com/Patitotective/kdl-nim/blob/main/src/kdl/lexer.nim#L272) |
02:17:23 | FromDiscord | <huantian> I’m pretty sure the nail art is called dash slash not slash dash |
02:17:47 | FromDiscord | <Bung> any rfc about const expr in arguments ? I haven't use complex one, but see them in issues |
02:19:00 | FromDiscord | <Patitotective> In reply to @huantian "I’m pretty sure the": :p |
02:25:47 | FromDiscord | <Elegantbeef> use `std/enumerate` https://github.com/Patitotective/kdl-nim/blob/main/src/kdl.nim#L96 |
02:25:47 | FromDiscord | <Elegantbeef> `result = &"({node.tag.get.quoted})"` is a convoluted `$` call |
02:26:51 | FromDiscord | <Elegantbeef> Macros are already hard enough, use genast or quote do https://github.com/Patitotective/kdl-nim/blob/main/src/kdl/lexer.nim#L95-L107 |
02:27:44 | FromDiscord | <Patitotective> In reply to @Elegantbeef "`result = &"({node.tag.get.quoted})"` is": so `result = "(" & node.tag.get.quoted & ")"`? |
02:27:55 | FromDiscord | <Elegantbeef> Oh i didnt even see the `()` |
02:28:41 | FromDiscord | <Patitotective> if i use strformat it will copy `node.tag.get.quoted`, which is already a string, right? |
02:29:12 | FromDiscord | <Elegantbeef> It's fine t ouse strformat but it's not the most ideal for performance, but yea didnt see the `()` when i commented |
02:29:29 | FromDiscord | <Patitotective> :p |
02:30:15 | FromDiscord | <Elegantbeef> Dont know if you're really benefitting from generics with your `match` procedure 😄 |
02:31:30 | FromDiscord | <Patitotective> In reply to @Elegantbeef "Dont know if you're": yea, i think a set would be enough |
02:32:06 | FromDiscord | <Elegantbeef> Eh i more mean the generic procedure is very clearly two separate specialisations and merging them together makes it very hard to read |
02:33:25 | FromDiscord | <Patitotective> i could separate them and make `match(x: TokenKind)` call `match(x: set[TokenKind])` by `{x}`, right↵thanks |
02:34:53 | FromDiscord | <Elegantbeef> I meant more like this |
02:35:03 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4bga |
02:36:03 | FromDiscord | <Patitotective> Smells like bloat |
02:36:22 | FromDiscord | <Elegantbeef> It's actually readable unlike what you had |
02:36:33 | FromDiscord | <Elegantbeef> Atleast the `if (when` was awful to me |
02:36:38 | FromDiscord | <Rika> Readability is bloat |
02:36:49 | FromDiscord | <Patitotective> In reply to @Elegantbeef "Atleast the `if (when`": hehe |
02:40:07 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4bgb |
02:41:04 | FromDiscord | <Patitotective> :] |
02:43:46 | FromDiscord | <Elegantbeef> Your set to has a similar 'issue' |
02:43:46 | FromDiscord | <Elegantbeef> You also needlessly assert inside each when branch |
02:43:48 | FromDiscord | <Elegantbeef> How fast is it now though? |
02:44:38 | FromDiscord | <Patitotective> In reply to @Elegantbeef "You also needlessly assert": oh, youre right |
02:45:38 | FromDiscord | <Patitotective> In reply to @Elegantbeef "How fast is it": well, the 376 lines long file now is parsed in less than 1 seconds |
02:45:41 | FromDiscord | <Patitotective> (edit) "seconds" => "second" |
02:45:55 | FromDiscord | <Patitotective> i should timeit probably |
02:46:09 | FromDiscord | <Patitotective> unittest should tell me how much time it took :p |
02:46:33 | FromDiscord | <Elegantbeef> No clue if it's worth your time you could make KDL a submodule inside `tests` so you can more easily manage your tests |
02:46:33 | FromDiscord | <Elegantbeef> But that's up to you |
02:46:44 | FromDiscord | <Elegantbeef> I do wonder if there's anyway you can make the parser work on `openarray[char]` instead of `string` |
02:47:44 | FromDiscord | <Elegantbeef> `scanKdl` and `parseKdl` should take a `sink string` |
02:47:59 | FromDiscord | <Elegantbeef> that way you only need to copy if you use the string after, saving allocations |
02:47:59 | FromDiscord | <Patitotective> In reply to @Elegantbeef "I do wonder if": it would have to be `seq[char]` because i store the `Lexer.source` |
02:48:10 | FromDiscord | <Elegantbeef> Sure but do you need to store it? |
02:48:46 | FromDiscord | <Elegantbeef> You'd have to pass `data` around everywhere i know, so i guess i'll shush |
02:49:41 | FromDiscord | <Elegantbeef> You could make a `cstring` variant that takes an openarray and grabs the `addr myArr[0]` and `len` from it |
02:49:57 | FromDiscord | <Elegantbeef> Would make it more reusable |
02:50:22 | FromDiscord | <Elegantbeef> But alas i'll shush |
02:50:51 | FromDiscord | <Patitotective> In reply to @Elegantbeef "But alas i'll shush": hehe↵ill try to make it work with openarray |
02:54:31 | FromDiscord | <Elegantbeef> Though parseutils expects a `string` so that makes your life more tedious |
02:55:11 | FromDiscord | <Patitotective> In reply to @Elegantbeef "Though parseutils expects a": "more tedious" means that i have to convert it to a string all the time? |
02:56:28 | FromDiscord | <Patitotective> also, how would i convert an openArray[char] to a string? |
02:56:33 | FromDiscord | <Elegantbeef> No |
02:56:33 | FromDiscord | <Elegantbeef> Port parseutils to use `openarray[char]` |
02:56:33 | FromDiscord | <Elegantbeef> Like it probably should |
02:56:41 | FromDiscord | <Elegantbeef> Why would you? |
02:57:27 | FromDiscord | <Elegantbeef> Like i said you'd convert it to a cstring and len |
02:58:50 | FromDiscord | <Patitotective> but some procedures like `splitLines` expect a string↵do i also need to port it? 😔 porting those modules will take too much time |
02:59:01 | FromDiscord | <Elegantbeef> That's why i said it'd be tedious |
02:59:28 | FromDiscord | <Elegantbeef> Anything that takes `string` but doesnt need to mutate it, should be `openarray[char]` |
02:59:28 | FromDiscord | <Elegantbeef> It's just a fact |
02:59:46 | FromDiscord | <Elegantbeef> Or if it doesnt need owership |
03:01:15 | FromDiscord | <Patitotective> In reply to @Elegantbeef "Anything that takes `string`": i actually had to mutate `source` because mult-line strings got CRLF but i wanted it to be LF so i had to `lexer.source[lexer.current..lexer.current + 1] = "\n"` |
03:01:17 | FromDiscord | <Patitotective> 💀 |
03:01:21 | FromDiscord | <Elegantbeef> `openarray[char]` is just the right way to write reusable code imo |
03:01:48 | FromDiscord | <Elegantbeef> I mean you dont need to though |
03:02:03 | FromDiscord | <Patitotective> ill add it to the todo list :-] |
03:02:35 | FromDiscord | <Elegantbeef> It's very unlikely anyone will use KDL in the way i described |
03:02:39 | FromDiscord | <Elegantbeef> But i'm silly about code reuse |
03:03:07 | FromDiscord | <Patitotective> maybe one day youll get soo bored that will fix it for me ;] |
03:03:40 | FromDiscord | <Elegantbeef> Eh i was going to make a PR to the stdlib but there is a present issue that `string` matches `cstring` and `openarray[char]` |
03:03:43 | FromDiscord | <Elegantbeef> So... yea |
03:23:47 | FromDiscord | <Patitotective> damn this semver regex is so sexy `^(0|[1-9]\d)\.(0|[1-9]\d)\.(0|[1-9]\d)(?:-((?:0|[1-9]\d|\d[a-zA-Z-][0-9a-zA-Z-])(?:\.(?:0|[1-9]\d|\d[a-zA-Z-][0-9a-zA-Z-]))))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)))?$` |
03:24:18 | FromDiscord | <Rika> Yum |
03:58:57 | FromDiscord | <ravinder387> sent a long message, see http://ix.io/4bgg |
03:59:26 | FromDiscord | <ravinder387> I want to save the writefile(to the assets folder) |
03:59:40 | FromDiscord | <ravinder387> file.nim is my nim file where i execute the code |
04:00:20 | FromDiscord | <ravinder387> writeFile(..\\assets\\img.png) |
04:00:22 | FromDiscord | <ravinder387> error |
04:00:37 | FromDiscord | <Patitotective> error... |
04:00:59 | FromDiscord | <ravinder387> I'm using windows |
04:01:08 | FromDiscord | <Elegantbeef> It dpends on your working path |
04:01:24 | FromDiscord | <ravinder387> I'm under folder |
04:01:27 | FromDiscord | <Elegantbeef> set the current directory to the directory the app is in |
04:07:46 | FromDiscord | <Bung> sent a code paste, see https://play.nim-lang.org/#ix=4bgi |
04:07:51 | FromDiscord | <Elegantbeef> Exactly my point |
04:07:59 | FromDiscord | <Elegantbeef> It shouldnt compile but presently does |
04:08:12 | FromDiscord | <Elegantbeef> `lent T` will be valid i believe |
04:08:45 | FromDiscord | <Bung> so what would the error message like |
04:09:33 | FromDiscord | <Elegantbeef> for sink it'd be "cannot use sink as a field type" |
04:09:33 | FromDiscord | <Elegantbeef> for `openarray` it'd be same as seq/array |
04:09:57 | FromDiscord | <Elegantbeef> Lent would be similar i'd imagine to openarray since eventually it'll be how you do a read only borrow |
04:14:45 | FromDiscord | <Bung> so `lent`, `openarray` can be used as field type ? as `seq/array` error about lack of generic params |
04:17:51 | FromDiscord | <Elegantbeef> `lent` will be eventually with views |
04:18:03 | FromDiscord | <Elegantbeef> `openarray` cannot be used |
04:20:04 | FromDiscord | <Bung> I see, I just searched these in nim repo |
04:20:43 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/manual_experimental.html#view-types |
04:22:55 | FromDiscord | <Bung> hmm, so openArray can be used when `--experimental:view` ? |
04:23:13 | FromDiscord | <Elegantbeef> Dont recall how views work now |
04:23:14 | FromDiscord | <Elegantbeef> I t hink so |
04:25:06 | FromDiscord | <Bung> ok, get it. |
04:35:57 | * | dtomato quit (Ping timeout: 252 seconds) |
05:08:08 | * | kenran joined #nim |
05:10:48 | NimEventer | New question by Top-Master: Nim-lang: OOP features supported?, see https://stackoverflow.com/questions/73834873/nim-lang-oop-features-supported |
05:16:31 | FromDiscord | <Prestige> Was that question asked by a bot? |
05:19:59 | FromDiscord | <ChocolettePalette> > PHP↵The most important question is missing\: does Nim support word-press or dru-pal? |
05:35:40 | FromDiscord | <Prestige> Pretty hilarious post |
05:40:06 | FromDiscord | <aph> In reply to @Avahe "Was that question asked": 5814 rep bot :(↵open source that bot when |
05:41:11 | FromDiscord | <Elegantbeef> You know you can legally open up a text file and write 5815 and no one can stop you |
05:41:53 | FromDiscord | <Rika> What? |
05:42:20 | FromDiscord | <Elegantbeef> Internet points dont matter |
05:43:26 | FromDiscord | <Prestige> Correct |
05:48:24 | * | qwr quit (Ping timeout: 264 seconds) |
05:54:33 | * | qwr joined #nim |
06:08:31 | * | kenran quit (Quit: WeeChat info:version) |
06:33:17 | * | tiorock joined #nim |
06:33:17 | * | tiorock quit (Changing host) |
06:33:17 | * | tiorock joined #nim |
06:33:17 | * | rockcavera is now known as Guest1483 |
06:33:17 | * | Guest1483 quit (Killed (tungsten.libera.chat (Nickname regained by services))) |
06:33:17 | * | tiorock is now known as rockcavera |
07:03:11 | FromDiscord | <Bung> https://github.com/nim-lang/Nim/pull/20408 @ElegantBeef |
07:04:25 | * | dtomato joined #nim |
07:09:25 | * | neceve quit (Quit: ZNC - https://znc.in) |
07:09:26 | FromDiscord | <Bung> I still dont think const closure proc make sense, it just a thing works |
07:10:10 | * | neceve joined #nim |
07:10:30 | FromDiscord | <Elegantbeef> Does it work? |
07:10:36 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4bgG |
07:11:29 | * | dtomato quit (Quit: The Lounge - https://thelounge.chat) |
07:12:11 | * | dtomato joined #nim |
07:13:08 | FromDiscord | <Bung> oh, yes .. I forgot that example code in issue just echo isNil |
07:13:39 | FromDiscord | <Bung> so it's just a thing can be defined |
07:15:43 | FromDiscord | <Bung> what's rawEnv ? access without through callconv ? |
07:15:56 | FromDiscord | <Elegantbeef> You can access the closures environment directly |
07:18:26 | FromDiscord | <Bung> have no idea what's environment of closures |
07:18:30 | FromDiscord | <Elegantbeef> https://github.com/beef331/slicerator/blob/master/src/closures.nim#L99-L103 |
07:18:50 | FromDiscord | <Elegantbeef> It's where the closure stores its state |
07:21:03 | FromDiscord | <Bung> I only know iterator has state |
07:22:16 | FromDiscord | <Mrcool> Are there other back-ends planed? |
07:22:42 | FromDiscord | <Elegantbeef> Run that and you'll see 11, 12, 13 be printed out |
07:22:42 | FromDiscord | <Elegantbeef> What happens is Nim lifts that `i` to the heap and stores it in the closure, a closure procedure is actually a `(ref Environment, ptrProc)` |
07:22:43 | FromDiscord | <Elegantbeef> This is why `sizeof(proc(){.closure.}) != sizeof(proc(){.nimcall.})` |
07:22:43 | FromDiscord | <Elegantbeef> When you run a closure procedure it passes the environment as the first parameter and uses that to access the variables you've captured |
07:22:46 | FromDiscord | <Elegantbeef> That's where the term capture comes from, it's capturing variables to throw in the environment on the heap |
07:22:46 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4bgI |
07:22:46 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/intern.html#code-generation-for-closures might make you a happy programmer |
07:22:47 | * | dtomato quit (Quit: The Lounge - https://thelounge.chat) |
07:24:04 | * | dtomato joined #nim |
07:24:28 | FromDiscord | <Elegantbeef> `closure` means it has state↵(@Bung) |
07:24:31 | FromDiscord | <Elegantbeef> That's what a `closure` means basically |
07:25:28 | FromDiscord | <Bung> oh, I understand the code, just has no connection with the word "Environment" |
07:26:05 | FromDiscord | <Elegantbeef> Environment, state, it's all the same |
07:26:10 | FromDiscord | <Elegantbeef> It's just the term for that pointer where the data is stored |
07:27:19 | FromDiscord | <Bung> yeah , in js we call scope |
07:27:47 | FromDiscord | <Elegantbeef> Scope and environment is different |
07:28:26 | FromDiscord | <Elegantbeef> Scope is just the symbol accessibillity |
07:29:02 | FromDiscord | <Elegantbeef> Environment is the captured data for a closure that is passed around with it so you can continue where you left off |
07:29:44 | FromDiscord | <Bung> understand . thanks! |
07:38:19 | FromDiscord | <Mrcool> how do I express js optional in nim? |
07:44:28 | FromDiscord | <Mrcool> it seems nim can't express them |
07:44:35 | FromDiscord | <Mrcool> is this planned in the future? |
07:45:01 | FromDiscord | <Elegantbeef> What do you mean by optionals? |
07:45:32 | FromDiscord | <Mrcool> <https://github.com/nim-lang/Nim/blob/devel/lib/js/jsre.nim#L31> flags is optional in js |
07:45:39 | FromDiscord | <Mrcool> but its required by nim |
07:45:53 | FromDiscord | <Mrcool> and this make some arguments completly omited |
07:46:03 | FromDiscord | <Elegantbeef> you'd make a proc that wraps it with `self: RegExpr, pattern: cstring)` |
07:46:05 | FromDiscord | <Mrcool> see <https://github.com/nim-lang/Nim/blob/version-1-6/lib/js/jsre.nim#L36> where limit argument can't be expressed |
07:46:20 | FromDiscord | <Elegantbeef> Yea you need to make overloads for it manually |
07:46:41 | FromDiscord | <Elegantbeef> Nim is static typed so you cannot really express "this value doesnt need to be passed, and if it's not passed it's fine" |
07:47:11 | FromDiscord | <Mrcool> I imagiened Optional<type> that compiles to js type | undefiend |
07:47:17 | FromDiscord | <Mrcool> but if overloading wors that nice too |
07:47:21 | FromDiscord | <Mrcool> (edit) "wors" => "works" |
07:47:32 | FromDiscord | <Elegantbeef> I mean there is `std/options` |
07:47:32 | FromDiscord | <Elegantbeef> But that doesnt do what you want |
07:47:36 | FromDiscord | <Mrcool> (edit) "imagiened" => "imagined" |
07:48:13 | FromDiscord | <Bung> you can try provide nil |
07:48:21 | FromDiscord | <Rika> New package time? jsoptions lol |
07:48:48 | FromDiscord | <Elegantbeef> It'd just be a `type Jsoption[T] = object jsObj: JsObject` 😄 |
07:49:17 | FromDiscord | <Elegantbeef> Or a distinct, depending on how i feel |
07:49:43 | FromDiscord | <Elegantbeef> I assume that Nim is smart enough to make `JsObject` default to a valid object though. But i dont know |
07:50:33 | FromDiscord | <Mrcool> is this the correct way? https://media.discordapp.net/attachments/371759389889003532/1023139357521092629/unknown.png |
07:51:01 | FromDiscord | <Mrcool> (I'm using github to edit, cloning the repo seems to take long time xD ) |
08:16:24 | FromDiscord | <Mrcool> I guess overloading is not sustainable because js uses optional everywhere we'll have a lot of duplicate fns just to handle this , hopefully jsoption idea can materialize |
09:22:21 | * | arkurious joined #nim |
09:43:51 | FromDiscord | <Mrcool> sent a code paste, see https://play.nim-lang.org/#ix=4bhl |
09:47:15 | NimEventer | New thread by drkameleon: Update dictionary value function?, see https://forum.nim-lang.org/t/9490 |
09:53:01 | FromDiscord | <Mrcool> sent a code paste, see https://play.nim-lang.org/#ix=4bhm |
09:53:19 | FromDiscord | <Mrcool> but it seems like inline importjs is not a thing |
09:54:42 | FromDiscord | <Mrcool> (edit) "https://play.nim-lang.org/#ix=4bhm" => "https://play.nim-lang.org/#ix=4bhn" |
09:59:42 | FromDiscord | <hotdog> In reply to @Mrcool "It seems like using": What about `proc a(b: int) {.importjs: “a({b: #})”.}` ? |
10:00:20 | FromDiscord | <Mrcool> thats where I reached xD https://media.discordapp.net/attachments/371759389889003532/1023172015689060423/unknown.png |
10:00:39 | FromDiscord | <Mrcool> now the next steps are ↵- make it accept varargs↵- make a macro that use it to do the above |
10:00:59 | FromDiscord | <hotdog> Cool |
10:00:59 | FromDiscord | <Mrcool> (edit) "now the next steps are ↵- make it accept varargs↵- make a macro that use it to do the above ... " added "with `js{a:4}`" |
10:01:21 | FromDiscord | <Mrcool> is it possible to have varargs with different types |
10:02:41 | FromDiscord | <hotdog> I think you’ll probably need to macro this |
10:03:29 | FromDiscord | <hotdog> Nim is very flexible, there’s definitely room to make this js interop stuff more ergonomic |
10:05:15 | FromDiscord | <Mrcool> Yeah I'm enjoying it so far, so many different features from everywhere |
10:06:42 | FromDiscord | <Mrcool> What got me interested in nim in the first place is its compile time super power, so lets see how far can I go |
10:10:24 | FromDiscord | <hotdog> Good to hear 🙂 |
10:18:03 | FromDiscord | <Mrcool> ok pseudo code in place, time to read some docs https://media.discordapp.net/attachments/371759389889003532/1023176481230307388/unknown.png |
10:26:04 | FromDiscord | <Mrcool> is there something like array.map |
10:30:54 | FromDiscord | <Rika> Map in sequtils |
10:31:12 | FromDiscord | <Rika> Or did I misinterpret? what do you mean? |
10:32:10 | FromDiscord | <Mrcool> map (+ 1) [1,2,3] |
10:32:22 | FromDiscord | <Mrcool> or in js [1,2,3].map(e=>e+1) |
10:35:37 | FromDiscord | <Rika> Yeah then my answer is fine |
10:36:27 | FromDiscord | <Rika> https://nim-lang.org/docs/sequtils.html#map%2CopenArray%5BT%5D%2Cproc%28T%29 |
10:46:46 | FromDiscord | <aruZeta> Just released QRgen v2.2.0, now supporting rendering QR codes into pixie's `Image`, which can be rendered in any format supported by pixie |
10:46:51 | FromDiscord | <aruZeta> (edit) "pixie" => "pixie, like PNG" |
10:47:01 | FromDiscord | <Rika> Nice |
10:47:11 | FromDiscord | <Rika> Wait so how were you doing it at first |
10:47:19 | FromDiscord | <aruZeta> SVGs you mean? |
10:47:22 | FromDiscord | <Rika> Ah |
10:47:24 | FromDiscord | <aruZeta> by hand |
10:47:35 | FromDiscord | <Rika> No I didn’t know what you rendered to at first |
10:47:44 | FromDiscord | <aruZeta> just SVG was supported before |
10:48:00 | FromDiscord | <aruZeta> which should be enough for web developers ig |
10:49:59 | FromDiscord | <aruZeta> and like yesterday I found some repo using my QR generator lib with JS |
10:52:49 | FromDiscord | <Rika> Already? Damn that’s quick |
10:53:03 | FromDiscord | <aruZeta> yh lol |
10:53:35 | FromDiscord | <aruZeta> lemme find it |
10:54:01 | FromDiscord | <aruZeta> it was this one https://github.com/JohnRSim/OCM-QR-Field |
10:54:30 | FromDiscord | <Mrcool> can I get the type from these nodes? https://media.discordapp.net/attachments/371759389889003532/1023185651618820196/unknown.png |
10:54:36 | FromDiscord | <Mrcool> as in intLit -> int StrLit -> string |
10:54:45 | FromDiscord | <Mrcool> (edit) "intLit" => "`intLit" | "int StrLit" => "int` `StrLit" | "string" => "string`" |
10:59:25 | FromDiscord | <Mrcool> .kind gets me closer |
11:00:28 | FromDiscord | <Forest [She/Her]> How would i make a list of clients with AsyncSockets? |
11:00:45 | FromDiscord | <Forest [She/Her]> I want it so they have their own ID, so they're easily able to be referenced |
11:04:23 | FromDiscord | <Mrcool> In reply to @Mrcool "can I get the": There seems to be no builtin way, for now ths works I guess https://media.discordapp.net/attachments/371759389889003532/1023188137150783558/unknown.png |
11:06:59 | FromDiscord | <Forest [She/Her]> Also is there a bidirectional table in Nim? |
11:07:06 | FromDiscord | <Forest [She/Her]> In reply to @Mrcool "can I get the": Do you mean the value? |
11:07:33 | FromDiscord | <Forest [She/Her]> For integers, it's `intVal` and for strings it's `strVal` |
11:07:37 | FromDiscord | <Rika> In reply to @Event Horizon "Also is there a": Not in the standard library |
11:07:49 | FromDiscord | <auxym> @Mrcool I'm far from a macro expert, but if you use `typed` instead of `untyped` arguments to your macro I think you can extract the type (somehow). |
11:07:57 | FromDiscord | <Forest [She/Her]> In reply to @Rika "Not in the standard": Google didn't help me find any libraries for it either sadly |
11:08:11 | FromDiscord | <Forest [She/Her]> May just hack something together using a normal table |
11:08:20 | FromDiscord | <Rika> In reply to @Mrcool "There seems to be": You will need a typed macro for types as if you pass a variable then the type is not known in an untyped macro |
11:08:29 | FromDiscord | <Rika> Naturally from the name ;P |
11:09:43 | FromDiscord | <auxym> `getType` I think is the proc. see https://dev.to/beef331/demystification-of-macros-in-nim-13n8 scroll down to "untyped vs typed" |
11:09:48 | FromDiscord | <Mrcool> I passed typed but still getType didn't work |
11:10:23 | FromDiscord | <Mrcool> actually that not correct |
11:10:45 | FromDiscord | <Mrcool> I just need untyped because of the end goal I'm after, so I just can't use typed |
11:10:54 | FromDiscord | <Mrcool> for now kind works instead |
11:10:56 | FromDiscord | <Rika> Then there is no sensible way |
11:12:23 | FromDiscord | <hotdog> In reply to @Mrcool "I just need untyped": Then it will only work for literals I think |
11:12:28 | FromDiscord | <Rika> Yes |
11:13:31 | FromDiscord | <hotdog> You can do a two stage macro, where the untyped macro transforms the code into something that will pass the type check and then it calls a typed macro |
11:13:59 | FromDiscord | <Rika> Two stage macros are kinda funky though from what I’ve heard |
11:14:29 | FromDiscord | <hotdog> I’ve done it successfully before but it is complicated to get right |
11:18:17 | FromDiscord | <Mrcool> I'll start with untyped since it should handle simple js object |
11:18:30 | FromDiscord | <Mrcool> is there a push for string? |
11:18:54 | FromDiscord | <Mrcool> var a = "ez"↵a += "b" #fails |
11:19:32 | FromDiscord | <hotdog> &= |
11:19:57 | FromDiscord | <auxym> or `add` |
11:20:20 | FromDiscord | <auxym> `myString.add("b")` |
11:20:20 | FromDiscord | <Mrcool> thanks |
11:21:13 | FromDiscord | <Mrcool> so now I have this https://media.discordapp.net/attachments/371759389889003532/1023192376988147753/unknown.png |
11:21:20 | FromDiscord | <Mrcool> and argslit https://media.discordapp.net/attachments/371759389889003532/1023192404725088306/unknown.png |
11:21:33 | FromDiscord | <Mrcool> but quoting add quotes to it so it fails https://media.discordapp.net/attachments/371759389889003532/1023192459200700476/unknown.png |
11:21:40 | FromDiscord | <Rika> What’s the AST representation |
11:22:10 | FromDiscord | <Mrcool> argslit is an actal string |
11:22:15 | FromDiscord | <Mrcool> (edit) "actal" => "actual" |
11:22:25 | FromDiscord | <Rika> You can’t use strings for that |
11:22:31 | FromDiscord | <Rika> You have to make an AST |
11:22:39 | * | jjido joined #nim |
11:23:48 | FromDiscord | <auxym> you might be able to feed your string to `parseStmt` to convert it to an AST |
11:24:11 | FromDiscord | <auxym> also consider std/genasts instead of quote do |
11:25:29 | FromDiscord | <Forest [She/Her]> How can i make Nim's VSC extension by Nimsaem use `nimlsp` by PMunch? |
11:26:25 | FromDiscord | <auxym> is there a reason to do that? nimlsp is just a "bridge" to nimsuggest, which the extension uses directly |
11:27:01 | FromDiscord | <Forest [She/Her]> Nimsuggest almost constantly crashes for me so maybe it'd be able to handle that for me |
11:30:42 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
11:39:22 | FromDiscord | <Mrcool> now I have an AST, but I need to remove those quotes https://media.discordapp.net/attachments/371759389889003532/1023196940156030977/unknown.png https://media.discordapp.net/attachments/371759389889003532/1023196940621590528/unknown.png https://media.discordapp.net/attachments/371759389889003532/1023196941087166536/unknown.png |
11:39:56 | FromDiscord | <Mrcool> and parens |
11:41:17 | * | jmdaemon quit (Ping timeout: 252 seconds) |
11:42:04 | * | jjido joined #nim |
11:44:19 | FromDiscord | <auxym> you'll need to extract those two ColonExpr from the TupleConstr |
11:47:39 | FromDiscord | <Mrcool> actually turns out its easy to extract |
11:47:40 | FromDiscord | <auxym> is the number of args always 2? because if not you can't really use quote do for this, you'll need to build the AST manually with newtree and whatnot |
11:48:11 | FromDiscord | <Mrcool> I can set a var outside the quote for extarcting https://media.discordapp.net/attachments/371759389889003532/1023199160121434172/unknown.png |
11:48:26 | FromDiscord | <Mrcool> but now obviously a new error https://media.discordapp.net/attachments/371759389889003532/1023199226248831007/unknown.png |
11:48:32 | FromDiscord | <auxym> yeah if its always 2 args that should work |
11:49:15 | FromDiscord | <auxym> yeah macros are fun to debug |
11:50:01 | FromDiscord | <auxym> use treeRepr on your proc node in your macro, and compare it to a `dumpTree` call with the result you're expecting |
11:50:46 | FromDiscord | <Mrcool> I'm gettign close https://media.discordapp.net/attachments/371759389889003532/1023199812990017627/unknown.png |
11:51:01 | FromDiscord | <Mrcool> this fails with https://media.discordapp.net/attachments/371759389889003532/1023199874730168370/unknown.png |
11:51:09 | FromDiscord | <Mrcool> which means I need to build the ast at a granual level |
11:51:14 | FromDiscord | <Mrcool> (edit) "granual" => "granular" |
11:51:18 | FromDiscord | <Bung> hi, am debugging into this https://github.com/nim-lang/Nim/issues/10833 , now I get `Error: type mismatch: got <Foo[t10833.Bar, t10833.Baz, system.int]> but expected 'Foo[t10833.Bar, t10833.Baz, 1]'` , my question is does literal can be a type constrain ? or I may turn the expected into `int` ? |
11:51:20 | FromDiscord | <auxym> ident"a: int" wont work, that not an ident, it a colon expression with two ident children |
11:53:12 | FromDiscord | <Bung> well, when I change the return type to `auto` it compiles , so should I follow this behavior make it to `int` ? |
11:53:20 | FromDiscord | <auxym> In reply to @Bung "hi, am debugging into": yeah I've use `static[int]` in the past as a generic param, not sure why it doesnt work there |
11:54:30 | FromDiscord | <Bung> generic has serveral bugs , static[T] also |
11:55:35 | FromDiscord | <auxym> yeah, some weird error messages that are hard to understand sometimes, too |
11:56:35 | FromDiscord | <Bung> that's these days I focus on, I now have 11 opened PRs. |
11:58:06 | FromDiscord | <Bung> generic are useful, but when u heavily use it, more issue comes up. |
12:00:24 | FromDiscord | <Bung> okay, back to my problem, I think I'd follow `auto` behavior, since I never seen a literal as type constrain. |
12:07:41 | NimEventer | New thread by BarrOff25: To `ref` or not to `ref` on embedded?, see https://forum.nim-lang.org/t/9491 |
12:09:04 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
12:27:06 | FromDiscord | <Phil> Looking at the thread I'm mildly confused, why would ref or not ref matter or be somehow special on embedded? Wouldn't it mostly matter on how large your L1 cache is to see if your data fits in it? |
12:28:55 | FromDiscord | <flywind> With arc, ref is heap allocated reference counting object. It comes with overhead like incRef, decRef. |
12:29:04 | FromDiscord | <Rika> Embedded doesn’t have a lot of memory |
12:29:22 | FromDiscord | <Rika> Heavy reference usage can lead to fragmentation |
12:29:46 | FromDiscord | <Rika> And thus pockets of memory that could possibly not fit objects they try to allocate |
12:29:56 | FromDiscord | <Rika> There’s a lot of other reasons of course, this is just one |
12:31:39 | FromDiscord | <Rika> Some MCUs have no cache (Arduino Atmel 8 bit ones I believe) |
12:31:43 | FromDiscord | <Phil> So you got small stack memory that might be too small in general and not a lot of heap either that risks fragmentation, huh |
12:32:23 | FromDiscord | <Rika> Those that do have cache I believe are instruction only most of the time? Don’t quote me on this one I have no good idea on this |
12:33:05 | FromDiscord | <Rika> (Yeah, recall that there’s both instruction and data cache) |
12:33:55 | FromDiscord | <Rika> Not sure what other arguments are now |
12:34:43 | FromDiscord | <PyryTheBurger> What are templatea used fot? |
12:35:07 | FromDiscord | <Rika> A language-level copy paste of code almost? |
12:35:39 | FromDiscord | <Rika> It’s like a function that can return code, almost |
12:35:49 | FromDiscord | <Rika> Something like that I think works as a description |
12:44:03 | FromDiscord | <Mrcool> so now this works, now I need to make it work for the whole arguments instead of just the first one https://media.discordapp.net/attachments/371759389889003532/1023213217843003402/unknown.png |
12:45:46 | FromDiscord | <Mrcool> https://media.discordapp.net/attachments/371759389889003532/1023213650196054067/unknown.png |
12:48:14 | FromDiscord | <Phil> In reply to @PyryTheBurger "What are templatea used": I like to use it for stuff to set up a context that does something when a scope starts and/or when it ends |
12:49:41 | * | oprypin quit (Quit: Bye) |
12:49:43 | FromDiscord | <Phil> E.g. "withDb(con)" to grab a dB connection when the scope starts and closes it (or returns it to a pool) when the scope ends |
12:50:00 | * | oprypin joined #nim |
13:18:26 | FromDiscord | <Mrcool> finally https://media.discordapp.net/attachments/371759389889003532/1023221874605436999/unknown.png |
13:26:04 | FromDiscord | <Mrcool> works in an actual not toy example nice https://media.discordapp.net/attachments/371759389889003532/1023223791645634742/unknown.png |
13:29:04 | * | kenran joined #nim |
13:31:55 | FromDiscord | <Mrcool> the magic trick is `&` + `parseStatement` +`quote` seems to be an unlimited combo |
13:32:35 | FromDiscord | <Mrcool> here is the code <https://gist.github.com/sigmaSd/92436e85eccd8adfd451c748e6ffc181> |
13:41:09 | FromDiscord | <Mrcool> To handle nested object I probably need recursive macro, is that possible with nim? |
13:42:20 | FromDiscord | <Yardanico> the code generated by a macro can have calls to other macros if you mean that |
13:42:26 | FromDiscord | <Yardanico> or you can just walk the node tree recursively |
13:42:37 | FromDiscord | <Mrcool> I mean a macro that call itself |
13:42:54 | FromDiscord | <Yardanico> if you mean directly, no, you'd need some compile-time proc that would actually do the work and call itself |
13:43:09 | FromDiscord | <Yardanico> you can make procs that operate on NimNode arguments and return NimNode |
14:03:01 | FromDiscord | <Mrcool> is there a panic macro? or throw like js |
14:07:17 | FromDiscord | <Mrcool> first nim segfault achievement unlocked |
14:07:36 | FromDiscord | <Mrcool> (edit) "first nim ... segfault" added "compiler" |
14:09:28 | FromDiscord | <Rika> https://nim-lang.org/docs/macros.html#error%2Cstring%2CNimNode |
14:14:00 | FromDiscord | <Mrcool> I'm trying to workaround recursing in macros, I tried https://media.discordapp.net/attachments/371759389889003532/1023235856619810917/unknown.png |
14:14:11 | FromDiscord | <Mrcool> but it fails with https://media.discordapp.net/attachments/371759389889003532/1023235903465996329/unknown.png |
14:14:18 | FromDiscord | <Mrcool> any hope for importc to work at compile time? |
14:15:37 | FromDiscord | <hotdog> @Mrcool I was thinking about your functions with undefined args thing earlier, here's a quick solution that's fairly ergonomic - https://gist.github.com/geotre/227f7be1621b254c4266a54d3446b0f4 |
14:16:41 | FromDiscord | <Mrcool> looks very awesome ! |
14:16:41 | FromDiscord | <hotdog> In reply to @Mrcool "any hope for importc": If the js macro is just constructing an object use `asm` instead |
14:17:07 | FromDiscord | <hotdog> Though it's hard to tell how it all works only seeing snippets |
14:17:33 | FromDiscord | <Mrcool> do you think your code can be used in nim std? |
14:17:50 | FromDiscord | <hotdog> Generally if you need to call macros in other macros it's best to start splitting some bits out to compile time procs that operate on nimnodes |
14:18:29 | FromDiscord | <Mrcool> In reply to @hotdog "<@331914114001534978> I was thinking": can this be used here <https://github.com/nim-lang/Nim/blob/devel/lib/js/jsre.nim#L31> |
14:19:14 | FromDiscord | <Mrcool> In reply to @hotdog "Though it's hard to": <https://pastebin.com/q647yedg> |
14:20:02 | FromDiscord | <Mrcool> I posted earlier the workig code btw https://discord.com/channels/371759389889003530/371759389889003532/1023225436152537188 |
14:20:06 | FromDiscord | <Mrcool> (edit) "workig" => "working" |
14:20:07 | FromDiscord | <hotdog> In reply to @Mrcool "do you think your": I suppose, it's only two lines of code though and I'm not sure if it's use would confuse people. It also codegens some unnecessary function call indirection (if you leave out arguments when calling the wrapped js function, it calls a function just to generate the undefined var) |
14:21:24 | FromDiscord | <Mrcool> In reply to @hotdog "I suppose, it's only": the problem js std of nim is currently is eiter missing alot of optional arguments and at the sametime hardcoding alot of them as well, because no one wants to write 5 copies of each function |
14:21:31 | FromDiscord | <Mrcool> (edit) "is eiter" => "" |
14:21:35 | FromDiscord | <Mrcool> (edit) "alot" => "a lot" |
14:22:00 | FromDiscord | <hotdog> In reply to @Mrcool "the problem js std": Perhaps open an issue on the nim github to start a discussion |
14:26:12 | FromDiscord | <hotdog> In reply to @Mrcool "<https://pastebin.com/q647yedg>": Cool just had a look. If you want to support nested calls personally I would turn the code in the js macro into a `proc toJsObj(n: NimNode): NimNode` and have the js macro call into that. Then the toJsObj proc can call itself recursively when there's a nested table to deal with |
14:30:58 | FromDiscord | <Mrcool> sent a code paste, see https://play.nim-lang.org/#ix=4bii |
14:31:20 | FromDiscord | <Mrcool> (edit) "https://play.nim-lang.org/#ix=4bii" => "https://play.nim-lang.org/#ix=4bij" |
14:34:00 | * | sagax quit (Ping timeout: 264 seconds) |
14:34:43 | FromDiscord | <Yardanico> In reply to @Mrcool "how do you call": you don't call macros inside compile-time procs directly, if you want to emit code that does that then use `quote do` or similar things |
14:34:46 | FromDiscord | <Rika> id personally say "please dont" |
14:35:03 | FromDiscord | <Yardanico> and if you want to call it to process nimnodes, then make your macro a proc as well, and write another macro as the entry-point |
14:38:06 | FromDiscord | <Mrcool> Ok now I see that I can't use a proc as the entry point since its typed the table needs to have the same type, so ↵`{"a": 4,"a":"aze"}" wont work` |
14:38:20 | FromDiscord | <Mrcool> also the keys needs to be quoted but that's not the blocker |
14:38:30 | FromDiscord | <Mrcool> (edit) "4,"a":"aze"}"" => "4,"b":"aze"}"" |
14:39:14 | FromDiscord | <Yardanico> In reply to @Mrcool "Ok now I see": you can use a macro as an entry point, then pass the node directly to the proc and recurse it there |
14:39:25 | FromDiscord | <Yardanico> and then the initial proc call returns the node result to the macro |
14:39:42 | FromDiscord | <Mrcool> but the proc will fail still because of different types ? |
14:39:46 | FromDiscord | <Yardanico> why? |
14:40:03 | FromDiscord | <Yardanico> macros get NimNode, it's just named typed/untyped so you can get a typed or untyped AST |
14:40:16 | FromDiscord | <Mrcool> ah ok |
14:40:39 | FromDiscord | <Yardanico> something like that |
14:40:42 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4bil |
14:41:01 | * | rockcavera quit (Read error: Connection reset by peer) |
14:41:19 | * | rockcavera joined #nim |
14:41:20 | * | rockcavera quit (Changing host) |
14:41:20 | * | rockcavera joined #nim |
15:11:21 | FromDiscord | <Mrcool> it seems like recursing to the outside function from the macro ↵- calls the function↵- but stops at the macro invocation https://media.discordapp.net/attachments/371759389889003532/1023250280789311560/unknown.png https://media.discordapp.net/attachments/371759389889003532/1023250281166803074/unknown.png https://media.discordapp.net/attachments/371759389889003532/1023250281544294410/unknown.png |
15:12:17 | FromDiscord | <Mrcool> <https://pastebin.com/21G4TD49> |
15:12:39 | FromDiscord | <Mrcool> (the errors are not important, whats important is the echo on line 25) |
15:16:46 | FromDiscord | <Yardanico> i'm really, really not sure why are you doing three levels of depth |
15:16:52 | FromDiscord | <Yardanico> can you show your use-case? |
15:17:15 | FromDiscord | <Yardanico> okay, the code is there, lemme try |
15:17:36 | FromDiscord | <Mrcool> the macro does js({a: 4, b:"hello"}) this works↵but now the next step is to handle nested objects |
15:17:43 | FromDiscord | <Mrcool> like {a:4, {c:5}} |
15:18:03 | * | wallabra_ joined #nim |
15:18:46 | * | kenran quit (Quit: WeeChat info:version) |
15:18:54 | FromDiscord | <Mrcool> (edit) "works↵but" => "works -> it basicly transform it into inline importjs↵but" |
15:19:01 | FromDiscord | <Mrcool> (edit) "basicly" => "basically" |
15:20:07 | * | wallabra quit (Ping timeout: 246 seconds) |
15:20:18 | * | wallabra_ is now known as wallabra |
15:38:31 | * | sagax joined #nim |
15:40:06 | * | genpaku quit (Read error: Connection reset by peer) |
15:40:47 | * | genpaku joined #nim |
16:04:05 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4bj1 |
16:04:08 | FromDiscord | <Yardanico> and the idea of the proc that calls itself is what I wanted to tell you |
16:04:32 | FromDiscord | <Yardanico> `importc` in place of `importjs` won't work here because it generates a () at the end of the object expression |
16:05:19 | FromDiscord | <Yardanico> and also, doing too much string stuff during compile-time can lead to slower compile-times, you can just use typed Nim objects for JS proc arguments that require JS objects |
16:06:44 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4bj3 |
16:07:33 | FromDiscord | <Yardanico> if you still want to use the `js{}` like syntax, one idea I think is to generate those type definitions in the macro, and then instantiate the types with given values, so you don't have any string handling involved |
16:33:50 | FromDiscord | <Mrcool> @Yardanico thanks a lot! |
17:17:26 | FromDiscord | <Patitotective> can i make a nimble library have extra-content? similar to pypi's `pip install lib[extra]`↵so i can install it if i need it but i dont install it if i dont↵would a `when defined(extra): requires "extra_lib >= 0.1.0"` work? |
17:18:09 | FromDiscord | <Yardanico> In reply to @Patitotective "can i make a": when defined won't work, do you mean additional files and folders? |
17:18:24 | FromDiscord | <Yardanico> if so, yes, you can, but it'll be installed in the package directory as well |
17:18:37 | FromDiscord | <Patitotective> In reply to @Yardanico "when defined won't work,": yes |
17:19:25 | FromDiscord | <Yardanico> lemme find it |
17:19:29 | FromDiscord | <Patitotective> In reply to @Yardanico "if so, yes, you": you mean that `requires "extra_lib" >= 0.1.0` is there but in my library i only import `extra_lib` `when defined(extra)`? |
17:19:40 | FromDiscord | <Yardanico> no, I meant regarding the files |
17:19:46 | FromDiscord | <Yardanico> regarding packages - nimble doesn't have optional dependencies |
17:19:53 | FromDiscord | <Yardanico> you either depend on a package in the .nimble file or not |
17:20:08 | FromDiscord | <Patitotective> then the best would be to create another library :p |
17:20:28 | FromDiscord | <Yardanico> and for additional files |
17:20:30 | FromDiscord | <Yardanico> "Directories and files can also be specified on a whitelist basis, if you specify either of installDirs, installFiles or installExt then Nimble will only install the files specified." |
17:20:36 | FromDiscord | <Yardanico> https://github.com/nim-lang/nimble |
17:20:54 | FromDiscord | <Yardanico> it's because "All files and folders in the directory where the .nimble file resides will be copied as-is, you can however skip some directories or files by setting the skipDirs, skipFiles or skipExt options in your .nimble file." |
17:40:32 | FromDiscord | <richard_matrix> Click and thank me later ↵👇👇👇👇👇👇↵http://t.me/Stevecoldham001 |
17:43:52 | FromDiscord | <PyryTheBurger> Honestly nim would be the perfect language if it allowed procs to have the same name as types |
17:44:04 | FromDiscord | <PyryTheBurger> Its such a small thing but so anoying |
17:46:39 | FromDiscord | <Patitotective> In reply to @richard_matrix "Click and thank me": <@&371760044473319454> |
17:47:08 | FromDiscord | <Patitotective> In reply to @PyryTheBurger "Honestly nim would be": then how does it know when you want the type or the procedure? |
17:48:02 | FromDiscord | <Patitotective> (edit) "does" => "would" |
17:48:04 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=4bjy |
17:49:07 | FromDiscord | <PyryTheBurger> If you put parenthesis it means proc else the type |
17:49:30 | FromDiscord | <Yardanico> In reply to @PyryTheBurger "Honestly nim would be": camelcase exists for this reason :) |
17:49:38 | FromDiscord | <Yardanico> first character is case sensitive |
17:49:50 | FromDiscord | <Patitotective> In reply to @PyryTheBurger "If you put parenthesis": if you put parenthesis you're calling it, what if you want to pass the procedure as an argument? |
17:50:24 | FromDiscord | <PyryTheBurger> Yeah thats the only problem |
17:51:06 | FromDiscord | <Patitotective> why would you want to name procedures and types the same? sounds like a bad practice |
17:53:15 | FromDiscord | <PyryTheBurger> Like a constructor |
17:53:56 | FromDiscord | <PyryTheBurger> I dont want to have inconsistensies like if i dont want to do newType for every type but then there will be inconsistencies |
17:54:48 | FromDiscord | <Patitotective> https://github.com/beef331/constructor |
17:56:34 | FromDiscord | <Patitotective> also https://github.com/demotomohiro/objectDef |
17:59:35 | FromDiscord | <Patitotective> related https://github.com/nim-lang/RFCs/issues/126 |
18:00:01 | FromDiscord | <PyryTheBurger> What does the square brackets do in here: typedesc[User] |
18:00:43 | FromDiscord | <Patitotective> https://nim-lang.org/docs/manual.html#special-types-typedesc-t |
18:01:28 | FromDiscord | <PyryTheBurger> In reply to @Patitotective "related https://github.com/nim-lang/RFCs/issues/126": This is exactly what needs to be implemented |
18:02:50 | FromDiscord | <Patitotective> In reply to @Patitotective "https://github.com/beef331/constructor": it can already be implemented with macros though |
18:04:25 | FromDiscord | <PyryTheBurger> How |
18:05:26 | FromDiscord | <Patitotective> read https://github.com/beef331/constructor#defaults |
18:06:51 | * | wallabra_ joined #nim |
18:07:46 | * | wallabra quit (Ping timeout: 246 seconds) |
18:09:08 | * | wallabra_ is now known as wallabra |
18:23:32 | FromDiscord | <PyryTheBurger> Im just saying, it would be way better if it was actually implemented in to the language |
18:23:56 | FromDiscord | <PyryTheBurger> Dont even need the constructors, just the default values |
18:38:31 | FromDiscord | <Forest [She/Her]> I'm thinking of writing a basic Lua implementation, but i wanna know the pros and cons of doing that first |
18:38:57 | FromDiscord | <Forest [She/Her]> What are the reasons to write one, compared to just making user friendly bindings to the existing and official Lua implementation? |
18:39:47 | FromDiscord | <Forest [She/Her]> Compelling reasons for writing one could be better Nim integration maybe, but Nim compiles to C which means that's irrelevant anyway, it'll still work with the official Lua bindings with minimal glue |
18:40:04 | FromDiscord | <sOkam!> In reply to @PyryTheBurger "Im just saying, it": I believe the philosophy about constructing new values in Nim is to just create your own custom function that does it, just like pure C does |
18:40:54 | FromDiscord | <sOkam!> If you come from a constructor-based language, not having them its gonna feel weird. But not having that abstracted away is actually a good thing |
18:41:45 | FromDiscord | <Forest [She/Her]> In reply to @sOkam! "If you come from": Can vouch for that lmao, i came from Python |
18:41:59 | FromDiscord | <Forest [She/Her]> Nim is epic tho, it feels clean and it's typically readable a lot of the time |
18:42:14 | FromDiscord | <sOkam!> Its like the good of python, but with all the great of pure C |
18:42:41 | FromDiscord | <Forest [She/Her]> People compare it to Pascal iirc |
18:42:44 | FromDiscord | <Forest [She/Her]> Cleaner pascal |
18:43:11 | FromDiscord | <sOkam!> NeverTriedPascal, other than the case 🙂 |
18:43:18 | FromDiscord | <Forest [She/Her]> Same lmao |
18:44:54 | FromDiscord | <Patitotective> is there a nim library that parser an ISO8601 date/time format? |
18:45:00 | FromDiscord | <Patitotective> nvm found it https://github.com/juancarlospaco/nim-datetime2human |
18:48:17 | FromDiscord | <Patitotective> or maybe https://github.com/treeform/chrono 🤔 |
18:49:51 | FromDiscord | <Patitotective> In reply to @Patitotective "or maybe https://github.com/treeform/chrono 🤔": `parseIsoTs` :] |
18:51:02 | FromDiscord | <Forest [She/Her]> Working on a Lua implemention in Nim now haha |
18:53:13 | FromDiscord | <PyryTheBurger> Nim has everything i need, except the constructors. Every constructor based language lacks what i need. I would also use lua, but i want compiled language |
18:53:55 | FromDiscord | <Forest [She/Her]> In reply to @PyryTheBurger "Nim has everything i": Why not just create an init proc? |
19:02:51 | FromDiscord | <Forest [She/Her]> Does anyone have any idea of how lexbase works? |
19:04:00 | FromDiscord | <Generic> you inherit from BaseLexer |
19:04:14 | FromDiscord | <Forest [She/Her]> Yeah, but then what? How do i handle getting more values from the buffer? |
19:04:43 | FromDiscord | <Forest [She/Her]> I'm trying to find a project that uses std/lexbase but I can't find one |
19:04:49 | FromDiscord | <Generic> I'm currently trying to figure that out again |
19:04:59 | FromDiscord | <Generic> I used it for my gc dsp assembler |
19:05:05 | FromDiscord | <Forest [She/Her]> Ah fair haha |
19:05:10 | FromDiscord | <Generic> https://github.com/RSDuck/hocuspocube/blob/master/hocuspocube/dsp/asm/dspasm.nim |
19:05:35 | FromDiscord | <Generic> https://github.com/RSDuck/hocuspocube/blob/master/hocuspocube/dsp/asm/dspasm.nim#L274 |
19:05:38 | FromDiscord | <Generic> I think this is it |
19:05:42 | FromDiscord | <Forest [She/Her]> Hm |
19:05:46 | FromDiscord | <Generic> you call skip |
19:06:09 | FromDiscord | <Generic> then you read from the current position via buf |
19:06:14 | FromDiscord | <Generic> and increase bufpos |
19:06:45 | FromDiscord | <Generic> when newline occurs you need to pass that to the lexer so that it can refill the buffer |
19:06:49 | FromDiscord | <Generic> https://github.com/RSDuck/hocuspocube/blob/master/hocuspocube/dsp/asm/dspasm.nim#L334 |
19:07:19 | FromDiscord | <Forest [She/Her]> Hm I don't understand that tbh... Maybe I'd be better off writing my own basic lexer that i understand fully |
19:07:33 | FromDiscord | <Generic> ah no |
19:07:40 | FromDiscord | <Generic> I implemented skip myself |
19:07:55 | FromDiscord | <Generic> you really just need to call the appropriate methods for newlines |
19:08:28 | FromDiscord | <Forest [She/Her]> Hm fair |
19:09:07 | FromDiscord | <Generic> it is really underdocumented |
19:09:31 | FromDiscord | <Forest [She/Her]> Yeah, makes it a bit tricky to use |
19:09:53 | FromDiscord | <Generic> I think I figured it out by reading the source of the simplest stdlib parser |
19:09:59 | FromDiscord | <Generic> I'm trying to recall which one it was |
19:10:07 | FromDiscord | <Forest [She/Her]> Hm yeah okay, i think I'd be better off making my own simple one |
19:10:20 | FromDiscord | <Forest [She/Her]> I understand it, but it just looks a bit clunky |
19:10:30 | FromDiscord | <Generic> probably parsecfg or parsecsv |
19:10:33 | FromDiscord | <Forest [She/Her]> (I say, as if my go at a lexer would be any better heh) |
19:10:56 | FromDiscord | <Generic> well once you got it working, it's quite useful |
19:11:08 | FromDiscord | <Generic> because it handles line number/column information for you |
19:11:13 | FromDiscord | <Generic> it also always overfills the buffer a bit |
19:11:46 | FromDiscord | <Generic> so you don't need to fill your code with buffer length checks to the brim |
19:14:07 | FromDiscord | <Forest [She/Her]> Hm fair |
19:14:20 | FromDiscord | <Forest [She/Her]> Hm... I'll look into getting it working |
19:14:32 | FromDiscord | <Forest [She/Her]> Where do you get `Parser` from btw? |
19:14:35 | FromDiscord | <Forest [She/Her]> Your own thing? |
19:14:54 | FromDiscord | <Generic> it's my own object inheriting from BaseLexer |
19:14:58 | FromDiscord | <Forest [She/Her]> Aaah okay |
19:15:18 | FromDiscord | <Forest [She/Her]> Why parser then? Aren't parsers typically for handling the tokens made by a lexer? |
19:16:02 | FromDiscord | <Generic> yes, I kind of threw that all together into one object |
19:16:17 | FromDiscord | <Forest [She/Her]> Aah fair |
19:16:20 | FromDiscord | <Generic> e.g. https://github.com/RSDuck/hocuspocube/blob/master/hocuspocube/dsp/asm/dspasm.nim#L417 |
19:16:45 | FromDiscord | <Generic> this is kind of how it constructs an AST |
19:17:53 | FromDiscord | <Forest [She/Her]> Ah alright |
19:18:04 | FromDiscord | <Forest [She/Her]> I'm planning on mostly splitting the logic for the AST and lexer tbh |
19:18:10 | FromDiscord | <Forest [She/Her]> Parser and lexer |
19:18:42 | FromDiscord | <Forest [She/Her]> Since then I can always drop in a different lexer if i desired (which idk why I'd need to, but the option being there would be nice) |
19:22:33 | FromDiscord | <Generic> I guess |
19:23:48 | FromDiscord | <Generic> I'm always the kind of person who thinks that abstracting and generalising every part has it's own cost |
19:24:13 | FromDiscord | <Forest [She/Her]> Yeah it does, but then if you wanna swap something out and it's all tightly integrated, then it's just harder |
19:24:56 | FromDiscord | <Forest [She/Her]> I don't say "abstract everything!" but things that can be used on their own in a way that doesn't take away from the functionality in a major way, i say that's fine to separate from the main code |
19:26:28 | FromDiscord | <Generic> well functionality is only aspect |
19:26:49 | FromDiscord | <Generic> indirect function calls are another |
19:27:33 | FromDiscord | <Forest [She/Her]> Indirect function calls? Wdym? |
19:28:48 | FromDiscord | <Generic> function calls made from function pointers |
19:30:37 | FromDiscord | <Generic> it's what virtual function calls are implemented over (most of the time, Nim methods aren't which is it's own story) |
19:30:38 | FromDiscord | <Forest [She/Her]> Ah |
19:30:54 | FromDiscord | <Generic> they're not the slowest thing in the world |
19:31:04 | FromDiscord | <Generic> but you shouldn't put them in hot loops |
19:31:16 | FromDiscord | <Generic> (looking at you average Java program) |
19:33:24 | FromDiscord | <Forest [She/Her]> In reply to @Generic "they're not the slowest": Ah okay then |
19:33:45 | FromDiscord | <Forest [She/Her]> In reply to @Generic "(looking at you average": Virtual methods in java are just any non private and non protected method afaik |
19:33:53 | FromDiscord | <Forest [She/Her]> From the short time of messing with Jasmin lmao |
19:34:04 | FromDiscord | <Forest [She/Her]> Hm i need a name for a Nim implementation of Lua |
19:34:42 | FromDiscord | <Generic> nimlua |
19:34:45 | FromDiscord | <Generic> luanim |
19:34:57 | FromDiscord | <Generic> minaul |
19:35:01 | FromDiscord | <Forest [She/Her]> That's just slapping the name on, uncreative lmao |
19:35:10 | FromDiscord | <Forest [She/Her]> NiLua can be used for now ig |
19:35:18 | FromDiscord | <Patitotective> nua |
19:35:24 | FromDiscord | <Generic> nothing is more permanent than something temporary |
19:35:28 | FromDiscord | <Patitotective> lim |
19:35:29 | FromDiscord | <Patitotective> limua |
19:35:36 | FromDiscord | <Forest [She/Her]> Lunar |
19:35:37 | * | jjido joined #nim |
19:35:39 | FromDiscord | <Patitotective> In reply to @Generic "nothing is more permanent": true |
19:35:57 | FromDiscord | <Forest [She/Her]> Lua apparently means Moon, so Lunar maybe? |
19:36:02 | FromDiscord | <Forest [She/Her]> In reply to @Generic "nothing is more permanent": True lmao |
19:36:38 | FromDiscord | <Forest [She/Her]> stellar maybe? |
19:36:54 | FromDiscord | <Patitotective> name is the less important thing |
19:37:03 | FromDiscord | <Forest [She/Her]> Hm yeah I'll go with `Stellar` |
19:37:05 | FromDiscord | <Patitotective> better start working on it :p |
19:37:11 | FromDiscord | <Forest [She/Her]> True aha |
19:37:47 | FromDiscord | <Patitotective> In reply to @Patitotective "`parseIsoTs` :]": i think id do better copying that proc to make it work with std/times↵less dependencies :p |
19:38:02 | FromDiscord | <Patitotective> (edit) "to" => "and" |
19:38:02 | FromDiscord | <Forest [She/Her]> Pff fair |
19:39:14 | FromDiscord | <wiga> am i the only one who found out that the strings contained in nim binaries are all reversed? |
19:39:36 | FromDiscord | <Generic> huh |
19:40:49 | FromDiscord | <wiga> https://media.discordapp.net/attachments/371759389889003532/1023318106485051422/unknown.png |
19:40:57 | FromDiscord | <wiga> https://media.discordapp.net/attachments/371759389889003532/1023318139624239125/unknown.png |
19:42:30 | FromDiscord | <Forest [She/Her]> Oh what? |
19:42:41 | FromDiscord | <Forest [She/Her]> Maybe it's to do with how Nim strings are handled? |
19:43:18 | FromDiscord | <wiga> all tge puVar1 are reversed strings being concat https://media.discordapp.net/attachments/371759389889003532/1023318732317134879/unknown.png |
19:43:48 | FromDiscord | <wiga> dunno why on ghidra i cant convert in char array directly |
19:45:16 | FromDiscord | <Patitotective> In reply to @Patitotective "i think id do": actually `times.parse` is good enough |
19:47:05 | FromDiscord | <wiga> In reply to @wiga "all tge puVar1 are": https://media.discordapp.net/attachments/371759389889003532/1023319681827881144/2022-09-24_15-46-25.mov |
19:50:09 | FromDiscord | <d4rckh> If I make a library in C I could use it in Nim right? |
19:50:16 | FromDiscord | <wiga> yeah |
19:50:52 | FromDiscord | <wiga> idk C/C++ but there's a parameter in the compiler to make a dynamic lib |
19:51:00 | FromDiscord | <Yardanico> In reply to @wiga "am i the only": that can't be true, maybe your decompiler is kind of wrong |
19:51:20 | FromDiscord | <Yardanico> well, maybe it's your C compiler that's acting strange, but you can check the Nim-compiled C code |
19:51:24 | FromDiscord | <Yardanico> and the strings there are not reversed |
19:51:25 | FromDiscord | <wiga> its not a decompiler first |
19:51:36 | * | kenran joined #nim |
19:51:50 | FromDiscord | <wiga> it reassembles assembly into C |
19:51:59 | FromDiscord | <Yardanico> i know what it is, it's still called a "decompiler" usually |
19:52:05 | FromDiscord | <Yardanico> like a hex-rays decompiler |
19:52:31 | * | jjido quit (Ping timeout: 260 seconds) |
19:52:34 | FromDiscord | <wiga> ain't hex-rays the name of the guy who made IDA |
19:52:42 | FromDiscord | <Yardanico> it's the name of the company, https://hex-rays.com/decompiler/ |
19:52:45 | FromDiscord | <Yardanico> but that's more for #offtopic |
19:52:50 | FromDiscord | <wiga> yeah |
19:54:20 | FromDiscord | <wiga> well if i search strings in ghidra it reverse them |
19:54:23 | FromDiscord | <wiga> back to normal |
19:54:39 | FromDiscord | <wiga> https://media.discordapp.net/attachments/371759389889003532/1023321586696192153/unknown.png |
19:54:43 | FromDiscord | <Yardanico> are you sure it's not just due to how C compilers generally compile code? |
19:54:46 | FromDiscord | <Yardanico> and the architecture/etc |
19:55:00 | FromDiscord | <Yardanico> try compiling a simple C program with the same C compiler and check the result |
19:55:01 | FromDiscord | <wiga> how C compiler has something to do with that? |
19:55:14 | FromDiscord | <Yardanico> In reply to @wiga "how C compiler has": Nim compiles to C which is then compiled by the C compiler to binary |
19:55:25 | FromDiscord | <wiga> yes |
19:55:26 | FromDiscord | <Yardanico> Nim doesn't really "reverse" string layout in binaries, it doesn't output binaries directly |
19:55:49 | FromDiscord | <Yardanico> as I said, if you check the intermediate C code, it'll be with normal strings |
19:55:50 | FromDiscord | <wiga> idk i just opened my tool executable on ghidra |
19:57:50 | FromDiscord | <wiga> ik i imported strformat lib |
19:58:02 | FromDiscord | <wiga> and used it on this specific string |
19:58:08 | FromDiscord | <wiga> that is reversed |
19:58:14 | FromDiscord | <wiga> so maybe its included in the lib |
19:58:16 | FromDiscord | <wiga> dunno |
20:20:13 | * | tiorock joined #nim |
20:20:14 | * | tiorock quit (Changing host) |
20:20:14 | * | tiorock joined #nim |
20:20:14 | * | rockcavera is now known as Guest9833 |
20:20:14 | * | tiorock is now known as rockcavera |
20:21:59 | * | Guest9833 quit (Ping timeout: 244 seconds) |
20:24:31 | FromDiscord | <Patitotective> In reply to @Patitotective "actually `times.parse` is good": actually no, neither `times.parse` nor `std/strscans` do support optional terminals so i guess its time for regex :p |
20:35:13 | FromDiscord | <jos> is there anything like an associated type in nim? |
20:35:28 | FromDiscord | <jos> i'm rewriting my parser as a pratt parser, and i want each Parselet to have an output type that's statically known |
20:36:04 | FromDiscord | <jos> so for example like AddOperatorParselet would fulfill a concept called OperatorParselet |
20:36:54 | FromDiscord | <jos> sent a code paste, see https://play.nim-lang.org/#ix=4bkj |
20:36:54 | FromDiscord | <jos> Self::Output is the part i'm not sure how to express |
20:37:09 | FromDiscord | <jos> coming from rust looking for something similar |
20:37:49 | * | jmdaemon joined #nim |
20:37:50 | FromDiscord | <jos> the type that `Self::Output` describes wouldn't be known until `AddOperatorParselet` is implemented |
20:40:00 | FromDiscord | <jos> actually do typeclasses even work with dynamic dispatch, like can i create an operator table `seq[OperatorParselet]` or do they only work as generic bounds |
20:53:17 | * | kenran quit (Quit: WeeChat info:version) |
21:23:47 | FromDiscord | <jos> also is it just me or has the nim playground been inaccessible for a while |
21:25:42 | FromDiscord | <Patitotective> @PMunch ever gonna fix the playground? |
21:42:59 | FromDiscord | <Forest [She/Her]> Question: Would it be better for the parser to call the lexer on imported files, or the interpreter to call the lexer and then call the parser? |
21:45:40 | FromDiscord | <Patitotective> readFile -> lexer -> parser -> interpreter↵iiuc |
21:46:00 | FromDiscord | <Forest [She/Her]> Yeah but what stage should i handle imported files? |
21:46:16 | FromDiscord | <Forest [She/Her]> Parsing or interpreting? |
21:46:35 | FromDiscord | <Patitotective> interpreting↵parsing will just make sure the import statement is ok, i think |
21:46:46 | FromDiscord | <Forest [She/Her]> Alright then |
21:47:05 | FromDiscord | <Patitotective> https://craftinginterpreters.com/contents.html 💀 |
21:47:08 | FromDiscord | <Patitotective> (edit) "💀" => "👀" |
21:48:22 | FromDiscord | <Forest [She/Her]> I'm reading https://www.toptal.com/scala/writing-an-interpreter because i find other tutorials really hard to follow haha |
22:03:58 | FromDiscord | <Forest [She/Her]> Does Nom allow trailing commas for enums? |
22:04:34 | FromDiscord | <Patitotective> yes |
22:04:55 | FromDiscord | <Forest [She/Her]> Sweet |
22:15:26 | FromDiscord | <Forest [She/Her]> How would i reliably quote a string? So `hello world, i am "Forest"!` so when printing, it becomes `"hello world, i am \"Forest\"!"` |
22:15:33 | FromDiscord | <jos> what do you mean by "handling" imported files? |
22:15:46 | FromDiscord | <Forest [She/Her]> I can see `quoteShell` but that uses `'` |
22:15:48 | FromDiscord | <jos> are you making an interpreted language, compiled, etc.. |
22:16:03 | FromDiscord | <Forest [She/Her]> In reply to @jos "are you making an": I'm making an interpreted language yeah |
22:16:03 | FromDiscord | <jos> there's a lot of ways to "handle" imported files, you could just copy paste them like the C compiler |
22:16:09 | FromDiscord | <Patitotective> In reply to @Event Horizon "How would i reliably": `addQuoted` |
22:16:17 | FromDiscord | <jos> yeah if it's interpreted, you could have some kind of module system during runtime |
22:16:24 | FromDiscord | <jos> but only if your language is dynamic, i guess |
22:16:34 | FromDiscord | <jos> if your language has good static checks, you'd probably want to do it during the semantic analysis phase |
22:16:42 | FromDiscord | <Patitotective> this is what i do `proc quoted(x: string): string = result.addQuoted(x)` (ignore the allocations 💀 ) |
22:16:49 | FromDiscord | <Elegantbeef> Or you just newline and dont use any commas! 😄↵(@Forest [She/Her]) |
22:16:58 | FromDiscord | <Forest [She/Her]> In reply to @Patitotective "this is what i": Ah thank you ^^ |
22:17:08 | FromDiscord | <Forest [She/Her]> In reply to @Elegantbeef "Or you just newline": Oh that's allowed? That's nicer |
22:17:26 | FromDiscord | <Forest [She/Her]> In reply to @jos "if your language has": I'm just making a basic Lua implementation so don't think i could do that haha |
22:17:42 | FromDiscord | <jos> lua prolly has its own standards for stuff like this then |
22:18:02 | FromDiscord | <jos> sent a code paste, see https://play.nim-lang.org/#ix=4bkG |
22:18:08 | FromDiscord | <Elegantbeef> you just do `123` |
22:18:08 | FromDiscord | <jos> i know that the last expression in a block is implicitly "returned" |
22:18:12 | FromDiscord | <jos> yeah but my issue is that |
22:18:16 | FromDiscord | <Elegantbeef> There is no block return |
22:18:24 | FromDiscord | <Forest [She/Her]> In reply to @jos "yeah if it's interpreted,": For now I'd probably have a global environment and work on separating it out later when i get something minimal working (all my attempts to do that before didn't work haha) |
22:18:30 | FromDiscord | <jos> well i'm covering all the paths of control flow, but the compiler isn't clever enough to realize i'm doing it |
22:18:49 | FromDiscord | <jos> i mean it might not even be statically decidable, depending on how variants are implemented in patty |
22:18:54 | FromDiscord | <Elegantbeef> Code?↵(@jos) |
22:19:05 | FromDiscord | <Patitotective> In reply to @jos "well i'm covering all": you're probably not convering all |
22:19:07 | FromDiscord | <Patitotective> (edit) "convering" => "covering" |
22:19:28 | FromDiscord | <jos> something like this |
22:19:33 | FromDiscord | <jos> sent a code paste, see https://play.nim-lang.org/#ix=4bkH |
22:20:12 | FromDiscord | <jos> the return here is meant to return the value in the function that calls the template |
22:20:30 | FromDiscord | <Patitotective> templates nor blocks have return |
22:20:30 | FromDiscord | <jos> the only branch that should be evaluated and actually yield a value from the block is the `if token is tokenKind: token` one |
22:20:38 | FromDiscord | <jos> yes, but functions do, and the template is meant to be invoked from a function |
22:20:48 | FromDiscord | <Elegantbeef> compile with `--expandMacro:expectToken` |
22:21:14 | FromDiscord | <Elegantbeef> also the block is pointles |
22:21:26 | FromDiscord | <jos> it might be |
22:21:29 | FromDiscord | <jos> wasn't sure about that |
22:21:39 | FromDiscord | <jos> i can't expand the macro because the error looks like it's before that |
22:21:45 | FromDiscord | <Elegantbeef> You dont break and dont inject any symbols |
22:21:57 | FromDiscord | <Elegantbeef> I guess expand match |
22:22:04 | FromDiscord | <jos> i wasn't sure if templates would generate their own block |
22:22:07 | FromDiscord | <Elegantbeef> see what the generated code looks like |
22:22:08 | FromDiscord | <jos> do they? |
22:22:14 | FromDiscord | <Elegantbeef> They dont but they turn into statement lists |
22:22:25 | FromDiscord | <jos> because i mostly don't want to leak vars created inside the template |
22:22:31 | FromDiscord | <jos> so if the template doesn't do that then it's fine |
22:22:33 | FromDiscord | <jos> don't need a block |
22:22:39 | FromDiscord | <Elegantbeef> And cause it's not marked dirty it doesnt inject any symbols |
22:23:01 | FromDiscord | <Elegantbeef> Templates are hygenic only if they're annotated `{.dirty.}` or you mark a symbol `{.inject.}` do they emit those symbols as is |
22:23:42 | FromDiscord | <jos> ok i think it works actually |
22:23:51 | FromDiscord | <jos> i just made a syntax error 🙂 |
22:23:56 | FromDiscord | <Elegantbeef> Ah |
22:24:08 | FromDiscord | <jos> so if i mark a symbol {.inject.} |
22:24:15 | FromDiscord | <jos> ah i'll just read the docs now that i know what it's called |
22:24:15 | FromDiscord | <jos> thx |
22:27:17 | FromDiscord | <dlesnoff> sent a code paste, see https://play.nim-lang.org/#ix=4bkJ |
22:27:57 | FromDiscord | <dlesnoff> (edit) "https://play.nim-lang.org/#ix=4bkJ" => "https://play.nim-lang.org/#ix=4bkK" |
22:28:57 | FromDiscord | <Elegantbeef> I've never used musl but that seems quite odd for a different libc to cause that |
22:30:24 | FromDiscord | <jos> it only prompts me once on macos |
22:30:51 | FromDiscord | <Elegantbeef> Yea but you're using clang 😄 |
22:33:23 | FromDiscord | <dlesnoff> sent a long message, see http://ix.io/4bkN |
22:33:44 | FromDiscord | <Elegantbeef> what's your Nim command? |
22:33:53 | FromDiscord | <Elegantbeef> I assume you are only using musl though so that doesnt make my life easier 😄 |
22:35:55 | FromDiscord | <jos> so one thing that's weird is that the fmt macro can't see locals declared in my template |
22:36:07 | FromDiscord | <jos> any idea why this might happen |
22:36:07 | FromDiscord | <jos> sent a code paste, see https://play.nim-lang.org/#ix=4bkO |
22:36:17 | FromDiscord | <jos> doesn't work with locals or args or anything rly |
22:36:19 | FromDiscord | <Elegantbeef> Yes it's a known limitation due to them being hygenic |
22:36:28 | FromDiscord | <jos> is there a workaround |
22:36:49 | FromDiscord | <Elegantbeef> inject symbols you want to print, or use the `%` operator |
22:37:02 | FromDiscord | <jos> ty |
22:37:37 | FromDiscord | <Elegantbeef> @dlesnoff\: compiling with musl as my C compiler does not make it expect input twice |
22:37:54 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/1023362669786431498/image.png |
22:45:30 | FromDiscord | <dlesnoff> In reply to @Elegantbeef "what's your Nim command?": nim c -r testMusl.nim |
22:48:28 | FromDiscord | <Elegantbeef> Might be a thing with a full musl setup |
22:49:27 | FromDiscord | <jos> maybe im still misunderstanding something about this, but now i get: |
22:49:38 | FromDiscord | <jos> sent a code paste, see https://play.nim-lang.org/#ix=4bkR |
22:49:38 | FromDiscord | <jos> where ideally it out print int for both |
22:50:01 | FromDiscord | <dlesnoff> sent a code paste, see https://play.nim-lang.org/#ix=4bkS |
22:50:31 | FromDiscord | <Elegantbeef> You've made an alias it prints the name of the type jos |
22:50:35 | FromDiscord | <dlesnoff> Well I'll wait to have my home computer at disposal to do my Nim's programming tests then. |
22:50:37 | FromDiscord | <Elegantbeef> templates + strformat are annoying due to them being hygenic |
22:51:21 | FromDiscord | <jos> makes sense |
22:51:24 | FromDiscord | <Elegantbeef> Cause the template emits code, then the macro is evaluated, and when that macro is evaluated `x` doesnt exist there |
22:51:57 | FromDiscord | <Elegantbeef> so you either inject variables or use `strutils.%` and call it a day |
22:52:01 | FromDiscord | <jos> can i get the name of the original type in a const expression and print that or something |
22:52:07 | FromDiscord | <jos> well im trying to inject |
22:52:14 | FromDiscord | <Elegantbeef> You cannot inject type names |
22:52:16 | FromDiscord | <jos> but i can't bind a type to a variable afaik |
22:52:21 | FromDiscord | <jos> ye |
22:52:31 | FromDiscord | <jos> maybe via rtti |
22:52:38 | FromDiscord | <Elegantbeef> you'd have to do like `const typeName {.inject.} = $tokenId` |
22:52:44 | FromDiscord | <Elegantbeef> No you dont need RTTI |
22:54:14 | FromDiscord | <jos> nice that worked |
22:54:17 | FromDiscord | <jos> ty |
23:27:30 | FromDiscord | <Patitotective> time for another parser https://github.com/kdl-org/kdl/blob/main/QUERY-SPEC.md :p |