<< 24-11-2022 >>

00:03:04FromDiscord<nixfreak> I would I like write "a" \ 10 like in pytho
00:03:15FromDiscord<Elegantbeef> So then do it
00:03:27FromDiscord<nixfreak> you can't
00:03:35FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4gHa
00:03:39FromDiscord<Elegantbeef> Whoops `repeat(s, i)`
00:03:48FromDiscord<Elegantbeef> You clearly can
00:03:54FromDiscord<nixfreak> ahh didn't know about repeat
00:04:04FromDiscord<Elegantbeef> Even if you didnt know about repeat
00:04:42FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4gHd
00:05:26FromDiscord<nixfreak> yes I meant if there was an easier way
00:05:34FromDiscord<nixfreak> I guess I'm too used to perl python
00:06:54FromDiscord<Elegantbeef> Using operators like the above is awful
00:07:06FromDiscord<Elegantbeef> Especially since `` is suppose to be commutative
00:07:06FromDiscord<nixfreak> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/1045128004755525652): I guess I'm too used to pearl and python
00:07:17FromDiscord<Elegantbeef> `10 "hello"` is nonsensical
00:07:29FromDiscord<Elegantbeef> Same as `"hello" 10`
00:07:41*dnh quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
00:07:43*jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…)
00:08:07FromDiscord<nixfreak> yeah I agree , but it's easy and its a bad habit
00:11:33FromDiscord<Rika> Then break the habit
00:43:10FromDiscord<dedraiaken> sent a code paste, see https://play.nim-lang.org/#ix=4gHl
00:45:14FromDiscord<Generic> you can declare a helper
00:45:21FromDiscord<Generic> something like
00:46:17FromDiscord<Generic> sent a code paste, see https://play.nim-lang.org/#ix=4gHm
01:19:39FromDiscord<MagPhi> Can I write a standalone scalajs file in my node project and compile it to js and then bundle it using vite webpack etc
01:19:47FromDiscord<MagPhi> (edit) "scalajs" => "nim"
01:20:08FromDiscord<! Nilts> Are there pointers in nim?
01:20:23FromDiscord<ChocolettePalette> Yes
01:21:08FromDiscord<! Nilts> what is the syntax
01:22:49FromDiscord<Elegantbeef> `ptr T`
01:23:13FromDiscord<Elegantbeef> But you dont really use them unless you're doing low level schtuff
01:23:32FromDiscord<ChocolettePalette> Like summing up two numbers?
01:23:53FromDiscord<Elegantbeef> One day you'll say something not silly
01:24:04FromDiscord<Rika> Beef we all think that same thing with you
01:24:12FromDiscord<Elegantbeef> True
01:29:54FromDiscord<jmgomez> In reply to @MagPhi "Can I write a": Yes
01:49:34FromDiscord<Patitotective> hello
01:49:53FromDiscord<Elegantbeef> Who is that?!
01:50:09FromDiscord<Patitotective> :]
01:53:01FromDiscord<Patitotective> i think ive finished kdl-nim 1.0↵added streams and static parsing support↵so if you wanted to take a look, its here https://github.com/Patitotective/kdl-nim/tree/devel :]
01:53:26FromDiscord<Elegantbeef> That's a good sign
01:55:52FromDiscord<Elegantbeef> ` case runtime: bool`
01:55:57FromDiscord<Elegantbeef> what does `runtime` mean?
01:56:32FromDiscord<Patitotective> nonstatic/work with streams
01:57:05FromDiscord<Elegantbeef> why isnt it `isStream`? or something sensible
01:58:19FromDiscord<Patitotective> im obsessed to one-word variable names 🤷‍♀️ but i guess `isStream` would be better
01:58:24FromDiscord<Patitotective> (edit) "to" => "with"
01:59:02FromDiscord<Patitotective> btw are newlines in multiline strings always `\n`? even on windows?
01:59:47FromDiscord<Elegantbeef> No clue you can check with `-d:mingw`
02:00:46FromDiscord<Patitotective> yep, only `\n`
03:02:55FromDiscord<Cheesy Brik> Is there anything like pickle from python but for nim (without the obvious vulnerabilities hopefully)? Storing class instances and such?
03:03:22FromDiscord<Elegantbeef> frosty, flatty
03:04:20FromDiscord<Rika> In reply to @Cheesy Brik "Is there anything like": As long as something stores function data it would have the same vulnerabilities no?
03:11:31FromDiscord<dedraiaken> sent a code paste, see https://play.nim-lang.org/#ix=4gHF
03:11:44FromDiscord<Elegantbeef> It's not exported
03:12:06FromDiscord<Elegantbeef> there are helper procs to get them
03:12:20FromDiscord<dedraiaken> Oh, duh. Nothing like asking a question that makes you immediately see the problem. 🙃
03:13:00FromDiscord<Rika> Hindsight is powerful
03:53:55*arkurious quit (Quit: Leaving)
04:19:41FromDiscord<Cheesy Brik> What is nimph?
04:24:23FromDiscord<Rika> A differently styled package manager for Nim
05:08:54*rockcavera quit (Remote host closed the connection)
06:04:43*kenran joined #nim
06:11:24FromDiscord<Tuatarian> I have a macro question
06:11:26FromDiscord<Tuatarian> this simple macro
06:11:33FromDiscord<Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=4gI0
06:11:40FromDiscord<Tuatarian> generates the AST of `@["1"]`
06:11:44FromDiscord<Tuatarian> (accurately)
06:12:03FromDiscord<Tuatarian> but the problem is, when I try to do something simple with it, even something like `echo sq12()`, it gives some odd errors
06:12:20FromDiscord<Tuatarian> the errors are inside the macro, and say `/home/tuatarian/code/Heaviside/greybox.nim(4, 22) Error: expression '@["1"]' is of type 'seq[string]' and has to be used (or discarded)`
06:12:32FromDiscord<Elegantbeef> `sq12(): untyped`
06:12:33*kenran quit (Remote host closed the connection)
06:12:41FromDiscord<Tuatarian> you have to explicitly add that?
06:13:06FromDiscord<Elegantbeef> Fairly certain
06:13:11FromDiscord<Tuatarian> wait so what is happening in macro/template when you don't write anything there?
06:13:13FromDiscord<Tuatarian> yes that was the issue
06:13:18FromDiscord<Elegantbeef> `void`
06:13:26FromDiscord<Tuatarian> what does that mean in the context of a macro/template?
06:13:42FromDiscord<Elegantbeef> It returns untyped ast
06:13:54FromDiscord<Elegantbeef> untyped == auto
06:14:25FromDiscord<Tuatarian> so it simply substitutes the returned AST for the call?
06:15:05FromDiscord<Elegantbeef> well yea
06:15:05FromDiscord<Elegantbeef> That's how templates/macros work
06:15:05FromDiscord<Elegantbeef> They're expanded at call
06:15:31FromDiscord<Tuatarian> right
06:15:46FromDiscord<Tuatarian> but isn't the same as what's happening if it returns untyped?
06:16:12FromDiscord<Elegantbeef> What?
06:16:37FromDiscord<Tuatarian> if it returns untyped, it simply replaces its call with the returned AST
06:16:48FromDiscord<Elegantbeef> macros (need?) a return type if the code can be an expression
06:16:54FromDiscord<Tuatarian> what's the difference between that and a macro which returns void?
06:16:59FromDiscord<Tuatarian> meaning?
06:17:05FromDiscord<Elegantbeef> A macro that returns void only does introspection
06:17:28FromDiscord<Tuatarian> so it can't return an expression basically
06:17:35FromDiscord<Tuatarian> it can only return an AST which is void
06:17:42FromDiscord<Tuatarian> right?
06:18:37FromDiscord<Rika> it cant return ast
06:18:55FromDiscord<Rika> "ast which is void" is no ast
06:20:16FromDiscord<Rika> but iirc, a macro with no return type returns `typed`
06:20:51FromDiscord<Elegantbeef> Well it should be valid if it returns void
06:20:51FromDiscord<Elegantbeef> I mean typed
06:21:03FromDiscord<Tuatarian> yeah... I thought it returned `typed` as well
06:21:38FromDiscord<Elegantbeef> It cannot returned typed ast though
06:21:51FromDiscord<Rika> what are you saying
06:21:55FromDiscord<Elegantbeef> That requires semantic analysis, and macros are by definition not semantically correct
06:22:23FromDiscord<Elegantbeef> A macro returning `typed` doesnt make any sense
06:22:34FromDiscord<Elegantbeef> Maybe i'm just being dumb
06:22:38FromDiscord<Rika> you are
06:26:34FromDiscord<Tuatarian> I'm now more confused
06:27:54FromDiscord<Elegantbeef> Just annotate macros `: untyped` if they're the can have a value and carry on
06:28:00FromDiscord<Elegantbeef> if they can have\
06:28:27FromDiscord<Tuatarian> yeah that's what I'll do I guess
06:28:32FromDiscord<Tuatarian> little confusing, but whatever
06:29:05FromDiscord<Elegantbeef> The manual doesnt really talk about macros return type so it's mostly just a case of "what compiles works" 😄
06:38:15*tanami joined #nim
06:58:27FromDiscord<Tuatarian> can I use a `strformat` string in a `newLit`?
06:58:43FromDiscord<Elegantbeef> Of course
07:08:21*LuxuryMode quit (Quit: Connection closed for inactivity)
07:14:32FromDiscord<Girvo> Anyone had much experience exporting some Nim procs/modules to the JVM? Theres https://github.com/yglukhov/jnim I can see, which seems to have some JNI generator/wrapping tools?
07:15:16FromDiscord<Elegantbeef> There we go a proper question! 😛
07:17:05pbotfullertonIs there a way to specify how a struct gets packed without specifying manual unused fields? For some reason MSVC includes some padding in a struct between 2 members that MinGW doesn't
07:17:37FromDiscord<Elegantbeef> You can annotate `{.packed.}` if you want
07:18:45FromDiscord<Elegantbeef> There is also `align`
07:18:57FromDiscord<Elegantbeef> but aside from that it's down to your compiler
07:19:21pbotfullertonI tried that, and it didn't make them the same. The struct is composed of 7 shorts followed by an 8-byte union. MSVC includes 2 bytes of padding between the 7th short and the union, so the union start address is actually at 16 instead of the expected 14
07:19:59pbotfullertonHm so it does look like I'll have to leave a manual extra short in there for padding
07:25:39pbotfullertonNevermind, aligning the union to 8 did the trick. Thank you.
07:34:24FromDiscord<OdoItal> sent a code paste, see https://paste.rs/XUg
07:35:03FromDiscord<OdoItal> sent a code paste, see https://play.nim-lang.org/#ix=4gIm
07:35:12FromDiscord<OdoItal> sent a code paste, see https://play.nim-lang.org/#ix=4gIn
07:37:49FromDiscord<Elegantbeef> Not much to say
07:45:03*NimBot joined #nim
07:45:19*xaltsc joined #nim
07:46:02pbotfullertonHuh that's weird, I removed the align pragma and the struct stayed working. I made a change in the same file, the struct broke again. Re-added the pragma, good to go again
07:48:39pbotfullertonI guess GCC is smart enough to guess whether a struct member needs aligned access?
07:54:46*PMunch joined #nim
07:55:49FromDiscord<ShalokShalom> @Odotal Maybe its the bot, but the message reached us here three times in a row.
07:56:06FromDiscord<Elegantbeef> They edited it
07:56:12FromDiscord<ShalokShalom> Ah, makes sense.
07:56:27FromDiscord<Elegantbeef> The bridge doesnt do edits well
07:56:32FromDiscord<Rika> sent a code paste, see https://play.nim-lang.org/#ix=4gIv
07:56:39FromDiscord<Rika> "not much to say"
07:57:08FromDiscord<Elegantbeef> Uhh insert excuse here
07:57:30FromDiscord<Elegantbeef> I was more looking for some stupendously wrong code
07:57:59FromDiscord<Rika> floordivmod where /s
07:58:11*jjido joined #nim
07:58:17FromDiscord<Rika> then again floormod doesnt change to div when the number is nonnegative
07:58:48FromDiscord<Rika> wait what
07:58:52FromDiscord<Rika> nim doesnt have divmod
07:59:03FromDiscord<Rika> am i going crazy
08:00:10FromDiscord<OdoItal> It doesn't, I checked, I'm very sad about it↵(@Rika)
08:00:21FromDiscord<Rika> sent a code paste, see https://play.nim-lang.org/#ix=4gIw
08:00:41FromDiscord<Rika> prolly best to use regular mod/div
08:14:49FromDiscord<OdoItal> Oooh, I like this, makes total sense! And yeah, only ever expecting non-negative integers thankfully↵(@Rika)
08:16:34FromDiscord<Rika> 👍
08:34:14FromDiscord<ShalokShalom> Rika is the best. 🥳
08:44:47pbotfullertonIf I need to allocate a string buffer to pass to a C function, what's the proper way of doing that? I tried cstring(newString(length)) but that gets garbage collected either before or soon after the C function runs
08:45:09pbotfullertonalloc0 does work correctly but I'm wondering if there is a non-manual allocation way of doing this
08:45:36FromDiscord<Elegantbeef> There isnt really
08:59:14pbotfullertonI'd expect the garbage collector to not collect the string until the end of the function since the string might be used after the C FFI call depending on a couple of conditions
08:59:24pbotfullertonBut I think that's just me not knowing how the ORC collector works
08:59:30FromDiscord<Elegantbeef> `cstring` is non allocating
08:59:44FromDiscord<Elegantbeef> At the end of scope the local string is GC'd
09:00:48FromDiscord<Elegantbeef> `cstring(myString)` is really just `cast[cstring](myString[0].addr)`
09:01:10FromDiscord<Elegantbeef> The GC cannot know what the library does with that pointer
09:07:52*jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…)
09:09:19pbotfullertonSo I create the string, call the C FFI, and then have a chance to use the string after the FFI returns. Does that change anything? Does the fact that the cstring based on the new string is assigned to a union within an object change anything?
09:09:52FromDiscord<Elegantbeef> Nim does not track pointers and it cannot track what libraries do
09:27:52*Perkol joined #nim
10:08:19NimEventerNew thread by Ward: Open XML Spreadsheet (Excel) Library for Nim, see https://forum.nim-lang.org/t/9645
10:24:09NimEventerNew Nimble package! xl - Open XML Spreadsheet (Excel) Library for Nim, see https://github.com/khchen/xl
10:29:19*piertoni joined #nim
10:30:46piertonihi guys!
10:30:47piertoniHow can I forward declare a procedure for later use? The obvious solution to only put the function declaration without implementation is not working:
10:30:47piertoniE.G: proc parseExpression(seq[ref Token], var int): ref Node
10:31:07FromDiscord<Rika> Not working in what way?
10:31:24FromDiscord<Rika> Oh, you still need to specify parameter names
10:31:53piertoniproc parseExpression(s: seq[ref Token], i: var int): ref Node
10:31:53piertoni?
10:32:01FromDiscord<Rika> Yes
10:34:31piertoniUh, oh, in fact was my first attempt, but for some reason was not working, now is working, thanks.
10:46:42*jmdaemon quit (Ping timeout: 256 seconds)
11:05:07FromDiscord<hmmm> sent a code paste, see https://play.nim-lang.org/#ix=4gJf
11:06:15FromDiscord<hmmm> I'm pretty sure there is a simpler way lol
11:15:17*dnh joined #nim
11:19:53FromDiscord<hotdog> In reply to @hmmm "broskis is there a": echo @[0,0,0].allIt(it == 0)↵?
11:22:07FromDiscord<hmmm> genius skeleton hotdog!
11:24:22FromDiscord<Rika> lol
11:55:05FromDiscord<Jessa> using the `terminial` module for nim, you can get per-character inputs using `getch()`, however, this does not include any special keys like arrows, control, shift etc↵is there any alternative that also catches a singular character (without pressing enter), that also captures all special keys?
12:02:10FromDiscord<amadan> Don't know about shift and control but `getch()` does support arrow keys. You need to call it three times though. First two characters should have codes 27 and 91 and then the third code is 65 for up and 66 for down
12:03:15PMunch@Jessa, I'm not sure that is possible in terminals
12:03:32PMunchShift and Control I mean
12:05:41FromDiscord<Jessa> In reply to @amadan "Don't know about shift": i have it in a while loop, and when i press the arrow key, it only printed nothing once
12:06:10FromDiscord<Jessa> In reply to @PMunch "Shift and Control I": i sure would hope so
12:07:24FromDiscord<amadan> In reply to @Jessa "i have it in": Are you printing the output of getch? It'll be a character that doesn't get displayed, do `getch().ord` to get the code
12:07:25FromDiscord<ChocolettePalette> Are you printing characters or their int values?↵(@Jessa)
12:07:39FromDiscord<Jessa> It doesn't neccecarily need to be the the terminal module either, jmust any that can do it
12:07:46FromDiscord<Jessa> In reply to @amadan "Are you printing the": Yes, it's result is 0
12:07:55FromDiscord<amadan> Oh weird
12:07:56FromDiscord<Jessa> as well as for ctrl/shift/etc..
12:08:21FromDiscord<ChocolettePalette> You can try SDL even listener or smth↵(@Jessa)
12:08:39FromDiscord<Jessa> sent a code paste, see https://paste.rs/VvO
12:12:45PMunch@ChocolettePalette, that needs a window
12:14:04PMunchAs far as I know there is no way to get only modifier keys in the terminal. Sure you might be able to hack something by e.g. swallowing the terminal window in another window and redirecting output or something like that. But apart from ugly non-portable hacks I'm pretty sure it's not possible
12:16:56FromDiscord<Jessa> ah, nevermind↵↵i can use the msvcrt import
12:16:58FromDiscord<Jessa> or well
12:17:00FromDiscord<Jessa> C thing
12:19:10PMunchThat's the kind of ugly non-portable hacks I was talking about :P
12:32:45NimEventerNew thread by RodSteward: Atomic ARC option?, see https://forum.nim-lang.org/t/9646
12:36:33arkanoidshould "of" cases of a case switch vertically aligned with the "c" of "case", or should they be indented? manual says I can do both, but unsure which route I should pick https://nim-lang.org/docs/manual.html#statements-and-expressions-case-statement
13:02:49NimEventerNew thread by bjorn_madsen: Looking for a pair programming partner / coach, see https://forum.nim-lang.org/t/9647
13:06:39*wallabra quit (Quit: ZNC 1.8.2 - https://znc.in)
13:08:24*wallabra joined #nim
13:08:53FromDiscord<Rika> In reply to @arkanoid "should "of" cases of": i believe the community is roughly split on which it is but the probable majority would say not indented
13:11:47FromDiscord<ringabout> In reply to @NimEventer "New thread by bjorn_madsen:": Sounds like a good proposal. I can teach someone Nim for free as long as they can teach me English speaking 😂 Though I am not capable of talking in English at the moment.
14:28:05*arkurious joined #nim
14:59:54*PMunch quit (Quit: Leaving)
15:08:42*dtomato4 quit (Ping timeout: 252 seconds)
15:11:36*dnh quit (Ping timeout: 264 seconds)
15:36:38*dtomato4 joined #nim
15:56:30FromDiscord<haxscramper> In reply to @arkanoid "should "of" cases of": It's like `{}` braces for `if`
15:56:45FromDiscord<haxscramper> there is a consistent way and there is a weirdly popular one
15:58:26FromDiscord<haxscramper> (edit) "consistent" => "consistent/logical" | "consistent/logicalway and there is a weirdly popular one ... " added "that has a lot of inertia for whatever reasons"
16:04:13*krux02_ quit (Remote host closed the connection)
16:21:54*piertoni quit (Quit: Client closed)
16:29:27NimEventerNew thread by sls1005: Does modifying cstring affect its string?, see https://forum.nim-lang.org/t/9648
16:30:34*dtomato4 quit (Quit: The Lounge - https://thelounge.chat)
16:31:08*dtomato4 joined #nim
16:32:06*dtomato4 quit (Client Quit)
16:34:22*dtomato4 joined #nim
16:53:59FromDiscord<mantielero (mantielero)> I am playing with npeg. I am trying to capture comments that happen to be between `(` and `)`. I am trying to capture whatever is not `)`. How should I do that?
16:54:52FromDiscord<mantielero (mantielero)> I tried\: `comment <- "(" >!(")") ")"` but it doesn't work
16:56:02*Perkol quit (Quit: Leaving)
17:11:40Zevv"(" * *(1-")") * ")"
17:12:26Zevv"(" followed by zero-or-more-times everything but ")" (1 - ")"), followed by a ")"
17:13:27Zevv. ╭─────»─────╮
17:13:27FromDiscord<mantielero (mantielero)> It is not that case, the comments are written like\: `( This is a comment )`
17:13:27Zevv. │ ━━━ │
17:13:27Zevv. o──"("─»┴┬─")"─»─1─┬┴»─")"──o
17:13:30Zevv. ╰────«────╯
17:14:14Zevvyou want to capture what is inside the brackets, you prepend '>' to that part
17:14:45Zevv "(" * >*(1-")") * ")"
17:15:37FromDiscord<mantielero (mantielero)> My issue is with the limits including two characters (not one)\: the parenthesis and the asterisk
17:18:10Zevvim currently traveling, if you are still stuck feel free to throw an issue on the npeg repo
17:18:22Zevvwith some example text you are parsing
17:18:33FromDiscord<mantielero (mantielero)> Great. Thanks for your help.
17:18:42Zevvnp
17:21:17FromDiscord<Mike> sent a code paste, see https://play.nim-lang.org/#ix=4gLe
17:21:28FromDiscord<Mike> Works great on c, all day long. But if I run it on the js backend I get a different number. Is that expected for `random` with the same seed?
17:46:18FromDiscord<hotdog> In reply to @Mike "Works great on c,": Probably expected, the implementation is different for js backend
17:49:13Zevvmantielero: you still here?
17:49:25FromDiscord<mantielero (mantielero)> Yes
17:49:29Zevvyour code only captures 1 character that does not match (1-')')
17:49:41Zevv "(*" * >*(1-"*)") * "*)" is what you need
17:50:28Zevvwhen in doubt, use -d:npegTrace
17:50:34Zevvyou can see it much through your subject
17:50:46Zevvand get a grasp of what it is doing and why
17:51:00FromDiscord<Phil> In reply to @ringabout "Sounds like a good": Best I can do is talk at you in english 😛
17:51:21Zevvif the playground wasn't broken you could run it at https://play.nim-lang.org/#ix=4gLj
17:51:45FromDiscord<mantielero (mantielero)> Did you see the issue I raised?
17:52:02Zevvyes, this is what I answered to, sin't it?
17:52:09FromDiscord<mantielero (mantielero)> I think you are still missing capturing the asterisk
17:52:31Zevv@["This is a comment"]
17:54:07FromDiscord<mantielero (mantielero)> I mean, you are matching `"("` then whatever is not `")"` and finally you match `")"`
17:54:41Zevvno, whatever is not "*)"
17:54:48Zevv1 - "*)"
17:55:27Zevvyou were close, but you were only capturing one of those
17:55:31FromDiscord<mantielero (mantielero)> But I am trying to match\: `"("`, then whatever is not `")"` and finally\: `")"`.
17:56:07Zevvyes, but you match only one. You need to change >(1-"*)") into >*(1-"*)")
17:56:15Zevv> capture * zero-or-more
17:56:29Zevvyou almost had it right
17:56:42Zevvbut it's crappy to read with all the quotes and brackets
17:57:01FromDiscord<mantielero (mantielero)> Ah ok. I see the answer in the Issue
17:57:10Zevvmore white space helps
17:57:10Zevv comment <- "(*" * > * (1 - "*)" ) * "*)"
17:59:05Zevvyou good?
18:00:06FromDiscord<mantielero (mantielero)> Yeah. In fact I see that my example was right. The issue
18:01:17FromDiscord<mantielero (mantielero)> The issue was that I was capturing the string, so it was available within variable `comm`, not under `captures`!
18:01:31Zevvyour example was almost right
18:01:34Zevvyou missed a *
18:02:05Zevvrun your example with -d:npegTrace
18:02:25Zevvyou will see it fails afte the first char of the comment body, expecting the *)
18:02:29FromDiscord<vestel> Can I forward declare a type?
18:02:49Zevvonly in the same type block
18:03:06Zevvwelcome to nim, one of the things that has hunted me for years
18:03:35FromDiscord<vestel> In reply to @Zevv "welcome to nim, one": how?
18:03:51FromDiscord<mantielero (mantielero)> Yeah true
18:03:52FromDiscord<mantielero (mantielero)> I see it
18:03:54FromDiscord<mantielero (mantielero)> Very useful the npegTrace
18:04:01Zevvgood, good
18:04:35Zevvvestel: well, almost every seriousle large project ends up with a file types.nim
18:04:52Zevvwhich has a lot of types from all over the place in one type block
18:05:00Zevvto allow circular dependencies on types
18:05:19Zevvsome people told me my design is wrong if i have circular types, so it must be me
18:05:20FromDiscord<mantielero (mantielero)> I understand now
18:05:34Zevvgreat happy parsing
18:08:11*jjido joined #nim
18:08:15FromDiscord<mantielero (mantielero)> A completely different topic. Wrapping a C++ class, how is the appropriate way to override a method declared in Nim?
18:09:11FromDiscord<hmmm> sent a code paste, see https://play.nim-lang.org/#ix=4gLr
18:12:04*rockcavera joined #nim
18:13:13FromDiscord<Rika> no
18:13:16FromDiscord<Rika> cannot
18:18:53FromDiscord<hmmm> bummer, but turns out I didn't really need it
18:34:15FromDiscord<jmgomez> In reply to @mantielero (mantielero) "A completely different topic.": There is no current official solution for it yet. I have in my TODO to play with it, I would approach it by importing the vtable and replacing the fn pointer with a Nim hand manually. Once that works (if it does) I would make a pragma that does it for me. Not sure how they internally works, but you may want to store the old one somewhere in case you want to do a super
18:34:37FromDiscord<jmgomez> (edit) "In reply to @mantielero (mantielero) "A completely different topic.": There is no current official solution for it yet. I have in my TODO to play with it, I would approach it by importing the vtable and replacing the fn pointer with a Nim ... hand" added "fn by hand (maybe thiscall?)"
18:50:46FromDiscord<tope> sent a code paste, see https://play.nim-lang.org/#ix=4gLz
18:52:17FromDiscord<hmmm> when is compiletime if and static is compiletime var right?
18:53:16FromDiscord<hmmm> pretty neat I thought it wasn't possible
18:56:18FromDiscord<Phil> static is compile time expression I think could be more accurately expressed as you can also statically evaluate other stuff
19:02:57FromDiscord<Rika> That is possible yes
19:03:07FromDiscord<Rika> I assumed you wanted it runtime so I said no
19:04:38FromDiscord<hmmm> you assumed correctly 😎
19:39:39ehmryis it possible to programatically import a module from and inspect something in it?
19:41:36*pro joined #nim
19:42:09ehmryI need to generate code that uses a type from another module but I need to know if that type is generic
19:42:51*pro left #nim (#nim)
19:49:22FromDiscord<guttural666> naively I'd say that a parser + the nim compile time introspection facilities would be required for something like that
19:50:27ehmrythis would be a lot easier if I didn't have to deal with generics
20:07:35pbotfullertonIs there a function to append the contents of one seq to another, analogous to Python's list `+=` syntax or should I just iterate and add?
20:09:11FromDiscord<planetis> There is &=
20:09:31pbotfullertonSweet, thank you
20:11:25FromDiscord<jmgomez> In reply to @ehmry "this would be a": what are you trying to do? Cant you pass the symbol as parameter?
20:11:48FromDiscord<jmgomez> Im looking at ## for generating docs. But how do you suppose to use it with imporc?
20:12:42ehmryjmgomez: I have a code generator that generates generic types, but I think I can specify the generic parameter at code generation time
20:13:26FromDiscord<jmgomez> In reply to @jmgomez "Im looking at ##": Ok, just at the end rather than in a new line
20:14:27FromDiscord<jmgomez> In reply to @ehmry "<@726017160115126333>: I have a": Like expand/bake an existing generic?
20:15:43ehmryI generate types that sometimes contain a member that is generic, and so the generality has to propagate outwards
20:16:40ehmryI think what I am doing here is too complicated
20:19:18FromDiscord<jmgomez> cant you just check the ast? IIRC generics has a nnkGenericParams or something like that node
20:33:11ehmryI don't think I can inspect an ast from code that I will import a compile time when I am still at generation time
20:37:16FromDiscord<jmgomez> How are you using the Macro? ↵I did something similar recently but I had access to type, like a pass in a func implementation with generics and it generates an extra type and a FFI function to interop with C for those expanded types. Obviously for doing so you need to have access to the generics if you dont, not sure if you can
20:38:24FromDiscord<jmgomez> There is a locals plugin in the compiler that inspect the local scope. Not sure if you can really add plugins to the compiler without recompiling it but if you dont care about it, you could take a look at it I think it filters the types out from a module
20:40:28FromDiscord<Cheesy Brik> Does nim make local paths absolute when compiling production? Cus I need local paths to stay local.
20:41:52FromDiscord<Cheesy Brik> (edit) "Does nim make local paths ... absolute" added "to"
20:45:33FromDiscord<Tuatarian> for some reason, this macro throws a compile error
20:45:40FromDiscord<Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=4gM1
20:45:52FromDiscord<Tuatarian> I'm trying here to build an AST for a `seq[string]`
20:46:01FromDiscord<Tuatarian> I tried a simpler verison of this, namely
20:46:08FromDiscord<Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=4gM2
20:46:09FromDiscord<Tuatarian> which directly builds the literal and works perfectly
20:46:50FromDiscord<Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=4gM3
20:47:00FromDiscord<Tuatarian> which is weird since the eabove code works perfectly without error
21:09:06*jmdaemon joined #nim
21:11:02FromDiscord<Tuatarian> one useful piece of info is that it gives a compile error before `echo treeRepr result` finishes executing
21:11:27FromDiscord<Tuatarian> (edit) "error before `echo treeRepr result` finishes executing" => "error, but really not sure why this could be happening"
21:11:36FromDiscord<Tuatarian> it dislikes my stringificationsomewhere
21:31:25FromDiscord<Tuatarian> I see the issue
21:31:48FromDiscord<Tuatarian> one of the arguements of `contains` is a `HSlice[U, V]`
21:32:09FromDiscord<Tuatarian> sent a code paste, see https://paste.rs/w5w
21:32:11FromDiscord<Tuatarian> ie not flat
21:33:10FromDiscord<Tuatarian> and the fix then is to instead of using `$` for stringification, use `repr(NimNode)`
21:41:07FromDiscord<vindaar> yeah, whenever you see the error "Error\: Invalid node kind nnkBracketExpr for macros.\`$" it means you're trying to print / string convert a NimNode
21:42:23FromDiscord<vindaar> (the node kinds may differ of course)
21:44:06FromDiscord<vindaar> not entirely certain of the top of my head, but I think `$` for NimNode is only valid for literals
21:44:57FromDiscord<Elegantbeef> Symbols and idents aswell
21:45:01FromDiscord<Elegantbeef> just use `repr`
21:54:02FromDiscord<Tuatarian> yeah
21:54:20FromDiscord<Tuatarian> I'm extremely unfamiliar with macros/templates, this is my first time seeing this error
21:55:08FromDiscord<Tuatarian> I think perhaps it would be nice if `$` became an alias for `repr` or if trying to use `$` on a node with children gave an error telling you what you were doing
21:55:18FromDiscord<Tuatarian> but honestly
21:55:28FromDiscord<Tuatarian> the move is to avoid using `$` and just stick with repr
21:56:46FromDiscord<Tuatarian> especially since the thing I was making was a bracket expression
21:57:01FromDiscord<Tuatarian> I didn't realize for a bit that the error was not at all related to my tree construction
22:10:56FromDiscord<QuiteQuietQ> sent a long message, see http://ix.io/4gMm
22:11:18FromDiscord<QuiteQuietQ> sent a long message, see http://ix.io/4gMn
22:12:32FromDiscord<Elegantbeef> That's a table constructor
22:12:49FromDiscord<Elegantbeef> It's a syntax that creates an array that you then can feed to a proc
22:13:06FromDiscord<Elegantbeef> So you can do like `import std/tables; var a = {"a": 100, "b": 200}.toTable`
22:17:18FromDiscord<QuiteQuietQ> however, it feels confusing, since it uses curly brackets like sets, also that it changes meaning according to what is inside
22:17:46FromDiscord<QuiteQuietQ> what type should I use when I am using a table constructor?
22:17:53FromDiscord<Elegantbeef> `{a: b}` is a table constructor
22:17:56FromDiscord<Elegantbeef> `{a, b}` is a set
22:17:59FromDiscord<Elegantbeef> It's not too complicated
22:18:12FromDiscord<ChocolettePalette> This is so called "Unix Way", which is an opposite to Apple's ecosystem
22:18:27FromDiscord<QuiteQuietQ> true, I just need to get it under my skin
22:18:28FromDiscord<Elegantbeef> A table constructor is for when you want an ergonomic key value pair
22:18:41FromDiscord<QuiteQuietQ> like Python dict?
22:19:34FromDiscord<Elegantbeef> It's just a different syntax for an array
22:20:31FromDiscord<Elegantbeef> `{"a": 100, "b": 200} == [("a", 100), ("b", 200)]`↵`{MyObject(): bleh, MyObject(): blugh} == [(MyObject(), bleh), (MyObject(), blugh)]`
22:20:34FromDiscord<Elegantbeef> It's just syntax sugar
22:21:23FromDiscord<QuiteQuietQ> get it
22:21:48FromDiscord<QuiteQuietQ> are there other tricks with syntactic sugar for creating collections?
22:22:01FromDiscord<Elegantbeef> Not that i can think of
22:22:17FromDiscord<Elegantbeef> The main benefit of this being in the syntax is that it means that you can make any table using the syntax
22:22:23FromDiscord<Elegantbeef> Be it actual tables or httpheaders
22:22:29FromDiscord<Elegantbeef> It's not specialised for a type
22:24:11FromDiscord<QuiteQuietQ> aha, thanks
22:27:16FromDiscord<QuiteQuietQ> sent a long message, see http://ix.io/4gMr
22:28:05FromDiscord<QuiteQuietQ> i know that the GenericsArray is nonsense 😄
22:28:07FromDiscord<Elegantbeef> `n: static int`
22:28:29FromDiscord<Elegantbeef> `n: int` is a generic constraint of a type not a value
22:28:40FromDiscord<Elegantbeef> `n: static int` is a value
22:29:20FromDiscord<QuiteQuietQ> wow, it works
22:29:23FromDiscord<QuiteQuietQ> lol, thanks!
22:36:11FromDiscord<emmicat> wait is that the irc bridge
22:36:27FromDiscord<Elegantbeef> Matrix
22:37:00FromDiscord<emmicat> oHhhhh cool
22:47:30FromDiscord<tope> sent a code paste, see https://play.nim-lang.org/#ix=4gMv
22:49:20FromDiscord<ChocolettePalette> What does the compiler say?
22:50:35FromDiscord<tope> sent a code paste, see https://play.nim-lang.org/#ix=4gMx
22:50:48FromDiscord<Elegantbeef> It's an issue with the static generic parameter reasoning
22:51:48FromDiscord<Elegantbeef> It doesnt evaluate complex expressions in generic parameters
22:51:56FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4gMA
22:52:10FromDiscord<Elegantbeef> It's not great but it does atleast force it to work
22:52:17FromDiscord<Elegantbeef> I have been meaning in looking at this bug
22:55:38FromDiscord<tope> hmm, ok, as a general rule would you recommend using auto return type when result type depends on static calculations based on generic input types? I'm trying to do a simplified ndarray with static compile-time rank, and I get most of it to work it's just that it can be pretty unintuitive what I have to do sometimes
22:56:13FromDiscord<Elegantbeef> Until this bug gets fixed yes
22:57:35FromDiscord<Marak> Howdy Y'all
22:58:24FromDiscord<tope> sent a code paste, see https://play.nim-lang.org/#ix=4gMB
22:58:55FromDiscord<tope> but I expect it's related to using expressions in return type
22:58:56FromDiscord<Elegantbeef> Without context cannot say much
23:00:32FromDiscord<Elegantbeef> The issue with `Phantom[pred(N, 1)]` is likely a simple check inside semtypeinst to evaluate expressions after instantiating the procedure
23:01:02FromDiscord<Elegantbeef> Sorry seminst
23:04:08FromDiscord<dlesnoff> sent a long message, see http://ix.io/4gME
23:07:36FromDiscord<dlesnoff> Sorry for this sudden and mysterious comment, I will explain myself better tomorrow.
23:09:24FromDiscord<Elegantbeef> `float` is 64bit regardless
23:09:33FromDiscord<Elegantbeef> Nim only has 32 and 64bit floats
23:09:58FromDiscord<Elegantbeef> Personally it's Sentinel -\> Option -\> Exception, though depends on the API
23:10:05FromDiscord<Elegantbeef> I very much prefer exception's semantics
23:10:09FromDiscord<Elegantbeef> I dislike option/result semantics
23:11:40madpropsyou're the exception
23:13:50FromDiscord<Elegantbeef> Uhh
23:14:34FromDiscord<Elegantbeef> I know you're likely joking, but I've even see people that use rust say they prefer exception semantics
23:27:45FromDiscord<Tuatarian> imo option semantics are a little unnecessarily verbose
23:28:43ehmrystack unwinding seems like more work than checking an option
23:30:44FromDiscord<Yepoleb> more work for who?
23:31:36ehmryok, less work and more waiting for something to finish
23:31:58FromDiscord<Yepoleb> you think stack unwinding is slow?
23:32:25ehmryI think its more expensive
23:32:52ehmryand if you are consistent with options than there is a flow to writing that code
23:35:43ehmryoption checking can be inlined, throwing an exception cannot
23:35:55FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4gML
23:36:20FromDiscord<Yepoleb> but you don't throw exceptions constantly
23:36:27FromDiscord<Yepoleb> unless python xD
23:36:39FromDiscord<voidwalker> just curious about the situation here, tDict is a ref object. why does this assignment change the file iterator variable, ` filetmp.d["path"].l = Bencode("") & filetmp.d["path"].l` ? is it a ref thing as well ?
23:37:21ehmryi'm grumpy about exceptions because I've had to look inside libunwind
23:37:53ehmrybut whatever, as long as its not python
23:38:37FromDiscord<Yepoleb> even then, a few µs of unwind time when an exception actually happens are negligible
23:39:03FromDiscord<voidwalker> if so, how can i dereference it and assign just the value ? I tried ` var filetmp = file[]` but the result is the same
23:52:31FromDiscord<Elegantbeef> if `d` is a ref aswell you need to deref that↵(@voidwalker)
23:52:56FromDiscord<Elegantbeef> Yea exceptions can be more expensive, but they also have more sensible semantics imo
23:53:19FromDiscord<Elegantbeef> There are ways to make them less expensive, not that Nim does it
23:53:36FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4gMN
23:54:29FromDiscord<voidwalker> In this particular case it seems there's no harm to modify in place, in the yielded value by the iterator. But I'd like to understand what's going on
23:54:56FromDiscord<Elegantbeef> Is BenCodeObj a ref?
23:55:19FromDiscord<Elegantbeef> If so a copy doesnt deep copy so all the refs are the same
23:55:26FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4gMO
23:55:32FromDiscord<Elegantbeef> Well there you go
23:55:50FromDiscord<voidwalker> deep copy = go all the way down ?
23:55:53FromDiscord<Elegantbeef> `filetmp.d["path"].l` accesses the same `BenCodeObj`
23:55:54FromDiscord<Elegantbeef> Yep
23:56:29FromDiscord<Elegantbeef> A normal copy copies all value types, which means the pointer to the ref is copied
23:56:37FromDiscord<Elegantbeef> It doesnt go down the tree copying all data
23:57:33FromDiscord<albassort> can someone recommend me a database server that wont take years of my life off from sheer frustration