[#42194] Enhancing Numeric#step — "Akinori MUSHA" <knu@...>

 Numeric#step の仕様の拡張を提案します。

26 messages 2010/09/08
[#42196] Re: Enhancing Numeric#step — Yukihiro Matsumoto <matz@...> 2010/09/08

まつもと ゆきひろです

[#42200] Re: Enhancing Numeric#step — "Akinori MUSHA" <knu@...> 2010/09/08

At Wed, 8 Sep 2010 22:46:57 +0900,

[#42204] Re: Enhancing Numeric#step — Yukihiro Matsumoto <matz@...> 2010/09/09

まつもと ゆきひろです

[#42232] 1.9.2 readline can't handle cursorkeys, mbcs chars etc (msvcrt) — arton <artonx@...>

artonです。

11 messages 2010/09/10

[#42269] [Ruby 1.9-Bug#3836] Kernel.system, spawnがスペースを含むパスで動作しない — Hiroki Najima <redmine@...>

チケット #3836 が更新されました。 (by Hiroki Najima)

12 messages 2010/09/16
[#42270] WindowsでのKernel.systemの挙動、一貫性について — NAJIMA Hiroki <h.najima@...> 2010/09/16

名島(Nazy)と申します。

[#42310] ビジースレッドがあるとコンテキストスイッチが起きづらくなる — kuwamoto shintaro <beuniv@...>

こんにちは。

9 messages 2010/09/29
[#42315] [bug:trunk] ビジースレッドがあるとコンテキストスイッチが起きづらくなる — "U.Nakamura" <usa@...> 2010/09/30

こんにちは、なかむら(う)です。

[ruby-dev:42307] Re: Introducing "rb_scan_keyword_args()" (was Re: Re: Enhancing Numeric#step)

From: Yukihiro Matsumoto <matz@...>
Date: 2010-09-29 07:10:27 UTC
List: ruby-dev #42307
まつもと ゆきひろです

In message "Re: [ruby-dev:42305] Re: Introducing "rb_scan_keyword_args()" (was Re:  Re: Enhancing Numeric#step)"
    on Wed, 29 Sep 2010 11:21:09 +0900, "Akinori MUSHA" <knu@iDaemons.org> writes:

| もうだいぶ経つので後ほど入れようと思います。以下のようなAPIです。

いれることそのものには反対ではないんですが、

|num-of-mandatory-args          := DIGIT ; The number of mandatory
|                                        ; keywords
|
|sym-for-capture                := "*"   ; Indicates that all the
|                                        ; keywords that are not on the
|                                        ; list should be captured as a
|                                        ; ruby hash.
|sym-for-raise                  := "!"   ; Indicates that an
|                                        ; ArgumentError should be
|                                        ; raised if any keyword that
|                                        ; are not on the list is given.
|sym-for-warning                := ""    ; Indicates that a soft warning
|                                        ; should be emitted raised if
|                                        ; any keyword that are not on
|                                        ; the list is given.

この辺の文法は好みではありません。

引数をシンボルにしたのでこのようになっているのだと思いますが、
個人的には

 * シンボルでなく文字列
 * 文字列末尾に:がついていたらoptional
   または文字列末尾に!がついていたらmandatory
 * "*" があれば残りがハッシュとして渡る
 * "*" が指定されていなければ例外
 * soft warningはなし

を考えていました。あと関数名はrb_scan_keyword_argsじゃなくて、
rb_keyword_argsがいいかなあ。

|  /*
|   * The keywords <x> and <y> are mandatory, and <color> is optional;
|   * If any other keyword arguments are given, an ArgumentError is raised.
|   */
|  rb_scan_keyword_args(opt, "2!",
|                       rb_intern("x"), &x, rb_intern("y"), &y,
|                       rb_intern("color"), &color, NULL);

は

  rb_scan_keyword_args(opt,
                       "x", &x, "y", &y,
                       "color:", &color, NULL);

となり、

|  /*
|   * The keywords <x> and <y> are mandatory, and <color> is optional;
|   * If other keyword arguments are given, they are packed into a hash
|   * and assigned to the variable rest.
|   */
|  rb_scan_keyword_args(opt, "2*",
|                       rb_intern("x"), &x, rb_intern("y"), &y,
|                       rb_intern("color"), &color, NULL, &rest);

  rb_scan_keyword_args(opt, 
                       "x", &x, "y", &y,
                       "color:", &color, "*", &rest, NULL);

|  /* Unknown parameters can just be dropped by passing a NULL. */
|  rb_scan_keyword_args(opt, "2*",
|                       rb_intern("x"), &x, rb_intern("y"), &y,
|                       rb_intern("color"), &color, NULL, NULL);

  rb_scan_keyword_args(opt, 
                       "x", &x, "y", &y,
                       "color:", &color, "*", NULL, NULL);

|  /*
|   * The keywords <x>, <y>, and <color> are all optional;
|   * If any other keyword arguments are given, a soft warning (only
|   * reported in verbose mode) is emitted.
|   */
|  rb_scan_keyword_args(opt, "0",
|                       rb_intern("x"), &x, rb_intern("y"), &y,
|                       rb_intern("color"), &color, NULL);
|

  rb_scan_keyword_args(opt,
                       "x:", &x, "y:", &y,
                       "color:", &color, NULL);

というのを考えていました。

                                まつもと ゆきひろ /:|)

In This Thread