FizzyOrange

joined 11 months ago
[–] [email protected] 1 points 5 days ago

I dunno, does it even need a new feature? Kind of feels like Rust should be able to figure it out as long as the lambdas aren't moved/stored/etc?

[–] [email protected] 5 points 5 days ago (12 children)

Sorry that example was a bit too limited to demonstrate the problem actually. Add a second lambda and you hit the issue:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=eb99d3d670bdd9d92006f4672444d611

Still totally fine from a safety point of view, but the borrow checker can't figure that out.

[–] [email protected] 9 points 5 days ago (14 children)

I disagree. It's a sign your code isn't structured in a way that the borrow checker understands, but that is a subset of well-structured code.

In other words, if your code nicely fits with the borrow checker then it's likely well structured, but the inverse is not necessarily true.

One thing I always run into is using lambdas to reduce code duplication within a function. For example writing a RLE encoder:

fn encode(data: &[u8]) -> Vec<u8> {
  let mut out = Vec::new();

  let mut repeat_count = 0;

  let mut output_repeat = || {
     out.push(... repeat_count ...);
  };

  for d in data {
      output_repeat();
      ...
  }
  output_repeat();
  out
}

This is a pretty common pattern where you have a "pending" thing and need to resolve it in the loop and after the loop. In C++ you can easily use lambdas like this to avoid duplication.

Doesn't work in Rust though even though it's totally fine, because the borrow checker isn't smart enough. Instead I always end up defining inline functions and explicitly passing the parameters (&mut out) in. It's much less ergonomic.

(If anyone has any better ideas how to solve this problem btw I'm all ears - I've never heard anyone even mention this issue in Rust.)

[–] [email protected] 9 points 5 days ago (4 children)

only access secrets from environment variables

I kind of think this is a bad idea because environment variables can be read from anywhere and aren't designed to be secret.

But I'm not sure what a better solution is tbh.

[–] [email protected] 4 points 5 days ago

Matthias Wandel has a video on this is YouTube. He didn't talk about it they keyboard is any good though which I think is probably the most important thing.

[–] [email protected] 3 points 6 days ago

I’m an old 31yo man. These fora are getting to complex. Back in my day we had bulletin board systems.

Lol bullshit. BBSs were completely obsolete by like 1997 when you were 4.

[–] [email protected] 1 points 1 week ago

I mean... You're probably going to run the code in the repo eventually anyway right? At least in the majority of cases. Tbh I don't think it really changes the threat model significantly.

[–] [email protected] 10 points 1 week ago (1 children)

I never did a CS degree but recently I've been doing some things that make me wish I had. But it isn't any of this stuff which seems mostly programming things that you can easily learn outside academia.

The stuff I would like to understand which I haven't yet been able to learn on my own is the hard computer sciency stuff: lambda calculus, type inference (how do you read that weird judgement syntax?), how SAT/SMT solvers work, dependent typing systems... Does anyone have any good resources for those sorts of things?

[–] [email protected] 6 points 1 week ago (4 children)

I haven't used one, but my guess would be they're fine if you're a "web browsing and email" sort, but most of us here probably aren't, and then you're going to have pain when you need to install some tool that expects to be installed globally, because so many pieces of open source software assume the "spew files all over /usr" installation method.

Feels like you'd be spending a lot of time fighting expectations in the same way that Nix has to.

[–] [email protected] 2 points 1 week ago

Thanks for finally being explicit about the kind of person you are.

As if wokeness isn't a thing 🙄

[–] [email protected] 3 points 1 week ago (2 children)

You seem to be giving a lot more leeway to interpretations of Peters’ words than my comparison. Odd.

It doesn't require any leeway. It's a totally mainstream opinion supported by actual research. It's only in woke CoC teams that comments like that are objectionable.

he’s also dismissing that it’s worthwhile to try and have an environment free from sexual harassment.

Complete misunderstanding of his comment. Read it again.

Gracefully accepting constructive criticism.

Lol the irony is overpowering.

[–] [email protected] 3 points 1 week ago (4 children)

If you "made light of sexual harassment training" at your job like this you would be fired?

And I lost count of how many times an executive at a startup I’ve worked for was charged with sexual harassment. The outcome was always the same: nothing actually happened to them, but the entire company was sentenced to days of “sexual harassment prevention” training, as part of the deal the bigwig cut to get off easy. By now I must be one of the most highly trained people on Earth in that specialty :wink:.

Jesus you should leave now! That's not ok. (At least in countries with proper labour laws; I guess in America they can fire you for anything.)

I mean I wouldn't advise writing that on your company Slack, but nowhere I have ever worked would fire you for it.

In any case the Python community isn't a company & as far as I understand it Peters isn't getting paid.

view more: ‹ prev next ›