00:00:01 | * | junland quit (Quit: %ZNC Disconnected%) |
00:00:11 | FromDiscord | <slymilano> Is there something like this for Nim? https://github.com/dominikh/filesize |
00:00:50 | * | junland joined #nim |
00:01:07 | FromDiscord | <mratsim> maybe bytes2human, see: https://nimble.directory/search?query=size |
00:04:30 | FromDiscord | <slymilano> Hm... unfortunately I need to parse the string as well, to convert 287.3 MB into it's bytes in int format |
00:26:39 | FromGitter | <Varriount> slymilano: If you need a parser, I recommend NPeg... though that might be a bit too much for simple parsing. |
00:27:34 | FromGitter | <Varriount> Zevv: Did you use any special tool for the diagrams in NPeg's documentation, or did you do it by hand? |
00:41:22 | * | qwertfisch quit (Quit: ZNC - http://znc.in) |
00:41:54 | * | qwertfisch joined #nim |
01:08:09 | * | Hideki_ joined #nim |
01:19:04 | FromDiscord | <slymilano> Thanks Varriount |
01:19:50 | FromGitter | <kayabaNerve> Is there a parser out there that allows conversion between two syntaxes? Like if you enter two NPeg specs, you can convert back and forth. |
01:20:09 | FromGitter | <kayabaNerve> Not really the role of a parser, I just assume if such a 'mutator' exists it's built around a parser. |
01:20:11 | FromDiscord | <slymilano> I'm liking Nim a lot, I have something running and working, probably not idiomatic, but goes to show how quick you can get productive. https://github.com/sergiotapia/torrentinim 2020 is the year Nim will blow up 🙂 |
01:41:33 | FromGitter | <bung87> @kayabaNerve the npeg accept extro param , you can save parsed data to a stack , then you can do what you what |
02:05:47 | FromGitter | <Varriount> @kayabaNerve I don't quite understand what you're describing. Do you mean, something that would take a regular PEG grammar, and convert it into NPeg code? |
02:08:40 | FromDiscord | <exelotl> @slymilano nice! For a quick tip: you can combine the fact that seqs are initialised to empty by default, with the implicit `result` variable, to save quite a few lines |
02:08:40 | FromDiscord | <exelotl> https://cdn.discordapp.com/attachments/371759389889003532/658128737552039966/unknown.png |
02:10:44 | * | rockcavera joined #nim |
02:14:50 | FromGitter | <kayabaNerve> @Varriount Nah. Something that parses X according to PEG grammar XG then outputs Y which can be parsed via YG to a value equivalent to the parsed X |
02:15:04 | FromGitter | <kayabaNerve> @bung87 I get that. Not the question :p |
02:32:35 | FromDiscord | <slymilano> That is AWESOME @exelotl |
02:51:05 | FromDiscord | <exelotl> :) |
03:16:32 | * | seerix quit (Ping timeout: 260 seconds) |
03:17:42 | * | muffindrake quit (Ping timeout: 260 seconds) |
03:19:42 | * | muffindrake joined #nim |
03:51:20 | FromGitter | <xflywind> when I use DateTime, I got a crash. |
03:51:20 | FromGitter | <xflywind> https://play.nim-lang.org/#ix=255M |
03:52:53 | voltist | Does anyone know how I would go about creating a C fp object in Nim? |
03:58:26 | FromGitter | <xflywind> And it seems to appear only in DateTime object. ⏎ https://play.nim-lang.org/#ix=255O |
04:03:05 | disruptek | xflywind: it feels a little like my exception issue; like it's do to an alloc problem (ie. init-only fields). |
04:03:18 | disruptek | !issue author:disruptek exceptions |
04:03:19 | disbot | https://github.com/nim-lang/Nim/issues/11088 -- 5Exceptions, raises pragma hard to use at best |
04:03:20 | disruptek | !issue author:disruptek exception |
04:03:22 | disbot | https://github.com/nim-lang/Nim/issues/11081 -- 3DateTime field on Exception produces inconsistent C/++ handling 7& 2 more... |
04:03:25 | disruptek | that one. |
04:03:55 | disruptek | although exceptions are refs. |
04:08:54 | disruptek | i would try using an object instead of a tuple. |
04:13:32 | FromGitter | <xflywind> I can use my object, but can't iterate in it.But if iteration in generic function, it's ok. |
04:41:46 | shashlick | leorize: you around? |
04:42:28 | shashlick | trying to get nimterop working with nimsuggest - nimcheck already works correctly but nimsuggest isn't seeing the symbols |
04:42:45 | shashlick | unsure how to debug since all I have is neovim in the foreground |
04:43:08 | disruptek | there's a way to tell it to log to a file. |
04:47:15 | shashlick | no idea how to use this |
04:47:18 | shashlick | nothing goes into the log |
04:47:36 | shashlick | no idea what code is being processed in the background |
04:50:04 | * | Hideki_ quit (Remote host closed the connection) |
04:50:59 | * | Hideki_ joined #nim |
04:53:13 | * | chemist69 quit (Ping timeout: 245 seconds) |
04:55:14 | * | Hideki_ quit (Ping timeout: 240 seconds) |
04:55:21 | * | chemist69 joined #nim |
04:58:35 | FromDiscord | <Xydium> So, is a NimNode passed to a macro mutable? |
04:58:58 | FromDiscord | <Xydium> I.e., `parent[i] = newNode...` to replace a node in the tree? |
05:02:22 | FromDiscord | <Xydium> Or do I have to rebuild the tree, one node at a time? |
05:13:10 | FromDiscord | <Xydium> Wait... I'm betting it's because the iterator returns values not references |
05:13:52 | FromDiscord | <slymilano> If I built my application with nimble, as a binary - what's the command to build a release for production? nimble build releases a binary, but with development symbols according to nimble's docs. |
05:14:08 | FromDiscord | <slymilano> is there like a `nimble build release` or similar? |
05:14:38 | zedeus | `nimble build -d:release` |
05:16:27 | FromDiscord | <slymilano> Awesome, where do you find this flag? It's not mentioned here: https://github.com/nim-lang/nimble#nimble-build |
05:16:42 | shashlick | gets forwarded to nim compiler |
05:18:18 | FromDiscord | <slymilano> I see awesome |
05:27:21 | FromDiscord | <slymilano> My github actions is dying mid-release because it's not auto answering Y. Is there a way to auto answer this prompt> |
05:27:21 | FromDiscord | <slymilano> https://cdn.discordapp.com/attachments/371759389889003532/658178738751799307/Screen20Shot202019-12-2220at2012.png |
05:27:43 | shashlick | -y |
05:27:58 | FromDiscord | <slymilano> ty |
05:30:43 | disruptek | no, just -y. if you at the t it won't work |
05:31:13 | * | seerix joined #nim |
05:33:30 | FromDiscord | <slymilano> lol |
05:34:10 | FromDiscord | <slymilano> Thanks guys, got auto releases working and the project builds + ships in like 50 seconds. https://github.com/sergiotapia/torrentinim/commit/4edae75a7bbe26d6c82c6133273d95c3a62eab71/checks?check_suite_id=370273999 |
05:34:28 | FromDiscord | <slymilano> Now I need to figure out how to cross compile for all three major platforms, and name the release binaries different things. |
05:36:30 | shashlick | just use travis - https://gist.github.com/genotrance/fb53504a4fba88bc5201d3783df5c522 |
05:37:20 | FromDiscord | <slymilano> You mean hosted travisCI? |
05:37:26 | FromDiscord | <slymilano> I'd rather stay in house in github for free... |
05:37:38 | shashlick | travis is also free - for open source that is |
05:38:39 | shashlick | anyway, no reason to change if you prefer what you have, only that the yml file i linked is all you need to get everything working |
05:40:50 | FromDiscord | <Xydium> Why does `nimNode[index] = newNode(...` not modify the AST |
05:41:03 | FromDiscord | <slymilano> I hear ya thanks for that backup strat @shashlick |
05:44:37 | shashlick | no problem |
05:45:34 | shashlick | @Xydium - share your code as a paste? |
05:46:04 | FromDiscord | <slymilano> It seems like nimble build doesn't use the `-o` or `--out` flag properly. |
05:46:04 | FromDiscord | <slymilano> |
05:46:04 | FromDiscord | <slymilano> ``` |
05:46:04 | FromDiscord | <slymilano> THIS DOESN'T WORK, I just get torrentinim |
05:46:05 | FromDiscord | <slymilano> # sergiotapia at Sergios-Air in ~/Work/torrentinim on git:master ● [0:44:24] |
05:46:05 | FromDiscord | <slymilano> → nimble build -d:release --out:torrentinim-macosx |
05:46:06 | FromDiscord | <slymilano> |
05:46:08 | FromDiscord | <slymilano> THIS WORKS, I get torrentinim-macosx |
05:46:10 | FromDiscord | <slymilano> # sergiotapia at Sergios-Air in ~/Work/torrentinim on git:master ● [0:44:31] |
05:46:12 | FromDiscord | <slymilano> → nim c -d:release --out:torrentinim-macosx src/torrentinim.nim |
05:46:13 | FromDiscord | <slymilano> ``` |
05:46:59 | FromDiscord | <Xydium> @shashlick https://pastebin.com/syRJAn6i |
05:48:01 | shashlick | slymilano - please use a paste service |
05:48:39 | FromDiscord | <slymilano> ok |
05:55:27 | shashlick | skymilano: can you try with --debug and see what the actual command line sent to nim is |
05:57:29 | shashlick | Xydium - current is not mutable (let) |
05:59:06 | FromDiscord | <Xydium> Changing it to var doesn't fix the issue |
06:00:43 | FromDiscord | <slymilano> Yeah with --debug I can see it's ignoring my --out flag. |
06:00:47 | FromDiscord | <slymilano> Is this a bug then? |
06:03:52 | shashlick | can you see if -o works? |
06:04:38 | shashlick | Xydium: your code doesn't even compile - https://play.nim-lang.org/#ix=2565 |
06:04:50 | FromDiscord | <slymilano> -o doesn't work either |
06:05:30 | shashlick | is there another -o in the command? |
06:05:40 | shashlick | doesn't nimble build decide where the binary should go already? |
06:06:36 | FromDiscord | <Xydium> It compiles on my computer lol |
06:07:14 | shashlick | well, if you can get a paste on http://play.nim-lang.org, it will be easier to help 🙂 |
06:08:20 | FromDiscord | <slymilano> Here's the output; https://pastebin.com/181hLRK9 |
06:08:37 | * | nsf joined #nim |
06:08:41 | FromDiscord | <slymilano> It uses my name at the start, then it's overwritten at the tail end of that command |
06:09:14 | FromDiscord | <Xydium> https://play.nim-lang.org/#ix=2566 |
06:10:00 | shashlick | slymilano - yes cause nimble has been configured with the binary it should build and where it should go |
06:11:07 | FromDiscord | <slymilano> so i should just remove the `bin = @["torrentinim"]` from my .nimble file |
06:11:14 | FromDiscord | <slymilano> is that correct? |
06:12:40 | shashlick | ```Error: undeclared identifier: 'uNeq'``` |
06:13:02 | shashlick | slymilano - if you do that then nimble won't know what to build |
06:13:06 | FromDiscord | <Xydium> Yeah, because when the macro doesn't work, it doesn't parse |
06:13:22 | shashlick | just rename it after the fact, or create a separate nimble task that builds with the name you want |
06:13:22 | FromDiscord | <Xydium> The macro is supposed to take 'tagged' identifiers (uNeq) and replace with untagged (Neq) |
06:13:44 | FromDiscord | <Xydium> Untagged alpha-numeric identifiers are variables in the CSP graph, and should be replaced with an array access |
06:14:28 | FromDiscord | <Xydium> The tree output after the macro is identical to the tree input to the macro |
06:14:55 | FromDiscord | <Xydium> Despite the fact that the macro does `parent[index] = newNode(...` |
06:15:30 | FromDiscord | <Xydium> (well technically it's done by a proc called by the macro but that shouldnt matter) |
06:16:42 | FromDiscord | <Xydium> For some reason, the NimNode tree passed to the proc is immutable |
06:17:08 | FromDiscord | <Xydium> It doesn't generate any compiler/runtime errors by trying to use the []= op, but it doesn't actually do anything either |
06:17:18 | FromDiscord | <Xydium> Or, |
06:17:24 | * | Hideki_ joined #nim |
06:17:35 | FromDiscord | <Xydium> Somehow, copies are being created where there should be references, and the changes only occur on the copies |
06:18:43 | FromDiscord | <Xydium> Pretty sure it's the second one |
06:19:01 | FromDiscord | <Xydium> When I echo the treeRepr of current[i] immediately after modifying it, it has the new nodes |
06:19:28 | FromDiscord | <Xydium> So the value of current is not a reference to the AST subtree that eventually gets returned by the macro |
06:20:14 | shashlick | Why do you expect tree to change |
06:20:30 | shashlick | It isn't passed in as a var arg |
06:20:40 | FromDiscord | <Xydium> and for some reason can't be |
06:21:06 | FromDiscord | <Xydium> edit: couldn't be |
06:21:17 | shashlick | What do you mean |
06:21:18 | FromDiscord | <Xydium> but I just added that and the compiler didn't start screaming so maybe... |
06:21:31 | FromDiscord | <Xydium> The last time I tried using var NimNode I got lots of errors |
06:21:54 | FromDiscord | <Xydium> But alas, it still does not fix the problem |
06:22:31 | shashlick | What did you change? |
06:23:08 | FromDiscord | <Xydium> `proc parseVars(node: var NimNode): (seq[string]) =` |
06:23:26 | * | Romanson joined #nim |
06:24:45 | shashlick | Maybe pop gives you a copy |
06:24:50 | FromDiscord | <Xydium> That's my guess yeah |
06:24:55 | shashlick | You aren't really operating on the original node |
06:25:05 | shashlick | What's the queue even for |
06:25:14 | FromDiscord | <Xydium> Iterative tree traversal |
06:25:20 | FromDiscord | <Xydium> I really didn't feel like writing recursion |
06:26:32 | shashlick | Ok anyway my suggestion would be to work on node directly to avoid some copy |
06:27:03 | shashlick | The for loop could also be copying |
06:29:37 | FromDiscord | <Xydium> well, there is no way to work on the nodes directly |
06:29:45 | FromDiscord | <Xydium> the only way to get the nodes is putting them through that queue |
06:29:59 | FromDiscord | <Xydium> or rewriting recursively but that's its own mess |
06:30:00 | * | Hideki_ quit (Ping timeout: 265 seconds) |
06:30:12 | FromDiscord | <Xydium> Since I need to preserve each constraints var table at all levels of the tree |
06:30:49 | FromDiscord | <Xydium> I.e. given `X == Y and Y == Z`, X is always index 0, y is always index 1, etc, no matter how far down the recursion they are |
06:31:00 | FromDiscord | <Xydium> That's why I wanted to do it iteratively, to stay in one function scope |
06:31:17 | FromDiscord | <Xydium> but apparently Nim likes passing values too much |
06:31:37 | FromDiscord | <Xydium> It doesn't matter if the for loop makes copies |
06:31:51 | FromDiscord | <Xydium> I don't modify the nodes from the loop |
06:32:16 | FromDiscord | <Xydium> `var current = queue[^1]` doesnt work either |
06:46:08 | * | nsf quit (Quit: WeeChat 2.6) |
06:56:35 | * | dddddd quit (Ping timeout: 265 seconds) |
06:57:05 | * | gour joined #nim |
07:00:58 | * | voltist quit (Remote host closed the connection) |
07:24:34 | * | seerix_ joined #nim |
07:25:02 | * | seerix quit (Ping timeout: 260 seconds) |
07:39:32 | FromGitter | <Varriount> Xydium: Still around? |
07:53:04 | * | solitudesf joined #nim |
08:00:00 | * | gmpreussner quit (Quit: kthxbye) |
08:02:56 | * | solitudesf quit (Quit: Leaving) |
08:03:13 | * | solitudesf joined #nim |
08:04:55 | * | gmpreussner joined #nim |
08:26:58 | * | Hideki_ joined #nim |
08:31:48 | * | Hideki_ quit (Ping timeout: 260 seconds) |
08:55:49 | * | letto quit (Quit: Konversation terminated!) |
08:57:50 | * | letto joined #nim |
09:01:39 | FromDiscord | <funcmike> How to write a test and code in general in interface like style for ex. pass mocked auth service for test or have multiple storage implementations? Afaik there is no interfaces in Nim? Where can I find some code samples? |
09:17:34 | FromDiscord | <Rika> Concepts |
09:17:41 | FromDiscord | <Rika> Look at the experimental manual |
09:17:50 | FromDiscord | <funcmike> i'm not interested in experimental features |
09:18:08 | FromDiscord | <Rika> Inheritance |
09:19:44 | FromDiscord | <Rika> Check the manual or nim by example |
09:21:50 | FromDiscord | <funcmike> yeah i have checked them |
09:22:24 | FromDiscord | <funcmike> and I'm still confused |
09:25:50 | FromDiscord | <Milerius> is imariscal in one of the 3 channel ? |
09:35:34 | FromDiscord | <funcmike> Rika: Maybe some real world project example. I want to know how to build for something like this (I made it up) - for ex. TestService (it requires/dependencies IStorage for ex. save(s: Session) method and IAuthorization auth(l: LoginInfo): bool method and i want to test TestService with mocked storage and auth if I'm creating Session correctly based on LoginInfo data? |
09:37:50 | FromDiscord | <Rika> The best is to make a ref object with dummy methods, then inherit that object for every implementation |
09:38:04 | FromDiscord | <Rika> There is no multiple inheritance here |
09:38:11 | FromDiscord | <Rika> If you need that then use experimental |
09:38:20 | FromDiscord | <Rika> No other way about it AFAIK |
09:38:28 | FromDiscord | <funcmike> But why i haved to use inheritence ? |
09:38:34 | FromDiscord | <Rika> Well |
09:38:37 | FromDiscord | <Rika> You don't have to either |
09:39:03 | FromDiscord | <Rika> You can just make 2 objects, actual and mock, with the same procs and argument arity/type |
09:39:28 | FromDiscord | <Rika> But if you want the interfaces then I think concepts are the closest thing |
09:40:21 | FromDiscord | <funcmike> i dont want interfaces or concepts i want to know how do Nim programmers write code for those cases. |
09:40:39 | FromDiscord | <funcmike> langauge is quite old |
09:41:13 | FromDiscord | <funcmike> so if there is no interfaces, people are writing in different style and I want to know how they deal with this |
09:46:58 | FromDiscord | <funcmike> Is it idiomatic to create just 2 objects (mock and actual) or it's just if Your really need this You can... use this trick? |
09:47:09 | FromDiscord | <funcmike> Is it idiomatic to create just 2 objects (mock and actual) or it's just if You really need this You can... use this trick? |
09:55:18 | FromDiscord | <mratsim> You write a generator |
09:55:31 | FromDiscord | <mratsim> and then you used thse generated objects to test your code |
09:57:34 | FromDiscord | <funcmike> mratsim: can you refer me some project or link to code example? |
10:11:31 | FromDiscord | <mratsim> https://github.com/status-im/nim-stint/blob/master/tests/property_based_uint256.nim#L30-L37 |
10:12:08 | FromDiscord | <mratsim> I generate random uint256 and test that the operations invariant are held |
10:14:08 | FromDiscord | <mratsim> same here to test neural networks: https://github.com/mratsim/Arraymancer/blob/a4d3fc11f337f0c1837fdb19a34c3b7b7fa6c65c/tests/nn_primitives/test_nnp_gru.nim#L85-L90 |
10:15:32 | FromDiscord | <mratsim> and in blockchain: https://github.com/status-im/nim-beacon-chain/blob/9050db7b95c7f072a8048cc0f955cbf2a2c5c9e1/tests/spec_block_processing/test_process_attestation.nim#L29-L70 |
10:17:31 | FromDiscord | <mratsim> the generator are more involved because we pass around mutable objects in blockchain but that's one of the issue of mutable state: https://github.com/status-im/nim-beacon-chain/blob/master/tests/mocking/mock_attestations.nim#L22-L129 |
10:17:32 | FromDiscord | <funcmike> maybe im too stupid but i dont see how property based testing help me with case that i have described (i just want to know how to write for ex. network service that requires two statefull / impure / sideffect services and test the code that depends on them without knowing how there are implemented - mock them based on common interface) |
10:18:35 | FromDiscord | <mratsim> you have one-side that is mocked, and one side under test |
10:18:49 | FromDiscord | <mratsim> you need a generator for the mocked side |
10:19:38 | FromDiscord | <mratsim> thath just submit valid (or invalid) inputs to the interface |
10:21:34 | FromDiscord | <mratsim> once that works you can replace the generator by a fuzzer |
10:23:01 | FromDiscord | <mratsim> which is what we did here, for the "attestation" example: https://github.com/status-im/nim-beacon-chain/blob/master/nfuzz/libnfuzz.nim#L51-L69 |
10:24:23 | FromDiscord | <funcmike> ok maybe i'will describe it that way, forget about tests, mocks, generators, fuzzer and stuff, what if i just want to write proc that requires "Db" and i want to pass to it sqlite or mysql or postgresql? |
10:24:42 | * | silvernode quit (Ping timeout: 260 seconds) |
10:24:57 | FromDiscord | <mratsim> known at runtime or compile-time? |
10:25:10 | FromDiscord | <funcmike> both cases |
10:25:21 | FromDiscord | <mratsim> if compile-time only you use generics |
10:25:39 | FromDiscord | <mratsim> if runtime you use object variants or inheritance |
10:26:27 | * | adeohluwa joined #nim |
10:26:51 | FromDiscord | <Rika> common_db |
10:27:00 | FromDiscord | <Rika> Or whatever that module was called |
10:27:06 | FromDiscord | <funcmike> 😉 its just example |
10:27:13 | FromDiscord | <Rika> https://nim-lang.org/docs/db_common.html |
10:27:15 | FromDiscord | <Rika> Oof |
10:27:24 | FromDiscord | <funcmike> i know this cases is in std lib |
10:27:35 | FromDiscord | <Rika> I guess you can look into the modules under db_common though |
10:28:00 | FromDiscord | <Rika> See what it did, and apply that to your usecase |
10:28:11 | FromDiscord | <funcmike> im writing generally using db as example im aware of nim std lib |
10:28:18 | FromDiscord | <mratsim> Example used in production: https://github.com/status-im/nim-eth/tree/master/eth/trie/backends |
10:28:18 | FromDiscord | <mratsim> |
10:28:18 | FromDiscord | <mratsim> backends are rocksdb, sqlite or LMDB |
10:30:42 | FromDiscord | <mratsim> or something I wrote yesterday to abstract implementations differences between windows and posix: https://github.com/mratsim/weave/blob/master/weave/primitives/barriers.nim#L8-L69 |
10:31:03 | FromDiscord | <funcmike> mratsim: ok this looks like what im looking for (trie backends) |
10:31:49 | FromDiscord | <mratsim> basically you just create a wrapper that exports proc with the same name |
10:32:33 | FromDiscord | <mratsim> you can use "assumptions" in your other types proc using concepts: https://github.com/mratsim/weave/blob/master/weave/datatypes/prell_deques.nim#L10-L20 |
10:32:35 | FromDiscord | <funcmike> but trie uses concept |
10:32:56 | FromDiscord | <mratsim> https://github.com/mratsim/weave/blob/master/weave/memory/lookaside_lists.nim#L11-L14 |
10:32:57 | FromDiscord | <funcmike> concept is experimental |
10:33:28 | FromDiscord | <funcmike> is it safe to use? |
10:34:09 | FromDiscord | <mratsim> Concept is compile-time so any issues will be caught either by the Nim compiler or the C compiler |
10:34:27 | FromDiscord | <mratsim> it won't happen like 100hours after your deployed your program |
10:34:46 | Zevv | sealmove: you here? |
10:34:59 | FromDiscord | <mratsim> also experimental means that it might disappear or be changed, but if it's done there will be a migration path |
10:35:14 | sealmove | Zevv: heyyy good timing |
10:35:30 | FromDiscord | <mratsim> the simple usage, just ensuring that a proc or field is defined likely won't be changed |
10:35:38 | livcd | mratsim: i saw there are some perf issues with weave on windows. but you also mention it is not really a big problem |
10:35:58 | FromDiscord | <mratsim> the super complex usages that you can see in the experimental doc might be reworked |
10:36:25 | FromDiscord | <mratsim> @livcd, yes, windows memory allocator is really slow when doing trillions of allocations in a couple of milliseconds 😛 |
10:36:52 | FromDiscord | <mratsim> It's not a problem because it's an extreme, that is made to measure tuntime overhead |
10:37:18 | Zevv | sealmove: Oi! so, I'm not sure where to go from here. Building grammars with enums is good and all, but I guess there should be some kind of sum type with a discriminator to match on instead |
10:37:34 | FromDiscord | <mratsim> It's most likely due to Windows VirtualAlloc allocating eagerly memory pages instead of on first touch like Linux |
10:38:15 | FromDiscord | <mratsim> normal workloads with some computation that takes at least a couple of microseconds are fine |
10:38:43 | FromDiscord | <funcmike> ok thanks for help 🙂 |
10:38:56 | Zevv | do you have a concrete vision on where this should go yet? If not, I'll just play around a bit to see how it fits what I think is useful |
10:39:02 | livcd | interesting i wonder how does Go get around it or if at all |
10:40:21 | FromDiscord | <mratsim> Go is just slow for compute tasks |
10:41:28 | sealmove | Zevv: Even if there is a sum type, it's still about matching enums |
10:41:50 | Zevv | that would suffice, right? |
10:42:13 | sealmove | unless i am missing something, yeah |
10:42:13 | Zevv | So npeg needs to know at least which field of the type is the discriminator |
10:42:25 | * | dmknght joined #nim |
10:42:44 | FromDiscord | <mratsim> I'll have to check more deeply into Microsoft's allocators, mimalloc and snmalloc. But in their paper they mentionned this big difference between Windows and the rest of the OSes |
10:43:10 | sealmove | user can build it, npeg doesn't need to know about the sum type, only the enums |
10:43:21 | dmknght | Hi everybody! Did anybody work with gintro before? I need a little help with spawn process and get output |
10:43:50 | Zevv | sealmove: but npeg needs to be able to compare two things to see if there is a match. So it needs to compare a specific field of the passed type |
10:44:14 | Zevv | so either I need to tell npeg the name of the field, or I need to pass some kind of callback function that does the work, like algoritm.sort |
10:48:31 | * | krux02 joined #nim |
10:48:42 | sealmove | let's say the passed type is an enum (not a sum type). then the user can define his sum typ, pass it as state argument to the peg macro, and construct his sum type. That's how I have it in mind atm. What are you thinking? passing openArray[mySumType]? |
10:49:24 | Zevv | Well, I guess that openarray[mySumType] is what a lexer would spit out |
10:49:31 | Zevv | so that would be the least friction for the user |
10:50:20 | Zevv | the npeg code blocks would then yield these things for the user to act on |
10:50:29 | sealmove | i see, yeah could be the next level ;) |
10:51:11 | Zevv | I don't see how I can get this done with enums only, unless npeg keeps track of the index in the subject and the user uses this to reference back to the lexed components |
10:51:59 | Zevv | I'm also afraid that the whole thing will blow up in complexity so for your average user it is no longer understandable. |
10:52:58 | * | adeohluwa quit (Ping timeout: 260 seconds) |
10:53:45 | sealmove | nah, what you shown on the issue discussion is already simple and useful |
10:53:51 | sealmove | showed* |
10:54:03 | Zevv | ok, one step at a time then |
10:55:20 | sealmove | but I agree, you can keep doing things for the user, but this might limit flexibility for him, and the api becomes more complex |
10:56:37 | sealmove | accepting tokens instead of char is not just a convenience-feature, it's essential for making 2-pass parsers |
10:57:36 | sealmove | so my opinion is do the minimum to provide this choice |
11:00:02 | * | adeohluwa joined #nim |
11:07:55 | * | krux02 quit (Remote host closed the connection) |
11:08:43 | * | krux02 joined #nim |
11:08:43 | * | Zevv quit (Ping timeout: 260 seconds) |
11:09:34 | * | Zevv joined #nim |
11:09:44 | Zevv | Arg power outage third time this week. |
11:10:14 | * | krux02 quit (Read error: Connection reset by peer) |
11:10:53 | FromDiscord | <funcmike> What project / resource its recommended to learn idiomatic nim code with simple and clean code without using all of metaprogramming and advanced language features - for newcomers ? |
11:11:28 | sealmove | i am not sure what "idiomatic nim code" means :P |
11:12:03 | sealmove | nim gives you freedom, you develop your idioms |
11:14:41 | FromDiscord | <exelotl> I mean there are still plenty of idiomatic things, like only using return where needed for flow control, or putting a relevant acronym at the start of your enum items (fmRead, fmWrite) |
11:15:41 | adeohluwa | maybe some conventions are in the docs like having types capitalized, variable names mostly camelCase e.t.c |
11:16:06 | adeohluwa | you will naturally pick that up over time |
11:17:15 | Zevv | don't learn from the compiler source however |
11:20:20 | FromDiscord | <funcmike> Ok so maybe project that shows that this is how a good project with "modern nim" can look if you spend with language enough time |
11:21:05 | sealmove | just pick up a project and learn alongside from the docs like adeohluwa said |
11:21:15 | sealmove | doesn't have to be anything specific |
11:21:47 | * | adeohluwa quit (Remote host closed the connection) |
11:22:20 | FromDiscord | <funcmike> Ok so i will pick mratsim's weave and after a year maybe i will understand something :) |
11:22:33 | lqdev[m] | I remember Zevv saying that my WIP embedded programming language has pretty clean code. I still disagree, but you can read for yourself https://github.com/liquid600pgm/rod |
11:22:46 | dom96 | In case anyone's interested, my book is 50% off (not sure for how long but I think the publisher is doing Xmas sales) https://www.manning.com/books/nim-in-action?a_aid=niminaction&a_bid=78a27e81 |
11:23:17 | sealmove | that's nice |
11:24:15 | FromDiscord | <funcmike> Yes i have read this book, its good but short |
11:24:31 | Zevv | lqdev[m]: given what it does it is pretty clear, but given what it does it is not really a starters codebase |
11:25:10 | FromDiscord | <funcmike> From twitter bot and chat app to real project is a long way |
11:25:29 | Zevv | sealmove: argh, half my lib ends up with procs now having [S,T] |
11:26:00 | dom96 | funcmike: twitter bot? It's a twitter website. I'd say that's a pretty sizeable project |
11:26:05 | dom96 | Especially for a book to cover |
11:26:20 | sealmove | Zevv: ¯\_(ツ)_/¯ |
11:26:44 | FromDiscord | <funcmike> Dont understand wrong Yeah :) its really good book |
11:27:04 | sealmove | still thinking about this sumType, if we come up with a simple interface it could be worth implementing |
11:27:52 | * | luis_ joined #nim |
11:28:07 | lqdev[m] | @funcmike my friend also told me that this codebase is pretty clean, but again I strongly disagree. it was written during a game jam, don't expect 100% clean code https://github.com/liquid600pgm/memrecall |
11:28:52 | FromDiscord | <funcmike> dom96: one of the best books that i have read imho and thank you for it :) i admit i downloaded it from illegal place :) i will buy legal copy |
11:29:01 | dom96 | lol |
11:29:01 | lqdev[m] | it's still idiomatic Nim, because I'm too pedantic |
11:32:25 | FromDiscord | <funcmike> dom96: but in our work place we use go and extensive use of channels and gorutines so too convice other guys to try nim i have to find real projects with nim simillar to ours or rewrite some of the them to so im am searching for more then examples in book |
11:33:04 | * | tane joined #nim |
11:33:37 | sealmove | Zevv: so let's say it does accept seq[mySumType], then in a peg block, the token is $1 (or $2, etc). the user can do $1.someField etc. is this not nice enough? what did you have in mind instead? |
11:38:01 | Zevv | no that is what I had in mind indeed |
11:38:06 | Zevv | but now token is only an enum |
11:38:51 | FromDiscord | <funcmike> dom96: for example how to tell them ehkem nim httpbeast server is really good (but does not support httpv2 (i appreciate your work) and we must write it our selfs when Go has this for free. So im preparing for many questions. |
11:39:17 | sealmove | ok, is there an issue with making a sum type then? more complex codegen? |
11:39:35 | FromDiscord | <Milerius> Hey, i have a seq[NimType] inside my NimType i have a string and i want to sort the sequence based on this String, what is the most idiomatic way to do that |
11:39:55 | * | luis_ quit (Remote host closed the connection) |
11:39:56 | FromDiscord | <Milerius> Can i do smth like : my_seq.sort(my_field) ? |
11:40:05 | dom96 | funcmike: if you really need http 2.0 then you might just want to use nginx |
11:40:07 | FromDiscord | <Milerius> Can i do smth like : my_seq.sort(my_seq.my_field) ? |
11:40:09 | sealmove | Zevv: well, there is flex idea, use a union instead of sum type |
11:40:15 | dom96 | or just put your site behind cloudflare and get that for free |
11:41:07 | sealmove | which temporarily holds the values for the currently-being-parsed token |
11:41:21 | * | luis_ joined #nim |
11:41:35 | sealmove | this would solve the problem, but might introduce new ones, because the lexer and parser will have to work tightly together |
11:41:35 | * | luis_ quit (Remote host closed the connection) |
11:42:33 | Zevv | indeed. |
11:42:42 | Zevv | But first I'm trying to get stuff working including captures |
11:45:26 | FromDiscord | <funcmike> dom96: grpc needs this so nigjnx and cf is not an option for me |
11:46:22 | FromDiscord | <Milerius> Hello there is a better to achieve: https://gist.github.com/Milerius/28754e3ba5158ff82ac7cfcd8c7412ac ? |
11:46:53 | sealmove | Zevv: you can force the user to always use `kind` as a name for the descriminator |
11:47:15 | Zevv | well, currently I'm getting nowhere, so hold your horses :) |
11:47:17 | sealmove | if detecting it is pita |
11:47:27 | sealmove | ok :D |
11:47:30 | Zevv | I keep bumping my head, blood all over the walls now |
11:47:31 | lqdev[m] | @Milerius first of all, remove the `destinations` variable and use `result` |
11:48:17 | lqdev[m] | also, you can use `sort` to sort in place instead of `sorted` |
11:48:30 | sealmove | Zevv: can you make a branch at least? so i can see what parts of the code base you touched? |
11:48:32 | lqdev[m] | https://nim-lang.org/docs/algorithm.html#sort%2CopenArray%5BT%5D |
11:48:41 | * | luis_ joined #nim |
11:48:58 | Zevv | there is a breanch, it's called "bwhaah" |
11:49:09 | sealmove | haha, ok great |
11:49:15 | * | luis_ quit (Remote host closed the connection) |
11:50:18 | * | luis_ joined #nim |
11:50:35 | Zevv | https://github.com/zevv/npeg/commit/b5c935bc2ec8d0e600192f82cef82b36b505ee3a |
11:50:59 | * | luis_ quit (Remote host closed the connection) |
11:51:36 | * | luis_ joined #nim |
11:52:09 | * | luis_ quit (Remote host closed the connection) |
11:52:23 | FromDiscord | <Milerius> what is result @lqdev ? |
11:53:08 | * | luis_ joined #nim |
11:53:23 | FromDiscord | <Milerius> according to the sort declaration, i cannot sort my custom type with it no? |
11:54:09 | * | nsf joined #nim |
11:56:29 | sealmove | Milerius: i think you can |
11:56:40 | FromDiscord | <Milerius> i can i just do it ! |
11:56:47 | FromDiscord | <Milerius> What is this result magic stuff ? |
11:56:52 | FromDiscord | <Milerius> it's funny |
11:56:52 | lqdev[m] | @Milerius result is an implicit variable that's returned at the end of the proc https://nim-lang.org/docs/manual.html#statements-and-expressions-return-statement |
11:57:09 | FromDiscord | <Milerius> 😮 |
11:57:09 | lqdev[m] | it makes code a little cleaner, because you don't have to declare your own var |
11:57:10 | FromDiscord | <Milerius> thanks |
11:57:16 | FromDiscord | <Milerius> thanks a lot my friend |
11:57:19 | FromDiscord | <Milerius> i was not aware |
11:57:31 | solitudesf | https://nim-lang.org/docs/algorithm.html#sortedByIt.t,untyped,untyped |
11:58:00 | * | luis_ quit (Remote host closed the connection) |
11:58:08 | FromDiscord | <Milerius> there is a lambda/closure syntax in nim? |
11:58:41 | FromDiscord | <funcmike> lqdev[m]: thx for suggestions |
11:59:14 | * | luis_ joined #nim |
12:00:03 | lqdev[m] | @Milerius there's the `myProc() do (arg1: string, arg2: float) -> int: discard` notation |
12:00:04 | sealmove | Milerius: there is anonymous proc |
12:00:11 | lqdev[m] | it's in the experimental manual |
12:00:20 | lqdev[m] | or as @sealmove suggested, anon proc |
12:00:25 | FromDiscord | <Milerius> ok thanks ! |
12:00:36 | lqdev[m] | `myProc(proc (arg1: string, arg2: float): int = discard)` |
12:00:41 | Zevv | sealmove: I could greatly simplify things by restriting tokens to be numeric types only |
12:00:48 | FromDiscord | <Milerius> Nice |
12:01:02 | Zevv | that would keep out alal these generics and allows me to just use int |
12:01:18 | Zevv | it would require more infrastructure provided by the user though |
12:01:24 | sealmove | hmm, so int instead of enum? |
12:02:41 | sealmove | wait... |
12:02:56 | sealmove | this is what flex-bison does too |
12:03:23 | sealmove | tokens are just ints starting from a specific number (1000, 1001 etc) |
12:07:23 | sealmove | yeah sure! the user can still define an enum but use it as int, that's fine |
12:08:22 | FromDiscord | <Milerius> i updated to https://gist.github.com/Milerius/28754e3ba5158ff82ac7cfcd8c7412ac @lqdev |
12:08:25 | FromDiscord | <Milerius> I hope it's better now |
12:08:33 | * | ikan-keli_ quit (Quit: ZNC 1.8.x-git-125-e415d9f5 - https://znc.in) |
12:08:47 | * | ikan-keli_ joined #nim |
12:10:29 | sealmove | Zevv: The infrastructure needed from the user is logical, I think generalizing it from seq[char] to seq[int] is already a great upgrade. |
12:11:23 | sealmove | npeg won't provide a lexer -> parser api out of the box, but user will be able to build it, and we can make that api an external lib |
12:12:42 | sealmove | so I am with you at this, should keep npeg code as clean as possible |
12:18:41 | sealmove | i think this is the correct direction to go, in the same spirit as nim, the lexer/parser api should be an external lib and not decided in npeg's core code. |
12:20:31 | sealmove | so i was thinking this was almost already possible with seq[char], but you don't always have spair chars to use to represent tokens. just making it seq[int] solves the problem. i can write a seperate repo that implements an API externally. |
12:20:49 | sealmove | spare* |
12:24:37 | Zevv | Well, there is still the need to write readable parsers |
12:24:54 | Zevv | so the [Token] notation or similar would be handy still |
12:25:32 | sealmove | at the start of your parser you will define the tokens |
12:25:36 | * | dmknght quit (Remote host closed the connection) |
12:25:45 | sealmove | Token1 <- 1001 |
12:25:53 | sealmove | Token2 <- 1002 |
12:25:55 | sealmove | etc |
12:26:04 | FromGitter | <bung87> is there `asyncdispatch. addRead` example ? |
12:26:24 | sealmove | or even better: |
12:26:27 | Zevv | also a possibility, that would make things simpler because npeg does not need to know about any external types at all |
12:26:32 | sealmove | Token1 <- myEnum.int |
12:26:46 | sealmove | exactly |
12:27:12 | Zevv | and now for the output: what would a code block deliver, and how? |
12:27:16 | Zevv | e.g. the captures |
12:27:38 | sealmove | yeah, thinking about that |
12:28:52 | * | luis_ quit (Quit: luis_) |
12:29:18 | sealmove | well, just like npeg currently provides string, it can provide seq[int] instead? |
12:29:40 | sealmove | i know, it doesn't seem useful, but will a helper library it can be |
12:33:07 | Zevv | sounds like the easiest to go |
12:41:13 | sealmove | npeg should capture patterns anyway, not data |
12:48:00 | Zevv | totally depends on waht you're using if for. It is pretty useful for me as it is already :) |
12:49:37 | * | krux02 joined #nim |
12:50:35 | * | krux02 quit (Remote host closed the connection) |
12:51:15 | sealmove | Zevv: https://play.nim-lang.org/#ix=257r |
12:53:29 | Zevv | that makes sense. I don't like the requirement that I have to respecify all tokens in the grammar while they should be deducable from an enum instead |
12:53:32 | Zevv | DRY |
12:57:29 | * | Hideki joined #nim |
12:57:52 | * | Hideki is now known as Guest22245 |
12:59:05 | FromDiscord | <mratsim> DRY is overrated |
12:59:12 | solitudesf | can somebody explain me what's the difference between this c code http://ix.io/257u/c and this nim translation http://ix.io/257v/nim because i've fighting segfaults entire day |
12:59:24 | FromDiscord | <mratsim> DRYMTT is the future, don't repeat yourself more than twice 😉 |
13:01:48 | FromDiscord | <mratsim> I don't see a difference, unless PDisplay is not a pointer |
13:01:54 | * | clyybber joined #nim |
13:03:38 | clyybber | solitudesf: Where does the segfault occur? |
13:03:42 | FromDiscord | <mratsim> is that normal that I get a bunch of numbers though? |
13:04:03 | lqdev[m] | solitudesf: can you `nim c --debugger:gdb file`, `gdb ./file`, and `backtrace`? |
13:04:07 | FromDiscord | <mratsim> I don't get a segfault |
13:04:22 | lqdev[m] | s/`backtrace`/`run`; `backtrace` |
13:04:40 | FromDiscord | <mratsim> Hint: /home/beta/Programming/Nim/weave/build/disp [Exec] |
13:04:40 | FromDiscord | <mratsim> 0 |
13:04:40 | FromDiscord | <mratsim> 0 |
13:04:40 | FromDiscord | <mratsim> 0 |
13:04:41 | FromDiscord | <mratsim> 4 |
13:04:41 | FromDiscord | <mratsim> 4 |
13:04:41 | FromDiscord | <mratsim> 0 |
13:04:42 | FromDiscord | <mratsim> 2 |
13:04:44 | FromDiscord | <mratsim> 4 |
13:04:45 | FromDiscord | <mratsim> 2 |
13:04:46 | FromDiscord | <mratsim> 0 |
13:04:47 | FromDiscord | <mratsim> ... |
13:05:36 | solitudesf | yes, thats the minimal example, it doesnt segfault. but the output differs from c version and it shouldn't |
13:08:04 | stefantalpalaru | You switched the order of those struct fields. |
13:08:06 | * | luis_ joined #nim |
13:08:23 | clyybber | yeah, but that shouldn't matter |
13:08:46 | clyybber | but its the only thing I can spot either |
13:09:02 | clyybber | and maybe that the desc is `let` but that shouldn't matter either |
13:12:10 | * | Guest22245 quit (Remote host closed the connection) |
13:12:55 | * | Hideki joined #nim |
13:13:18 | * | Hideki is now known as Guest45353 |
13:13:55 | * | luis_ quit (Remote host closed the connection) |
13:14:14 | stefantalpalaru | Why the import exception? "import x11/xkb except X_kbGetMap" |
13:15:35 | * | luis_ joined #nim |
13:16:17 | solitudesf | because xkblib has XkbGetMap |
13:17:14 | * | Guest45353 quit (Ping timeout: 240 seconds) |
13:17:48 | stefantalpalaru | And why is keycode cast to an int16 when it's a regular int in C? |
13:17:52 | * | Hideki joined #nim |
13:18:12 | solitudesf | because that how procedure is declared in bindings |
13:18:16 | * | Hideki is now known as Guest5566 |
13:18:36 | stefantalpalaru | Then you start debugging the bindings. |
13:19:35 | solitudesf | i commented version expanded from "macros", it doesnt convert anything, but is still incorrect. |
13:23:42 | * | luis_ quit (Remote host closed the connection) |
13:24:51 | sealmove | Zevv: I think it's nice because then your grammar includes everything, and you don't have the cognitive strain of looking for terminals in one place and non-terminals in other. |
13:25:03 | * | luis_ joined #nim |
13:28:57 | sealmove | Zevv: I have alternatives in mind, for example peg() macro can generate the enum, so you only have to specify it in your grammar, but i think it would make the code a bit more cryptic because as a user you would imagine the enum definition |
13:29:17 | sealmove | would have to imagine* |
13:30:12 | * | luis_ quit (Ping timeout: 248 seconds) |
13:33:37 | Zevv | yeah, and ordering might be odd |
13:36:19 | * | luis_ joined #nim |
13:37:44 | * | luis_ quit (Remote host closed the connection) |
13:42:20 | * | luis_ joined #nim |
13:43:45 | * | luis_ quit (Client Quit) |
13:44:04 | sealmove | fwiw specifying tokens both outside and inside the grammar is what other tools (like bison) do |
13:44:12 | * | luis_ joined #nim |
13:46:54 | * | couven92 joined #nim |
13:47:50 | * | Vladar joined #nim |
13:54:18 | * | nsf quit (Quit: WeeChat 2.6) |
13:54:57 | * | luis_ quit (Remote host closed the connection) |
14:00:46 | Zevv | true. but for the captures: only getting the captures themselves is not what you want, you want indices to the subject there |
14:01:10 | * | NimBot joined #nim |
14:03:24 | FromGitter | <deech> How do I access flags passed to `nimble` in a `task`, eg. I'd like to do `task aTask, "A Task": let myFlag = options["myFlag"] ...` |
14:04:13 | dom96 | no standard Nimble way to do this yet, but you can use `paramStr` IIRC |
14:12:05 | sealmove | Zevv: A capture can actually be just an index for subject; this suffices. The user just has to setup his lexer so that it outputs 2 seperates but parallel seqs, one for tokens and one for their values. |
14:12:49 | sealmove | so a capture can be seq[int], where each int is an index |
14:14:11 | sealmove | in case you are parsing strings, the int represents a character directly, otherwise it represents an index from which you can get (token, value) |
14:14:54 | sealmove | capture can be seq[int] for all cases ;) |
14:14:56 | clyybber | deech: Do you know where to find a safe doubly-linked-list implementation in ATS? |
14:15:45 | Zevv | sealmove: right |
14:16:19 | Zevv | but i'm not going to use 64 bit ints for chars :) |
14:16:37 | sealmove | char|int then? |
14:16:58 | sealmove | seq[char|int] |
14:17:32 | FromGitter | <deech> dom96 Great that worked. Do you see any issues with me relying on it for custom flags? There's always the risk that it'll stomp over something that's introduced in the future but other than that do you anticipate a problem? |
14:18:07 | dom96 | deech: nope, should work fine for the foreseeable future. |
14:19:32 | sealmove | or 2 peg() macros, one that accepts seq[char] and one that accepts seq[int] |
14:20:07 | sealmove | one for lexing/(+parsing), one for parsing? ;) |
14:20:40 | sealmove | I think seq[char|int] works though |
14:21:26 | Zevv | that should do I think |
14:25:22 | sealmove | hmm, i think 2 seperate peg() macros are needed after all |
14:26:04 | sealmove | because otherwise current npeg interface would change |
14:26:57 | Zevv | I'll have to give it another try, the first three tries endedin the swamps |
14:26:59 | sealmove | because if there is 1 macro that accepts seq[char|int] you have no way of knowing if you should treat each element as char or as index to subject |
14:28:12 | * | PMunch joined #nim |
14:28:52 | sealmove | just make a new peg macro that accepts seq[int] and uses `index` or `(token, index)` as captures |
14:29:39 | sealmove | oh wait |
14:29:42 | sealmove | i have an idea |
14:30:07 | sealmove | you can just extend the current macro so that there is a way to reference the index |
14:30:30 | sealmove | for example you can still do $1 to get the token, but can also do @1 to get the index |
14:30:55 | sealmove | this will make a uniform api |
14:33:22 | sealmove | how does this sound? |
14:33:58 | FromGitter | <bung87> ` owned(Socket)` means what ? |
14:34:39 | sealmove | I think it's synonym with new(Socket) atm |
14:36:21 | Zevv | hm not bad sealmove. the only problem is that a capture would be a seq of indices |
14:36:30 | Zevv | just as a string is a seq of chars |
14:36:48 | sealmove | that's right |
14:36:49 | Zevv | but i do like the offset id anyway, also usable for normal captures! |
14:37:22 | Zevv | i once reserved the @ there because $ has precedence issues |
14:37:38 | sealmove | awesome! |
14:38:01 | shashlick | Any nimsuggest experts here? |
14:38:08 | shashlick | https://github.com/nimterop/nimterop/issues/144#issuecomment-568234296 |
14:38:09 | disbot | ➥ toast results aren't cached with `nim check` |
14:41:44 | FromGitter | <bung87> @sealmove thanks! |
14:43:23 | sealmove | np |
14:44:42 | sealmove | Zevv: I'll summarize the idea and write in the issue (#20) an example of how a lexer-parser will look like |
14:44:43 | disbot | https://github.com/nim-lang/Nim/issues/20 -- 5GC leak |
14:44:52 | sealmove | not this 20, npeg's :P |
14:48:28 | sealmove | I think you will like it |
14:48:29 | FromGitter | <deech> @Clyybber https://github.com/githwxi/ATS-Postiats/blob/master/libats/SATS/dllist.sats |
14:49:22 | FromGitter | <deech> @Clyybber Those are the type sigs., the implementation is https://github.com/githwxi/ATS-Postiats/blob/master/libats/DATS/dllist.dats. |
14:50:39 | FromGitter | <deech> clyybber, For you ^^^, used your Gitter handle by mistake. |
14:53:18 | clyybber | thank you! |
15:01:03 | * | luis_ joined #nim |
15:04:16 | * | ng0_ joined #nim |
15:06:43 | * | ng0 quit (Disconnected by services) |
15:07:15 | * | ng0_ quit (Client Quit) |
15:07:16 | * | luis_ quit (Ping timeout: 248 seconds) |
15:07:31 | * | ng0 joined #nim |
15:07:31 | * | ng0 quit (Changing host) |
15:07:31 | * | ng0 joined #nim |
15:19:56 | Zevv | How is Golden doing then? |
15:21:56 | disruptek | uh, good? |
15:28:05 | Zevv | and your ex-wife? |
15:28:30 | Zevv | sealmove: baaah Error: A nested proc can have generic parameters only when it is used as an operand to another routine and the types of the generic paramers can be inferred from the expected signature. |
15:29:22 | disruptek | the ex-wife is pissed. |
15:29:44 | clyybber | you flushed the parts? |
15:29:56 | sealmove | Zevv: eh, this is inconvenient. hold on, I am making a proof of concept demo. |
15:29:59 | clyybber | s/parts/limbs |
15:30:09 | disruptek | i did my best. |
15:30:29 | dom96 | 0_o |
15:30:33 | Zevv | I like how "pissed" in english can be "angry as hell" or "drunk enough to make a fool of oneself" |
15:41:24 | * | dddddd joined #nim |
15:43:12 | FromGitter | <bung87> `socket.acceptAddr().addCallback proc (f:Future[tuple[address: string, client:asyncnet.AsyncSocket]]) =` what’s wrong with this? |
15:50:13 | Zevv | 2/c |
15:54:54 | * | PMunch quit (Quit: leaving) |
15:55:27 | FromGitter | <bung87> `2/c` means what? |
15:58:57 | sealmove | Zevv: https://github.com/zevv/npeg/issues/20#issuecomment-568275146 |
15:58:58 | disbot | ➥ Feature request: Parse from seq[Token] |
16:01:50 | Zevv | yeah that about sums it up. It's not very friendly but its flexible |
16:01:57 | Zevv | let me see if I can get there somehow |
16:03:54 | FromDiscord | <exelotl> uhh I'm getting an error with varargs[untyped] when passing zero arguments |
16:03:58 | FromDiscord | <exelotl> https://play.nim-lang.org/#ix=258a |
16:04:33 | FromDiscord | <exelotl> (if you comment out line 9 it works fine) |
16:05:26 | * | luis_ joined #nim |
16:05:30 | FromDiscord | <exelotl> should I file an issue? |
16:05:32 | FromDiscord | <Xydium> I've narrowed down the possible problems with the macro I'm writing |
16:05:41 | FromDiscord | <Xydium> Somewhere a copy is being made that should not be made |
16:05:56 | FromDiscord | <Xydium> Either in parameter passing, creating a sequence, or removing from the sequence |
16:06:30 | FromDiscord | <Xydium> But none of those make sense, because NimNode is a ref object |
16:07:23 | sealmove | the only issue I can see is that this approach requires global vars |
16:07:36 | sealmove | personally I don't mind that though |
16:10:04 | Zevv | We'll see. I just ended up refactoring the codegen and I finally got rid of one of the nasty things I never knew how to fix. Not at all working on your feature anymore, but this might help |
16:12:40 | sealmove | sure, I am still playing around with the proof of concept example |
16:13:12 | sealmove | should only start implementing once we have a solid example of what we want the feature to look like |
16:25:56 | * | nsf joined #nim |
16:27:32 | * | Vladar quit (Quit: Leaving) |
16:27:33 | yumaikas | o/ |
16:28:34 | madprops | is nimble intended to work as a binary package manager too? |
16:28:57 | dom96 | yep |
16:32:58 | * | luis_ quit (Quit: luis_) |
16:33:02 | yumaikas | dom96 how goes it? |
16:34:22 | FromDiscord | <Xydium> Is there a way to check whether two objects are the same object? |
16:35:30 | sealmove | ok, my example makes much more sense now: https://github.com/zevv/npeg/issues/20#issuecomment-568275146 |
16:35:30 | disbot | ➥ Feature request: Parse from seq[Token] |
16:36:36 | sealmove | the approach is as follows: |
16:36:43 | sealmove | - you define 2 globals seqs |
16:36:43 | yumaikas | Xydium: I think you could use addr to compare addresses? |
16:36:47 | FromGitter | <deech> A number of functions listed in the `os` module are not available in NimScript but per the docs they should be: https://nim-lang.org/docs/nims.html |
16:36:52 | sealmove | - one has enums and it's just for helping peg() macro do the matches |
16:36:59 | FromGitter | <deech> `getCurrentDir()` is an example. |
16:37:06 | sealmove | - the other has actual Nodes |
16:37:22 | sealmove | then you call the lexer which fills in both seqs |
16:38:23 | sealmove | finally you call the parser which uses seq[myEnum] to do the matching and seq[Node] is used by the user in peg block, since he has the index with @1 |
16:38:31 | sealmove | the index works for both seqs |
16:39:07 | FromDiscord | <Xydium> Expression has no addr is the result |
16:39:20 | sealmove | obviously the lexer will spil out a seq[Node] where all Nodes are terminals |
16:39:32 | yumaikas | Xydium: I'm going to need more context then |
16:39:38 | sealmove | or rather fill in* (not spil out) |
16:40:07 | FromDiscord | <Xydium> Now I'm attempting to make all of the `NimNode`s into `ref NimNode`s but I need to get a reference to a value in a sequence in another node |
16:40:40 | * | Guest5566 quit (Remote host closed the connection) |
16:40:50 | yumaikas | Xydium: Why are you trying to find out if two Nim nodes are the same nim node? |
16:40:59 | Zevv | Hmm anyone here with macro brains? I use genSym() to generate unique id's, but I can't use these when they happened to get used as proc param: "cannot use symbol of kind 'var' as a 'param'". When I generate the id myself with ident() there's no problem there |
16:41:12 | * | Hideki joined #nim |
16:41:48 | * | Hideki is now known as Guest69046 |
16:42:10 | * | yumaikas doesn't have macro brains atm, has mostly been satisfied with templates |
16:42:22 | * | Romanson quit (Quit: Connection closed for inactivity) |
16:43:02 | FromDiscord | <Xydium> Because node trees are being passed by value **somewhere** and I need to figure out where/why |
16:43:19 | sealmove | genSym: "Generates a fresh symbol that is guaranteed to be unique. The symbol needs to occur in a declaration context." |
16:43:22 | FromDiscord | <Xydium> I want to be able to modify the AST with a simple `parent[i] = newNode(...` |
16:43:54 | FromDiscord | <Xydium> But since the parent is always the wrong copy, it's impossible |
16:44:09 | FromDiscord | <Xydium> I posted a link to the code last night, I'll resend |
16:44:47 | FromDiscord | <Xydium> https://play.nim-lang.org/#ix=2566 |
16:44:49 | sealmove | hmm ident(mySym) doesn't work? |
16:44:53 | Zevv | sealmove: yeah I know. it seems that genSym() attaches more info to the generated node, which I actually do not want there. But I now just do ident() and add some random digits - good enough for now |
16:44:59 | FromDiscord | <Xydium> The functions in question are parseVars and constrain |
16:46:15 | FromDiscord | <Xydium> Inside the macro: `var r = new(ref NimNode)` gets a Cannot parse VM Code error |
16:47:03 | * | Guest69046 quit (Ping timeout: 260 seconds) |
16:47:53 | yumaikas | wouldn't that be var r = newRef[NimNode]() ? |
16:48:08 | yumaikas | Actually, probably not |
16:49:33 | FromDiscord | <Xydium> doesn't exist afaik |
16:49:49 | sealmove | Zevv: ident(genSym().repr) |
16:51:47 | FromDiscord | <Xydium> Yeah I can't use ref NimNode at all on the VM |
16:51:55 | FromDiscord | <Xydium> But I shouldn't need it, since NimNode is a ref object |
16:52:19 | Zevv | sealmove: Baaah! :) |
16:52:20 | FromDiscord | <Xydium> But somehow every single collection type in this language deep-copies NimNodes |
16:54:05 | sealmove | dunno, genSym() is weird: https://play.nim-lang.org/#ix=258w |
16:54:19 | yumaikas | Xydium: I think that's on purpose? |
16:54:30 | yumaikas | Araq or dom96 would have a better idea tho |
16:55:35 | FromDiscord | <Xydium> Well it shouldn't be the case, it prevents doing quick tree substitutions with an iterative traversal |
16:56:10 | FromDiscord | <Xydium> I guess I could do recursion in a single scope by using a nested proc |
16:56:33 | FromDiscord | <Xydium> Since each statement needs one vartable at all levels of the tree, and passing that around is annoying |
16:57:02 | FromDiscord | <Xydium> But if I have a nested proc with no return type, can it access the result variable of its host? |
16:57:10 | sealmove | genSym() must be used at CT but its results can only be used at RT |
16:57:34 | FromGitter | <mratsim> Just store your NimNode in another NimNode |
16:57:46 | FromDiscord | <Xydium> I've tried that |
16:57:48 | FromGitter | <mratsim> NimNode shallow copies as they are ref |
16:58:41 | FromGitter | <mratsim> One thing is that var NimNode don't properly update if you are passing a result |
16:58:42 | FromDiscord | <Xydium> constrain macro receives stmtlist, passes each statement to the parseVars proc, which should reference the original AST input |
16:58:52 | FromGitter | <mratsim> Create an intermediate var |
16:58:57 | FromDiscord | <Xydium> I've tried that |
16:59:14 | FromDiscord | <Xydium> I had parseVars make a deep copy of its input statement |
16:59:18 | FromDiscord | <Xydium> Then edit the copy |
16:59:20 | FromDiscord | <Xydium> Then return the copy |
16:59:28 | FromDiscord | <Xydium> And add that to a new statement list returned by the macro |
16:59:41 | FromDiscord | <Xydium> But because that copy still puts nodes through the queue, |
17:00:00 | FromDiscord | <Xydium> Somehow they get copied, and the edits don't apply to what I return |
17:00:45 | * | Hideki joined #nim |
17:01:08 | * | Hideki is now known as Guest20674 |
17:02:11 | sealmove | eeeh this is so confusing, I don't know how genSym() works at all |
17:04:22 | * | endragor quit (Remote host closed the connection) |
17:05:05 | * | _seerix joined #nim |
17:05:16 | * | Guest20674 quit (Ping timeout: 258 seconds) |
17:07:47 | * | seerix_ quit (Ping timeout: 260 seconds) |
17:08:58 | * | letto quit (Ping timeout: 265 seconds) |
17:11:27 | * | natrys joined #nim |
17:13:28 | * | letto joined #nim |
17:18:08 | * | couven92 quit (Read error: Connection reset by peer) |
17:18:27 | * | couven92 joined #nim |
17:21:08 | * | couven92 quit (Read error: Connection reset by peer) |
17:21:28 | * | couven92 joined #nim |
17:21:57 | FromGitter | <mratsim> @xydium is it related to this? https://github.com/nim-lang/Nim/issues/11637 |
17:21:58 | disbot | ➥ {.compileTime.} var ref are not updated properly for implicit result |
17:22:36 | FromGitter | <mratsim> If you have a pastebin I can have a look (but probably tomorrow) |
17:24:57 | * | luis_ joined #nim |
17:26:51 | * | lqdev[m] uploaded an image: image.png (2KB) < https://matrix.org/_matrix/media/r0/download/matrix.org/SQiXMRzpIafyEIEiqRiHSfPb > |
17:27:06 | lqdev[m] | nice to see nimsuggest stuck in a `while true` loop again. |
17:27:12 | lqdev[m] | this time, it's 3 instances, not 1. |
17:29:32 | * | luis_ quit (Client Quit) |
17:29:43 | * | Cthalupa quit (Ping timeout: 252 seconds) |
17:30:00 | * | luis_ joined #nim |
17:30:39 | clyybber | `if dumbInput: while true: discard` |
17:32:25 | * | Cthalupa joined #nim |
17:32:41 | disruptek | 3 instances is 3 times the fun. |
17:33:01 | disruptek | where are my nimph bugs? |
17:33:37 | * | _seerix quit (Quit: Leaving) |
17:34:08 | * | seerix joined #nim |
17:35:54 | * | Hideki joined #nim |
17:36:18 | * | Hideki is now known as Guest81552 |
17:38:11 | * | endragor joined #nim |
17:42:53 | * | endragor quit (Ping timeout: 268 seconds) |
17:43:36 | lqdev[m] | 3 times the fun, 3 times the `free(): invalid size` `fish: “nvim mods/moddef.nim” terminated by signal SIGABRT (Abort)` |
17:44:27 | lqdev[m] | one `pkill nimsuggest` later, CPU usage's back to normal |
17:44:42 | disruptek | well, it was fun while it lasted. |
17:45:53 | FromGitter | <deech> Is there a standard library function for strictifying an iterator into a `seq`, something that captures the `var res = @[]; for x in ... : res.add(x)`? |
17:46:39 | disruptek | sounds like you want the new collect macro. |
17:47:12 | clyybber | deech: toSeq |
17:47:35 | clyybber | I think |
17:48:01 | disruptek | i think he wants to mess with x and not just add it. |
17:49:27 | FromGitter | <deech> clyybber, thanks just what I needed! Should have looked there first. :) |
17:49:38 | FromDiscord | <Xydium> @mratsim I figured it might be a bug like that, let me try not using the implicit result |
17:50:56 | FromDiscord | <Xydium> And nope, still the same problem |
17:51:31 | * | Guest81552 quit (Ping timeout: 268 seconds) |
17:52:35 | FromDiscord | <Xydium> Seems like the VM is pretty broken, I'll just suffer the recursive rewrite instead |
17:53:11 | FromDiscord | <Xydium> Then again, if the recursion is using the same `parent[i] = newNode(...` stuff, even that won't work |
17:53:34 | FromDiscord | <Xydium> Unless the copies are being created by the queue |
17:54:10 | FromDiscord | <Xydium> In fact, it must be the queue creating copies |
17:55:07 | FromDiscord | <Xydium> https://pastebin.com/eGhig2rr |
17:55:41 | FromDiscord | <Xydium> 1. parseVars proc gets each statement's AST from constrain macro |
17:55:57 | FromDiscord | <Xydium> 2. parseVars deep-copies the received statement and stores it in a heapqueue |
17:56:22 | FromDiscord | <Xydium> 3. Deep-copied Nodes from the tree are popped from the queue |
17:56:42 | FromDiscord | <Xydium> 4. Children are set on the popped node, this is confirmed working, as the treeRepr of current changes |
17:57:04 | FromDiscord | <Xydium> 5. These changes are not reflected back on the tree from which all nodes in the queue should be from |
17:58:52 | FromDiscord | <Xydium> And the VM forbids making the queue `HeapQueue[ref NimNode]` |
17:59:19 | FromDiscord | <Xydium> It makes sense that this is as broken as using a seq, since it uses a seq internally |
17:59:37 | FromDiscord | <Xydium> Is there a single collection in this language that doesn't make erroneous copies |
18:00:01 | lqdev[m] | ha, `nim.nvim: unable to connect to nimsuggest`. @leorize |
18:00:27 | lqdev[m] | seems like nimsuggest is stuck in a while loop again, eating up 100% of a CPU thread |
18:05:13 | disruptek | tuples don't make erroneous copies. |
18:05:45 | FromDiscord | <Xydium> any **variable sized** collection |
18:06:11 | disruptek | if there is, we can patch it. 😁 |
18:06:18 | FromDiscord | <Xydium> unless you mean I need `HeapQueue[tuple[whatMatters: NimNode, whatDoesnt: Lmao]]` |
18:07:56 | disruptek | give me bugs or give me death. |
18:10:50 | FromDiscord | <Xydium> tuples still make useless copies |
18:17:54 | FromDiscord | <slymilano> In the nim forums, what does "Thread is moderated" mean? Only my thread has that: https://forum.nim-lang.org/t/5725 |
18:18:06 | FromDiscord | <Xydium> is there some where to iterate the nodepaths of the tree and access the original tree directly? |
18:22:05 | disruptek | http://ix.io/259b/nim |
18:28:17 | FromDiscord | <niv> hi. im trying to read the outputhandle of a Process (osproc) async. i tried asyncfile, but that would block on readLine() despite promising otherwise. i tried the threadpool workaround mentioned here: https://github.com/nim-lang/Nim/issues/11564 but that would eventually error out with "too many open files". whats the canonical/best way to wrap a existing FD into async so i can await on input from it? |
18:28:49 | disruptek | niv: golden does this quite simply. |
18:28:57 | disruptek | !repo golden |
18:28:58 | disbot | https://github.com/disruptek/golden -- 9golden: 11a benchmark for compile-time and/or runtime Nim 15 13⭐ 0🍴 |
18:29:28 | disruptek | see the invocation file, iirc. |
18:29:45 | FromDiscord | <niv> i'll take a look, thanks |
18:30:07 | disruptek | the open files issue is probably due to this issue: |
18:30:25 | disruptek | !issue author:disruptek signal |
18:30:26 | disbot | https://github.com/nim-lang/Nim/issues/12354 -- 3selectors API encourages signal file descriptor leak |
18:30:54 | disruptek | i think the golden code is pretty well commented to explain the solution. |
18:31:23 | FromDiscord | <niv> erghh. ok, thanks. i'll give it a good read. |
18:31:51 | luis_ | Hi all, I am trying to add a nim kernel to rmarkdown... I have a very simple question, how do I pass a string to the nim compiler and get the command output from such string in the stdout? |
18:31:57 | luis_ | Is there a way? |
18:32:00 | FromDiscord | <niv> oh, i didnt even know about the selectors module! |
18:32:14 | disruptek | have fun. 😀 |
18:32:22 | FromDiscord | <niv> i certainly will, ty |
18:32:36 | FromDiscord | <niv> though it would be nicer if nim would take care of all this yak shaving .. ;) |
18:33:12 | luis_ | Something like nim c -r "echo 'cool'" does not work |
18:33:26 | disruptek | luis: save it to a file first. |
18:34:15 | FromDiscord | <Xydium> @disruptek NimNodes have no high/low definition |
18:34:32 | FromDiscord | <Xydium> If I replace high with len-1 and low with 0, it does not halt |
18:35:04 | disruptek | that makes me sad. |
18:35:08 | disruptek | is it a bug in the walker? |
18:35:13 | FromDiscord | <Xydium> no clue |
18:35:26 | FromDiscord | <Xydium> I'll have to figure out how the walker works |
18:35:36 | luis_ | Thanks. I understand this, but was hoping I could pass a string... |
18:35:55 | disruptek | it's pretty simple. just something i wrote to help stefan in an issue. |
18:36:21 | FromDiscord | <Xydium> my guess is that `while path.len > 0: if path.didAscend: continue` does not halt because, |
18:36:39 | FromDiscord | <Xydium> `path[path.high].index < 0` is never true |
18:37:03 | FromDiscord | <Xydium> and since it's never true, the path is never shortened |
18:37:23 | FromDiscord | <Xydium> So what is `path[path.high].node.low` supposed to mean? |
18:37:46 | disruptek | the last node's first child. |
18:37:53 | FromDiscord | <Xydium> That's what I thought |
18:38:05 | FromDiscord | <Xydium> should it be greater? |
18:38:12 | FromDiscord | <Xydium> greater-than* |
18:38:26 | disruptek | i dunno, i wrote this code months ago. i don't even know if i ran it outside of the playground. |
18:39:01 | disruptek | i think you should fix it for us and post it in the forum thread about walking trees. pretty active right now. |
18:39:41 | FromDiscord | <Xydium> Sounds good, just hope it actually uses references correctly when I get it working lol |
18:39:54 | FromDiscord | <Xydium> Link to the post? |
18:40:04 | FromDiscord | <Xydium> Also does the predicate matter at all? |
18:40:06 | disruptek | i mean, i'm sure it compiles... it's not designed for write-while-read, though. |
18:40:10 | disruptek | predicate doesn't matter. |
18:40:23 | disruptek | https://forum.nim-lang.org/t/5697 |
18:40:43 | FromDiscord | <Xydium> oh that could be the problem, write-while-read |
18:41:09 | FromDiscord | <Xydium> Well, the thing is, the tree will only ever have terminals replaced with terminals or longer branches |
18:41:17 | FromDiscord | <Xydium> the longer branches should never be walked |
18:41:31 | disruptek | then you should be fine. long as the indices aren't changing, obviously. |
18:41:41 | disruptek | just make stuff mutable. |
18:41:51 | disruptek | and beware of this: |
18:42:01 | disruptek | !issue mutable iterator |
18:42:02 | disbot | https://github.com/nim-lang/Nim/issues/12945 -- 3mutable iterator cannot yield named tuples 7& 4 more... |
18:42:04 | FromDiscord | <Milerius> What do you use when you need to share a table between thread ? |
18:42:16 | disruptek | there's a sharedtables impl. |
18:42:35 | FromDiscord | <Milerius> yeah but Andres tell me it's unstable |
18:42:43 | disruptek | well, you can use channels. |
18:42:53 | disruptek | they aren't brilliant, but they are the best we have atm. |
18:43:02 | shashlick | !repo shared |
18:43:03 | disbot | https://github.com/genotrance/shared -- 9shared: 11Nim library for shared types 15 3⭐ 0🍴 7& 12 more... |
18:43:38 | shashlick | Or maybe just use boehm |
18:44:01 | * | sealmove quit (Quit: WeeChat 2.6) |
18:44:02 | FromDiscord | <Milerius> i use bohem already yeah |
18:44:08 | FromDiscord | <Milerius> But let's say i'm using Tables |
18:44:18 | FromDiscord | <Milerius> I absolutely need to read/write from different thread into this table |
18:44:28 | FromDiscord | <Milerius> and it's should be non blocking |
18:46:22 | FromDiscord | <Milerius> (In fact i want to share a JsonNode between threads) |
18:46:39 | FromDiscord | <Milerius> This JsonNode represents my json configuration and threads/main thread need it |
18:47:09 | luis_ | disruptek: solved that, now how do I hide all hint output from the nim compiler? |
18:47:26 | disruptek | you can toggle hints in your nim.cfg or via the command-line. |
18:48:02 | disruptek | eg. in nim.cfg: hint[Processing]=off |
18:48:03 | luis_ | do you recall the tag for this? |
18:48:09 | luis_ | oh, thanks |
18:49:04 | luis_ | for the command line, do you recall the flag? |
18:49:33 | disruptek | no, but `nim --fullhelp` should mention it. |
18:49:39 | shashlick | Boehm should handle multiple threads |
18:49:48 | luis_ | --hints:on|off|list |
18:49:51 | luis_ | thanks |
18:49:52 | disruptek | hints are defined in compiler/lineinfos.nim |
18:51:59 | FromDiscord | <Xydium> `Error: unhandled exception: 'sym' is not accessible using discriminant 'kind' of type 'TNode' [FieldError]` |
18:52:10 | FromDiscord | <Xydium> this is new |
18:53:02 | FromDiscord | <Xydium> I think I got the walker working now |
18:53:14 | FromDiscord | <Xydium> Ascent should happen when a node's index is zero |
18:53:33 | FromDiscord | <Xydium> The ascent loop should break when no ascent occurs |
18:55:53 | luis_ | I am almost there, how do I take the first lines with the path of the code run from the output? https://i.imgur.com/jpTs6sv.png |
18:56:56 | FromDiscord | <Xydium> I need a predicate that skips any nodes added by the macro |
18:58:04 | disruptek | luis: probably some output is on stderr and some on stdout. |
18:58:41 | disruptek | i want a pragma that warns when there's a case statement with an else. |
18:59:19 | luis_ | oh, ok, will try to hide stderr... but the package is ready... will announce here when I upload to github... we can now include nim code to rmarkdown files |
19:02:01 | disruptek | neat. |
19:20:36 | * | nsf quit (Quit: WeeChat 2.6) |
19:31:05 | FromDiscord | <Xydium> @disruptek The traversal almost works, aside from skipping the first child of the root |
19:31:14 | FromDiscord | <Xydium> But, it still doesn't allow me to return the modified tree |
19:31:39 | disruptek | details... |
19:34:51 | FromDiscord | <Xydium> I'm changing things to var T but it still doesn't help |
19:38:36 | * | silvernode joined #nim |
19:43:29 | FromDiscord | <Milerius> Is it possible if i have an `OrderedTable` that i want to share between threads, to return only a copy of This table since most of my Threads just need to read into this table ? |
19:43:44 | disruptek | sure. |
19:44:03 | FromDiscord | <Milerius> How can i specify that ? |
19:44:21 | disruptek | let tableB = tableA |
19:44:55 | * | silvernode quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.) |
19:46:43 | FromDiscord | <Milerius> It's a copy or a reference in this case ? |
19:47:11 | disruptek | it's a copy if tableA is OrderedTable. |
19:47:27 | FromDiscord | <Milerius> Hmmm |
19:50:40 | FromDiscord | <slymilano> Hey guys, why does my user and my thread both say "Moderated" on the forums? https://forum.nim-lang.org/profile/sergio |
19:52:27 | FromGitter | <Willyboar> @narimiran ^^^ |
19:58:40 | * | actuallybatman joined #nim |
20:05:09 | * | natrys quit (Quit: natrys) |
20:16:39 | FromDiscord | <Xydium> @disruptek I rewrote it recursively, and it ended up being far less annoying |
20:16:56 | Zevv | Probably another stupid question, but is there a way for nim to resolve an Enum value at macro time? So I have an identifier matching a valid enum member, and I want to get its value as intval. |
20:17:20 | disruptek | Zevv: not a stupid question, it comes up every few months. |
20:17:40 | Zevv | soooo - where is the FAQ?! |
20:17:47 | disruptek | actually, i think you asked it last time, didn't you? |
20:17:56 | Zevv | dang, did I? |
20:17:59 | Zevv | I'm not *that* old |
20:18:04 | * | Zevv greps |
20:18:38 | Zevv | was 7/24 the last time? |
20:18:43 | disruptek | could be. |
20:18:52 | disruptek | you were younger, then. |
20:19:03 | Zevv | I asked - but noone answered |
20:19:27 | Zevv | worthless support on this channel, like always |
20:20:07 | Zevv | well, nice job for sealmove to figure that out then |
20:20:24 | disruptek | like always. |
20:20:28 | disruptek | at least we're consistent. |
20:21:09 | Zevv | he requested the feature, he does the nasty parts |
20:22:38 | disruptek | fwiw, i think it's the same issue with booleans. so, maybe that'll help him find the solution. |
20:23:54 | Zevv | it's actaully simple: http://ix.io/259V |
20:23:56 | FromDiscord | <Xydium> Okay so now I need proc(x: varargs[T]): bool = `tree`, to correctly access the x param of the lambda |
20:24:06 | Zevv | but it breaks somewhere in my chain of events, because `intval` is no longer there when I need it |
20:24:10 | FromDiscord | <Xydium> But the lambda param is some weird gensymNumbers |
20:24:32 | Zevv | " Error: node lacks field: intVal |
20:24:33 | Zevv | " |
20:25:42 | disruptek | you must be playing, "hide the banana" over there. |
20:26:23 | Zevv | not today, not today |
20:27:33 | Zevv | ah, there it is: my NimNode is untyped |
20:27:37 | Zevv | there it gets lost in translation |
20:27:42 | Zevv | sigh |
20:28:03 | FromDiscord | <Xydium> https://pastebin.com/3Vks8NT7 |
20:28:20 | FromDiscord | <Xydium> This is the last thing I need to get working, but I havent the slightest idea how symbols work |
20:28:51 | disruptek | you just bang them together and they make a big crashing, smashing noise. |
20:29:09 | FromDiscord | <Xydium> https://pastebin.com/e9xDMcWJ |
20:29:20 | FromDiscord | <Xydium> `Error: undeclared identifier: 'x'` |
20:29:47 | FromDiscord | <Xydium> Ident "x`gensym280440" |
20:29:56 | FromDiscord | <Xydium> That's what the lambda parameter becomes |
20:30:09 | FromDiscord | <Xydium> How do I link that to the x in the constraint subtree |
20:31:11 | disruptek | let xarg = ident"x" .... proc(`xarg`: ...) |
20:32:26 | FromDiscord | <Xydium> causes a type mismatch, it can't figure out the type of x |
20:37:17 | FromDiscord | <Xydium> `Error: type mismatch: got <T, T>` on `x[1] * x[1]` |
20:42:54 | muffindrake | Stropping lets you use identifiers with spaces? Neat. |
20:45:32 | disruptek | thanks, i hate it. |
20:46:02 | FromDiscord | <Generic> is this code supposed to work with newruntime? https://play.nim-lang.org/#ix=25a1 |
20:46:23 | FromDiscord | <Generic> because in this case a reference outlives the owned object |
20:48:18 | * | endragor joined #nim |
20:49:51 | FromDiscord | <mratsim> don't use generic macros @Xydium |
20:50:00 | * | natrys joined #nim |
20:50:27 | FromDiscord | <mratsim> it's not tested, and you don't need them |
20:51:19 | FromDiscord | <Xydium> Alright so how do I ignore the generics then |
20:51:29 | FromDiscord | <Xydium> Since it operates on a Problem[T] |
20:51:58 | FromDiscord | <Xydium> The lambdas given to the problem take varargs[T] |
20:54:03 | * | endragor quit (Ping timeout: 268 seconds) |
20:54:11 | FromDiscord | <mratsim> I use this to get the generic out of the a Tensor[T] type: https://github.com/mratsim/Arraymancer/blob/master/src/private/ast_utils.nim#L42-L44 |
20:54:39 | FromDiscord | <mratsim> oh, it seems like i do have one generic macro |
20:54:40 | FromDiscord | <mratsim> https://github.com/mratsim/Arraymancer/blob/master/src/tensor/accessors_macros_read.nim#L20 |
20:54:54 | FromDiscord | <mratsim> well, somehow it might work in corner cases then |
20:55:37 | FromDiscord | <Xydium> The issue I'm having is, once I replace the identifier in the lambda to not have the `gensymXXXXXX` thing, it complains about the types |
20:56:55 | * | eys joined #nim |
20:56:57 | * | eys left #nim (#nim) |
20:56:58 | FromDiscord | <mratsim> if you replace one node nnkSym by a fresh nnkIdent, you need to replace all the nnkSym with the same identifier by a fresh nnkIdent |
20:57:12 | FromDiscord | <mratsim> because nnkSym are already resolved and bound to something |
20:57:21 | FromDiscord | <mratsim> and with your replacement you deleted that something |
20:58:37 | FromDiscord | <Xydium> It's an identifier node though |
20:58:44 | FromDiscord | <Xydium> https://pastebin.com/e9xDMcWJ |
20:59:14 | FromDiscord | <Xydium> `IdentDefs >> Ident "x'gensym280440"` |
20:59:34 | FromDiscord | <Xydium> And I just replace the ident with Ident"X" |
20:59:49 | FromDiscord | <mratsim> that's strange that it has been gensymed then |
21:00:00 | FromDiscord | <mratsim> can you pass an untyped instead of a typed parameter |
21:00:12 | FromDiscord | <mratsim> that avoids the OpenSyymChoice and the creation of symbols |
21:00:35 | FromDiscord | <Xydium> `Untyped is only allowed in macros` |
21:00:41 | FromDiscord | <mratsim> if you have your code in your repo or something I can have a look at it |
21:01:18 | FromDiscord | <Xydium> `quote do: addConstraint('problem', proc(x: untyped): bool = 'tree', 'vars')` |
21:02:11 | FromDiscord | <Xydium> I have it in a paste from earlier |
21:02:16 | FromDiscord | <mratsim> before the quote do, do `let x = ident"x"` |
21:02:16 | FromDiscord | <mratsim> And then |
21:02:16 | FromDiscord | <mratsim> ``` |
21:02:17 | FromDiscord | <mratsim> quote do: addConstraint('problem', proc(`x`: untyped): bool = 'tree', 'vars') |
21:02:17 | FromDiscord | <mratsim> ``` |
21:02:49 | FromDiscord | <Xydium> https://pastebin.com/3Vks8NT7 |
21:02:51 | FromDiscord | <Xydium> That's the old paste |
21:03:01 | FromDiscord | <Xydium> The ident"x" doesn't work either |
21:03:20 | FromDiscord | <Xydium> Still `Untyped is only allowed in templates and macros` |
21:03:32 | FromDiscord | <Xydium> Quote do is trying to output runtime nim code using untyped |
21:03:32 | FromDiscord | <mratsim> strange |
21:03:46 | FromDiscord | <mratsim> do you have the rest, problem[T] and parseVars? |
21:04:00 | FromDiscord | <mratsim> and addCOnstraint |
21:04:28 | * | nsf joined #nim |
21:04:36 | FromDiscord | <Xydium> https://pastebin.com/Gge6Nj9x |
21:05:46 | FromDiscord | <mratsim> looking, give me a couple of min (hopefully |
21:07:24 | FromDiscord | <mratsim> ittree is useful? |
21:07:41 | FromDiscord | <Xydium> I'm not using ittree anymore |
21:08:08 | FromDiscord | <Xydium> I replaced it with recursion that rebuilds the tree node by node, making substitutions where appropriate |
21:08:22 | FromDiscord | <Xydium> ~~because something thinks everything should be passed by value~~ |
21:08:32 | FromDiscord | <Xydium> ~~because someone thinks everything should be passed by value~~ |
21:08:38 | FromDiscord | <mratsim> oh but you are creating an untyped proc with your macro |
21:08:41 | FromDiscord | <mratsim> you can't |
21:08:43 | FromDiscord | <Xydium> Yeah |
21:08:54 | FromDiscord | <Xydium> That was one of your suggestions |
21:09:04 | FromDiscord | <mratsim> untyped macro, not proc |
21:09:04 | FromDiscord | <Xydium> It needs to be varargs[T] |
21:09:07 | FromDiscord | <mratsim> ok |
21:09:15 | FromDiscord | <Xydium> but, |
21:09:29 | FromDiscord | <Xydium> If it's varargs[T], then it does not get the correct type info for operators within the parsed tree |
21:09:49 | FromDiscord | <Xydium> the constraint `Y == X * X` tries to do `x[1] * x[1]` but still thinks x is type T |
21:10:54 | Zevv | sealmove: success: NPeg can now do two stage lexing and parsing! Thanks for helping out! |
21:11:45 | disruptek | nice job, zevv! |
21:12:46 | FromDiscord | <Xydium> Even using the getSubType thing to put the generic parameter into the varargs[] doesn't work for some reason |
21:13:19 | FromDiscord | <Xydium> wait... does my bracketexpression node need to encode the type of the array? |
21:13:52 | FromDiscord | <Xydium> https://nim-lang.org/docs/macros.html#callsslashexpressions-array-access-operator |
21:14:00 | FromDiscord | <mratsim> here you go: https://gist.github.com/mratsim/72d60d9376793a69bfe33aac95aa8e71 |
21:14:43 | FromDiscord | <Xydium> thats all it needed? two extra ``? lmao |
21:14:46 | FromDiscord | <mratsim> the constcall x assign can reuse the x you already defined |
21:14:55 | FromDiscord | <Xydium> That assign is redundant |
21:14:59 | FromDiscord | <mratsim> I removed the generic macro as well |
21:15:46 | FromDiscord | <Xydium> oh I see that now |
21:15:57 | FromDiscord | <Xydium> and got the type info |
21:16:00 | FromDiscord | <mratsim> because I get T instead of the actual instantiation with the generic macro |
21:16:47 | FromDiscord | <mratsim> not too sure what a CSP solver is but it looks interesting |
21:16:53 | FromDiscord | <Xydium> thanks for the help, probably would've taken weeks for me to find the solution |
21:17:07 | FromDiscord | <mratsim> no problem |
21:17:16 | FromDiscord | <Xydium> CSPs are problems where the solution is expressed as a set of variables with values from domains |
21:17:29 | FromDiscord | <Xydium> A really complicated exam is circuit board trace layouts |
21:17:33 | FromDiscord | <Xydium> example* |
21:17:42 | FromDiscord | <mratsim> I did start an ILP solver here but never finished, it was for polyhedral loop optimization but in the end I will take another approach: https://github.com/mratsim/hydra/tree/master/hydra/ilp |
21:18:23 | FromDiscord | <Xydium> One of the classic examples of CSPs is setting colors of regions on (geographical) maps where no adjacent regions may have the same color |
21:18:29 | FromDiscord | <mratsim> the constraint are expressed like this: https://github.com/mratsim/hydra/blob/master/tests/test_sets.nim#L31 |
21:18:34 | FromDiscord | <mratsim> I see |
21:19:22 | FromDiscord | <Xydium> Scheduling is another form of constraint satisfaction |
21:20:19 | FromDiscord | <Xydium> It differs from typical state-space search because a) the sequence of actions (variable assigns) does not matter and b) the path to the solution does not matter |
21:22:44 | Zevv | I will now take up disrupteks habit of naming my releases. |
21:24:03 | disruptek | i'm sorry my names for your releases are mostly 4-letter words. 🙁 |
21:29:05 | * | nsf quit (Quit: WeeChat 2.6) |
21:44:49 | * | clyybber quit (Quit: WeeChat 2.7) |
21:46:12 | * | luis_ quit (Ping timeout: 248 seconds) |
21:47:41 | Zevv | oh who was is then |
21:48:17 | * | Hideki joined #nim |
21:48:40 | * | Hideki is now known as Guest43218 |
21:52:43 | * | Guest43218 quit (Ping timeout: 260 seconds) |
21:59:22 | disruptek | i bestow emojis on releases named after members of the community. 😁 |
22:01:33 | disruptek | maybe the bot should show a release/date for repos/packages it finds. |
22:04:54 | * | luis_ joined #nim |
22:05:49 | luis_ | Hi all, I would really like if someone with some R experience could test the nim rmarkdown engine for linux here: https://github.com/lf-araujo/nimrmarkdown |
22:07:59 | * | luis__ joined #nim |
22:08:35 | * | azed joined #nim |
22:10:12 | * | luis_ quit (Ping timeout: 248 seconds) |
22:12:43 | disruptek | !package diff |
22:12:44 | disbot | https://git.sr.ht/~reesmichael1/nim-simplediff -- 9simplediff: 11A library for straightforward diff calculation |
22:13:20 | disruptek | !package diff |
22:13:21 | disbot | https://github.com/mark-summerfield/diff -- 9diff: 11Library for finding the differences between two sequences |
22:29:01 | * | clyybber joined #nim |
22:33:40 | * | EvergreenTree joined #nim |
22:45:09 | * | natrys quit (Quit: natrys) |
22:54:07 | * | adeohluwa joined #nim |
22:54:49 | * | gour_ joined #nim |
22:54:51 | * | luis__ quit (Remote host closed the connection) |
22:54:57 | * | gour_ quit (Remote host closed the connection) |
22:55:38 | * | solitudesf quit (Ping timeout: 258 seconds) |
22:55:55 | * | adeohluwa quit (Remote host closed the connection) |
22:58:37 | * | gour quit (Ping timeout: 268 seconds) |
23:04:29 | FromGitter | <bung87> @alehander92 I notice you have create new repo for transpiling other language projects to nim |
23:59:15 | FromDiscord | <mratsim> @Clyybber, here you go on the state machine approach: https://github.com/mratsim/weave/pull/63/files |
23:59:15 | FromDiscord | <mratsim> |
23:59:16 | FromDiscord | <mratsim> No perf difference. I'm slightly unhappy about the fact that it doubled my number of lines here, will closely monitor as the codebase is transitioned. |
23:59:16 | disbot | ➥ [WIP] Refactor workers into state machines |