tracing variables

Discussion in 'Ruby' started by gabriele renzi, Jul 5, 2004.

  1. Hi gurus and nubys,

    I wonder: is there a way in ruby to trace assignments to variables?
    gabriele renzi, Jul 5, 2004
    1. Advertisements

  2. Paul Brannan

    Paul Brannan Guest

    On Tue, Jul 06, 2004 at 12:57:39AM +0900, gabriele renzi wrote:
    > Hi gurus and nubys,
    > I wonder: is there a way in ruby to trace assignments to variables?

    I don't know of any way, but I think it would be a nice feature to have.
    The debugger supports watchpoints, but afaict they seem to only break
    when an expression becomes true.

    It shouldn't be difficult (though it would be slow) to use
    set_trace_func to determine when the value of an expression/variable
    changes, but there's no easy way to detect "a = a".

    If you want to use this in a real program and not just for debugging,
    then you might want to consider using the observer pattern (see

    Paul Brannan, Jul 6, 2004
    1. Advertisements

  3. John Carter

    John Carter Guest

    On Tue, 6 Jul 2004, gabriele renzi wrote:

    > I wonder: is there a way in ruby to trace assignments to variables?

    Umm, what exactly do you mean. $globals? Ruby magic variables like $:?

    Local variables?

    John Carter Phone : (64)(3) 358 6639
    Tait Electronics Fax : (64)(3) 359 4632
    PO Box 1645 Christchurch Email :
    New Zealand

    The universe is absolutely plastered with the dashed lines exactly one
    space long.
    John Carter, Jul 6, 2004
  4. il Tue, 6 Jul 2004 13:43:35 +0900, John Carter
    <> ha scritto::

    paul, john, I'll try to answer both in one message.

    Actually I don't realy feel the need for this feature, I just happened
    to read this:

    And I realized that I did not knew if this was possible to do in ruby,
    so I asked on the list :)

    # further delirium
    I think this could be an interesting feature, for debugging purposes
    and (maybe) to satisfy people that wants stricter checks (i.e. we
    could provide required variable declarations like perl strict, or
    checking attributes of the objects being assigned to variable.

    We could provide first-win behaviour where a progtram could raise an
    exception whenever a global variable (even instance and locals,
    anyway) got its value changed from the existing type to an
    incompatible one due to an error (please don't think type==class) and
    other little nifty things.
    gabriele renzi, Jul 6, 2004
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bruce Wayne

    Re: ASP 3 Debugging and Tracing in VB.Net

    Bruce Wayne, Oct 8, 2003, in forum: ASP .Net
    Sue Parker
    Oct 30, 2003
  2. Benjie Fallar

    tracing output explanation

    Benjie Fallar, Jul 15, 2003, in forum: ASP .Net
    Benjie Fallar
    Jul 15, 2003
  3. John Saunders

    Re: Tracing does not show up anything

    John Saunders, Oct 14, 2003, in forum: ASP .Net
  4. Do

    Tracing.Enabled question

    Do, Dec 1, 2003, in forum: ASP .Net
    Ken Cox [Microsoft MVP]
    Dec 1, 2003
  5. Replies:

Share This Page