[#636] doc/NEWS — Matt Armstrong <matt@...>

22 messages 2002/12/15

Re: [patch] doc/NEWS

From: nobu.nokada@...
Date: 2002-12-16 17:35:03 UTC
List: ruby-core #648
Hi,

At Mon, 16 Dec 2002 23:01:14 +0900,
Yukihiro Matsumoto wrote:
> |If an assignment method which doesn't return an argument is not
> |intuitive, why don't ruby force it?
> 
> Agreed.  Last time I thought that, I was too lazy to modify compiler
> itself, and then forgot.  I will fix it someday.

Is it better to define NODE_ASGN?


Index: eval.c
===================================================================
RCS file: /cvs/ruby/src/ruby/eval.c,v
retrieving revision 1.360
diff -u -2 -p -r1.360 eval.c
--- eval.c	15 Dec 2002 03:18:04 -0000	1.360
+++ eval.c	16 Dec 2002 17:22:15 -0000
@@ -2745,5 +2745,5 @@ rb_eval(self, n)
       case NODE_CALL:
 	{
-	    VALUE recv;
+	    VALUE recv, val;
 	    int argc; VALUE *argv; /* used in SETUP_ARGS */
 	    TMP_PROTECT;
@@ -2755,5 +2755,7 @@ rb_eval(self, n)
 
 	    SET_CURRENT_SOURCE();
-	    result = rb_call(CLASS_OF(recv),recv,node->nd_mid,argc,argv,0);
+	    val = rb_call(CLASS_OF(recv),recv,node->nd_mid,argc,argv,0);
+	    if (rb_is_attrset_id(node->nd_mid)) val = argv[argc-1];
+	    result = val;
 	}
 	break;
Index: intern.h
===================================================================
RCS file: /cvs/ruby/src/ruby/intern.h,v
retrieving revision 1.103
diff -u -2 -p -r1.103 intern.h
--- intern.h	10 Dec 2002 06:23:39 -0000	1.103
+++ intern.h	16 Dec 2002 17:22:15 -0000
@@ -303,4 +303,5 @@ void rb_gc_mark_parser _((void));
 int rb_is_const_id _((ID));
 int rb_is_instance_id _((ID));
+int rb_is_attrset_id _((ID));
 int rb_is_class_id _((ID));
 int rb_is_local_id _((ID));
Index: parse.y
===================================================================
RCS file: /cvs/ruby/src/ruby/parse.y,v
retrieving revision 1.232
diff -u -2 -p -r1.232 parse.y
--- parse.y	16 Dec 2002 06:56:33 -0000	1.232
+++ parse.y	16 Dec 2002 17:22:16 -0000
@@ -5677,4 +5677,12 @@ rb_is_instance_id(id)
 
 int
+rb_is_attrset_id(id)
+    ID id;
+{
+    if (is_attrset_id(id)) return Qtrue;
+    return Qfalse;
+}
+
+int
 rb_is_local_id(id)
     ID id;


-- 
Nobu Nakada

In This Thread