Project

General

Profile

Actions

Bug #201

closed

Re: [ruby-cvs:24798] Ruby:r17573 (trunk): * parse.y (primary): make functional-style not operator to act

Added by usa (Usaku NAKAMURA) almost 16 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
Backport:
[ruby-dev:35227]

Description

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

In message "[ruby-cvs:24798] Ruby:r17573 (trunk): * parse.y (primary): make functional-style not operator to act"
on Jun.25,2008 21:55:48, wrote:

matz 2008-06-25 21:55:47 +0900 (Wed, 25 Jun 2008)

New Revision: 17573
(snip)
Log:
* parse.y (primary): make functional-style not operator to act
like function. see http://d.hatena.ne.jp/ku-ma-me/20080624/p1.

遠藤さんに教えてもらったのですが、この変更で
not()
がパースエラーになるようになっています(従来はtrueを返す)。

修正してみました。

Index: parse.y

--- parse.y (revision 17573)
+++ parse.y (working copy)
@@ -2621,6 +2621,14 @@ primary : literal
$$ = dispatch2(unary, ripper_intern("not"), $3);
%*/
}

  •  | keyword_not '(' rparen
    
  •      {
    
  •      /*%%%*/
    
  •  	$$ = call_uni_op(cond(NEW_NIL()), '!');
    
  •      /*%
    
  •  	$$ = dispatch2(unary, ripper_intern("not"), Qnil);
    
  •      %*/
    
  •      }
     | operation brace_block
         {
         /*%%%*/
    


それでは。

U.Nakamura
=end

Actions #1

Updated by matz (Yukihiro Matsumoto) almost 16 years ago

=begin
まつもと ゆきひろです

In message "Re: [ruby-dev:35227] [Bug:trunk] Re: [ruby-cvs:24798] Ruby:r17573 (trunk): * parse.y (primary): make functional-style not operator to act"
on Wed, 25 Jun 2008 22:33:26 +0900, "U.Nakamura" writes:

|遠藤さんに教えてもらったのですが、この変更で
| not()
|がパースエラーになるようになっています(従来はtrueを返す)。

おおっ。気がつかなかった。

|修正してみました。

っていうか、純粋にliteral trueでいいんじゃないですかね。

=end

Actions #2

Updated by matz (Yukihiro Matsumoto) almost 16 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r17574.
=end

Actions #3

Updated by usa (Usaku NAKAMURA) almost 16 years ago

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

In message "[ruby-dev:35231] Re: [Bug:trunk] Re: [ruby-cvs:24798] Ruby:r17573 (trunk): * parse.y (primary): make functional-style not operator to act"
on Jun.26,2008 00:41:43, wrote:

|修正してみました。

っていうか、純粋にliteral trueでいいんじゃないですかね。

昔ならそれでもよかったんでしょうけど、今や!は再定義できるので、
私のパッチと今のtrunkだと、

% ruby-mypatch -e 'def nil.!; false; end; p not()'
false
% ruby-trunk -e 'def nil.!; false; end; p not()'
true

という違いが発生します。

それでは。

U.Nakamura

=end

Actions #4

Updated by matz (Yukihiro Matsumoto) almost 16 years ago

=begin
まつもと ゆきひろです

In message "Re: [ruby-dev:35237] Re: [Bug:trunk] Re: [ruby-cvs:24798] Ruby:r17573 (trunk): * parse.y (primary): make functional-style not operator to act"
on Thu, 26 Jun 2008 09:12:32 +0900, "U.Nakamura" writes:

|> っていうか、純粋にliteral trueでいいんじゃないですかね。
|
|昔ならそれでもよかったんでしょうけど、今や!は再定義できるので、
|私のパッチと今のtrunkだと、
|
| % ruby-mypatch -e 'def nil.!; false; end; p not()'
| false
| % ruby-trunk -e 'def nil.!; false; end; p not()'
| true
|
|という違いが発生します。

それはそうですが、not()がnot(nil)と等しいということは自明では
ないので、trueならtrueで構わないのではないかと思ってしまいま
す。

=end

Actions #5

Updated by usa (Usaku NAKAMURA) almost 16 years ago

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

In message "[ruby-dev:35245] Re: [Bug:trunk] Re: [ruby-cvs:24798] Ruby:r17573 (trunk): * parse.y (primary): make functional-style not operator to act"
on Jun.26,2008 16:02:09, wrote:

|> っていうか、純粋にliteral trueでいいんじゃないですかね。
|
|昔ならそれでもよかったんでしょうけど、今や!は再定義できるので、
|私のパッチと今のtrunkだと、
|
| % ruby-mypatch -e 'def nil.!; false; end; p not()'
| false
| % ruby-trunk -e 'def nil.!; false; end; p not()'
| true
|
|という違いが発生します。

それはそうですが、not()がnot(nil)と等しいということは自明では
ないので、trueならtrueで構わないのではないかと思ってしまいま
す。

え、自明じゃないんですか?
()はnilになりますから、not()が(not nil)と等しいのは当然な気が
するのですが...

どっちかというと()がnilになるのが私には自明じゃなかったんです
が、0.95からそうだったらしいのでそれはそういうもんかなと思っ
ています。

それでは。

U.Nakamura

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0