From b5d9cbe8e8bb5c0eb826ce68a81aa5579359b5e8 Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 20 Jul 2006 17:30:01 +0000 Subject: [PATCH] * object.c (rb_mod_attr): make Module#attr to be an alias to attr_reader. [RCR#331] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ object.c | 60 ++++++++++++++++++------------------------------------- 2 files changed, 24 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index 42f65f9c8f..d4147286c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jul 20 20:27:07 2006 Yukihiro Matsumoto + + * object.c (rb_mod_attr): make Module#attr to be an alias to + attr_reader. [RCR#331] + Thu Jul 20 15:07:14 2006 Yukihiro Matsumoto * ruby.h: export classes/modules to implement sandbox. diff --git a/object.c b/object.c index 9ede440c53..0a02e0f7f9 100644 --- a/object.c +++ b/object.c @@ -1513,45 +1513,10 @@ rb_to_id(VALUE name) return id; } -/* - * call-seq: - * attr(symbol, writable=false) => nil - * - * Defines a named attribute for this module, where the name is - * symbol.id2name, creating an instance variable - * (@name) and a corresponding access method to read it. - * If the optional writable argument is true, also - * creates a method called name= to set the attribute. - * - * module Mod - * attr :size, true - * end - * - * is equivalent to: - * - * module Mod - * def size - * @size - * end - * def size=(val) - * @size = val - * end - * end - */ - -static VALUE -rb_mod_attr(int argc, VALUE *argv, VALUE klass) -{ - VALUE name, pub; - - rb_scan_args(argc, argv, "11", &name, &pub); - rb_attr(klass, rb_to_id(name), 1, RTEST(pub), Qtrue); - return Qnil; -} - /* * call-seq: * attr_reader(symbol, ...) => nil + * attr(symbol, ...) => nil * * Creates instance variables and corresponding methods that return the * value of each instance variable. Equivalent to calling @@ -1564,11 +1529,22 @@ rb_mod_attr_reader(int argc, VALUE *argv, VALUE klass) int i; for (i=0; i nil @@ -1583,7 +1559,7 @@ rb_mod_attr_writer(int argc, VALUE *argv, VALUE klass) int i; for (i=0; i nil * - * Equivalent to calling ``attrsymbol, - * true'' on each symbol in turn. + * Defines a named attribute for this module, where the name is + * symbol.id2name, creating an instance variable + * (@name) and a corresponding access method to read it. + * Also creates a method called name= to set the attribute. * * module Mod * attr_accessor(:one, :two) @@ -1607,7 +1585,7 @@ rb_mod_attr_accessor(int argc, VALUE *argv, VALUE klass) int i; for (i=0; i