[#20036] Re: Roundoff problem with Float and Marshal — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

16 messages 2003/04/18
[#20045] Re: Roundoff problem with Float and Marshal — nobu.nakada@... 2003/04/20

なかだです。

[#20063] Re: Roundoff problem with Float and Marshal — matz@... (Yukihiro Matsumoto) 2003/04/22

まつもと ゆきひろです

[#20097] jcode.rb — akira yamada / やまだあきら <akira@...>

25 messages 2003/04/26
[#20098] Re: jcode.rb — matz@... (Yukihiro Matsumoto) 2003/04/27

まつもと ゆきひろです

[#20105] Re: jcode.rb — WATANABE Hirofumi <eban@...> 2003/04/28

わたなべです。

[#20108] Re: jcode.rb — matz@... (Yukihiro Matsumoto) 2003/04/28

まつもと ゆきひろです

[ruby-dev:20124] Re: jcode.rb

From: WATANABE Hirofumi <eban@...>
Date: 2003-04-30 15:00:34 UTC
List: ruby-dev #20124
わたなべです。

Shin-ichiro HARA <sinara@blade.nagaokaut.ac.jp> writes:

> import-module では、こんなふうに使います:
> 
>   require 'import-module'
>   require 'jstring_2'
>   $KCODE='e'
>   
>   str1 = 'あいうえお'
>   str2 = 'あいうえお'
>   
>   str1.import(JString) do
>     p str1[2] # => "う"
>     p str2[2] # => 164
>     p str1.chop #=> "あいうえ"
>     p str2.chop #=> "あいうえ\244"
>     str2.import(JString) do
>       p str1[2] # => "う"
>       p str2[2] # => "う"
>       p str1.chop #=> "あいうえ"
>       p str2.chop #=> "あいうえ"
>     end
>   end
>   p str1.import(JString){|s| s[2]} #=> "う"
>   p str1[2] # => 164
>   p str1.import(JString){str1.chop} #=> "あいうえ"
>   p str2.chop #=> "あいうえ\244"
>   
> これは今の jstring_2.rb でも動いています。

これを動かすと

% ruby test-jstring_2.rb
./jstring_2.rb:77: warning: character class has `]' without escape
./jstring_2.rb:77: warning: character class has `[' without escape
./jstring_2.rb:77: warning: character class has `]' without escape
./jstring_2.rb:77: warning: character class has `[' without escape
"う"
164
test-jstring_2.rb:11: private method `chop' called for "あいうえお":String (NoMethodError)
        from test-jstring_2.rb:8:in `import'
        from /usr/local/lib/ruby/site_ruby/1.8/import-module.rb:407:in `import_module'
        from /usr/local/lib/ruby/site_ruby/1.8/import-module.rb:407:in `import'
        from test-jstring_2.rb:8

とエラーになってしまいます。
import-moduleは最新と思われる0.77を、Rubyは
  ruby 1.8.0 (2003-04-27) [i386-linux]
  ruby 1.6.8 (2003-04-20) [i386-linux]
を使ってます。
原因はrb_define_global_function化してる所為かな。

実はimport-moduleも試したんですが、エラーになったので、

> >|原先生のimport-moduleでもできると思いますが、
> >|どちらか標準にならないかなあ。

とあいまいにごまかしたのでした。

> 石塚さんの scope-in-state は、もうちょっと大規模なシステムの
> 変更も念頭にあって、手軽さでは import-module かな。

そうなんですよね。newしないで使えるからお手軽でimport-module
のほうが好みなんですが。

-- 
わたなべひろふみ

In This Thread