[#42169] [Ruby 1.9-Bug#3781][Open] FIBER_USE_NATIVE が有効だと落ちるスクリプトがある — Makoto Kishimoto <redmine@...>
Bug #3781: FIBER_USE_NATIVE が有効だと落ちるスクリプトがある
5 messages
2010/09/01
[#42188] [Ruby-Bug#3794][Open] test/openssl/test_ssl.rb hungs on mswin32_100 — Akio Tajima <redmine@...>
Bug #3794: test/openssl/test_ssl.rb hungs on mswin32_100
8 messages
2010/09/06
[#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
まつもと ゆきひろです
[#42207] Re: Enhancing Numeric#step
— "Akinori MUSHA" <knu@...>
2010/09/09
At Thu, 9 Sep 2010 09:59:45 +0900,
[#42237] Introducing "rb_scan_keyword_args()" (was Re: Re: Enhancing Numeric#step)
— "Akinori MUSHA" <knu@...>
2010/09/12
At Thu, 9 Sep 2010 09:59:45 +0900,
[#42244] Re: Introducing "rb_scan_keyword_args()" (was Re: Re: Enhancing Numeric#step)
— "Akinori MUSHA" <knu@...>
2010/09/13
At Sun, 12 Sep 2010 19:51:21 +0900,
[#42305] Re: Introducing "rb_scan_keyword_args()" (was Re: Re: Enhancing Numeric#step)
— "Akinori MUSHA" <knu@...>
2010/09/29
At Mon, 13 Sep 2010 12:48:37 +0900,
[#42307] Re: Introducing "rb_scan_keyword_args()" (was Re: Re: Enhancing Numeric#step)
— Yukihiro Matsumoto <matz@...>
2010/09/29
まつもと ゆきひろです
[#42308] Re: Introducing "rb_scan_keyword_args()" (was Re: Re: Enhancing Numeric#step)
— "Akinori MUSHA" <knu@...>
2010/09/29
At Wed, 29 Sep 2010 16:10:27 +0900,
[#42312] Re: Introducing "rb_scan_keyword_args()" (was Re: Re: Enhancing Numeric#step)
— Yukihiro Matsumoto <matz@...>
2010/09/29
まつもと ゆきひろです
[#42318] Re: Introducing "rb_scan_keyword_args()" (was Re: Re: Enhancing Numeric#step)
— "Akinori MUSHA" <knu@...>
2010/09/30
At Wed, 29 Sep 2010 23:43:47 +0900,
[#42232] 1.9.2 readline can't handle cursorkeys, mbcs chars etc (msvcrt) — arton <artonx@...>
artonです。
11 messages
2010/09/10
[#42233] Re: 1.9.2 readline can't handle cursorkeys, mbcs chars etc (msvcrt)
— Yukihiro Matsumoto <matz@...>
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)と申します。
[#42274] Re: WindowsでのKernel.systemの挙動、一貫性について
— "U.Nakamura" <usa@...>
2010/09/21
こんにちは、なかむら(う)です。
[#42276] Re: WindowsでのKernel.systemの挙動、一貫性について
— NAJIMA Hiroki <h.najima@...>
2010/09/21
名島(Nazy)です。
[#42277] Re: WindowsでのKernel.systemの挙動、一貫性について
— NAJIMA Hiroki <h.najima@...>
2010/09/21
名島(Nazy)です。
[#42310] ビジースレッドがあるとコンテキストスイッチが起きづらくなる — kuwamoto shintaro <beuniv@...>
こんにちは。
9 messages
2010/09/29
[#42315] [bug:trunk] ビジースレッドがあるとコンテキストスイッチが起きづらくなる
— "U.Nakamura" <usa@...>
2010/09/30
こんにちは、なかむら(う)です。
[ruby-dev:42305] Re: Introducing "rb_scan_keyword_args()" (was Re: Re: Enhancing Numeric#step)
From:
"Akinori MUSHA" <knu@...>
Date:
2010-09-29 02:21:09 UTC
List:
ruby-dev #42305
At Mon, 13 Sep 2010 12:48:37 +0900,
I wrote:
> At Sun, 12 Sep 2010 19:51:21 +0900,
> I wrote:
> > At Thu, 9 Sep 2010 09:59:45 +0900,
> > matz wrote:
> > > でキーワード辞書を取れたり、
> > >
> > > rb_scan_keywords(kw, "by", &step, "to", &limit, NULL);
> > >
> > > で、キーワード辞書を分解したりするようなAPIはどうだろうかと
> > > 考えています。
> >
> > 少し考えてから、 rb_scan_keyword_args() というものを設計・実装
> > してみました。仕様は以下の差分中に(日本語も)あるので見てみて
> > ください。
> >
> > 改良点として、 fmt の頭に ':' を置くと、キーワード名として
> > const char * でなく ID を取るという機能を付けると、何度も呼び
> > 出されることを考慮して効率のために rb_intern() の結果を取って
> > おくようなところでも使えるのかなと思っています。
>
> rb_intern() 程度の手間は強いてもいいかなと思ったので、IDを取る
> ようにしました。(パッチは省きます)
もうだいぶ経つので後ほど入れようと思います。以下のようなAPIです。
=begin
rb_scan_keyword_args(VALUE hash, const char *fmt, ...)
Retrieve keyword arguments from hash (Qnil is allowed and treated the
same as empty hash) according to the format string and an arbitrary
number of pairs of a keyword's ID and a VALUE reference that follow,
terminated by a single occurrence of NULL. Another VALUE reference
may be put after the NULL, to which unlisted keyword arguments are
captured in a hash.
The format can be described in ABNF as follows:
--
scan-kw-arg-spec := [num-of-mandatory-args] how-to-deal-with-unlisted-spec
how-to-deal-with-unlisted-spec := sym-for-capture / sym-for-raise / sym-for-warn
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.
Typical usage of this function is as follows:
/*
* 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);
/*
* 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);
/* 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);
/*
* 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);
For each optional keyword arguments that are not given, the
corresponding VALUE reference is set to Qundef unlike rb_scan_args()
which sets Qnil. This is because in rb_scan_args() distinction
between nil and unspecified can be made by checking argc but in
rb_scan_keyword_args() there is no concept of argc where hash is
unordered.
If you want to settle more than nine mandatory keyword arguments,
split up the retrieval into several steps, i.e. retrieve the first
nine arguments with "9*", apply "9*" to the captured rest to retrieve
the next nine, and so on.
=end
--
Akinori MUSHA / http://akinori.org/