[#23332] to_str再考 — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

15 messages 2004/04/05

[#23380] [SEGV] make test-all (bccwin32 ruby1.9.0) — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>

山本です。

17 messages 2004/04/15
[#23400] Re: [SEGV] make test-all (bccwin32 ruby1.9.0) — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2004/04/16

山本です。落ちる場所がわかりました。

[#23402] Re: [SEGV] make test-all (bccwin32 ruby1.9.0) — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2004/04/16

山本です。

[#23403] Re: [SEGV] make test-all (bccwin32 ruby1.9.0) — nobu.nakada@... 2004/04/16

なかだです。

[#23405] Re: [SEGV] make test-all (bccwin32 ruby1.9.0) — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2004/04/16

山本です。

[#23407] Re: [SEGV] make test-all (bccwin32 ruby1.9.0) — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2004/04/16

山本です。

[ruby-dev:23299] Re: English alias

From: Minero Aoki <aamine@...>
Date: 2004-04-01 13:11:17 UTC
List: ruby-dev #23299
青木です。

  In mail "[ruby-dev:23225] Re: English alias"
    matz@ruby-lang.org (Yukihiro Matsumoto) wrote:

> まつもと ゆきひろです

> ちゅーか、ものによってそれぞれだと思います。そもそもグローバ
> ルな状態が望ましくないものも多いですし。私の記憶が正しければ、
> $<記号>変数のほとんどにはすでに代替手段を用意していると思い
> ます。だから、むしろ警告を出すようにすればよいのではないかと。

ruby-dev summary のついでに状況を調べました。

    変数名     推奨されるアクセサ

    $!         rescue => err
    $"         ?
    $$         Process.pid
    $~         Regexp.last_match
    $&         Regexp.last_match[0]
    $`         Regexp.last_match.pre_match
    $'         Regexp.last_match.post_match
    $+         Regexp.last_match[-1]
    $*         ARGV
    $?         Process.waitpid2(pid)[1]
    $@         rescue => err; err.backtrace
    $/         (obsolete?)
    $\         (obsolete?)
    $0         ?
    $1,$2...   Regexp.last_match[n]
    $:         $LOAD_PATH
    $;         (obsolete?)
    $<         ARGF
    $=         (obsolete)
    $>         $stdout (1.8), $defout (1.6)
    $,         (obsolete?)
    $-a,...    ?
    $.         ARGF.lineno

このように、$" $0 $-a, $-c ... の代替手段がないようです。
$-a 系統はちょっと厄介なので、とりあえず $" ($LOADED_FEATURES)
と $0 ($PROGRAM_NAME) についてだけでも alias を組み込みにしては
どうでしょうか。将来よりよいアクセサを用意するにしても、警告の
出ない移行パスがあったほうがよいと思います。
-------------------------------------------------------------------
青木峰郎

Index: lib/English.rb
===================================================================
RCS file: /src/ruby/lib/English.rb,v
retrieving revision 1.4
diff -u -r1.4 English.rb
--- lib/English.rb	20 Jan 2004 05:04:13 -0000	1.4
+++ lib/English.rb	1 Apr 2004 13:02:30 -0000
@@ -24,9 +24,6 @@
 # exception. <tt>See Kernel.caller</tt> for details. Thread local.
 alias $ERROR_POSITION          $@
 
-# An array containing the filenames of modules loaded by +require+.
-alias $LOADED_FEATURES         $"
-
 # The default separator pattern used by <tt>String.split</tt>.  May be
 # set from the command line using the <tt>-F</tt> flag.
 alias $FS                      $;
@@ -129,12 +126,6 @@
 # will be case insensitive, string comparisons will ignore case, and
 # string hash values will be case insensitive. Deprecated
 alias $IGNORECASE              $=
-
-# The name of the top-level Ruby program being executed.  Typically
-# this will be the program's filename. On some operating systems,
-# assigning to this variable will change the name of the process
-# reported (for example) by the <tt>ps(1)</tt> command.
-alias $PROGRAM_NAME            $0
 
 # An array of strings containing the command-line
 # options from the invocation of the program. Options
Index: eval.c
===================================================================
RCS file: /src/ruby/eval.c,v
retrieving revision 1.651
diff -u -r1.651 eval.c
--- eval.c	30 Mar 2004 09:19:06 -0000	1.651
+++ eval.c	1 Apr 2004 12:58:48 -0000
@@ -7643,6 +7643,7 @@
 
     rb_features = rb_ary_new();
     rb_define_readonly_variable("$\"", &rb_features);
+    rb_define_readonly_variable("$LOADED_FEATURES", &rb_features);
 
     rb_define_global_function("load", rb_f_load, -1);
     rb_define_global_function("require", rb_f_require, 1);
Index: ruby.c
===================================================================
RCS file: /src/ruby/ruby.c,v
retrieving revision 1.89
diff -u -r1.89 ruby.c
--- ruby.c	12 Mar 2004 11:19:21 -0000	1.89
+++ ruby.c	1 Apr 2004 13:02:30 -0000
@@ -1081,6 +1081,7 @@
     rb_define_readonly_variable("$-l", &do_line);
 
     rb_define_hooked_variable("$0", &rb_progname, 0, set_arg0);
+    rb_define_hooked_variable("$PROGRAM_NAME", &rb_progname, 0, set_arg0);
 
     rb_argv = rb_ary_new();
     rb_define_readonly_variable("$*", &rb_argv);

In This Thread