Arguing about arguments

Here’s some Rust code:

// define a function
fn foo(x: i32, y: i32) -> i32 {
    // body elided
}
// call it
let z = foo(5, 6);

In programming language jargon, we call x and y parameters and 5 and 6 arguments.

Rust does not have many fancy features related to parameters and arguments. But other languages do. For example, here’s a function in Ruby, another language I’ve written a ton of:

# its definition in Rails
def redirect_to(options = {}, response_options = {})
  # body elided
end
# you can call it in all of these ways:
# pass a string with a URL
redirect_to "http://www.rubyonrails.org"
# pass an instance of a model to go to it, if post.id = 5 then this might go to
# "/posts/5"
redirect_to @post
# invoke an action directly, might be equivalent to the above in a Posts controller
redirect_to action: "show", id: 5
# redirect to a model's URL, passing a flash message
redirect_to post_url(@post), alert: "Watch it, mister!"
# do the same but also set a specific HTTP code
redirect_to post_url(@post), status: :found
# do both
redirect_to post_url(@post), status: 301, flash: { updated_post_id: @post.id }