[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:01796] date2 and the new Symbol stuff

From: Dave Thomas <Dave@...>
Date: 2000-03-10 03:44:01 UTC
List: ruby-talk #1796
date2.rb has a neat method to cache the results of method calls

    def once(*ids)
      for id in ids
	module_eval <<-"end;"
	  alias_method :__#{id}__, #{id}
	  def #{id.id2name}(*args, &block)
	    def self.#{id.id2name}(*args, &block); @__#{id}__ end
	    @__#{id}__ = __#{id}__(*args, &block)
	  end
	end;
      end
    end


    once :julian

However, using the new Symbol code, this doesn't run, as ":__#{id}__"
expands to ":__:julian__".

I could either submit a patch which changed all the {id}'s to
{id.id2name}, or we could change Symbol.to_s to return "julian", not
":julian".

Which is the better solution?


Regards


Dave

In This Thread

Prev Next