[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

not finding a breakpoint + values are nil

Dan Bensen

9/14/2006 9:43:00 PM

Ruby seems to be passing over a breakpoint in a class initialize
function. "Got grid" is the only break that occurs before the program
hits a bug. What is Grid.new doing, and how come the "Grid initialized"
breakpoint wasn't found or didn't work?

grid after "Got grid":
=> [[nil, nil, nil], [nil, nil, nil], [nil, nil, nil]]

In file controllers/t3_controller.rb:
....
grid = Grid.new(gridStr)
breakpoint "Got grid"
....

In file controllers/t3/t3lib.rb:

module Cell
class Val < String
def isBlank
self == BLANK
end
end
BLANK = Val.new(' ')
end

class Grid < Array
def initialize(array = ())
super(3) { |row| Array.new(3,Cell::BLANK) }
breakpoint "Grid initialized"
....

--
My name is dsb, and I'm at prairienet, which is an O-R-G.
7 Answers

Ara.T.Howard

9/14/2006 10:06:00 PM

0

Gary Wright

9/14/2006 10:27:00 PM

0


On Sep 14, 2006, at 5:45 PM, Dan Bensen wrote:

> Ruby seems to be passing over a breakpoint in a class initialize
> function. "Got grid" is the only break that occurs before the
> program hits a bug. What is Grid.new doing, and how come the "Grid
> initialized" breakpoint wasn't found or didn't work?

Is this perhaps an issue of inheriting from a core class? I know
there are lots
of gotcha's when you do this because the normal method dispatch tends
to be bypassed.
Maybe try delegating to Array instead.

Gary Wright




Rick DeNatale

9/15/2006 4:23:00 PM

0

On 9/14/06, Dan Bensen <randomgeek@cyberspace.net> wrote:
> Ruby seems to be passing over a breakpoint in a class initialize
> function. "Got grid" is the only break that occurs before the program
> hits a bug. What is Grid.new doing, and how come the "Grid initialized"
> breakpoint wasn't found or didn't work?
>
> grid after "Got grid":
> => [[nil, nil, nil], [nil, nil, nil], [nil, nil, nil]]
>
> In file controllers/t3_controller.rb:
> ...
> grid = Grid.new(gridStr)
> breakpoint "Got grid"
> ...
>
> In file controllers/t3/t3lib.rb:
>
> module Cell
> class Val < String
> def isBlank
> self == BLANK
> end
> end
> BLANK = Val.new(' ')
> end
>
> class Grid < Array
> def initialize(array = ())
> super(3) { |row| Array.new(3,Cell::BLANK) }
> breakpoint "Grid initialized"

Well I'm not sure what else is in your real code, but I just tried
this, and it works. Not that I'm a big fan of subclassing core classes
either:

rick@frodo:/public/rubyscripts$ cat gridtest.rb
require 'rubygems'

require_gem 'ruby-breakpoint'

module Cell
class Val < String
def isBlank
self == BLANK
end
end
BLANK = Val.new('')
end

class Grid < Array
def initialize(array=())
super(3) {|row| Array.new(3, Cell::BLANK)}
breakpoint "Grid initialized"
end
end

grid = Grid.new("foo")
breakpoint "Got grid #{grid.inspect}"

rick@frodo:/public/rubyscripts$ ruby gridtest.rb
Executing break point "Grid initialized" at gridtest.rb:17 in `initialize'
irb():001:0> quit
Executing break point "Got grid [[\"\", \"\", \"\"], [\"\", \"\",
\"\"], [\"\", \"\", \"\"]]" at gridtest.rb:22
irb(main):001:0> quit
rick@frodo:/public/rubyscripts$

By the way, what's up with the array=() parameter in initialize?

1) You don't seem to be using it,
2) The default value is () which is nil, did you mean []?


--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denh...

Dan Bensen

9/15/2006 8:53:00 PM

0

Rick DeNatale wrote:

> Well I'm not sure what else is in your real code, but I just tried
> this, and it works.

Does it work in a Rails app? Breakpoints in the controller file work,
and everything else works from the command line, but other than
breakpoints in the controller file, I haven't gotten anything to work
from Rails:

* breakpoints
* printing to standard output
* printing to a log file
* made the class free-standing, not derived from anything
* require 'breakpoint'
* require 'rubygems'; require_gem 'ruby-breakpoint'

Nothing. Not one single thing has worked outside the controller file.
And there's not even a useful error message, just an "Internal Server
Error" on the client. I have no idea what I'm missing. Is there some
special place the files have to be? I have them in a subdirectory of
controllers.

--
My name is dsb, and I'm at prairienet, which is an O-R-G.

Ezra Zygmuntowicz

9/15/2006 10:38:00 PM

0


On Sep 15, 2006, at 1:55 PM, Dan Bensen wrote:

> Rick DeNatale wrote:
>
>> Well I'm not sure what else is in your real code, but I just tried
>> this, and it works.
>
> Does it work in a Rails app? Breakpoints in the controller file
> work, and everything else works from the command line, but other
> than breakpoints in the controller file, I haven't gotten anything
> to work from Rails:
>
> * breakpoints
> * printing to standard output
> * printing to a log file
> * made the class free-standing, not derived from anything
> * require 'breakpoint'
> * require 'rubygems'; require_gem 'ruby-breakpoint'
>
> Nothing. Not one single thing has worked outside the controller
> file. And there's not even a useful error message, just an
> "Internal Server Error" on the client. I have no idea what I'm
> missing. Is there some special place the files have to be? I have
> them in a subdirectory of controllers.
>
> --
> My name is dsb, and I'm at prairienet, which is an O-R-G.
>

Breakpoint is broken in ruby1.8.5. Maybe that is your issue?

-Ezra

Dan Bensen

9/16/2006 2:30:00 AM

0

Ezra Zygmuntowicz wrote:
> Breakpoint is broken in ruby1.8.5. Maybe that is your issue?
I have 1.8.4.

Well, I made a little test app that works. I'll try building that up
and see if it breaks at some point.

--
My name is dsb, and I'm at prairienet, which is an O-R-G.

Dan Bensen

9/16/2006 3:58:00 AM

0

Dan Bensen wrote:
> Ruby seems to be passing over a breakpoint ...
Okay, it looks like require doesn't look for a new copy of a file when
you edit it. load seems to work, but is there a way to make sure you
only load once, other than C-style tricks?

--
My name is dsb, and I'm at prairienet, which is an O-R-G.