01:46:29 | arkanoid | is there a proper way to convert an array[2, Meter] to array[2, Float] where type Meter = distinct float, without copying/duplicating the array? |
01:51:17 | arkanoid | I mean, converting a distinct to its base type is trivial when base type is ... base |
01:51:35 | arkanoid | but when base type is array or something more seem not working |
01:54:40 | * | rockcavera joined #nim |
02:02:11 | FromDiscord | <Elegantbeef> `cast` is there |
02:02:25 | FromDiscord | <Elegantbeef> But otherwise they're "invariant" i believe is the term |
02:02:50 | FromDiscord | <Elegantbeef> Might be "covariant" I don't recall the fancy term |
02:03:05 | FromDiscord | <Elegantbeef> Just cause generic parameters are convertible does not mean generic instantiations are |
02:04:48 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#pasty=mixUtqPeHVkj is a case where `cast` does not work for obvious reasons |
02:06:57 | arkanoid | this is the cast based solution I've found, but I'd guess there's a safe alternative for that https://play.nim-lang.org/#pasty=RfjQKOBGcJgL |
02:07:20 | FromDiscord | <Elegantbeef> There isnt cause this is isn't an operation that is safe to do |
02:07:56 | arkanoid | I don't understand why. Let me remove imports and write a self-contained example |
02:08:00 | FromDiscord | <Elegantbeef> To convert between generic instantiations creating an L-value you have to know the trees are identical so whilst possible it's not a fun thing to do |
02:08:15 | FromDiscord | <Elegantbeef> I just showed an example of why it's not |
02:08:25 | FromDiscord | <Elegantbeef> In the case of an array it's fine but there is not a general solution |
02:08:55 | FromDiscord | <Elegantbeef> I should say there is a general solution but it's quite elaborate so probably why it's not implemented |
02:09:14 | FromDiscord | <Elegantbeef> We can make this safe using a proc |
02:11:57 | arkanoid | here the self contained example. Please forgive me I've been typing Nim, I'm going to read your example now https://play.nim-lang.org/#pasty=cuLsxWovMtbR |
02:17:23 | FromDiscord | <girvo> In reply to @Elegantbeef "https://play.nim-lang.org/#pasty=fqPpUSTJYCBs I of ": Does this play nice with a =destroy as well? |
02:17:35 | FromDiscord | <Elegantbeef> Indeed |
02:17:40 | FromDiscord | <girvo> Clean |
02:17:46 | FromDiscord | <Elegantbeef> Implement a `=destroy` only for `Uart[Init]` |
02:17:59 | FromDiscord | <Elegantbeef> `Uart[Uninit]` owns nothing |
02:18:12 | FromDiscord | <girvo> Yeah makes sense |
02:18:47 | FromDiscord | <girvo> This actually fits the way it's configured/setup too |
02:22:17 | FromDiscord | <Elegantbeef> Type states are great |
02:22:46 | FromDiscord | <girvo> Yeah esp for this one-to-one object to hardware mapping |
02:24:10 | FromDiscord | <Elegantbeef> Arkanoid https://play.nim-lang.org/#pasty=TLgZiGlRjAwO here is a simple proc based implementation that makes it a tinge safer |
02:24:25 | FromDiscord | <Elegantbeef> This also works for distinct of distinct |
02:24:43 | FromDiscord | <Elegantbeef> Atleast in theory |
02:25:57 | arkanoid | neat use of typetraits! |
02:26:56 | FromDiscord | <Elegantbeef> Lol |
02:27:01 | FromDiscord | <Elegantbeef> I was trying to use it but the compiler did not like it |
02:27:04 | arkanoid | thanks, I got it now. It's just a matter that two real types generates from same metaclass may have very different fields |
02:27:09 | FromDiscord | <Elegantbeef> So it stayed there |
02:27:22 | arkanoid | *generated |
02:27:49 | FromDiscord | <Elegantbeef> It is of course fully possible to have the compiler check if they're convertible but that does require walking down each instantiation and checking the fields are convertible |
02:41:56 | arkanoid | Elegantbeef, do you see if more or less safe if I turn your example from procs to templates? https://play.nim-lang.org/#pasty=yGRxdoGsQziL |
02:42:05 | arkanoid | *do you see it |
02:43:31 | arkanoid | also, why is std/typetraits imported? you seems not using it |
02:44:25 | FromDiscord | <Elegantbeef> I said why |
02:44:39 | arkanoid | uh? sorry again, let me re-read |
02:45:32 | FromDiscord | <Elegantbeef> > I was trying to use it but the compiler did not like it |
02:45:37 | arkanoid | oh, ok |
02:46:17 | arkanoid | mh, I wonder which improvement you were looking for with std/typetraits |
02:51:58 | * | krux02 quit (Remote host closed the connection) |
02:54:00 | FromDiscord | <Elegantbeef> `Y: typedesc = distinctBase(T)` |
03:00:06 | arkanoid | uhm, I don't understand why your proposed solution works when used with types copied from vmath, but it doesn't when imported real vmath https://play.nim-lang.org/#pasty=uLPUZNsuaBkt |
03:07:47 | arkanoid | wait, I might have found the reason |
03:08:33 | arkanoid | https://github.com/treeform/vmath?tab=readme-ov-file#vector-and-matrix-representation-and-benchmarks -> https://github.com/treeform/vmath/blob/7282ae1247f2f384ebeaec3826d7fa38fd0e1df1/src/vmath.nim#L249 |
03:10:21 | arkanoid | I can confirm that it compiles and run with -d:vmathArrayBased |
03:27:42 | FromDiscord | <Elegantbeef> Right replace the array with `GVec...` |
03:35:11 | * | rockcavera quit (Remote host closed the connection) |
03:49:07 | * | rockcavera joined #nim |
03:57:33 | arkanoid | one more step and I get an elegant solution: how to get the underlying (generic?) typeclass from a proc foo[T](bar: GVec234[T]): GVec234[Y] = cast[???](bar) <-- https://github.com/treeform/vmath/blob/7282ae1247f2f384ebeaec3826d7fa38fd0e1df1/src/vmath.nim#L46 |
03:59:08 | arkanoid | GVec234[T] = GVec2[T] | GVec3[T] | GVec4[T], I want to know when a proc with argument GVec234[T] is called with GVec2[T] or GVec3[T] or GVec4[T]. Do I need a when/else cascade? |
03:59:28 | FromDiscord | <Elegantbeef> `typetraits` has `GenericHead` |
04:02:11 | FromDiscord | <user2m> how do I append text to a file? writeFile seems to overwrite |
04:02:24 | FromDiscord | <Elegantbeef> `open(..., fmWriteExisting)` |
04:04:38 | arkanoid | Elegantbeef, in your original solution, you used `when not compiles(T(arr[Idx.low]))`. Did you mean to write `when not compiles(Y(arr[Idx.low]))` instead? |
04:04:47 | FromDiscord | <Elegantbeef> Yes |
04:04:56 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#pasty=gaYKZUWrmNsD |
04:05:06 | arkanoid | thanks |
04:07:40 | arkanoid | This is the most complete solution I've found so far https://play.nim-lang.org/#pasty=ybCJHVKfTlIc but I didn't get how to use GenericHead to replace the when/elif/else chain |
04:09:09 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#pasty=KiQyCwWDZkWs |
04:11:38 | arkanoid | doesn't compile Error: invalid type: 'typeof(typeof(p1).genericHead)' for let |
04:11:56 | FromDiscord | <Elegantbeef> Forgot the `[Y]` |
04:12:09 | FromDiscord | <Elegantbeef> You win some you lose more |
04:15:08 | arkanoid | mh, I'm trying adding [Y] in every possible posible position, but compiled doesn't get satisfaction. It's Y kamasutra here |
04:15:27 | arkanoid | *compiler. Damn, can't type today |
04:17:09 | FromDiscord | <Elegantbeef> We'll do it another way π |
04:19:30 | arkanoid | the long chain of when/else is ugly but works: https://play.nim-lang.org/#pasty=nnaKLnqUKSQA |
04:21:27 | FromDiscord | <Elegantbeef> Yea typetraits macros are silly |
04:21:35 | FromDiscord | <Elegantbeef> Actually they're not even macros |
04:22:03 | FromDiscord | <Elegantbeef> I do despise that you're using templates but you do you |
04:23:13 | arkanoid | lol! compiler internal error |
04:23:25 | arkanoid | just by replacing template with proc |
04:26:51 | arkanoid | what's the idea of genericHead? typeof(arr) would return like GVec2[float], genericHead would return GVec2, then we're trying to add [Y] to get GVec2[Y] right? |
04:27:10 | FromDiscord | <Elegantbeef> That was the idea yes |
04:27:27 | arkanoid | mmm ok |
04:28:05 | arkanoid | but somehow it doesn't like it |
04:29:45 | arkanoid | cast[(genericHead(typeof(arr)))[Y]](arr) -> Error: identifier expected |
04:30:16 | FromDiscord | <girvo> Dumb question, is there way to get the `nim` binary to output/dump it's compile time defines? |
04:31:09 | FromDiscord | <Elegantbeef> Sadly not |
04:31:25 | FromDiscord | <Elegantbeef> Atleast not that I know of |
04:31:35 | FromDiscord | <Elegantbeef> Could probably abuse `--importFile` and Term rewriting macros |
04:31:51 | FromDiscord | <girvo> damn |
04:31:59 | FromDiscord | <girvo> Oh well, CMake parsing `nim.cfg` it is! |
04:33:27 | FromDiscord | <Elegantbeef> Oh you meant like that |
04:35:52 | FromDiscord | <girvo> π |
04:36:02 | arkanoid | thanks for all the hints beef, as usual |
04:36:17 | FromDiscord | <girvo> It's all good, `file(READ nim.cfg NIM_CONFG)` and `string(REGEX MATCH ...)` will be enough |
04:36:21 | arkanoid | needs some sleep! bye |
04:36:28 | FromDiscord | <Elegantbeef> `dump` |
04:36:44 | FromDiscord | <Elegantbeef> Wait that's not write |
04:36:45 | FromDiscord | <Elegantbeef> right\ |
04:52:41 | FromDiscord | <girvo> Is there any other way =destroy can be called other than via =sink or going out of scope? Oh I guess being called explicitly by a dev? |
04:53:09 | FromDiscord | <Elegantbeef> Yep |
04:53:40 | FromDiscord | <Elegantbeef> All hooks are supposed to destroy the dest |
05:10:12 | FromDiscord | <girvo> hm. Alright I'm going to have to test this a heap |
06:07:30 | FromDiscord | <girvo> sent a code paste, see https://play.nim-lang.org/#pasty=DYcVLzmzmhWT |
06:07:41 | FromDiscord | <girvo> Which I've bound in a higher level manner |
06:09:08 | FromDiscord | <girvo> Is there an equivalent of this #define newFunction oldFunction(withSomeStuff)? β΅β΅I can obviously just define them as procs doing the same thing and calling the other procs... I guess marked with {.inline.}? |
06:09:14 | FromDiscord | <Elegantbeef> @bung8954 you got me too deep into actually making that cleaner so now rdldd exists π |
06:13:05 | FromDiscord | <Elegantbeef> Templates or inline procs girvo |
06:14:48 | FromDiscord | <Elegantbeef> https://github.com/beef331/rdldd/blob/master/rdldd.nim whoops meant to place that there |
06:17:58 | * | advesperacit joined #nim |
06:18:33 | * | advesperacit quit (Client Quit) |
06:18:51 | * | advesperacit joined #nim |
06:28:17 | * | ntat joined #nim |
06:45:55 | * | rockcavera quit (Remote host closed the connection) |
07:11:14 | FromDiscord | <bung8954> interesting, I found appimage provide tools do the task |
07:12:57 | * | SchweinDeBurg quit (Quit: WeeChat 4.3.0-dev) |
07:13:41 | * | SchweinDeBurg joined #nim |
07:24:50 | FromDiscord | <girvo> I wonder what's preferable here, inline or a template |
07:25:20 | FromDiscord | <girvo> probably inline because templates seem to break nimsuggest/lsp/error outputs sometimes lol |
07:40:28 | FromDiscord | <morgan> sent a long message, see https://pasty.ee/twuiHerPgehv |
08:06:24 | FromDiscord | <Elegantbeef> Use an untagged union inside of a union and you can place them wherever you want |
08:07:58 | FromDiscord | <Elegantbeef> inside of an object\ |
08:08:03 | FromDiscord | <Elegantbeef> @morgan |
08:12:46 | * | azimut quit (Ping timeout: 260 seconds) |
08:47:18 | * | ntat quit (Quit: Leaving) |
11:44:41 | * | xet7 joined #nim |
11:58:54 | * | krux02 joined #nim |
13:45:30 | * | rockcavera joined #nim |
13:49:18 | FromDiscord | <A2> sent a code paste, see https://play.nim-lang.org/#pasty=jWrQaGYQrytV |
13:49:31 | FromDiscord | <A2> it compiles fine, but behaves differently from what I expect at runtime |
13:50:28 | FromDiscord | <A2> I expect that the `parse_json` function might throw an exception, which might be caught by the `except Exception` block.What actually happens is that `parse_json` throws an exception, which is only caught many scopes above (inside the caller of the caller of the caller of this function) |
13:51:12 | FromDiscord | <Robyn [She/Her]> Is https://codeberg.org/pswilde/threadlogging a real solution for using a logger across multiple threads? I just wanna ask to see if I'm better off writing my own logging library or not |
13:52:19 | FromDiscord | <A2> ...it's just super weird to me that a proc tagged with `{.raises [].}` can throw exceptions at all.β΅β΅Is this a compiler bug, or am I misunderstanding something here? |
13:52:50 | * | ntat joined #nim |
13:56:48 | FromDiscord | <arnetheduck> In reply to @A2 "...it's just super weird": `raises` does not track `Defect` so YMMV when it's that kind of exception.. the code generally looks like it should do what you expect it to, so potentially what could be happening is that it's a different exception being caught than what you think |
13:57:35 | FromDiscord | <arnetheduck> ie if you try to access `value` of the Result when it has an error set, `Defect` will be raised which is not considered by `raises` |
13:57:47 | FromDiscord | <Robyn [She/Her]> That's the intended behaviour because `panics:on` exists, right? |
13:58:08 | FromDiscord | <arnetheduck> when panics:on is on, the application will terminate on first defect |
13:58:33 | FromDiscord | <arnetheduck> (edit) "defect" => "Defect" |
13:59:19 | FromDiscord | <Robyn [She/Her]> Makes sense yeah |
14:01:50 | FromDiscord | <arnetheduck> generally, for this reason, we've stopped using `except:` and `except Exception` - instead, we use `except CatchableError` (if we use exceptions at all) |
14:04:12 | FromDiscord | <Robyn [She/Her]> Understandable |
14:11:59 | FromDiscord | <odexine> it would be nice to encode that a defect cannot happen, though |
14:24:33 | FromDiscord | <A2> yeah that would be awesome |
14:25:26 | FromDiscord | <A2> I had written a bunch of code that relies on catching Exceptions and turning those into `Result`s - but now that some libraries are using Defects instead, I can't catch them, and I can't annotate that they shouldn't happen? |
14:25:51 | FromDiscord | <A2> I don't really understand these regressions.. it seems like a clear downgrade from the stuff that was doable with exceptiosn before |
14:26:05 | FromDiscord | <A2> Β―\\\_(γ)\_/Β― anyway I got some pointers on what to look out for now. hopefully I can figure out my problem |
14:27:18 | FromDiscord | <griffith1deadly> In reply to @A2 "I don't really understand": any code even without raising can raise exceptions |
14:27:28 | FromDiscord | <griffith1deadly> for example - outofmem defect |
15:12:00 | FromDiscord | <A2> yeah OOM seems unavoidable. it's just that this same code was catching my exception/defect earlier, and now it is no longer |
15:12:03 | FromDiscord | <A2> and I don't really understand why, because it bypasses the first `try: ... except Exception: ...` but is caught by a `try: ... except: ...` a few scopes further up the callstack |
15:16:29 | FromDiscord | <A2> Is it correct that a `Defect` can never be caught? If one occurs in my program, it will crash? |
15:17:15 | FromDiscord | <odexine> it "should not be caught" |
15:17:25 | FromDiscord | <odexine> it can be caught when compiled with `--panics:off` |
15:17:29 | FromDiscord | <odexine> otherwise it will crash |
15:17:44 | FromDiscord | <A2> ahh interesting- |
15:17:50 | FromDiscord | <A2> this explains the behavior of my program |
15:17:55 | FromDiscord | <A2> now i understand |
15:18:05 | NimEventer | New Nimble package! nimcso - nim Composition Space Optimization: A high-performance tool leveraging metaprogramming to implement several methods for selecting components (data dimensions) in compositional datasets, as to optimize the data availability and density for applications such as machine learning., see https://github.com/amkrajewski/nimcso |
15:18:43 | * | azimut joined #nim |
15:19:13 | FromDiscord | <A2> what types of errors should I expect to cause a Defect, rather than an Exception?β΅β΅When parsing json into some custom types of mine, I'm running into some Defects now, but I feel like I should be able to define what happens if the user input is bad? |
15:20:10 | FromDiscord | <odexine> defects are meant to represent irrecoverable errors, much like the idea of exceptions in elixir/erlang, if you're familiar |
15:21:16 | FromDiscord | <A2> elixir is still an unchecked item on my bucketlist \:) |
15:21:24 | FromDiscord | <A2> but that makes sense |
15:21:45 | FromDiscord | <A2> re\: Defects anyway |
15:21:58 | FromDiscord | <A2> I still think it's a bit weird that json parsing is considered an "irrecoverable error" |
15:22:28 | FromDiscord | <A2> I might just need to compile my program with `--panics:off` always and catch defects with `try: ... except: ...` blocks then? |
15:22:55 | FromDiscord | <A2> haha thanks for indulging me with so many newbie questions |
15:27:51 | FromDiscord | <odexine> it would be nice to know what defect you seem to have caught |
15:28:28 | FromDiscord | <odexine> In reply to @A2 "I still think it's": and its not rigorously defined what an irrecoverable error is, so some of us have different ideas of what is or isnt |
15:30:31 | FromDiscord | <A2> let me try and find the specific name of it.β΅`echo $(get_current_exception().name` should do it, right? |
15:30:36 | FromDiscord | <A2> let me try and find the specific name of it.β΅`echo $(get_current_exception().name)` should do it, right? |
15:32:10 | * | krux02_ joined #nim |
15:32:46 | * | krux02 quit (Ping timeout: 268 seconds) |
15:35:11 | FromDiscord | <arnetheduck> In reply to @A2 "I still think it's": indeed - nothing that processes user input should raise defect in a well-written program - with --linetrace:on you should get an exact location of where the defect was raised, in particular when you use --panics:on - using `except:` or `except Exception` to catch defects is a good way to introduce bugs because after a defect, the program is typically in an inconsistent state |
15:36:00 | FromDiscord | <arnetheduck> (edit) "--linetrace:on" => "`--linetrace:on --stacktrace:on`" |
15:36:12 | FromDiscord | <A2> ..which is also why I try to convert `Exceptions` to something formulated in your wonderful results library as close to the exception as I possibly can |
15:36:20 | FromDiscord | <A2> (thanks for your lib btw) |
15:37:11 | FromDiscord | <A2> I guess there is probably something else going wrong... It also seems to only happen when I invoke my compiled library from C++, and not when I run my nim-only unit tests |
15:37:34 | FromDiscord | <arnetheduck> yeah, so use the stacktrace options and --panics:on to find exactly where the exception is being raised - I don't know about parseJson - we don't use the std lib for json, but if it indeed raises a Defect that would be a bug to raise in the issue tracker |
15:37:49 | FromDiscord | <arnetheduck> (edit) "exception" => "Defect" |
15:38:47 | FromDiscord | <A2> I get a "ObjectConversionDefect" when I try to call `parse_json` on what I belive is a valid json `string` |
15:38:55 | FromDiscord | <A2> I get a "ObjectConversionDefect" when I try to call `parseJson` on what I belive is a valid json `string` |
15:39:02 | FromDiscord | <odexine> doesnt the results library have an autowrapper for exceptionable functions to result monad functions? |
15:39:05 | FromDiscord | <A2> I get a "ObjectConversionDefect" when I try to call `parseJson` on what I believe is a valid json `string` |
15:39:25 | FromDiscord | <A2> oh that sounds like a beautiful thing I didn't know about |
15:41:46 | FromDiscord | <odexine> seems like its under the template `catch` |
15:52:32 | FromDiscord | <A2> sent a code paste, see https://play.nim-lang.org/#pasty=hVmZYIffBoEH |
15:57:39 | FromDiscord | <A2> There is also something about the `json` module being backend-dependant, right? I guess switching to a pure-nim json parser might help me, when my bug seems to be backend-dependant, righ? |
15:57:41 | FromDiscord | <A2> There is also something about the `json` module being backend-dependant, right? I guess switching to a pure-nim json parser might help me, when my bug seems to be backend-dependant, right? |
15:57:44 | FromDiscord | <A2> There is also something about the `json` module being backend-dependant, right? I guess switching to a pure-nim json parser might help me, when my bug seems to be backend-dependant, maybe? |
16:07:06 | FromDiscord | <odexine> that probably means that the contents is invalid json? but thats so weird to make it a defect... |
16:08:04 | FromDiscord | <odexine> hm i dont think im right |
16:13:01 | FromDiscord | <A2> I don't understand this problem still... now I am considering just switching to treeform/jsony in the hopes that it doesn't have this bug |
16:21:50 | * | azimut quit (Ping timeout: 260 seconds) |
16:24:01 | * | azimut joined #nim |
16:24:46 | FromDiscord | <A2> yup - that's the plan. Thanks for all your help! [Robyn [She/Her]](https://matrix.to/#/%40_discord_524288464422830095%3At2bot.io) [odexine](https://matrix.to/#/%40_discord_259277943275126785%3At2bot.io) [arnetheduck](https://matrix.to/#/%40_discord_449019668296892420%3At2bot.io) π |
16:24:48 | FromDiscord | <A2> I really appreciate it. |
16:26:46 | FromDiscord | <Robyn [She/Her]> Ah I didn't really help but no worries! |
16:36:23 | FromDiscord | <m4ul3r> sent a code paste, see https://play.nim-lang.org/#pasty=QscJVxpBHUJq |
16:36:51 | FromDiscord | <m4ul3r> (edit) "https://play.nim-lang.org/#pasty=aXdDKxJYCGPi" => "https://play.nim-lang.org/#pasty=zrSrarHovatI" |
16:37:22 | FromDiscord | <odexine> sent a code paste, see https://play.nim-lang.org/#pasty=CKSZquNtzzYZ |
16:37:28 | FromDiscord | <odexine> templates need return types too |
16:37:45 | FromDiscord | <odexine> sorry i highlighted it because i thought it wouldnt be obvious but its more obvious than i thought |
16:38:13 | FromDiscord | <odexine> obvious as in visible |
16:38:53 | FromDiscord | <m4ul3r> oh yeah, im dumb |
16:39:03 | FromDiscord | <m4ul3r> I had been using some other templates that don't return anything |
16:39:17 | FromDiscord | <odexine> common error, dw about it |
16:39:33 | FromDiscord | <m4ul3r> https://tenor.com/view/cat-smooth-brain-silly-cute-gif-12951836389394006733 |
16:39:53 | FromDiscord | <odexine> yeah this channel doesnt embed links |
16:39:58 | FromDiscord | <m4ul3r> i am creature of habit i guess |
16:39:58 | FromDiscord | <odexine> i dont remember why it was set this way |
16:40:32 | FromDiscord | <m4ul3r> It must have happened after someone spamed some really NSFL stuff really late at night (US time)... |
16:41:31 | * | advesperacit quit () |
16:43:27 | FromDiscord | <Robyn [She/Her]> No it's been like this forever |
16:43:36 | FromDiscord | <Robyn [She/Her]> (edit) "No it's been like this ... forever" added "since" |
16:48:46 | FromDiscord | <m4ul3r> Maybe that was in offtopic or something |
16:49:50 | FromDiscord | <warcrime> i found a bug |
16:49:54 | FromDiscord | <warcrime> not sure if it's with linux or with nim |
16:50:11 | FromDiscord | <warcrime> but when i write the `cat` command in front of executing a cli program |
16:50:30 | FromDiscord | <warcrime> the entire CLI starts printing out random crazy characters |
16:51:12 | FromDiscord | <m4ul3r> it's expected, you're sending the actual bytes of a program to std out |
16:51:28 | FromDiscord | <m4ul3r> https://media.discordapp.net/attachments/371759389889003532/1215341057466957874/image.png?ex=65fc6590&is=65e9f090&hm=2b6a5ba27f7616632489802d329f05738a2c1418f3f86875f4ce55e305ee03f9& |
16:52:50 | FromDiscord | <warcrime> https://media.discordapp.net/attachments/371759389889003532/1215341400598511677/image.png?ex=65fc65e1&is=65e9f0e1&hm=4c49c06a429a7b0d754334c54cb59dbdee03602f150136758fe99f87901ead8e& |
16:52:55 | FromDiscord | <warcrime> i see |
16:53:30 | FromDiscord | <m4ul3r> yeah, looks normal if you do that |
16:53:37 | FromDiscord | <warcrime> i found this out when trying to grep my stdout |
16:54:48 | FromDiscord | <Robyn [She/Her]> How would a borrow checker in Nim work? Curious now |
16:56:24 | FromDiscord | <odexine> i dont even understand the question |
16:57:59 | FromDiscord | <Robyn [She/Her]> I vaguely remember something about a borrow checker in Nim being needed to do something accurately but I can't remember what |
17:28:06 | NimEventer | New thread by isaiah: A chat app please recommend necessary libraries, see https://forum.nim-lang.org/t/11175 |
17:55:18 | * | def- quit (Quit: -) |
17:56:39 | * | def- joined #nim |
18:07:00 | * | def- quit (Quit: -) |
18:10:14 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @chronos.vitaqua "How would a borrow": No God please no! |
18:26:35 | * | advesperacit joined #nim |
18:32:54 | FromDiscord | <Robyn [She/Her]> In reply to @sys64 "No God please no!": The borrow checker just checks safety and mutability rules aren't violated, imo it'd be good to have in Nim |
18:33:06 | FromDiscord | <Robyn [She/Her]> Might help prevent a segfault before it happens in prod |
18:45:35 | * | def- joined #nim |
18:46:16 | FromDiscord | <leorize> it does need to get a little smarter, though |
18:48:49 | NimEventer | New thread by isaiah: What is the nim equivalent to the python None type, see https://forum.nim-lang.org/t/11176 |
18:53:13 | * | xet7 quit (Ping timeout: 264 seconds) |
18:53:32 | * | def- quit (Read error: Connection timed out) |
18:54:38 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @chronos.vitaqua "The borrow checker just": Rust's Borrow Checker is ANNOYING |
19:02:59 | * | ntat quit (Quit: Leaving) |
19:05:11 | FromDiscord | <Robyn [She/Her]> In reply to @leorize "it does need to": Rust or Nim? |
19:05:26 | FromDiscord | <Robyn [She/Her]> In reply to @sys64 "Rust's Borrow Checker is": I mean, Nim is a lot less strict with everything so |
19:09:24 | FromDiscord | <morgan> if it's automatic, i think that would be nice |
19:09:30 | * | def- joined #nim |
19:14:36 | * | xet7 joined #nim |
19:15:48 | * | def- quit (Quit: -) |
19:22:28 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @chronos.vitaqua "I mean, Nim is": Which is a good thing |
19:43:02 | * | Lord_Nightmare quit (Quit: ZNC - http://znc.in) |
19:46:29 | * | Lord_Nightmare joined #nim |
19:51:01 | * | def- joined #nim |
19:59:45 | * | jmdaemon joined #nim |
20:03:42 | FromDiscord | <0rigami_> bro what is going on |
20:03:43 | FromDiscord | <0rigami_> https://media.discordapp.net/attachments/371759389889003532/1215389439929352272/image.png?ex=65fc929f&is=65ea1d9f&hm=107c4ed5db878c22dc41f0ab52f4720258d10801b0ec20e4a50bb5e45a7b6444& |
20:04:36 | FromDiscord | <cineration> Apparently nimble thinks I have a package installed that isn't installed, and insists on trying to find the version that's missing even though that version isn't required by anything.. How can I fix it? |
20:08:46 | FromDiscord | <0rigami_> In reply to @0rigami_ "": to be specific that happens in `config.nims` |
20:09:14 | FromDiscord | <0rigami_> sent a code paste, see https://play.nim-lang.org/#pasty=ErsghrYZdJtJ |
20:09:20 | FromDiscord | <0rigami_> (edit) "https://play.nim-lang.org/#pasty=peCBvlrEqFoA" => "https://play.nim-lang.org/#pasty=VjSWeBmqryIx" |
20:09:27 | FromDiscord | <0rigami_> (edit) "https://play.nim-lang.org/#pasty=YanUuMKfXMqe" => "https://play.nim-lang.org/#pasty=IJvZPmcjBOiu" |
20:09:42 | FromDiscord | <bosinski2023> sent a code paste, see https://play.nim-lang.org/#pasty=OjSOBvRpQSzl |
20:10:32 | * | def- quit (Quit: -) |
20:10:56 | FromDiscord | <bosinski2023> (edit) "https://play.nim-lang.org/#pasty=FnepfKAvhgpL" => "https://play.nim-lang.org/#pasty=fAdmJgcTLlHC" |
20:24:00 | * | jmdaemon quit (Ping timeout: 255 seconds) |
20:33:32 | * | def- joined #nim |
21:13:05 | FromDiscord | <guttural666> sent a code paste, see https://play.nim-lang.org/#pasty=PGkSayKfrPWG |
21:14:16 | FromDiscord | <morgan> it would be nice if there was a github wiki page comparing nim and rust like there is for c, python, java, and even d |
21:34:36 | systemdsucks | i can make one just saying nim rocks, rust sucks in no time |
21:43:03 | FromDiscord | <Elegantbeef> Just write Nim code? |
21:44:15 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=GImhkjrdFoFo |
22:18:57 | FromDiscord | <ezquerra> sent a code paste, see https://play.nim-lang.org/#pasty=aPnxrlRnXajW |
22:20:55 | FromDiscord | <Elegantbeef> `except CatchableError` |
22:21:12 | FromDiscord | <Elegantbeef> \`{.cast({.raises\: [CatchableError].})\: ... code here |
22:26:18 | FromDiscord | <Tomz_plug> sent a long message, see https://pasty.ee/brUWeMVylHUA |
22:30:15 | FromDiscord | <ezquerra> Sorry beef, I don't understand where to put that cast? |
22:30:33 | FromDiscord | <Elegantbeef> Where you have the warning |
22:40:45 | * | advesperacit quit () |
22:45:49 | FromDiscord | <ezquerra> sent a code paste, see https://play.nim-lang.org/#pasty=zACsEUeEoJQd |
22:47:29 | FromDiscord | <Elegantbeef> \`{.cast({.raises\: [CatchableError]).}\: |
22:51:57 | FromDiscord | <ezquerra> sent a code paste, see https://play.nim-lang.org/#pasty=fPFQjOQwLFJF |
22:52:11 | FromDiscord | <ezquerra> Is there somewhere in the manual that explains this? |
22:52:25 | FromDiscord | <Elegantbeef> I'm making typos like crazy but this is driving me toward wanting to take your keyboard from you |
22:52:30 | FromDiscord | <Elegantbeef> `{.cast({.raises: [CatchableError]).}:` |
22:52:31 | FromDiscord | <ezquerra> LOL |
22:52:54 | FromDiscord | <Elegantbeef> Cmon you can reason what is valid Nim syntax! |
22:53:00 | FromDiscord | <ezquerra> I don't know that you'd be able to type on my kinesis π |
22:53:28 | FromDiscord | <Elegantbeef> There are a few `{.cast....` references in here https://nim-lang.org/docs/manual.html |
22:57:16 | FromDiscord | <ezquerra> That's one of the most obscure nim syntaxes I've seen so far... |
22:57:39 | FromDiscord | <Elegantbeef> It's just pragma syntaX |
22:57:39 | FromDiscord | <Elegantbeef> x\ |
22:57:54 | FromDiscord | <ezquerra> sent a code paste, see https://play.nim-lang.org/#pasty=xSQvrMBPNoob |
22:58:11 | FromDiscord | <Elegantbeef> No it shouldnt |
22:58:17 | FromDiscord | <Elegantbeef> Cause you have an inane `{.` |
22:58:33 | FromDiscord | <Elegantbeef> Oh god I was dumb |
22:58:43 | FromDiscord | <Elegantbeef> Why the hell did i write the `{.` there and then completely miss it |
22:58:47 | FromDiscord | <Elegantbeef> I'm going to jump in a river |
22:59:13 | FromDiscord | <Elegantbeef> `{.cast(raises: [CatchableError]).}: ...` is it |
22:59:28 | FromDiscord | <Elegantbeef> Sorry for all the confusion I will send 3 snarky comments to my own brain |
23:01:49 | FromDiscord | <ezquerra> LOL, _that_ compiles _and_ removes the warning, thank you! π |
23:02:18 | FromDiscord | <ezquerra> So is that the right way to fix the original problem, then? |
23:02:30 | FromDiscord | <Elegantbeef> "right way" is a stretch it's a way |
23:02:45 | FromDiscord | <Elegantbeef> the write way would be to make `=destroy` annotated `{.raise: [].}` |
23:02:45 | FromDiscord | <ezquerra> π |
23:02:55 | FromDiscord | <Elegantbeef> But also your `=destryo` does nothing if that's a `ptr` |
23:03:03 | FromDiscord | <Elegantbeef> cause `=destroy` does nothing |
23:03:10 | FromDiscord | <Elegantbeef> on pointers |
23:03:17 | FromDiscord | <Elegantbeef> You need to iterate the collection calling destroy on each element |
23:04:30 | FromDiscord | <ezquerra> sent a code paste, see https://play.nim-lang.org/#pasty=owpjVqFYzObI |
23:04:48 | FromDiscord | <Elegantbeef> I'm saying `=destroy` should not raise |
23:04:56 | FromDiscord | <ezquerra> (edit) "https://play.nim-lang.org/#pasty=GUAOdFkGeBvn" => "https://play.nim-lang.org/#pasty=IIaszXespoGM" |
23:05:04 | FromDiscord | <Elegantbeef> All destroy's should be `{.raises: [].}` |
23:05:31 | FromDiscord | <ezquerra> I thought destroy was implicitly {.raise: [].} (according to the manual)? |
23:05:34 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=kpmsajYwZOBN |
23:05:46 | FromDiscord | <Elegantbeef> Unless you know these are some types that have no need for destructors |
23:06:15 | FromDiscord | <Elegantbeef> Leo are you actually here or did you just open your matrix client? π |
23:06:20 | FromDiscord | <ezquerra> My understanding is that this is what's storing the data of a Tensor, which is just numeric data |
23:06:30 | FromDiscord | <Elegantbeef> Playing around with mkfifo and `open` is causing a lovely Os error π |
23:07:42 | FromDiscord | <ezquerra> I actually do not know why nim assumes that `=destroy`(storage.raw_buffer) can raise a bare Exception |
23:08:05 | FromDiscord | <Elegantbeef> Cause `=destroy` was not implemented with `{.raises: [].}` so it is inferred it can raise |
23:08:11 | FromDiscord | <Elegantbeef> Generic funky stuff is fun |
23:09:06 | FromDiscord | <ezquerra> sent a code paste, see https://play.nim-lang.org/#pasty=prsJulieZBGP |
23:09:30 | FromDiscord | <Elegantbeef> Right |
23:09:32 | FromDiscord | <ezquerra> And (I think!) leaves the code I don't really understand basically untouched. I guess that's something π |
23:09:36 | FromDiscord | <Elegantbeef> It also does not emit a exception handler |
23:11:02 | FromDiscord | <ezquerra> I'm surprised that as you said `=destroy`(storage.raw_buffer) does nothing on a ptr UncheckedArray[T]. I would have expected it to do a free... |
23:15:00 | FromDiscord | <Elegantbeef> Nim does not know how it was allocated |
23:15:36 | FromDiscord | <ezquerra> OK |
23:17:23 | FromDiscord | <ezquerra> Is it true that in nim 2.0 `=destroy` will automatically set the values of the fields of the input object to their default values (which in the case of a pointer is nil)? |
23:17:55 | FromDiscord | <Elegantbeef> You say that like it's a rumour |
23:17:55 | FromDiscord | <Elegantbeef> Nope you need to use `=wasMoved` |
23:24:15 | * | def- quit (Quit: -) |
23:25:39 | FromDiscord | <ezquerra> sent a code paste, see https://play.nim-lang.org/#pasty=pxdGFVhYDDFt |
23:26:07 | FromDiscord | <ezquerra> (edit) "https://play.nim-lang.org/#pasty=sIeTCmJqdnDu" => "https://play.nim-lang.org/#pasty=PIHhjzklFWTD" |
23:26:39 | FromDiscord | <jovial_lamb_38837> hi friends, trying to extend the Dollar example for distinct types ... |
23:26:45 | FromDiscord | <Elegantbeef> `=wasMoved` |
23:26:45 | FromDiscord | <Elegantbeef> `wasMoved` zeros data |
23:27:02 | FromDiscord | <jovial_lamb_38837> sent a long message, see https://pasty.ee/jBPtaurRvOtx |
23:27:55 | FromDiscord | <jovial_lamb_38837> division works as expected, but $ is ... janky? works, but there must be a simpler elegant solution i cant find? |
23:28:19 | FromDiscord | <Elegantbeef> Why are you echoing inside `$`? |
23:29:04 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=fFDUKkhDlEJu |
23:29:05 | FromDiscord | <takemichihanagaki3129> In reply to @jovial_lamb_38837 "'''type Dollar = distinct": $ should return a string instead, I guess. |
23:29:13 | FromDiscord | <takemichihanagaki3129> sent a code paste, see https://play.nim-lang.org/#pasty=HzpZmsdWBpbo |
23:29:51 | FromDiscord | <ezquerra> So =destroy should call wasMoved(storage) at the end? |
23:29:56 | FromDiscord | <jovial_lamb_38837> lol, fair point ... I never noticed bc it works just the same with the echo in there |
23:29:58 | FromDiscord | <Elegantbeef> No |
23:30:13 | FromDiscord | <Elegantbeef> `=wasMoved` zeros memory and is called in appropriate places |
23:30:20 | FromDiscord | <Elegantbeef> All you need in `=destroy` is a `isNil` check |
23:30:26 | FromDiscord | <ezquerra> Ah, so nim calls it |
23:30:40 | FromDiscord | <Elegantbeef> It should be `=destroy` `=wasMoved` by Nim wherever needed |
23:30:49 | FromDiscord | <Elegantbeef> Or `=wasMoved` to disarm the destructor |
23:30:57 | FromDiscord | <ezquerra> OK, that makes sense |
23:31:10 | FromDiscord | <ezquerra> Thank you |
23:34:12 | NimEventer | New thread by iffy1: Subset of enum values, see https://forum.nim-lang.org/t/11177 |
23:39:49 | FromDiscord | <ezquerra> sent a code paste, see https://play.nim-lang.org/#pasty=QSopRSmzxyzE |
23:40:11 | FromDiscord | <Elegantbeef> The builtin nim `=destroy` is not annotated `{.raises: [].}` and is magic |
23:40:37 | FromDiscord | <ezquerra> But is the built-in `=destroy` defined as taking a var?? |
23:41:56 | FromDiscord | <Elegantbeef> Not in 2.0 |
23:42:44 | FromDiscord | <ezquerra> Then I don't understand why nim generates that warning here (since I'm using nim 2.0) |
23:42:55 | * | def- joined #nim |
23:43:41 | FromDiscord | <Elegantbeef> Actually it might be reverted I don't recall |
23:43:48 | FromDiscord | <Elegantbeef> Just don't worry about the warning for now |
23:50:16 | FromDiscord | <ezquerra> π― |
23:51:31 | FromDiscord | <that_dude.> In reply to @Tomz_plug "Hello sorry for bothering": <@&371760044473319454> This is still here btw |
23:51:49 | FromDiscord | <that_dude.> Thanks :) |
23:52:11 | FromDiscord | <ezquerra> OK, thank you beef! |