• 26 Posts
  • 1.99K Comments
Joined 6 years ago
cake
Cake day: May 31st, 2020

help-circle
  • Where I typically notice it, is that the text starts repeating a few handful of points.

    The prompt will have been to write a story on those points, and because it doesn’t have much else to go off of, it will just shoehorn those exact points again and again.

    I expect this to always be a telltale sign, because if your point can be made in the length of the prompt, there’s a rather limited amount of noise it can add to that before it would have to go off-script.


  • My problem was that “Albert Heijn” is a dude’s name. It does not exactly scream “we’re talking about a real physical building”.

    For all I knew, the impossible problem we’re solving could’ve been on a mathematical plane, named after mathematician Albert Heijn. “Sweeping” just as well can be used in an abstract sense.

    Obviously, I did think of physically sweeping a physical floor first and foremost, but especially with the rest of the blog post being so entirely abstract, I had doubts on that for far too long, which did not make it easier to understand.











  • In many cases, you don’t need an equivalent to finally, because the cleanup is automatically handled via the Drop trait, which runs cleanup code when the object is freed from memory (similar to “destructors” in some other languages).
    Because of Rust’s whole ownership thingamabob, it’s generally entirely deterministic when this code will run (at the closing brace for the scope in which the object is defined, unless you pass that object outside of that scope).

    In other cases, you don’t need a finally, because nothing forces you to bubble up errors instantly. You can make a call which fails, store the error in a variable, run your cleanup steps and then return the error at the end of you function.

    Sometimes, however, you do want to bubble up errors right away (via ? or early return), typically so you can group them together and handle them all the same.
    In that case, you can run the cleanup code in the calling function. If you don’t to want to make it the responsibility of the caller, then pull out a small function within your function, so that you become the caller of that small function and can do the cleanup steps at the end of your function, while you do the bubbling within the smaller function.
    There’s also ways to make that less invasive via closures (which also serve as a boundary to which you can bubble errors), but those are somewhat complex in Rust, due to the whole ownership thingamabob.

    I will say, I do sometimes feel like Rust could use a better way to handle doing something before the error bubbles up. But generally speaking, I don’t feel like a finally is missing.


  • You can use the anyhow crate for something quite similar to exceptions: https://crates.io/crates/anyhow

    In terms of how it actually fits into Rust, you want to use anyhow for application code. If you’re writing a library, then anyhow is a no-go, because users cannot match on different error classes with it. (Much like you would want custom exception classes, so that users can catch them in different catch branches and handle them differently.)

    Every so often, you will also need matchable error classes within your application code, then you would have to replace anyhow with a custom error type there, too, of course.

    I will also say, IMHO it is fine to use anyhow even while you’re learning Rust. It is so easy that you kind of skip learning error handling, which you will need to learn at some point, but you can still do that when you actually need it.





  • Ephera@lemmy.mltoNo Stupid Questions@lemmy.worldIs ice heavier than water?
    link
    fedilink
    English
    arrow-up
    14
    arrow-down
    2
    ·
    edit-2
    6 days ago

    Ackshually, gram is a measurement of mass, not of weight. And because a gram of ice takes up more volume than a gram of water, it is likely to float on top of the water, where it is slightly further away from the center of gravity, therefore experiencing less strong gravity. As such, a gram of ice likely weighs less than a gram of water. :P

    (I spent far too long thinking how I could torpedo that silly joke of yours, because I figured there must be something with mass vs. weight there. 🫠)


  • Haha wow, my initial thought after reading your post was “signatures went away”, but then I figured I’m biased towards that being significant, because I recently was on an ancient forum that still had them.

    So, instead I tried to formulate the more abstract development. I had read about it a long time ago, so I did not pull that whole comment out of my arse just then, thankfully.

    But that it is then precisely signatures which elicit a reaction, that’s hilarious. 😅

    And yeah, I do not miss signatures. Within minutes of reading on that forum, I had grown a disdain for some users, because they’d respond with half a sentence and then a distracting GIF in their signature. And of course, they would respond multiple times to a topic, so you could get 10+ instances of that same GIF on one page.

    Unfortunately, this does mean I now need to demonstrate that by including a shitty signature:


    I’m not a signature, I just clean here. GIF of an emoticon wiping the floor.

    The supreme art of war is to subdue the enemy without fighting. ~ Sun Tzu

    Flashy GIF of some anime character blasting a gun towards the viewer. Don't ask me what it is, I literally just searched for "forum signature gif".


  • Not sure, I can articulate this thought well enough, but I feel like there’s been a split between “personal” and “impersonal” social media.

    Early internet forums were usually about some specific topic and pseudonyms were paramount, but each person was still given room to present themselves.
    So, what I mean by that, is that forum posts had signatures, big profile pictures, as well as typically some additional information about the user, like “Rank: Lord Supreme – Joined: March 2005 – Posts: 3 trillion”.
    The forums generally weren’t focused on the people, but you still knew the regulars.

    Then came Facebook, Twitter, Instagram, Mastodon etc., which put people into the focus. You were discouraged from using pseudonyms. You were encouraged to post pictures of yourself. You were encouraged to broadcast any random thought you had.
    And while you can use these networks to read or talk about certain topics, you’re really supposed to follow people and get to know them.

    And then, sort of as a counter movement again, you have your “link aggregators”, i.e. Lemmy, Lobsters, Reddit etc…
    Discussions only happen when there’s a topic, i.e. a post, to talk about. You can’t just broadcast thoughts without context, but rather have to sort them into specific topics/communities.
    And while there’s a tiny profile picture next to posts and we do have some regulars that are more widely recognized, most users are not.