News for hackers. Stuff that matters.
Re:Open-sourcing Sorbet: a fast, powerful type checker for Ruby by hartator on Thursday June 20, 2019 @03:37PM (#20236524)
Awesome work.

    sig {params(person: Person).returns(Integer)}
    def name_length(person)
Not sure if I dig the syntax. Furthermore arguments seems to be the official names for method arguments, not parameters. eg, `ArgumentError`. `params` also feels like it's linked to Rails `params` variable in controllers. It can be confusing.

Something like this will also feel more Rubyist:

    def name_length person: Person, return: Integer
But it probably requires a deeper hack or a change in MRI.
Re:Open-sourcing Sorbet: a fast, powerful type checker for Ruby by ptarjan on Thursday June 20, 2019 @03:42PM (#20236582)
Thanks for the idea.

We used `params` because Method#parameters was what they called it in the standard library. I actually had it as `args` originally until someone pointed this out. https://ruby-doc.org/core-2.6.3/Method.html#method-i-paramet...

As for the syntax change, we are actually on our 8th iteration of the syntax. We really wanted this to NOT be a fork of Ruby so finding something compatible was very important. For example that's why it has the weird `sig {` syntax too, we didn't want to have to cause load-time and cyclic dependencies from adding type signatures.

Re:Open-sourcing Sorbet: a fast, powerful type checker for Ruby by hartator on Thursday June 20, 2019 @03:47PM (#20236624)
> We used `params` because Method#parameters was what they called it in the standard library

Super interesting. We should probably have being consistent for naming parameters vs. arguments in stdlib. It's too late though!

Re:Open-sourcing Sorbet: a fast, powerful type checker for Ruby by steveklabnik on Thursday June 20, 2019 @03:59PM (#20236733)
On a super pedantic level, "parameters" are the names that you write in the function definition, and "arguments" are the values you pass as parameters.

  def name_length(person)

  steve = Person.new
  name_length(steve)
Here, 'person' is a parameter, and 'steve' is an argument.

Most programmers use them interchangeably.

Re:Open-sourcing Sorbet: a fast, powerful type checker for Ruby by learc83 on Thursday June 20, 2019 @04:07PM (#20236804)
We called those 2 terms "formal parameters", and "actual parameters" if I remember my programming language concepts class from college correctly.
Re:Open-sourcing Sorbet: a fast, powerful type checker for Ruby by sdegutis on Thursday June 20, 2019 @04:21PM (#20236931)
I've never been to programming college but in 10 years I have always heard them as def(parameters) and call(arguments). Probably a lot of that was when reading about how VMs and compilers work, though.
Re:Open-sourcing Sorbet: a fast, powerful type checker for Ruby by matharmin on Thursday June 20, 2019 @03:56PM (#20236715)
I'm not sure how consistent it is with everything in Ruby, but parameters is technically the correct term here. A parameter is a variable definition, while an argument is the value that is passed to the parameter.

ArgumentError is still consistent with this definition (it's an error with the value you passed, not with the definition). However, params in a Rails controller does violate this definition.

Re:Open-sourcing Sorbet: a fast, powerful type checker for Ruby by lloeki on Thursday June 20, 2019 @04:49PM (#20237209)
Different levels of abstraction/concerns. Params in Rails come from HTTP params i.e the conceptual merge between GET query strings and POST body (e.g forms, but also JSON).
Re:Open-sourcing Sorbet: a fast, powerful type checker for Ruby by kazinator on Thursday June 20, 2019 @04:58PM (#20237308)
In computer science, "formal parameters" is the name for those named variables that are established on entry into the function and immediately receive external values. "arguments" are the values that they receive. A function has only one set of parameters, but a new set of arguments in each invocation.
Re:Open-sourcing Sorbet: a fast, powerful type checker for Ruby by kentor on Thursday June 20, 2019 @03:56PM (#20236716)
My view is you define methods with parameters, you call methods with arguments.

`ArgumentError` is consistent with an error during call time.

Re:Open-sourcing Sorbet: a fast, powerful type checker for Ruby by ljm on Thursday June 20, 2019 @04:19PM (#20236911)
That might work in .rbi files because they could be parsed independently of Ruby itself (basically giving Ruby the C-style header+impl split).

As far as ruby goes, though, it would conflict with keyword arguments.

Re:Open-sourcing Sorbet: a fast, powerful type checker for Ruby by pbiggar on Thursday June 20, 2019 @04:24PM (#20236958)
Dont know if this applies, but my understanding is that in functions, a parameter is the name of a declaration which when called will receive an argument.