• 21 Posts
  • 164 Comments
Joined 6 months ago
cake
Cake day: December 31st, 2023

help-circle

  • I’m sure there are a bunch of patterns that emerge out of this (anyone with some wisdom here?) …

    The classical one is something that looks like the following:

    struct LoggedOut;
    struct User {name: String};
    struct Admin {name: String};
    
    impl LoggedOut {
      fn login(self, name: String, password: String) -> User {
        User { name }
      }
      fn admin_login(self, name: String) -> Admin {
        Admin { name }
      }
    }
    
    impl User {
      fn log_out(self) -> LoggedOut {
        LoggedOut {}
      }
    }
    
    impl Admin {
      fn log_out(self) -> LoggedOut {
        LoggedOut {}
      }
    }
    
    fn fetch_user_preferences(user: User) { /*...*/ }
    
    fn do_admin_action(admin_account: Admin) { /* ... */ }
    
    fn main() {
      let mut user_session = LoggedOut {};
      /* (get user input) */
      match input {
        "login" => {
            user_session = user_session.login(name, password);
        }
        "admin" => {
           user_session = user_session.admin_login(name);
        }
      }
    }
    

    This would prevent you from writing code that uses the user’s info / session “object” after they have logged out (and/or before they have logged in). On its own it’s naive and a bit encumbering - I expect an enum would make more sense but then you can’t restrict via types which user session values can and can’t be passed to specific functions. In any case, when you are building a whole system around it it can be very useful to have the compiler enforcing these sorts of things “in the background”.

    This is basically what Gary Bernhardt is talking about in the talk you linked.


  • I want to highlight one of the more subtle-yet-important clarifications made in these 2 chapters: associated functions vs methods, and how method calls are just syntactic sugar for function calls.

    Unlike in many other languages, there is no formal distinction (e.g. via separate keywords) between methods vs constructors vs property getters. The first parameter as well as the return type determine if a given associated function is “actually” a constructor or a method (etc.).

    Personally, I find this incredibly elegant; it’s a form of “less is more” that gets out of my way when I’m coding while still allowing me to use all of the existing patterns that I know from elsewhere.








  • I just got back from a trip to a substantially less developed country, and really living in a country, even for a little bit, where I could see how many lives that money could improve, all being poured down the Microsoft Fabric drain, it just grinds my gears like you wouldn’t believe. I swear to God, I am going to study, write, network, and otherwise apply force to the problem until those resources are going to a place where they’ll accomplish something for society instead of some grinning clown’s wallet.

    Amen. We always need more insiders who are ready to take up the cause of not doing stupid shit with the ungodly accumulation of resources our society has permitted, especially when we are currently leaving so much of the world to play catch-up while we continue to leech them dry.






  • Not necessarily cash, but definitely a bit of luck. Some lawyers, if they think a case is guaranteed to go your way, will do the work for free in exchange for receiving a portion of the damages the final judgement will award you. Even rarer, some lawyers care enough about some issues on a personal level that they’ll work for free, or reduced rates, on certain cases.

    In this case, I’m not sure there are any damages whatsoever to award to OP - a “win” is forcing the company to abide by the GPL, not pay up money. The EFF and the FSF, as others have brought up, are probably the best bet to find lawyers that would work on this case for the outcome instead of the pay.


  • Tout comme a une époque les portugais et polonais n’étaient pas blancs au meme titre que les français “de souche”, la déclinaison politique et sociale des “races” s’adapte avec le temps et aux besoins de ceux au pouvoir (et notamment des que les anciennes limites entre “races” deviennent un rapport de force trop perdant).

    Le discours du RN c’est clairement “on se permet de faire payer aux non-francais tout ce qu’il faudra pour nous mettre bien”. D’où slogans comme “preference nationale” (tiens donc ca ressemble drôlement a “socialisme national”). C’est de ca dont @[email protected] parle quant il évoque le pacte raciale. Donc tes cohabitants qui votent a 55% pour le RN avec en tête “tant pis pour les autres, au moins on va s’occuper de moi” s’inscrivent dedans, peu importe leur couleur de peau ou leurs "origines’. Et il faut soit être ignorant, soit avoir ca en tête pour voter RN aujourd’hui.