Most active commenters

    ←back to thread

    611 points LorenDB | 13 comments | | HN request time: 0.54s | source | bottom
    1. jsat ◴[] No.43908667[source]
    I see an article about how strict typing is better, but what would really be nice here is named parameters. I never want to go back to anonymous parameters.
    replies(3): >>43908741 #>>43908994 #>>43909858 #
    2. kelnos ◴[] No.43908741[source]
    Yes, this is one of the few things that I think was a big mistake in Rust's language design. I used to do a lot of Scala, and really liked named parameters there.

    I suppose it could still be added in the future; there are probably several syntax options that would be fully backward-compatible, without even needing a new Rust edition.

    replies(1): >>43913577 #
    3. codedokode ◴[] No.43908994[source]
    When there are 3-4 parameters it is too much trouble to write the names.
    replies(2): >>43909925 #>>43910187 #
    4. sophacles ◴[] No.43909858[source]
    Why? In 2025 we have tooling available for most every editor that will annotate that information into the display without needing them present in the file. When I autocomplete a function name, all the parameters are there for me to fill in, and annotated into the display afterwards. It seems like an unnecessary step to reify it and force the bytes to be present in the the saved file.
    replies(1): >>43914868 #
    5. noitpmeder ◴[] No.43909925[source]
    Not OP, but I imagine he's arguing for something like python's optional named arguments.
    6. bsder ◴[] No.43910187[source]
    > When there are 3-4 parameters it is too much trouble to write the names.

    Sorry, I don't agree.

    First, code is read far more often than written. The few seconds it takes to type out the arguments are paid again and again each time you have to read it.

    Second, this is one of the few things that autocomplete is really good at.

    Third, almost everybody configures their IDE to display the names anyway. So, you might as well put them into the source code so people reading the code without an IDE gain the benefit, too.

    Finally, yes, they are redundant. That's the point. If the upstream changes something and renames the argument without changing the type I probably want to review it anyway.

    replies(2): >>43913742 #>>43922634 #
    7. quietbritishjim ◴[] No.43913577[source]
    I suppose the sense it is backwards incompatible is that library authors have named their parameters without intended to make them part of the public interface that they commit to maintaining. Perhaps it could be made backwards compatible by being opt in function declarations but that would seem like a bit of a pain.
    8. monkeyelite ◴[] No.43913742{3}[source]
    Making something longer doesn’t make it easier to read, especially in repetition.
    replies(1): >>43922571 #
    9. skywhopper ◴[] No.43914868[source]
    So those editors could just insert the names for you. The bytes in the source file are not a serious concern, are they?
    10. int_19h ◴[] No.43922571{4}[source]
    Making something explicit does.
    replies(1): >>43952190 #
    11. int_19h ◴[] No.43922634{3}[source]
    They aren't even necessarily redundant. If you have argument names as part of the function name, they can be overloaded on - and this is much more readable than type-based overloading because it's all explicit. Swift uses this to great effect, e.g. here are some different ways to construct a string:

       String(repeating: "foo", count: 42);
    
       String(cString: zeroTerminatedBuffer); 
    
       String(42, radix: 16);
    
       String(contentsOfFile: "foo.txt", encoding: .utf8);
    replies(1): >>43923215 #
    12. bsder ◴[] No.43923215{4}[source]
    Oooh. Nice. I forgot about the Smalltalk / ObjC / Swift usage of keywords for messages.
    13. monkeyelite ◴[] No.43952190{5}[source]
    Would it be better if you wrote out the type of every variable every time you used it? That would be more explicit.