00:03:04 | FromDiscord | <nixfreak> I would I like write "a" \ 10 like in pytho |
00:03:15 | FromDiscord | <Elegantbeef> So then do it |
00:03:27 | FromDiscord | <nixfreak> you can't |
00:03:35 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4gHa |
00:03:39 | FromDiscord | <Elegantbeef> Whoops `repeat(s, i)` |
00:03:48 | FromDiscord | <Elegantbeef> You clearly can |
00:03:54 | FromDiscord | <nixfreak> ahh didn't know about repeat |
00:04:04 | FromDiscord | <Elegantbeef> Even if you didnt know about repeat |
00:04:42 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4gHd |
00:05:26 | FromDiscord | <nixfreak> yes I meant if there was an easier way |
00:05:34 | FromDiscord | <nixfreak> I guess I'm too used to perl python |
00:06:54 | FromDiscord | <Elegantbeef> Using operators like the above is awful |
00:07:06 | FromDiscord | <Elegantbeef> Especially since `` is suppose to be commutative |
00:07:06 | FromDiscord | <nixfreak> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/1045128004755525652): I guess I'm too used to pearl and python |
00:07:17 | FromDiscord | <Elegantbeef> `10 "hello"` is nonsensical |
00:07:29 | FromDiscord | <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:07 | FromDiscord | <nixfreak> yeah I agree , but it's easy and its a bad habit |
00:11:33 | FromDiscord | <Rika> Then break the habit |
00:43:10 | FromDiscord | <dedraiaken> sent a code paste, see https://play.nim-lang.org/#ix=4gHl |
00:45:14 | FromDiscord | <Generic> you can declare a helper |
00:45:21 | FromDiscord | <Generic> something like |
00:46:17 | FromDiscord | <Generic> sent a code paste, see https://play.nim-lang.org/#ix=4gHm |
01:19:39 | FromDiscord | <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:47 | FromDiscord | <MagPhi> (edit) "scalajs" => "nim" |
01:20:08 | FromDiscord | <! Nilts> Are there pointers in nim? |
01:20:23 | FromDiscord | <ChocolettePalette> Yes |
01:21:08 | FromDiscord | <! Nilts> what is the syntax |
01:22:49 | FromDiscord | <Elegantbeef> `ptr T` |
01:23:13 | FromDiscord | <Elegantbeef> But you dont really use them unless you're doing low level schtuff |
01:23:32 | FromDiscord | <ChocolettePalette> Like summing up two numbers? |
01:23:53 | FromDiscord | <Elegantbeef> One day you'll say something not silly |
01:24:04 | FromDiscord | <Rika> Beef we all think that same thing with you |
01:24:12 | FromDiscord | <Elegantbeef> True |
01:29:54 | FromDiscord | <jmgomez> In reply to @MagPhi "Can I write a": Yes |
01:49:34 | FromDiscord | <Patitotective> hello |
01:49:53 | FromDiscord | <Elegantbeef> Who is that?! |
01:50:09 | FromDiscord | <Patitotective> :] |
01:53:01 | FromDiscord | <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:26 | FromDiscord | <Elegantbeef> That's a good sign |
01:55:52 | FromDiscord | <Elegantbeef> ` case runtime: bool` |
01:55:57 | FromDiscord | <Elegantbeef> what does `runtime` mean? |
01:56:32 | FromDiscord | <Patitotective> nonstatic/work with streams |
01:57:05 | FromDiscord | <Elegantbeef> why isnt it `isStream`? or something sensible |
01:58:19 | FromDiscord | <Patitotective> im obsessed to one-word variable names 🤷♀️ but i guess `isStream` would be better |
01:58:24 | FromDiscord | <Patitotective> (edit) "to" => "with" |
01:59:02 | FromDiscord | <Patitotective> btw are newlines in multiline strings always `\n`? even on windows? |
01:59:47 | FromDiscord | <Elegantbeef> No clue you can check with `-d:mingw` |
02:00:46 | FromDiscord | <Patitotective> yep, only `\n` |
03:02:55 | FromDiscord | <Cheesy Brik> Is there anything like pickle from python but for nim (without the obvious vulnerabilities hopefully)? Storing class instances and such? |
03:03:22 | FromDiscord | <Elegantbeef> frosty, flatty |
03:04:20 | FromDiscord | <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:31 | FromDiscord | <dedraiaken> sent a code paste, see https://play.nim-lang.org/#ix=4gHF |
03:11:44 | FromDiscord | <Elegantbeef> It's not exported |
03:12:06 | FromDiscord | <Elegantbeef> there are helper procs to get them |
03:12:20 | FromDiscord | <dedraiaken> Oh, duh. Nothing like asking a question that makes you immediately see the problem. 🙃 |
03:13:00 | FromDiscord | <Rika> Hindsight is powerful |
03:53:55 | * | arkurious quit (Quit: Leaving) |
04:19:41 | FromDiscord | <Cheesy Brik> What is nimph? |
04:24:23 | FromDiscord | <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:24 | FromDiscord | <Tuatarian> I have a macro question |
06:11:26 | FromDiscord | <Tuatarian> this simple macro |
06:11:33 | FromDiscord | <Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=4gI0 |
06:11:40 | FromDiscord | <Tuatarian> generates the AST of `@["1"]` |
06:11:44 | FromDiscord | <Tuatarian> (accurately) |
06:12:03 | FromDiscord | <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:20 | FromDiscord | <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:32 | FromDiscord | <Elegantbeef> `sq12(): untyped` |
06:12:33 | * | kenran quit (Remote host closed the connection) |
06:12:41 | FromDiscord | <Tuatarian> you have to explicitly add that? |
06:13:06 | FromDiscord | <Elegantbeef> Fairly certain |
06:13:11 | FromDiscord | <Tuatarian> wait so what is happening in macro/template when you don't write anything there? |
06:13:13 | FromDiscord | <Tuatarian> yes that was the issue |
06:13:18 | FromDiscord | <Elegantbeef> `void` |
06:13:26 | FromDiscord | <Tuatarian> what does that mean in the context of a macro/template? |
06:13:42 | FromDiscord | <Elegantbeef> It returns untyped ast |
06:13:54 | FromDiscord | <Elegantbeef> untyped == auto |
06:14:25 | FromDiscord | <Tuatarian> so it simply substitutes the returned AST for the call? |
06:15:05 | FromDiscord | <Elegantbeef> well yea |
06:15:05 | FromDiscord | <Elegantbeef> That's how templates/macros work |
06:15:05 | FromDiscord | <Elegantbeef> They're expanded at call |
06:15:31 | FromDiscord | <Tuatarian> right |
06:15:46 | FromDiscord | <Tuatarian> but isn't the same as what's happening if it returns untyped? |
06:16:12 | FromDiscord | <Elegantbeef> What? |
06:16:37 | FromDiscord | <Tuatarian> if it returns untyped, it simply replaces its call with the returned AST |
06:16:48 | FromDiscord | <Elegantbeef> macros (need?) a return type if the code can be an expression |
06:16:54 | FromDiscord | <Tuatarian> what's the difference between that and a macro which returns void? |
06:16:59 | FromDiscord | <Tuatarian> meaning? |
06:17:05 | FromDiscord | <Elegantbeef> A macro that returns void only does introspection |
06:17:28 | FromDiscord | <Tuatarian> so it can't return an expression basically |
06:17:35 | FromDiscord | <Tuatarian> it can only return an AST which is void |
06:17:42 | FromDiscord | <Tuatarian> right? |
06:18:37 | FromDiscord | <Rika> it cant return ast |
06:18:55 | FromDiscord | <Rika> "ast which is void" is no ast |
06:20:16 | FromDiscord | <Rika> but iirc, a macro with no return type returns `typed` |
06:20:51 | FromDiscord | <Elegantbeef> Well it should be valid if it returns void |
06:20:51 | FromDiscord | <Elegantbeef> I mean typed |
06:21:03 | FromDiscord | <Tuatarian> yeah... I thought it returned `typed` as well |
06:21:38 | FromDiscord | <Elegantbeef> It cannot returned typed ast though |
06:21:51 | FromDiscord | <Rika> what are you saying |
06:21:55 | FromDiscord | <Elegantbeef> That requires semantic analysis, and macros are by definition not semantically correct |
06:22:23 | FromDiscord | <Elegantbeef> A macro returning `typed` doesnt make any sense |
06:22:34 | FromDiscord | <Elegantbeef> Maybe i'm just being dumb |
06:22:38 | FromDiscord | <Rika> you are |
06:26:34 | FromDiscord | <Tuatarian> I'm now more confused |
06:27:54 | FromDiscord | <Elegantbeef> Just annotate macros `: untyped` if they're the can have a value and carry on |
06:28:00 | FromDiscord | <Elegantbeef> if they can have\ |
06:28:27 | FromDiscord | <Tuatarian> yeah that's what I'll do I guess |
06:28:32 | FromDiscord | <Tuatarian> little confusing, but whatever |
06:29:05 | FromDiscord | <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:27 | FromDiscord | <Tuatarian> can I use a `strformat` string in a `newLit`? |
06:58:43 | FromDiscord | <Elegantbeef> Of course |
07:08:21 | * | LuxuryMode quit (Quit: Connection closed for inactivity) |
07:14:32 | FromDiscord | <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:16 | FromDiscord | <Elegantbeef> There we go a proper question! 😛 |
07:17:05 | pbotfullerton | Is 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:37 | FromDiscord | <Elegantbeef> You can annotate `{.packed.}` if you want |
07:18:45 | FromDiscord | <Elegantbeef> There is also `align` |
07:18:57 | FromDiscord | <Elegantbeef> but aside from that it's down to your compiler |
07:19:21 | pbotfullerton | I 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:59 | pbotfullerton | Hm so it does look like I'll have to leave a manual extra short in there for padding |
07:25:39 | pbotfullerton | Nevermind, aligning the union to 8 did the trick. Thank you. |
07:34:24 | FromDiscord | <OdoItal> sent a code paste, see https://paste.rs/XUg |
07:35:03 | FromDiscord | <OdoItal> sent a code paste, see https://play.nim-lang.org/#ix=4gIm |
07:35:12 | FromDiscord | <OdoItal> sent a code paste, see https://play.nim-lang.org/#ix=4gIn |
07:37:49 | FromDiscord | <Elegantbeef> Not much to say |
07:45:03 | * | NimBot joined #nim |
07:45:19 | * | xaltsc joined #nim |
07:46:02 | pbotfullerton | Huh 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:39 | pbotfullerton | I guess GCC is smart enough to guess whether a struct member needs aligned access? |
07:54:46 | * | PMunch joined #nim |
07:55:49 | FromDiscord | <ShalokShalom> @Odotal Maybe its the bot, but the message reached us here three times in a row. |
07:56:06 | FromDiscord | <Elegantbeef> They edited it |
07:56:12 | FromDiscord | <ShalokShalom> Ah, makes sense. |
07:56:27 | FromDiscord | <Elegantbeef> The bridge doesnt do edits well |
07:56:32 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=4gIv |
07:56:39 | FromDiscord | <Rika> "not much to say" |
07:57:08 | FromDiscord | <Elegantbeef> Uhh insert excuse here |
07:57:30 | FromDiscord | <Elegantbeef> I was more looking for some stupendously wrong code |
07:57:59 | FromDiscord | <Rika> floordivmod where /s |
07:58:11 | * | jjido joined #nim |
07:58:17 | FromDiscord | <Rika> then again floormod doesnt change to div when the number is nonnegative |
07:58:48 | FromDiscord | <Rika> wait what |
07:58:52 | FromDiscord | <Rika> nim doesnt have divmod |
07:59:03 | FromDiscord | <Rika> am i going crazy |
08:00:10 | FromDiscord | <OdoItal> It doesn't, I checked, I'm very sad about it↵(@Rika) |
08:00:21 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=4gIw |
08:00:41 | FromDiscord | <Rika> prolly best to use regular mod/div |
08:14:49 | FromDiscord | <OdoItal> Oooh, I like this, makes total sense! And yeah, only ever expecting non-negative integers thankfully↵(@Rika) |
08:16:34 | FromDiscord | <Rika> 👍 |
08:34:14 | FromDiscord | <ShalokShalom> Rika is the best. 🥳 |
08:44:47 | pbotfullerton | If 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:09 | pbotfullerton | alloc0 does work correctly but I'm wondering if there is a non-manual allocation way of doing this |
08:45:36 | FromDiscord | <Elegantbeef> There isnt really |
08:59:14 | pbotfullerton | I'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:24 | pbotfullerton | But I think that's just me not knowing how the ORC collector works |
08:59:30 | FromDiscord | <Elegantbeef> `cstring` is non allocating |
08:59:44 | FromDiscord | <Elegantbeef> At the end of scope the local string is GC'd |
09:00:48 | FromDiscord | <Elegantbeef> `cstring(myString)` is really just `cast[cstring](myString[0].addr)` |
09:01:10 | FromDiscord | <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:19 | pbotfullerton | So 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:52 | FromDiscord | <Elegantbeef> Nim does not track pointers and it cannot track what libraries do |
09:27:52 | * | Perkol joined #nim |
10:08:19 | NimEventer | New thread by Ward: Open XML Spreadsheet (Excel) Library for Nim, see https://forum.nim-lang.org/t/9645 |
10:24:09 | NimEventer | New Nimble package! xl - Open XML Spreadsheet (Excel) Library for Nim, see https://github.com/khchen/xl |
10:29:19 | * | piertoni joined #nim |
10:30:46 | piertoni | hi guys! |
10:30:47 | piertoni | How 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:47 | piertoni | E.G: proc parseExpression(seq[ref Token], var int): ref Node |
10:31:07 | FromDiscord | <Rika> Not working in what way? |
10:31:24 | FromDiscord | <Rika> Oh, you still need to specify parameter names |
10:31:53 | piertoni | proc parseExpression(s: seq[ref Token], i: var int): ref Node |
10:31:53 | piertoni | ? |
10:32:01 | FromDiscord | <Rika> Yes |
10:34:31 | piertoni | Uh, 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:07 | FromDiscord | <hmmm> sent a code paste, see https://play.nim-lang.org/#ix=4gJf |
11:06:15 | FromDiscord | <hmmm> I'm pretty sure there is a simpler way lol |
11:15:17 | * | dnh joined #nim |
11:19:53 | FromDiscord | <hotdog> In reply to @hmmm "broskis is there a": echo @[0,0,0].allIt(it == 0)↵? |
11:22:07 | FromDiscord | <hmmm> genius skeleton hotdog! |
11:24:22 | FromDiscord | <Rika> lol |
11:55:05 | FromDiscord | <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:10 | FromDiscord | <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:15 | PMunch | @Jessa, I'm not sure that is possible in terminals |
12:03:32 | PMunch | Shift and Control I mean |
12:05:41 | FromDiscord | <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:10 | FromDiscord | <Jessa> In reply to @PMunch "Shift and Control I": i sure would hope so |
12:07:24 | FromDiscord | <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:25 | FromDiscord | <ChocolettePalette> Are you printing characters or their int values?↵(@Jessa) |
12:07:39 | FromDiscord | <Jessa> It doesn't neccecarily need to be the the terminal module either, jmust any that can do it |
12:07:46 | FromDiscord | <Jessa> In reply to @amadan "Are you printing the": Yes, it's result is 0 |
12:07:55 | FromDiscord | <amadan> Oh weird |
12:07:56 | FromDiscord | <Jessa> as well as for ctrl/shift/etc.. |
12:08:21 | FromDiscord | <ChocolettePalette> You can try SDL even listener or smth↵(@Jessa) |
12:08:39 | FromDiscord | <Jessa> sent a code paste, see https://paste.rs/VvO |
12:12:45 | PMunch | @ChocolettePalette, that needs a window |
12:14:04 | PMunch | As 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:56 | FromDiscord | <Jessa> ah, nevermind↵↵i can use the msvcrt import |
12:16:58 | FromDiscord | <Jessa> or well |
12:17:00 | FromDiscord | <Jessa> C thing |
12:19:10 | PMunch | That's the kind of ugly non-portable hacks I was talking about :P |
12:32:45 | NimEventer | New thread by RodSteward: Atomic ARC option?, see https://forum.nim-lang.org/t/9646 |
12:36:33 | arkanoid | should "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:49 | NimEventer | New 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:53 | FromDiscord | <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:47 | FromDiscord | <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:30 | FromDiscord | <haxscramper> In reply to @arkanoid "should "of" cases of": It's like `{}` braces for `if` |
15:56:45 | FromDiscord | <haxscramper> there is a consistent way and there is a weirdly popular one |
15:58:26 | FromDiscord | <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:27 | NimEventer | New 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:59 | FromDiscord | <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:52 | FromDiscord | <mantielero (mantielero)> I tried\: `comment <- "(" >!(")") ")"` but it doesn't work |
16:56:02 | * | Perkol quit (Quit: Leaving) |
17:11:40 | Zevv | "(" * *(1-")") * ")" |
17:12:26 | Zevv | "(" followed by zero-or-more-times everything but ")" (1 - ")"), followed by a ")" |
17:13:27 | Zevv | . ╭─────»─────╮ |
17:13:27 | FromDiscord | <mantielero (mantielero)> It is not that case, the comments are written like\: `( This is a comment )` |
17:13:27 | Zevv | . │ ━━━ │ |
17:13:27 | Zevv | . o──"("─»┴┬─")"─»─1─┬┴»─")"──o |
17:13:30 | Zevv | . ╰────«────╯ |
17:14:14 | Zevv | you want to capture what is inside the brackets, you prepend '>' to that part |
17:14:45 | Zevv | "(" * >*(1-")") * ")" |
17:15:37 | FromDiscord | <mantielero (mantielero)> My issue is with the limits including two characters (not one)\: the parenthesis and the asterisk |
17:18:10 | Zevv | im currently traveling, if you are still stuck feel free to throw an issue on the npeg repo |
17:18:22 | Zevv | with some example text you are parsing |
17:18:33 | FromDiscord | <mantielero (mantielero)> Great. Thanks for your help. |
17:18:42 | Zevv | np |
17:21:17 | FromDiscord | <Mike> sent a code paste, see https://play.nim-lang.org/#ix=4gLe |
17:21:28 | FromDiscord | <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:18 | FromDiscord | <hotdog> In reply to @Mike "Works great on c,": Probably expected, the implementation is different for js backend |
17:49:13 | Zevv | mantielero: you still here? |
17:49:25 | FromDiscord | <mantielero (mantielero)> Yes |
17:49:29 | Zevv | your code only captures 1 character that does not match (1-')') |
17:49:41 | Zevv | "(*" * >*(1-"*)") * "*)" is what you need |
17:50:28 | Zevv | when in doubt, use -d:npegTrace |
17:50:34 | Zevv | you can see it much through your subject |
17:50:46 | Zevv | and get a grasp of what it is doing and why |
17:51:00 | FromDiscord | <Phil> In reply to @ringabout "Sounds like a good": Best I can do is talk at you in english 😛 |
17:51:21 | Zevv | if the playground wasn't broken you could run it at https://play.nim-lang.org/#ix=4gLj |
17:51:45 | FromDiscord | <mantielero (mantielero)> Did you see the issue I raised? |
17:52:02 | Zevv | yes, this is what I answered to, sin't it? |
17:52:09 | FromDiscord | <mantielero (mantielero)> I think you are still missing capturing the asterisk |
17:52:31 | Zevv | @["This is a comment"] |
17:54:07 | FromDiscord | <mantielero (mantielero)> I mean, you are matching `"("` then whatever is not `")"` and finally you match `")"` |
17:54:41 | Zevv | no, whatever is not "*)" |
17:54:48 | Zevv | 1 - "*)" |
17:55:27 | Zevv | you were close, but you were only capturing one of those |
17:55:31 | FromDiscord | <mantielero (mantielero)> But I am trying to match\: `"("`, then whatever is not `")"` and finally\: `")"`. |
17:56:07 | Zevv | yes, but you match only one. You need to change >(1-"*)") into >*(1-"*)") |
17:56:15 | Zevv | > capture * zero-or-more |
17:56:29 | Zevv | you almost had it right |
17:56:42 | Zevv | but it's crappy to read with all the quotes and brackets |
17:57:01 | FromDiscord | <mantielero (mantielero)> Ah ok. I see the answer in the Issue |
17:57:10 | Zevv | more white space helps |
17:57:10 | Zevv | comment <- "(*" * > * (1 - "*)" ) * "*)" |
17:59:05 | Zevv | you good? |
18:00:06 | FromDiscord | <mantielero (mantielero)> Yeah. In fact I see that my example was right. The issue |
18:01:17 | FromDiscord | <mantielero (mantielero)> The issue was that I was capturing the string, so it was available within variable `comm`, not under `captures`! |
18:01:31 | Zevv | your example was almost right |
18:01:34 | Zevv | you missed a * |
18:02:05 | Zevv | run your example with -d:npegTrace |
18:02:25 | Zevv | you will see it fails afte the first char of the comment body, expecting the *) |
18:02:29 | FromDiscord | <vestel> Can I forward declare a type? |
18:02:49 | Zevv | only in the same type block |
18:03:06 | Zevv | welcome to nim, one of the things that has hunted me for years |
18:03:35 | FromDiscord | <vestel> In reply to @Zevv "welcome to nim, one": how? |
18:03:51 | FromDiscord | <mantielero (mantielero)> Yeah true |
18:03:52 | FromDiscord | <mantielero (mantielero)> I see it |
18:03:54 | FromDiscord | <mantielero (mantielero)> Very useful the npegTrace |
18:04:01 | Zevv | good, good |
18:04:35 | Zevv | vestel: well, almost every seriousle large project ends up with a file types.nim |
18:04:52 | Zevv | which has a lot of types from all over the place in one type block |
18:05:00 | Zevv | to allow circular dependencies on types |
18:05:19 | Zevv | some people told me my design is wrong if i have circular types, so it must be me |
18:05:20 | FromDiscord | <mantielero (mantielero)> I understand now |
18:05:34 | Zevv | great happy parsing |
18:08:11 | * | jjido joined #nim |
18:08:15 | FromDiscord | <mantielero (mantielero)> A completely different topic. Wrapping a C++ class, how is the appropriate way to override a method declared in Nim? |
18:09:11 | FromDiscord | <hmmm> sent a code paste, see https://play.nim-lang.org/#ix=4gLr |
18:12:04 | * | rockcavera joined #nim |
18:13:13 | FromDiscord | <Rika> no |
18:13:16 | FromDiscord | <Rika> cannot |
18:18:53 | FromDiscord | <hmmm> bummer, but turns out I didn't really need it |
18:34:15 | FromDiscord | <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:37 | FromDiscord | <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:46 | FromDiscord | <tope> sent a code paste, see https://play.nim-lang.org/#ix=4gLz |
18:52:17 | FromDiscord | <hmmm> when is compiletime if and static is compiletime var right? |
18:53:16 | FromDiscord | <hmmm> pretty neat I thought it wasn't possible |
18:56:18 | FromDiscord | <Phil> static is compile time expression I think could be more accurately expressed as you can also statically evaluate other stuff |
19:02:57 | FromDiscord | <Rika> That is possible yes |
19:03:07 | FromDiscord | <Rika> I assumed you wanted it runtime so I said no |
19:04:38 | FromDiscord | <hmmm> you assumed correctly 😎 |
19:39:39 | ehmry | is it possible to programatically import a module from and inspect something in it? |
19:41:36 | * | pro joined #nim |
19:42:09 | ehmry | I 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:22 | FromDiscord | <guttural666> naively I'd say that a parser + the nim compile time introspection facilities would be required for something like that |
19:50:27 | ehmry | this would be a lot easier if I didn't have to deal with generics |
20:07:35 | pbotfullerton | Is 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:11 | FromDiscord | <planetis> There is &= |
20:09:31 | pbotfullerton | Sweet, thank you |
20:11:25 | FromDiscord | <jmgomez> In reply to @ehmry "this would be a": what are you trying to do? Cant you pass the symbol as parameter? |
20:11:48 | FromDiscord | <jmgomez> Im looking at ## for generating docs. But how do you suppose to use it with imporc? |
20:12:42 | ehmry | jmgomez: I have a code generator that generates generic types, but I think I can specify the generic parameter at code generation time |
20:13:26 | FromDiscord | <jmgomez> In reply to @jmgomez "Im looking at ##": Ok, just at the end rather than in a new line |
20:14:27 | FromDiscord | <jmgomez> In reply to @ehmry "<@726017160115126333>: I have a": Like expand/bake an existing generic? |
20:15:43 | ehmry | I generate types that sometimes contain a member that is generic, and so the generality has to propagate outwards |
20:16:40 | ehmry | I think what I am doing here is too complicated |
20:19:18 | FromDiscord | <jmgomez> cant you just check the ast? IIRC generics has a nnkGenericParams or something like that node |
20:33:11 | ehmry | I 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:16 | FromDiscord | <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:24 | FromDiscord | <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:28 | FromDiscord | <Cheesy Brik> Does nim make local paths absolute when compiling production? Cus I need local paths to stay local. |
20:41:52 | FromDiscord | <Cheesy Brik> (edit) "Does nim make local paths ... absolute" added "to" |
20:45:33 | FromDiscord | <Tuatarian> for some reason, this macro throws a compile error |
20:45:40 | FromDiscord | <Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=4gM1 |
20:45:52 | FromDiscord | <Tuatarian> I'm trying here to build an AST for a `seq[string]` |
20:46:01 | FromDiscord | <Tuatarian> I tried a simpler verison of this, namely |
20:46:08 | FromDiscord | <Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=4gM2 |
20:46:09 | FromDiscord | <Tuatarian> which directly builds the literal and works perfectly |
20:46:50 | FromDiscord | <Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=4gM3 |
20:47:00 | FromDiscord | <Tuatarian> which is weird since the eabove code works perfectly without error |
21:09:06 | * | jmdaemon joined #nim |
21:11:02 | FromDiscord | <Tuatarian> one useful piece of info is that it gives a compile error before `echo treeRepr result` finishes executing |
21:11:27 | FromDiscord | <Tuatarian> (edit) "error before `echo treeRepr result` finishes executing" => "error, but really not sure why this could be happening" |
21:11:36 | FromDiscord | <Tuatarian> it dislikes my stringificationsomewhere |
21:31:25 | FromDiscord | <Tuatarian> I see the issue |
21:31:48 | FromDiscord | <Tuatarian> one of the arguements of `contains` is a `HSlice[U, V]` |
21:32:09 | FromDiscord | <Tuatarian> sent a code paste, see https://paste.rs/w5w |
21:32:11 | FromDiscord | <Tuatarian> ie not flat |
21:33:10 | FromDiscord | <Tuatarian> and the fix then is to instead of using `$` for stringification, use `repr(NimNode)` |
21:41:07 | FromDiscord | <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:23 | FromDiscord | <vindaar> (the node kinds may differ of course) |
21:44:06 | FromDiscord | <vindaar> not entirely certain of the top of my head, but I think `$` for NimNode is only valid for literals |
21:44:57 | FromDiscord | <Elegantbeef> Symbols and idents aswell |
21:45:01 | FromDiscord | <Elegantbeef> just use `repr` |
21:54:02 | FromDiscord | <Tuatarian> yeah |
21:54:20 | FromDiscord | <Tuatarian> I'm extremely unfamiliar with macros/templates, this is my first time seeing this error |
21:55:08 | FromDiscord | <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:18 | FromDiscord | <Tuatarian> but honestly |
21:55:28 | FromDiscord | <Tuatarian> the move is to avoid using `$` and just stick with repr |
21:56:46 | FromDiscord | <Tuatarian> especially since the thing I was making was a bracket expression |
21:57:01 | FromDiscord | <Tuatarian> I didn't realize for a bit that the error was not at all related to my tree construction |
22:10:56 | FromDiscord | <QuiteQuietQ> sent a long message, see http://ix.io/4gMm |
22:11:18 | FromDiscord | <QuiteQuietQ> sent a long message, see http://ix.io/4gMn |
22:12:32 | FromDiscord | <Elegantbeef> That's a table constructor |
22:12:49 | FromDiscord | <Elegantbeef> It's a syntax that creates an array that you then can feed to a proc |
22:13:06 | FromDiscord | <Elegantbeef> So you can do like `import std/tables; var a = {"a": 100, "b": 200}.toTable` |
22:17:18 | FromDiscord | <QuiteQuietQ> however, it feels confusing, since it uses curly brackets like sets, also that it changes meaning according to what is inside |
22:17:46 | FromDiscord | <QuiteQuietQ> what type should I use when I am using a table constructor? |
22:17:53 | FromDiscord | <Elegantbeef> `{a: b}` is a table constructor |
22:17:56 | FromDiscord | <Elegantbeef> `{a, b}` is a set |
22:17:59 | FromDiscord | <Elegantbeef> It's not too complicated |
22:18:12 | FromDiscord | <ChocolettePalette> This is so called "Unix Way", which is an opposite to Apple's ecosystem |
22:18:27 | FromDiscord | <QuiteQuietQ> true, I just need to get it under my skin |
22:18:28 | FromDiscord | <Elegantbeef> A table constructor is for when you want an ergonomic key value pair |
22:18:41 | FromDiscord | <QuiteQuietQ> like Python dict? |
22:19:34 | FromDiscord | <Elegantbeef> It's just a different syntax for an array |
22:20:31 | FromDiscord | <Elegantbeef> `{"a": 100, "b": 200} == [("a", 100), ("b", 200)]`↵`{MyObject(): bleh, MyObject(): blugh} == [(MyObject(), bleh), (MyObject(), blugh)]` |
22:20:34 | FromDiscord | <Elegantbeef> It's just syntax sugar |
22:21:23 | FromDiscord | <QuiteQuietQ> get it |
22:21:48 | FromDiscord | <QuiteQuietQ> are there other tricks with syntactic sugar for creating collections? |
22:22:01 | FromDiscord | <Elegantbeef> Not that i can think of |
22:22:17 | FromDiscord | <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:23 | FromDiscord | <Elegantbeef> Be it actual tables or httpheaders |
22:22:29 | FromDiscord | <Elegantbeef> It's not specialised for a type |
22:24:11 | FromDiscord | <QuiteQuietQ> aha, thanks |
22:27:16 | FromDiscord | <QuiteQuietQ> sent a long message, see http://ix.io/4gMr |
22:28:05 | FromDiscord | <QuiteQuietQ> i know that the GenericsArray is nonsense 😄 |
22:28:07 | FromDiscord | <Elegantbeef> `n: static int` |
22:28:29 | FromDiscord | <Elegantbeef> `n: int` is a generic constraint of a type not a value |
22:28:40 | FromDiscord | <Elegantbeef> `n: static int` is a value |
22:29:20 | FromDiscord | <QuiteQuietQ> wow, it works |
22:29:23 | FromDiscord | <QuiteQuietQ> lol, thanks! |
22:36:11 | FromDiscord | <emmicat> wait is that the irc bridge |
22:36:27 | FromDiscord | <Elegantbeef> Matrix |
22:37:00 | FromDiscord | <emmicat> oHhhhh cool |
22:47:30 | FromDiscord | <tope> sent a code paste, see https://play.nim-lang.org/#ix=4gMv |
22:49:20 | FromDiscord | <ChocolettePalette> What does the compiler say? |
22:50:35 | FromDiscord | <tope> sent a code paste, see https://play.nim-lang.org/#ix=4gMx |
22:50:48 | FromDiscord | <Elegantbeef> It's an issue with the static generic parameter reasoning |
22:51:48 | FromDiscord | <Elegantbeef> It doesnt evaluate complex expressions in generic parameters |
22:51:56 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4gMA |
22:52:10 | FromDiscord | <Elegantbeef> It's not great but it does atleast force it to work |
22:52:17 | FromDiscord | <Elegantbeef> I have been meaning in looking at this bug |
22:55:38 | FromDiscord | <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:13 | FromDiscord | <Elegantbeef> Until this bug gets fixed yes |
22:57:35 | FromDiscord | <Marak> Howdy Y'all |
22:58:24 | FromDiscord | <tope> sent a code paste, see https://play.nim-lang.org/#ix=4gMB |
22:58:55 | FromDiscord | <tope> but I expect it's related to using expressions in return type |
22:58:56 | FromDiscord | <Elegantbeef> Without context cannot say much |
23:00:32 | FromDiscord | <Elegantbeef> The issue with `Phantom[pred(N, 1)]` is likely a simple check inside semtypeinst to evaluate expressions after instantiating the procedure |
23:01:02 | FromDiscord | <Elegantbeef> Sorry seminst |
23:04:08 | FromDiscord | <dlesnoff> sent a long message, see http://ix.io/4gME |
23:07:36 | FromDiscord | <dlesnoff> Sorry for this sudden and mysterious comment, I will explain myself better tomorrow. |
23:09:24 | FromDiscord | <Elegantbeef> `float` is 64bit regardless |
23:09:33 | FromDiscord | <Elegantbeef> Nim only has 32 and 64bit floats |
23:09:58 | FromDiscord | <Elegantbeef> Personally it's Sentinel -\> Option -\> Exception, though depends on the API |
23:10:05 | FromDiscord | <Elegantbeef> I very much prefer exception's semantics |
23:10:09 | FromDiscord | <Elegantbeef> I dislike option/result semantics |
23:11:40 | madprops | you're the exception |
23:13:50 | FromDiscord | <Elegantbeef> Uhh |
23:14:34 | FromDiscord | <Elegantbeef> I know you're likely joking, but I've even see people that use rust say they prefer exception semantics |
23:27:45 | FromDiscord | <Tuatarian> imo option semantics are a little unnecessarily verbose |
23:28:43 | ehmry | stack unwinding seems like more work than checking an option |
23:30:44 | FromDiscord | <Yepoleb> more work for who? |
23:31:36 | ehmry | ok, less work and more waiting for something to finish |
23:31:58 | FromDiscord | <Yepoleb> you think stack unwinding is slow? |
23:32:25 | ehmry | I think its more expensive |
23:32:52 | ehmry | and if you are consistent with options than there is a flow to writing that code |
23:35:43 | ehmry | option checking can be inlined, throwing an exception cannot |
23:35:55 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4gML |
23:36:20 | FromDiscord | <Yepoleb> but you don't throw exceptions constantly |
23:36:27 | FromDiscord | <Yepoleb> unless python xD |
23:36:39 | FromDiscord | <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:21 | ehmry | i'm grumpy about exceptions because I've had to look inside libunwind |
23:37:53 | ehmry | but whatever, as long as its not python |
23:38:37 | FromDiscord | <Yepoleb> even then, a few µs of unwind time when an exception actually happens are negligible |
23:39:03 | FromDiscord | <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:31 | FromDiscord | <Elegantbeef> if `d` is a ref aswell you need to deref that↵(@voidwalker) |
23:52:56 | FromDiscord | <Elegantbeef> Yea exceptions can be more expensive, but they also have more sensible semantics imo |
23:53:19 | FromDiscord | <Elegantbeef> There are ways to make them less expensive, not that Nim does it |
23:53:36 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4gMN |
23:54:29 | FromDiscord | <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:56 | FromDiscord | <Elegantbeef> Is BenCodeObj a ref? |
23:55:19 | FromDiscord | <Elegantbeef> If so a copy doesnt deep copy so all the refs are the same |
23:55:26 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4gMO |
23:55:32 | FromDiscord | <Elegantbeef> Well there you go |
23:55:50 | FromDiscord | <voidwalker> deep copy = go all the way down ? |
23:55:53 | FromDiscord | <Elegantbeef> `filetmp.d["path"].l` accesses the same `BenCodeObj` |
23:55:54 | FromDiscord | <Elegantbeef> Yep |
23:56:29 | FromDiscord | <Elegantbeef> A normal copy copies all value types, which means the pointer to the ref is copied |
23:56:37 | FromDiscord | <Elegantbeef> It doesnt go down the tree copying all data |
23:57:33 | FromDiscord | <albassort> can someone recommend me a database server that wont take years of my life off from sheer frustration |