not finding a breakpoint + values are nil

D

Dan Bensen

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"
....
 
A

ara.t.howard

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"
...


if you haven't used narray you should check it out - it'll give you beautiful
numerical grids with blinding speed in few lines of code...

fyi.

-a
 
G

gwtmp01

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
 
R

Rick DeNatale

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 []?
 
D

Dan Bensen

Rick said:
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.
 
E

Ezra Zygmuntowicz

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.

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

-Ezra
 
D

Dan Bensen

Ezra said:
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.
 
D

Dan Bensen

Dan said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top