00:12:42 | * | madprops joined #nim |
00:12:44 | FromDiscord | <slymilano> Hey gang, I have my Nim project as #1 on hackernews' "Show HN"! |
00:13:25 | FromDiscord | <Elegantbeef> Congrats! |
00:14:12 | madprops | seems I visited the torrentinim repo in mid 2020 huh |
00:14:31 | madprops | i was wondering because the link had the "visited" tone |
00:15:58 | FromDiscord | <slymilano> yeah been plugging away at it every so often over the last year |
01:04:23 | FromDiscord | <undersquire> what gui libraries do you guys recommend? (preferably pure nim gui libraries, I have only found NiGui so far) |
01:05:00 | * | auxym joined #nim |
01:06:10 | FromDiscord | <undersquire> (edit) "(preferably" => "(trying to find" |
01:22:51 | FromDiscord | <codic> wow that is cool |
01:25:08 | * | Mister_Magister quit (Quit: bye) |
01:25:20 | * | Mister_Magister joined #nim |
01:30:48 | FromDiscord | <Elegantbeef> Nimx, Fidget, are probably the most developed pure Nim GUI libraries |
01:35:31 | FromDiscord | <womble73> I am playing with wxnim at the moment but only because I wanted WebKit as well as other native GUI things. It has been a small battle. Depends on how pure you want, it wraps header files but you need to install wxwidgets and it doesn't play nice with all the latest. But none of the other lib's matched my needs. |
01:41:34 | federico3_ | I use gintro |
01:51:29 | * | auxym quit (Ping timeout: 248 seconds) |
01:59:52 | * | byanka_ quit (Ping timeout: 258 seconds) |
02:01:42 | * | flynn quit (Read error: Connection reset by peer) |
02:02:49 | * | flynn joined #nim |
02:05:30 | * | federico3_ is now known as federico3 |
02:30:57 | * | arkurious quit (Quit: Leaving) |
03:14:36 | * | rockcavera quit (Remote host closed the connection) |
03:26:41 | FromDiscord | <undersquire> where can I learn macros in Nim more, the official docs don't really explain much |
03:26:51 | FromDiscord | <undersquire> (edit) "where can I learn ... macrosNim," added "more about" | "Nim more," => "Nim," |
03:28:48 | FromDiscord | <Elegantbeef> I have this https://dev.to/beef331/demystification-of-macros-in-nim-13n8 but there are many macro explanations on the internet |
03:29:47 | FromDiscord | <Elegantbeef> https://peterme.net/metaprogramming-and-read-and-maintainability-in-nim.html |
03:30:03 | FromDiscord | <codic> wait that expandIf macro in your post might be useul |
03:30:04 | FromDiscord | <codic> (edit) "useul" => "useful" |
03:30:53 | FromDiscord | <Elegantbeef> Well it was inspired by someone asking how to make it |
03:31:01 | FromDiscord | <Elegantbeef> So someone atleast needed it |
03:31:06 | FromDiscord | <Elegantbeef> Rather wanted it |
03:32:31 | FromDiscord | <undersquire> thanks i will read those |
03:32:44 | FromDiscord | <Elegantbeef> If you have any more questions i can probably answer them |
03:47:44 | FromDiscord | <lamersc.com 🐧> I've never used SDL2 before, but am curious if the nim library is up to date? |
03:47:52 | FromDiscord | <lamersc.com 🐧> I'm planning on taking a shot at it |
03:47:59 | FromDiscord | <lamersc.com 🐧> and maybe making a simple platformer |
03:49:03 | FromDiscord | <Elegantbeef> Yea it's up to date afaik |
03:49:25 | FromDiscord | <Elegantbeef> Using it presently atleast |
04:06:01 | * | supakeen quit (Quit: WeeChat 3.2) |
04:06:30 | * | supakeen joined #nim |
04:21:17 | FromDiscord | <undersquire> In reply to @lamersc.com 🐧 "I've never used SDL2": use sdl2_nim library, not sdl2 |
04:21:34 | FromDiscord | <undersquire> the official nim sdl2 bindings are not as up to date as sdl2_nim |
04:57:01 | FromDiscord | <lamersc.com 🐧> In reply to @undersquire "use sdl2_nim library, not": Thank you, I'll check it out |
06:51:41 | * | Vladar joined #nim |
06:53:13 | FromDiscord | <enthus1ast> i'm curious, is it still true that sdl2 cannot use shaders? |
06:53:14 | FromDiscord | <enthus1ast> (withouth additional opengl context i mean) |
06:53:14 | FromDiscord | <Elegantbeef> Yes it's |
06:53:15 | FromDiscord | <enthus1ast> for ours games (in c++) we have used SFML, if i recall correctly it only supported gles2 but that was good enough, and compatible for old devices. |
06:53:15 | FromDiscord | <Elegantbeef> Yea i mean opengl + sdl2 is relatively simple |
06:57:39 | * | max22- joined #nim |
07:09:40 | * | PMunch joined #nim |
07:38:58 | * | Pyautogui joined #nim |
07:43:26 | Pyautogui | Newbie question again, sorry: https://play.nim-lang.org/#ix=3vwI. It is giving a odd error, which does not really make sense to me. |
07:46:07 | FromDiscord | <Elegantbeef> You're using `VM` so accessing the type description |
07:46:49 | Pyautogui | Oh, sorry. Stupid of me. |
07:47:10 | PMunch | Damn it, beat me to it |
07:47:57 | PMunch | Fixing that you also use Code as the name of a field in the Chunk object, while in your code you refer to it as code |
07:48:08 | supakeen | (in multiple places) |
07:48:29 | PMunch | Nim is only case-insensitive for all letters but the first |
07:49:33 | Pyautogui | Sorry. Late at night for me. |
07:51:51 | PMunch | This compiles, but I've made some assumptions that might not be right for you: https://play.nim-lang.org/#ix=3vwJ |
07:52:10 | Pyautogui | Thanks. I have actually already fixed. |
07:52:50 | FromDiscord | <Elegantbeef> What's the point of saying `uint16(1)` on that enum |
07:53:14 | FromDiscord | <Elegantbeef> enums are best sized, and use whatever you tell them for all the numbers so you can just do `Op_ret = 1` |
07:53:36 | PMunch | Yeah I don't think that would actually do much, if anything at all |
07:54:04 | FromDiscord | <Elegantbeef> It doesnt do anything afaik |
07:54:33 | FromDiscord | <Elegantbeef> yea the `ord` is a int |
07:54:34 | Pyautogui | I was trying to follow crafting interpreters. I am not very knowledgable about Nim's enums. Thank you, I will fix it. |
07:55:53 | PMunch | If for some reason you really need it to be two bytes large for some reason there is a way to force it, but not sure if you can force the data-type to be uint at the same time |
07:56:00 | PMunch | You probably don't need that though |
07:56:22 | Pyautogui | No, thank you for the suggestion though. |
07:56:27 | FromDiscord | <Elegantbeef> There probably isnt much reason to give a first value to be fair |
07:57:26 | FromDiscord | <Elegantbeef> Since it's doubtful the value is really important |
07:57:50 | Pyautogui | No, it is not. I have changed the code not to use the value. |
07:58:02 | Pyautogui | (and not define it) |
07:58:37 | FromDiscord | <Elegantbeef> is that constants supposed to be the size of TokenType? |
07:58:59 | FromDiscord | <Elegantbeef> If so you can do `array[TokenType, uin16]` |
07:59:12 | FromDiscord | <Elegantbeef> Then index it with the enum value |
07:59:24 | PMunch | Oh, good idea |
07:59:46 | FromDiscord | <Elegantbeef> Thanks i'm allowed one of them every 2.5months |
07:59:49 | FromDiscord | <Elegantbeef> So see you again then |
07:59:58 | Pyautogui | No need. Thanks for the suggestion |
08:02:37 | PMunch | What do you mean "no need"? If the constants are intended to be indexed by TokenType then setting it as an array with that as the index is a neat little trick |
08:03:23 | Pyautogui | I meant that that was not the purpose of TokenType |
08:03:43 | Pyautogui | Sorry for the ambigous phrasing |
08:04:21 | PMunch | Ah right, with the snippet you sent is was hard to tell as that's the only time you use it |
08:13:13 | FromDiscord | <tbrekalo> Hello, new to nim; I am coming from a cpp background. Interested is there something something like std::vector::reserve in nim sequence? |
08:14:10 | FromDiscord | <tbrekalo> (edit) "sequence?" => "sequence?↵↵Also, is there something with auto& like functionality?" |
08:14:12 | FromDiscord | <pointystick> newSeqOfCap, I think |
08:14:25 | FromDiscord | <tbrekalo> In reply to @pointystick "newSeqOfCap, I think": Thanks 👌 |
08:14:43 | FromDiscord | <enthus1ast> https://nim-lang.org/docs/system.html#newSeq%2Cseq%5BT%5D%2CNatural |
08:14:52 | * | Pyautogui quit (Quit: Connection closed) |
08:15:00 | FromDiscord | <Elegantbeef> There are a multitude of newSeq procs which may help you |
08:15:04 | FromDiscord | <Elegantbeef> no clue what auto& does |
08:15:27 | FromDiscord | <enthus1ast> there is an auto type in nim |
08:15:45 | FromDiscord | <enthus1ast> i think it should behave similar |
08:15:56 | FromDiscord | <Elegantbeef> It does |
08:16:04 | FromDiscord | <Elegantbeef> But the `auto&` is what a auto reference? |
08:17:14 | FromDiscord | <tbrekalo> In reply to @Elegantbeef "But the `auto&` is": Yes |
08:18:21 | FromDiscord | <tbrekalo> Takes a reference to an object.. Let's say I want to access a last element in a sequence repeatedly and instead of typing `s[^1]`, I would like to access it via reference.. something like `auto& curr_elem = s[^1]`. That way I can modify the `s[^1]` through `curr_elem` |
08:19:09 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3vwR |
08:19:42 | FromDiscord | <tbrekalo> In reply to @Elegantbeef "Ah there is `byaddr`": Thanks 👍🏿 |
08:19:45 | PMunch | Assuming that the type in the sequence is not already a reference type of course |
08:20:07 | PMunch | Then you will just get the reference and can modify it as a reference directly |
08:20:28 | FromDiscord | <tbrekalo> Thanks guys 🙂 |
08:20:33 | FromDiscord | <Elegantbeef> No problem |
08:21:09 | PMunch | In this case you could of course also create a template |
08:21:28 | PMunch | If you just want to save yourself having to type [^1] which can be awkward on some layouts |
08:21:44 | PMunch | `template curr_elem = s[^1]` |
08:22:13 | FromDiscord | <Elegantbeef> Nope pmunch you left out the return type |
08:22:18 | FromDiscord | <Elegantbeef> That's an error! |
08:23:10 | FromDiscord | <Elegantbeef> `template currElem: auto = s[^1]` for this hypothetical collectio |
08:23:10 | FromDiscord | <Elegantbeef> `template currElem: auto = s[^1]` for this hypothetical collection |
08:23:30 | FromDiscord | <tbrekalo> What I am actually trying is to compress https://en.wikipedia.org/wiki/FASTA_format so that each DNA base is encoded as two bits and nim's bit operations are kinda.. Uhhh |
08:24:07 | FromDiscord | <Elegantbeef> Nim's bit ops are awesome \:P |
08:24:48 | PMunch | Oh shit, you're right Elegant |
08:24:57 | FromDiscord | <enthus1ast> https://nim-lang.org/docs/bitops.html |
08:25:54 | FromDiscord | <tbrekalo> In reply to @enthus1ast "https://nim-lang.org/docs/bitops.html": Yes, using that and I find it clunky 😦 |
08:26:21 | PMunch | Huh, how have I not seen the bitops module until now? |
08:26:29 | PMunch | I always do my bit operations by hand.. |
08:26:42 | FromDiscord | <Elegantbeef> peasant |
08:27:04 | PMunch | It's not much, but it's honest work :P |
08:27:05 | * | Pyautogui joined #nim |
08:27:06 | FromDiscord | <Elegantbeef> Why do you even need bit ops? |
08:27:15 | FromDiscord | <tbrekalo> In reply to @Elegantbeef "Why do you even": Asking me? |
08:27:19 | FromDiscord | <Elegantbeef> Yea |
08:27:29 | FromDiscord | <tbrekalo> In reply to @Elegantbeef "Yea": give me a moment |
08:29:12 | FromDiscord | <tbrekalo> In reply to @Elegantbeef "Why do you even": To achieve this: https://github.com/rvaser/biosoup/blob/62b942c921c5a42f92020b283884a3f6afeb7e9d/include/biosoup/nucleic_acid.hpp#L61 |
08:29:56 | FromDiscord | <Elegantbeef> So each letter is turned into how many bits in your desired output? |
08:31:26 | FromDiscord | <tbrekalo> 2 bits |
08:31:40 | FromDiscord | <enthus1ast> @tbrekalo\: we also have a nim science channel by the way |
08:31:58 | FromDiscord | <tbrekalo> In reply to @enthus1ast "<@783283008567640125>\: we also have": Should I go there or this is the place? |
08:32:19 | FromDiscord | <enthus1ast> no just mentioning, in case you don't know \:) |
08:36:42 | FromDiscord | <proud linux user> why balck imjoi |
08:37:57 | PMunch | Probably more people here, so for general Nim help this would be the place to be |
08:38:09 | PMunch | @proud linux user, why not? |
08:39:02 | FromDiscord | <Rika> What did he say? |
08:40:06 | FromDiscord | <enthus1ast> @tbrekalo\: maybe something like this could help\: https://github.com/sealmove/bitstreams |
08:40:08 | nrds | <prestigebot99> itHub: 7"Interface for reading per bits" |
08:40:23 | FromDiscord | <enthus1ast> then you can just write out the bits for each basepair |
08:40:51 | FromDiscord | <Elegantbeef> I'm pretty dumb cause there is way more than 4 choices \:D |
08:41:38 | FromDiscord | <tbrekalo> Thanks; will look into that. I am also struggling with generics a bit.. `decltype(vec_obj)::value_type` Looking for that sort of functionality in nim |
08:42:27 | FromDiscord | <Rika> For a sequence or an array |
08:42:43 | FromDiscord | <tbrekalo> why not both? 😆 ↵sequence in this case |
08:43:13 | FromDiscord | <Elegantbeef> Well i had fun compressing it without using any manual bitops got \~37 if my logic isnt wrong https://play.nim-lang.org/#ix=3vx5 |
08:43:46 | FromDiscord | <Rika> theSeq.T should work? |
08:44:04 | FromDiscord | <Elegantbeef> `theSeq.type.T` maybe |
08:44:19 | FromDiscord | <Rika> Better to use typeof |
08:44:30 | FromDiscord | <Elegantbeef> You're not my real mom! |
08:44:42 | FromDiscord | <tbrekalo> Thanks guys; I have a lot of to digest now |
08:44:44 | FromDiscord | <Rika> Call me mommy |
08:44:46 | PMunch | So basically you want to compress stuff like GATTACA to a sequence of bits, two per letter? |
08:45:02 | PMunch | Because there are only four options two bits can hold them just fine |
08:45:13 | FromDiscord | <tbrekalo> Yes |
08:45:24 | PMunch | Interesting |
08:45:25 | FromDiscord | <Elegantbeef> And a slight modification of my code will give that |
08:46:14 | FromDiscord | <tbrekalo> Thanks; I'll probably request a code review later today or tomorrow |
08:46:35 | FromDiscord | <Elegantbeef> I'm actually pretty surprised that my compression worked so simply |
08:47:00 | FromDiscord | <Elegantbeef> I expected it to have to do some coercing the savings to appear |
08:47:26 | FromDiscord | <Rika> You’re missing a “for” |
08:47:34 | FromDiscord | <enthus1ast> i think the reason it is to not compress fasta is to search it faster (but what do i know, not a biochemist ;) ) |
08:48:18 | FromDiscord | <tbrekalo> Actually to compress it because datasets loaded into memory take up few tens of GB |
08:48:24 | FromDiscord | <Elegantbeef> Oh nvm it didnt compress it |
08:48:34 | FromDiscord | <Elegantbeef> This data has symbols mine doesny |
08:48:40 | FromDiscord | <Elegantbeef> Whew i'm not crazy |
08:54:51 | * | Pyautogui quit (Quit: Connection closed) |
09:05:08 | PMunch | @tbrekalo, did this for fun: http://ix.io/3vxg/nim |
09:05:32 | FromDiscord | <tbrekalo> thanks! |
09:05:57 | FromDiscord | <Elegantbeef> Wow look at this dude actually compress stuff |
09:06:02 | FromDiscord | <Elegantbeef> Big brain over here |
09:06:19 | PMunch | You could obviously replace that loop over the string with something like a streaming read from a file |
09:09:23 | FromDiscord | <tbrekalo> Umm, my 2nd day of nim 😆 still struggling with some rng stuff. I'll send you min impl by noon |
09:09:56 | FromDiscord | <Elegantbeef> Ah noon so you've given yourself 9 hours |
09:10:01 | PMunch | RNG in DNA, sounds like a recipe for cancer :P |
09:10:19 | FromDiscord | <Elegantbeef> Well within an acceptable amount of course pmunch |
09:15:37 | FromDiscord | <dimspith> How can i watch a file for changes asynchronously in nim? i'd like to have a variable storing the last modified time of a file and update it's contents dynamically. |
09:15:50 | FromDiscord | <Elegantbeef> also pmunch using `genome.len - 1` instead of `genomone.high`... 😀 |
09:19:11 | PMunch | http://ix.io/3vxj/nim |
09:19:45 | PMunch | Just a bit more fun, now it has it's own type, and an accessor so you can easily get out the different nucleobases from the binary data or iterato over it :) |
09:19:52 | PMunch | @tbrekalo ^ |
09:19:59 | FromDiscord | <Elegantbeef> still using `.len - 1` |
09:20:13 | PMunch | Yes, because logically that's what I'm doing |
09:20:33 | FromDiscord | <Elegantbeef> but that's what `genome.high` is? |
09:20:40 | PMunch | I'm not trying to get the highest index, I'm subtracting one from the length so I get the proper rounding effect |
09:20:43 | FromDiscord | <Rika> Yes but that isn’t the intention |
09:20:48 | PMunch | I like to differentiate the two cases :P |
09:20:59 | PMunch | The result would be exactly the same |
09:21:12 | FromDiscord | <Elegantbeef> Of course but i'm just joking around |
09:21:31 | PMunch | It's an interesting question though |
09:22:25 | PMunch | I mean they are functionally equivalent, but I feel this one is more "correct" with the intent I have there as opposed to using .high. Makes it a bit more clear what I'm trying to do |
09:22:52 | FromDiscord | <Elegantbeef> \Can i atleast joke about using `+= 1` instead of `inc`?! |
09:24:20 | PMunch | Haha, you can joke about anything :) It just reminded me of an interesting stylistic discussion |
09:25:41 | PMunch | Since most languages don't have these systems it's one I haven't seen much before. But with Nim and these handy operations for these common tasks I think it's an interesting discussion |
09:25:47 | PMunch | Same with `reset` |
09:26:16 | PMunch | I like using reset instead of ` = 0` or whatever the default value is |
09:26:56 | FromDiscord | <Elegantbeef> I didnt even know reset existed |
09:27:05 | PMunch | Because reset explains what I'm actually trying to do. I don't care what the value actually is, I just want to reset it back to what it would be if I hadn't assigned anything to it |
09:27:18 | PMunch | It's pretty neat, can be helpful in generic code as well |
09:28:00 | FromDiscord | <Elegantbeef> Yea i mean it's just short hand of `a = default(typeof(a))` |
10:16:27 | FromDiscord | <KnorrFG> if i have an enum in c, and i wanna cycle through it, id do something like this `state = (state + 1) % 3` (if the enum has 3 values) what is the nim-equivalent for this? |
10:23:10 | * | Vladar quit (Quit: Leaving) |
10:27:06 | * | Vladar joined #nim |
10:31:47 | FromDiscord | <hotdog> In reply to @dimspith "How can i watch": @dimspith there’s a few bindings for libfswatch you could use - https://nimble.directory/search?query=fswatch+ |
10:36:16 | PMunch | KnorrFG, you can use inc to increase the value of an enum |
10:36:20 | PMunch | But that doesn't wrap |
10:42:23 | FromDiscord | <KnorrFG> Yep, that's what I found out too. I'll just go with an extra if I guess |
10:43:43 | PMunch | Could wrap it as a `next` proc or template |
10:44:37 | FromDiscord | <System64 ~ Flandre Scarlet> Hello, does the Nim bindings of SDL2 allow to do that kind of things? https://media.discordapp.net/attachments/371759389889003532/874604134173638696/unknown.png |
10:45:13 | PMunch | @System64, sure why wouldn't they? |
10:47:03 | FromDiscord | <System64 ~ Flandre Scarlet> 'cause C doesn't allow it |
10:48:14 | FromDiscord | <jtiai> In reply to @System64 "'cause C doesn't allow": I recommend to use Vladr4 sdl2_nim. It's better than "official" bindings. |
10:48:22 | FromDiscord | <dom96> In reply to @dimspith "How can i watch": if you want a fun project you can port https://github.com/nim-lang/graveyard/blob/master/fsmonitor/src/fsmonitor.nim to async/await |
10:48:46 | FromDiscord | <haxscramper> In reply to @System64 "'cause C doesn't allow": C does not have lambdas, nim does |
10:49:07 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @jtiai "I recommend to use": What does it add? |
10:49:09 | FromDiscord | <haxscramper> The part you outlined assigns lambda to a field in constructor |
10:49:38 | FromDiscord | <haxscramper> So naturally C would not allow for that, but it is not really related to SDL I think |
10:49:52 | FromDiscord | <Rika> Couldn’t you technically do that by passing the address of a function |
10:49:55 | FromDiscord | <System64 ~ Flandre Scarlet> ah alright |
10:50:53 | FromDiscord | <jtiai> In reply to @System64 "What does it add?": Bindings are done more nim-style than plain C-bindings to nim which official ones are. |
10:51:24 | FromDiscord | <System64 ~ Flandre Scarlet> ah alright, let me check that |
10:52:10 | FromDiscord | <jtiai> And technically, sdl2_nim was created before official one. 😄 |
10:53:03 | FromDiscord | <jtiai> It's mainly how sdl2_nim handles types etc. They're better. And good set of examples and docs. But they're not that different. Both enables the same stuff. |
10:55:17 | FromDiscord | <tbrekalo> In reply to @PMunch "Just a bit more": http://ix.io/3vxC/nim |
10:56:23 | PMunch | You don't need that {size} pragma, enums are automatically the smallest possible size |
10:56:57 | FromDiscord | <tbrekalo> In reply to @PMunch "You don't need that": thanks |
10:57:42 | FromDiscord | <tbrekalo> How does enum encoding work under the hub? How can I benchmark is lookup table faster than default enum decoding in nim? |
10:58:14 | PMunch | Uhm, that `pos shr 5` is not going to work as soon as you go over 5 bits in size.. |
10:58:31 | PMunch | There are a lot of odd choices in this code.. |
10:58:44 | PMunch | 32 + 0.999 for example |
10:58:56 | PMunch | And what is the baseEncoder for? |
10:59:01 | FromDiscord | <tbrekalo> In reply to @PMunch "Uhm, that `pos shr": wym? |
10:59:26 | FromDiscord | <tbrekalo> In reply to @PMunch "And what is the": It's a lookup table for encoding chars to base values used for bit mapping |
11:00:18 | PMunch | Oh wait, that shr thing might actually work |
11:00:30 | PMunch | But why? |
11:01:41 | PMunch | Eh, I guess it might be slightly faster depending on the CPU, hard to tell without a benchmark |
11:02:08 | PMunch | Speaking of how to benchmark, just generate a bunch of valid data (or run on a data-set) and test both approaches against each other |
11:03:17 | * | neurocyte joined #nim |
11:04:05 | PMunch | By the way here you don't need to declare the type: var buffer: seq[Base] = newSeqOfCap[Base](fasta.size) |
11:04:15 | FromDiscord | <tbrekalo> Because one block encodes 32 bases which is 2^5. You can write each `pos` as `x|y` in bits. (here I use `|` as concatenation operator with bit strings) `y` is 5 bits long because it represents number in range (0-31) which are always discarded in whole division with 32 |
11:04:32 | PMunch | Same for your strings at the end |
11:05:09 | PMunch | Yeah I realised that it would work as I tried to type out why it wouldn't :P |
11:06:02 | FromDiscord | <tbrekalo> In reply to @PMunch "By the way here": Thanks 🙂 I have a bad habit of redundant typedefs xD |
11:07:28 | PMunch | And the lookup table might be faster than the parseEnum route, but I doubt it'd be much faster than a case statement |
11:08:28 | * | auxym joined #nim |
11:10:14 | FromDiscord | <tbrekalo> got one quesiton regarding code |
11:11:06 | FromDiscord | <tbrekalo> `result.data = newSeq[uint64]((data.len() / 32 + 0.999).toInt()` Can I deduce the type argument for `newSeq` from `result.data`. I asked that earlier but failed to translate answers to code |
11:11:34 | PMunch | What do you mean? |
11:11:52 | PMunch | Instead of having to type newSeq[uint64] use the type from result.data? |
11:13:05 | FromDiscord | <tbrekalo> I would like to be able to write something like: `result.data = newSeq[typeof(result.data[0])] ....` |
11:13:06 | FromDiscord | <Rika> Put “typeof(result.data)” instead of the uint part |
11:13:08 | FromDiscord | <Rika> ? |
11:13:23 | * | Pyautogui joined #nim |
11:13:23 | FromDiscord | <Rika> Oh that’s what you mean |
11:13:34 | FromDiscord | <Rika> (edit) "“typeof(result.data)”" => "“typeof(result.data).T”" |
11:13:38 | FromDiscord | <Rika> I forgot the T part |
11:14:21 | FromDiscord | <proud linux user> bruh |
11:14:31 | FromDiscord | <tbrekalo> In reply to @Rika "Put “typeof(result.data).T” instead of": but I get `Error: undeclared field: 'T' ` |
11:14:41 | FromDiscord | <Rika> Outside of the typeof? |
11:14:53 | FromDiscord | <tbrekalo> yes |
11:15:03 | FromDiscord | <tbrekalo> brb few mins |
11:15:52 | FromDiscord | <proud linux user> min |
11:16:16 | * | Pyautogui quit (Client Quit) |
11:16:33 | FromDiscord | <Rika> Then import typetraits and typeof(result.data).genericParams().get(0) |
11:17:02 | PMunch | Rika, I have never seen that .T thing, where did you get that from? |
11:17:25 | FromDiscord | <Rika> I was pretty sure it was valid for generics |
11:17:42 | FromDiscord | <Rika> I do not remember |
11:18:23 | * | arkurious joined #nim |
11:18:37 | FromDiscord | <Rika> Actually I guess elementType from typetraits also works |
11:20:14 | * | max22- quit (Ping timeout: 256 seconds) |
11:20:40 | * | rockcavera joined #nim |
11:20:40 | * | rockcavera quit (Changing host) |
11:20:40 | * | rockcavera joined #nim |
11:23:29 | FromDiscord | <tbrekalo> Thanks @Rika !↵It works 🙂 |
11:25:11 | FromDiscord | <Rika> The second one I sent (elementType) should be cleaner |
11:26:42 | FromDiscord | <System64 ~ Flandre Scarlet> does someone know how can I make a lambda there please? https://media.discordapp.net/attachments/371759389889003532/874614732525559818/unknown.png |
11:27:16 | FromDiscord | <Rika> Making lambdas should be in the manual |
11:29:05 | FromDiscord | <dimspith> In reply to @dom96 "if you want a": Sounds like a good chance to learn more about async/await and contribute. Thanks! |
11:38:22 | FromDiscord | <System64 ~ Flandre Scarlet> nice, first try https://media.discordapp.net/attachments/371759389889003532/874617665346502706/unknown.png |
11:40:42 | FromDiscord | <Rika> Cursed indentation ngl |
11:43:23 | FromDiscord | <System64 ~ Flandre Scarlet> why is it cursed? |
11:45:52 | FromDiscord | <Rika> I would put the proc signature on the next line |
11:46:03 | FromDiscord | <Rika> That way I don’t add 1515724852 levels of indentation for the proc body |
11:46:16 | PMunch | Ditto |
11:46:48 | PMunch | And what's up with 4 spaces indent? |
11:47:54 | supakeen | it's not following the fibonacci rule :( |
11:48:12 | * | laintree joined #nim |
11:48:30 | PMunch | Fibonacci indentation? |
11:48:46 | * | mahlon_ joined #nim |
11:49:01 | FromDiscord | <proud linux user> is that system64 |
11:49:03 | FromDiscord | <proud linux user> ohgod |
11:49:03 | * | auxym quit (Ping timeout: 258 seconds) |
11:51:53 | * | xet7 quit (*.net *.split) |
11:51:53 | * | lucerne quit (*.net *.split) |
11:51:53 | * | jkl quit (*.net *.split) |
11:51:53 | * | happycorsair[m] quit (*.net *.split) |
11:51:53 | * | lain quit (*.net *.split) |
11:51:54 | * | mahlon quit (*.net *.split) |
11:51:54 | * | mjsir911 quit (*.net *.split) |
11:51:54 | * | icebattle quit (*.net *.split) |
11:51:54 | * | blackbeard420 quit (*.net *.split) |
11:51:54 | * | Amun-Ra quit (*.net *.split) |
11:51:54 | * | nixfreak_nim[m] quit (*.net *.split) |
11:51:54 | * | Helios quit (*.net *.split) |
11:51:54 | * | Ekho quit (*.net *.split) |
11:51:54 | * | greyrat quit (*.net *.split) |
11:51:54 | * | robertmeta quit (*.net *.split) |
11:51:55 | * | oz quit (*.net *.split) |
11:51:55 | * | asd quit (*.net *.split) |
11:51:55 | * | ecs quit (*.net *.split) |
11:53:12 | * | xet7 joined #nim |
11:53:12 | * | lucerne joined #nim |
11:53:12 | * | jkl joined #nim |
11:57:09 | * | ecs joined #nim |
11:57:09 | * | asd joined #nim |
11:57:48 | * | happycorsair[m] joined #nim |
11:57:52 | * | nixfreak_nim[m] joined #nim |
11:57:53 | * | Helios joined #nim |
11:57:53 | * | Ekho joined #nim |
11:57:53 | * | greyrat joined #nim |
11:57:53 | * | robertmeta joined #nim |
11:57:53 | * | oz joined #nim |
11:58:00 | * | mjsir911 joined #nim |
11:58:00 | * | icebattle joined #nim |
11:58:00 | * | blackbeard420 joined #nim |
11:58:00 | * | Amun-Ra joined #nim |
12:00:44 | * | nixfreak_nim[m] quit (Ping timeout: 252 seconds) |
12:00:44 | * | Helios quit (Ping timeout: 252 seconds) |
12:00:54 | supakeen | PMunch: 1 for the first indentation, 1 for the second, 2, 3, 5, etc. |
12:00:59 | supakeen | Good way to have less levels ;) |
12:01:02 | * | happycorsair[m] quit (Ping timeout: 256 seconds) |
12:01:11 | PMunch | Haha, sounds, interesting.. :P |
12:06:01 | * | supakeen quit (Quit: WeeChat 3.2) |
12:06:54 | * | supakeen joined #nim |
12:23:59 | FromDiscord | <bolino> Hi!↵I have a sequence of tables, each of those tables represent a row to be written in a MySQL database with `db_mysql` module.↵Do you know how I can build the query with the values from those tables as parameters of a prepared SQL statement like `db.exec(sql("INSERT INTO table (fieldA, fieldB, fieldC) VALUES (?, ?, ?);"), "row1valueA", "row1valueB", "row1valueC")`? |
12:25:18 | FromDiscord | <bolino> (edit) ""row1valueC")`?" => ""row1valueC", "row2valueA", "row2valueB", "row2valueC")`, (but with many an undefined number of rows/tables of course)?" |
12:35:18 | * | laintree is now known as lain |
12:46:41 | * | max22- joined #nim |
13:04:52 | * | rockcavera quit (Remote host closed the connection) |
13:05:15 | * | rockcavera joined #nim |
13:05:15 | * | rockcavera quit (Changing host) |
13:05:15 | * | rockcavera joined #nim |
13:20:29 | * | happycorsair[m] joined #nim |
13:24:04 | * | xet7 quit (Remote host closed the connection) |
13:31:23 | * | nixfreak_nim[m] joined #nim |
13:33:21 | * | Helios joined #nim |
13:37:43 | * | PMunch quit (Quit: Leaving) |
13:44:58 | * | Vladar quit (Quit: Leaving) |
13:51:24 | * | rockcavera quit (Remote host closed the connection) |
13:59:21 | FromDiscord | <planetis> @bracketmaster\: try this https://github.com/planetis-m/cowstrings |
13:59:24 | nrds | <prestigebot99> itHub: 7"Copy-On-Write string implementation according to nim-lang/RFCs#221" |
13:59:34 | * | rockcavera joined #nim |
14:03:08 | FromDiscord | <Rika> moo |
14:08:52 | * | neurocyte left #nim (The Lounge - https://thelounge.chat) |
14:12:42 | FromDiscord | <proud linux user> did you moo todaY? |
14:14:10 | FromDiscord | <enthus1ast> whom's bot is @proud linux user btw? \:) |
14:14:35 | FromDiscord | <proud linux user> its me |
14:14:45 | FromDiscord | <proud linux user> i am a disgorg user |
14:30:27 | FromDiscord | <TurtleP> is there a way to statically link on macOS? I keep getting an error about `ld: -lcrt0.o library not found` on macOS 10.15. |
14:47:35 | FromDiscord | <proud linux user> ohyes. i have ad this mulitple times |
14:47:41 | FromDiscord | <proud linux user> but i forgor sorry |
15:27:50 | * | mahlon_ is now known as mahlon |
15:54:39 | FromDiscord | <leorize> `--passL:'-Wl,-Bstatic -llibs -lto_be -llinked_statically -Wl,-Bdynamic'`↵(@TurtleP) |
15:55:01 | FromDiscord | <leorize> on mac you can't statically link the libc for the most part (nor should you) |
16:02:01 | FromDiscord | <TurtleP> Ah I mainly wanted to because I do it for Windows and Linux |
16:02:15 | * | auxym joined #nim |
16:04:00 | * | stkrdknmibalz quit (Ping timeout: 268 seconds) |
16:06:57 | * | auxym quit (Ping timeout: 248 seconds) |
16:13:32 | FromDiscord | <Jakraes> Is there a way to make certain procs from a file unusable when imported |
16:13:50 | FromDiscord | <Rika> dont export it |
16:14:03 | FromDiscord | <Jakraes> Gotcha, thank you! |
16:14:07 | FromDiscord | <Rika> can you be more specific |
16:15:12 | FromDiscord | <Jakraes> I want to make a library, so far only for myself and there are certain functions that are not supposed to be imported, they're only used inside the library |
16:15:28 | FromDiscord | <Rika> yeah then dont export it |
16:15:43 | FromDiscord | <Rika> aka no after the name of the function (procedure) |
16:16:04 | FromDiscord | <Jakraes> Gotcha, thank you for the help! |
16:27:22 | * | cyraxjoe quit (Ping timeout: 240 seconds) |
16:39:24 | * | ozzz joined #nim |
16:43:00 | * | auxym joined #nim |
17:06:08 | FromDiscord | <dankrad> if you create a nimble package you can place those also in "private" folder inside the src/projectname/ folder, I guess. |
17:08:25 | * | fputs joined #nim |
17:11:26 | * | auxym quit (Ping timeout: 258 seconds) |
17:16:35 | * | rockcavera quit (Read error: Connection reset by peer) |
17:17:26 | * | rockcavera joined #nim |
17:17:26 | * | rockcavera quit (Changing host) |
17:17:26 | * | rockcavera joined #nim |
17:27:35 | FromDiscord | <gerwy> guys guys guys |
17:27:44 | FromDiscord | <gerwy> NimScript is interpreted right? |
17:27:54 | * | notchris quit (Ping timeout: 240 seconds) |
17:28:38 | FromDiscord | <haxscramper> yes |
17:28:47 | FromDiscord | <haxscramper> well, compiled to register VM which then executes it |
17:29:28 | FromDiscord | <gerwy> how can i get the size of it's interpreter? i do a little comparison between scripting langs |
17:30:10 | FromDiscord | <haxscramper> https://github.com/nim-lang/Nim/blob/devel/compiler/vm.nim |
17:30:28 | FromDiscord | <haxscramper> for vm |
17:30:30 | FromDiscord | <haxscramper> https://github.com/nim-lang/Nim/blob/devel/compiler/vmgen.nim for codegen |
17:30:38 | FromDiscord | <haxscramper> \~4k |
17:31:07 | FromDiscord | <haxscramper> But if you compare other scripting langs you get into tricky situation, since you also need to include parser/lexer/typecheck etc. ... which is basically most of the compiler |
17:31:26 | FromDiscord | <gerwy> 4k lines of code, i mean more like a binary |
17:31:52 | FromDiscord | <haxscramper> wait a second, I have a test script, so I can tell you approximate size |
17:32:00 | FromDiscord | <gerwy> yeah i should include also libraries that are built in some of them like in Python or Lua but thats get hard, i can't find the size of any Ruby interpreter |
17:32:40 | FromDiscord | <gerwy> In reply to @haxscramper "wait a second, I": oooh, that would be cool if you would get the size of it, also if you would compress it with upx that would be cool too |
17:35:33 | * | notchris joined #nim |
17:36:26 | FromDiscord | <System64 ~ Flandre Scarlet> For callbacks, are callbacks faster with lambdas or predefined functions? https://media.discordapp.net/attachments/371759389889003532/874707778533470218/unknown.png |
17:36:48 | FromDiscord | <Rika> please benchmark |
17:37:00 | FromDiscord | <Rika> that isnt something that's obvious i assume and imagine |
17:37:36 | FromDiscord | <System64 ~ Flandre Scarlet> Humm how can I benchmark it? |
17:37:48 | FromDiscord | <haxscramper> https://github.com/treeform/benchy |
17:37:50 | nrds | <prestigebot99> itHub: 7"Benchmarking." |
17:38:55 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3vzD |
17:39:08 | FromDiscord | <haxscramper> `nim c -r -d:release test1.nim` gives `3.4M` |
17:40:05 | FromDiscord | <haxscramper> `nim c -r -d:release --stacktrace:off --opt:size test1.nim` is down to `2.5M` |
17:40:32 | FromDiscord | <gerwy> Hmm still quiet big to be honest |
17:40:35 | FromDiscord | <haxscramper> `strip` cuts out another `0.5M` |
17:40:52 | FromDiscord | <gerwy> And upx --lzma maybe? |
17:41:11 | * | clemens3 joined #nim |
17:41:29 | FromDiscord | <haxscramper> `528k` |
17:41:55 | FromDiscord | <gerwy> (edit) "upx --lzma" => "`upx --lzma`" |
17:42:53 | FromDiscord | <gerwy> Okay thats quiet nice, thank you <33 |
17:43:10 | FromDiscord | <gerwy> Now i need to say the same thing in Ruby server lol |
17:43:22 | FromDiscord | <haxscramper> You can try this yourself, `nimble install compiler` and check for different flags |
17:46:17 | FromDiscord | <gerwy> Okay, but its just rough comparison |
18:02:31 | ozzz | Hi all! what is second argument for truncate() from posix? |
18:02:39 | ozzz | can't find it in man |
18:02:40 | * | auxym joined #nim |
18:02:40 | FromDiscord | <Jakraes> I need some help, for some reason the program doesn't output "test", instead it outputs an error, even if it's inside a try except, what's going on? https://media.discordapp.net/attachments/371759389889003532/874714377746518036/Screenshot_5.png |
18:04:12 | nrds | <Prestige99> @ozzz should be length - where are you looking? |
18:05:24 | ozzz | nrds: thanks, for some reason I can't find anythin on nim-lang.org |
18:05:37 | ozzz | Prestige ^ |
18:05:56 | FromDiscord | <Rika> wrong index is a defect |
18:05:58 | FromDiscord | <Rika> cannot be caught |
18:06:48 | FromDiscord | <Rika> please test size; we do not follow "try, dont check" here |
18:08:33 | FromDiscord | <Rika> In reply to @Rika "cannot be caught": well afaik they are by default, `--panics:off` probably disables the behavior |
18:09:05 | FromDiscord | <Rika> ah, incorrect array indexes are never exceptions and are checked on compile time |
18:09:40 | FromDiscord | <Rika> change it to a seq and itll work (while --panics:off is set or is default) |
18:09:53 | FromDiscord | <undersquire> what about with sequences? |
18:10:00 | FromDiscord | <Rika> In reply to @Rika "change it to a": i just said |
18:10:00 | FromDiscord | <undersquire> are index checks at runtime then? |
18:10:05 | FromDiscord | <Rika> yes |
18:10:07 | FromDiscord | <undersquire> ah ok |
18:10:18 | FromDiscord | <undersquire> would that be handled via try except then? |
18:10:33 | FromDiscord | <Rika> i said as well "while panics:off is either set or still default" |
18:10:45 | FromDiscord | <Rika> otherwise they cannot be caught and will crash your program |
18:10:49 | FromDiscord | <undersquire> ah ok |
18:14:02 | FromDiscord | <dain> nim has a repl but it's called `secret` so i guess it's experimental |
18:14:16 | FromDiscord | <dain> is it unstable or something? |
18:14:33 | FromDiscord | <konsumlamm> yes |
18:15:02 | FromDiscord | <konsumlamm> it's called that because noone is supposed to use it for serious stuff |
18:18:43 | FromDiscord | <dain> oh :( |
18:37:08 | * | max22- quit (Ping timeout: 256 seconds) |
18:58:04 | * | notchris_ joined #nim |
18:58:31 | * | notchris quit (Ping timeout: 268 seconds) |
19:16:08 | * | auxym quit (Quit: Konversation terminated!) |
19:16:20 | * | auxym joined #nim |
19:18:57 | * | auxym quit (Read error: Connection reset by peer) |
19:46:14 | FromDiscord | <lamersc.com 🐧> I’m genuinely curious, are there plans for a native LLVM backend in the future? https://media.discordapp.net/attachments/371759389889003532/874740444997759047/image0.png |
19:46:25 | FromDiscord | <lamersc.com 🐧> I know there’s nlvm, but just noticed this in the docs |
19:51:47 | * | max22- joined #nim |
19:52:54 | FromDiscord | <konsumlamm> apart from nlvm, not that i know of |
19:59:00 | FromDiscord | <tsoj> Is there some kind of (unofficial) convention how to name library functions that shouldn't be used directly by the user, but need to be public? |
19:59:54 | FromDiscord | <haxscramper> `xxxImpl`, `xxxAux` |
20:00:18 | FromDiscord | <haxscramper> You can also move things to `private/` |
20:17:00 | FromDiscord | <tsoj> sent a code paste, see https://play.nim-lang.org/#ix=3vAn |
20:24:49 | ozzz | another question, is there any sleep() which may handle ms? |
20:26:05 | FromDiscord | <tsoj> doesn't `sleep()` from os use milliseconds? |
20:26:41 | ozzz | proc sleep(milsecs: int) |
20:26:48 | ozzz | correct, sorry |
21:22:30 | FromDiscord | <Jakraes> Is there an expression to transform any number into an int? Just like there's $ to transform anything into a string |
21:26:00 | FromDiscord | <Elegantbeef> If it's within the range of an int you can just do `int(yourNumber)` |
21:27:20 | FromDiscord | <Jakraes> Unfortunately that doesn't work |
21:28:03 | FromDiscord | <Jakraes> Even if I do int(3.0) it doesn't work |
21:29:34 | FromDiscord | <Elegantbeef> !eval echo int(3.0) |
21:29:35 | NimBot | 3 |
21:30:37 | FromDiscord | <undersquire> !eval echo "Hello" |
21:30:39 | NimBot | Hello |
21:30:41 | FromDiscord | <undersquire> 😭 |
21:30:44 | FromDiscord | <undersquire> oh |
21:31:05 | FromDiscord | <Jakraes> https://media.discordapp.net/attachments/371759389889003532/874766828650524712/Screenshot_8.png |
21:31:33 | FromDiscord | <Jakraes> It doesn't work like this for example |
21:31:35 | FromDiscord | <Elegantbeef> You're assigning int to test which is a float |
21:31:45 | FromDiscord | <Jakraes> Ooooh |
21:31:46 | FromDiscord | <Jakraes> So that's why |
21:31:49 | FromDiscord | <Jakraes> Thank you! |
21:31:50 | FromDiscord | <Elegantbeef> Nim isnt dynamically typed |
21:32:04 | FromDiscord | <Jakraes> Yeah I completely forgot about that |
21:32:08 | FromDiscord | <Jakraes> Thank you |
21:33:26 | FromDiscord | <Elegantbeef> Error messages are your friend |
21:39:18 | FromDiscord | <Jakraes> I was reading them but I wasn't getting there lmao, I was thinking "Yeah that's what I want to happen" but yeah, completely forgot nim wasn't dynamically typed |
22:02:26 | madprops | What's the proper way to add a public method to an object? |
22:02:29 | madprops | I'm doing: method getInt*(a:NapArg, fallback=0, exit_on_fail=true): int {.base.} = |
22:02:37 | madprops | but I get: Error: attempting to call undeclared routine: 'getInt' |
22:02:58 | madprops | NapArg is a ref object |
22:04:05 | FromDiscord | <Elegantbeef> that is the proper way, is the `NapArg` type exported? |
22:04:13 | madprops | type NapArg* = ref object |
22:04:20 | madprops | I import the file |
22:04:49 | madprops | should I import the type manually? |
22:04:55 | FromDiscord | <Elegantbeef> Nah |
22:06:18 | FromDiscord | <Elegantbeef> Also what's the point of the method if it's non inheritable type? |
22:07:01 | madprops | the aim is just to offer an obj.getIt() method |
22:07:03 | madprops | what's the proper way? |
22:07:08 | madprops | getInt* |
22:07:16 | FromDiscord | <Elegantbeef> if you dont need to override you just make a proc |
22:07:43 | FromDiscord | <Elegantbeef> So it becomes `proc getInt(a:NapArg, fallback=0, exit_on_fail=true): int` |
22:08:24 | FromDiscord | <Elegantbeef> But it's still weird the `getInt` wasnt accessible |
22:09:47 | FromDiscord | <Elegantbeef> Yea i can only reason you tried to call `getInt` on a non `NapArg` object |
22:10:07 | madprops | i'll check, thanks |
22:14:18 | madprops | so the issue is that to make it work in the integration file, I need to not just import "appname" but also the "types" file |
22:14:31 | madprops | since it's a library I don't want users to have to do more than just import appname |
22:14:49 | madprops | so I'll have to move the procs to the main file I guess |
22:15:13 | FromDiscord | <lamersc.com 🐧> Is there a Nim roadmap? |
22:15:16 | FromDiscord | <Elegantbeef> you can always export the types in the `appname` |
22:15:19 | FromDiscord | <lamersc.com 🐧> And if so, where can I find it? |
22:15:28 | FromDiscord | <Elegantbeef> Or the procedure in this case |
22:17:29 | madprops | how could I export it? |
22:17:53 | madprops | it's already exported from 'types', and imported in 'appname' file |
22:18:19 | FromDiscord | <Elegantbeef> `export NapArg` to selectively export the type or `export types` for the module |
22:19:07 | madprops | 'export types' works, ty |
23:13:30 | madprops | seems that updating a library dependency won't trigger a recompilation on next launch |
23:26:39 | * | max22- quit (Remote host closed the connection) |