all 26 comments

sorted by: hot top controversial new old
[–] 57 points 3 years ago (1 child)

int unused_variable = 0;

Dude wtf is your problem don’t just leave things lying about there don’t you know how to code I mean what the- I don’t go to your house and leave shit on the floor and just—

int _unused_variable = 0;

Ok. We cool.

  • source
  • hideshow 1 child comment
  • [–] 1 point 2 years ago

    sometimes you need an unused variable. some uses in rust:

    // destructuring
    let (width, _height) = get_dimensions();
    
    // trait implementations (i couldnt think of a better example for this)
    impl Into for AlwaysZero {
        fn into(_value: Self) -> {
            return 0;
        }
    }
    
    // some types (eg. Result) must be 'used'
    // assigned to a variable if we dont care about the return value
    let _ = returns_result("foo");
    
  • source
  • parent
  • [–] 49 points 3 years ago (4 children)

    mfw my face when the go compiler fucking screams at me because I dared to declare a variable and not use it

  • source
  • hideshow 4 child comments
  • [–] 11 points 3 years ago (1 child)

    "Don't worry too much about your loops bro, I am the apex of computer science research, I know every optimization in the book." Ok want to compile this? "Is that... An unused variable?!? WHAT THE FUCK ARE WE GOING TO DO GOD IS DEAD"

  • source
  • parent
  • hideshow 1 child comment
  • [–] 29 points 3 years ago* (1 child)

    I am guilty of passing Exception variables into try catches and not using them

  • source
  • hideshow 1 child comment
  • [–] 13 points 3 years ago (4 children)

    Function is changing a global variable, the global variable is checked after every call to the function. That's your return value.

  • source
  • hideshow 4 child comments
  • [–] 9 points 3 years ago (7 children)
  • [–] [S] 8 points 3 years ago (6 children)

    I would love to use golang for this but it’s standard library alone is bigger than the amount of available RAM.

  • source
  • parent
  • hideshow 6 child comments
  • [–] 2 points 3 years ago (2 children)

    Interesting, since golang only includes the parts of the stdlib that are used in the executable binary.

  • source
  • parent
  • hideshow 2 child comments
  • [–] [S] 4 points 3 years ago (1 child)

    I just tested it and a simple hello world program still produces a 1.7MiB binary, while the device only has 512KiB of RAM.

    package main
    
    import "fmt"
    
    func main() {
        fmt.Println("hello world")
    }
    
  • source
  • parent
  • hideshow 1 child comment
  • [–] 1 point 3 years ago (2 children)

    BTW: what are you using instead to get small binaries/scripts?

  • source
  • parent
  • hideshow 2 child comments
  • [+] 6 points 3 years ago
    [–] 1 point 3 years ago

    Idk, mb they expected you to modify smth passed by reference/pointer, and the compiler's too busy to care :)

  • source
  • [–] -2 points 3 years ago (1 child)

    Ok, you are certainly in one of those languages where plenty of your functions shouldn't return a value, and you won't ever let the compiler know that.

    On all of the other languages, it's an error, not even a warning.

  • source
  • hideshow 1 child comment