<< 24-09-2022 >>

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