<< 21-07-2021 >>

00:10:06FromDiscord<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:06FromDiscord<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:46FromDiscord<impbox [ftsf]> pretty sure i just copied someone else's solution
00:13:56FromDiscord<dan> 😂
00:14:06FromDiscord<dan> do you remember who so i can annoy him?
00:14:26FromDiscord<dan> (edit) "him?" => "them?"
00:14:38FromDiscord<impbox [ftsf]> i don't know where i got it from sorry
00:21:11FromDiscord<dan> alright thank you anyways
00:21:42FromDiscord<dan> taking a look at nico has brought me a bit close to actually integrating nim into my work project
00:21:50FromDiscord<dan> (edit) "close" => "closer"
01:49:05FromDiscord<@bracketmaster-5a708063d73408ce4> I'm currently fighting macros
01:49:05FromDiscord<@bracketmaster-5a708063d73408ce4> https://play.nim-lang.org/#ix=3tzc
01:49:23FromDiscord<@bracketmaster-5a708063d73408ce4> How can I make line 11 work? ↵↵var instance = sometype(str.len).uint64
01:53:47FromDiscord<ElegantBeef> Is the macro supposed to emit this or use it internally?
01:53:59FromDiscord<@bracketmaster-5a708063d73408ce4> use it internally
01:55:29*stkrdknmibalz joined #nim
01:56:16FromDiscord<@bracketmaster-5a708063d73408ce4> that's a dummy example - but essentially the same problem I'm having in a larger codebase
01:57:45FromDiscord<ElegantBeef> I dont know if this is possible
01:57:54FromDiscord<@bracketmaster-5a708063d73408ce4> is this impossible?
01:57:55FromDiscord<@bracketmaster-5a708063d73408ce4> basically, I've got my own internal bigint library that uses arrays instead of seqs
01:57:55FromDiscord<@bracketmaster-5a708063d73408ce4> so the max value of a bigint is fixed after compilation
01:58:03FromDiscord<@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:24FromDiscord<@bracketmaster-5a708063d73408ce4> but the macro need to start with a smaller bigint and keep making larger ones
01:58:36FromDiscord<@bracketmaster-5a708063d73408ce4> until it finds a sufficiently sized one
01:59:25FromDiscord<@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:53FromDiscord<ElegantBeef> I might be able to help with you more elaborate example
02:03:58FromDiscord<ElegantBeef> (edit) "you" => "your"
02:04:23FromDiscord<@bracketmaster-5a708063d73408ce4> My codebase is private - I guess I could push it public
02:06:07FromDiscord<ElegantBeef> Well a small practical example to see what could be worked around would be nice 😄
02:06:56FromDiscord<@bracketmaster-5a708063d73408ce4> shouldn't this work?
02:06:57FromDiscord<@bracketmaster-5a708063d73408ce4> https://paste.debian.net/1205079/
02:08:47FromDiscord<ElegantBeef> Not ideal but this "works" https://play.nim-lang.org/#ix=3tzg
02:10:23FromDiscord<@bracketmaster-5a708063d73408ce4> ok - that might help me solve my other problem
02:10:29FromDiscord<@bracketmaster-5a708063d73408ce4> but "why" does that work?
02:10:34FromDiscord<@bracketmaster-5a708063d73408ce4> what's going on there?
02:12:13FromDiscord<ElegantBeef> I think due to the type being derived from a parameter it's considered a runtime value on not compile time
02:12:27FromDiscord<ElegantBeef> It may possibly be a bug
02:14:10FromDiscord<@bracketmaster-5a708063d73408ce4> is your solution exploiting a bug?
02:14:31FromDiscord<ElegantBeef> No it may be working around one
02:31:08FromDiscord<ElegantBeef> Though the issue with the work around is it may require import macros in the submodule
02:31:13FromDiscord<ElegantBeef> (edit) "submodule" => "importing module"
02:32:16FromDiscord<@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:42FromDiscord<Jakraes> Is it not possible to assign a var to a parameter and then assign a new value to said parameter?
04:05:44FromDiscord<Jakraes> Like this
04:06:02*supakeen quit (Quit: WeeChat 3.2)
04:06:36*supakeen joined #nim
04:07:11FromDiscord<Jakraes> sent a code paste, see https://play.nim-lang.org/#ix=3tzG
04:07:48*springb0k quit (Ping timeout: 252 seconds)
04:10:10FromDiscord<Jakraes> Oooh nvm
04:10:20FromDiscord<Jakraes> Just found out I can do test(p: var int)
04:15:07FromDiscord<Bung> is it possible create a code placeholder, when user call some function, inject code there?
04:15:07*springb0k joined #nim
04:16:19FromDiscord<Rika> I'm sorry I don't understand well, but isn't that just a template?
04:16:58FromDiscord<Bung> but template inject code where it called
04:19:15FromDiscord<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:25FromDiscord<Rika> It's how the async pragma works
04:19:57FromDiscord<Bung> like aExpr;bTemplateExpand;cExpr this is template and macros works
04:20:42FromDiscord<Bung> what I want I call aFunc somewhere the body will inject to aExpr;
04:23:07FromDiscord<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:06FromDiscord<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:14FromDiscord<Bung> sent a code paste, see https://play.nim-lang.org/#ix=3tzK
04:28:36FromDiscord<Bung> it's like this, I just dont want store procs in runtime
04:28:55FromDiscord<ElegantBeef> Ah then yes macrocache to the rescue, will quickly make an example
04:31:09FromDiscord<Bung> oh, that save me, so I just add nimnode to a macrocache storage.
04:31:50FromDiscord<ElegantBeef> https://play.nim-lang.org/#ix=3tzN yep
04:32:03FromDiscord<ElegantBeef> `impl` in the first should be typed
04:32:18FromDiscord<ElegantBeef> that way it gets `sym` not `untyped`
04:32:35FromDiscord<ElegantBeef> (edit) "`untyped`" => "`ident`"
04:34:01FromDiscord<ElegantBeef> Proper version that will work across modules https://play.nim-lang.org/#ix=3tzQ
04:36:19FromDiscord<Bung> hmm how they work differently ?
04:36:20FromDiscord<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:40FromDiscord<ElegantBeef> typed is semantically checked so you arent emitting untyped code
04:37:07FromDiscord<Jakraes> How so? Sorry I don't really understand what you mean
04:37:18FromDiscord<ElegantBeef> Not in response to you
04:37:34FromDiscord<Jakraes> Oh gotcha
04:37:36FromDiscord<ElegantBeef> What's `vector.startX`?
04:37:47FromDiscord<Jakraes> Oh nvm, I can just include everything inside the float64
04:37:51FromDiscord<Bung> oh , it's just safer I think
04:38:01*springb0k quit (Ping timeout: 268 seconds)
04:38:05FromDiscord<Jakraes> It's the starting position of a vector
04:38:42FromDiscord<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:50FromDiscord<Bung> okay, I'll use typed version as the Impl may coming from nimble package I think
04:41:11FromDiscord<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:02FromDiscord<Bung> the impl part is proc , how can call it with args ?
04:57:14FromDiscord<Bung> oh, get it , get proc name node
04:59:13FromDiscord<ElegantBeef> Yea remember you can also change `typed` to any type so it's semantically checked
05:01:23FromDiscord<Bung> yeah , like proc(req:Request)
05:21:23FromDiscord<Bung> I get `postProcessMiddlewares.len` == 0 in macro
05:22:19FromDiscord<ElegantBeef> Without code to look at that doesnt mean much
05:25:12FromDiscord<Bung> pls check https://github.com/bung87/scorper/commit/a534d9b6281b3612a442a77b349c743a534cd932
05:26:53FromDiscord<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:51FromDiscord<ElegantBeef> You could make `processClient` a macro which inserts the calls where they need to
05:31:56FromDiscord<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:58FromDiscord<Bung> hmm , guess I'll seperate Request to other file, but it has many private fields.
05:32:47FromDiscord<ElegantBeef> I do wonder if you couldnt just put it in a template
05:33:44FromDiscord<Bung> processClient ? that's a proc pass to a proc as callback
05:35:48FromDiscord<ElegantBeef> Sure but i mean something like this https://play.nim-lang.org/#ix=3tA6 not idea though
05:36:02FromDiscord<ElegantBeef> No clue if it even compiles truthfully 😄
05:36:42FromDiscord<ElegantBeef> You need something to late bind that procedure to a callsite 😄
05:39:29FromDiscord<Bung> hmm , that does not compiled
05:40:19FromDiscord<Bung> in the end I'll seperate Request type to other file
05:41:34FromDiscord<Bung> import scoper/middlewaremacro ; imp it; import scorper make this works I think.
05:43:57FromDiscord<ElegantBeef> Ah yes i see why it didnt solve the issue, didnt realize you called this later in this file
05:45:22FromDiscord<Bung> yeah, just some kind not friendly to user, that import order are imortant.
05:45:59FromDiscord<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:45FromDiscord<Bung> oh, I did not aware it handle this case.
05:46:50FromDiscord<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:06FromDiscord<Bung> that's cool
05:48:08FromDiscord<ElegantBeef> Yea the macrocache is quite awesome
05:49:07FromDiscord<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:00fn<ForumUpdaterBot99> New Nimble package! harpoon - HTTP Client, see https://github.com/juancarlospaco/harpoon
06:04:01fn<R2D299> itHub: 7"HTTP Harpoon, HTTP Client"
06:35:10*Vladar joined #nim
06:39:00FromDiscord<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:07FromDiscord<Bung> how you declare two type that reference each other in fields?
07:38:17FromDiscord<Rika> in the same type block
07:38:42FromDiscord<Bung> how about seperated files ?
07:39:14FromDiscord<Rika> impossible w/o experimental package type i believe
07:41:27FromDiscord<Bung> oh , I stuck in old problem.
07:44:38FromDiscord<Bung> hmm , I dont need to do this.
07:53:23*fredrikhr joined #nim
07:59:28FromDiscord<Bung> can I give param a cast by default ? I dont want write cast in every interfaces body
10:00:50FromDiscord<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:05FromDiscord<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:26FromDiscord<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:36FromDiscord<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:37fn<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:08FromDiscord<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:00FromDiscord<theangryepicbanana> In reply to @haxscramper "What do you mean": like syntax-based pattern match, could look something like `@lhs + @rhs`
12:16:26FromDiscord<haxscramper> In reply to @theangryepicbanana "like syntax-based pattern match,": https://play.nim-lang.org/#ix=3tBo
12:16:46FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3tBp
12:21:27FromDiscord<haxscramper> https://play.nim-lang.org/#ix=3tBr
12:21:44FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3tBs
12:22:16FromDiscord<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:45FromDiscord<haxscramper> ~27 lines total, most likely it has some bugs but not too much as it is dead-simple transform
12:30:50FromDiscord<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:13arkanoidWhen 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:33FromDiscord<haxscramper> Create more functions
13:22:49*Vladar quit (Quit: Leaving)
13:23:33arkanoidI'm unsure about creating more root level functions as it may fracture the sequential logic into pieces that really are sequential
13:24:39arkanoidClosures seems somehow better fit. They really say: those procs are just for this outer proc
13:24:52FromDiscord<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:06FromDiscord<haxscramper> Making it a closure is just looks like fancy indentation to me
13:25:25FromDiscord<haxscramper> Same with `block`
13:25:36FromDiscord<haxscramper> You want to create a closure and immediately call it?
13:25:53arkanoidIt is fancy indentation. The target here is to make it more readable/maintenable, non to reuse code.
13:25:56FromDiscord<haxscramper> we have templates for that
13:26:24FromDiscord<haxscramper> cheaper than closure, no need for to pay for indentation
13:26:56arkanoidI don't see how templates joins the party
13:27:22FromDiscord<haxscramper> Put code in the template and use it the same way as function
13:29:52arkanoidArent block: blocks scopes handled at compile time too?
13:30:16FromDiscord<haxscramper> They are handled at compile-time too, yes
13:30:50FromDiscord<haxscramper> If you are looking to just add more scopes use block
13:31:40arkanoidI 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:49arkanoidLike "why a template here"
13:32:14FromDiscord<haxscramper> You have large proc you want to split into parts, correct?
13:32:22FromDiscord<haxscramper> somehow
13:32:51arkanoidYes, but parts are not really reusable. They would become private parts of the module. Maximum level of encapsulation
13:33:27FromDiscord<haxscramper> So what is wrong with putting the parts in the procedure and not exporting it?
13:33:55FromDiscord<haxscramper> Or adding `# section that does <thing>` comments
13:34:37FromDiscord<haxscramper> If parts are not reusable it does not mean you are forbidden from putting them to other procs
13:34:58arkanoid# 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:25FromDiscord<haxscramper> Then simply add `block`
13:35:55FromDiscord<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:18FromDiscord<haxscramper> Also `block` can be named, so you can do `block collectEntries`
13:36:27FromDiscord<haxscramper> Doesn't add anything, but might look nice
13:36:32arkanoidAdding 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:56arkanoidSo yeah I'm in doubt blocks vs inlined inner closures (are these a thing? Can I inline closure?)
13:38:04FromDiscord<konsumlamm> you can mark the procs as `{.inline.}`
13:38:15FromDiscord<haxscramper> that does not guarantee inlining
13:38:33FromDiscord<haxscramper> And it is almost useless for inner closures
13:39:06FromDiscord<haxscramper> IIRC `.inline.` copies generated C code into each file where function was used so `C` compiler could inline it better
13:40:11arkanoidIf an inline closure works like a template doing the same thing, it may work
13:40:42FromDiscord<haxscramper> Why not use template then?
13:41:59FromDiscord<haxscramper> Because inline closure looks just as weird in that case
13:44:29*stkrdknmibalz quit (Quit: WeeChat 3.0.1)
13:46:06arkanoidI do agree. Well. Thanks, at least I have a better idea of the pros and cons
13:46:32arkanoidblocks and templates are zero cost and improves encapsulation
13:57:22FromDiscord<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:21FromDiscord<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:36FromDiscord<konsumlamm> are you on devel?
14:05:58FromDiscord<Clonkk> Yep
14:14:36FromDiscord<rishavs (Rishav Sharan)> sent a code paste, see https://play.nim-lang.org/#ix=3tBY
14:33:38FromDiscord<haxscramper> That should work with fusion/matching
14:36:16FromDiscord<haxscramper> sent a code paste, see https://paste.rs/bPn
14:40:45FromDiscord<hamidb80> hey
14:40:59FromDiscord<hamidb80> https://media.discordapp.net/attachments/371759389889003532/867415865376768040/unknown.png
14:41:13FromDiscord<hamidb80> https://media.discordapp.net/attachments/371759389889003532/867415924693008434/unknown.png
14:42:15FromDiscord<hamidb80> why do my document comments are not in generated docummentation?
14:42:19FromDiscord<hamidb80> (edit) "docummentation?" => "documentation?"
14:42:42FromDiscord<hamidb80> (edit) removed "do" | "are not" => "dont exist"
14:46:04FromDiscord<Rika> addtestcov probably clobbering it
14:46:29FromDiscord<Rika> do you have the code for the macro so i can see
14:48:30FromDiscord<hamidb80> i expanded them using `expandMacros` and the comments exist
14:48:57FromDiscord<hamidb80> oh my god
14:49:04arkanoidI've another question linked to my previous one. Is there any automatic inlining system in nim?
14:49:14FromDiscord<hamidb80> https://media.discordapp.net/attachments/371759389889003532/867417946623442964/unknown.png
14:50:24FromDiscord<hamidb80> they are under `result=`
14:50:48FromDiscord<hamidb80> sent a code paste, see https://play.nim-lang.org/#ix=3tC8
14:53:04FromDiscord<Rika> wdym? templates are literally inlined code
14:58:23fn<ForumUpdaterBot99> New thread by Miran: Nim online meetup - Friday July 23rd, see https://forum.nim-lang.org/t/8254
15:16:55FromDiscord<Kermithos> sent a code paste, see https://play.nim-lang.org/#ix=3tCx
15:18:11ozzzHow to specify option to parsexml - allowEmptyAttribs using open(...)?
15:18:42ozzzIt won't eat for some reason, or I misunderstand smth
15:21:05ozzzalso 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:58FromDiscord<Kermithos> In reply to @Kermithos "how can I get": okay, figured it out, getTempDir() work perfectly
15:52:29fn<ForumUpdaterBot99> New thread by Tsojtsoj: Expensive copy when compiling with --gc:arc, see https://forum.nim-lang.org/t/8255
15:59:10FromDiscord<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:55FromDiscord<hamidb80> In reply to @Rika "wdym? templates are literally": nim doc doesnt detect doc comments for some procs
16:01:04FromDiscord<hamidb80> (edit) "nim doc" => "`nim doc`"
16:01:30FromDiscord<Rika> might be the same issue as hamid got above then
16:02:36FromDiscord<hamidb80> oh it's because of another macro😄
16:03:15*stkrdknmibalz joined #nim
16:03:26FromDiscord<Rika> oh
16:03:30FromDiscord<Rika> you're hamid
16:03:39FromDiscord<Rika> i didnt notice, avatar tripped me up
16:03:51FromDiscord<Rika> misread
16:04:02FromDiscord<Rika> In reply to @Rika "wdym? templates are literally": i was talking to arkanoid here...
16:04:30fn<ForumUpdaterBot99> New thread by Clonk: Investigating C++ codegen error, see https://forum.nim-lang.org/t/8256
16:23:47FromDiscord<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:32FromDiscord<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:00FromDiscord<hamidb80> In reply to @carmysilna "I can see that,": yeah, i think nims standard library is very powerful
16:39:07FromDiscord<hamidb80> (edit) "i" => "I" | "nims" => "the"
16:56:54*max22- quit (Ping timeout: 250 seconds)
17:11:32*max22- joined #nim
17:25:43FromDiscord<haxscramper> public `const array[Kind, <X>]` in documentation↵https://haxscramper.github.io/htsparse/src/htsparse/systemVerilog/systemVerilog.html#verilogNodeKindMap
17:26:24FromDiscord<haxscramper> sent a code paste, see https://paste.rs/ead
17:27:56FromDiscord<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:13FromDiscord<haxscramper> Based on tree-sitter wrappers
17:29:36FromDiscord<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:20fn<Prestige99> Treesitter for Nim would be cool - it seems difficult to pull off though
18:15:53FromDiscord<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:42fn<Prestige99> I came to the conclusion that the compiler would be the best way to generate the grammar
18:16:47FromDiscord<haxscramper> Most of the mechanical work is done, but I need to either spend more time and finish this
18:16:52fn<Prestige99> But would need to be modified ofc
18:17:17FromDiscord<haxscramper> what do you mean by "generate grammar"?
18:17:46FromDiscord<haxscramper> https://github.com/haxscramper/tree-sitter-nim/blob/master/grammar.js
18:18:03FromDiscord<haxscramper> I took what was in manual
18:18:42fn<Prestige99> Sorry, meant AST
18:19:20FromDiscord<haxscramper> I need this for pretty-printer
18:19:24FromDiscord<haxscramper> nim compiler AST is not enough for that
18:19:54FromDiscord<haxscramper> it simplifies a lot of information and does not track node ranges, only start poitns
18:19:54FromDiscord<haxscramper> points\
18:20:05fn<Prestige99> Yeah I'm talking about generating the treesitter AST for Nim
18:20:25fn<Prestige99> Would be nice if the compiler could handle it since it has all the context
18:20:34fn<Prestige99> But it's a pipe dream
18:21:15FromDiscord<haxscramper> well, it is not a hard technical problem to write tree-sitter grammar
18:21:44FromDiscord<haxscramper> Maybe at some point I will be annoyed enough with having to manually format code and I finish this thing
18:22:55fn<Prestige99> I couldn't figure out a way to do it without having a custom parser
18:23:51FromDiscord<haxscramper> nimpretty is hacked into nim parser, so I assume that is the only way
18:23:59FromDiscord<haxscramper> the only other way without having to write custom parser\
18:24:01FromDiscord<haxscramper> and this is not a good solution regardless
18:24:30FromDiscord<haxscramper> I have code layout optimizer, and it takes in AST, converts them into text blocks and then chooses optimal placement
18:24:52FromDiscord<haxscramper> nimpretty, on the other hand, takes in code and almost immediately outputs it, from what I can see
18:25:17federico3yes - nimfmt uses it
18:26:54FromDiscord<haxscramper> compiler parser?
18:26:58fn<Prestige99> That's why I want the compiler to be able to support it (probably via some sort of plugin)
18:28:13FromDiscord<haxscramper> we just need more detailed AST
18:28:13FromDiscord<haxscramper> CST\
18:28:22fn<Prestige99> Yep
18:28:44FromDiscord<haxscramper> so I'm pretty fine with `{.define(concreteAst).}` that
18:28:50FromDiscord<haxscramper> 1. Stores end position
18:28:56FromDiscord<haxscramper> 2. Stores code comments
18:29:14FromDiscord<haxscramper> And that's basically it - maybe I've missed something, but I can go on with that much
18:29:45FromDiscord<haxscramper> Maybe some additional heuristics that parser used could also be represented in the AST
18:30:03FromDiscord<haxscramper> Like node indentation
18:30:18FromDiscord<haxscramper> And underlying token ranges
18:30:45FromDiscord<haxscramper> Speaking of `case`, `case:` with four different ways of writing total
18:32:50FromDiscord<haxscramper> Actually, forking nim parser and patching it from time to time does not seem like a terrible idea
18:33:37FromDiscord<haxscramper> I'm more likely to use tree-sitter anyway, but as an alternative that sounds not too bad
18:34:20fn<Prestige99> I mean you could add support to the Nim parser to return info you need
18:34:28fn<Prestige99> Then just use it for treesitter
18:35:56FromDiscord<haxscramper> what is the point of tree-sitter in that case?
18:36:00FromDiscord<haxscramper> tree-sitter is a parser generator
18:36:26FromDiscord<haxscramper> it also has support for incremental editing and AST querying, but that is all supplementary
18:40:58FromDiscord<haxscramper> Main problem with tree-sitter & nim is that our grammar seems to contain all possible edge cases
18:41:15fn<Prestige99> You would get all of the benefits of tree sitter, you would just be using Nim as your parser
18:41:31FromDiscord<haxscramper> I can't do that
18:41:40FromDiscord<haxscramper> It is impossible
18:41:53*max22- joined #nim
18:41:58FromDiscord<@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:00FromDiscord<haxscramper> "all benefits of tree sitter" are based on their incremental GLR parser algorithm
18:42:14FromDiscord<@bracketmaster-5a708063d73408ce4> sub\_arr needs to be parameterized by a value generated within the macro
18:42:32FromDiscord<haxscramper> And internal runtime that is tightly coupled with an implementation
18:43:03fn<Prestige99> Treesitter supports custom parsers
18:43:16FromDiscord<haxscramper> tree-sitter supports custom lexers
18:43:43fn<Prestige99> Yeah that's what I'm talking about, use nim for that
18:44:01FromDiscord<haxscramper> I can write lexer in nim, yes
18:44:13fn<Prestige99> Uh
18:44:26FromDiscord<haxscramper> But I can't reuse compiler lexer
18:44:33fn<Prestige99> I guess I'm really struggling to get my point across
18:44:37FromDiscord<haxscramper> Because required lexer implementation is also coupled with their runtime
18:44:57FromDiscord<@bracketmaster-5a708063d73408ce4> so going back to this
18:44:58FromDiscord<@bracketmaster-5a708063d73408ce4> https://paste.debian.net/1205079
18:45:03FromDiscord<@bracketmaster-5a708063d73408ce4> I'm not sure its actually possible
18:46:32FromDiscord<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:00FromDiscord<haxscramper> So if you wanted to say something unrelated to it, then I might've misunderstood you
18:47:43fn<Prestige99> Nah that was it, idk why that would prevent you from using Nim's lexer (with modifications)
18:51:05FromDiscord<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:38FromDiscord<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:11fn<Prestige99> I was thinking just have calls to Nim's lexer from within that function
18:52:11FromDiscord<haxscramper> Also nim lexer does not support incremental re-lexing, while TS one has this functionality built-in
18:52:34FromDiscord<haxscramper> I would have to sync two completely unrelated lexer states
19:01:45FromDiscord<haxscramper> After looking into it more, idea of hacking into `compiler/[lexer, parser]` seems pretty reasonable to me
19:02:27FromDiscord<haxscramper> I can store all tokens in the file and start/end token indices for a node, and that should be enough
19:03:44FromDiscord<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:00FromDiscord<haxscramper> Yes, this is just a more complicated macro
19:05:26FromDiscord<haxscramper> I think someone was writing a language that compiled to nim
19:09:18FromDiscord<carmysilna> I think min does
19:13:47FromDiscord<creonico> Is this a valid way to declare an array? `var some_array:array[size, T];`
19:15:52FromDiscord<haxscramper> !eval var test\: array[100, int]
19:15:55NimBotCompile failed: /usercode/in.nim(1, 12) Error: ':' or '=' expected, but got 'array'
19:16:09FromDiscord<haxscramper> what
19:16:40fn<Prestige99> !eval var test: array[100, int]
19:16:46FromDiscord<haxscramper> https://wandbox.org/permlink/dEiR1IGZajz6PWaq
19:16:57NimBot<no output>
19:16:59fn<R2D299> /usercode/in.nim(1, 5) Hint: 'test' is declared but not used [XDeclaredButNotUsed]
19:17:21fn<Prestige99> hax: it added a `\` before the `:` because of the bridge I think
19:24:24FromDiscord<haxscramper> But ultimately nim formatter must have support for custom pretty-printer plugins, due to various DSLs
19:25:30FromDiscord<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:08FromDiscord<timotheecour> is azure CI broken ? CI jobs are cancelled in https://github.com/nim-lang/Nim/pull/18555 and other PRs
20:23:46FromDiscord<carmysilna> Will the `nim.cfg` in my project root be used during `nimble build`?
20:27:23FromDiscord<@bracketmaster-5a708063d73408ce4> is there really no way to use arrays within a macro?
20:27:43FromDiscord<@bracketmaster-5a708063d73408ce4> https://paste.debian.net/1205165/
20:30:04FromDiscord<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:18FromDiscord<@bracketmaster-5a708063d73408ce4> correct
20:30:32FromDiscord<@bracketmaster-5a708063d73408ce4> to be more specific, arrays of TBD length in a macro
20:41:42FromDiscord<@bracketmaster-5a708063d73408ce4> so I know nim has static blocks
20:41:42FromDiscord<@bracketmaster-5a708063d73408ce4> can I somehow access a variable that was initialized in a static block during runtime?
20:41:59FromDiscord<checkersai> sent a code paste, see https://play.nim-lang.org/#ix=3tDE
20:42:04FromDiscord<checkersai> When I select yes it builds and runs fine
20:42:34FromDiscord<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:38FromDiscord<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:07FromDiscord<@bracketmaster-5a708063d73408ce4> @ynfle how?
21:09:16*fredrikhr quit (Ping timeout: 268 seconds)
21:16:50*max22- quit (Quit: Leaving)
21:33:38FromDiscord<@bracketmaster-5a708063d73408ce4> sent a long message, see http://ix.io/3tDU
22:10:48FromDiscord<checkersai> Is there a nim library that lets me just draw pixels on a window with little overhead?
22:11:52FromDiscord<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:31FromDiscord<InventorMatt> niGUI i believe can do that
22:17:26*xet7 quit (Remote host closed the connection)
22:30:03FromDiscord<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:45FromDiscord<@bracketmaster-5a708063d73408ce4> nim really doesn't like the length param of any arrays to be non-const during compile time
22:33:47FromDiscord<@bracketmaster-5a708063d73408ce4> apparently
22:40:08FromDiscord<creonico> So how can I achieve that? In C it gives me no issue
22:40:53FromDiscord<carmysilna> You can use `seq` instead of an array
22:44:38FromDiscord<creonico> Seq?
22:44:43FromDiscord<creonico> What is that ._.
22:46:28FromDiscord<@bracketmaster-5a708063d73408ce4> it means sequence in nim
22:48:06FromDiscord<creonico> ok
22:49:08FromDiscord<@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:31FromDiscord<ElegantBeef> well `physical_devices = newSeq[VKPhysicalDevice](physical_device_count)` 😄
22:57:22FromDiscord<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:15FromDiscord<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:45FromDiscord<konsumlamm> the main reason is that arrays are all9cated on the stack
23:02:04FromDiscord<konsumlamm> and the stack size has to be known at compile time
23:03:13FromDiscord<ElegantBeef> Well here's a start for that fixed seq really should make this a package 😄
23:03:14FromDiscord<@bracketmaster-5a708063d73408ce4> it seems that nim 1.5 allows for custom number literal operators
23:03:14FromDiscord<ElegantBeef> https://play.nim-lang.org/#ix=3tE8
23:03:18FromDiscord<ElegantBeef> Yes
23:03:24FromDiscord<@bracketmaster-5a708063d73408ce4> specifically, `'something`
23:03:43FromDiscord<@bracketmaster-5a708063d73408ce4> https://github.com/nim-lang/bigints/blob/master/src/literals.nim#L4
23:04:08FromDiscord<@bracketmaster-5a708063d73408ce4> but it seems that operator only allows for number literals?
23:04:31FromDiscord<Tuatarian> is there a findall function built into sequtils?
23:04:44FromDiscord<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:49FromDiscord<ElegantBeef> `filterit`
23:04:54FromDiscord<Tuatarian> indices
23:04:54FromDiscord<ElegantBeef> `filter`
23:05:10FromDiscord<Tuatarian> is there a way to grab indices from filter?
23:05:36FromDiscord<ElegantBeef> nope
23:06:04FromDiscord<Tuatarian> yeah
23:06:20FromDiscord<ElegantBeef> sent a code paste, see https://play.nim-lang.org/#ix=3tE9
23:06:23FromDiscord<Tuatarian> it's not hard to implement for sure
23:06:28FromDiscord<Tuatarian> but imo it should be in stdlib
23:06:33FromDiscord<Tuatarian> should I make a PR for it?
23:06:55FromDiscord<ElegantBeef> Possibly
23:07:06FromDiscord<Tuatarian> or maybe just add it to fusion
23:07:19FromDiscord<konsumlamm> honestly, there doesn't need to be a combinator for everything
23:07:46FromDiscord<konsumlamm> there are hundreds if "missing" combinators that are useful
23:08:07*def- quit (Quit: -)
23:08:11FromDiscord<konsumlamm> `collect` is a good enough solution imo
23:08:19*def- joined #nim
23:08:56FromDiscord<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:23FromDiscord<@bracketmaster-5a708063d73408ce4> Not seeing any documentation on the `'` operator that comes with nim 1.5 tho
23:09:24FromDiscord<konsumlamm> without or with low additional cost, that is
23:09:25FromDiscord<carmysilna> can't you `toSeq` an iterator
23:09:45FromDiscord<Tuatarian> is there a find iterator?
23:09:59FromDiscord<Tuatarian> don't remember there being a find iterator
23:10:11FromDiscord<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:45FromDiscord<Tuatarian> this kind of thing is my primary concern with contributing to nim stdlib or fusion
23:11:10FromDiscord<Tuatarian> I'm not super knowledgable interms of effciency
23:11:15FromDiscord<konsumlamm> In reply to @iWonderAboutTuatara "don't remember there being": https://nim-lang.github.io/Nim/system.html#find%2CT%2CS
23:11:35FromDiscord<Tuatarian> huh
23:11:40FromDiscord<konsumlamm> a `filterWithIbdex` wouldn't be inefficient
23:11:42FromDiscord<Tuatarian> would have expected it to be in sequtils
23:11:55FromDiscord<konsumlamm> my point is that it shouldn't be necessary in the first place
23:12:06FromDiscord<Tuatarian> it's not, for sure
23:12:13FromDiscord<konsumlamm> sewutils is for stuff that works on seqs, nit stuff that works for any iterable
23:12:18FromDiscord<Tuatarian> I see
23:12:20FromDiscord<konsumlamm> (edit) "sewutils" => "sequtils"
23:12:25FromDiscord<Tuatarian> openarrays yeah
23:12:27FromDiscord<konsumlamm> (edit) "nit" => "not"
23:12:27FromDiscord<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:27FromDiscord<Tuatarian> fair enough
23:12:51FromDiscord<carmysilna> In reply to @iWonderAboutTuatara "is there a find": `seq.filter(pred)[0]` should work
23:13:19FromDiscord<ElegantBeef> well ideally we do this with 0 allocations
23:13:27FromDiscord<konsumlamm> it would, but it first allocates a seq
23:13:39FromDiscord<konsumlamm> this isn't Haskell where the list is fused away
23:13:50FromDiscord<carmysilna> disappointing
23:14:44FromDiscord<carmysilna> sent a code paste, see https://play.nim-lang.org/#ix=3tEa
23:14:51FromDiscord<Zoom> zero\_functtional doesn't allocate and behaves just as requested, even though it's strictly speaking an incorrect behaviour
23:15:15FromDiscord<ElegantBeef> sent a code paste, see https://play.nim-lang.org/#ix=3tEb
23:15:32FromDiscord<ElegantBeef> Yea carmysilna that's 0 allocating
23:16:14FromDiscord<ElegantBeef> that break is wrong though since they want all indicies
23:16:20FromDiscord<ElegantBeef> And it returns the object 😄
23:16:23FromDiscord<konsumlamm> sent a code paste, see https://play.nim-lang.org/#ix=3tEc
23:16:59FromDiscord<konsumlamm> except it's a proc, not an iterator
23:17:08FromDiscord<konsumlamm> it just iterates
23:17:19FromDiscord<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:59FromDiscord<Tuatarian> another question
23:24:04FromDiscord<Tuatarian> what is the difference between
23:24:13FromDiscord<Tuatarian> and
23:24:18FromDiscord<Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=3tEd
23:24:28FromDiscord<Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=3tEe
23:25:50FromDiscord<Tuatarian> though ideally I think you would use an iterator to avoid an allocation
23:26:00FromDiscord<Tuatarian> but ignore that, mostly asking about collect
23:26:08FromDiscord<carmysilna> `collect` is basically a list comprehension but defined in the stdlib, its sugar to genericize iteration, afaict
23:26:14FromDiscord<carmysilna> https://nim-lang.org/docs/sugar.html#collect.m%2Cuntyped%2Cuntyped
23:27:44FromDiscord<Tuatarian> not really familiar with any of those terms lmao
23:27:57FromDiscord<Tuatarian> I've never done anything much with functional programming
23:28:05FromDiscord<Tuatarian> oh wait nevermind I see
23:28:15FromDiscord<Tuatarian> just lets you iterate over tables and hashmaps and such
23:28:40FromDiscord<Tuatarian> iterate over custom datatypes without implementing an iterator?
23:33:08FromDiscord<carmysilna> Yeah, I think so, but it might be restricted to stdlib stuff idk
23:38:17FromDiscord<ElegantBeef> Nah it works with custom collections
23:38:32FromDiscord<ElegantBeef> Just needs the `add` or `incl` procs
23:39:14FromDiscord<ElegantBeef> or i guess `[]=`
23:40:54FromDiscord<carmysilna> sent a code paste, see https://play.nim-lang.org/#ix=3tEf
23:41:16FromDiscord<ElegantBeef> They need to be in the same type section
23:41:38FromDiscord<carmysilna> Can I put a `variant` in a type section?
23:41:54FromDiscord<ElegantBeef> Probably not as it probably emits it's own typesection
23:42:26FromDiscord<carmysilna> I guess I'll just write my own object variant impl then
23:43:08FromDiscord<ElegantBeef> You could just modify it have a `variantTypeDef` that does `[0]` to the generated AST
23:43:29FromDiscord<ElegantBeef> Actually idk if that'd work
23:46:17FromDiscord<ElegantBeef> Could modify the macro then the use a `Value = variant` syntax then just have it mostly look like standard typesection
23:48:28fn<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:36FromDiscord<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:48FromDiscord<leorize> `import std/exitprocs`
23:53:59FromDiscord<RattleyCooper> oh lol
23:54:17FromDiscord<leorize> as a rule of thumb you should prefix stdlib modules with `std/`
23:54:18FromDiscord<RattleyCooper> wow, thank you that worked
23:54:30FromDiscord<leorize> I'm not sure if we have communicated this yet
23:54:39FromDiscord<ElegantBeef> also for multiple modules you should `std/[a, b, c]`
23:54:58FromDiscord<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:40FromDiscord<Jakraes> Hey guys, I need some help, is it possible to assign a value to a certain parameter in an object?
23:55:47FromDiscord<Jakraes> I wanted to do something like this
23:56:46FromDiscord<Jakraes> sent a code paste, see https://play.nim-lang.org/#ix=3tEh
23:57:09FromDiscord<ElegantBeef> Not built in but macros can let you
23:57:24FromDiscord<Jakraes> I wanted to assign a value to direc as soon as all the 4 parameters above are chosen
23:57:26FromDiscord<ElegantBeef> Typically you just make an `initVector`
23:57:26FromDiscord<Jakraes> Oh?
23:57:41FromDiscord<Jakraes> Oh, is there documentation on that?
23:58:16FromDiscord<ElegantBeef> well it's just a `proc initVector(yourArgsHere): Vector = Vector(direc: [finalX - startX, finalY - startY])`
23:58:26FromDiscord<ElegantBeef> It's rather tedious of course
23:59:29FromDiscord<@bracketmaster-5a708063d73408ce4> @\_discord\_145405730571288577\:t2bot.io - is this possible with macros?
23:59:29FromDiscord<@bracketmaster-5a708063d73408ce4> for i in 0..5\:↵ result.add\:↵ quote do\:↵ echo `i`
23:59:48FromDiscord<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:51fn<R2D299> itHub: 7"Nim macros to aid in object construction including event programming, and constructors."
23:59:56FromDiscord<ElegantBeef> yea that's possible with macros