[#11073] segfault printing instruction sequence for iterator — <noreply@...>

Bugs item #10527, was opened at 2007-05-02 14:42

14 messages 2007/05/02
[#11142] Re: [ ruby-Bugs-10527 ] segfault printing instruction sequence for iterator — Nobuyoshi Nakada <nobu@...> 2007/05/10

Hi,

[#11188] Re: [ ruby-Bugs-10527 ] segfault printing instruction sequence for iterator — Paul Brannan <pbrannan@...> 2007/05/16

On Thu, May 10, 2007 at 04:51:18PM +0900, Nobuyoshi Nakada wrote:

[#11234] Planning to release 1.8.6 errata — Urabe Shyouhei <shyouhei@...>

Hi all.

17 messages 2007/05/25

Re: Understanding code: Kernel#require and blocks.

From: George <george.ogata@...>
Date: 2007-05-04 07:54:04 UTC
List: ruby-core #11083
On 5/4/07, Hugh Sasse <hgs@dmu.ac.uk> wrote:
> I'm trying to debug a Rails application which complains about an
> undefined constant when `rake db:migrate` is invoked.  The rakefile
> that comes with rails modifies $:, then does several more requires.
> Given the length of $: it is tedious to find which files are
> require`d.   Clearly this is not a rails specific difficulty: it is
> common to understanding anyone's code making sufficiently extensive
> use of require.  So my question is this:
> Would it be practical to modify require so that it accepts a block,
> to which it would pass the path of the object it successfully
> require`d?  Then, to find the files I must read to understand what
> is happening I could change
>
> -  require 'tasks/rails'
> +  require 'tasks/rails' {|path| $stderr.puts "require`d #{path]"}
>

Hi Hugh,

A rudimentary lookup isn't too much more work, is it?

  $stderr.puts $:.find{|path| File.exist? "#{path}/tasks/rails.rb"}

Particularly if you wrap it around #require and keep it as a debugging
method somewhere.

Your proposal strikes me as a rather arbitrary use of a block.  I
might expect it to be run in the event that the require fails, for
example, or for something to be done after the block finishes.  It
doesn't have my vote just yet (for the little that's worth :-).

Regards,
George.

In This Thread