00:10:06 | FromDiscord | <dan> In reply to @impbox "(best to ask your": hi! sorry, i went to sleep an hour after i tagged you yesterday, but my question was concerning the build process of nim stuff, when using just the generated c files |
00:12:06 | FromDiscord | <dan> i looked through nico a bit and saw something that looked like it could work for me. you use a dump command there and read the second to last element. im guessing thats the path to the nim standard library. is it guaranteed to be the second to last always? and how did you arrive at that solution? |
00:13:46 | FromDiscord | <impbox [ftsf]> pretty sure i just copied someone else's solution |
00:13:56 | FromDiscord | <dan> 😂 |
00:14:06 | FromDiscord | <dan> do you remember who so i can annoy him? |
00:14:26 | FromDiscord | <dan> (edit) "him?" => "them?" |
00:14:38 | FromDiscord | <impbox [ftsf]> i don't know where i got it from sorry |
00:21:11 | FromDiscord | <dan> alright thank you anyways |
00:21:42 | FromDiscord | <dan> taking a look at nico has brought me a bit close to actually integrating nim into my work project |
00:21:50 | FromDiscord | <dan> (edit) "close" => "closer" |
01:49:05 | FromDiscord | <@bracketmaster-5a708063d73408ce4> I'm currently fighting macros |
01:49:05 | FromDiscord | <@bracketmaster-5a708063d73408ce4> https://play.nim-lang.org/#ix=3tzc |
01:49:23 | FromDiscord | <@bracketmaster-5a708063d73408ce4> How can I make line 11 work? ↵↵var instance = sometype(str.len).uint64 |
01:53:47 | FromDiscord | <ElegantBeef> Is the macro supposed to emit this or use it internally? |
01:53:59 | FromDiscord | <@bracketmaster-5a708063d73408ce4> use it internally |
01:55:29 | * | stkrdknmibalz joined #nim |
01:56:16 | FromDiscord | <@bracketmaster-5a708063d73408ce4> that's a dummy example - but essentially the same problem I'm having in a larger codebase |
01:57:45 | FromDiscord | <ElegantBeef> I dont know if this is possible |
01:57:54 | FromDiscord | <@bracketmaster-5a708063d73408ce4> is this impossible? |
01:57:55 | FromDiscord | <@bracketmaster-5a708063d73408ce4> basically, I've got my own internal bigint library that uses arrays instead of seqs |
01:57:55 | FromDiscord | <@bracketmaster-5a708063d73408ce4> so the max value of a bigint is fixed after compilation |
01:58:03 | FromDiscord | <@bracketmaster-5a708063d73408ce4> I use macros to do computation to consume a string value and determine the needed array size for a big int |
01:58:24 | FromDiscord | <@bracketmaster-5a708063d73408ce4> but the macro need to start with a smaller bigint and keep making larger ones |
01:58:36 | FromDiscord | <@bracketmaster-5a708063d73408ce4> until it finds a sufficiently sized one |
01:59:25 | FromDiscord | <@bracketmaster-5a708063d73408ce4> because you don't know how many binary digits a large number such as "1234567898765432345678765" might need before you convert it to binary |
02:03:53 | FromDiscord | <ElegantBeef> I might be able to help with you more elaborate example |
02:03:58 | FromDiscord | <ElegantBeef> (edit) "you" => "your" |
02:04:23 | FromDiscord | <@bracketmaster-5a708063d73408ce4> My codebase is private - I guess I could push it public |
02:06:07 | FromDiscord | <ElegantBeef> Well a small practical example to see what could be worked around would be nice 😄 |
02:06:56 | FromDiscord | <@bracketmaster-5a708063d73408ce4> shouldn't this work? |
02:06:57 | FromDiscord | <@bracketmaster-5a708063d73408ce4> https://paste.debian.net/1205079/ |
02:08:47 | FromDiscord | <ElegantBeef> Not ideal but this "works" https://play.nim-lang.org/#ix=3tzg |
02:10:23 | FromDiscord | <@bracketmaster-5a708063d73408ce4> ok - that might help me solve my other problem |
02:10:29 | FromDiscord | <@bracketmaster-5a708063d73408ce4> but "why" does that work? |
02:10:34 | FromDiscord | <@bracketmaster-5a708063d73408ce4> what's going on there? |
02:12:13 | FromDiscord | <ElegantBeef> I think due to the type being derived from a parameter it's considered a runtime value on not compile time |
02:12:27 | FromDiscord | <ElegantBeef> It may possibly be a bug |
02:14:10 | FromDiscord | <@bracketmaster-5a708063d73408ce4> is your solution exploiting a bug? |
02:14:31 | FromDiscord | <ElegantBeef> No it may be working around one |
02:31:08 | FromDiscord | <ElegantBeef> Though the issue with the work around is it may require import macros in the submodule |
02:31:13 | FromDiscord | <ElegantBeef> (edit) "submodule" => "importing module" |
02:32:16 | FromDiscord | <@bracketmaster-5a708063d73408ce4> oof |
03:25:49 | * | arkurious quit (Quit: Leaving) |
03:29:45 | * | tiorock joined #nim |
03:29:46 | * | tiorock quit (Changing host) |
03:29:46 | * | tiorock joined #nim |
03:29:46 | * | rockcavera quit (Killed (lithium.libera.chat (Nickname regained by services))) |
03:29:46 | * | tiorock is now known as rockcavera |
04:05:42 | FromDiscord | <Jakraes> Is it not possible to assign a var to a parameter and then assign a new value to said parameter? |
04:05:44 | FromDiscord | <Jakraes> Like this |
04:06:02 | * | supakeen quit (Quit: WeeChat 3.2) |
04:06:36 | * | supakeen joined #nim |
04:07:11 | FromDiscord | <Jakraes> sent a code paste, see https://play.nim-lang.org/#ix=3tzG |
04:07:48 | * | springb0k quit (Ping timeout: 252 seconds) |
04:10:10 | FromDiscord | <Jakraes> Oooh nvm |
04:10:20 | FromDiscord | <Jakraes> Just found out I can do test(p: var int) |
04:15:07 | FromDiscord | <Bung> is it possible create a code placeholder, when user call some function, inject code there? |
04:15:07 | * | springb0k joined #nim |
04:16:19 | FromDiscord | <Rika> I'm sorry I don't understand well, but isn't that just a template? |
04:16:58 | FromDiscord | <Bung> but template inject code where it called |
04:19:15 | FromDiscord | <Rika> You can have a macro or template that acts as a pragma to a function which then could change the function body if that's what you're looking for |
04:19:25 | FromDiscord | <Rika> It's how the async pragma works |
04:19:57 | FromDiscord | <Bung> like aExpr;bTemplateExpand;cExpr this is template and macros works |
04:20:42 | FromDiscord | <Bung> what I want I call aFunc somewhere the body will inject to aExpr; |
04:23:07 | FromDiscord | <Bung> in other words, like declare a nim node, when user call func assign body to nim node, I detect it's not nil , I execute it somewhere. |
04:24:06 | FromDiscord | <ElegantBeef> As in recent fashion i think macrocache might help but uncertain the desire, want to show a "desired impl" so i could understand |
04:28:14 | FromDiscord | <Bung> sent a code paste, see https://play.nim-lang.org/#ix=3tzK |
04:28:36 | FromDiscord | <Bung> it's like this, I just dont want store procs in runtime |
04:28:55 | FromDiscord | <ElegantBeef> Ah then yes macrocache to the rescue, will quickly make an example |
04:31:09 | FromDiscord | <Bung> oh, that save me, so I just add nimnode to a macrocache storage. |
04:31:50 | FromDiscord | <ElegantBeef> https://play.nim-lang.org/#ix=3tzN yep |
04:32:03 | FromDiscord | <ElegantBeef> `impl` in the first should be typed |
04:32:18 | FromDiscord | <ElegantBeef> that way it gets `sym` not `untyped` |
04:32:35 | FromDiscord | <ElegantBeef> (edit) "`untyped`" => "`ident`" |
04:34:01 | FromDiscord | <ElegantBeef> Proper version that will work across modules https://play.nim-lang.org/#ix=3tzQ |
04:36:19 | FromDiscord | <Bung> hmm how they work differently ? |
04:36:20 | FromDiscord | <Jakraes> Uuuh quick question, what's up with this? I'm not sure what the error might be https://media.discordapp.net/attachments/371759389889003532/867263699961905162/Screenshot_3.png |
04:36:40 | FromDiscord | <ElegantBeef> typed is semantically checked so you arent emitting untyped code |
04:37:07 | FromDiscord | <Jakraes> How so? Sorry I don't really understand what you mean |
04:37:18 | FromDiscord | <ElegantBeef> Not in response to you |
04:37:34 | FromDiscord | <Jakraes> Oh gotcha |
04:37:36 | FromDiscord | <ElegantBeef> What's `vector.startX`? |
04:37:47 | FromDiscord | <Jakraes> Oh nvm, I can just include everything inside the float64 |
04:37:51 | FromDiscord | <Bung> oh , it's just safer I think |
04:38:01 | * | springb0k quit (Ping timeout: 268 seconds) |
04:38:05 | FromDiscord | <Jakraes> It's the starting position of a vector |
04:38:42 | FromDiscord | <ElegantBeef> In reply to @Bung "oh , it's just": No it just works, cause without `typed` you get identifiers which means unless that symbol exists in the scope of `callImpl` it will not function |
04:40:50 | FromDiscord | <Bung> okay, I'll use typed version as the Impl may coming from nimble package I think |
04:41:11 | FromDiscord | <ElegantBeef> well with out it just wont work when imported |
04:45:16 | * | springb0k joined #nim |
04:50:43 | * | springb0k quit (Ping timeout: 265 seconds) |
04:55:02 | FromDiscord | <Bung> the impl part is proc , how can call it with args ? |
04:57:14 | FromDiscord | <Bung> oh, get it , get proc name node |
04:59:13 | FromDiscord | <ElegantBeef> Yea remember you can also change `typed` to any type so it's semantically checked |
05:01:23 | FromDiscord | <Bung> yeah , like proc(req:Request) |
05:21:23 | FromDiscord | <Bung> I get `postProcessMiddlewares.len` == 0 in macro |
05:22:19 | FromDiscord | <ElegantBeef> Without code to look at that doesnt mean much |
05:25:12 | FromDiscord | <Bung> pls check https://github.com/bung87/scorper/commit/a534d9b6281b3612a442a77b349c743a534cd932 |
05:26:53 | FromDiscord | <ElegantBeef> Yea this is somewhat dependant on import order so you need to have the use site in a different file that's imported after subscription, or have an `implStuff` somewhere |
05:28:51 | FromDiscord | <ElegantBeef> You could make `processClient` a macro which inserts the calls where they need to |
05:31:56 | FromDiscord | <ElegantBeef> The issue being that it gets the macros, then finalizes the `processClient` so then embeds nothing since it hasnt had any calls to `implPreProcessMiddleware` |
05:31:58 | FromDiscord | <Bung> hmm , guess I'll seperate Request to other file, but it has many private fields. |
05:32:47 | FromDiscord | <ElegantBeef> I do wonder if you couldnt just put it in a template |
05:33:44 | FromDiscord | <Bung> processClient ? that's a proc pass to a proc as callback |
05:35:48 | FromDiscord | <ElegantBeef> Sure but i mean something like this https://play.nim-lang.org/#ix=3tA6 not idea though |
05:36:02 | FromDiscord | <ElegantBeef> No clue if it even compiles truthfully 😄 |
05:36:42 | FromDiscord | <ElegantBeef> You need something to late bind that procedure to a callsite 😄 |
05:39:29 | FromDiscord | <Bung> hmm , that does not compiled |
05:40:19 | FromDiscord | <Bung> in the end I'll seperate Request type to other file |
05:41:34 | FromDiscord | <Bung> import scoper/middlewaremacro ; imp it; import scorper make this works I think. |
05:43:57 | FromDiscord | <ElegantBeef> Ah yes i see why it didnt solve the issue, didnt realize you called this later in this file |
05:45:22 | FromDiscord | <Bung> yeah, just some kind not friendly to user, that import order are imortant. |
05:45:59 | FromDiscord | <ElegantBeef> Yea it's why i did the whole `implNimScriptModule` in the nimscripter rewrite, it means that import order doesnt matter just calling that after all subscriptions does |
05:46:45 | FromDiscord | <Bung> oh, I did not aware it handle this case. |
05:46:50 | FromDiscord | <ElegantBeef> So it kinda sucks, but if you can make it so the user just has an `init` like call it'd make it easier |
05:47:06 | FromDiscord | <Bung> that's cool |
05:48:08 | FromDiscord | <ElegantBeef> Yea the macrocache is quite awesome |
05:49:07 | FromDiscord | <Bung> it's cool I face use cases in two projects just in few days. |
05:52:47 | * | rockcavera quit (Remote host closed the connection) |
06:04:00 | fn | <ForumUpdaterBot99> New Nimble package! harpoon - HTTP Client, see https://github.com/juancarlospaco/harpoon |
06:04:01 | fn | <R2D299> itHub: 7"HTTP Harpoon, HTTP Client" |
06:35:10 | * | Vladar joined #nim |
06:39:00 | FromDiscord | <haxscramper> In reply to @theangryepicbanana "yeah I've seen that,": `Infix[Ident(strVal: "+"), @lhs, @rhs]` |
06:52:57 | * | sagax joined #nim |
07:09:07 | * | max22- joined #nim |
07:09:24 | * | max22- quit (Remote host closed the connection) |
07:09:46 | * | max22- joined #nim |
07:38:07 | FromDiscord | <Bung> how you declare two type that reference each other in fields? |
07:38:17 | FromDiscord | <Rika> in the same type block |
07:38:42 | FromDiscord | <Bung> how about seperated files ? |
07:39:14 | FromDiscord | <Rika> impossible w/o experimental package type i believe |
07:41:27 | FromDiscord | <Bung> oh , I stuck in old problem. |
07:44:38 | FromDiscord | <Bung> hmm , I dont need to do this. |
07:53:23 | * | fredrikhr joined #nim |
07:59:28 | FromDiscord | <Bung> can I give param a cast by default ? I dont want write cast in every interfaces body |
10:00:50 | FromDiscord | <haxscramper> What is the correct way to convert `.nimcall.` procvar into `.closure.`? Right now I have `proc toClosure(arg: proc() {.nimcall.}): proc() {.closure.} = arg`, which does not seem like a good solution (is it safe to just take nimcall and return closure?)↵\` |
10:01:05 | FromDiscord | <haxscramper> On top of that - this would require writing 2xN overloads for any number of arguments (for procvar with return value and without) |
10:01:26 | FromDiscord | <haxscramper> Last part it the most troublesome one |
10:20:19 | * | krux02 joined #nim |
10:34:13 | * | fredrikhr quit (Read error: Connection reset by peer) |
11:01:51 | * | max22- quit (Ping timeout: 268 seconds) |
11:21:33 | * | fredrikhr joined #nim |
11:27:35 | * | fredrikhr quit (Read error: Connection reset by peer) |
11:30:58 | * | fredrikhr joined #nim |
11:37:41 | * | arkurious joined #nim |
11:58:18 | * | krux02 quit (Remote host closed the connection) |
12:05:36 | FromDiscord | <theangryepicbanana> In reply to @haxscramper "`Infix[Ident(strVal: "+"), @lhs, @rhs]`": still not direct pattern matching, but I suppose it's the best I'll get in nim |
12:05:37 | fn | <ForumUpdaterBot99> New post on r/nim by thprogramador: Nim baazar, see https://reddit.com/r/nim/comments/ooohy8/nim_baazar/ |
12:06:01 | * | supakeen quit (Quit: WeeChat 3.2) |
12:06:08 | FromDiscord | <haxscramper> In reply to @theangryepicbanana "still not direct pattern": What do you mean by "direct pattern matching" then |
12:06:37 | * | supakeen joined #nim |
12:07:00 | FromDiscord | <theangryepicbanana> In reply to @haxscramper "What do you mean": like syntax-based pattern match, could look something like `@lhs + @rhs` |
12:16:26 | FromDiscord | <haxscramper> In reply to @theangryepicbanana "like syntax-based pattern match,": https://play.nim-lang.org/#ix=3tBo |
12:16:46 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3tBp |
12:21:27 | FromDiscord | <haxscramper> https://play.nim-lang.org/#ix=3tBr |
12:21:44 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3tBs |
12:22:16 | FromDiscord | <haxscramper> Retains all properties of pattern matching (like automatically declaring `@head` as `Option` if it participates only in one variant of the arm) |
12:22:45 | FromDiscord | <haxscramper> ~27 lines total, most likely it has some bugs but not too much as it is dead-simple transform |
12:30:50 | FromDiscord | <haxscramper> I think this is a good example why implicitly overloading `case` is not a good idea |
13:18:03 | * | rockcavera joined #nim |
13:18:03 | * | rockcavera quit (Changing host) |
13:18:03 | * | rockcavera joined #nim |
13:21:13 | arkanoid | When I have long function and I want to split it, I'm not sure if the best nim approach is to create more root level functions, or more inner closures, or create inner "block" s |
13:21:33 | FromDiscord | <haxscramper> Create more functions |
13:22:49 | * | Vladar quit (Quit: Leaving) |
13:23:33 | arkanoid | I'm unsure about creating more root level functions as it may fracture the sequential logic into pieces that really are sequential |
13:24:39 | arkanoid | Closures seems somehow better fit. They really say: those procs are just for this outer proc |
13:24:52 | FromDiscord | <haxscramper> I don't understand the problem. If you have a block of code that can has some "inputs" and some "outputs" then you can put it in function |
13:25:06 | FromDiscord | <haxscramper> Making it a closure is just looks like fancy indentation to me |
13:25:25 | FromDiscord | <haxscramper> Same with `block` |
13:25:36 | FromDiscord | <haxscramper> You want to create a closure and immediately call it? |
13:25:53 | arkanoid | It is fancy indentation. The target here is to make it more readable/maintenable, non to reuse code. |
13:25:56 | FromDiscord | <haxscramper> we have templates for that |
13:26:24 | FromDiscord | <haxscramper> cheaper than closure, no need for to pay for indentation |
13:26:56 | arkanoid | I don't see how templates joins the party |
13:27:22 | FromDiscord | <haxscramper> Put code in the template and use it the same way as function |
13:29:52 | arkanoid | Arent block: blocks scopes handled at compile time too? |
13:30:16 | FromDiscord | <haxscramper> They are handled at compile-time too, yes |
13:30:50 | FromDiscord | <haxscramper> If you are looking to just add more scopes use block |
13:31:40 | arkanoid | I mean, while I do see disadvantaged for calling unnecessary non-inlined procs just for splitting, templates for the cause seems like improper usage of them |
13:31:49 | arkanoid | Like "why a template here" |
13:32:14 | FromDiscord | <haxscramper> You have large proc you want to split into parts, correct? |
13:32:22 | FromDiscord | <haxscramper> somehow |
13:32:51 | arkanoid | Yes, but parts are not really reusable. They would become private parts of the module. Maximum level of encapsulation |
13:33:27 | FromDiscord | <haxscramper> So what is wrong with putting the parts in the procedure and not exporting it? |
13:33:55 | FromDiscord | <haxscramper> Or adding `# section that does <thing>` comments |
13:34:37 | FromDiscord | <haxscramper> If parts are not reusable it does not mean you are forbidden from putting them to other procs |
13:34:58 | arkanoid | # comment is what I have now. It works, but future me can't assume that variables of one part are not used further down |
13:35:25 | FromDiscord | <haxscramper> Then simply add `block` |
13:35:55 | FromDiscord | <haxscramper> Still ton of code in one place, and I would not classify it as "splitting" proc, but if that's what you are after it should be the best option |
13:36:18 | FromDiscord | <haxscramper> Also `block` can be named, so you can do `block collectEntries` |
13:36:27 | FromDiscord | <haxscramper> Doesn't add anything, but might look nice |
13:36:32 | arkanoid | Adding more procs would add calls to the stack, and the the global function is in an endless loop and is running as fast as possible, so yeah optimization is also good |
13:37:56 | arkanoid | So yeah I'm in doubt blocks vs inlined inner closures (are these a thing? Can I inline closure?) |
13:38:04 | FromDiscord | <konsumlamm> you can mark the procs as `{.inline.}` |
13:38:15 | FromDiscord | <haxscramper> that does not guarantee inlining |
13:38:33 | FromDiscord | <haxscramper> And it is almost useless for inner closures |
13:39:06 | FromDiscord | <haxscramper> IIRC `.inline.` copies generated C code into each file where function was used so `C` compiler could inline it better |
13:40:11 | arkanoid | If an inline closure works like a template doing the same thing, it may work |
13:40:42 | FromDiscord | <haxscramper> Why not use template then? |
13:41:59 | FromDiscord | <haxscramper> Because inline closure looks just as weird in that case |
13:44:29 | * | stkrdknmibalz quit (Quit: WeeChat 3.0.1) |
13:46:06 | arkanoid | I do agree. Well. Thanks, at least I have a better idea of the pros and cons |
13:46:32 | arkanoid | blocks and templates are zero cost and improves encapsulation |
13:57:22 | FromDiscord | <Clonkk> Does anyone know how to investigate the code gen error \:`ror: invalid initialization of reference of type ‘tySequence9apztJSmgERYU8fZOjI4pOg&’ from expression of type ‘tySequence48JTohSgTy339bRxHzUD8KA’ newSeq_OOZOOZOOZlocalwsZnimfftw51Zfftw51_548(result, len); ` ? |
13:58:21 | FromDiscord | <Clonkk> It's on rather big code base (can't seem to isolate for now). I've seen something similar that is supposedly fixed, so I wonder if anyone has encoutered this error ? |
14:04:36 | FromDiscord | <konsumlamm> are you on devel? |
14:05:58 | FromDiscord | <Clonkk> Yep |
14:14:36 | FromDiscord | <rishavs (Rishav Sharan)> sent a code paste, see https://play.nim-lang.org/#ix=3tBY |
14:33:38 | FromDiscord | <haxscramper> That should work with fusion/matching |
14:36:16 | FromDiscord | <haxscramper> sent a code paste, see https://paste.rs/bPn |
14:40:45 | FromDiscord | <hamidb80> hey |
14:40:59 | FromDiscord | <hamidb80> https://media.discordapp.net/attachments/371759389889003532/867415865376768040/unknown.png |
14:41:13 | FromDiscord | <hamidb80> https://media.discordapp.net/attachments/371759389889003532/867415924693008434/unknown.png |
14:42:15 | FromDiscord | <hamidb80> why do my document comments are not in generated docummentation? |
14:42:19 | FromDiscord | <hamidb80> (edit) "docummentation?" => "documentation?" |
14:42:42 | FromDiscord | <hamidb80> (edit) removed "do" | "are not" => "dont exist" |
14:46:04 | FromDiscord | <Rika> addtestcov probably clobbering it |
14:46:29 | FromDiscord | <Rika> do you have the code for the macro so i can see |
14:48:30 | FromDiscord | <hamidb80> i expanded them using `expandMacros` and the comments exist |
14:48:57 | FromDiscord | <hamidb80> oh my god |
14:49:04 | arkanoid | I've another question linked to my previous one. Is there any automatic inlining system in nim? |
14:49:14 | FromDiscord | <hamidb80> https://media.discordapp.net/attachments/371759389889003532/867417946623442964/unknown.png |
14:50:24 | FromDiscord | <hamidb80> they are under `result=` |
14:50:48 | FromDiscord | <hamidb80> sent a code paste, see https://play.nim-lang.org/#ix=3tC8 |
14:53:04 | FromDiscord | <Rika> wdym? templates are literally inlined code |
14:58:23 | fn | <ForumUpdaterBot99> New thread by Miran: Nim online meetup - Friday July 23rd, see https://forum.nim-lang.org/t/8254 |
15:16:55 | FromDiscord | <Kermithos> sent a code paste, see https://play.nim-lang.org/#ix=3tCx |
15:18:11 | ozzz | How to specify option to parsexml - allowEmptyAttribs using open(...)? |
15:18:42 | ozzz | It won't eat for some reason, or I misunderstand smth |
15:21:05 | ozzz | also what I want to ask, how to identify xml special char? I have to do x.next() on each occasion of xml_special_char, othervise x.charData points only on data before spec. char |
15:48:58 | FromDiscord | <Kermithos> In reply to @Kermithos "how can I get": okay, figured it out, getTempDir() work perfectly |
15:52:29 | fn | <ForumUpdaterBot99> New thread by Tsojtsoj: Expensive copy when compiling with --gc:arc, see https://forum.nim-lang.org/t/8255 |
15:59:10 | FromDiscord | <carmysilna> I'm going through Project euler in Nim and its ridiculously easy. An import from sequtils or math and then 20 lines of functions and you've got the answer |
16:00:55 | FromDiscord | <hamidb80> In reply to @Rika "wdym? templates are literally": nim doc doesnt detect doc comments for some procs |
16:01:04 | FromDiscord | <hamidb80> (edit) "nim doc" => "`nim doc`" |
16:01:30 | FromDiscord | <Rika> might be the same issue as hamid got above then |
16:02:36 | FromDiscord | <hamidb80> oh it's because of another macro😄 |
16:03:15 | * | stkrdknmibalz joined #nim |
16:03:26 | FromDiscord | <Rika> oh |
16:03:30 | FromDiscord | <Rika> you're hamid |
16:03:39 | FromDiscord | <Rika> i didnt notice, avatar tripped me up |
16:03:51 | FromDiscord | <Rika> misread |
16:04:02 | FromDiscord | <Rika> In reply to @Rika "wdym? templates are literally": i was talking to arkanoid here... |
16:04:30 | fn | <ForumUpdaterBot99> New thread by Clonk: Investigating C++ codegen error, see https://forum.nim-lang.org/t/8256 |
16:23:47 | FromDiscord | <Hi02Hi> In reply to @carmysilna "I'm going through Project": There are hundreds of puzzles, they get much much harder as you continue. (I'm not the expert, I've solved like 30 puzzles, I was just looking through the later puzzles) |
16:24:32 | FromDiscord | <carmysilna> I can see that, it was just amazing to me how easy it was in Nim compared to when I tried them earlier in Erlang and Rust |
16:29:49 | * | max22- joined #nim |
16:34:17 | * | max22- quit (Ping timeout: 245 seconds) |
16:38:55 | * | max22- joined #nim |
16:39:00 | FromDiscord | <hamidb80> In reply to @carmysilna "I can see that,": yeah, i think nims standard library is very powerful |
16:39:07 | FromDiscord | <hamidb80> (edit) "i" => "I" | "nims" => "the" |
16:56:54 | * | max22- quit (Ping timeout: 250 seconds) |
17:11:32 | * | max22- joined #nim |
17:25:43 | FromDiscord | <haxscramper> public `const array[Kind, <X>]` in documentation↵https://haxscramper.github.io/htsparse/src/htsparse/systemVerilog/systemVerilog.html#verilogNodeKindMap |
17:26:24 | FromDiscord | <haxscramper> sent a code paste, see https://paste.rs/ead |
17:27:56 | FromDiscord | <haxscramper> Also I had to make java -\> nim transpiler - not a finished project by any means (some manual editing is needed after, and it fails on some constructs), https://github.com/haxscramper/htsparse/blob/master/tests/tJavaTranspiler.nim |
17:28:13 | FromDiscord | <haxscramper> Based on tree-sitter wrappers |
17:29:36 | FromDiscord | <haxscramper> And there are total of \~30+ languages with tree-sitter wrappers generated for them as well, I made them for some dirty X-\>nim transpilers |
18:09:12 | * | max22- quit (Ping timeout: 268 seconds) |
18:12:04 | * | SebastianM joined #nim |
18:13:20 | fn | <Prestige99> Treesitter for Nim would be cool - it seems difficult to pull off though |
18:15:53 | FromDiscord | <haxscramper> I did some work on that as well, but nim has very "free-form" grammar and I'm not very skilled at writing LR parsers |
18:16:42 | fn | <Prestige99> I came to the conclusion that the compiler would be the best way to generate the grammar |
18:16:47 | FromDiscord | <haxscramper> Most of the mechanical work is done, but I need to either spend more time and finish this |
18:16:52 | fn | <Prestige99> But would need to be modified ofc |
18:17:17 | FromDiscord | <haxscramper> what do you mean by "generate grammar"? |
18:17:46 | FromDiscord | <haxscramper> https://github.com/haxscramper/tree-sitter-nim/blob/master/grammar.js |
18:18:03 | FromDiscord | <haxscramper> I took what was in manual |
18:18:42 | fn | <Prestige99> Sorry, meant AST |
18:19:20 | FromDiscord | <haxscramper> I need this for pretty-printer |
18:19:24 | FromDiscord | <haxscramper> nim compiler AST is not enough for that |
18:19:54 | FromDiscord | <haxscramper> it simplifies a lot of information and does not track node ranges, only start poitns |
18:19:54 | FromDiscord | <haxscramper> points\ |
18:20:05 | fn | <Prestige99> Yeah I'm talking about generating the treesitter AST for Nim |
18:20:25 | fn | <Prestige99> Would be nice if the compiler could handle it since it has all the context |
18:20:34 | fn | <Prestige99> But it's a pipe dream |
18:21:15 | FromDiscord | <haxscramper> well, it is not a hard technical problem to write tree-sitter grammar |
18:21:44 | FromDiscord | <haxscramper> Maybe at some point I will be annoyed enough with having to manually format code and I finish this thing |
18:22:55 | fn | <Prestige99> I couldn't figure out a way to do it without having a custom parser |
18:23:51 | FromDiscord | <haxscramper> nimpretty is hacked into nim parser, so I assume that is the only way |
18:23:59 | FromDiscord | <haxscramper> the only other way without having to write custom parser\ |
18:24:01 | FromDiscord | <haxscramper> and this is not a good solution regardless |
18:24:30 | FromDiscord | <haxscramper> I have code layout optimizer, and it takes in AST, converts them into text blocks and then chooses optimal placement |
18:24:52 | FromDiscord | <haxscramper> nimpretty, on the other hand, takes in code and almost immediately outputs it, from what I can see |
18:25:17 | federico3 | yes - nimfmt uses it |
18:26:54 | FromDiscord | <haxscramper> compiler parser? |
18:26:58 | fn | <Prestige99> That's why I want the compiler to be able to support it (probably via some sort of plugin) |
18:28:13 | FromDiscord | <haxscramper> we just need more detailed AST |
18:28:13 | FromDiscord | <haxscramper> CST\ |
18:28:22 | fn | <Prestige99> Yep |
18:28:44 | FromDiscord | <haxscramper> so I'm pretty fine with `{.define(concreteAst).}` that |
18:28:50 | FromDiscord | <haxscramper> 1. Stores end position |
18:28:56 | FromDiscord | <haxscramper> 2. Stores code comments |
18:29:14 | FromDiscord | <haxscramper> And that's basically it - maybe I've missed something, but I can go on with that much |
18:29:45 | FromDiscord | <haxscramper> Maybe some additional heuristics that parser used could also be represented in the AST |
18:30:03 | FromDiscord | <haxscramper> Like node indentation |
18:30:18 | FromDiscord | <haxscramper> And underlying token ranges |
18:30:45 | FromDiscord | <haxscramper> Speaking of `case`, `case:` with four different ways of writing total |
18:32:50 | FromDiscord | <haxscramper> Actually, forking nim parser and patching it from time to time does not seem like a terrible idea |
18:33:37 | FromDiscord | <haxscramper> I'm more likely to use tree-sitter anyway, but as an alternative that sounds not too bad |
18:34:20 | fn | <Prestige99> I mean you could add support to the Nim parser to return info you need |
18:34:28 | fn | <Prestige99> Then just use it for treesitter |
18:35:56 | FromDiscord | <haxscramper> what is the point of tree-sitter in that case? |
18:36:00 | FromDiscord | <haxscramper> tree-sitter is a parser generator |
18:36:26 | FromDiscord | <haxscramper> it also has support for incremental editing and AST querying, but that is all supplementary |
18:40:58 | FromDiscord | <haxscramper> Main problem with tree-sitter & nim is that our grammar seems to contain all possible edge cases |
18:41:15 | fn | <Prestige99> You would get all of the benefits of tree sitter, you would just be using Nim as your parser |
18:41:31 | FromDiscord | <haxscramper> I can't do that |
18:41:40 | FromDiscord | <haxscramper> It is impossible |
18:41:53 | * | max22- joined #nim |
18:41:58 | FromDiscord | <@bracketmaster-5a708063d73408ce4> @\_discord\_145405730571288577\:t2bot.io \: regarding your solution last night, I need to instantiate `sub_arr` within the macro itself - and manipulate it |
18:42:00 | FromDiscord | <haxscramper> "all benefits of tree sitter" are based on their incremental GLR parser algorithm |
18:42:14 | FromDiscord | <@bracketmaster-5a708063d73408ce4> sub\_arr needs to be parameterized by a value generated within the macro |
18:42:32 | FromDiscord | <haxscramper> And internal runtime that is tightly coupled with an implementation |
18:43:03 | fn | <Prestige99> Treesitter supports custom parsers |
18:43:16 | FromDiscord | <haxscramper> tree-sitter supports custom lexers |
18:43:43 | fn | <Prestige99> Yeah that's what I'm talking about, use nim for that |
18:44:01 | FromDiscord | <haxscramper> I can write lexer in nim, yes |
18:44:13 | fn | <Prestige99> Uh |
18:44:26 | FromDiscord | <haxscramper> But I can't reuse compiler lexer |
18:44:33 | fn | <Prestige99> I guess I'm really struggling to get my point across |
18:44:37 | FromDiscord | <haxscramper> Because required lexer implementation is also coupled with their runtime |
18:44:57 | FromDiscord | <@bracketmaster-5a708063d73408ce4> so going back to this |
18:44:58 | FromDiscord | <@bracketmaster-5a708063d73408ce4> https://paste.debian.net/1205079 |
18:45:03 | FromDiscord | <@bracketmaster-5a708063d73408ce4> I'm not sure its actually possible |
18:46:32 | FromDiscord | <haxscramper> What point? If I use tree-sitter, I can't take advantage of any already existing implementation in nim compiler and/or other handwritten parser. That is due to tree-sitter being a highly coupled, self-contained system that only has very narrow extension points for lexers. |
18:47:00 | FromDiscord | <haxscramper> So if you wanted to say something unrelated to it, then I might've misunderstood you |
18:47:43 | fn | <Prestige99> Nah that was it, idk why that would prevent you from using Nim's lexer (with modifications) |
18:51:05 | FromDiscord | <haxscramper> Most obvious part is - nim lexer based in internal buffer and it controls it, while tree-sitter provides support for custom lexer in form of `bool tree_sitter_my_language_external_scanner_scan(void payload, TSLexer lexer, const bool valid_symbols)` |
18:51:38 | FromDiscord | <haxscramper> I could try to put nim scanner object in payload and somehow sync it with TsLexer, but that seems like a major pain |
18:52:11 | fn | <Prestige99> I was thinking just have calls to Nim's lexer from within that function |
18:52:11 | FromDiscord | <haxscramper> Also nim lexer does not support incremental re-lexing, while TS one has this functionality built-in |
18:52:34 | FromDiscord | <haxscramper> I would have to sync two completely unrelated lexer states |
19:01:45 | FromDiscord | <haxscramper> After looking into it more, idea of hacking into `compiler/[lexer, parser]` seems pretty reasonable to me |
19:02:27 | FromDiscord | <haxscramper> I can store all tokens in the file and start/end token indices for a node, and that should be enough |
19:03:44 | FromDiscord | <carmysilna> Is it a viable idea to compile to Nim by importing the nim package and then directly emitting AST nodes from my AST, and then using nim API to generate code? |
19:05:00 | FromDiscord | <haxscramper> Yes, this is just a more complicated macro |
19:05:26 | FromDiscord | <haxscramper> I think someone was writing a language that compiled to nim |
19:09:18 | FromDiscord | <carmysilna> I think min does |
19:13:47 | FromDiscord | <creonico> Is this a valid way to declare an array? `var some_array:array[size, T];` |
19:15:52 | FromDiscord | <haxscramper> !eval var test\: array[100, int] |
19:15:55 | NimBot | Compile failed: /usercode/in.nim(1, 12) Error: ':' or '=' expected, but got 'array' |
19:16:09 | FromDiscord | <haxscramper> what |
19:16:40 | fn | <Prestige99> !eval var test: array[100, int] |
19:16:46 | FromDiscord | <haxscramper> https://wandbox.org/permlink/dEiR1IGZajz6PWaq |
19:16:57 | NimBot | <no output> |
19:16:59 | fn | <R2D299> /usercode/in.nim(1, 5) Hint: 'test' is declared but not used [XDeclaredButNotUsed] |
19:17:21 | fn | <Prestige99> hax: it added a `\` before the `:` because of the bridge I think |
19:24:24 | FromDiscord | <haxscramper> But ultimately nim formatter must have support for custom pretty-printer plugins, due to various DSLs |
19:25:30 | FromDiscord | <haxscramper> Maybe reuse nimscript for that. Macro-like API - take in AST, return "block tree" with alternative layouts |
19:42:02 | * | xet7 joined #nim |
19:54:57 | * | SebastianM quit (Quit: Bye) |
19:55:08 | FromDiscord | <timotheecour> is azure CI broken ? CI jobs are cancelled in https://github.com/nim-lang/Nim/pull/18555 and other PRs |
20:23:46 | FromDiscord | <carmysilna> Will the `nim.cfg` in my project root be used during `nimble build`? |
20:27:23 | FromDiscord | <@bracketmaster-5a708063d73408ce4> is there really no way to use arrays within a macro? |
20:27:43 | FromDiscord | <@bracketmaster-5a708063d73408ce4> https://paste.debian.net/1205165/ |
20:30:04 | FromDiscord | <konsumlamm> that doesn't seem to have anything to do with arrays, rather that `val` can't be evaluated at compile time for some reason |
20:30:18 | FromDiscord | <@bracketmaster-5a708063d73408ce4> correct |
20:30:32 | FromDiscord | <@bracketmaster-5a708063d73408ce4> to be more specific, arrays of TBD length in a macro |
20:41:42 | FromDiscord | <@bracketmaster-5a708063d73408ce4> so I know nim has static blocks |
20:41:42 | FromDiscord | <@bracketmaster-5a708063d73408ce4> can I somehow access a variable that was initialized in a static block during runtime? |
20:41:59 | FromDiscord | <checkersai> sent a code paste, see https://play.nim-lang.org/#ix=3tDE |
20:42:04 | FromDiscord | <checkersai> When I select yes it builds and runs fine |
20:42:34 | FromDiscord | <checkersai> sent a code paste, see https://play.nim-lang.org/#ix=3tDF |
20:45:32 | * | supakeen quit (Remote host closed the connection) |
20:45:38 | FromDiscord | <ynfle (ynfle)> > can I somehow access a variable that was initialized in a static block during runtime?↵Yes |
20:45:55 | * | supakeen joined #nim |
21:04:07 | FromDiscord | <@bracketmaster-5a708063d73408ce4> @ynfle how? |
21:09:16 | * | fredrikhr quit (Ping timeout: 268 seconds) |
21:16:50 | * | max22- quit (Quit: Leaving) |
21:33:38 | FromDiscord | <@bracketmaster-5a708063d73408ce4> sent a long message, see http://ix.io/3tDU |
22:10:48 | FromDiscord | <checkersai> Is there a nim library that lets me just draw pixels on a window with little overhead? |
22:11:52 | FromDiscord | <checkersai> Nico is nice but I'm not looking for a fantasy console type lib, I don't need any restrictions on the color palette and stuff |
22:13:31 | FromDiscord | <InventorMatt> niGUI i believe can do that |
22:17:26 | * | xet7 quit (Remote host closed the connection) |
22:30:03 | FromDiscord | <creonico> Hey, I get `cannot evaluate at compile time: physical_device_count` when declaring this array `var physical_devices:array[physical_device_count, VkPhysicalDevice];`. `physical_device_count` is 0 before a fuction call that changes its value to the amount of devices there are. After that, I declare the array with the error using `physical_device_count`'s new value |
22:33:45 | FromDiscord | <@bracketmaster-5a708063d73408ce4> nim really doesn't like the length param of any arrays to be non-const during compile time |
22:33:47 | FromDiscord | <@bracketmaster-5a708063d73408ce4> apparently |
22:40:08 | FromDiscord | <creonico> So how can I achieve that? In C it gives me no issue |
22:40:53 | FromDiscord | <carmysilna> You can use `seq` instead of an array |
22:44:38 | FromDiscord | <creonico> Seq? |
22:44:43 | FromDiscord | <creonico> What is that ._. |
22:46:28 | FromDiscord | <@bracketmaster-5a708063d73408ce4> it means sequence in nim |
22:48:06 | FromDiscord | <creonico> ok |
22:49:08 | FromDiscord | <@bracketmaster-5a708063d73408ce4> not sure that nim would have a binding for `physical_devices:seq[VkPhysicalDevice]` as it seems you're using some vulkan binding |
22:56:31 | FromDiscord | <ElegantBeef> well `physical_devices = newSeq[VKPhysicalDevice](physical_device_count)` 😄 |
22:57:22 | FromDiscord | <ElegantBeef> It's not that it doesnt like it but it has to be a compile time value, could make a `FixedSeq` type to give similar syntax to an array |
23:01:15 | FromDiscord | <carmysilna> In reply to @creonico "Hey, I get `cannot": the reasoning behind this is that nim needs to be able to calculate the length of the array at comptime so that it can compile the array efficiently and check for array out of bounds errors |
23:01:45 | FromDiscord | <konsumlamm> the main reason is that arrays are all9cated on the stack |
23:02:04 | FromDiscord | <konsumlamm> and the stack size has to be known at compile time |
23:03:13 | FromDiscord | <ElegantBeef> Well here's a start for that fixed seq really should make this a package 😄 |
23:03:14 | FromDiscord | <@bracketmaster-5a708063d73408ce4> it seems that nim 1.5 allows for custom number literal operators |
23:03:14 | FromDiscord | <ElegantBeef> https://play.nim-lang.org/#ix=3tE8 |
23:03:18 | FromDiscord | <ElegantBeef> Yes |
23:03:24 | FromDiscord | <@bracketmaster-5a708063d73408ce4> specifically, `'something` |
23:03:43 | FromDiscord | <@bracketmaster-5a708063d73408ce4> https://github.com/nim-lang/bigints/blob/master/src/literals.nim#L4 |
23:04:08 | FromDiscord | <@bracketmaster-5a708063d73408ce4> but it seems that operator only allows for number literals? |
23:04:31 | FromDiscord | <Tuatarian> is there a findall function built into sequtils? |
23:04:44 | FromDiscord | <Tuatarian> wasn't able to find one, could implement myself but I think this is something that should really be in the stdlib |
23:04:49 | FromDiscord | <ElegantBeef> `filterit` |
23:04:54 | FromDiscord | <Tuatarian> indices |
23:04:54 | FromDiscord | <ElegantBeef> `filter` |
23:05:10 | FromDiscord | <Tuatarian> is there a way to grab indices from filter? |
23:05:36 | FromDiscord | <ElegantBeef> nope |
23:06:04 | FromDiscord | <Tuatarian> yeah |
23:06:20 | FromDiscord | <ElegantBeef> sent a code paste, see https://play.nim-lang.org/#ix=3tE9 |
23:06:23 | FromDiscord | <Tuatarian> it's not hard to implement for sure |
23:06:28 | FromDiscord | <Tuatarian> but imo it should be in stdlib |
23:06:33 | FromDiscord | <Tuatarian> should I make a PR for it? |
23:06:55 | FromDiscord | <ElegantBeef> Possibly |
23:07:06 | FromDiscord | <Tuatarian> or maybe just add it to fusion |
23:07:19 | FromDiscord | <konsumlamm> honestly, there doesn't need to be a combinator for everything |
23:07:46 | FromDiscord | <konsumlamm> there are hundreds if "missing" combinators that are useful |
23:08:07 | * | def- quit (Quit: -) |
23:08:11 | FromDiscord | <konsumlamm> `collect` is a good enough solution imo |
23:08:19 | * | def- joined #nim |
23:08:56 | FromDiscord | <konsumlamm> and if the `sequtils` stuff worked on iterators instead of seqs, you could probably combine a filter combinator with a combinator that provides access to the index |
23:09:23 | FromDiscord | <@bracketmaster-5a708063d73408ce4> Not seeing any documentation on the `'` operator that comes with nim 1.5 tho |
23:09:24 | FromDiscord | <konsumlamm> without or with low additional cost, that is |
23:09:25 | FromDiscord | <carmysilna> can't you `toSeq` an iterator |
23:09:45 | FromDiscord | <Tuatarian> is there a find iterator? |
23:09:59 | FromDiscord | <Tuatarian> don't remember there being a find iterator |
23:10:11 | FromDiscord | <konsumlamm> In reply to @carmysilna "can't you `toSeq` an": sure, but the combinators take and return a seq, which means lots of intermediate allocations when combining them |
23:10:45 | FromDiscord | <Tuatarian> this kind of thing is my primary concern with contributing to nim stdlib or fusion |
23:11:10 | FromDiscord | <Tuatarian> I'm not super knowledgable interms of effciency |
23:11:15 | FromDiscord | <konsumlamm> In reply to @iWonderAboutTuatara "don't remember there being": https://nim-lang.github.io/Nim/system.html#find%2CT%2CS |
23:11:35 | FromDiscord | <Tuatarian> huh |
23:11:40 | FromDiscord | <konsumlamm> a `filterWithIbdex` wouldn't be inefficient |
23:11:42 | FromDiscord | <Tuatarian> would have expected it to be in sequtils |
23:11:55 | FromDiscord | <konsumlamm> my point is that it shouldn't be necessary in the first place |
23:12:06 | FromDiscord | <Tuatarian> it's not, for sure |
23:12:13 | FromDiscord | <konsumlamm> sewutils is for stuff that works on seqs, nit stuff that works for any iterable |
23:12:18 | FromDiscord | <Tuatarian> I see |
23:12:20 | FromDiscord | <konsumlamm> (edit) "sewutils" => "sequtils" |
23:12:25 | FromDiscord | <Tuatarian> openarrays yeah |
23:12:27 | FromDiscord | <konsumlamm> (edit) "nit" => "not" |
23:12:27 | FromDiscord | <Zoom> @Tuatarian\: zero\_functional's `enumerate` confusingly outputs original indices even after filtering. I even opened an issue on that, but it remained unresolved |
23:12:27 | FromDiscord | <Tuatarian> fair enough |
23:12:51 | FromDiscord | <carmysilna> In reply to @iWonderAboutTuatara "is there a find": `seq.filter(pred)[0]` should work |
23:13:19 | FromDiscord | <ElegantBeef> well ideally we do this with 0 allocations |
23:13:27 | FromDiscord | <konsumlamm> it would, but it first allocates a seq |
23:13:39 | FromDiscord | <konsumlamm> this isn't Haskell where the list is fused away |
23:13:50 | FromDiscord | <carmysilna> disappointing |
23:14:44 | FromDiscord | <carmysilna> sent a code paste, see https://play.nim-lang.org/#ix=3tEa |
23:14:51 | FromDiscord | <Zoom> zero\_functtional doesn't allocate and behaves just as requested, even though it's strictly speaking an incorrect behaviour |
23:15:15 | FromDiscord | <ElegantBeef> sent a code paste, see https://play.nim-lang.org/#ix=3tEb |
23:15:32 | FromDiscord | <ElegantBeef> Yea carmysilna that's 0 allocating |
23:16:14 | FromDiscord | <ElegantBeef> that break is wrong though since they want all indicies |
23:16:20 | FromDiscord | <ElegantBeef> And it returns the object 😄 |
23:16:23 | FromDiscord | <konsumlamm> sent a code paste, see https://play.nim-lang.org/#ix=3tEc |
23:16:59 | FromDiscord | <konsumlamm> except it's a proc, not an iterator |
23:17:08 | FromDiscord | <konsumlamm> it just iterates |
23:17:19 | FromDiscord | <carmysilna> oh, I'm used to haskell `find :: [a] -> (a -> Bool) -> a` |
23:20:44 | * | oprypin_ quit (Ping timeout: 255 seconds) |
23:22:10 | * | oprypin joined #nim |
23:23:59 | FromDiscord | <Tuatarian> another question |
23:24:04 | FromDiscord | <Tuatarian> what is the difference between |
23:24:13 | FromDiscord | <Tuatarian> and |
23:24:18 | FromDiscord | <Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=3tEd |
23:24:28 | FromDiscord | <Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=3tEe |
23:25:50 | FromDiscord | <Tuatarian> though ideally I think you would use an iterator to avoid an allocation |
23:26:00 | FromDiscord | <Tuatarian> but ignore that, mostly asking about collect |
23:26:08 | FromDiscord | <carmysilna> `collect` is basically a list comprehension but defined in the stdlib, its sugar to genericize iteration, afaict |
23:26:14 | FromDiscord | <carmysilna> https://nim-lang.org/docs/sugar.html#collect.m%2Cuntyped%2Cuntyped |
23:27:44 | FromDiscord | <Tuatarian> not really familiar with any of those terms lmao |
23:27:57 | FromDiscord | <Tuatarian> I've never done anything much with functional programming |
23:28:05 | FromDiscord | <Tuatarian> oh wait nevermind I see |
23:28:15 | FromDiscord | <Tuatarian> just lets you iterate over tables and hashmaps and such |
23:28:40 | FromDiscord | <Tuatarian> iterate over custom datatypes without implementing an iterator? |
23:33:08 | FromDiscord | <carmysilna> Yeah, I think so, but it might be restricted to stdlib stuff idk |
23:38:17 | FromDiscord | <ElegantBeef> Nah it works with custom collections |
23:38:32 | FromDiscord | <ElegantBeef> Just needs the `add` or `incl` procs |
23:39:14 | FromDiscord | <ElegantBeef> or i guess `[]=` |
23:40:54 | FromDiscord | <carmysilna> sent a code paste, see https://play.nim-lang.org/#ix=3tEf |
23:41:16 | FromDiscord | <ElegantBeef> They need to be in the same type section |
23:41:38 | FromDiscord | <carmysilna> Can I put a `variant` in a type section? |
23:41:54 | FromDiscord | <ElegantBeef> Probably not as it probably emits it's own typesection |
23:42:26 | FromDiscord | <carmysilna> I guess I'll just write my own object variant impl then |
23:43:08 | FromDiscord | <ElegantBeef> You could just modify it have a `variantTypeDef` that does `[0]` to the generated AST |
23:43:29 | FromDiscord | <ElegantBeef> Actually idk if that'd work |
23:46:17 | FromDiscord | <ElegantBeef> Could modify the macro then the use a `Value = variant` syntax then just have it mostly look like standard typesection |
23:48:28 | fn | <ForumUpdaterBot99> New thread by Stu002: Which combination of pragmas is best for proc arguments to procs?, see https://forum.nim-lang.org/t/8258 |
23:51:17 | * | mst quit (Quit: Reconnecting) |
23:51:24 | * | mst joined #nim |
23:53:36 | FromDiscord | <RattleyCooper> How do I import `exitprocs` or use `addExitProc`? I feel like I might be missing something. Doesn't seem that `exitprocs` is in the stdlib and I can't find a nimble package. |
23:53:48 | FromDiscord | <leorize> `import std/exitprocs` |
23:53:59 | FromDiscord | <RattleyCooper> oh lol |
23:54:17 | FromDiscord | <leorize> as a rule of thumb you should prefix stdlib modules with `std/` |
23:54:18 | FromDiscord | <RattleyCooper> wow, thank you that worked |
23:54:30 | FromDiscord | <leorize> I'm not sure if we have communicated this yet |
23:54:39 | FromDiscord | <ElegantBeef> also for multiple modules you should `std/[a, b, c]` |
23:54:58 | FromDiscord | <ElegantBeef> Yea leorize it's a common occurance which 1.6 will resolve due to the docgen showing import path in the header of the manual |
23:55:40 | FromDiscord | <Jakraes> Hey guys, I need some help, is it possible to assign a value to a certain parameter in an object? |
23:55:47 | FromDiscord | <Jakraes> I wanted to do something like this |
23:56:46 | FromDiscord | <Jakraes> sent a code paste, see https://play.nim-lang.org/#ix=3tEh |
23:57:09 | FromDiscord | <ElegantBeef> Not built in but macros can let you |
23:57:24 | FromDiscord | <Jakraes> I wanted to assign a value to direc as soon as all the 4 parameters above are chosen |
23:57:26 | FromDiscord | <ElegantBeef> Typically you just make an `initVector` |
23:57:26 | FromDiscord | <Jakraes> Oh? |
23:57:41 | FromDiscord | <Jakraes> Oh, is there documentation on that? |
23:58:16 | FromDiscord | <ElegantBeef> well it's just a `proc initVector(yourArgsHere): Vector = Vector(direc: [finalX - startX, finalY - startY])` |
23:58:26 | FromDiscord | <ElegantBeef> It's rather tedious of course |
23:59:29 | FromDiscord | <@bracketmaster-5a708063d73408ce4> @\_discord\_145405730571288577\:t2bot.io - is this possible with macros? |
23:59:29 | FromDiscord | <@bracketmaster-5a708063d73408ce4> for i in 0..5\:↵ result.add\:↵ quote do\:↵ echo `i` |
23:59:48 | FromDiscord | <ElegantBeef> For an automated version you can try https://github.com/beef331/constructor though i dont know about the relying on the runtime values |
23:59:51 | fn | <R2D299> itHub: 7"Nim macros to aid in object construction including event programming, and constructors." |
23:59:56 | FromDiscord | <ElegantBeef> yea that's possible with macros |