• 2 Posts
  • 134 Comments
Joined 1 year ago
cake
Cake day: July 31st, 2023

help-circle


  • If somebody goes and causes an outage, I would expect nothing less than a tech walking around and trying to triangulate the offending router.

    But in OP’s case, it’s an external ISP that provides internet services to the dorm. As long as nobody gives them a reason to start looking, I don’t expect a for-profit ISP to be sending out a contractor proactively beyond the first week of move-ins. That costs them money, and likely a lot more money than they would recover by catching the handful of people trying to dogde the per-device upcharge.




  • You shall not use or attempt to use a device or software (such as NAT, Address Masquerading, Proxying, or the connection of an additional wireless router) that would allow you to connect more than the number of devices set out in the Service Information to the Network.

    One of the ways they detect this is by checking the TTL of the packets coming from the “one” device is less than expected. If your router is using OpenWrt, you can configure an iptables rule to reset the TTL of outgoing packets to the default.



  • There’s no suitable metaphor for ad blocking IRL

    Sure there is.

    Every week, your community puts on an old movie in the town park that everyone can watch for free. You, an avid movie enjoyer, watch this movie every week.

    But, the movie equipment isn’t free. To make this event happen, the community accepts a donation from The Church of Microwaving Babies and Kicking Puppies. In exchange, the Church of Microwaving Babies and Kicking Puppies pauses the movie every 50 minutes and puts on a small two-minute presentation about why you should consider joining and what puppy-kicking can do to improve your life.

    You don’t care. You do not agree with their views, and you definitely are never going to join. Instead of paying attention to their mandatory presentation, you stare at your phone and read Lemmy. Then, when the movie is back on, you once again pay attention.

    That’s ad-blocking. Some group gains revenue from their publicly available service by having an advertiser peddle their crap through said service. You take an active role in ignoring said crap, while most people just sit there twiddling their thumbs and pretending to care. The only tangible difference between you ignoring the ad while it plays and you blocking it is 60 seconds of your time and the bandwidth required to serve the ad.

    Advertisers don’t like it—but fuck the advertisers. The difference that you as an individual makes in how much money is made through advertising is less than a hundredth of a cent. If the impact of the collective using adblockers is enough to be an issue in sustainability, then advertising was not the correct business model to begin with.



  • That’s not the point, though. The point is to use a nominal type that asserts an invariant and make it impossible to create an instance of said type which violates the invariant.

    Both validation functions and refinement types put the onus on the caller to ensure they’re not passing invalid data around, but only refinement types can guarantee it. Humans are fallible, and it’s easy to accidentally forget to put a check_if_valid() function somewhere or assume that some function earlier in the call stack did it for you.

    With smart constructors and refinement types, the developer literally can’t pass an unvalidated type downstream by accident.


  • You’re going to need to cite that.

    I’m not familiar with C23 or many of the compiler-specific extensions, but in all the previous versions I worked with, there is no type visibility other than “fully exposed” or opaque and dangerous (void*).

    You could try wrapping your Foo in

    typedef struct {
        Foo validated
    } ValidFoo;
    

    But nothing stops someone from being an idiot about it and constructing it by hand:

    ValidFoo trustMeBro;
    trustMeBro.validated = someFoo;
    otherFunction(trustMeBro);
    

    Or even just casting it.

    Foo* someFoo;
    otherFunction((ValidFoo*) someFoo);
    

  • If it were poorly designed and used exceptions, yes. The correct way to design smart constructors is to not actually use a constructor directly but instead use a static method that forces the caller to handle both cases (or explicitly ignore the failure case). The static method would have a return type that either indicates “success and here’s the refined type” or “error and this is why.”

    In Rust terminology, that would be a Result<T, Error>.

    For Go, it would be (*RefinedType, error) (where dereferencing the first value without checking it would be at your own peril).

    C++ would look similar to Rust, but it doesn’t come as part of the standard library last I checked.

    C doesn’t have the language-level features to be able to do this. You can’t make a refined type that’s accessible as a type while also making it impossible to construct arbitrarily.


  • Unless you’re a functional programming purist or coming from a systems programming background, it takes a lot longer than a few days to get used to the borrow checker. If you’re coming as someone who most often uses garbage-collected languages, it’s even worse.

    The problem isn’t so much understanding what the compiler is bitching about, as it is understanding why the paradigm you used isn’t safe and learning how to structure your code differently. That part takes the longest and only really starts to become easier when you learn to stop fighting the language.




  • The first directory block is a hole. But type == DIRENT, so no error is reported. After that, we get a directory block without ‘.’ and ‘…’ but with a valid dentry. This may cause some code that relies on dot or dotdot (such as make_indexed_dir()) to crash

    The problem isn’t that the block is a hole. It’s that the downstream function expects the directory block to contain . and .., and it gets given one without because of incorrect error handling.

    You can encode the invariant of “has dot and dot dot” using a refinement type and smart constructor. The refined type would be a directory block with a guarantee it meets that invariant, and an instance of it could only be created through a function that validates the invariant. If the invariant is met, you get the refined type. If it isn’t, you only get an error.

    This doesn’t work in C, but in languages with stricter type systems, refinement types are a huge advantage.