00:01:14 | FromDiscord | <a weird programmer> is it possible to implement my own system that enforces this? or would i have to edit how the compile works? |
00:01:25 | FromDiscord | <a weird programmer> (edit) "compile" => "compiler" |
00:03:16 | FromDiscord | <Elegantbeef> The compiler has no mechanism for this |
00:03:33 | FromDiscord | <Elegantbeef> Almost all Nim code doesnt even use type annotations |
00:04:02 | FromDiscord | <a weird programmer> so if i would go about enforcing this what would my options be? |
00:05:46 | FromDiscord | <Elegantbeef> Fork the compiler |
00:10:19 | FromDiscord | <huantian> or make a style checker and/or linter |
00:10:34 | FromDiscord | <huantian> and make users of your project use it and/or integrate it with your CI |
00:10:54 | FromDiscord | <huantian> (edit) "users" => "contributers" |
00:14:51 | * | moonlit quit (Remote host closed the connection) |
00:15:13 | * | moonlit joined #nim |
00:24:52 | FromDiscord | <Yepoleb> fucking kernel headers are so cursed |
00:24:58 | FromDiscord | <Yepoleb> `u8 addr[][ETH_ALEN]` i hate this |
00:25:29 | FromDiscord | <<She>Horizon</Her>> sent a code paste, see https://play.nim-lang.org/#ix=4iy9 |
00:26:03 | FromDiscord | <a weird programmer> In reply to @Elegantbeef "Fork the compiler": can you point me to what file dictates how vars work? |
00:26:22 | FromDiscord | <Yepoleb> apparently it's syntax to for an array of undetermined size of arrays of ETH\_LEN uint8's |
00:26:55 | FromDiscord | <Elegantbeef> look for semVarStmt or similar↵(@a weird programmer) |
00:27:31 | FromDiscord | <a weird programmer> In reply to @Elegantbeef "look for semVarStmt or": is this the file name? |
00:27:54 | FromDiscord | <Elegantbeef> No |
00:28:19 | FromDiscord | <Elegantbeef> You also will need to ensure that the code you're erroring on isnt in the stdlib or a pkg |
00:28:28 | FromDiscord | <Elegantbeef> It's quite a undertaking for no benefit really |
00:29:03 | FromDiscord | <a weird programmer> yeah |
00:37:18 | FromDiscord | <Rika> the linter would be easier |
00:54:32 | * | pbsds quit (Quit: The Lounge - https://thelounge.chat) |
00:55:32 | * | pbsds joined #nim |
01:07:59 | * | pbsds quit (Quit: The Lounge - https://thelounge.chat) |
01:10:32 | * | pbsds joined #nim |
01:36:11 | FromDiscord | <huantian> and along the way you could make a good nim linter too! |
01:42:58 | FromDiscord | <<She>Horizon</Her>> So NEPs would become a thing? Lmao |
01:43:06 | FromDiscord | <<She>Horizon</Her>> Nim extension proposals |
01:46:52 | FromDiscord | <Elegantbeef> I still say we just need TRMs to work and we get a first class linter |
01:57:53 | FromDiscord | <<She>Horizon</Her>> TRMs? |
01:58:11 | FromDiscord | <Elegantbeef> Term rewriting macros |
01:58:11 | FromDiscord | <<She>Horizon</Her>> Treesitter something? |
01:58:13 | FromDiscord | <Elegantbeef> Pattern matching dispatch macros |
01:58:19 | FromDiscord | <<She>Horizon</Her>> Ah |
02:00:20 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4iyk |
02:00:24 | FromDiscord | <Elegantbeef> In theory should error on `b` but TRMs dont work like you'd expect |
02:23:53 | FromDiscord | <ringabout> It seems that nimble is completely broken with the devel branch. https://github.com/nim-lang/nimble/pull/1041 |
02:43:09 | NimEventer | New thread by Ward: TinyRE - Tiny Regex Engine for Nim, see https://forum.nim-lang.org/t/9723 |
02:54:15 | FromDiscord | <@thatrandomperson5-6310e3b26da03> Is it possible to get the type of this `let hello = makeHelloString()` in a macro, or do i have to explicitly type |
03:07:21 | FromDiscord | <! Nilts> In reply to @@thatrandomperson5-6310e3b26da03 "Is it possible to": If anyone has the answer please ping me because i am not going to be online |
03:07:36 | FromDiscord | <! Nilts> (edit) "me" => "my discord account" |
03:36:56 | NimEventer | New Nimble package! tinyre - Tiny Regex Engine for Nim, see https://github.com/khchen/tinyre |
03:46:35 | * | arkurious quit (Quit: Leaving) |
04:32:27 | FromDiscord | <ringabout> When does `template nodeInfo: var NodeInfo = nodesInfo[node]` change its meaning? |
04:32:57 | FromDiscord | <ringabout> Perhaps the alias templates PR |
04:35:07 | FromDiscord | <sexnine> might be a dumb question and maybe library specific but to compile this nim app (using dimscord lib) i need to build with the flag `-d:ssl` and that works when using `nimble build -d:ssl` but not when using `nimble run -d:ssl`, i dont really feel like building every time and then running the executable, `nimble run` is just easier, is there anything i can do? |
04:35:17 | FromDiscord | <sexnine> (edit) "compile" => "run" |
04:35:27 | FromDiscord | <Elegantbeef> make a `config.nims` with `--define:ssl` |
04:36:23 | FromDiscord | <ringabout> In reply to @ringabout "When does `template nodeInfo:": The templates seems to evaluate its result which doesn't happen in 1.6.10 |
04:36:40 | FromDiscord | <ringabout> (edit) "which doesn't happen in 1.6.10" => "wrong;y" |
04:36:49 | FromDiscord | <ringabout> (edit) "templates" => "template" | "wrong;y" => "wrongly" |
04:37:51 | FromDiscord | <sexnine> In reply to @Elegantbeef "make a `config.nims` with": thank you, helped :thanks: |
04:43:00 | NimEventer | New Nimble package! fitl - Self-contained fit of linear models with regression diagnostics, see https://github.com/c-blake/fitl |
04:48:12 | * | Jjp137 joined #nim |
05:03:02 | FromDiscord | <sexnine> hows nimsuggest v2 compared to v3? is v3 stable and should it be used over v2? |
05:45:24 | FromDiscord | <MetuMortis> I'd like to see a tutorial about how to create a nim dev env |
05:46:49 | FromDiscord | <MetuMortis> VSCode Extension is good but I couldn't create a dev env in Intellij, Neovim or Doom Emacs |
06:11:11 | FromDiscord | <ShalokShalom> In reply to @MetuMortis "VSCode Extension is good": what stopped you in Intellij? |
06:12:00 | FromDiscord | <ShalokShalom> You know this? https://github.com/alaviss/nim.nvim |
06:22:31 | FromDiscord | <Bung> undefined |
06:25:18 | * | ltriant quit (Ping timeout: 252 seconds) |
06:38:44 | FromDiscord | <Freakwill (William Song)> sent a code paste, see https://paste.rs/OtE |
06:41:51 | FromDiscord | <Elegantbeef> Mean is overloaded so passing it as a pointer proc that is generic doesnt give it any information |
06:50:55 | * | tiorock joined #nim |
06:50:55 | * | tiorock quit (Changing host) |
06:50:55 | * | tiorock joined #nim |
06:50:55 | * | rockcavera is now known as Guest9757 |
06:50:55 | * | Guest9757 quit (Killed (cadmium.libera.chat (Nickname regained by services))) |
06:50:55 | * | tiorock is now known as rockcavera |
07:01:17 | FromDiscord | <ynfle> In reply to @@thatrandomperson5-6310e3b26da03 "Is it possible to": @! Nilts What do you mean by "get the type of this in a macro"? What is the macro operating on? If that line is passed in, the macro input param can be `typed` |
07:07:51 | * | kenran joined #nim |
07:09:07 | * | kenran quit (Remote host closed the connection) |
07:22:15 | FromDiscord | <Freakwill (William Song)> thank you. |
07:34:40 | * | PMunch joined #nim |
07:58:14 | * | rockcavera quit (Remote host closed the connection) |
08:13:02 | FromDiscord | <luteva> In reply to @a weird programmer "so if i would": as huntian and beef said: build your own "checker" and throw an error on what you would like to ban. you can then of course use the nim compiler to do the rest. but of yourse you can't use existing code anymore as most of it doesn't have the types annotated. |
08:13:33 | * | junaid_ joined #nim |
08:15:11 | FromDiscord | <Phil> Couldn't you ensure that the checker only checks project-code?↵I mean, in order to gather a list of all files to be checked, gather all nim files referenced in import statements, then all nim files reference in import statements from the second wave of nim files and so on, then throw out everything from within .nimble and analyze the rest.↵Or am I missing something? |
08:15:28 | FromDiscord | <Phil> (edit) "statements," => "statements of the original file you pass to the checker," |
08:15:33 | * | ltriant joined #nim |
08:15:45 | FromDiscord | <Phil> (edit) "Couldn't you ensure that the checker only checks project-code?↵I mean, in order to gather a list of all files to be checked, gather all nim files referenced in import statements of the original file you pass to the checker, then all nim files reference in import statements from the second wave of nim files and so on, then throw out everything from within ... .nimbledirectory" added "the" | "the.nimble ... and" added "direct |
08:16:58 | FromDiscord | <Elegantbeef> Matrix is always fun |
08:17:00 | FromDiscord | <Elegantbeef> Yes you could |
08:17:15 | FromDiscord | <Elegantbeef> I still just say TRM is the true path towards user defined linters |
08:21:13 | FromDiscord | <luteva> @ElegantBeef i wanted to use your constructor/defaults lib and i just tried the examle. But it doesn't work (at least for nim version 1.6.6)↵Here's the message:↵https://discord.com/channels/371759389889003530/371759389889003532/1052230992628289666↵Yo you have any idea how to solve this? |
08:22:18 | * | junaid_ quit (Remote host closed the connection) |
08:22:33 | FromDiscord | <Elegantbeef> yea i guess not use funcs in my code 😄 |
08:27:34 | FromDiscord | <Elegantbeef> 1.0.6 is out |
08:27:53 | FromDiscord | <Elegantbeef> If you do run into any issues please do make an issue on the repo |
08:28:13 | FromDiscord | <Elegantbeef> It's much better than asking a question into the void 😛 |
08:29:34 | FromDiscord | <Elegantbeef> For some reason the compiler thinks `&` has a side effect with `strictFuncs` on 1.6.x |
08:35:18 | FromDiscord | <Phil> In reply to @Elegantbeef "I still just say": TRM? Not aware of the acronym |
08:35:41 | FromDiscord | <Elegantbeef> Term rewriting macros |
08:35:42 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4izd |
08:37:46 | FromDiscord | <Elegantbeef> They use patterns to call macros |
08:55:29 | FromDiscord | <albassort> https://media.discordapp.net/attachments/371759389889003532/1052509121729003550/image.png |
08:55:51 | FromDiscord | <albassort> when will the war crime tribunal see me? |
08:56:14 | FromDiscord | <albassort> eh fuck it I think I'll just do it line by line |
08:56:32 | FromDiscord | <<She>Horizon</Her>> ....@albassort |
08:56:35 | FromDiscord | <<She>Horizon</Her>> What the fuck- |
08:56:53 | FromDiscord | <albassort> sometimes you need to work low level with the keyboard and want broad support |
08:56:55 | * | ltriant_ joined #nim |
08:57:12 | FromDiscord | <<She>Horizon</Her>> Is there no existing library for that? |
08:57:18 | FromDiscord | <albassort> gotta break out keysymdef.h |
08:57:19 | FromDiscord | <<She>Horizon</Her>> Also either way: What the fuck- |
08:57:20 | * | ltriant quit (Ping timeout: 272 seconds) |
08:57:27 | FromDiscord | <albassort> make x11 has it |
08:57:27 | FromDiscord | <<She>Horizon</Her>> In reply to @albassort "gotta break out keysymdef.h": F |
08:58:14 | FromDiscord | <albassort> https://github.com/nim-lang/x11/blob/2093a4c01360cbb5dd33ab79fd4056e148b53ca1/x11/keysym.nim |
08:58:16 | FromDiscord | <albassort> they have this |
08:58:19 | FromDiscord | <albassort> but i dont think its my usecase |
08:58:55 | FromDiscord | <albassort> i want a big fat enum |
09:01:59 | FromDiscord | <albassort> oh god i changed too many things at once everything is broken |
09:34:37 | * | eal left #nim (ERC 5.4.1 (IRC client for GNU Emacs 28.2)) |
09:36:07 | FromDiscord | <luteva> sent a code paste, see https://paste.rs/jyI |
09:57:49 | FromDiscord | <a weird programmer> In reply to @Isofruit "Couldn't you ensure that": thats what i though |
09:58:03 | FromDiscord | <a weird programmer> make it ignore imports and only go through files in the dir |
09:58:16 | FromDiscord | <a weird programmer> sounds like one hell of a project to me |
10:05:25 | FromDiscord | <Elegantbeef> @luteva\: that's to be expected, if you want other behaviour use `constr`'s macro instead |
10:17:28 | * | pro joined #nim |
10:17:57 | * | pro quit (Client Quit) |
10:22:43 | FromDiscord | <luteva> ok. hmmm i do not really uderstand the benefit of constr (in this case). i mean: if i have to write the proc setting the default values the benefit of having the defaults in the type declaration is lost. And a standard initX / newX proc may also set the default values. So i do not see the benefit of the constr macro. |
10:23:18 | FromDiscord | <luteva> but maybe i am just stupid 😜 |
10:24:12 | FromDiscord | <Elegantbeef> Yea it probably doesnt work in this case |
10:25:33 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4izK |
10:25:47 | FromDiscord | <Elegantbeef> Or the equivalent that works |
10:26:05 | FromDiscord | <Elegantbeef> Constructing OOP is quite a chore |
10:26:18 | FromDiscord | <Elegantbeef> Cause you really need a `proc init(myBase: var Base)` |
10:29:40 | FromDiscord | <Elegantbeef> The simple thing is that `defaults` does not work with anything complex, cause it cannot |
10:30:52 | FromDiscord | <Elegantbeef> I guess i could make `implDefaults` more complex to generate calls to the parent types |
10:41:28 | * | FromDiscord quit (Remote host closed the connection) |
10:41:41 | * | FromDiscord joined #nim |
11:22:26 | deadmarshal | How can i prepend something to a sequence? |
11:38:34 | FromDiscord | <luteva> In reply to @Elegantbeef "I guess i could": that would be really great! 😃 |
12:10:30 | * | cyraxjoe quit (Ping timeout: 260 seconds) |
12:10:43 | * | cyraxjoe joined #nim |
12:12:52 | FromDiscord | <Phil> In reply to @deadmarshal "How can i prepend": std/sequtils has an `insert` proc |
12:14:35 | deadmarshal | Phil:awesome |
12:49:27 | * | pro joined #nim |
12:50:55 | FromDiscord | <<She>Horizon</Her>> Anyway to stop a certain object from being managed by the GC in Nim? |
12:51:35 | PMunch | Don't make it a ref object? |
12:51:54 | PMunch | Other than that you can of course GC_ref it manually to make sure the refcount is always >0 |
12:52:14 | * | pro left #nim (#nim) |
12:52:35 | FromDiscord | <<She>Horizon</Her>> Think i found it |
12:52:48 | FromDiscord | <<She>Horizon</Her>> In reply to @PMunch "Don't make it a": I'm using the Minetypes object |
12:52:52 | FromDiscord | <<She>Horizon</Her>> So |
12:55:25 | PMunch | Minetypes? |
12:56:31 | FromDiscord | <<She>Horizon</Her>> Yup |
12:56:33 | FromDiscord | <<She>Horizon</Her>> MimeDB |
12:56:41 | FromDiscord | <<She>Horizon</Her>> And I'm using it with prologue |
12:57:03 | FromDiscord | <<She>Horizon</Her>> So it has to be threadsafe, it works fine now but just in case, plus the warning is annoying so might as well solve it |
13:06:25 | FromDiscord | <albassort> @treeform oi you forgot about the HEAD verb and it through an error because no body |
13:06:39 | FromDiscord | <albassort> (edit) "through" => "throws " |
13:06:43 | FromDiscord | <albassort> (edit) removed "" |
13:07:42 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix=4iAa |
13:08:12 | FromDiscord | <albassort> (edit) "https://play.nim-lang.org/#ix=4iAa" => "https://play.nim-lang.org/#ix=4iAb" |
13:08:40 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix= |
13:10:30 | FromDiscord | <albassort> :notLikeThis: |
13:15:20 | PMunch | Hmm, is there a compile-time version of the `line` pragma? |
13:16:21 | FromDiscord | <Phil> In reply to @PMunch "Don't make it a": Wouldn't making the object a global object make it non-gcable since its in global scope which only dies when the program does? |
13:17:26 | PMunch | Basically I have a macro which reads some files and generates Nim code. Now if there's something wrong in one of the files it will generate incorrect code and trigger a compilation error. But the error trace just points to what in my code generates the code, I tried to use `{.line: .}` to pass it information about which file I read for generation, but this doesn't seem to do anything on compile-time.. |
13:17:40 | PMunch | @Phil, sure, that should work as well |
13:20:09 | FromDiscord | <Phil> In reply to @Event Horizon "And I'm using it": Given that Pmunch just confirmed, would putting the variable into global scope you don't want to have GC'ed work? |
13:21:07 | PMunch | Damn it.. I can get the LineInfo of a NimNode, and I can copy it from one NimNode to another. But I can't seem to just set it.. |
13:23:23 | FromDiscord | <<She>Horizon</Her>> In reply to @Isofruit "Given that Pmunch just": Already did, but it's still giving that warning even if it impacts nothing |
13:24:22 | FromDiscord | <Phil> In reply to @Event Horizon "Already did, but it's": Hmmmmmm I could've sword there was a pragma that allows you do enable/disable GC for sections of code |
13:24:29 | FromDiscord | <Phil> sworn, not sword |
13:24:32 | FromDiscord | <Phil> I don't have a sword |
13:30:47 | FromDiscord | <Phil> Skimming through the pragmas section of the nim manual: I stand corrected |
13:30:51 | FromDiscord | <Phil> (edit) "corrected" => "corrected, can't find one" |
13:35:06 | FromDiscord | <luteva> do you mean GC_ref and GC_unref ? |
13:40:09 | FromDiscord | <Phil> Just looked at it, that's a proc? Could've sword it was a pragma.... but yeah I guess so |
13:41:40 | FromDiscord | <Rika> it doesnt really make sense as a pragma |
13:43:39 | FromDiscord | <ringabout> There is a pragma disabling the gcsafe analysis. |
13:45:39 | FromDiscord | <Phil> Maybe I've disabled gcsafe analysis so much I just think everything related to garbage collection is a pragma |
13:49:06 | FromDiscord | <albassort> is there a function which formats a number with space |
13:49:18 | FromDiscord | <albassort> "eg" " 1" " 2" |
13:52:42 | FromDiscord | <albassort> leading 0s good enough |
13:53:32 | PMunch | https://nim-lang.org/docs/strutils.html#align%2Cstring%2CNatural%2Cchar |
13:53:55 | PMunch | @albassort ^ |
13:55:47 | PMunch | Hmm, is there a way to override `$` with a macro in a scope? |
14:14:19 | FromDiscord | <! Nilts> In reply to @ynfle "<@910899642236043294> What do you": Like thats part of a nodetree that i got |
14:15:03 | FromDiscord | <Phil> In reply to @PMunch "Hmm, is there a": Can't say I succeeded, I ran into similar issues and tried for a while with having `$` methods, but that blew up in my face in its own way and I left saddened and disheartened |
14:16:32 | * | xaltsc_ is now known as xaltsc |
14:17:19 | * | pro joined #nim |
14:17:28 | * | pro left #nim (#nim) |
14:22:08 | FromDiscord | <Phil> In reply to @albassort "is there a function": Did you already browse through strformat? |
14:22:28 | FromDiscord | <Phil> https://nim-lang.org/docs/strformat.html#standard-format-specifiers-for-strings-integers-and-floats↵Sounds like what you need |
14:29:34 | * | rockcavera joined #nim |
14:37:08 | PMunch | @Phil, well I wanted to use a macro that was local to a procedure to transform all $ calls in that procedure only |
14:50:28 | om3ga | Error Success to you all friends! (Microsoft style greeting). I removed libsndfile from my project, raw C code integration is not easy, so I will try now nim-riff for reading wav's. Strange thing, but This is good example why I hate dynamic libraries |
14:50:37 | FromDiscord | <Yepoleb> PMunch\: can't you just replace all calls of $ with some other name instead of trying to replace the definition of $? |
14:52:06 | FromDiscord | <Rika> In reply to @om3ga "Error Success to you": congratulations on successfully failing |
14:52:53 | PMunch | @Yepoleb, well replacing calls is considered bad practice. Causes issues with templates and composeability of macros |
14:54:33 | FromDiscord | <Yepoleb> Is this supposed to work for code you don't control? |
14:54:51 | PMunch | Yes |
14:56:01 | FromDiscord | <Yepoleb> I don't understand why it would cause issues |
14:56:17 | FromDiscord | <Yepoleb> Your macro has to run after all others anyway |
14:56:43 | PMunch | Essentially the system I'm building reads a folder structure of template files, then matches that to objects in Nim and generates a procedure to convert an object into the template representation |
14:58:52 | PMunch | @Yepoleb, well you end up with errors like this: https://github.com/dom96/jester/issues/114 |
15:00:34 | PMunch | I've actually considered writing a guide to macros that would amongst other things go into this. It's easy to write macros in Nim that don't really work that well |
15:04:59 | * | PMunch quit (Quit: Leaving) |
15:06:53 | deadmarshal | How can i find the minimum element in a sequence? something like this? foldr(s,min(a,b)) |
15:09:01 | deadmarshal | I also tried to get all the keys of a table with toSeq(mytable.keys) but it doesn't work. tough it works with .values |
15:09:01 | FromDiscord | <Yepoleb> PMunch\: Makes sense that macros modifying control flow cause issues with templates, but i don't see how replacing a proc name with another changes anything about that |
15:09:02 | FromDiscord | <Vindaar> In reply to @deadmarshal "How can i find": https://nim-lang.org/docs/system.html#min%2CopenArray%5BT%5D |
15:11:27 | FromDiscord | <Yepoleb> If two macros try to replace $ that is of course asking for trouble again but that's not gonna work right anyway |
15:11:50 | deadmarshal | Vindaar:great |
15:18:13 | om3ga | Rika, thanks. It was huge step forward. |
15:19:07 | * | Phytolizer joined #nim |
15:27:21 | * | junaid_ joined #nim |
15:32:21 | * | junaid_ quit (Remote host closed the connection) |
15:39:48 | FromDiscord | <Takemichi Hanagaki> In reply to @PMunch "I've actually considered writing": It would be awesome! |
15:43:15 | FromDiscord | <nonce> sent a code paste, see https://play.nim-lang.org/#ix=4iAS |
15:46:18 | NimEventer | New thread by max: Nim Static linking OpenSSL issue with fork(), see https://forum.nim-lang.org/t/9724 |
15:47:09 | FromDiscord | <Vindaar> In reply to @nonce "hi guys, why is": because your procedure returns a `seq[string]`, but the actual value you return, `sessionFields`, is a `Table` |
15:47:30 | FromDiscord | <nonce> argh |
15:47:35 | FromDiscord | <nonce> thank you |
15:51:28 | * | Phytolizer quit (Ping timeout: 260 seconds) |
15:53:50 | FromDiscord | <@thatrandomperson5-6310e3b26da03> How would i concatnate a string in a macro |
16:22:47 | om3ga | Error: for --gc:arc|orc 'deepcopy' support has to be enabled with --deepcopy:on <--- Is this ok? |
16:22:59 | om3ga | or I did something very wrong |
16:23:20 | om3ga | never seen that error before |
16:23:55 | FromDiscord | <vindaar> depends, did you call `deepCopy` yourself? Or did you call some function that uses `deepCopy`? If it's the latter and it's a library the best idea is to open an issue about it↵(<@709044657232936960_om3ga=5b=49=52=43=5d>) |
16:24:58 | om3ga | vindaar, I don't remember, I will check if deepcopy used in nim-riff |
16:25:00 | FromDiscord | <vindaar> well, if it's a runtime string in the context of the macro, then you do it same as in regular code. if you want to concat two strings that will only exist at actual runtime, you generate the call to `&` (or `add`, `fmt`, `%`, ... depending on what you want to do)) |
16:26:05 | FromDiscord | <vindaar> yes, it uses it https://github.com/johnnovak/nim-riff/blob/61a7428c6136bbf7f82ca6a3148e0742044a6a8b/riff.nim#L529 |
16:40:50 | om3ga | vindaar, unexpected surprise |
17:35:56 | FromDiscord | <@thatrandomperson5-6310e3b26da03> Ok thanks |
17:36:33 | FromDiscord | <@thatrandomperson5-6310e3b26da03> What is the pupouse of “nnkEmpty” in macros? |
17:40:32 | FromDiscord | <vindaar> it's what the name suggests. An empty node. If you have a tree with optional fields, an empty node can be used in such places |
17:43:44 | FromDiscord | <@thatrandomperson5-6310e3b26da03> How come the `repr` only works if you stick nnkEmpty’s everywhere? |
17:49:47 | * | jmdaemon quit (Ping timeout: 265 seconds) |
17:51:28 | * | pro joined #nim |
17:53:25 | * | pro left #nim (#nim) |
17:57:10 | FromDiscord | <a weird programmer> whats the best gc mode to use |
17:57:30 | FromDiscord | <a weird programmer> and why does nim have so many gc modes as well why dont they stick with one and keep refining it |
17:59:25 | FromDiscord | <vindaar> Not sure what you mean, the only thing I can think of is if you're constructing invalid ASTs. Trying to print those breaks `repr` |
18:08:19 | * | rez joined #nim |
18:13:55 | * | moonlit quit (Remote host closed the connection) |
18:14:13 | * | moonlit joined #nim |
18:19:31 | FromDiscord | <auxym> In reply to @a weird programmer "and why does nim": swappable GCs is a feature of Nim. You can use the best GC for your application as they each have strengths and drawbacks. Atm, ORC is probably the best general-purpose choice and will be the default in nim v2 (to be release very soon, probably) |
18:19:52 | FromDiscord | <a weird programmer> In reply to @auxym "swappable GCs is a": isnt arc better? |
18:25:25 | FromDiscord | <auxym> ARC is ORC + cycle collector. If you have cycles, ARC will leak memory. |
18:25:42 | FromDiscord | <auxym> If you don't have cycles, ARC might have very slightly better performance |
18:42:40 | NimEventer | New post on r/nim by SpookyFries: How to extract last three characters of a string?, see https://reddit.com/r/nim/comments/zlyrhw/how_to_extract_last_three_characters_of_a_string/ |
19:04:19 | * | nisstyre quit (Ping timeout: 256 seconds) |
19:17:55 | * | nisstyre joined #nim |
19:50:30 | FromDiscord | <ezquerra> In reply to @auxym "ARC is ORC +": This is not phrased correctly. It’s actually the opposite: ORC is ARC + a cycle collector |
19:51:17 | FromDiscord | <ezquerra> Use arc for real-time systems for example, if you don’t have cycles or do not mind them (e.g. if you can live with the memory that won’t be collected) |
19:54:20 | * | Phytolizer joined #nim |
20:05:48 | * | Phytolizer quit (Ping timeout: 260 seconds) |
20:12:54 | FromDiscord | <aquova> sent a code paste, see https://play.nim-lang.org/#ix=4iCa |
20:19:47 | * | ltriant_ quit (Ping timeout: 260 seconds) |
20:20:39 | * | doug_ joined #nim |
20:21:23 | doug_ | with following progam |
20:22:05 | doug_ | const asize = 10_000_000 |
20:22:05 | doug_ | proc main() = |
20:22:05 | doug_ | var a: array[asize, int] |
20:22:05 | doug_ | main() |
20:22:48 | doug_ | get segmentation fault, but if change asize to 1_000_000 runs ok |
20:23:47 | doug_ | Any thoughts? |
20:26:54 | doug_ | Using Nim Compiler Version 1.6.10 [Linux: amd64] |
20:28:25 | doug_ | Anyone online? |
20:30:20 | doug_ | I have 32GB of main memory |
20:31:30 | * | arkurious joined #nim |
20:31:30 | * | kenran joined #nim |
20:31:52 | * | kenran quit (Remote host closed the connection) |
20:32:46 | FromDiscord | <Elegantbeef> Doug that's stack allocated so you may need to pass an argument to increase your stack size |
20:34:13 | doug_ | Will try that |
20:36:23 | FromDiscord | <Elegantbeef> Should be like `--passC:"--stack,200000000"` |
20:36:38 | FromDiscord | <Elegantbeef> But the solution is still more likely to make it a `ref array[width, T]` |
20:38:11 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4iCf |
20:40:18 | doug_ | nim c --passC:"--stack,20000000" testArray.nim |
20:40:37 | doug_ | unrecognized command-line option ‘--stack,20000000’ |
20:47:18 | doug_ | If I add -d:release it runs ok for asize = 100_000_000 |
20:51:15 | doug_ | changing to ref array[asize, int] also works |
21:21:44 | FromDiscord | <@thatrandomperson5-6310e3b26da03> How would i iterate through the values of a the attributes type? |
21:23:16 | FromDiscord | <auxym> In reply to @ezquerra "This is not phrased": oh yeah, brain fart. |
21:26:57 | FromDiscord | <Elegantbeef> doug it might be `--passL:"-Wl,--stack, yourStackSizeHere` |
21:27:06 | FromDiscord | <Elegantbeef> Though like i said it's much smarter to just use a `ref array` and heap allocate it |
21:27:12 | FromDiscord | <Elegantbeef> No reason putting that massive object on your stack |
21:31:32 | FromDiscord | <daniellowrie (Daniel Lowrie)> Greetings All, I'm having a little trouble with my first attempt at making an HTTPs request with Nim. I've tried the example from the docs...`import httpclient↵var client = newHttpClient(sslContext=newContext(verifyMode=CVerifyPeer))` but I'm getting an error "`undeclared identifier: 'newContext'` . Any help would be much appreciated. |
21:32:09 | FromDiscord | <Elegantbeef> `import std/net` |
21:32:46 | FromDiscord | <daniellowrie (Daniel Lowrie)> sent a code paste, see https://play.nim-lang.org/#ix=4iCv |
21:33:23 | FromDiscord | <daniellowrie (Daniel Lowrie)> sent a long message, see http://ix.io/4iCw |
21:35:44 | FromDiscord | <daniellowrie (Daniel Lowrie)> That worked! Thanks @elegantbeef\:matrix.org ! |
21:35:59 | FromDiscord | <Elegantbeef> Gitter is really a joke client now isnt it 😄 |
21:36:41 | FromDiscord | <Elegantbeef> \For context overhere you typed my name + homeserver |
21:37:00 | FromDiscord | <Elegantbeef> Oh that's what it shows in gitter aswell |
21:37:26 | FromDiscord | <daniellowrie (Daniel Lowrie)> DOH!!! Sorry bout that |
21:37:57 | FromDiscord | <Elegantbeef> It doesnt really matter to me, i just find gitter very funny given how many things it does |
21:38:18 | FromDiscord | <Elegantbeef> Like code blocks are converted into HTML so are unreadable in discord land |
21:38:38 | FromDiscord | <daniellowrie (Daniel Lowrie)> Well that seems reasonable LOL |
21:39:21 | FromDiscord | <daniellowrie (Daniel Lowrie)> I haven't really used Gitter, so I'm just now experiencing all its glorious splendor |
21:40:03 | FromDiscord | <Elegantbeef> It's in a weird state now that it's matrix backed |
21:48:48 | FromDiscord | <a weird programmer> In reply to @a weird programmer "sounds like one hell": remember this |
21:49:01 | FromDiscord | <a weird programmer> i got a prototype working in python |
22:01:15 | FromDiscord | <c4ulmu> sent a code paste, see https://play.nim-lang.org/#ix=4iCE |
22:04:12 | FromDiscord | <Elegantbeef> You cannot make destroy hooks for ref objects |
22:04:28 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4iCF |
22:05:12 | FromDiscord | <c4ulmu> ok, I see. Thank you |
22:11:57 | * | tiorock joined #nim |
22:11:57 | * | tiorock quit (Changing host) |
22:11:57 | * | tiorock joined #nim |
22:11:57 | * | rockcavera quit (Killed (sodium.libera.chat (Nickname regained by services))) |
22:11:57 | * | tiorock is now known as rockcavera |
22:13:30 | * | doug_ quit (Ping timeout: 252 seconds) |
22:16:43 | FromDiscord | <jos> https://media.discordapp.net/attachments/371759389889003532/1052710755423768576/image.png |
22:16:47 | FromDiscord | <jos> why do my macros look like this |
22:16:50 | FromDiscord | <jos> am i doing something stupid |
22:17:15 | FromDiscord | <jos> is there like a library or something that makes reading the AST more ergonomic |
22:17:41 | FromDiscord | <jos> in rust with syn and dart's metaprogramming u actually have the whole AST strongly typed just in little structs, it reads quite nice |
22:18:30 | FromDiscord | <Gumbercules> There's an ast pattern matching library |
22:18:44 | FromDiscord | <Elegantbeef> https://github.com/beef331/micros/ exists |
22:18:45 | FromDiscord | <Elegantbeef> It doesnt cover the entire AST but it has a lot of it |
22:19:07 | FromDiscord | <Gumbercules> Rust doesn't offer the metaprogramming capabilities of Nim either... |
22:19:27 | FromDiscord | <Elegantbeef> technically my micros package also has a sort of pattern matching on AST |
22:19:30 | FromDiscord | <Gumbercules> And the AST is strongly typed. |
22:19:55 | FromDiscord | <Gumbercules> (edit) "the" => "Nim's" |
22:20:07 | FromDiscord | <Elegantbeef> But it's not a full on pattern matching you can just match based off node types |
22:20:09 | FromDiscord | <Elegantbeef> https://github.com/beef331/micros/blob/master/tests/tcasemacro.nim#L8-L43 |
22:20:14 | FromDiscord | <Elegantbeef> Not the most clean solution 😄 |
22:24:46 | * | jmdaemon joined #nim |
22:27:33 | FromDiscord | <Elegantbeef> I will say I very much think something like micros should be the "way to write macros", treating all AST as the same type is just a tedious API |
22:27:56 | FromDiscord | <Elegantbeef> In most cases no one needs to know the low level API a high level static typed API is much simpler to read |
22:29:08 | * | ltriant joined #nim |
22:43:39 | FromDiscord | <jos> In reply to @Gumbercules "And Nim's AST is": i can't remember why i have code like the screenshot above (i wrote it a long time ago) but i didn't see anything like "functionNode.arguments" and instead wrote stuff like "genericNode.child[4]" |
22:43:45 | FromDiscord | <jos> that's what i mean by strongly typed |
22:43:47 | FromDiscord | <jos> does that exist? |
22:45:00 | FromDiscord | <Gumbercules> In reply to @jos "does that exist?": Nim stores its AST in a tree structure similar to how you'd store a deserialized JSON object |
22:45:42 | FromDiscord | <Gumbercules> the AST needs to be dynamic to support the mutations that you can perform at compile time |
22:46:22 | FromDiscord | <Gumbercules> but no there isn't a type defined for every type of NimNode |
22:46:25 | FromDiscord | <Gumbercules> which is what I believe you're asking |
22:46:27 | FromDiscord | <jos> i think u could probably express it statically |
22:46:32 | FromDiscord | <jos> ye that's my question |
22:46:42 | FromDiscord | <Gumbercules> well it can be changed at comile time |
22:46:53 | FromDiscord | <Gumbercules> so expressing it statically can be difficult since it can also be mutated in a static context |
22:47:08 | FromDiscord | <Gumbercules> take for instance a node that represents a pragma |
22:47:15 | FromDiscord | <jos> that's true, i guess if you're actually literally mutating it instead of just `fn(ast) -> ast` |
22:47:20 | FromDiscord | <jos> it would be cumbersome |
22:47:35 | FromDiscord | <jos> it would still be nice to have a static way to access it for read, but i think that's what the ast pattern matching lib mentioned above was? |
22:47:38 | FromDiscord | <jos> i'll take a look at that |
22:48:14 | FromDiscord | <Gumbercules> let me link |
22:48:27 | FromDiscord | <Gumbercules> https://github.com/krux02/ast-pattern-matching |
22:48:34 | FromDiscord | <Gumbercules> take for instance a pragma node in the Nim AST |
22:49:25 | FromDiscord | <Gumbercules> pragmas are composed by combining different keywords - so the pragma itself is a dynamic collection of these keywords |
22:49:29 | FromDiscord | <Gumbercules> and you can invent custom pragmas |
22:50:17 | FromDiscord | <Gumbercules> many nodes in Nim's AST fall under this category where the can be composed of many different values - so yeah as you said you can imagine how this gets difficult to express in a static context |
22:50:21 | FromDiscord | <c4ulmu> Hey, I have another question. If I create a thread using `createThread` how do I return result of the execution (especially if it is a ref object) of this thread?↵I want to know how to do it without `spawn` and `threadpool`. I think I can use channels, but I thought maybe there is some other way? Maybe someone can explain how FlowVar do this? |
22:50:33 | FromDiscord | <Gumbercules> the reason Rust can be more explicit about things is because it can't do much of what Nim can via its macros |
22:50:51 | FromDiscord | <jos> makes sense-- thanks! i'll take a look at some of the libs ppl posted above |
22:50:57 | FromDiscord | <jos> if anyone knows any more lmk 🙂 |
22:53:47 | FromDiscord | <Gumbercules> Rust's macros simply operate on a stream of tokens but doesn't work on the actual AST |
22:54:14 | FromDiscord | <Gumbercules> so Nim's macros are much closer to Lisp macros vs Rust/C++ |
22:55:01 | FromDiscord | <! Nilts> Is it possible to iterate through the attributes of a type? It'd be useful for stuff like string reprs |
22:55:07 | FromDiscord | <Gumbercules> In reply to @c4ulmu "Hey, I have another": I don't think you can use `FlowVar` here - why don't you just have some global that you lock |
22:55:21 | FromDiscord | <Gumbercules> In reply to @not logged in "Is it possible to": `fields` I think? |
22:55:37 | FromDiscord | <Gumbercules> https://nim-lang.org/docs/iterators.html#fieldPairs.i%2CT |
22:56:24 | FromDiscord | <! Nilts> thanks! |
22:56:47 | FromDiscord | <Gumbercules> In reply to @Gumbercules "I don't think you": and if you want to know when it is set and the thread assigns it use a semaphore |
22:57:12 | FromDiscord | <Gumbercules> flowvars are using locks / semaphores anyway under the hood |
22:57:34 | FromDiscord | <Gumbercules> I think just using them yourself is much cleaner and more clear than using anything from `threadpool` but this is personal preference and coming from someone who does quite a bit of multithreading in Nim |
22:58:05 | FromDiscord | <Gumbercules> (note I don't use `threadpool` or any of Nim's higher level abstractions related to concurrency and parallelism` |
22:58:17 | FromDiscord | <Gumbercules> (edit) "parallelism`" => "parallelism)" |
22:59:55 | * | doug_ joined #nim |
23:14:27 | FromDiscord | <! Nilts> Anyone have a good list on the special procs in nim? like `$`, `[]` and `[]=` |
23:18:57 | FromDiscord | <Elegantbeef> They arent special they're just procs |
23:19:18 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/manual.html#lexical-analysis-operators |
23:20:39 | FromDiscord | <Phil> In reply to @Elegantbeef "https://github.com/beef331/micros/ exists": Question, you got docs for somebody trying to understand how to use micros assuming they have only very basic understanding of nim macros? |
23:20:43 | FromDiscord | <! Nilts> sent a code paste, see https://play.nim-lang.org/#ix=4iCV |
23:26:45 | FromDiscord | <Elegantbeef> I suppose i should do that |
23:27:55 | FromDiscord | <Phil> I can understand that that's highly annoying... but on the bright-side, if you use nimibook, you can make your CI pipelines break when your code changes enough to make your examples go out of date |
23:27:58 | * | doug_ quit (Remote host closed the connection) |
23:28:06 | FromDiscord | <Phil> So at least you can make sure that your docs are always valid |
23:28:12 | FromDiscord | <Elegantbeef> Or i can just use Nimdoc↵(@Phil) |
23:28:33 | FromDiscord | <Phil> Both sounds also pretty good! |
23:28:44 | FromDiscord | <Phil> One for reference, one for introduction |
23:29:10 | FromDiscord | <c4ulmu> Ohh, I have a lot of questions about multithreading in Nim!If I have a global hash table it is ref object (or has ref under the hood). Then I can't use it inside thread. Nim complains that I use gc unsafe staff.↵Is it ok to wrap hash table access code inside thread function in `{.gcsafe.}` and use lock to access hash table? Or it is considered as bad practice?↵(@Gumbercules) |
23:30:03 | FromDiscord | <Elegantbeef> The issue with making docs for a macro library is I dont want to explain macros in side the API 😄 |
23:31:25 | FromDiscord | <Phil> That is fair, but I also have been trying to find my own "in" for learning macros and so far it's not been easy enough to pick up while at the same time I couldn't find something that grabbed me to the point of "I want to have that" that would lead to me biting my way towards enlightenment to get proficient with macros 😛 |
23:31:55 | FromDiscord | <Phil> (edit) "macros" => "macros, so I'd love to try via learning through micros" |
23:34:21 | FromDiscord | <Elegantbeef> It's just such a hard thing to explain, all my tests are pretty much the best documentation i can think of |
23:36:33 | FromDiscord | <Elegantbeef> Like i dont see this being that helpful |
23:36:33 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/1052730850699116554/image.png |
23:36:47 | * | ltriant quit (Read error: Connection reset by peer) |
23:37:14 | FromDiscord | <Elegantbeef> If you use `orc` or `arc` you can do `{.cast(gcSafe).}:....` |
23:38:06 | * | ltriant joined #nim |
23:39:08 | FromDiscord | <Phil> In reply to @Elegantbeef "image.png": I mean, I understand you're defining the return type of the proc and changing it from "nothing" to "value given to the pragma" |
23:39:12 | FromDiscord | <Elegantbeef> gcSafe is to protect from race conditions of course, but Nim's multithreading doesnt really have fantastic methods of sharing without the new 'experimental' threading module at nim-lang/threading |
23:39:25 | FromDiscord | <Phil> I don't quite get why you're doing it 2 different ways and how they differ from one another though |
23:39:37 | FromDiscord | <Elegantbeef> The entire point is Macros vs micros here |
23:39:55 | FromDiscord | <Elegantbeef> They differ in that one way uses `std/macrs` the other uses `micros` |
23:40:15 | FromDiscord | <Elegantbeef> IE one is statically typed and cleaner 😛 |
23:44:50 | FromDiscord | <Elegantbeef> With a global table you'd use `SharedPtr[Table[X, Y]]` |
23:45:52 | FromDiscord | <c4ulmu> Can you make a simple example, or may be send a link in docs? |
23:46:11 | FromDiscord | <c4ulmu> Sorry 😐 |
23:46:13 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/threading/blob/master/threading/smartptrs.nim#L97 |
23:46:53 | FromDiscord | <Elegantbeef> I dont even know if `SharedPtr[Table[X, Y]]` works as one expects |
23:52:04 | FromDiscord | <c4ulmu> Ok, one last question for today. ↵If I have a deque of strings (or other ref objects) then I start threads and they pops elements from this deque (protected by lock and cast(gcsafe)). And I use Orc.↵Will this strings be moved to the threads and then gc'ed(cleaned up) by the threads? |
23:52:47 | FromDiscord | <Elegantbeef> Ownership should be given to the callsite |
23:52:52 | FromDiscord | <Elegantbeef> But dont take that as gospel |
23:52:57 | FromDiscord | <Elegantbeef> I hardly ever use multithreading 😄 |
23:53:50 | * | brettgilio quit (Quit: The Lounge - https://thelounge.chat) |
23:56:39 | FromDiscord | <c4ulmu> I recently realized, that a lot of languages doesn't support normal threading.↵For example\: python, ruby, Lua, smalltalk, JavaScript. All single threaded (GIL)↵Even golang doesn't give you mess with threads directly only via scheduler and gorutines |