00:01:09 | FromDiscord | <nsauzede> sent a code paste, see https://play.nim-lang.org/#ix=2VT4 |
00:01:40 | FromDiscord | <nsauzede> sent a code paste, see https://play.nim-lang.org/#ix=2VT5 |
00:01:51 | * | njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.) |
00:02:11 | * | njoseph joined #nim |
00:07:08 | FromDiscord | <konsumlamm> wdym by "ref of an item"? |
00:07:11 | FromDiscord | <ElegantBeef> you cannot turn a non ref into a ref |
00:07:17 | FromDiscord | <konsumlamm> `addr` returns a `ptr` |
00:07:25 | FromDiscord | <ElegantBeef> you have to `new T` to create a ref of a type |
00:07:31 | FromDiscord | <ElegantBeef> Show code is the best thing to do |
00:07:36 | FromDiscord | <konsumlamm> `ref` is a heap-allocated garabage collected reference, you can't get that out of nowhere |
00:07:55 | FromDiscord | <ElegantBeef> Especially from a stack allocated object |
00:08:10 | FromDiscord | <nsauzede> sent a code paste, see https://play.nim-lang.org/#ix=2VT7 |
00:08:21 | FromDiscord | <nsauzede> but maybe that's the proper type ? |
00:08:24 | FromDiscord | <konsumlamm> are you sure that you don't just want to make `Material` a `ref object`? |
00:08:33 | FromDiscord | <ElegantBeef> ^ probably the wisest thing to do |
00:08:34 | FromDiscord | <nsauzede> hmm |
00:09:05 | FromDiscord | <ElegantBeef> alternatively you make it `lent Material` and hope that works for you 😄 |
00:09:18 | FromDiscord | <ElegantBeef> Doesnt recall the non view type limitations of `lent` |
00:10:13 | FromDiscord | <nsauzede> (edit) "but maybe that's ... the" added "not" |
00:10:47 | FromDiscord | <konsumlamm> alternatively, you can use `new(mat_ptr)` to allocate the object and then manually instantiate it or if you have an existing `Material` object, dereference (`[]`) |
00:11:15 | FromDiscord | <nsauzede> sent a code paste, see https://play.nim-lang.org/#ix=2VTa |
00:11:42 | FromDiscord | <nsauzede> would thus hold a `ref`, which then would just need to be copied into rec.mat_ptr ? |
00:11:52 | FromDiscord | <ElegantBeef> Well you could make `Material = ref object` |
00:12:14 | FromDiscord | <ElegantBeef> then Hsphere would have a reference to it and so would hitrec |
00:13:38 | FromDiscord | <j-james> Is putting an `openArray` inside a `seq` like so https://play.nim-lang.org/#ix=2VT8 allowed? |
00:14:39 | FromDiscord | <nsauzede> Awesome, thanks a lot @konsumlamm @ElegantBeef that was that simple |
00:14:54 | FromDiscord | <ElegantBeef> Also watch for `nil` now |
00:19:04 | FromDiscord | <konsumlamm> In reply to @j-james "Is putting an `openArray`": i don't think so, `openArray` isn't really supposed to be stored anywhere (at least without view types?), it's used as paramater, so that you can pass an array or a seq or a string |
00:38:00 | * | vicfred joined #nim |
00:40:52 | * | vicfred quit (Client Quit) |
00:47:34 | * | vicfred joined #nim |
00:50:20 | * | rockcavera quit (Read error: Connection reset by peer) |
00:51:17 | * | rockcavera joined #nim |
00:59:53 | * | abm quit (Read error: Connection reset by peer) |
01:27:46 | FromGitter | <gogolxdong> Anyone know NFT, we are planning to build the first programming language NFT for Nim. |
01:30:30 | FromGitter | <gogolxdong> Nim chain , Nim token, Nim devs get Nim token as reward. |
02:38:14 | FromDiscord | <Gary M> neat |
02:51:02 | FromDiscord | <ajusa> Will incremental compilation speed up js builds as well? I didn't see anything about it in the github rfc |
02:56:09 | FromDiscord | <ElegantBeef> I imagine it should since it allows caching of Nim files as rod files |
02:56:22 | FromDiscord | <ElegantBeef> So many files can be cached and not have to reevaluate |
03:01:30 | FromDiscord | <ajusa> That would be really nice, as there is more of a delay with my nim builds than with my webpack builds |
03:11:01 | * | abhixec joined #nim |
03:11:05 | * | abhixec left #nim (#nim) |
03:29:48 | FromDiscord | <sealmove> is there a way to split a string to substrings of len `n` with stdlib? |
03:35:36 | * | spiderstew_ joined #nim |
03:35:42 | ForumUpdaterBot | New thread by Kobi: Cs2nim progresses., see https://forum.nim-lang.org/t/7785 |
03:38:03 | * | spiderstew quit (Ping timeout: 265 seconds) |
03:38:20 | FromDiscord | <ElegantBeef> It doesnt seem so |
03:39:46 | FromDiscord | <ElegantBeef> I am curious what you're doing with the data |
03:56:33 | FromDiscord | <sealmove> just trying to split a hex value to its bytes |
03:57:00 | FromDiscord | <sealmove> "123456" -> @[0x12'u8, 0x34, 0x56] |
03:57:19 | FromDiscord | <sealmove> (edit) ""123456"" => "`"123456"`" | "@[0x12'u8," => "`@[0x12'u8," | "0x56]" => "0x56]`" |
04:00:01 | FromDiscord | <ElegantBeef> Yea but i'm wondering if read only would work 😄 |
04:16:53 | FromDiscord | <ElegantBeef> @sealmove like for instance this is a nice method of non reallocating slicing into byte collections https://play.nim-lang.org/#ix=2VTO |
04:19:23 | FromDiscord | <sealmove> `toOpenArrayByte`? |
04:19:36 | FromDiscord | <ElegantBeef> It's a slice of a string that doesnt reallocate |
04:19:55 | FromDiscord | <sealmove> :o thanks for hacking this up |
04:20:11 | FromDiscord | <ElegantBeef> Yea for read only that's pretty good, for mutating it's meh |
04:21:18 | FromDiscord | <ElegantBeef> There's a whole lot of toOA, they start here <https://nim-lang.org/docs/system.html#toOpenArray%2Cptr.UncheckedArray%5BT%5D%2Cint%2Cint> |
04:23:08 | FromDiscord | <ElegantBeef> Of course i realize we can remove the annoying math by using `countUp` 😄 |
04:24:17 | FromDiscord | <ElegantBeef> Less redundant cleaner version https://play.nim-lang.org/#ix=2VTQ |
04:31:34 | * | rockcavera quit (Remote host closed the connection) |
04:36:20 | FromGitter | <gogolxdong> https://github.com/Chia-Network/chia-blockchain |
04:39:58 | FromDiscord | <sealmove> Nim used in CTF context 😅 https://github.com/sealmove/ctf-journey |
05:47:40 | * | johannes_ joined #nim |
05:47:55 | * | johannes_ is now known as kenran |
06:07:38 | * | narimiran joined #nim |
06:40:24 | ForumUpdaterBot | New thread by Stefan_Salewski: The NaN story, short version, see https://forum.nim-lang.org/t/7786 |
06:47:55 | * | kenran quit (Quit: leaving) |
06:52:28 | * | letto quit (Quit: Konversation terminated!) |
06:52:48 | * | letto joined #nim |
07:08:47 | * | hyiltiz quit (Ping timeout: 265 seconds) |
07:09:54 | * | hyiltiz joined #nim |
07:09:54 | * | hyiltiz quit (Changing host) |
07:09:54 | * | hyiltiz joined #nim |
07:26:30 | * | PMunch joined #nim |
07:32:30 | ForumUpdaterBot | New thread by Clonk: How to create generic type without C++ Template , see https://forum.nim-lang.org/t/7787 |
08:25:12 | * | Vladar joined #nim |
08:32:21 | * | idf joined #nim |
08:49:36 | ForumUpdaterBot | New post on r/nim by themoregames: I saw a Tweet: Manning's Nim ebook for free, directly from Manning (I am not affiliated) "till Apr 18th", see https://reddit.com/r/nim/comments/mpyayv/i_saw_a_tweet_mannings_nim_ebook_for_free/ |
09:00:04 | * | k0mpjut0r quit (Quit: Idle for 30+ days) |
09:05:20 | FromDiscord | <no name fits> yay free stuff |
09:19:02 | * | vicfred quit (Quit: Leaving) |
09:26:09 | * | haxscramper joined #nim |
09:28:10 | FromDiscord | <Gary M> how do I get the name of every file by extension in a directory at compile time |
09:28:50 | FromDiscord | <Gary M> the VM doesn't want to do it with walkFiles |
09:33:07 | FromDiscord | <haxscramper> Maybe https://nim-lang.org/docs/nimscript.html#listFiles%2Cstring |
09:37:17 | FromDiscord | <Gary M> how would you even use nimscript in nim itself |
09:47:11 | PMunch | @Gary M, all code that runs on compile-time is NimScript |
09:52:11 | FromDiscord | <haxscramper> Actually no, I just didn't read the question accurately enough. I suppose this is not possible to use `std/nimscript` at compile-time, it is implicitly imported when you use `.nims` file |
09:52:28 | FromDiscord | <haxscramper> But not available in `.nim` |
09:53:29 | FromDiscord | <haxscramper> I believe you might have to just `ls` to get files, |
10:00:57 | giaco__ | I have a veeeery long literal string to handle in my code. I'm using """mytext""".unindent over multiple lines but I also need to remove newlines, just like if it is one single long line. What's the best way to handle that? |
10:01:19 | FromDiscord | <Rika> strutils.replace maybe? |
10:02:31 | giaco__ | so is .unindent.replace("\n", "") |
10:02:45 | giaco__ | quite long for a code style matter |
10:03:57 | FromDiscord | <Rika> i believe it would be as long (if not longer) in many other language |
10:03:59 | FromDiscord | <Rika> s |
10:04:48 | Clonkk[m] | Is there a difference between assigning values to a variable and assigning value to a field of an object ? |
10:05:19 | giaco__ | k thanks |
10:05:54 | FromDiscord | <Rika> what kind of difference are you expecting? |
10:06:03 | liblq-dev | @Clonkk assigining to a field may trigger a setter |
10:06:11 | liblq-dev | or write to the heap, if the object is stored there |
10:06:15 | FromDiscord | <Rika> or the dot procedure |
10:06:21 | Clonkk[m] | <FromDiscord "<Rika> what kind of difference a"> Assigning to a field cause a segfault that I can't explain. Assigin to a variable do not |
10:06:28 | liblq-dev | @Rika template, rather |
10:06:32 | liblq-dev | or macro |
10:06:45 | FromDiscord | <Rika> well the dot thingy then |
10:06:55 | giaco__ | sealmove, I see a lot of updates in binarylang! Just started reading the changelog |
10:06:56 | FromDiscord | <Rika> In reply to @Clonkk "<FromDiscord "<Rika> what kind": check if the object is nil? |
10:08:32 | Clonkk[m] | <FromDiscord "<Rika> In reply to @Clonkk "<Fro"> It's a C++ type. If I do ``var a : A = b`` everything works. If I declare a type with a field ``A`` and try to use it, it doesn't work |
10:09:04 | FromDiscord | <Rika> might be imported wrong? can you show the original and the nim code? |
10:09:51 | Clonkk[m] | It's rather big :) https://github.com/Clonkk/flambeau/blob/feat_refactor/flambeau/raw/bindings/rawtensors.nim#L165 |
10:11:06 | Clonkk[m] | The thing is that using the imported alone works |
10:18:12 | giaco__ | Rika, I see that if the string is an hex string literal (prefix 0x) the .unindent.replace("\n", "") trick cannot work |
10:18:36 | FromDiscord | <Rika> huh? why? |
10:19:30 | giaco__ | you can't have tabs/spaces and newlines in an hex literal string |
10:19:56 | giaco__ | so the option is to .unindent.replace("\n", "").parseHexStr |
10:37:53 | * | lritter joined #nim |
10:43:29 | FromDiscord | <bolino> Hi guys, doing my first professional project in Nim. Loving it, but I'm so slow... |
10:43:55 | FromDiscord | <Rika> got any questions? |
10:44:58 | FromDiscord | <bolino> I do, thanks for asking. I'm trying to initialize a sequence of table with no success. I tried `var variants = newSeq[Table]()` and var `variants: seq[Table]` . Any idea?. |
10:45:15 | FromDiscord | <bolino> (edit) "var `variants:" => "`var variants:" | "idea?." => "idea?" |
10:45:24 | FromDiscord | <Rika> Table needs generic params |
10:45:36 | FromDiscord | <Rika> newSeq[Table[T, U]]() |
10:45:39 | FromDiscord | <bolino> (edit) "table" => "tables" |
10:45:49 | FromDiscord | <Rika> substitute T and U for the key type and the value type |
10:46:00 | FromDiscord | <Rika> note that T must have a function `hash` implemented |
10:46:10 | FromDiscord | <bolino> I see. So `newSeq[Table[string, string]]()` should be working? |
10:46:18 | FromDiscord | <Rika> yes |
10:48:40 | FromDiscord | <bolino> Works, thanks Rika! I have other issues though |
10:49:39 | FromDiscord | <bolino> Trying to add a Table to the sequence now: |
10:49:54 | FromDiscord | <bolino> `variants = newSeq[Table]()↵var v = newTable[string, string]()↵v["test_key"] = "test_value"↵variants.add(v)` |
10:51:50 | FromDiscord | <Rika> newTable => TableRef, not Table |
10:51:52 | FromDiscord | <Rika> use initTable |
10:53:24 | FromDiscord | <bolino> I see! Thanks a lot. Looks like a great community 🙂 |
10:53:46 | FromDiscord | <bolino> (edit) "🙂" => "🤗" |
10:59:27 | PMunch | Ooh, first professional project in Nim without knowing Nim to begin with, how'd you end up in that situation? |
10:59:57 | FromDiscord | <Rika> prolly hired by status? |
11:01:18 | PMunch | @bolino, by the way you don't need newSeq |
11:03:36 | PMunch | You can do it all like this for example: https://play.nim-lang.org/#ix=2VVu |
11:04:13 | PMunch | @Rika, possible, I'm just low-key trying to find Nim jobs :P |
11:04:30 | giaco__ | how to update a dependency in nimble? Nor "nimble install" or "nimble refresh" or "nimble update" does the job |
11:06:09 | PMunch | giaco__, if `nimble install <the dependency>` doesn't work then there isn't an update |
11:06:37 | PMunch | But note that for Nimble to see the package as updated I think it needs to have a Git tag with a higher version number |
11:06:38 | giaco__ | PMunch: yes there is, but seems not pulling with the_dependency#head |
11:06:49 | PMunch | Hmm, that sounds weird |
11:07:08 | PMunch | You can always try to delete it in .nimble/pkgs and run the install again |
11:07:51 | giaco__ | ok be deleting the packages it works |
11:09:08 | FromDiscord | <Solitude> In reply to @giaco__ "<@392962235737047041>: yes there is,": #head package wont be updated if its already present, so its pretty bad to depend on `#head` |
11:12:16 | FromDiscord | <bolino> > Ooh, first professional project in Nim without knowing Nim to begin with, how'd you end up in that situation?↵Well we had a backend parsing-csv-writing-to-db service that we just coded in Python and which speed didn't scale enough in production. I don't like Rust and my colleague don't like Go, we both looked at Nim with envy for a long time, so we decided it was probably the right time/work project to try it - if all that makes sense |
11:12:17 | giaco__ | Solitude, ah, ok, so with #head I have to delete package manually |
11:12:38 | FromDiscord | <bolino> (edit) "don't" => "doesn't" |
11:12:54 | FromDiscord | <bolino> (edit) "situation?↵Well" => "situation?↵↵Well" |
11:13:21 | FromDiscord | <Rika> why dont you like rust? just interested in other peoples opinions |
11:15:19 | FromDiscord | <Goel> https://play.nim-lang.org/#ix=2VVw↵This doesn't show any output? it means its a compiler crash? |
11:16:02 | FromDiscord | <Solitude> In reply to @Rika "why dont you like": its my favourite language to steal code from |
11:16:22 | FromDiscord | <Rika> @Goel no, it compiled and ran fine, what output do you expect? |
11:16:29 | FromDiscord | <Rika> assert doesnt print output |
11:17:32 | PMunch | @bolino, ah I see, natural discovery, cool! Hope you like it :) |
11:17:57 | FromDiscord | <Rika> In reply to @Solitude "its my favourite language": lmao 👌 i cant steal from it because i cant read it :XD: |
11:19:03 | FromDiscord | <Goel> sent a code paste, see https://play.nim-lang.org/#ix=2VVy |
11:19:16 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=2VVz |
11:19:16 | FromDiscord | <Yardanico> strings by default are empty |
11:19:24 | FromDiscord | <Rika> the code you sent showed "" |
11:19:48 | FromDiscord | <Yardanico> In reply to @Goel "https://play.nim-lang.org/#ix=2VVw This doesn't sho": no, how is it a compiler crash? not showing anything != crash |
11:19:55 | FromDiscord | <Yardanico> it compiled successfully https://media.discordapp.net/attachments/371759389889003532/831488868142284840/unknown.png |
11:20:12 | * | spiderstew_ quit (Ping timeout: 240 seconds) |
11:21:23 | * | xet7 joined #nim |
11:22:02 | FromDiscord | <bolino> > why dont you like rust? just interested in other peoples opinions |
11:22:41 | FromDiscord | <bolino> In reply to @Rika "why dont you like": Rust is a bit too verbose for me... Syntax is not as nice as Nim. |
11:22:55 | FromDiscord | <bolino> In reply to @PMunch "<@509668107665539073>, ah I see,": Love it so far! |
11:23:33 | FromDiscord | <Rika> In reply to @bolino "Rust is a bit": i see, so most peoples opinions |
11:23:36 | FromDiscord | <Rika> similar |
11:23:42 | FromDiscord | <Rika> english not working rn idk why sorry |
11:25:01 | * | spiderstew joined #nim |
11:43:56 | FromDiscord | <Yardanico> Should I post https://freecontent.manning.com/free-ebook-nim-in-action/ to announcements 🤔 |
11:45:43 | FromDiscord | <Goel> Yes, untill Dominik founds out 😆 |
11:45:58 | FromDiscord | <Goel> (edit) "founds" => "fiunds" |
11:46:05 | FromDiscord | <Goel> (edit) "fiunds" => "finds" |
11:46:11 | FromDiscord | <Yardanico> wdym? |
11:47:03 | FromDiscord | <Goel> Does he get any money for it during thise free-sale? |
11:47:37 | FromDiscord | <Yardanico> not sure, but manning has the rights to do that they're doing right now |
11:48:36 | FromDiscord | <Yardanico> it's been 3.5 years since the book release |
11:48:38 | FromDiscord | <Goel> I know, i already used the code sent by email and it works, i think you should post that in announcements and ping everyone on discord |
11:48:46 | FromDiscord | <Yardanico> no, no need to ping people |
11:49:40 | giaco__ | is it possible to initialize object with a tuple of its attributes? |
11:49:58 | FromDiscord | <Goel> sent a code paste, see https://play.nim-lang.org/#ix=2VVF |
11:50:37 | FromDiscord | <Yardanico> https://deepakg.github.io/nim/2019/09/28/nim-in-action-errata.html |
11:50:53 | FromDiscord | <Yardanico> In reply to @Goel "In fact, i found": the problem is not with "<list.len", the problem is in the spacing |
11:51:05 | FromDiscord | <Yardanico> it should be "0 ..< list.len" |
11:51:10 | FromDiscord | <Yardanico> no space after .. |
11:51:19 | FromDiscord | <Yardanico> but yeah, check the errata, it covers most of those cases |
11:52:35 | FromDiscord | <Goel> " But although sequences do have low and high fields, it’s more idiomatic to use the len field, which gives you the length of the sequence. The reason for this is that the low field for sequences is always 0" Is this still relevant? Because i checked this in the Nim latest docs and it says its safe to use `low` and `high` on sequences too |
11:52:59 | FromDiscord | <Yardanico> you're mixing up stuff |
11:53:06 | FromDiscord | <Yardanico> that quote doesn't say using low/high is "unsafe" |
11:53:11 | FromDiscord | <Yardanico> it simply says that using len is "more idiomatic" |
11:54:42 | FromDiscord | <Rika> why? |
11:55:08 | FromDiscord | <Yardanico> I don't know, I'm simply commenting on the quote |
12:05:58 | * | sacredfrog quit (Quit: ZNC 1.8.2 - https://znc.in) |
12:06:36 | * | sacredfrog joined #nim |
12:09:27 | FromDiscord | <nsauzede> sent a code paste, see https://paste.rs/JAw |
12:09:35 | FromDiscord | <nsauzede> sent a code paste, see https://play.nim-lang.org/#ix=2VVL |
12:15:07 | FromDiscord | <Rika> space |
12:15:09 | FromDiscord | <Rika> remove space |
12:15:11 | FromDiscord | <Rika> Camera( |
12:17:13 | FromDiscord | <sealmove> @giaco hi |
12:24:41 | FromDiscord | <nsauzede> In reply to @Rika "remove space": Wow thanks ! didn't see that |
12:25:15 | FromDiscord | <Goel> Is `'a'` considered a char or a string? Because nim already has the `char` keyword but i'm not sure if 'a' and "a" is the same thing, probably yes though |
12:25:31 | FromDiscord | <Rika> char |
12:25:40 | FromDiscord | <Rika> 'x' char "x" string |
12:25:48 | FromDiscord | <nsauzede> (edit) "In reply to @Rika "remove space": Wow thanks ! didn't see that ... " added "-- is there some special semantic in not tolerating spaces between object name and opening brace ?" |
12:25:50 | FromDiscord | <Rika> this is not python |
12:26:18 | FromDiscord | <Rika> In reply to @nsauzede "Wow thanks ! didn't": command syntax (same thing as being able to use `echo a`) |
12:26:55 | FromDiscord | <Rika> (a: 2) is a tuple, X (a:2) is a function call to X with tuple (a: 2) due to the space |
12:27:47 | FromDiscord | <nsauzede> thanks for that clear explanation |
12:29:29 | FromDiscord | <nsauzede> (edit) "thanks for that clear explanation ... " added "@Rika" |
12:35:27 | PMunch | Where is that handy table showing different ways of calling a proc when you need it.. |
12:36:12 | FromDiscord | <Yardanico> you mean https://nim-lang.org/docs/manual.html#procedures-method-call-syntax ? |
12:36:14 | FromDiscord | <Yardanico> but it's not a table |
12:36:45 | PMunch | Yeah I found that, but what I'm thinking about is a table that shows the different versions |
12:50:26 | FromDiscord | <nsauzede> I'm not used to having multiple ways to do the same thing 🙂 |
12:50:35 | FromDiscord | <nsauzede> but it makes sense once figured out |
13:02:53 | * | rockcavera joined #nim |
13:22:13 | FromDiscord | <Daniel> In reply to @Yardanico "Should I post https://freecontent.manning.com/free-": got the book, thank you |
13:22:45 | FromDiscord | <Daniel> maybe dominik is writing new book for nim, so this one might be outdated? |
13:22:52 | FromDiscord | <Daniel> (edit) "outdated?" => "outdated, thus free?" |
13:25:32 | PMunch | I don't think he's working on another book |
13:25:51 | PMunch | He's said that the curret version (with the fairly small errata is so up to date still that there really isn't much of a point |
13:59:52 | PMunch | I'll be doing another keyboard stream today. Finishing up the USB-HID Nim conversion and then hopefully getting into I²C. It's going to be after dinner though, so probably ~5UTC |
14:05:28 | Clonkk[m] | Do you specialize into writing keyboard firmware in Nim 😛 ? |
14:16:21 | * | NimBot joined #nim |
14:19:31 | * | hyiltiz quit (Ping timeout: 252 seconds) |
14:20:21 | * | hyiltiz joined #nim |
14:20:21 | * | hyiltiz quit (Changing host) |
14:20:21 | * | hyiltiz joined #nim |
14:36:58 | FromDiscord | <no name fits> In reply to @Yardanico "Should I post https://freecontent.manning.com/free-": Well I already got my copy, but sure |
14:38:41 | Clonkk[m] | Is there a pragma to stop Nim from generating ``nimZeroMem`` for an imported type ? |
14:38:58 | Clonkk[m] | (``noinit`` is at variable declaration) |
14:40:33 | FromDiscord | <haxscramper> "noinit" is a property of the variable, I don't think it is possible to attach this (or anything similar) to a type |
14:40:47 | Clonkk[m] | Damn |
14:40:49 | FromDiscord | <haxscramper> You are working with C++ object that is not implicitly constructible? |
14:41:38 | FromDiscord | <haxscramper> The only way I found to deal with those was to generate `noinit` or direct `{.emit: "return".}` for wrapper proc implementations |
14:41:40 | Clonkk[m] | The default constructor exists. But somehow (i'm still figuring out that part) if nimZeroMem is called (usually either during calling the Nim constructor or during ``=sink``) it segfault |
14:43:08 | FromDiscord | <haxscramper> You can wrap constructor using `.constructor.` and it won't generate initialization code at all |
14:43:15 | Clonkk[m] | <FromDiscord "<haxscramper> The only way I fou"> Good to know |
14:43:18 | giaco__ | how to check equality of ref types? |
14:43:22 | FromDiscord | <haxscramper> Though maybe you found A bug |
14:43:35 | FromDiscord | <haxscramper> In reply to @giaco__ "how to check equality": You mean pointer equality of value equality? |
14:43:43 | giaco__ | value equality |
14:43:46 | FromDiscord | <haxscramper> For value it is `a[] == b[]` |
14:43:56 | FromDiscord | <haxscramper> `[]` is a dereference operator |
14:43:57 | giaco__ | ok thanks |
14:44:23 | Clonkk[m] | <FromDiscord "<haxscramper> You can wrap const"> That's already done. The issue was triggered when using the type a field of another object because ``object.field = instance`` triggers ``=sink`` which tries to n``nimZeroMem`` on the ``dest`` reference |
14:45:09 | FromDiscord | <haxscramper> Maybe you can implement custom `=sink` that emits noop? LIke `=sink() = {.emit: "".}` |
14:45:32 | FromDiscord | <haxscramper> Do you have a code example that I can look at? |
14:46:27 | FromDiscord | <Clonkk> https://github.com/Clonkk/flambeau/tree/feat_refactor/tests/test_raw.nim is the reproducible example I isolated |
14:46:59 | FromDiscord | <Clonkk> I tried the =sink with emit |
14:47:08 | FromDiscord | <Clonkk> Still generate ``nimZeroMem`` |
14:49:42 | * | fredrikhr joined #nim |
14:52:38 | giaco__ | haxscramper: but what if the ref object contains other ref objects as fields and I want to value compare recursively? |
14:52:54 | FromDiscord | <haxscramper> then write custom implementation for `==` operator |
14:53:45 | FromDiscord | <haxscramper> If you use `ref` object it is not necessary to put `[]` everywhere, |
14:54:01 | FromDiscord | <haxscramper> `Type = ref object` |
14:57:02 | FromDiscord | <haxscramper> In reply to @giaco__ "<@608382355454951435>: but what if": https://play.nim-lang.org/#ix=2VWD |
14:58:08 | FromDiscord | <haxscramper> In reply to @SneakyBaguette "https://github.com/Clonkk/flambeau/tree/feat_refact": I can't reproduce the error with this example (even after uncommenting `tensorAg.raw = ...` |
14:58:20 | FromDiscord | <haxscramper> Nim `1.4.4` |
14:58:41 | FromDiscord | <Clonkk> Remove the ``noinit`` to ``tensorAg`` |
14:58:50 | giaco__ | haxscramper: yeah could be easy to check on just one field, but I'm writing test cases and I need to check all field, recursively |
14:58:58 | FromDiscord | <Clonkk> Then ``tensorAg.raw = a`` should segfault |
14:59:31 | FromDiscord | <haxscramper> In reply to @SneakyBaguette "Then ``tensorAg.raw = a``": Yes, it does. Alright, I will look into it now |
14:59:58 | FromDiscord | <haxscramper> In reply to @giaco__ "<@608382355454951435>: yeah could be": If you have `ref object` then creating custom `==` will make all comparisons by-value |
15:00:03 | FromDiscord | <Clonkk> Thanks ! And good luck down the rabbit hole |
15:00:33 | FromDiscord | <haxscramper> I.e. you of course have to compare necessary fields (can do this with `fieldPairs()` if this is not a case object) |
15:01:18 | giaco__ | how to check if a value is a ref value or not at runtime? |
15:03:15 | FromDiscord | <haxscramper> You can't check this at runtime |
15:03:24 | FromDiscord | <haxscramper> `ref` is a type basically |
15:03:38 | FromDiscord | <haxscramper> you can do `when value is ref`, but this would evaluate at compile-time |
15:04:37 | giaco__ | ok but so how can I use fieldPairs to achieve recursivity in value checking fields? |
15:05:01 | FromDiscord | <Clonkk> sent a code paste, see https://play.nim-lang.org/#ix=2VWS |
15:05:21 | FromDiscord | <haxscramper> That is not runtime, it will be statically resolved too |
15:06:10 | FromDiscord | <haxscramper> In reply to @giaco__ "ok but so how": If you implement `==` for type it will be automatically picked up |
15:06:21 | FromDiscord | <haxscramper> So you just need to recusively call `==` on subnodes |
15:07:26 | giaco__ | got it, thanks. Time to use | OR types I guess |
15:07:42 | ForumUpdaterBot | New thread by VickiCNolan: Error: invalid token: trailing underscore, see https://forum.nim-lang.org/t/7788 |
15:09:10 | FromDiscord | <haxscramper> In reply to @giaco__ "got it, thanks. Time": https://play.nim-lang.org/#ix=2VWT |
15:09:33 | FromDiscord | <haxscramper> The first example was bad because it didn't illustrate how this interacts with `nodes: seq[T]` |
15:10:54 | giaco__ | yeah, but I don't have a nested object of same T, I have nested object of multiple ref types (actually just 2 levels) |
15:11:29 | giaco__ | not sure if they share the same parent, I'm using a lib |
15:14:41 | giaco__ | is it possible to get the parent type? |
15:15:12 | giaco__ | at compile time, I mean. I just need to explore how the lib is doing things |
15:18:24 | FromDiscord | <haxscramper> > not sure if they share the same parent, I'm using a lib↵> is it possible to get the parent type?↵You mean you want to check if any of the several ref types share the same parent? Well, technically it is possible, but it would require tons of `getTypeImpl()` and other stuff like that |
15:19:07 | giaco__ | ok I can deal with OR types |
15:19:08 | FromDiscord | <haxscramper> I'm pretty sure it would be better to do things differently, or just write comparison manually |
15:20:00 | FromDiscord | <brainproxy> anyone had luck getting Nim 1.2.x compiler building properly on Apple M1? |
15:21:02 | FromDiscord | <Yardanico> it shouldn't work almost out of the box |
15:21:13 | FromDiscord | <Yardanico> just use 1.0 csources, they have m1 already added |
15:21:18 | FromDiscord | <Yardanico> https://github.com/nim-lang/csources_v1 |
15:21:22 | FromDiscord | <Yardanico> why 1.2 though? |
15:21:29 | FromGitter | <gogolxdong> Is there any python vs Nim performance figure? |
15:22:11 | * | teasea quit (Quit: teasea) |
15:22:28 | FromDiscord | <Yardanico> comparing languages like that is not always the best idea |
15:22:33 | * | teasea joined #nim |
15:22:33 | FromDiscord | <Yardanico> you can check the microbenchmarks at https://github.com/kostya/benchmarks |
15:27:43 | FromDiscord | <haxscramper> In reply to @SneakyBaguette "Then ``tensorAg.raw = a``": If you remove `{.noinit.}` on variable declaration it should segfault because object has been reset to zero (and internal state created in constructor is also invalidated). But adding `{.noinit.}` everywhere is really annoying, so maybe this https://play.nim-lang.org/#ix=2VX0 can be considered a "good enough" compromise? |
15:28:46 | FromDiscord | <haxscramper> This stuff is messy, I agreee, but we can only (1) add noinit, or (2) initialize manually to a known state (possibly using noop constructor proc) |
15:29:31 | FromDiscord | <exelotl> holy shit I love that // macro 😅 |
15:32:05 | FromDiscord | <Clonkk> In reply to @haxscramper "If you remove `{.noinit.}`": Hang on, trying to understand that |
15:35:27 | FromDiscord | <clyybber> In reply to @exelotl "holy shit I love": using rationals? |
15:35:42 | FromDiscord | <clyybber> oh nevermind |
15:35:51 | FromDiscord | <clyybber> saw the snippet now :D |
15:36:06 | FromDiscord | <clyybber> haha that is neat indeed |
15:38:04 | saem | Haha, that's a fun trick. |
15:39:37 | FromDiscord | <Clonkk> In reply to @haxscramper "If you remove `{.noinit.}`": So basically, tricking the compiler with an empty init cause it to NOT generate nimZeroMem ? |
15:43:26 | FromDiscord | <haxscramper> Yes, though I can't say I full understand all interactions that are going on with this code |
15:44:32 | FromDiscord | <Clonkk> Me neither haha. ↵Basically, the C++ aggregated type is ``torch::Tensor`` which is an ``intrusive_ptr<TensorImpl>`` (intrusive_ptr being a custom smart_ptr to the torch library). |
15:44:47 | FromDiscord | <Clonkk> The nimZeroMem somehow triggers a refcount to 0 and destroy the object |
15:45:15 | FromDiscord | <haxscramper> > somehow↵It just resets the object to zero-filled memory, so of course it would reset counter to zero |
15:45:28 | FromDiscord | <Clonkk> But the object doesn't exists yet |
15:46:17 | FromDiscord | <haxscramper> The segfault happens on `tensorAg.raw = a` line (at least according to by poor gdb skills) |
15:46:34 | FromDiscord | <haxscramper> It happens somewhere inside `operator=` (+8 levels more) |
15:46:53 | Clonkk[m] | Yes, but if you look at the generated C++ code there are multiple C++ lines with the stacktrace pointing to the line of the assignment |
15:46:56 | PMunch | @Clonkk[m], I've been interested in Nim for microcontrollers for a while. And I've always wanted to create my own DIY keyboard |
15:48:00 | FromDiscord | <Clonkk> In reply to @haxscramper "It happens somewhere inside": Maybe you're right and nimZeroMem zero the memory of the ref-counter |
15:49:27 | FromDiscord | <Clonkk> But that seems weird because ``nimZeroMem`` applies on sizeof and ``sizeof`` should be 8 (sizeof a pointer basically) |
15:52:10 | Clonkk[m] | <PMunch "@Clonkk[m], I've been interested"> https://forum.nim-lang.org/t/7731#49071 Elcritch wants to create EmbeddedNim I believe to port RTOS and stuff |
15:52:27 | Clonkk[m] | (if you missed it 😛) |
15:52:43 | PMunch | I didn't, but thanks :) |
15:53:04 | PMunch | RTOS would be great, but I'm doing even more low-level than that :P |
15:53:34 | PMunch | My hope is to be able to fit the entire firmware on an ATtiny85 |
16:10:14 | FromDiscord | <Clonkk> sent a long message, see http://ix.io/2VXf |
16:11:01 | FromDiscord | <Clonkk> For now, it'll have to do but I still think the situation could be improved 🙂 |
16:11:03 | FromDiscord | <haxscramper> `{.noinit.}` does remove zero memory init. |
16:11:12 | FromDiscord | <Clonkk> In reply to @haxscramper "`{.noinit.}` **does** remove zero": Yes, but you can't apply it to a type |
16:12:37 | FromDiscord | <haxscramper> > I assume there isn't a way to rewrite the default init for a given type `proc tensorAggregate() : TensorAggregate = # ...?`↵There is no support for default initialization for a type. For hcparse I just decided to wrap all constructors into procedures |
16:13:21 | FromDiscord | <haxscramper> with similar pattern |
16:14:47 | FromDiscord | <Clonkk> When you declare a type, the compiler generate an empty constructor proc, doesn't it ? From my understanding, it seems the nimZeroMem is generated inside said proc and added by the compiler to code generation when the object is no initialized. Is that correct ? |
16:15:18 | FromDiscord | <Clonkk> Or does the compiler ignore the default empty constructor and straight up call ``nimZeroMem`` on, object that are not initialized ? |
16:21:07 | giaco__ | haxscramper: I'm writing the `==` proc to compare two ref objects nexted structure, but I'm realising I cannot solve it looping one object fieldPairs and using the values to == on the second object, as I cannot reference field by name at runtime. I'm thinking about using zip + two fieldPairs, do you have a better idea? |
16:24:23 | FromDiscord | <haxscramper> How may fields there are? |
16:27:43 | giaco__ | haxscramper: 20 |
16:29:04 | * | natrys joined #nim |
16:31:26 | FromDiscord | <haxscramper> https://play.nim-lang.org/#ix=2VXp |
16:31:35 | FromDiscord | <haxscramper> field pairs for any number of objects |
16:36:05 | giaco__ | oh, I didn't know about the two args version of fieldPairs. This is a game changer |
16:36:07 | giaco__ | thanks! |
16:36:33 | giaco__ | I wonder about this Warning: This really transforms the 'for' and unrolls the loop. The current implementation also has a bug that affects symbol binding in the loop body. |
16:40:16 | giaco__ | thanks a lot, it works! |
16:59:38 | giaco__ | no, it doesn work if some values are nil |
17:03:58 | giaco__ | haxscramper: how would you solve this? https://play.nim-lang.org/ isNil seems not working inside a fieldPairs(x,y) |
17:04:19 | giaco__ | sorry, wrong link https://play.nim-lang.org/#ix=2VXB |
17:07:14 | FromDiscord | <Yardanico> i thought that fieldPairs only worked with same types? |
17:09:29 | giaco__ | I'm actually using it with same types |
17:09:31 | FromDiscord | <haxscramper> If you have separate types just write comparison by hand |
17:09:38 | FromDiscord | <haxscramper> ah |
17:09:56 | FromDiscord | <Yardanico> ah right sorry that was my bad |
17:10:26 | giaco__ | problem is if a field is nil |
17:10:39 | FromDiscord | <haxscramper> In reply to @giaco__ "<@608382355454951435>: how would you": `when field is ref: if isNIl(field): die` |
17:11:38 | giaco__ | I don't want to die, I want that if both objects have nil for the same field, they are equal |
17:11:58 | FromDiscord | <haxscramper> then return true |
17:12:03 | FromDiscord | <Yardanico> https://play.nim-lang.org/#ix=2VXF |
17:12:22 | FromDiscord | <Yardanico> the last return should be false |
17:12:29 | FromDiscord | <Yardanico> so just remove it |
17:12:35 | FromDiscord | <Yardanico> ah wait im dumb |
17:13:17 | FromDiscord | <exelotl> did anyone try to grab the free Nim In Action but didn't recieve any email? |
17:13:33 | FromDiscord | <exelotl> (I haven't tried it myself, just a friend told me that happened to them) |
17:13:47 | FromDiscord | <Yardanico> maybe they're using some weird email hosting? |
17:20:13 | giaco__ | Yardanico: thanks for the suggestion, but why do you double check f1 == f2 both inside the "when" and outside? |
17:20:23 | FromDiscord | <Yardanico> that code is wrong anyway :) |
17:26:35 | PMunch | Stream is live! Join me as I beautify the ported C code and explore how to make PROGMEM nicer to work with :) https://www.twitch.tv/pmunche |
17:29:34 | giaco__ | this seems to work nicely https://play.nim-lang.org/#ix=2VXI |
17:30:41 | FromDiscord | <Yardanico> you don't need to check if both f1 and f2 are refs |
17:30:44 | FromDiscord | <Yardanico> since they're of the same type |
17:58:43 | * | vicfred joined #nim |
18:09:11 | * | natrys quit (Ping timeout: 240 seconds) |
18:18:01 | * | Gustavo6046 quit (Ping timeout: 252 seconds) |
18:36:26 | * | natrys joined #nim |
18:46:22 | FromDiscord | <sealmove> @giaco you here? |
18:46:57 | FromDiscord | <sealmove> @giaco |
19:14:19 | * | lritter quit (Ping timeout: 252 seconds) |
19:18:26 | * | leorize quit (Quit: WeeChat 3.0) |
19:30:26 | * | Gustavo6046 joined #nim |
19:45:08 | FromDiscord | <jtiai> sent a code paste, see https://play.nim-lang.org/#ix=2VYM |
19:50:06 | FromDiscord | <konsumlamm> just make `XXX` a `const` |
19:50:57 | FromDiscord | <jtiai> but there are several ones. |
19:51:20 | FromDiscord | <jtiai> Like ROM 4kB and RAM 8kB. |
19:51:50 | FromDiscord | <Solitude> just sum the consts? |
19:52:04 | FromDiscord | <jtiai> Memories aren't consecutive. |
19:53:39 | FromDiscord | <jtiai> And they even can overlap (memory shadowing) |
19:54:34 | FromDiscord | <Solitude> i dont get it. if size is known at compile time - reserve that size, whats the problem? |
19:55:00 | FromDiscord | <jtiai> There are many. |
19:57:43 | * | Gustavo6046 quit (Ping timeout: 260 seconds) |
19:58:49 | FromDiscord | <jtiai> sent a code paste, see https://play.nim-lang.org/#ix=2VYP |
19:58:59 | FromDiscord | <ElegantBeef> Sounds like a case of you allocate the entire size then you use `toOpenArray` to get a read only view into it |
19:59:14 | FromDiscord | <jtiai> entire size of? |
19:59:51 | FromDiscord | <ElegantBeef> Actually i reason you'd want to mutate it so maybe just a range + an iterator |
19:59:58 | * | Gustavo6046 joined #nim |
20:00:13 | FromDiscord | <ElegantBeef> I'm uncertain how it's supposed to work but it sounded like it was a large chunk of memory |
20:00:35 | FromDiscord | <jtiai> In C I would use simple memory allocation. |
20:00:45 | FromDiscord | <jtiai> or C++ actually since it would be easier. |
20:00:46 | FromDiscord | <ElegantBeef> You know you can do `EmulatedMem[size: static int]`? |
20:00:54 | FromDiscord | <jtiai> No I don't. |
20:02:50 | FromDiscord | <SivadNai> thanks @pointystick |
20:05:59 | * | def- quit (Quit: -) |
20:07:03 | * | def- joined #nim |
20:09:27 | * | natrys quit (Quit: natrys) |
20:13:24 | PMunch | Haha, one thing I love about Nim. My Makefile is 22 lines long, but still almost 4% of my codebase :P |
20:17:48 | FromDiscord | <SivadNai> I love the smooth velvety texture more |
20:20:41 | * | narimiran quit (Ping timeout: 246 seconds) |
20:28:36 | * | haxscramper quit (Remote host closed the connection) |
20:28:59 | * | haxscramper joined #nim |
20:30:41 | * | haxscramper quit (Remote host closed the connection) |
20:34:11 | FromDiscord | <Sabena Sema> Did nim script mode ever get FFI? |
20:34:56 | FromDiscord | <ElegantBeef> there is a compile flag to add it |
20:35:04 | FromDiscord | <ElegantBeef> but it's not in the compiler by default |
20:36:29 | FromDiscord | <ElegantBeef> https://github.com/nim-lang/Nim/pull/10150 |
20:37:31 | FromDiscord | <lamersc> https://media.discordapp.net/attachments/371759389889003532/831629193170780190/image0.png |
20:40:03 | PMunch | With Nim you can be both :D |
20:41:02 | PMunch | Write the complex code once and put it in a nice macro, use the simple interface you've just created with zero risk of messing up later |
20:42:07 | FromDiscord | <SivadNai> 1 more python script at work which can be replaced by nim |
20:43:45 | PMunch | One chip at a time |
20:44:21 | PMunch | Soon the mountain is all but rubble |
21:04:47 | FromDiscord | <jtiai> Bummer. Dreaded circular imports. |
21:27:34 | FromDiscord | <exelotl> hehe |
21:28:13 | FromDiscord | <Yardanico> @sealmove you around? anyway, wanted to ask a question about binarylang - 1) why does it seem to create a ref type for storing the result of serialization/deserialization? 2) can I somehow "differentiate" between different substruct based on some value from the "header" struct? or I have to create a bit of code that does "case" switch and parses different structs myself? |
21:30:44 | FromDiscord | <Sabena Sema> hmm looking at that CT FFI issue and linked issues: Why is strutils.find even in the rtl anyway? |
21:31:42 | FromDiscord | <sealmove> In reply to @Yardanico "<@!173424250319929344> you around? anyway,": Hey @Yardanico. The only reason BL generates ref types is because I don't know why/when non-ref types are useful 😅 |
21:31:57 | FromDiscord | <Yardanico> they're generally more useful over ref types since they don't involve heap allocation and refcounting |
21:32:05 | FromDiscord | <sealmove> Still what are you trying to do? I don't get the thing about "case" |
21:32:05 | FromDiscord | <Yardanico> IMO they should be "object" by default with an option isRef |
21:32:34 | FromDiscord | <Yardanico> In reply to @รєคɭ๓๏שє "Still what are you": a game is sending different packets, and the header contains the size (of the whole data packet) and action id (basically packet id) |
21:32:38 | FromDiscord | <Yardanico> different packets have different info |
21:32:39 | ForumUpdaterBot | New thread by Btol: Nim on Raspberry Pi Pico, see https://forum.nim-lang.org/t/7789 |
21:33:49 | FromDiscord | <sealmove> In reply to @Yardanico "different packets have different": so you need a union |
21:34:03 | FromDiscord | <Yardanico> well, I know, I just wondered if binarylang has something for that or I need to do it myself |
21:34:09 | FromDiscord | <sealmove> there are 2 macros, `struct` and `union` |
21:34:17 | FromDiscord | <Yardanico> oh, nice |
21:34:26 | FromDiscord | <sealmove> and you call union parsers with `+` instead of `` |
21:34:44 | FromDiscord | <sealmove> the first argument is the discriminator and it is only evalutated for parsing |
21:37:28 | FromDiscord | <Yardanico> yeah, nice, seems to work |
21:37:34 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=2VZj |
21:37:36 | FromDiscord | <Yardanico> just reverse engineering packets from a game :) |
21:40:13 | FromDiscord | <Yardanico> not sure if you'd want to add that as an example |
21:40:20 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=2VZl |
21:40:25 | FromDiscord | <Yardanico> just simple stuff, wireshark + dnSpy |
21:40:30 | FromDiscord | <sealmove> all examples are welcome |
21:40:41 | FromDiscord | <Yardanico> maybe I should add a different packet first |
21:41:38 | FromDiscord | <sealmove> grad you found the `toSomething` procs. not sure I have documented them |
21:41:57 | FromDiscord | <Yardanico> from ajusa examples :) |
21:42:20 | FromDiscord | <Yardanico> although using binarylang for http parsing seems to be a bit weird as it's text-base (I would've preferred npeg :P) |
21:42:26 | FromDiscord | <Yardanico> (edit) "text-base" => "text-based" |
21:42:36 | FromDiscord | <sealmove> In reply to @Yardanico "they're generally more useful": ok, then I can change it. would you make an issue about it? |
21:42:40 | FromDiscord | <Yardanico> but if it works for them then it's fine I guess |
21:42:45 | FromDiscord | <Yardanico> In reply to @รєคɭ๓๏שє "ok, then I can": sure |
21:42:47 | FromDiscord | <TennisBowling> I'm trying to install `net` but when I run nimble install net It throws no ssl/tls certs found |
21:42:49 | FromDiscord | <sealmove> In reply to @Yardanico "from ajusa examples :)": i see, glad they are useful |
21:42:54 | FromDiscord | <Yardanico> In reply to @TennisBowling "I'm trying to install": net is a stdlib module |
21:43:22 | FromDiscord | <TennisBowling> yeah but the cert stuff still shows |
21:43:26 | FromDiscord | <TennisBowling> im willing to just use http |
21:43:45 | FromDiscord | <sealmove> In reply to @Yardanico "although using binarylang for": Yes I thought so too :D but it revealed to me something important, that BL is not only great because it helps you parse binary data, but also because it does the data -> object mapping automatically. |
21:43:58 | FromDiscord | <Yardanico> In reply to @TennisBowling "im willing to just": see https://forum.nim-lang.org/t/7551 |
21:44:01 | FromDiscord | <sealmove> In npeg you have to write procedural code to fill in your objects |
21:44:04 | FromDiscord | <Yardanico> true |
21:45:21 | FromDiscord | <sealmove> so if something can be easily described with binarylang, then it might be safer than npeg, even if it's text. |
21:46:00 | FromDiscord | <Yardanico> https://github.com/sealmove/binarylang/issues/13 |
21:46:07 | FromDiscord | <sealmove> thanks! |
21:46:48 | FromDiscord | <sealmove> there are no stability guarantees, I am changing stuff too fast rn, so it's fine |
21:47:00 | FromDiscord | <sealmove> it's pre-alpha, lol |
21:48:11 | FromDiscord | <nsauzede> sent a code paste, see https://play.nim-lang.org/#ix=2VZm |
21:48:36 | FromDiscord | <nsauzede> (`PI` seems to be `float` => `float64`) |
21:48:51 | FromDiscord | <Yardanico> generally that's fine, although you can make it a float too |
21:48:58 | FromDiscord | <Yardanico> (edit) "float" => "const" |
21:49:27 | FromDiscord | <Sabena Sema> won't `var pi_f32: float32 = PI` be more accurate? |
21:50:01 | FromDiscord | <nsauzede> sent a code paste, see https://play.nim-lang.org/#ix=2VZo |
21:50:08 | FromDiscord | <nsauzede> => I want `theta` to be `float32` |
21:50:23 | FromDiscord | <Yardanico> you can convert it to a 32-bit float after all math is done |
21:50:24 | FromDiscord | <nsauzede> (`vfov` is `float32`) |
21:50:46 | FromDiscord | <nsauzede> yeah, but I'm looking for the canonical / Nimical way |
21:51:04 | FromDiscord | <nsauzede> so global convert to float32 at the end ? |
21:51:35 | FromDiscord | <Sabena Sema> yeah |
21:52:04 | FromDiscord | <Sabena Sema> the reason I think using `var pi_f32: float32 = PI` may be more accurate is that parsing text as a float32 is _different_ than parsing as a double and then converting |
21:52:31 | FromDiscord | <Sabena Sema> not that anyone gets floating point parsing and printing correct in the first place |
21:52:50 | FromDiscord | <nsauzede> yeah in fact I want to avoid conversions b/z 32/64 as much as possible |
21:52:52 | FromDiscord | <Sabena Sema> wg21 standardized it for c++ and the google folks had to invent a new algorithm to implement it |
21:53:03 | FromDiscord | <nsauzede> so yeah I'll define a local 32 bit PI |
21:53:13 | FromDiscord | <Sabena Sema> and I know MSVC has had a bunch of bugs related to how it parses literal floats and doubles |
21:53:14 | FromDiscord | <Yardanico> In reply to @Sabena Sema "the reason I think": no one is parsing it as text |
21:53:20 | FromDiscord | <Sabena Sema> the compiler is |
21:53:21 | FromDiscord | <Yardanico> PI is a float64 const from std/math |
21:53:23 | FromDiscord | <Yardanico> already |
21:53:24 | FromDiscord | <nsauzede> (I wondered if there wasn't already one const available from std lib) |
21:53:28 | FromDiscord | <Sabena Sema> really? |
21:53:32 | FromDiscord | <Yardanico> yes |
21:53:32 | FromDiscord | <Sabena Sema> I thought PI was just the literal |
21:53:41 | FromDiscord | <Yardanico> nim doesn't have any special "literals" |
21:53:47 | FromDiscord | <Yardanico> PI is just a constant in math |
21:53:53 | FromDiscord | <Yardanico> ` PI = 3.1415926535897932384626433 ## The circle constant PI (Ludolph's number)` |
21:54:05 | FromDiscord | <Yardanico> https://media.discordapp.net/attachments/371759389889003532/831648462847475772/unknown.png |
21:54:35 | FromDiscord | <Sabena Sema> so are all literal floating point numbers parsed as a double and then converted? |
21:56:22 | FromDiscord | <nsauzede> yes ig |
21:56:37 | FromDiscord | <nsauzede> literal floats are `float` which is `float64` |
21:56:51 | FromDiscord | <nsauzede> (that's what I learnt here yesterday) |
21:57:25 | FromDiscord | <Sabena Sema> does it at least parse `'f32` style literals as 32-bit floats directly? |
21:57:35 | FromDiscord | <Sabena Sema> because if not that's ... not correct |
21:57:38 | FromDiscord | <nsauzede> yes `3.14f` is float32 |
21:57:52 | FromDiscord | <nsauzede> or `3.14'f` |
21:58:10 | FromDiscord | <nsauzede> (edit) "or" => "so is" |
21:58:20 | FromDiscord | <Sabena Sema> I know what the type is, I'm just wondering if the compiler parses the literal internally as a double (or bigger) than converts |
21:58:51 | FromDiscord | <Sabena Sema> I think even parsing as extened precision float and converting might not work |
21:59:09 | FromDiscord | <nsauzede> if you what the type it is, you know how the compiler parses it 🤷♂️ |
22:00:12 | FromDiscord | <nsauzede> (edit) "if you ... what" added "know" |
22:00:27 | FromDiscord | <Sabena Sema> that's not always the case. (this came up, apperently, when writing tests for c++'s std::to_chars) |
22:02:07 | FromDiscord | <nsauzede> idk; anyway, the Nim VSCod{e|ium} extension nicely displays each sub parts incl. operators of an experssion with their types (float, float32, float64 etc..) I just used that to debug an accuracy bug in my raytracer |
22:02:28 | FromDiscord | <nsauzede> (edit) "experssion" => "expression" |
22:03:29 | FromDiscord | <nsauzede> Thanks for you advice concerning PI conversion @Sabena Sema that fixed it |
22:07:29 | FromDiscord | <nsauzede> Are statements grouped on a single line using `;` standard practice in Nim ? |
22:07:54 | FromDiscord | <Sabena Sema> not really |
22:08:25 | FromDiscord | <nsauzede> sent a code paste, see https://play.nim-lang.org/#ix=2VZx |
22:08:46 | FromDiscord | <nsauzede> the first line of the func is broken up, and produce a compile error (indent) |
22:08:54 | FromDiscord | <nsauzede> is that a nim formatter bug ? |
22:10:30 | FromDiscord | <nsauzede> (and I know that I could use `&""` strformat to achieve the same with only one statement -- but that's irrelevant to my question) |
22:11:27 | FromDiscord | <nsauzede> (this is mostly bare transpiled code from another lang -- my question is regarding general statements grouping, and possible nim formatter bug) |
22:12:34 | FromDiscord | <Sabena Sema> the likely problem is that even if you use the semicolon you still need to properly indent stuff |
22:12:39 | FromDiscord | <Sabena Sema> it's possible the transpiler is broken |
22:13:21 | FromDiscord | <Sabena Sema> you can use `(` and `)` to mitigate some of the indent sensitivity if the transpiler really has trouble, but that's extremely odd |
22:17:35 | FromDiscord | <nsauzede> no no there's no transpiler involved 😅 I meant I manually "transpiled" C code to Nim, hence the bizarre/inefficient resulting Nim grouped statements |
22:18:11 | FromDiscord | <nsauzede> so you suggest me to put `()` around each statements groups ? |
22:24:33 | FromDiscord | <nsauzede> I tested the braces and it seems to work; thanks ! |
22:25:02 | FromDiscord | <nsauzede> (but I'd better rewrite into canonical Nim ofc 🙂 ) |
22:26:51 | FromDiscord | <Sabena Sema> oof the FFI evaulator does some extremely questionable things on windows |
22:32:43 | FromDiscord | <TennisBowling> hello, me again. there are no ++ or -- operators in nim, just like in python. what dose nim use? |
22:32:43 | FromDiscord | <Hi02Hi> why does std/rationals use a generic type? |
22:32:53 | * | fredrikhr quit (Quit: Client Disconnecting) |
22:32:54 | FromDiscord | <Hi02Hi> In reply to @TennisBowling "hello, me again. there": `inc` and `dic` |
22:32:56 | FromDiscord | <Hi02Hi> (edit) "`dic`" => "`dec`" |
22:32:58 | FromDiscord | <Sabena Sema> @TennisBowling `inc` and `dec` |
22:33:01 | FromDiscord | <TennisBowling> sick |
22:33:13 | FromDiscord | <Sabena Sema> you can write like `x.inc` in you like |
22:33:22 | FromDiscord | <TennisBowling> or just `x inc`? |
22:33:44 | FromDiscord | <Hi02Hi> that makes it seem like x(inc) |
22:33:50 | FromDiscord | <Hi02Hi> so no |
22:34:05 | FromDiscord | <TennisBowling> okay |
22:34:07 | FromDiscord | <TennisBowling> thanks |
22:34:19 | FromDiscord | <Hi02Hi> you're welcome |
22:34:33 | FromDiscord | <nsauzede> `x+=1` is valid too right ? |
22:34:39 | FromDiscord | <Hi02Hi> it is |
22:34:43 | FromDiscord | <nsauzede> but not prefered ? |
22:34:57 | FromDiscord | <Hi02Hi> you can do whatever you like |
22:37:11 | PMunch | Nim in nutshell right there :P |
22:38:20 | FromDiscord | <Hi02Hi> In reply to @Hi02Hi "why does std/rationals use": i feel like everyone only uses Rational[int] and nothing else |
22:38:22 | PMunch | I prefer to use inc when I increment something, like in a loop for example. Where I expect the value to steadily increase over the whole range. But I use +=1 when I just want to add one to a number |
22:42:56 | FromDiscord | <Patrickfield> I usually use inc/dec for readability when i'm incrementing by a well defined constant, while if it's a variable i use the += / -= |
22:43:42 | FromDiscord | <Patrickfield> (edit) removed "a" |
22:52:23 | * | PMunch quit (Quit: leaving) |
23:24:38 | * | Gustavo6046 quit (Ping timeout: 265 seconds) |
23:38:25 | * | Gustavo6046 joined #nim |
23:54:54 | * | krux02 quit (Remote host closed the connection) |