[#17480] Array#fill behavior — "Vladimir Sizikov" <vsizikov@...>
Hi,
[#17488] HOME and USERPROFILE aliasing under Windows — "John Lam (IRONRUBY)" <jflam@...>
MRI currently expects the HOME environment variable to be set under Windows=
[#17491] [Ruby 1.8.7 - Bug #213] (Open) Different ERB behavior across versions — Federico Builes <redmine@...>
Issue #213 has been reported by Federico Builes.
[#17503] Possible misbehaviour in mkmf.rb package — S駻gio Durigan J佖ior <sergiodj@...>
Hello all,
On Wednesday 02 July 2008, S駻gio Durigan J佖ior wrote:
[#17509] YAML in Ruby — Trans <transfire@...>
Might we ever imagine a time when YAML is an integral part of Ruby?
[#17518] [Ruby 1.8 - Bug #216] (Open) Memory leaks in 1.8.6p230 and p238 — Igal Koshevoy <redmine@...>
Issue #216 has been reported by Igal Koshevoy.
[#17566] rubychecker - runs checks on a Ruby interpreter — Igal Koshevoy <igal@...>
I've put together a shell script that runs checks on a Ruby interpreter.
Why not write it in ruby?
Kurt Stephens wrote:
I've split up the code of rubychecker. One git repo has the GNU Bash
[#17574] rubyspec reports for ruby_1_8, ruby_1_8_7, and v1_8_6_p265 — Stephen Bannasch <stephen.bannasch@...>
I wanted to learn more about specs recently started using git and so
Stephen Bannasch wrote:
[#17595] Crashes and hangups on latest 1_8 branch — "Vladimir Sizikov" <vsizikov@...>
Hi,
[#17609] [PATCH] Fix Makefile update-rubyspec task — Gaston Ramos <ramos.gaston@...>
Hi, I'm trying to run rubyspec tests on 1.8 branch and get this error:
[#17615] [PATCH] ruby-mode.el: Fix here-doc strings with inner quotes — Nathan Weizenbaum <nex342@...>
At the moment, ruby-mode.el uses font-lock-keywords as opposed to
It was designed to fix the following case:
Here's a third patch that fixes a bug in the second and uses a quicker
One more patch which fixes a few bugs in the the last one.
Hi,
Looks like version 22 doesn't support explicitly numbered regexp groups.
Hi,
Hi,
Alright, here's a version that fixes both the highlighting bug and the
Hi,
Are you asking me? If so, go right ahead. Also, for posterity's sake,
One more bugfix.
Hi,
[#17627] ncurses-specific functions in ruby's curses — "Kirill A. Shutemov" <kirill@...>
Is it possible to add ncurses-specific functions to curses ruby module?
On Sunday 06 July 2008, Kirill A. Shutemov wrote:
On Mon, Jul 07, 2008 at 10:25:42AM +0200, Marc Haisenko wrote:
On Monday 07 July 2008, Kirill A. Shutemov wrote:
[#17629] Proper exception out of throw? — "Vladimir Sizikov" <vsizikov@...>
Hi,
[#17644] Features to be included in Ruby 1.9.1 — "Yugui (Yuki Sonoda)" <yugui@...>
Hi, all
Dave Thomas wrote:
There are two things I would like to see added to 1.9.1. A one-byte
Hi,
Hi,
In article <E1KGF2L-0000Qx-K5@x61.netlab.jp>,
Hi,
[#17674] [Ruby 1.8 - Bug #238] (Open) Ruby doesn't respect the Windows read-only flag — Jim Deville <redmine@...>
Issue #238 has been reported by Jim Deville.
[#17690] [Ruby 1.8 - Feature #249] (Open) wish list item: binding.set_local_variable — Roger Pack <redmine@...>
Issue #249 has been reported by Roger Pack.
[#17694] Mark functions not called on exit — Charlie Savage <cfis@...>
Hi everyone,
Hi,
[#17699] Omissions on the ruby-lang.org website and in redmine — "Austin Ziegler" <halostatue@...>
As far as I can tell, there's nowhere on the ruby-lang.org website
On Jul 9, 2008, at 8:05 AM, Austin Ziegler wrote:
On Jul 9, 2008, at 6:07 PM, Ryan Davis wrote:
On Wed, Jul 9, 2008 at 5:14 PM, James Gray <james@grayproductions.net> wrote:
[#17708] [Ruby 1.8 - Bug #252] (Open) Array#sort doesn't respect overridden <=> — Ryan Davis <redmine@...>
Issue #252 has been reported by Ryan Davis.
Issue #252 has been updated by Vladimir Sizikov.
Hi,
Nobuyoshi Nakada wrote:
[#17759] Ruby 1.9.1 Feature and 1.9.0-3 release plan — "Yugui (Yuki Sonoda)" <yugui@...>
Thank you for your replies to [ruby-core:17644]. < all
[#17785] [Ruby 1.9 - Bug #277] (Open) 1.9/trunk: build broken in ruby/ruby.h — Ollivier Robert <redmine@...>
Issue #277 has been reported by Ollivier Robert.
[#17812] Tracing versus coverage (was Re: Re: Features to be included in Ruby 1.9.1) — "Rocky Bernstein" <rocky.bernstein@...>
Sorry for not noticing sooner. It occurs to me that the built-in
It seems to me what you need is not a coverage system but a general hook
I just looked at the code to set the coverage hash and it seems to
Hi Rocky,
[#17822] rdoc defines Hash#method_missing — "Yusuke ENDOH" <mame@...>
Hi,
[#17829] FAILURE of "expand_path" — "C.E. Thornton" <admin@...>
Core,
C.E. Thornton wrote:
Urabe Shyouhei wrote:
On Sat, Jul 19, 2008 at 04:27:09AM +0900, C.E. Thornton wrote:
[#17833] Object allocation tracking — Christopher Thompson <cthompson@...>
Please excuse the blog spam.
[#17843] Exapand_path Patch good as stands. — "C.E. Thornton" <admin@...>
Core,
[#17865] Expand_Path: New Patch - Modified Processing — "C.E. Thornton" <admin@...>
Core,
Hi,
Hi,
[#17871] duping the NilClass — "Nasir Khan" <rubylearner@...>
While nil is an object, calling dup on it causes TypeError. This doesnt seem
Nasir Khan wrote:
On Sun, Jul 20, 2008 at 7:55 PM, Urabe Shyouhei <shyouhei@ruby-lang.org>
Meinrad Recheis wrote:
Urabe Shyouhei wrote:
I write a lot of hand crafted dup or clone because I want control as well as
Hi --
+1 to David. A convenient way to do Marshal idiom should be a new
On Mon, Jul 21, 2008 at 8:21 AM, Urabe Shyouhei <shyouhei@ruby-lang.org> wrote:
Hi --
On Mon, Jul 21, 2008 at 1:02 PM, David A. Black <dblack@rubypal.com> wrote:
Hi --
On Mon, Jul 21, 2008 at 5:18 PM, David A. Black <dblack@rubypal.com> wrote:
[#17883] [Ruby 1.9 - Bug #340] (Open) 1.9/trunk does not work when compiled with llvm-gcc4 2.3 (gcc 4.2.1) — Ollivier Robert <redmine@...>
Issue #340 has been reported by Ollivier Robert.
[#17915] select returning an enumerator — "David A. Black" <dblack@...>
Hi --
[#17922] [Ruby 1.9 - Bug #345] (Open) 1.9 racc appears to seg fault — Roger Pack <redmine@...>
Issue #345 has been reported by Roger Pack.
[#17943] RUBY_ENGINE? — "Vladimir Sizikov" <vsizikov@...>
Hi,
In article <3454c9680807241200xf7cc766qb987905a3987bb78@mail.gmail.com>,
On Thu, Jul 24, 2008 at 7:46 PM, Ryan Davis <ryand-ruby@zenspider.com> wrote:
Hi,
In article <3454c9680807250054i70db563duf44b42d92ba41bfb@mail.gmail.com>,
On Sat, Jul 26, 2008 at 5:09 AM, Tanaka Akira <akr@fsij.org> wrote:
Hi,
Since this thread seemed to die out, I'll ask again:
Hi,
Hi all.
Hi,
Yukihiro Matsumoto wrote:
[#17954] Expand_path -- Proposal: An alternate method — "C.E. Thornton" <admin@...>
HI,
Hi,
Yukihiro Matsumoto wrote:
[#17973] Proposal of GC::Profiler — Narihiro Nakamura <authorNari@...>
Hi.
On Fri, 2008-07-25 at 23:59 +0900, Narihiro Nakamura wrote:
[#18016] Re: Hex string literals [Patch] — gdefty@...
Before posting the message below I thought long
[#18029] [Ruby 1.9 - Bug #378] (Open) rbconfig.rb:173: [BUG] Stack consistency error — Anonymous <redmine@...>
Issue #378 has been reported by Anonymous.
[#18033] JRuby adding ConcurrencyError for fatal concurrent modification — Charles Oliver Nutter <charles.nutter@...>
In order to limit or reduce the likelihood that multiple threads
Hi,
Yukihiro Matsumoto wrote:
[ruby-core:18008] Improving the metaprogramming facilities of Ruby.
G'day. I hope this is the right place to introduce this discussion,
as the ruby-lang.org website is not entirely clear on where language
design and specification discussion takes place.
If this is the wrong place then, please, be forgiving and direct me to
the correct venue to address this.
Also, if this has been previously discussed then please direct me to the
appropriate threads. I searched the mailing list but turned up nothing
obvious.[1]
Finally, I am sorry for the length of this message. I wanted to be as
clear and concise as possible in presenting this, to try and avoid
confusion. Clarity lead to more text than I expected, though.
I have recently been working on a Ruby / ERB template issue where,
essentially, we wanted to have the ERB templates run in an environment
that was almost, but not exactly, the same as Ruby.
Specifically, in the problem domain undefined variables are forbidden,
and we want to expose that rule to our ERB templates.
This was solved, previously, using 'method_missing', and pretending that
variables were actually local methods; that was a losing proposition as
soon as a variable named 'raise' came along. ;)
It could also be solved with an 'instance_variable_missing' method,
analogous to the 'method_missing' method, but thinking about that
brought me to thinking about metaprogramming in Ruby overall.
At the moment Ruby has two distinct and parallel methods for managing
instance variables[2], being:
@foo
instance_variable_get("@foo")
I had, initially, expected that I could simply define a method,
'instance_variable_get', on my object which would allow me to override
the standard ivar lookup process for our own.
What I found, to my surprise, was that @foo acts directly on the ivar
table, accessing or setting the instance variable directly. The
instance_variable_get method does the same, and there is no actual
relationship between the two.
So, after thinking about this and how I would have expected Ruby to
handle the situation, I have two questions:
First, is these a reason why these two operations are distinct?
In consulting the Ruby 1.8 and 1.9 code I see that rb_obj_ivar_get in
object.c and the handling of NODE_IVAR in eval.c both call directly into
the rb_ivar_set function.
Other than differences in error checking[3] both seem to be more or less
identical wrappers over the rb_ivar_set method.
To validate this I experimentally patched eval.c to call the
instance_variable_get (and set) methods rather than directly applying
the call; the results of that (and my tiny test code) are attached.
This seemed to support my theory: both methods seem identical, in
effect, and Ruby continues to pass the packages test suite with the
changes in place.
Second, would it be acceptable to change Ruby (1.9, and ideally 1.8) so
that these two paths /were/ uniform, at least in principal?
I am, obviously, happy to invest the time to write the needed code and
testing, and I am willing to work to see this happen. (eg, to seek
agreement on the specification of the changes, etc, and implement to
something that the various Ruby implementers all considered valid.)
To this effect I have included a rough draft of the specification I
think would be appropriate for this small area of Ruby. This is
intended to strike an appropriate balance between the users and the
implementers in terms of performance and power.
One of the specific goals I have kept in mind in the proposed
modification is that the implementation should be free to optimize the
behaviour of direct (@foo) and indirect (instance_variable_get) access
to ivar storage.
I believe that a conforming implementation could ensure that these
methods directly accessed the ivar table rather than making a method
call without too much trouble, while still supporting the user in
overriding the methods; a combination of caching and a sufficiently
smart compiler should be able to ensure safety.
In the text I have use the following terms:
"the results ... are undefined":
Ruby code may do this, but the behaviour is not guaranteed by Ruby
in any fashion. The code may behave as they expect, or it may cause
an exception, cause Ruby to malfunction, or any other result.
Implementers are encouraged to document the behaviour and limits of
their implementation, as well as to provide sensible results when
undefined actions are taken, such as raising an appropriate
exception.
"conforming code":
Ruby code that is written within the defined behaviour of the core
system, rather than code relying on the behaviour of any particular
implementation of Ruby.
The documentation below covers the range of Object instance_* methods
associated with ivars; the quoted text is the Ruby 1.9 documentation,
and my proposed additions are included.
Editorial comments -- the "why" I added the text are in square brackets,
such that:
> This is Ruby 1.9 documentation.
This is my modified text. [This is my editorial comment on my text.]
The modified method specifications:
> obj.instance_variables => array
>
> Returns an array of instance variable names for the receiver. Note
> that simply defining an accessor does not create the corresponding
> instance variable.
The array returned from this method may not be modified by the caller;
the results of doing so are undefined.
[This text was added so that anyone overriding this method knows that
they can safely return an internal array of names without risk of it
being modified -- for performance reasons, mostly.]
> obj.remove_instance_variable(symbol) => obj
>
> Removes the named instance variable from <i>obj</i>, returning that
> variable's value.
This method may or may not be called during object destruction;
conforming code should not rely on this to perform variable
finalization.
[Added so that implementers are guaranteed to be free of the burden of
calling this during object destruction, and to ensure users know where
they stand.]
> obj.instance_variable_defined?(symbol) => true or false
>
> Returns <code>true</code> if the given instance variable is defined in
> <i>obj</i>.
If instance_variable_get or instance_variable_set are defined then it is
the responsibility of the user to ensure that this method must also be
return accurate results. The results are undefined if this rule is not
respected.
[Added so that Ruby libraries can assume that this method and the
get/set methods are symmetric, and to make it clear to the user that
they are expected to preserve this behaviour.]
> obj.instance_variable_get(symbol) => obj
>
> Returns the value of the given instance variable, or nil if the
> instance variable is not set.
This method is called by Ruby when you write <code>@variable</code>
within the scope of your object methods. You can override this method
to change the rules for instance variable lookup, as long as you abide
by the specified rules.
[Added to make it clear that the user /is/ permitted to override this
method, and that this will result in *all* ivar references calling
their method.]
> The <code>@</code> part of the variable name should be included for
> regular instance variables. Throws a <code>NameError</code> exception
> if the supplied symbol is not valid as an instance variable name.
The default implementation of this method returns <code>nil</code> if
the instance variable has not been set. Conforming code is free to
override this in user defined classes, but the results of overriding
this method in system classes is not defined.
[This is added to make it clear to the user that, for example, returning
false rather than nil from Object.instance_variable_get would be a bad
idea, and to allow the implementer and third party library authors to
assume the standard behaviour in core classes.]
Care should be taken to avoid recursion in user supplied implementations
of this method, as the results of directly referencing an instance
variable inside the method are undefined.
[This is added so that the user, and the implementer, know that they can
just infinitely recurse in the face of the pathological code:
class BadlyBroken; def instance_variable_get name; @recurse; end; end ]
> obj.instance_variable_set(symbol, obj) => obj
>
> Sets the instance variable names by <i>symbol</i> to <i>object</i>,
> thereby frustrating the efforts of the class's author to attempt to
> provide proper encapsulation.
[This is the original text, and is probably not terribly appropriate
after the changes here, but I preserve it for the moment.]
> The variable did not have to exist prior to this call.
[The proceeding should be replaced with:]
This method is called to set the initial, and all subsequent, values of
the instance variable. The variable will not exist prior to setting the
initial value.
Ruby will call this method whenever an instance variable is set,
including for <code>@variable = value</code> expressions within the
scope of your object.
[Added to make it clear this is always called by Ruby to set a
variable.]
Conforming code may override this method, provided the specified
behaviour is implemented. However, the results of overriding this
method on core Ruby classes is undefined.
[Added to make it clear what the user can, and can't, do.]
Care should be taken to avoid recursion in this method; the results of
directly setting an instance variable within this method are undefined,
and you should call your superclass instance_variable_set method
instead.
[Added to avoid forcing implementers to support pathological code:
def BadlyBroken;
def instance_variable_set name, value; @recurse = true; end
end
Implementers are free to support that, of course, if they wish, but
conforming code cannot assume that it will do anything remotely
sensible.]
Regards,
Daniel
Footnotes:
[1] Since I have not previously contributed to the Ruby core I am
somewhat nervous about making such a large proposal for the
language, and I would really like to avoid offending anyone.
[2] This is also true of pretty much every other type, such as
constants, methods, and so forth. Assuming that the general
principals of this message are accepted I intend to also address
those areas for consistency.
[3] Which, in eval.c, is handled at a higher level, so both perform
identical checks and have an identical environment, as far as I can
tell.
Attachments (2)
diff --git a/eval.c b/eval.c
index bfe5f36..a501048 100644
--- a/eval.c
+++ b/eval.c
@@ -2468,6 +2468,7 @@ is_defined(self, node, buf)
break;
case NODE_IVAR:
+ /* REVISIT: This should call instance_variable_defined? */
if (rb_ivar_defined(self, node->nd_vid)) {
return "instance-variable";
}
@@ -3694,9 +3695,19 @@ rb_eval(self, n)
break;
case NODE_IASGN:
- result = rb_eval(self, node->nd_value);
- rb_ivar_set(self, node->nd_vid, result);
- break;
+ /* REVISIT: This will currently recurse infinitely when an IVAR is set
+ from inside the instance_variable_set method, which might surprise
+ some people badly. Perhaps we should have some magic to avoid
+ recursion, either by detecting the current call context? */
+ {
+ /* REVISIT: This probably breaks all sorts of GC protection rules... */
+ VALUE argv[2] = {
+ ID2SYM(node->nd_vid),
+ rb_eval(self, node->nd_value)
+ };
+ result = rb_call(CLASS_OF(self),self,rb_intern("instance_variable_set"),2,argv,1,self);
+ break;
+ }
case NODE_CDECL:
result = rb_eval(self, node->nd_value);
@@ -3737,9 +3748,13 @@ rb_eval(self, n)
break;
case NODE_IVAR:
- result = rb_ivar_get(self, node->nd_vid);
- break;
-
+ {
+ /* REVISIT: This probably breaks all sorts of GC protection rules... */
+ VALUE argv[1] = { ID2SYM(node->nd_vid) };
+ result = rb_call(CLASS_OF(self),self,rb_intern("instance_variable_get"),1,argv,1,self);
+ break;
+ }
+
case NODE_CONST:
result = ev_const_get(ruby_cref, node->nd_vid, self);
break;
class Test
def instance_variable_get name
@get = true
super
end
def instance_variable_set name, value
super
super("@set", true)
end
def success?
@get == true and @set == true
end
def initialize
@get = false
@set = false
end
end
test = Test.new
if test.success? then
puts "success"
else
puts "failure"
end