[#35631] [Ruby 1.9 - Bug #4558][Open] TestSocket#test_closed_read fails after r31230 — Tomoyuki Chikanaga <redmine@...>

23 messages 2011/04/06

[#35632] [Ruby 1.9 - Bug #4559][Open] Proc#== does not match the documented behaviour — Adam Prescott <redmine@...>

13 messages 2011/04/06

[#35637] [Ruby 1.9 - Bug #4561][Open] 1.9.2 requires parentheses around argument of method call in an array, where 1.8.7 did not — Dave Schweisguth <redmine@...>

9 messages 2011/04/07

[#35734] [Ruby 1.9 - Feature #4574][Open] Numeric#within — redmine@...

16 messages 2011/04/13

[#35753] [Ruby 1.9 - Bug #4576][Open] Range#step miss the last value, if end-exclusive and has float number — redmine@...

61 messages 2011/04/14
[#39566] [Ruby 1.9 - Bug #4576] Range#step miss the last value, if end-exclusive and has float number — Marc-Andre Lafortune <ruby-core@...> 2011/09/15

[#39590] [Ruby 1.9 - Bug #4576] Range#step miss the last value, if end-exclusive and has float number — Marc-Andre Lafortune <ruby-core@...> 2011/09/16

[#39593] Re: [Ruby 1.9 - Bug #4576] Range#step miss the last value, if end-exclusive and has float number — Tanaka Akira <akr@...> 2011/09/16

2011/9/17 Marc-Andre Lafortune <[email protected]>:

[#39608] Re: [Ruby 1.9 - Bug #4576] Range#step miss the last value, if end-exclusive and has float number — Masahiro TANAKA <masa16.tanaka@...> 2011/09/17

I have not been watching ruby-core, but let me give a comment for this issu=

[#35765] [Ruby 1.9 - Bug #4579][Open] SecureRandom + OpenSSL may repeat with fork — redmine@...

27 messages 2011/04/15

[#35866] [Ruby 1.9 - Bug #4603][Open] lib/csv.rb: when the :encoding parameter is not provided, the encoding of CSV data is treated as ASCII-8BIT — yu nobuoka <nobuoka@...>

13 messages 2011/04/24

[#35879] [Ruby 1.9 - Bug #4610][Open] Proc#curry behavior is inconsistent with lambdas containing default argument values — Joshua Ballanco <jballanc@...>

11 messages 2011/04/25

[#35883] [Ruby 1.9 - Bug #4611][Open] [BUG] Segementation fault reported — Deryl Doucette <me@...>

15 messages 2011/04/25

[#35895] [Ruby 1.9 - Feature #4614][Open] [RFC/PATCH] thread_pthread.c: lower RUBY_STACK_MIN_LIMIT to 64K — Eric Wong <normalperson@...>

10 messages 2011/04/25

[ruby-core:35904] Re: [Ruby 1.9 - Feature #4610] Proc#curry behavior is inconsistent with lambdas containing default argument values

From: Yusuke ENDOH <mame@...>
Date: 2011-04-26 11:57:59 UTC
List: ruby-core #35904
Hello,

2011/4/26 Joshua Ballanco <[email protected]>:
> Regarding the consistency argument, as I understand Currying (or at least=
 the way that it is implemented in most other languages), the result of a P=
roc#curry call should be a chain of Proc's with arity 1 that return Proc's =
with arity 1 until all arguments have been satisfied. It would be nice if R=
uby behaved similarly.

How should Ruby handle *rest parameter?

  proc {|x, y, z, *rest| }.curry.(1).(2).(3).(4).(5)... ?


> For example, in OCaml (which auto-curries functions):

If you quote OCaml, you should note that Ocaml also provides
optional arguments.
Actually, OCaml handles optional arguments as Ruby does.
IOW, OCaml function also fires as soon as all the required
arguments are given:


  # let foo ?(a=3D"ichi") ?(b=3D"ni") ?(c=3D"san") () =3D
      print_endline (S(String.concat ", " [a; b; c]);;
  val foo : ?a:string -> ?b:string -> ?c:string -> unit -> unit =3D <fun>
  # foo ();;
  ichi, ni, san
  - : unit =3D ()
  # foo ~a:"first" ();;
  first, ni, san
  - : unit =3D ()
  # foo ~a:"first" ~b:"second" ();;
  first, second, san
  - : unit =3D ()
  # foo ~a:"first" ~b:"second" ~c:"third" ();;
  first, second, third
  - : unit =3D ()


There are some differences between OCaml and Ruby:

  - OCaml function requires at least one mandatory argument.
    (In this case, () is the only mandatory argument.)

  - Optional arguments always requires labels (=3D keywords).


I believe your concern (and #4601) will be solved by keyword
arguments.

  def foo(a:"ichi", b:"ni", c:"san")
    puts "#{ a }, #{ b }, #{ c }"
  end

  foo(b:"second")  #=3D> ichi, second, san

  method(:foo).curry.
    pass_option(a: "first").
    pass_option(b: "second").
    pass_option(c: "third").
    call()  #=3D> first, second, third

Unfortunately, a new method (Proc#pass_option) is needed
because Proc#call(key: val) passes a hash { key =3D> val } as
a normal argument, unless we accept the incompatibility.


The future of keyword arguments is promised by matz
[ruby-core:32131]:

> Keyword arguments will be available on 2.0.

--=20
Yusuke Endoh <[email protected]>

In This Thread