Bug #201
Re: [ruby-cvs:24798] Ruby:r17573 (trunk): * parse.y (primary): make functional-style not operator to act
| Status: | Closed | Start date: | ||
|---|---|---|---|---|
| Priority: | Low | Due date: | ||
| Assignee: | - | % Done: | 100% |
|
| Category: | - | |||
| Target version: | - | |||
| ruby -v: |
Description
こんにちは、なかむら(う)です。
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, <matz@ruby-lang.org> 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 <usa@garbagecollect.jp>
Associated revisions
* parse.y (primary): not operand might be empty. [ruby-dev:35227]
* parse.y (primary): empty not should call '!' on nil.
cf [ruby-dev:35227]
History
Updated by matz (Yukihiro Matsumoto) almost 4 years ago
まつもと ゆきひろです
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" <usa@garbagecollect.jp> writes:
|遠藤さんに教えてもらったのですが、この変更で
| not()
|がパースエラーになるようになっています(従来はtrueを返す)。
おおっ。気がつかなかった。
|修正してみました。
っていうか、純粋にliteral trueでいいんじゃないですかね。
Updated by matz (Yukihiro Matsumoto) almost 4 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
Applied in changeset r17574.
Updated by usa (Usaku NAKAMURA) almost 4 years ago
こんにちは、なかむら(う)です。
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, <matz@ruby-lang.org> 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 <usa@garbagecollect.jp>
Updated by matz (Yukihiro Matsumoto) almost 4 years ago
まつもと ゆきひろです
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" <usa@garbagecollect.jp> 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で構わないのではないかと思ってしまいま
す。
Updated by usa (Usaku NAKAMURA) almost 4 years ago
こんにちは、なかむら(う)です。
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, <matz@ruby-lang.org> 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 <usa@garbagecollect.jp>