00:22:21 | FromGitter | <nepeckman> Is it possible to create a type for compile time? I'd like to keep some NimNodes together in an object for a set of compile time procs |
00:28:40 | FromGitter | <nepeckman> I tried putting the type declaration under a static statement, doesn't seem to help the procs know about the type |
00:28:55 | FromGitter | <timotheecour> use a macro |
00:29:28 | FromGitter | <timotheecour> ```macro foo(): untyped = ⏎ quote do: ⏎ type Foo = object``` [https://gitter.im/nim-lang/Nim?at=5c4cfb68975714406b4925f7] |
00:29:51 | FromGitter | <nepeckman> These procs are running at compile time though, won't that macro be too late? |
00:30:05 | FromGitter | <timotheecour> u can call a macro at CT |
00:30:11 | FromGitter | <timotheecour> try |
00:30:33 | FromGitter | <nepeckman> So write that macro and immediately invoke? |
00:32:53 | FromGitter | <nepeckman> ```code paste, see link``` ⏎ ⏎ This doesn't compile [https://gitter.im/nim-lang/Nim?at=5c4cfc35c2dba5382e93475b] |
00:33:14 | FromGitter | <timotheecour> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c4cfc4a41775971a08c8578] |
00:34:18 | FromGitter | <timotheecour> gtg |
00:37:37 | * | oculux quit (Remote host closed the connection) |
00:38:23 | * | oculux joined #nim |
00:48:11 | * | pagnol quit (Ping timeout: 246 seconds) |
00:57:45 | * | zachk quit (Quit: Leaving) |
01:14:26 | * | libman_ joined #nim |
01:15:20 | * | oculux quit (Quit: blah) |
01:15:24 | * | darithorn_test joined #nim |
01:18:10 | * | darithorn_test quit (Remote host closed the connection) |
01:22:58 | * | crem quit (Ping timeout: 272 seconds) |
01:24:49 | * | crem joined #nim |
01:26:00 | * | oculux joined #nim |
01:30:57 | * | xet7 quit (Remote host closed the connection) |
01:39:26 | * | oculux quit (Quit: blah) |
01:41:19 | * | elrood quit (Remote host closed the connection) |
02:03:21 | * | rect0x51 joined #nim |
02:03:23 | * | zachcarter quit (Ping timeout: 245 seconds) |
02:08:26 | * | ng0_ joined #nim |
02:11:59 | * | ng0 quit (Ping timeout: 256 seconds) |
02:14:52 | * | Tyresc quit (Quit: WeeChat 2.4-dev) |
02:26:57 | * | oculux joined #nim |
02:41:53 | * | gangstacat quit (Remote host closed the connection) |
02:42:31 | * | zachcarter joined #nim |
02:45:56 | * | crem quit (Ping timeout: 240 seconds) |
02:48:24 | * | crem joined #nim |
03:02:21 | * | banc quit (Quit: Bye) |
03:08:02 | * | rect0x51 quit (Quit: WeeChat 2.3) |
03:18:28 | * | ng0_ quit (Quit: Alexa, when is the end of world?) |
03:22:59 | * | banc joined #nim |
03:30:31 | * | smitop quit (Quit: Connection closed for inactivity) |
03:52:00 | * | crem quit (Ping timeout: 252 seconds) |
03:53:44 | * | crem joined #nim |
04:10:56 | * | crem quit (Ping timeout: 240 seconds) |
04:12:14 | * | crem joined #nim |
04:33:33 | * | darithorn quit (Quit: Leaving) |
04:36:18 | * | darithorn_ joined #nim |
04:36:35 | * | darithorn_ quit (Remote host closed the connection) |
04:41:06 | * | darithorn_ joined #nim |
04:41:14 | * | darithorn_ quit (Remote host closed the connection) |
05:08:32 | * | nsf joined #nim |
05:21:02 | * | noonien quit (Quit: Connection closed for inactivity) |
05:22:52 | * | Marumoto joined #nim |
05:25:39 | * | Marumto quit (Ping timeout: 244 seconds) |
05:35:57 | * | oz quit (Ping timeout: 252 seconds) |
05:40:18 | * | dddddd quit (Remote host closed the connection) |
05:50:40 | * | wildlander quit (Excess Flood) |
05:51:34 | * | wildlander joined #nim |
06:02:43 | * | oz joined #nim |
06:08:38 | * | Marumoto quit (Remote host closed the connection) |
06:18:35 | * | nsf quit (Quit: WeeChat 2.3) |
06:25:08 | FromGitter | <bung87> ```code paste, see link``` ⏎ ⏎ what am I missing here? image data send incorrectly [https://gitter.im/nim-lang/Nim?at=5c4d4ec478e1ed4103972d5f] |
06:27:36 | * | narimiran joined #nim |
06:46:07 | leorize | narimiran: autocomplete arrived https://github.com/alaviss/nim.nvim |
06:46:50 | narimiran | leorize: thanks for ruining my free sunday! :P |
06:48:37 | leorize | :P |
07:02:50 | libman_ | nim vim zim Lim |
07:14:38 | libman_ | Reminder: https://github.com/nim-lang/Nim/wiki/Editor-Support needs updating |
07:15:38 | narimiran | leorize: "Add this to your configuration file to register the autocomplete source" sorry for the stupid question, but what file is that? |
07:15:55 | leorize | neovim configuration file |
07:20:33 | narimiran | leorize: i guess i'm doing something wrong because i can't get the behaviour you showed in that asciinema video |
07:21:47 | leorize | what do you get? |
07:21:51 | narimiran | nothing :D |
07:22:28 | leorize | this is why I don't share plugins :P |
07:22:36 | leorize | can you give me you :messages output? |
07:22:38 | leorize | your* |
07:22:50 | narimiran | nah, this is on me, i'm complete nvim newbie |
07:23:00 | leorize | I was joking :P |
07:23:09 | leorize | did you get the semantic highlighter working? |
07:23:18 | narimiran | let us go on private, to not spam it here |
07:33:21 | * | lritter joined #nim |
07:48:55 | * | xet7 joined #nim |
07:53:58 | * | Perkol joined #nim |
07:55:25 | Perkol | In jester, I get a crash when I try to access static file https://bpaste.net/show/09cc91e15b71 |
07:55:33 | Perkol | What may be the reason? |
07:59:44 | Araq | jester.nim(177) |
08:03:36 | * | Trustable joined #nim |
08:10:09 | Perkol | It thinks it doent exist? |
08:14:11 | Perkol | Hm, it serves css normally, bot not this file |
08:15:35 | * | fanta7531 joined #nim |
08:21:45 | Perkol | This file is an ELF executable, other filetypes work. Should I submit bugreport? |
08:25:19 | * | Trustable quit (Remote host closed the connection) |
08:35:29 | Araq | ensure it's not a permission problem first |
08:35:53 | FromGitter | <Bennyelg> Hey, where can I find a simple guide of 'How create an nim code and import it on python' ? |
08:44:06 | FromGitter | <bung87> https://github.com/bung87/nim-pymod |
08:46:09 | FromGitter | <bung87> https://github.com/yglukhov/nimpy |
08:46:54 | FromGitter | <Bennyelg> thank you! |
08:57:25 | FromGitter | <Bennyelg> `````` [https://gitter.im/nim-lang/Nim?at=5c4d72757b68f94102268b18] |
09:06:16 | FromGitter | <Varriount> Araq: is there any documentation on how to use the regions Garbage collector? |
09:08:37 | * | fanta7531 quit (Quit: fanta7531) |
09:19:30 | Araq | it is not a GC, you need to free memory regions explicitly |
09:21:39 | Perkol | How do I get random element from set? |
09:26:18 | narimiran | Perkol: does it have to be random, or can it be any element? |
09:32:58 | Perkol | any element |
09:35:26 | * | nsf joined #nim |
09:35:54 | narimiran | ugly hack: `let a = mySet.pop` (followed by `mySet.incl a`) |
09:38:21 | Araq | no he wants the pop, no need to incl it back |
09:38:39 | * | Vladar joined #nim |
09:39:16 | narimiran | i didn't know if Perkol just wants to have some element (while it stays in the set), or a simple pop is what he's looking for |
09:40:00 | Araq | most (all?) algorithms I know ask for an arbitrary set element and then delete it from the set |
09:41:20 | narimiran | eh, i guess i overanalyzed "how do i *get*", thinking that otherwise he would write "how do i remove" :) |
09:51:47 | FromGitter | <Varriount> Araq: So is there any documentation on how to use it properly? |
10:03:33 | Araq | I wrote a blog post about it but it's still being refined |
10:03:56 | * | vonHabsi quit (Ping timeout: 250 seconds) |
10:03:57 | Araq | anyhow, gcbench or thavlak have been patched to show --gc:regions work |
10:05:12 | Araq | and if you use threading, it's particularly easy, every thread has 'withScratchRegion' in its main loop and the .gcsafe effect ensures you cannot mix memory regions |
10:05:34 | * | vonHabsi joined #nim |
10:09:38 | * | fanta7531 joined #nim |
10:13:39 | * | STX_ joined #nim |
10:14:02 | * | STX_ is now known as Guest13981 |
10:19:57 | * | Guest13981 left #nim (#nim) |
10:41:47 | * | narimiran quit (Ping timeout: 246 seconds) |
10:45:46 | * | elrood joined #nim |
10:47:26 | Zevv | Araq, on friday you were having a lengthy discussion with timotheecour about return vs result and proving correctness. I do understand your point here, but I was wondering: how could you ever cope with having exceptions in a language if your highest goal is to have things provable? Aren't exceptions even worse then premature returns, because you can't even *see* in your code where it might drop out of |
10:47:32 | Zevv | only-god-knows-how-many stack frames? |
10:50:03 | * | zachcarter quit (Ping timeout: 245 seconds) |
10:53:19 | * | oculux quit (Remote host closed the connection) |
10:54:26 | * | oculux joined #nim |
10:57:02 | Araq | Zevv: they are the same as 'return', read my blog post about "quirky exceptions" |
10:58:03 | FromGitter | <Clyybber> Araq: Are you hoping to merge quirky-exceptions anytime soon? |
10:59:07 | * | smitop joined #nim |
11:00:54 | Araq | well it's a rather clean patch, could be merged today. But I don't know if it's good. I'm still thinking about an escape analysis that would make them safer to use. |
11:06:59 | FromGitter | <Clyybber> Great to hear. It sounds good to me at least. But I now nothing about escape analysis so :D |
11:07:10 | FromGitter | <Clyybber> @leorize Is this the one? https://github.com/baabelfish/nvim-nim |
11:08:17 | FromGitter | <Clyybber> nvrmind, found your one |
11:11:34 | * | pagnol joined #nim |
11:23:57 | * | aguspiza joined #nim |
11:31:36 | * | dddddd joined #nim |
11:41:24 | * | Perkol quit (Remote host closed the connection) |
11:43:22 | Araq | Zevv: or actually, you are right, you don't "see" them like you see 'return' but we have exception tracking in the language to fight it |
11:47:51 | * | zachcarter joined #nim |
11:52:08 | * | zachcarter quit (Ping timeout: 245 seconds) |
11:59:46 | Zevv | I was just reading up on that yes |
12:03:28 | Zevv | I guess things get hairy with callback functions etc, hard to infere effects there |
12:03:32 | * | PMunch joined #nim |
12:09:12 | * | stefanos82 joined #nim |
12:12:15 | * | leorize quit (Quit: WeeChat 2.3) |
12:12:25 | * | leorize joined #nim |
12:20:52 | * | pagnol quit (Ping timeout: 250 seconds) |
12:33:30 | * | MyMind joined #nim |
12:34:56 | * | Sembei quit (Ping timeout: 240 seconds) |
12:36:26 | PMunch | "Warning, the .this pragma is deprecated" did it get replaced with something, or did we miss some really nice functionality there? |
12:38:03 | leorize | nope, it's not replaced by anything |
12:38:37 | Zevv | commit b4e5c9d0 Aug 9: "deprecate the .this pragma" |
12:41:02 | Zevv | leorize: add you plugin to the editor support page on the github wiki! |
12:43:21 | leorize | I think I should document the plugin properly before adding it there :P |
12:43:33 | Zevv | documentation is for sissies |
12:43:52 | Zevv | vim plugins for the masses! |
12:45:08 | * | dddddd quit (Ping timeout: 250 seconds) |
12:48:01 | leorize | well, I guess I'll add it later :P |
12:48:50 | * | dddddd joined #nim |
12:53:52 | PMunch | leorize :( Why was it deprecated though? Such a nice feature when doing OO stuff |
12:54:06 | leorize | Araq: ^ |
12:59:10 | * | Trustable joined #nim |
13:07:50 | elrood | you know a language is not yet mature when things get deprecated without a link to any preceding discussion |
13:09:46 | * | vonHabsi quit (Ping timeout: 272 seconds) |
13:15:46 | * | Yardanico quit (Quit: No Ping reply in 180 seconds.) |
13:17:12 | * | Yardanico joined #nim |
13:22:08 | FromGitter | <kaushalmodi> PMunch: https://github.com/nim-lang/Nim/commit/b4e5c9d075d9c2ef6192749b02738966b3dc943d |
13:23:05 | * | nc-x joined #nim |
13:23:16 | FromGitter | <kaushalmodi> I haven't used that pragma, but based on that commit, looks like it provided just some syntactic sugar earlier and now you need to prefix the "scope" (like `obj.elem`)? |
13:24:11 | FromGitter | <kaushalmodi> elrood: Looks like the reason for deprecation is in that commit and changelog. |
13:24:22 | nc-x | IIRC the reason for deprecation was that {.this.} had bugs related to generics, there is `using`, and Araq said that in the future it could probably be implemented as a macro. |
13:26:23 | PMunch | kaushalmodi, {.this: X.} was used to set the name of the first argument as the scope of procedures. Meaning you wouldn't have to do "obj.field" within those functions |
13:27:23 | FromGitter | <kaushalmodi> PMunch: I believe there was a package that did that |
13:28:00 | PMunch | Hmm, I can't find anything about `using` |
13:28:55 | elrood | kaushalmodi, i've seen that commit. Zevv mentioned it earlier, and it's reasonably easy to find anyways. reason: yes, link to any background info, issue, exchange of opinions: no |
13:31:43 | FromGitter | <kaushalmodi> Punch: there was a package that defined a macro .. let's say `with`, that allowed doing: |
13:31:48 | FromGitter | <kaushalmodi> `````` |
13:31:57 | FromGitter | <kaushalmodi> Argh, cannot type on mobile |
13:32:26 | FromGitter | <kaushalmodi> `with a:\n echo b # echoes a.b` |
13:32:57 | FromGitter | <kaushalmodi> Does someone remember the name? |
13:36:00 | * | nsf quit (Quit: WeeChat 2.3) |
13:46:47 | * | nc-x quit (Ping timeout: 256 seconds) |
13:47:06 | * | nc-x joined #nim |
13:47:16 | nc-x | PMunch: https://nim-lang.org/docs/manual.html#statements-and-expressions-using-statement |
13:47:23 | nc-x | elrood: it was discussed a lot on gitter/irc before being deprecated |
13:49:03 | * | zachcarter joined #nim |
13:49:12 | elrood | a link to that discussion naturally belongs into the commit message for a language that's aiming to be ready for a 1.0 release is what i was saying, nc-x |
13:49:26 | PMunch | Hmm, so `using` only saves some type typing |
13:50:11 | PMunch | That's not as annoying as having a procedure meant for an object and having the specify the name of the parameter of the object every time you need to use some state of the object though.. |
13:50:50 | * | nc-x quit (Client Quit) |
13:53:57 | * | zachcarter quit (Ping timeout: 268 seconds) |
14:10:11 | Araq | elrood: I agree completely but it was deprecated some time ago already, nowadays there would have been an RFC covering it |
14:10:37 | Araq | plus it always had to be enabled explicitly. |
14:11:23 | Araq | we need to be able to remove features that don't pull in their weight. |
14:12:57 | PMunch | this: self is such a convenient feature though.. |
14:13:09 | Araq | PMunch: I feel your pain but this feature should never have made it, due to its poor quality |
14:13:43 | PMunch | Are there any options that get me kind of the same function? |
14:14:47 | Araq | you can write a macro that transforms the proc that uses 'system.compiles' to see if 'x' should be 'self.x' |
14:14:58 | Araq | but I never tried to do that :-) |
14:15:55 | Araq | I think .self turned the language past its breaking point, even "freedom of boilerplate" can be taken too far |
14:16:13 | Araq | bbl |
14:20:11 | * | vonHabsi joined #nim |
14:21:02 | * | narimiran joined #nim |
14:34:18 | * | stefanos82 quit (Remote host closed the connection) |
14:49:00 | * | Ven`` joined #nim |
14:56:22 | * | zachcarter joined #nim |
14:58:07 | * | gangstacat joined #nim |
14:58:13 | * | gangstacat quit (Remote host closed the connection) |
14:58:37 | * | gangstacat joined #nim |
15:00:46 | * | zachcarter quit (Ping timeout: 250 seconds) |
15:16:39 | * | PMunch quit (Remote host closed the connection) |
15:30:42 | * | ng0 joined #nim |
15:31:07 | FromGitter | <kaushalmodi> finally remembered! |
15:31:10 | FromGitter | <kaushalmodi> PMunch: https://github.com/citycide/cascade ? |
15:40:16 | FromGitter | <zetashift> that's pretty handy actually |
15:46:31 | * | fanta7531 quit (Quit: fanta7531) |
15:55:45 | * | zachcarter joined #nim |
15:59:56 | * | zachcarter quit (Ping timeout: 240 seconds) |
16:02:33 | * | fanta7531 joined #nim |
16:15:44 | FromDiscord_ | <exelotl> it would be lovely if a 'with foo: ...' macro existed to fill the role of {.this:foo.} but such a macro seems really hard to get right |
16:17:34 | FromDiscord_ | <exelotl> it needs to handle every kind of node, transform x into foo.x but only if foo.x is valid, but also not if x exists at a lower scope |
16:18:12 | Zevv | Why not if x exists at a larger scope? |
16:18:45 | Zevv | The rule could simple be that the inner hides the outer |
16:19:38 | FromGitter | <kaushalmodi> Zevv, exelotl: may be an RFC is in order :) |
16:19:45 | leorize | I don't think such a macro is too complex |
16:19:51 | FromDiscord_ | <exelotl> I think a local x should take precedence over foo.x, but foo.x should take precedence over a global x |
16:19:55 | FromGitter | <kaushalmodi> I don't know Nim enough to design such a macro, but can surely test it out |
16:19:56 | FromDiscord_ | <exelotl> if that's clear |
16:19:58 | leorize | but iirc pascal people seems to dislike the idea of `with` |
16:20:14 | FromGitter | <kaushalmodi> leorize: `with` is beautiful |
16:20:27 | FromGitter | <kaushalmodi> *at least in Emacs (Lisp) I see it everywhere* |
16:20:40 | leorize | yea, I used it a lot back when I was initializing structures in pascal |
16:20:42 | FromDiscord_ | <exelotl> JS folks hate it but that's because it's poorly designed in JS |
16:23:50 | leorize | http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-with-is-evil-isn-t-it-td3219144.html |
16:33:31 | * | skellock joined #nim |
16:34:58 | * | smitop quit (Quit: Connection closed for inactivity) |
16:35:02 | * | gsc70cstr joined #nim |
16:36:42 | * | gsc70cstr quit (Quit: leaving) |
16:38:01 | * | zachcarter joined #nim |
16:39:09 | * | narimiran quit (Quit: Leaving) |
16:39:11 | * | gscacco joined #nim |
16:42:29 | * | zachcarter quit (Ping timeout: 244 seconds) |
16:43:21 | * | narimiran joined #nim |
16:44:14 | FromGitter | <Varriount> What is "with" in Pascal? |
16:45:26 | * | zachcarter joined #nim |
16:45:31 | * | pagnol joined #nim |
16:45:45 | * | gscacco quit (Quit: leaving) |
16:46:00 | * | gscacco joined #nim |
16:47:09 | * | gscacco quit (Client Quit) |
16:54:44 | * | livcd quit (Ping timeout: 250 seconds) |
16:55:41 | leorize | Varriount: `with a do x := 10;` == `a.x := 10;` if `x` is a member of `a` |
16:56:38 | narimiran | hmm, doesn't nim have (or it had), `using` or something like that? |
16:56:55 | narimiran | i know i've seen it somewhere, but never used it myself |
16:57:32 | leorize | using is to avoid specifying types for function |
16:57:41 | narimiran | aha! true |
16:57:46 | leorize | no one seem to use it tho |
16:58:01 | narimiran | nobody is using using :) |
17:01:56 | * | livcd joined #nim |
17:06:56 | * | Ven`` quit (Ping timeout: 240 seconds) |
17:15:19 | FromGitter | <Clyybber> I am using `using` |
17:15:44 | FromGitter | <Clyybber> I dont want to have to write "device: VkDevice" all the time |
17:15:50 | FromGitter | <Clyybber> as an example |
17:21:49 | * | pagnol_ joined #nim |
17:22:09 | pagnol_ | can nimble install packages directly from github? |
17:22:16 | narimiran | pagnol_: yep |
17:22:26 | narimiran | `nimble instal <url>` |
17:22:42 | pagnol | I tried that but nimble kept installing an older version, not the one in master |
17:22:54 | pagnol | with https://github.com/niv/websocket.nim |
17:23:11 | pagnol | nimble keeps downloading 0.3.4 |
17:23:13 | federico3 | https://travis-ci.community/c/languages no Nim entry :( |
17:23:25 | narimiran | pagnol: https://github.com/nim-lang/nimble#nimble-install |
17:23:36 | narimiran | specify "@#head" |
17:24:27 | pagnol | oh, thanks |
17:37:43 | zestyr | pagnol: take a look at this package https://github.com/treeform/ws |
17:37:55 | * | nsf joined #nim |
17:38:41 | zestyr | according to treeform, the websocket.nim package isn't very Nim-like, so he created ws |
17:40:53 | * | skellock quit (Ping timeout: 245 seconds) |
17:48:00 | * | pagnol_ quit (Ping timeout: 252 seconds) |
17:48:00 | * | pagnol quit (Ping timeout: 252 seconds) |
18:04:33 | * | ng0 quit (Ping timeout: 256 seconds) |
18:10:43 | * | skellock joined #nim |
18:26:10 | * | skellock quit (Ping timeout: 250 seconds) |
18:27:44 | * | noonien joined #nim |
18:31:07 | * | noonien quit (Client Quit) |
18:50:27 | * | pagnol joined #nim |
18:51:27 | * | skellock joined #nim |
19:01:47 | * | skellock1 joined #nim |
19:05:56 | * | skellock quit (Ping timeout: 240 seconds) |
19:06:20 | * | skellock1 quit (Ping timeout: 272 seconds) |
19:12:57 | FromGitter | <Clyybber> @kaushalmodi exelotl Zevv PMunch I quickly extracted this from citycides cascades: https://gist.github.com/Clyybber/7655fb852dafa701a3ee7847c5b51b10 |
19:13:07 | FromGitter | <Clyybber> Pretty simple as leorize said |
19:14:07 | FromGitter | <Clyybber> Usage is something like this: ⏎ ⏎ ```with someObject: ⏎ someMethodOfThatObj ⏎ someField = 0``` [https://gitter.im/nim-lang/Nim?at=5c4e02ff41775971a09281df] |
19:16:35 | FromGitter | <Clyybber> @kaushalmodi tagging you because it didn't work in the message above |
19:16:56 | Zevv | Clyybber: Ah, I was trying to build my own `with` macro, but you beat me to it |
19:17:41 | Zevv | *but*: I was also traversing the whole AST recursively, wich yours doesn't. Can you handle nested blocks under the "with:" block? |
19:17:50 | FromGitter | <Clyybber> nope |
19:18:20 | Zevv | Then I'll see if I can get this to work! :) |
19:18:49 | FromGitter | <Clyybber> Let me know how it goes :D |
19:18:59 | Zevv | I started too complicated I'm afraid |
19:19:27 | Zevv | I'm recursively looking op all nnkIdent nodes to check if the ident is a member of the given object |
19:20:29 | FromGitter | <Clyybber> Yeah I think you just need to do something like citycide does here (in the commented part of the code I sent) |
19:24:13 | FromGitter | <Clyybber> and then join the statement lists somehow |
19:30:21 | zestyr | that cascade macro looks pretty useful, especially for UI code, thanks for sharing it |
19:32:41 | * | abm joined #nim |
19:35:25 | FromGitter | <kaushalmodi> zestyr: you're welcome :) |
19:36:11 | FromGitter | <kaushalmodi> @Clyybber how does that `with` macro differ from Cascade? |
19:36:46 | FromGitter | <Clyybber> it doesn't "return" |
19:37:23 | FromGitter | <kaushalmodi> Araq: wondering if citycide's Cascade (probably renamed to `with`) would be accepted as an stdlib package |
19:37:30 | FromGitter | <Clyybber> as in you can't do this ⏎ ⏎ ```let someObj = with someObj(): ⏎ someField = 0``` [https://gitter.im/nim-lang/Nim?at=5c4e087a93fe7d5ac0fd574c] |
19:38:03 | FromGitter | <Clyybber> but have to do this: ⏎ ⏎ ```var someObje = someObj() ⏎ with someObj: ⏎ someField = 0``` [https://gitter.im/nim-lang/Nim?at=5c4e089b1b62f126505b8ee5] |
19:38:16 | FromGitter | <kaushalmodi> Understood |
19:38:52 | FromGitter | <Clyybber> @kaushalmodi Cascade can't be used the way that with macro can be used, because it returns |
19:39:04 | Zevv | does anyone know a simple idiomatic snippet for recursively traversing and modifying AST? What I'm doing feels too convoluted |
19:39:14 | FromGitter | <Clyybber> @kaushalmodi Yeah, I think we need a with in the stdlib |
19:39:29 | FromGitter | <Clyybber> Let's see if Zevv or me can come up with something worthy :D |
19:39:56 | Zevv | :) |
19:40:37 | FromGitter | <Clyybber> Zevv I don't know any "idiomatic" way, but I think a while loop should do? |
19:40:58 | FromGitter | <Clyybber> I don't think you can use recursive macros, but I may be wrong |
19:43:36 | Zevv | have something that nests |
19:43:41 | Zevv | and can even nest with itself |
19:44:18 | Zevv | http://paste.debian.net/1062784/ |
19:44:27 | Zevv | its not efficient though, I guess |
19:44:41 | Zevv | Usage is on the bottom: two objects 'foo' and 'bar' |
19:45:04 | Zevv | get passed to the macro. Top of the macro finds the list of field names and places those in a seq[str] - should be some kind if hash of course |
19:45:13 | FromGitter | <Clyybber> Thats awesome |
19:45:27 | Zevv | and then passes the code block to the 'aux' proc which recurses and find all idents which match the field name, and replaces those with a dot expr |
19:46:11 | FromGitter | <Clyybber> Zevv, why should it hash them? |
19:46:46 | Zevv | Line 19 |
19:47:12 | * | lritter quit (Ping timeout: 250 seconds) |
19:48:08 | FromGitter | <Clyybber> Why do you check if the field is valid anyways? |
19:48:29 | FromGitter | <Clyybber> If it isn't the compiler is gonna complain by itself |
19:48:42 | Zevv | Yeah but you'd want to use non-field identifiers as well, right? |
19:49:00 | FromGitter | <Clyybber> Ah, yes |
19:49:01 | Zevv | you could basically throw the whole contents of a proc in a 'with' and forget about it |
19:49:12 | Zevv | so basically it should work kind of the old with pragma |
19:49:28 | Zevv | but this implementation is probably severely broken for all but the most trivial use cases |
19:50:23 | Zevv | I'll do some cleaning up |
19:53:55 | * | nsf quit (Quit: WeeChat 2.3) |
19:59:17 | Zevv | https://github.com/zevv/nimwith/blob/master/with.nim |
20:02:30 | FromGitter | <Clyybber> Oh yeah, that looks nice, good job ! |
20:03:27 | Araq | kaushalmodi: unlikely, we polish what we have and only occasionally add modules we need for the infrastructure ('diff' algorithm) |
20:03:36 | Zevv | broken for refs, trying to fix that |
20:04:46 | FromGitter | <Clyybber> @Araq Wouldn't this fit in sugar.nim tho? |
20:04:46 | Zevv | ah araq, could you spare a second if you have time? I'm for the first time doing recursion in a macro, is this the proper way to recurs and modify? https://github.com/zevv/nimwith/blob/master/with.nim |
20:04:57 | Zevv | line 20, proc `aux` |
20:05:33 | Zevv | for each node I do a copyNimNode and then add() all children of the current node. It feels expensive |
20:05:57 | Zevv | but it is consice |
20:06:13 | * | Tyresc joined #nim |
20:07:34 | Araq | Zevv: it's what I do too. a 'recurse' macro would be nice to have though |
20:08:24 | Zevv | hm, one baby step at a time for me, first let me get this to work :) |
20:08:28 | Zevv | thanks |
20:11:56 | Araq | btw "hello world" now works with --gc:destructors |
20:12:07 | Araq | but str.add crashes :P |
20:12:10 | Zevv | \o/ |
20:12:17 | FromGitter | <Clyybber> yay |
20:13:02 | Zevv | Its funny - there is *so* much else you could do in all the time you spent getting constructors to work :/ |
20:13:03 | * | Trustable quit (Remote host closed the connection) |
20:13:17 | FromGitter | <Clyybber> Zevv When you add a common field to both objects, the nested with wont work |
20:13:24 | Araq | really? like what? Zevv |
20:13:29 | FromGitter | <Clyybber> I think constructors are really important |
20:13:30 | Zevv | Clybber: of coruse not :) |
20:13:46 | Araq | the feature is called "destructors" btw |
20:13:57 | FromGitter | <Clyybber> Zevv It could though, I expected it to shadow them |
20:13:58 | Zevv | yeah, of course, destructors, sorry |
20:14:18 | FromGitter | <Clyybber> Araq: I just copied that typo :P |
20:14:51 | Zevv | I'm just nitpicking from my limited world view as someone who never used a destructor in his life. |
20:15:12 | Zevv | And if I never used it, it must be stupid because I never missed it :) |
20:15:43 | FromGitter | <Clyybber> they are a life saviour in complicated big messy interacting codebases |
20:16:24 | Zevv | I can only think of the nightmare implementing this must be. How he hell do you handle the case where an exception causes destructors to trigger which cause an exception themselves? |
20:17:10 | Zevv | Do you then have two pending exceptions? Which one can you catch? What do you do if in that case only half your destructor was ran? |
20:17:38 | FromGitter | <Clyybber> thats why in cpp destructors cant raise exceptions afaik |
20:18:12 | Zevv | and what if they do? are you not allowed to write code in a destructor that *could* raise? Or does it simple not raise where it normally would? |
20:18:19 | FromGitter | <Clyybber> or at least its undefined behaviour |
20:18:28 | Zevv | and there you have it :/ |
20:18:51 | Araq | that's why I researched "quirky exceptions" :-) |
20:19:16 | Araq | in a destructor you set the error indicator. |
20:19:53 | Zevv | UB is one of the reasons I'm sick of C, I'm happy to now use a language which doesn't have too much of that |
20:20:51 | Zevv | Araq: would switching to Q.E. make your destructors more simple? |
20:22:05 | FromGitter | <Clyybber> It would allow destructors to raise: ⏎ ⏎ > Destructors can "raise" exceptions naturally since it merely sets an error flag. There are no special rules like "must not throw in a destructor", everything composes in a nice fashion. |
20:22:28 | Tyresc | Does len() give back the bytecount of the given string? |
20:22:53 | Araq | you don't have to go "all in" with QE, the conclusion I got from QE is that setting an error indicator works. |
20:22:54 | FromGitter | <Clyybber> Zevv So yeah, technically you could have two pending exceptions as in stacking them |
20:23:58 | Zevv | And you catch them both? So then multiple 'except:'s in one block could go off? |
20:25:00 | Zevv | Clybber: `with` macro update, now also works for ref obj |
20:25:17 | FromGitter | <Clyybber> Tyresc Nim uses utf8, so yeah |
20:25:25 | FromGitter | <Clyybber> Zevv Nice |
20:25:51 | Zevv | Problem with dup identifiers is that it gets double dotted |
20:26:20 | pagnol | anyone here familiar with karax? I'm trying to figure out what triggers the rerendering (and what doesn't) |
20:26:50 | Zevv | pagnol: the author is here, I believe |
20:28:14 | Zevv | Clybber: still lots of cases where with macro is still useless - nested objects, for example. |
20:29:56 | Araq | pagnol: every wrapped event causes a redraw() |
20:30:44 | Araq | Zevv: not sure what you mean, but yes? |
20:32:56 | * | narimiran quit (Ping timeout: 240 seconds) |
20:33:11 | FromGitter | <Clyybber> Zevv Can you give an example? |
20:34:24 | Zevv | Clyybber: http://paste.debian.net/1062794/ |
20:34:33 | FromGitter | <Clyybber> Thanks |
20:34:35 | Zevv | 'subfoo' does not work here. But its a bit of a corner case |
20:34:39 | * | narimiran joined #nim |
20:34:44 | Zevv | Araq: sorry, but what question were you answering? :) |
20:35:38 | pagnol | Araq, ah thanks I just arrived at this conclusion myself... I guess I should just call redraw() manually after state changes that happen outside of event handlers? |
20:40:51 | Zevv | clyybber: I might put it in a nimble, is "with" the right name for this thing? Python people might expect something like `with open("x.txt") as f:` instead |
20:43:47 | FromGitter | <Clyybber> I think with is fine. |
20:44:00 | pagnol | Araq, I'm modifying the state in a websocket message handler |
20:44:49 | * | oculux quit (Quit: blah) |
20:44:58 | Araq | yeah redraw() is for cases like this |
20:45:10 | pagnol | ok, thanks |
20:45:23 | Araq | Zevv: your question about QE for destructors |
20:46:02 | * | oculux joined #nim |
20:46:11 | Zevv | Nevermind that, this actually goes a bit over my head I think. I was just wondering if your musings about exceptions were inspired by the destructors work, that's why |
20:46:52 | FromDiscord_ | <exelotl> Zevv: here's how I think `with` should behave regarding local variables with conflicting names: https://gist.github.com/exelotl/a9d1c75012e4287bf9598c084fd7eef5 |
20:48:04 | FromGitter | <Clyybber> exelotl Yep, I think so too. But that is hard to do, I think |
20:48:08 | Zevv | exelotl: yes, that makes sense, but that'll complicate stuff a lot already |
20:48:30 | Zevv | I'm already excited as a toddler that I was able to make this work |
20:48:53 | FromGitter | <Clyybber> But I think not allowing shadowing this way is also fine |
20:52:19 | Zevv | wow, my first nimble |
20:52:21 | Zevv | \o/ |
20:52:36 | FromGitter | <Clyybber> congrats :D |
20:53:20 | * | fanta7531 quit (Quit: fanta7531) |
20:56:20 | Zevv | Bwah, `nimble publish` died on me: ./../../lib/pure/httpclient.nim(222) httpError |
20:56:20 | Zevv | Error: unhandled exception: Connection was closed before full request has been made [ProtocolError] |
20:56:23 | * | TheLemonMan joined #nim |
20:58:24 | * | TheLemonMan quit (Client Quit) |
21:01:48 | Zevv | clyybber: pkg moved to https://github.com/zevv/with. Time for sleep now. |
21:03:09 | FromGitter | <Clyybber> Gn8 |
21:03:20 | * | skellock1 joined #nim |
21:03:55 | narimiran | Zevv: show the result of running your example (in readme) ;) |
21:04:31 | narimiran | and of course, the more examples the better |
21:04:33 | Zevv | narimiran: willdo |
21:05:22 | * | narimiran quit (Remote host closed the connection) |
21:07:35 | * | skellock1 quit (Ping timeout: 246 seconds) |
21:32:33 | * | elrood quit (Remote host closed the connection) |
21:33:06 | * | absolutejam joined #nim |
21:33:24 | absolutejam | evening |
21:33:54 | absolutejam | I'm using the nimyaml/yaml package and trying to use the macro yaml.set_default_value, but it doesn't work on a ref object |
21:34:16 | absolutejam | Is there a way to make it work that I'm missing? |
21:34:23 | FromDiscord_ | <citycide> @kaushalmodi, zestyr: yeah thanks for sharing and glad cascade seems useful |
21:36:11 | FromDiscord_ | <citycide> Zevv: haven't looked at code difference yet but if anything you had is a good change or addition to cascade that'd be cool |
21:36:41 | FromDiscord_ | <citycide> although now I see you published a separate package |
21:49:02 | Araq | absolutejam: I don't know |
21:58:01 | absolutejam | fair enough. I'll have a poke at the source, but it may be a bit whooosh for me |
21:58:33 | absolutejam | just didn't know if there was an easy wayt to deref it or something (I know that's wrong) in this context |
22:16:56 | * | vlad1777d quit (Ping timeout: 240 seconds) |
22:41:11 | FromGitter | <timotheecour> @Clyybber @zevv regarding destructors that throw: it’s not always undefined behavior, as I wrote in that note https://github.com/Araq/blog/issues/1 regarding `quirky exceptions` article: ⏎ ⏎ > there are well defined cases where it's legal to do so since c++11, with noexcept(false) see spec here https://en.cppreference.com/w/cpp/language/destructor |
22:51:31 | * | Vladar quit (Remote host closed the connection) |
23:04:47 | FromGitter | <timotheecour> better idea |
23:05:04 | FromGitter | <timotheecour> (sorry wrong channel, ignore “better idea”) |
23:06:15 | FromGitter | <Varriount> Araq: I'm trying the quirky exceptions branch - the only behavior change I can seem to detect is that exception handler code isn't generated. |
23:15:22 | FromGitter | <Varriount> I try to open a nonexistant file, then catch the resulting error, however the exception still seem to be thrown. |
23:25:29 | * | skellock joined #nim |
23:35:58 | * | abm quit (Quit: Leaving) |