00:02:40 | FromDiscord | <リク> Odd question but I'm working with some C++-like code and it's expecting a `pointer`. It's for opengl and it's supposed to stand for the "Array buffer offset." In c++ the value that gets passed in is `(void)0`. How do I represent that in Nim? |
00:03:00 | FromDiscord | <Elegantbeef> `nil` |
00:03:22 | FromDiscord | <リク> Alright heh |
00:08:10 | FromDiscord | <リク> Yep that worked well, thanks |
00:25:57 | FromDiscord | <jmgomez> In reply to @jmgomez "any idea on how": for the record, it has ptype.itemId which contains the module |
00:37:37 | * | om3ga quit (Ping timeout: 276 seconds) |
01:09:49 | FromDiscord | <Prestige> Is there a way to insert an element into a seq at a given position? I see there's `insert` in sequtils, but that takes an openArray as an argument |
01:10:15 | FromDiscord | <Elegantbeef> A seq is a openarray |
01:10:25 | FromDiscord | <Elegantbeef> the system insert works |
01:10:39 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/system.html#insert%2Cseq%5BT%5D%2CsinkT |
01:10:48 | FromDiscord | <Elegantbeef> Thought that was defined with an openarray |
01:10:50 | FromDiscord | <Prestige> ah that's what i needed, thanks |
01:10:56 | FromDiscord | <Elegantbeef> Forgot that it probably has code for growing |
01:24:03 | FromDiscord | <voidwalker> welp, have a bug somewhere in my code where I deserialize with binarylang. Not very good with debugging, went at it with echos, writefiles and readline(stdin). |
01:24:52 | FromDiscord | <voidwalker> I tried to do sizeof() on the object/object fields, but I always get 32 or 8, not the actual data size |
01:25:33 | FromDiscord | <Elegantbeef> If it's a ref you want `sizeof(T()[])` |
01:27:37 | FromDiscord | <voidwalker> like `$sizeof(peerMsg[])` ? |
01:28:26 | FromDiscord | <voidwalker> that doesn't compile |
01:29:19 | FromDiscord | <Elegantbeef> If i meant that i'd have wrote that 😄 |
01:29:48 | FromDiscord | <Elegantbeef> If it's a ref object to get the size of the internal object you either need an alias to to instantiate it inside of a `typeof` expression |
01:29:51 | FromDiscord | <Elegantbeef> Hence `T()` |
01:31:13 | FromDiscord | <Elegantbeef> alias or to\ |
01:31:22 | FromDiscord | <voidwalker> I've no idea what it is, it's written with macros |
01:31:32 | FromDiscord | <voidwalker> but probably ref |
01:31:45 | FromDiscord | <Elegantbeef> `static: echo peerMsg is ref` |
01:33:10 | FromDiscord | <voidwalker> doesn't show anything when I run it with static: |
01:33:14 | FromDiscord | <voidwalker> without static:, it gives false |
01:33:23 | FromDiscord | <Elegantbeef> It shows at compile time |
01:33:24 | FromDiscord | <Elegantbeef> hence `static` |
01:33:40 | FromDiscord | <Elegantbeef> Well then it's not a reference object |
01:43:03 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4uQ5 |
01:43:36 | FromDiscord | <voidwalker> I have this simple parsing structure, len parses fine, id as well, inde-xP and beginP inside the sub-parser do too |
01:43:56 | FromDiscord | <voidwalker> but chunk (the big string) is anywhere from 0 to actual size, and deterministically so |
01:44:22 | FromDiscord | <voidwalker> (edit) "size," => "size (always 16384 bytes)," |
01:49:05 | * | beholders_eye quit (Ping timeout: 250 seconds) |
01:49:44 | FromDiscord | <Elegantbeef> Is the chunk a `string` or an `array` |
01:49:50 | FromDiscord | <Elegantbeef> If it's a string it's heap allocated |
01:51:22 | FromDiscord | <voidwalker> it's a string of course |
01:51:50 | FromDiscord | <Elegantbeef> Then yea `sizeof(yourObj.chunk)` will show `8` or `16` depending on arc/orc |
01:52:44 | FromDiscord | <voidwalker> What to do to try and figure this out ? it's driving me crazy |
01:52:54 | FromDiscord | <Elegantbeef> No clue the issue |
01:53:11 | FromDiscord | <voidwalker> I checked the bitstream that is passed to the parser, reading it into a stream.. it has the correct size |
01:53:26 | FromDiscord | <voidwalker> (edit) "stream.." => "string.." |
01:53:58 | FromDiscord | <voidwalker> There's no reason why the parser would discriminate against some values in the stream ,it shouldn't care |
01:54:10 | FromDiscord | <voidwalker> then why do I get consistently the same wildly wrong results |
01:55:00 | FromDiscord | <voidwalker> I hoped I would actually have my first succesful torrent download tonight ;[ |
02:01:44 | * | demetera quit (Remote host closed the connection) |
02:02:52 | * | demetera joined #nim |
02:14:41 | FromDiscord | <voidwalker> Aha! |
02:14:54 | FromDiscord | <voidwalker> The whole blocks that it parsers are all html/doc text |
02:15:16 | FromDiscord | <voidwalker> It seems to stop at the 00 char value |
02:22:53 | * | TakinOver quit (Ping timeout: 250 seconds) |
02:27:34 | FromDiscord | <voidwalker> Just a curiosity. What is technically the shortest possible route (as in fewest memory moves) from network (socket) to disk ? |
02:27:46 | FromDiscord | <RandomVisitor> sendfile() |
02:28:29 | FromDiscord | <RandomVisitor> actually, ignore me. The in_fd argument must correspond to a file which supports↵ mmap(2)-like operations (i.e., it cannot be a socket). |
02:29:05 | FromDiscord | <RandomVisitor> mmap() your output file, recv()/read() into that memory mapping |
02:30:23 | FromDiscord | <voidwalker> oh that's not in nim |
02:30:47 | FromDiscord | <RandomVisitor> https://nim-lang.org/docs/memfiles.html |
02:30:53 | FromDiscord | <voidwalker> sendFile |
02:32:50 | FromDiscord | <RandomVisitor> sendfile is only useful for disk -> socket |
02:33:17 | FromDiscord | <voidwalker> not from socket -> disk ? |
02:34:03 | FromDiscord | <voidwalker> well, disk to socket is still good, for when you are seeding a torrent |
02:35:15 | NimEventer | New Nimble package! dirtydeeds - macro for partially applied calls, see https://github.com/metagn/dirtydeeds |
02:35:26 | FromDiscord | <voidwalker> A memory-mapped file is a segment of virtual memory[1] that has been assigned a direct byte-for-byte correlation with some portion of a file or file-like resource |
02:35:47 | FromDiscord | <voidwalker> so it doesn't actually take memory equal to the file's size |
02:53:41 | * | demetera quit (Remote host closed the connection) |
02:54:21 | * | demetera joined #nim |
03:20:45 | * | TakinOver joined #nim |
03:54:25 | * | rockcavera quit (Remote host closed the connection) |
04:23:50 | FromDiscord | <voidwalker> So I need something like iterators but that I don't have to iterate over, just assign the next value it gives, like a proc, is it possible ? |
04:44:17 | NimEventer | New thread by iacore: About PR backlog, see https://forum.nim-lang.org/t/10163 |
04:48:47 | * | azimut joined #nim |
05:11:22 | * | advesperacit joined #nim |
05:22:03 | * | alice quit (Remote host closed the connection) |
05:23:26 | * | alice joined #nim |
05:51:45 | * | pbsds quit (Quit: Ping timeout (120 seconds)) |
05:52:08 | * | pbsds joined #nim |
06:11:35 | * | lucasta quit (Remote host closed the connection) |
06:38:39 | * | PMunch joined #nim |
06:41:23 | FromDiscord | <lantos> are there any benefits to using the visitor pattern in nim? or is it not really needed |
06:53:22 | FromDiscord | <voidwalker> HEh, this is the first time I get a C error instead of a nim error: |
06:53:28 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4uQP |
06:54:51 | PMunch | lantos, well Nim code is typically much less object oriented than those systems these patterns are written for |
06:55:29 | PMunch | voidwalker, that's bound to happen sooner or later :P |
06:55:53 | FromDiscord | <voidwalker> I randomly tried to make that iterator a "closure" one, little clue how it actually works |
06:55:55 | FromDiscord | <voidwalker> and that was the result |
06:56:01 | PMunch | The one you got is really strange though |
06:56:07 | PMunch | Is this devel or stable? |
06:56:21 | FromDiscord | <voidwalker> 1.6.10 |
06:56:50 | FromDiscord | <Elegantbeef> Generally this is due to const closures |
06:57:32 | FromDiscord | <voidwalker> you are right, I did use a let to assign the closure iterator, but same result with var |
06:57:41 | FromDiscord | <Elegantbeef> `let` isnt a const |
06:58:02 | FromDiscord | <voidwalker> oh literally const , ok |
06:58:55 | FromDiscord | <voidwalker> So I have this problem, I need an iterator that I can use like a proc, to call from many async running procs |
06:59:46 | FromDiscord | <voidwalker> To return a requestable (not taken or finished) block info in a torrent |
07:01:00 | FromDiscord | <voidwalker> using iterator is <=1 us, vs ~60-70us average if I do full search |
07:01:29 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4uQT |
07:02:38 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4uQU |
07:03:17 | FromDiscord | <voidwalker> so I put the iterator inside a proc, and no closure needed ? |
07:03:22 | FromDiscord | <Elegantbeef> Like i said you likely want a closure generator, uncertain why it gave a cgen error though |
07:03:35 | FromDiscord | <Elegantbeef> Well iterators have to be closure if they exist at runtime |
07:04:11 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4uQV |
07:04:39 | FromDiscord | <Elegantbeef> Yea that's quite odd that it errored |
07:05:22 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/aOz |
07:08:10 | FromDiscord | <Elegantbeef> It probably wont resolve the issue |
07:08:21 | FromDiscord | <voidwalker> Checking now |
07:08:35 | FromDiscord | <voidwalker> So I can't do result = blockDispatcher2(t) ? |
07:09:02 | FromDiscord | <Elegantbeef> What? |
07:09:17 | FromDiscord | <voidwalker> I mean some other way instead of writing the iterator definition inside the result. which looks weird to me |
07:09:31 | FromDiscord | <Elegantbeef> You can write the iterator inside the proc then give it a name |
07:10:06 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4uQX |
07:10:19 | FromDiscord | <voidwalker> so iterator has access to makeMyClos params.. ok |
07:10:50 | FromDiscord | <Elegantbeef> What you're doing with this proc is making a closure iterator that holds it's internal state |
07:10:58 | FromDiscord | <Elegantbeef> Instead of having to pass it's state every time |
07:11:06 | FromDiscord | <Elegantbeef> But anyway this probably wouldnt resolve anything |
07:12:00 | FromDiscord | <voidwalker> why not ? |
07:12:24 | FromDiscord | <Elegantbeef> Cause the issue is probably something with the actual iterator given that it's incorrectly generating code |
07:13:21 | FromDiscord | <voidwalker> var (a,b,c) = dispatchClo(t) |
07:13:26 | FromDiscord | <voidwalker> Error: 'tuple' expected |
07:13:47 | FromDiscord | <Elegantbeef> What did you make the closure return? |
07:13:54 | FromDiscord | <voidwalker> and used that |
07:13:55 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4uQY |
07:14:11 | FromDiscord | <Elegantbeef> Are you sure? |
07:14:49 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4uQZ |
07:14:54 | FromDiscord | <voidwalker> blah nvm |
07:15:30 | FromDiscord | <Elegantbeef> Ah you see the issue 😄 |
07:15:35 | FromDiscord | <voidwalker> actually no : ( |
07:15:49 | FromDiscord | <Elegantbeef> `dispatchClo` returns a iterator |
07:16:38 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4uR0 |
07:16:44 | FromDiscord | <voidwalker> hmm okay, so where should I assign this iterator ? |
07:16:50 | FromDiscord | <voidwalker> global var ? |
07:17:05 | FromDiscord | <Elegantbeef> I mean wherever you need to hold onto this torrent's state |
07:17:27 | FromDiscord | <voidwalker> well this state is global to the Torrent. each connection is handled in an async proc in a loop |
07:18:05 | FromDiscord | <voidwalker> and when we're connected and all is green, we ask for pieces' info that can be downloaded |
07:18:26 | FromDiscord | <voidwalker> no race condition since it's just async |
07:19:06 | FromDiscord | <voidwalker> so I only need to have one shared instance of this iterator, right ? |
07:19:27 | FromDiscord | <voidwalker> assigning multiple ones will make separate ones each with its own state |
07:19:45 | FromDiscord | <Elegantbeef> Correct |
07:25:27 | FromDiscord | <voidwalker> that's pretty nifty |
07:25:43 | FromDiscord | <voidwalker> So I can swap iterator types on the go |
07:25:49 | FromDiscord | <Elegantbeef> But does the compiler error still exist? 😄 |
07:26:00 | FromDiscord | <voidwalker> just a sec, I rewrote the types to more human readable names |
07:26:16 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4uR1 |
07:26:48 | FromDiscord | <voidwalker> that's actually what I wanted, to make other iterator types that use priorities instead of "first to last" |
07:30:39 | FromDiscord | <AmjadHD> sent a code paste, see https://play.nim-lang.org/#ix=4uR2 |
07:32:47 | FromDiscord | <voidwalker> it's working @ElegantBeef !! |
07:36:36 | FromDiscord | <voidwalker> and it got the exact same byte length as expected.. only I cannot write it to file properly cause of that parser error. I mean I could bypass the parser for that special case, but I'd rather wait for binarylang author to come online and maybe fix the bug |
07:43:30 | FromDiscord | <abisxir> Guys is there any good resource for understanding "concept" in nim and to see where to use it, where not? |
07:44:03 | FromDiscord | <Elegantbeef> https://www.jasonbeetham.com/codereuse.html probably the best writeup about them that i know of |
07:44:06 | FromDiscord | <Elegantbeef> Not biased |
07:51:05 | * | azimut quit (*.net *.split) |
07:51:05 | * | pharonix71 quit (*.net *.split) |
07:52:07 | * | azimut joined #nim |
07:52:07 | * | pharonix71 joined #nim |
07:56:43 | * | PMunch_ joined #nim |
07:59:37 | * | PMunch quit (Ping timeout: 276 seconds) |
08:13:26 | FromDiscord | <abisxir> In reply to @Elegantbeef "Not biased": Thanks 🙂 |
08:30:45 | * | PMunch__ joined #nim |
08:33:08 | * | PMunch_ quit (Ping timeout: 240 seconds) |
08:57:13 | * | PMunch_ joined #nim |
08:59:25 | * | PMunch__ quit (Ping timeout: 240 seconds) |
09:16:04 | * | beholders_eye joined #nim |
09:27:05 | FromDiscord | <cmc> sent a code paste, see https://paste.rs/uxf |
09:31:31 | FromDiscord | <Elegantbeef> I mean you can do `t: tuple` |
09:31:43 | FromDiscord | <Elegantbeef> But yes in your case you'd want a concept |
09:32:08 | FromDiscord | <Elegantbeef> https://github.com/beef331/nimtrest/blob/master/yeacs.nim#L13-L30 for some inspiration cmc |
09:43:00 | FromDiscord | <cmc> sent a code paste, see https://paste.rs/sAj |
10:28:16 | * | beholders_eye quit (Ping timeout: 248 seconds) |
10:47:56 | NimEventer | New thread by xendi: Arch package not up-to-date with 1.16.12, see https://forum.nim-lang.org/t/10164 |
10:48:56 | NimEventer | New thread by alexeypetrushin: String fmt doesn't work inside of template?, see https://forum.nim-lang.org/t/10165 |
11:49:12 | Amun-Ra | I like Nim 2.0 late 'let' initialization |
11:51:00 | Amun-Ra | (although I'm not sure it's called that way) |
11:58:55 | * | om3ga joined #nim |
12:00:53 | om3ga | is it possible to access Table elements (key, value) by index number? |
12:12:23 | * | PMunch_ quit (Quit: Leaving) |
12:15:21 | FromDiscord | <demotomohiro> It is possible if you use int type as key. |
12:16:43 | om3ga | demotomohiro thanks, unfortunately I cant do that, so I used .mpairs iterator, and .del to free the ram |
12:17:04 | om3ga | I hope it will work not too slow |
12:19:59 | om3ga | heh.. no chance, loop through the table not works due to length change... |
12:20:57 | FromDiscord | <ezquerra> In reply to @Amun-Ra "I like Nim 2.0": Does it require enabling {.experimental: "strictDefs".} or does the new definite assignment analysis work even without that flag? |
12:21:08 | * | rockcavera joined #nim |
12:21:20 | FromDiscord | <frobnicate> So I'm making some procs for rolling dice, is there a way I can make it so the `d` works like an operator?↵So `2d6` would return a seq with two random numbers between 1 and 6 and so on |
12:21:31 | FromDiscord | <frobnicate> Just to make the syntax a little more nifty |
12:22:27 | NimEventer | New thread by archnim: Locks on dynamically allocated memory, see https://forum.nim-lang.org/t/10166 |
12:23:55 | FromDiscord | <frobnicate> In case it's possible I wanted to also add things like `3d6kh1` to keep the highest or `dl` to drop lowest |
12:24:35 | Amun-Ra | ezquerra: it does |
12:26:00 | FromDiscord | <ezquerra> That’s awesome. Without this new feature sometimes I end up using variables where a let could (logically) be used |
12:27:35 | FromDiscord | <ezquerra> I wish there was a way to “convert” a bar into a let once you know the value shouldn’t be changed anymore (e.g. a way to rebind a name to a new var/let) |
12:28:03 | FromDiscord | <frobnicate> Otherwise I would have to write it as `2.d 6`? |
12:28:55 | FromDiscord | <demotomohiro> In reply to @frobnicate "So I'm making some": You can use only specific characters as operator:↵https://nim-lang.org/docs/manual.html#lexical-analysis-operators↵https://nim-lang.org/docs/manual.html#lexical-analysis-unicode-operators |
12:29:13 | FromDiscord | <demotomohiro> In reply to @frobnicate "Otherwise I would have": `2.d 6` is possible. |
12:29:14 | Amun-Ra | ezquerra: you can reuse variable passed as a proc argument, as in: proc foo(x: int): var x = x |
12:29:26 | Amun-Ra | but that's var→let |
12:29:31 | Amun-Ra | I mean ← |
12:29:43 | FromDiscord | <frobnicate> Ok thanks so much, I was struggling figure out if you could make custom operators 🙂 |
12:30:48 | FromDiscord | <frobnicate> Then I guess for my other example it would be something like `(6.d 6).kh 1` or is there a prettier way of writing it in the usual dice notation? |
12:36:05 | FromDiscord | <oxnan> Hey, I am struggling to find out what the fastest way for doing a string search through huge files is. Preferably I can do many strings at the same time, either single or multithreaded, but should be done without using too much memory. Anyone have experience with this and can point me in the right direction? |
12:45:25 | om3ga | oxnan, iterate over filenames, open the files, find the requred matching characters |
12:46:24 | om3ga | print out the filename, line number or offset, |
12:46:46 | om3ga | or store the results somewhere |
12:46:54 | FromDiscord | <oxnan> makes perfect sense, and that's what I tried, but something when out of control when using std/nre for the matching, to the point where reading a 1gb file would use 6gb memory |
12:47:55 | FromDiscord | <oxnan> might have been the combination of threadpool and nre that did it, not entirely sure, and my nim experience is limited |
12:48:36 | om3ga | unfortunately I cannot comment regarding std/nre, never used it. But regular character matching should work fast , just shift the comparison of the read bytes by one, and compare from beggining and the end - this mathematically will speedup the process |
12:49:47 | om3ga | once one byte will not match, you can shift the index of compared bytes by 1, and so on |
12:50:41 | FromDiscord | <oxnan> so just iterate over the file from beginning to end and check if mystring[0] == readstring[0] and mystring[^1] == readstring[^1] essentially? |
12:50:53 | FromDiscord | <oxnan> wait yeah, makes sense |
12:51:14 | om3ga | yeah, something like that |
12:51:15 | FromDiscord | <oxnan> my logic in the message is flawed but I get the idea |
12:52:00 | om3ga | only I mean compare all the bytes in the search string |
12:52:21 | FromDiscord | <oxnan> (edit) "readstring[0]" => "readstring[currentindex]" | "readstring[^1]" => "readstring[currentindex+len(mystring)]" |
12:52:56 | FromDiscord | <oxnan> yes, but from your message it seems like you suggest an inwards search from both sides or am I misunderstanding that? |
12:54:19 | om3ga | yeah, idk proper name of that method, if all bytes matched, then it should be the requred match |
12:54:45 | FromDiscord | <oxnan> no worries, just wanted to make sure we are on the same page and that I'm not misunderstanding 🙂 |
12:55:51 | om3ga | only it will work for ascii only, for utf stuff can require additional processing |
12:56:04 | FromDiscord | <oxnan> yeah, that should not be a problem for now 🙂 |
12:58:15 | FromDiscord | <oxnan> another thing you can help me with if you have the time: I am wondering if there is a way that I can have this run with multiple threads at once without multiplying my memory usage. currently I am trying to pass the filecontents to the thread when I spawn it, but from what I can tell it creates a new "local" version of that variable which is why the memory usage goes mad. Am I misunderstanding here, and/or is there something to do about it |
12:58:47 | om3ga | sure, you can use threads module |
12:59:34 | om3ga | for example you can create N number of theads , that will process portions of the filenames |
13:00:09 | om3ga | and the string finder procedure will do the stuff in parallel |
13:00:44 | FromDiscord | <oxnan> right, in my case I only need to check one file, but I need to check for many different strings. |
13:32:36 | * | frenchboy[m] quit (Quit: Bridge terminating on SIGTERM) |
13:38:18 | * | frenchboy[m] joined #nim |
13:42:21 | FromDiscord | <Nerve> Does there exist some sort of bug where macro-compiled source files can get too long? I have a templates source file where I deposit the render functions for a ton of nimja templates, and for whatever reason when it reaches some ways down the render functions, the imports seem to just...drop out of scope. |
13:43:55 | FromDiscord | <oxnan> thanks a lot om3ga, just the bump I needed, and it works now 🙂 |
13:55:34 | FromDiscord | <mratsim> In reply to @Nerve "Does there exist some": How long?↵↵That sounds more like a generic sandwich bug. You might need to reexport some modules |
13:58:34 | FromDiscord | <Nerve> In reply to @mratsim "How long? That": I tried re-importing the module that seemed to dropped out of scope right above the render function that was complaining, no apparent change |
13:59:08 | FromDiscord | <Nerve> There's probably something else going on here |
13:59:25 | FromDiscord | <Nerve> I've been reorganizing my sources and this worked fine before |
14:12:36 | * | beholders_eye joined #nim |
14:12:55 | FromDiscord | <Nerve> Also to be clear, a number of the render functions are generic to a parameter that can be of two or three types with very similar shapes. But numerous generic render functions above the one that is complaining don't complain. |
14:33:32 | FromDiscord | <BigPaperHand> Hey @guzba, do you have any suggestions for libs to support sessions in Mummy? |
14:38:11 | FromDiscord | <firq> @oxnan\: Have you looked into using memfiles? https://nim-lang.org/docs/memfiles.html I've achieved some very significant speed increases by going that route. |
14:38:12 | FromDiscord | <firq> Not sure if it's relevant for your use case, but there is some discussion about it here https://forum.nim-lang.org/t/9688 |
14:38:36 | FromDiscord | <oxnan> Uhh, nice thanks! |
14:38:53 | FromDiscord | <firq> I've been using the https://github.com/c-blake/cligen/blob/master/cligen/mfile.nim and https://github.com/c-blake/cligen/blob/master/cligen/mslice.nim helpers/wrappers from the cligen package though, which I think are a bit easier to use |
14:44:17 | * | beholders_eye quit (Ping timeout: 256 seconds) |
15:28:14 | FromDiscord | <Nerve> In reply to @mratsim "How long? That": I've done more testing. I thought that some procs being "out of scope" in the templates might be fixed if I first call those procs in the render function itself, fully within view of the imports in the render module. Still getting the same errors. It's like all the render procs/templates above the one complaining consume the imports and I can't do anything with them after that point. |
15:28:22 | FromDiscord | <Nerve> Does this still sound like that sandwich thing? |
15:28:43 | FromDiscord | <Nerve> (edit) "first call" => "pre-process" |
15:28:59 | FromDiscord | <Nerve> (edit) "function" => "proc" |
15:35:12 | * | beholders_eye joined #nim |
15:49:54 | * | lucasta joined #nim |
15:53:54 | FromDiscord | <treeform> In reply to @voidwalker "I used this one": I found that plain array of booleans is faster then compact bit array. But bit arrays take up a lot less space. But taking a bit out of a bit array significant penalty. I don't know why. |
15:54:48 | FromDiscord | <treeform> (edit) "In reply to @voidwalker "I used this one": I found that plain array of booleans is faster then compact bit array. But bit arrays take up a lot less space. But taking a bit out of a bit array ... significant" added "has" |
15:54:51 | FromDiscord | <voidwalker> i'm thinking it should be faster as well, although I have seen mentions of the bit structure being faster, for some reason. It shouldn't be much slower though |
15:56:05 | FromDiscord | <treeform> I think if you incorporate taking the bit out with your other logic it might negate the cost. But I have found bit arrays not being performant. |
15:56:12 | FromDiscord | <voidwalker> i was asking if it's somehow possible to hack allocating a not known at compile time array (even if custom implemented), allocated in stack. So I could write bit vectors on it, and compare performance vs seq |
15:57:26 | FromDiscord | <treeform> you just drop and use the the low level C functions for that and UncheckedArray. |
15:57:58 | FromDiscord | <voidwalker> well, for my use case, downloading torrents, it cannot be really helped. torrents can span to millions of little blocks, and if you have many active at a time, it's a big hit to RAM usage. Although I am thinking to implement both ways, and have some kind of method to pick the implementation depending on RAM usage or CPU usage tradeoff |
15:59:17 | FromDiscord | <treeform> I would not allocate that on the stack... |
15:59:21 | FromDiscord | <treeform> stack is only for small things |
15:59:25 | FromDiscord | <treeform> Some one did this: https://github.com/bpr/vla/blob/master/src/vla.nim |
16:00:04 | FromDiscord | <treeform> `alloca` allocates things on the stack |
16:00:17 | FromDiscord | <treeform> But the stacks are usually quite small |
16:01:09 | FromDiscord | <voidwalker> yeah I was looking at exactly that. But I read that alloca allocates on the heap normally ? |
16:01:10 | FromDiscord | <treeform> I do think bit arrays make sense in the torrent use case. |
16:02:06 | FromDiscord | <treeform> you are thinking of `aloc` functions in Nim |
16:02:25 | FromDiscord | <treeform> it's a name collision with the `aloca` C function which does the stack. |
16:02:34 | FromDiscord | <voidwalker> `The alloca() function allocates size bytes of space in the stack frame of the caller. This tempo‐↵ rary space is automatically freed when the function that called alloca() returns to its caller.↵` |
16:03:23 | FromDiscord | <treeform> https://man7.org/linux/man-pages/man3/alloca.3.html |
16:03:27 | FromDiscord | <treeform> yes |
16:03:33 | FromDiscord | <treeform> (edit) "`aloca`" => "`alloca`" |
16:03:38 | FromDiscord | <treeform> (edit) "`aloc`" => "`alloc`" |
16:04:29 | FromDiscord | <voidwalker> hm but yeah, given the potential size, even as bits, these should not be on the stack indeed |
16:05:18 | FromDiscord | <treeform> vs https://github.com/nim-lang/Nim/blob/devel/lib/system/alloc.nim#L1044-L1056 |
16:06:25 | FromDiscord | <treeform> I have a feeling that big vectors will work for your torrent as they are update not frequently. Unlike say in a ray tracer, A or a physics engine. |
16:06:42 | FromDiscord | <treeform> (edit) "big" => "bit" | "torrent" => "torrents" | "not frequently." => "infrequently." |
16:06:55 | FromDiscord | <treeform> (edit) "update" => "updated" |
16:12:45 | FromDiscord | <voidwalker> well yeah, they are only needed when downloading, to keep track of what we want/have/ and what is currently active |
16:12:57 | FromDiscord | <voidwalker> after download, you can ditch it, it's all 1's |
16:19:34 | NimEventer | New thread by Sentmoraap2: 2 blocks 1 indentation, see https://forum.nim-lang.org/t/10167 |
16:37:21 | * | arkurious joined #nim |
16:37:21 | * | arkurious quit (Client Quit) |
16:40:47 | * | lucasta quit (Ping timeout: 265 seconds) |
16:53:08 | * | beholders_eye quit (Ping timeout: 240 seconds) |
17:01:56 | * | lucasta joined #nim |
17:06:00 | * | beholders_eye joined #nim |
17:24:28 | * | hochata joined #nim |
17:28:23 | * | beholders_eye quit (Ping timeout: 264 seconds) |
17:45:04 | FromDiscord | <Chronos [She/Her]> Is the jsgen backend very messy? |
17:45:34 | FromDiscord | <Chronos [She/Her]> As in, could it be somewhat easily be adapted to output code in another format? |
17:56:43 | FromDiscord | <Nerve> Lesson learned: Calling nimja `compileTemplateFile` within generic/template functions is a bad idea. Need to manually have separate render function signatures for each possible input type, which is annoying, but prevents the sandwich symbol-resolution problem. |
17:56:57 | FromDiscord | <Nerve> (edit) "functions" => "render procs" |
17:57:06 | FromDiscord | <Nerve> (edit) "function" => "proc" |
17:58:11 | FromDiscord | <Nerve> (edit) "Lesson learned: Calling ... nimjamacro" added "the" | "thenimja `compileTemplateFile` ... within" added "macro" |
17:59:55 | * | hochata quit (Ping timeout: 260 seconds) |
18:56:17 | NimEventer | New post on r/nim by DromedarioDeChapeu: Where to find quick help, see https://reddit.com/r/nim/comments/137wdsv/where_to_find_quick_help/ |
19:00:49 | FromDiscord | <Chronos [She/Her]> I made a PR to a Nim library!↵↵...it was literally just 3-4 very small edits and didn't actually affect the code in any meaningful name lol |
19:04:42 | FromDiscord | <voidwalker> better, faster, cleaner |
19:21:26 | * | Guest9076 joined #nim |
19:21:54 | * | Guest9076 quit (Client Quit) |
19:26:41 | * | lucasta quit (Remote host closed the connection) |
19:30:59 | FromDiscord | <Dromedario de Chapeu> Hello, is in this chat where i can ask for help? I'm now with a recursive dependency types problem. And i cant find something |
19:42:44 | NimEventer | New thread by fish_fileng2: How to turn a string into a a procedure, see https://forum.nim-lang.org/t/10169 |
19:49:09 | * | Notxor joined #nim |
19:51:23 | * | advesperacit quit (Ping timeout: 268 seconds) |
19:58:30 | * | lumo_e joined #nim |
20:00:46 | FromDiscord | <Elegantbeef> Here↵(@Dromedario de Chapeu) |
20:00:53 | FromDiscord | <Elegantbeef> What's the actual problem |
20:27:53 | FromDiscord | <Dromedario de Chapeu> I have a type in file X, and other in file Y. But the type X and Y use each other. And this is a "recursive dependency" I'm doing by create the type X and Y in the same Type Block in the same file. But this hit me a little. Is possible to use type X in Y, and Y in X without this recursive dependency? (Also, sorry for my bad english, as i said in the Reddit post, i'm from Brazil and i'm not 100% comfortable to talk in english) |
20:36:00 | FromDiscord | <Nerve> I believe Nim explicitly makes that impossible, as do many languages. You probably need to rethink and remodel your problem so that hierarchically defined types can describe it. |
20:37:29 | FromDiscord | <Dromedario de Chapeu> Ok ok, i'll take notes. Thanks Marble Man |
20:38:24 | FromDiscord | <Elegantbeef> You can have recursively dependant types |
20:38:28 | FromDiscord | <Elegantbeef> So it depends on the way you're defining them |
20:39:33 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4uU1 |
20:39:35 | FromDiscord | <Dromedario de Chapeu> i'll continue with X and Y in the same file, i'll do my best to organize the code 2 types in one file |
20:41:58 | FromDiscord | <huantian> yeah if you have a dependency like that you either can restructure your code so you don't, or use one type block↵one somewhat common pattern is for people to have files dedicated just for type definitions |
20:42:43 | FromDiscord | <Elegantbeef> I do wonder if using generics for dependency injection could be a nice pattern 😄 |
20:43:25 | FromDiscord | <Dromedario de Chapeu> sent a code paste, see https://play.nim-lang.org/#ix=4uU2 |
20:44:27 | FromDiscord | <0ffh> You could define the types in a third module, then you can still distribute your procs in distinct files. |
20:44:41 | FromDiscord | <0ffh> (edit) "in" => "into" |
20:45:28 | FromDiscord | <Dromedario de Chapeu> In reply to @huantian "yeah if you have": and when i put the methods? Like, just put ever function in the same file looks a little rough to me |
20:45:48 | FromDiscord | <Elegantbeef> All the types in the same module, procedures would be in their own seperate module |
20:46:14 | FromDiscord | <Dromedario de Chapeu> So, i can create the type in file Types.nim, and create the procedures in other file? |
20:46:21 | FromDiscord | <Elegantbeef> Of course |
20:46:22 | FromDiscord | <0ffh> yep |
20:46:37 | FromDiscord | <Elegantbeef> Nim is procedural, which means all functions are free standing |
20:47:38 | FromDiscord | <Dromedario de Chapeu> sent a code paste, see https://play.nim-lang.org/#ix=4uU3 |
20:48:55 | FromDiscord | <Elegantbeef> Using a tuple, shame on you |
20:49:24 | FromDiscord | <huantian> beef when you make that linter you can make a rule to error on all tuples 🙃 |
20:49:34 | FromDiscord | <Elegantbeef> lol |
20:49:45 | FromDiscord | <Elegantbeef> Presently too busy adding line info to fungus |
20:49:54 | FromDiscord | <Dromedario de Chapeu> i prefer to use tuple instead of object in simple cases |
20:50:28 | FromDiscord | <Dromedario de Chapeu> In reply to @huantian "beef when you make": what? |
20:50:40 | FromDiscord | <Elegantbeef> Meh if you're adding procedures to a tuple you want a distinct type imo |
20:50:48 | FromDiscord | <huantian> In reply to @Dromedario de Chapeu "what?": don't worry about it, just a joke about something else |
20:50:57 | FromDiscord | <Dromedario de Chapeu> ok |
20:51:09 | FromDiscord | <Dromedario de Chapeu> In reply to @Elegantbeef "Meh if you're adding": distinct works with tuples to? |
20:51:15 | FromDiscord | <Dromedario de Chapeu> good to know |
20:51:19 | FromDiscord | <Elegantbeef> Yea it's called `object` |
20:51:23 | FromDiscord | <Elegantbeef> `MyType = object` |
20:52:37 | FromDiscord | <Dromedario de Chapeu> has some emote about hating OOP in this group? |
20:52:58 | FromDiscord | <Elegantbeef> `object` is not OOP in Nim |
20:53:09 | FromDiscord | <Elegantbeef> It's what Nim calls a record or struct |
20:53:39 | FromDiscord | <Elegantbeef> `ref object of ...` is inheritance with runtime polymorphism |
20:54:01 | FromDiscord | <Dromedario de Chapeu> ok.... so, objects in Nim, is """just""" a sugar to structs? |
20:54:13 | FromDiscord | <Elegantbeef> It's not a sugar to structs it is a struct |
20:54:31 | FromDiscord | <Elegantbeef> It's a non structurally typed data type |
20:54:40 | FromDiscord | <Elegantbeef> Tuples on the otherhand are structurally typed |
20:54:55 | FromDiscord | <0ffh> In reply to @Dromedario de Chapeu "ok.... so, objects in": Arguably OOP langs are just sugar to structs with references to function tables. |
20:55:42 | FromDiscord | <Dromedario de Chapeu> In reply to @Elegantbeef "It's not a sugar": Ok, now i need a emote about fall in love with Nim. This has been the only "I dont like this" in Nim for a long time |
20:56:41 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/0k4 |
20:56:53 | FromDiscord | <Elegantbeef> You can lose type information without any isssue |
20:57:01 | FromDiscord | <Elegantbeef> You also can gain type information |
20:57:43 | FromDiscord | <Elegantbeef> The only benefit of a type definitioned `tuple` is that it has unpacking |
20:57:57 | FromDiscord | <Elegantbeef> But with macros/procedures you can get the same with objects |
20:57:59 | FromDiscord | <Dromedario de Chapeu> sent a code paste, see https://play.nim-lang.org/#ix=4uU5 |
20:58:22 | FromDiscord | <Elegantbeef> Odd means weird, funky, swanky, unusual, weird.... wait i wrote that one already |
20:58:27 | FromDiscord | <0ffh> I admit I sometimes use tuples instead of objects just because the literals are less typing. 😅 |
20:58:48 | FromDiscord | <Elegantbeef> I like a static type system and gaining/losing type information is awful imo |
20:59:04 | FromDiscord | <Dromedario de Chapeu> In reply to @Elegantbeef "Odd means weird, funky,": Ok, thanks |
20:59:25 | FromDiscord | <Dromedario de Chapeu> sent a code paste, see https://play.nim-lang.org/#ix=4uU6 |
21:00:20 | FromDiscord | <0ffh> In reply to @Elegantbeef "I like a static": Yeah, it may be a pitfall sometimes but still for small programs I don't care as long as I save me some preciousss keystrokes. 😁 |
21:00:47 | FromDiscord | <Dromedario de Chapeu> In reply to @Elegantbeef "I like a static": the first motive to i start with nim is "Is like Python, but with good Type System" i really dislike dynamic type. |
21:01:09 | FromDiscord | <0ffh> In reply to @Dromedario de Chapeu "the first motive to": Good choice right there my man! |
21:05:41 | FromDiscord | <Dromedario de Chapeu> Also @Mitt 龍 is a friend of mine. I has talking so much about how Nim is fast but with a really satisfactory syntax to him, that him is trying for now. He is trying Rust Also, but soon he will come to Nim, i hope. |
21:06:07 | FromDiscord | <Dromedario de Chapeu> (edit) "him" => "he" |
21:26:34 | FromDiscord | <Dudugz> Honestly I came to Nim on a friend's recommendation, said it was similar to python only 10x better. |
21:28:02 | * | beholders_eye joined #nim |
21:28:45 | FromDiscord | <luteva> Hi! I would like to start a shell command and get the PID as result. how can i do that? execShellCmd returns the exit code and it returns after the process has finished. |
21:29:32 | FromDiscord | <luteva> is there something like spawn process that spawn a new thread starting a shell? |
21:29:51 | FromDiscord | <luteva> or how can i do that? |
21:30:35 | FromDiscord | <Dromedario de Chapeu> Is possible to echo the result in a file and read from that file? |
21:32:27 | FromDiscord | <luteva> also when i use startProcess, and see the process list, the started process is in defunct state. although it is a server process that should keep running |
21:33:49 | FromDiscord | <luteva> so: how can i start a server process from within a nim programm (and leave it running as normal) and get the PID (to work with this process). |
21:52:02 | FromDiscord | <guzba> In reply to @BigPaperHand "Hey <@318284269908918273>, do you": i do not know of any specific libs for sessions that nor am i that familiar with session stuff. iirc sessions are a cookie-based temp auth thing. i dislike cookies altogether so i have always just used a generated access token + localstorage and include it in http requests either as a header or however you prefer (eg `headers["Access-Token] = "token here"`) |
22:06:46 | * | beholders_eye quit (Ping timeout: 250 seconds) |
22:08:43 | arkanoid | I'm interested in learning how to build small web utilities with Nim, which packages are worth exploring? By looking https://github.com/ringabout/awesome-nim#web it seems to me that only 3 projects have contributors > 20, namely karax, jester and prologue. I need something production ready and something I can rely on (and that is here to stay). Should I consider some other packages? |
22:11:01 | FromDiscord | <guzba> i suggest your contributor count filter is not a good one. you probably do not care that many ppl contributed typo fixes or little things but are long gone now. it heavily biases toward simply old repos. you care some number of people use the lib in production themselves and thus have an incentive to keep it working well as opposed to letting the repo sit inactive |
22:11:18 | * | Notxor quit (Remote host closed the connection) |
22:11:57 | FromDiscord | <voidwalker> yeah and nim libraries don't have that many contributors to begin with, they're mostly 1-2 man job |
22:13:12 | FromDiscord | <voidwalker> Just consider what you can and want to use from that list. Some authors are still around and take feature requests even if last commit is >1 year. |
22:14:43 | FromDiscord | <voidwalker> I guess the main tool will be the framework, I haven't used any yet, but the real choice is between jester and prologue I guess |
22:15:21 | arkanoid | voidwalker, I'm aware of this, I'm new to nim web development but not new to nim in general. Nimble gives no stats for package usage/downloads, the only available metadata is stars, contributors, version number (is semantic), last commit |
22:16:17 | FromDiscord | <BigPaperHand> In reply to @guzba "i do not know": Guzba, whats your vision about Mummy? I feel that have a huge potencial as a web framework too, not only as a server. Do you think will be possible to add more resources regarding templating (html), cookies, etc? |
22:17:06 | FromDiscord | <voidwalker> Hey @guzba I noticed your httpbeast beast. I am trying to write a torrent client, which has sort of a similar pattern of i/o and potential threading. Can I randomly PM you at a future time to ask for some insights/opinions about this (threading/async model) ? |
22:17:49 | FromDiscord | <Elegantbeef> hey do not PM people, have conversations in public! |
22:18:12 | FromDiscord | <voidwalker> Well sure, if both online at the same time. |
22:18:55 | FromDiscord | <voidwalker> mummy, not beast, sorry, that's the other one |
22:19:55 | FromDiscord | <BigPaperHand> In reply to @voidwalker "mummy, not beast, sorry,": you can edit the message. |
22:20:02 | FromDiscord | <guzba> In reply to @BigPaperHand "Guzba, whats your vision": there is always more that i want to add, however i prefer a model of "composing parts" to "all or nothing whole"↵eg my mummy/routers is not required, you can totally bring your own router implementation since it is just a proc to be called↵same would apply for generating responses, bring your own json, bring your own database stuff↵it is not necessary to force one thing for all o |
22:20:29 | FromDiscord | <guzba> i dont mind having lots of examples and linking to good libs |
22:21:40 | FromDiscord | <guzba> but ive not seen a requirement to force things, totally room for someone to make a great toolkit for rest and have that plug in to mummy http callbacks or even create a richer callback based on a closure which i could demo in an example |
22:21:51 | FromDiscord | <guzba> (edit) "but ive not seen a requirement to force things, totally room for someone to make a great toolkit for ... reststuff" added "eg" | "egrest ... and" added "stuff" |
22:22:14 | FromDiscord | <BigPaperHand> In reply to @guzba "i dont mind having": :pepejam: That would be awesome. I'm a Nim entusiast, learning by doing, however I feel there is lack of examples related to web. I really want to adopt Mummy and glue other libs, but don't know how. |
22:22:49 | FromDiscord | <guzba> yeah i think the best thing is more examples, so much can be learned and then extended by just seeing a path / way of doing things |
22:23:36 | FromDiscord | <guzba> ive made a few and others have made some stuff, eg https://github.com/ajusa/rowdy im aware of |
22:25:32 | FromDiscord | <guzba> a specific example i will make next is showing how to take a basic mummy handler (`proc(request: Request`) and add more to it such as `proc(request: Request, context: Context)` if you want to add auth information or whatever to a set of handlers↵this lets you build what some think of as middlewhere by composing handlers |
22:25:43 | FromDiscord | <guzba> example will make this more clear |
22:26:10 | FromDiscord | <guzba> (edit) "middlewhere" => "middlewear" |
22:26:17 | FromDiscord | <guzba> (edit) "middlewear" => "middleware" |
22:27:59 | FromDiscord | <guzba> another small high level suggestion for a site would be embracing "serve static html + js" then have the js talk to a json-only api. dealing with html and cookies and caching and that stuff is an unnecessary mess. there are cases where a dynamic html site can make sense but i just alway see them go down instantly with a tiny bit of increased traffic so its sort of a trap to me |
22:28:21 | FromDiscord | <guzba> (edit) "another small high level suggestion for a site would be embracing "serve static html + js" then have the js talk to a json-only api. dealing with html and cookies and caching and that stuff is an unnecessary mess. ... there" added "just shove it in a bucket and only think about json api." |
22:30:01 | FromDiscord | <BigPaperHand> In reply to @guzba "another small high level": Nice, I plan to use HTMX (htmx.org), which is a light way to add dynamic without the overhead of having a huge js file (like next, vue, etc) |
22:34:42 | FromDiscord | <guzba> In reply to @voidwalker "Hey <@318284269908918273> I noticed": hmm i kind of think the path forward here depends on what youve worked with in the past↵this may be a reasonable forum post if you can formulate it into a "here are some of the ways i am considering what input do ppl have?"↵i also monitor the forum so id see↵may get good answers, may be treading a new path, either way nothing lost and it keeps building indexable nim know |
22:35:20 | FromDiscord | <guzba> In reply to @BigPaperHand "Nice, I plan to": i have not used that personally but i am aware of it and think it is a clever project |
22:35:32 | FromDiscord | <guzba> should fit well with the general mindset ive found successful |
22:35:46 | FromDiscord | <voidwalker> Indeed, I have prepared a template to pot on the forum, I am waiting to get a bit deeper in knowledge so I can formulate more sensible questions |
22:35:49 | FromDiscord | <guzba> (edit) "should fit well with the general mindset ive found successful ... " added "(static site + js + json api)" |
22:35:58 | FromDiscord | <voidwalker> (edit) "pot" => "post" |
22:37:10 | FromDiscord | <voidwalker> You can probably write a simple torrent client in 500-600 lines. But engineering it to actually be great.. many thousands. |
22:41:28 | FromDiscord | <guzba> sent a long message, see http://ix.io/4uUD |
22:47:03 | FromDiscord | <Recruit_main707> i dont know if this has gone unnoticed but we got flatbuffers support↵https://github.com/google/flatbuffers/pull/7534 |
23:06:59 | * | TakinOver quit (Ping timeout: 250 seconds) |
23:27:16 | * | lucasta joined #nim |
23:32:08 | * | lumo_e quit (Ping timeout: 240 seconds) |
23:45:27 | * | lumo_e joined #nim |