1. 40
  1.  

  2. 12

    Anyone else liked the labelled arguments? I liked how they added expressivity to the code without looking hackish, and I think It was a clever idea to make the label different from the parameter name

    1. 6

      Thank you! All credit goes to the clever people who designed Swift. We went through quite a few different designs but it turned out that copying Swift was best.

      1. 4

        well, this predates Swift by ages — this style of labeled args came to Swift directly from Objective-C :)

        1. 4

          I meant specifically the syntax here, but yes! We’re certainly standing on the shoulders of giants

          1. 4

            This predates objective-c by ages. It came to objective-c from Smalltalk.

        2. 3

          I didn’t get it at first, but took a second look upon reading your comment. They’re really nice! I can see it being useful to have both labels and arguments when you’d refer to those parameters while calling the method versus executing the method. Correct me if I’m wrong, but you could use it like this in pseudo code:

          pub fn run_job(at time) {
            if (time == now) execute(job_id)
          }
          
          run_job(at: 2020-01-01)
          

          I’ve had “cute” code in Ruby where I’d have arguments named at or in which is nice when calling the method, but not as nice in the body of the method. That’s a really neat feature.

          1. 2

            Yes, exactly, It reads really well from both outside and inside.

          2. 1

            Too bad default values and random ordering didn’t make it.

            1. 5

              When using labelled arguments random ordering is supported, and default values may come later :)

          3. 4

            Theoretically a case expression can match on up to 16,777,215 values. If you need to match on more values than this please let me know because wow, I wanna know what your code is doing.

            Wow, not web scale!

            1. 0

              Anyone else liked the labelled arguments? I liked how they added expressivity to the code without looking hackish, and I think It was a clever idea to make the label different from the parameter name

              1. 0

                Anyone else liked the labelled arguments? I liked how they added expressivity to the code without looking hackish, and I think It was a clever idea to make the label different from the parameter name