Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Trace function

 [1/14] from: sanghabum::aol::com at: 18-Jun-2001 18:47


Am I the only one who finds 'Trace too mighty a sledgehammer to be of any real use? Trace with any VID function is just burbles on forever, And, even outside VID, the amount of Rebol that is implemented as mezzanine functions means that my little code is often lost in the Trace output. Assuming this is a common experience, perhaps we could pool suggestions for improved debugging options and submit a combined request to Feedback. I'd be happy to collate any suggestions. Mine are a few refinements for Trace: ** Trace/UserFunctions -- just trace the input conditions to a user (i.e. not a system) function. I'm not sure if Rebol can distinguish User from System, but I'd be happy with a working definition that User is any function defined or redefined in or after the %user.r ** Trace/UserReturn -- just trace return conditions from user functions. ** Trace/UserAssign -- trace result of any assignment in user code (e.g. value of aa after aa: bb + 4) ** Trace/Disable -- turns off ALL tracing regardless of any further trace statements (other than a trace/disable false), Lets me turn off all tracing at one point without having to remove or comment out the individual trace statements. I've got a few other ideas, but that's my Christmas wish list. Any thoughts? --Colin.

 [2/14] from: g:santilli:tiscalinet:it at: 19-Jun-2001 19:18


Hello [Sanghabum--aol--com]! On 19-Giu-01, you wrote: S> Am I the only one who finds 'Trace too mighty a sledgehammer S> to be of any real use? Trace with any VID function is just I think I used TRACE 5 to 10 times at most since I use REBOL, and mainly to trace what PARSE was doing. PROBE is more than enough for debugging IMHO. You don't have all that useless output, and are immediately able to see what's going on. Regards, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/

 [3/14] from: sanghabum:aol at: 21-Jun-2001 5:14


[g--santilli--tiscalinet--it] writes:
> I think I used TRACE 5 to 10 times at most since I use REBOL, and > mainly to trace what PARSE was doing. > > PROBE is more than enough for debugging IMHO. You don't have all > that useless output, and are immediately able to see what's going > on.
Hi Gabriele, I suspect the lack of response to my request indicates just how few of us ever go near Trace after the first encounter. I'm sure we've all got our little toolkit of debugging toys. The simplest one I have is in my USER.R.... debugprint: :print ....so I can search code later for all Print statements that exist only for debugging. I think it is a shame that Rebol does not have a better set of debugging tools. Perhaps we could open this thread out....Anyone else got little scripts or tricks they use for debugging that they'd like to share? --Colin

 [4/14] from: joel:neely:fedex at: 21-Jun-2001 2:39


[Sanghabum--aol--com] wrote:
> I suspect the lack of response to my request indicates just > how few of us ever go near Trace after the first encounter. >
I suspect you're right.
> I'm sure we've all got our > little toolkit of debugging toys. The simplest one I have is > in my USER.R.... > > debugprint: :print > > ....so I can search code later for all Print statements that > exist only for debugging. >
Not only that, but you can later re-define debugprint: func [dummy [any-type!]] [] to disable debugging! You've got a good idea there.
> I think it is a shame that Rebol does not have a better set > of debugging tools. > > Perhaps we could open this thread out....Anyone else got > little scripts or tricks they use for debugging that they'd > like to share? >
1) (re)factoring, 2) objects, 3) probe 1) My favorite way to deal with debugging is to avoid it as much as possible (yeah, right! ;-) by (re)factoring the code into small, black-box pieces that can be recombined as flexibly as possible. This includes the use of higher-order functions such as MAP. In my experience, I'm much more likely to *need* debugging tricks with long sprawling functions than with concise ones. 2) Of course, I can get in a hurry and mess up even the most simple-looking functions. By wrapping a group of related functions into an object, and using data-like members of that object as scratch space, I can more easily perform a test and then look at the after-effects (or even add snapshot members) to see where I went off the rails. 3) When I keep my individual functions small and orthogonal, I usually find that a small number of well-placed PROBEs help me get a function working and tested with less effort. In a way, I'm glad that TRACE is so unwieldy! I've used other languages/platforms that had big piles of inspectors, "live" data displays, breakpoints, etc... While those things may be hard to against in *some* situations (embedded software, kernel, and device driver development, for example), I find that in most programming situations in a reasonable high-level language, they make it all too easy for me to get sloppy in my design and coding, because I've got such industrial-strength automated crutches to fall back on! -jn- ------------------------------------------------------------ Programming languages: compact, powerful, simple ... Pick any two! joel'dot'neely'at'fedex'dot'com

 [5/14] from: allenk:powerup:au at: 21-Jun-2001 23:22


> > > > Perhaps we could open this thread out....Anyone else got
<<quoted lines omitted: 4>>
> 2) objects, > 3) probe
?? is handy too USAGE: ?? 'name DESCRIPTION: Prints a variable name followed by its molded value. (for debugging) ?? is a function value. ARGUMENTS: name -- (Type: any)

 [6/14] from: chris:starforge:demon at: 21-Jun-2001 14:30


Joel Neely wrote:
>>Perhaps we could open this thread out....Anyone else got >>little scripts or tricks they use for debugging that they'd
<<quoted lines omitted: 4>>
> 2) objects, > 3) probe
Heh, makes me feel like a luddite! I mainly write cgi scripts, so I usually just bung in things like print rejoin [ "<!-- " foo " " bar " " foogle " -->" ] ; NUKE ME!!! and then just strip all the "; NUKE ME!!!"s when I'm done testing... Well it works :)) Chris

 [7/14] from: volker nitsch:crosswinds at: 21-Jun-2001 13:08


RE: [REBOL] Re: Trace function [Sanghabum--aol--com] wrote:
> [g--santilli--tiscalinet--it] writes: > > I think I used TRACE 5 to 10 times at most since I use REBOL, and
<<quoted lines omitted: 16>>
>> ???: func ['word value] [ print [mold :word " : " mold :value] word :value] >> ??? one-value: 5 ??? another-value: 7 ??? sum: one-value + another-value
one-value: : 5 another-value: : 7 sum: : 12 -Volker

 [8/14] from: sanghabum:aol at: 21-Jun-2001 12:34


[chris--starforge--demon--co--uk]:
> Heh, makes me feel like a luddite! I mainly write cgi scripts, so I > usually just bung in things like > > print rejoin [ "<!-- " foo " " bar " " foogle " -->" ] ; NUKE ME!!! > > and then just strip all the "; NUKE ME!!!"s when I'm done testing...
Hi Chris, You reminded me that (months ago) when I was doing some CGI work, I wrote a short debugging print function: ========= Rebol [] debugPrint: func [db [any-type!]] [ prin "<!-- " either error? try [prin type? db] [prin "[type?] "] [prin " "] either error? try [prin length? db] [prin " [length?] "] [prin " "] either error? try [prin mold db] [prin " [item?] "] [prin " "] print " -->" return true ] ========= Examples:
>> debugprint [carl--rebol--com]
<!-- email 14 [carl--rebol--com] -->
>> debugprint system/stats
<!-- integer [length?] 3841120 -->
>> debugprint reduce [red white blue]
<!-- block 3 [255.0.0 255.255.255 0.0.255] -->
>> debugprint try [do " 8 / 0"]
<!-- error [length?] [item?] --> (The last example showing that it could do with a bit more datatype awareness). Of course it can be disabled using Joel's nifty redefinition: debugprint: func [dummy [any-type!]] [] --Colin.

 [9/14] from: sanghabum:aol at: 21-Jun-2001 12:34


[joel--neely--fedex--com]:
> > I'm sure we've all got our > > little toolkit of debugging toys. The simplest one I have is
<<quoted lines omitted: 8>>
> debugprint: func [dummy [any-type!]] [] > to disable debugging! You've got a good idea there.
Hi Joel, Hey! You know, I'd always been meaning to write that disable function, but never got round to it. Thanks for saving me the time and effort, --Colin.

 [10/14] from: ddalley:idirect at: 21-Jun-2001 16:27


----- Original Message -----
> [Sanghabum--aol--com] wrote: > > > > I suspect the lack of response to my request indicates just > > how few of us ever go near Trace after the first encounter.
I use it regularly and it drives me up the wall. There is far too much returned and that takes too long to be efficient. TRACE needs a verbose switch, for those that need it; otherwise we only need to see the few important lines around the problem. Donald

 [11/14] from: allen:aussieweb:au at: 22-Jun-2001 12:27


----- Original Message ----- From: <[Sanghabum--aol--com]> To: <[rebol-list--rebol--com]> Sent: Tuesday, June 19, 2001 8:47 AM Subject: [REBOL] Trace function
> Am I the only one who finds 'Trace too mighty a sledgehammer to be of any > real use? Trace with any VID function is just burbles on forever, And,
even
> outside VID, the amount of Rebol that is implemented as mezzanine
functions
> means that my little code is often lost in the Trace output.
For vid debugging dump-face is usefull.

 [12/14] from: coussement:c:js:mil:be at: 22-Jun-2001 9:30


> 1) (re)factoring, > 2) objects,
<<quoted lines omitted: 25>>
> automated crutches to fall back on! > -jn-
[My experiences on that field are similar to those of Joel. - BTW I don't know *MAP* what does it means ?- I try to use the most modular code possible by the isolation of functionnalities into specific functions and objects, and to protect the global context by the use of a local one (aka 'context). I like to see my code as an assembly of *LEGO* blocks, being able to test each one individualy, and putting it together to achieve an higher fonctionnality. For tracing I mostly use '? which tell me a lot about used words:
>> help ?
USAGE: ? 'word DESCRIPTION: Prints information about words and values. ? is a function value. ARGUMENTS: word -- (Type: any-type)
>> a: 35
== 35
>> ? a
A is an integer of value: 35 I put then a visual remainder for finding it back with ease when I don't need it anymore: (in the script) ? a ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< I used to develop in PowerBuilder, which has a rather big debug env. I remember losing more time finding back how to use it efficiently and finding my vars back, then debugging my code :-( I definitely prefer the REBOL approach: keep simple things simple ;-)) CU, chr== ]

 [13/14] from: joel:neely:fedex at: 22-Jun-2001 1:49


Hi, Christophe, CRS - Psy Sel/SPO, COUSSEMENT, Christophe, CPN wrote:
> [My experiences on that field are similar to those of Joel. > - BTW I don't know *MAP* what does it means ?- >
We've kicked around several variations on the MAP theme, here's one... map: function [ {Maps a function to all elements of a block} [throw] f [any-function!] blk [block!] ] [result] [ result: make block! length? blk foreach elem blk [ insert/only tail :result f get/any 'elem ] result ] ...from the collection of functions Ladislav published on his web site: http://www.sweb.cz/LMecir/highfun.r MAP applies an argument function to all elements of a block and returns the block of results, as in
>> square: func [x] [x * x] >> map :square [1 2 3 4 5]
== [1 4 9 16 25]
>> map :positive? [1 -2 3 -4 5 -6]
== [true false true false true false]
>> map :random [2 2 6 6 52 52]
== [2 1 2 1 11 10] HTH! -jn- ------------------------------------------------------------ Programming languages: compact, powerful, simple ... Pick any two! joel'dot'neely'at'fedex'dot'com

 [14/14] from: jeff:rebol at: 22-Jun-2001 7:36


Trace is very handy for REBOL implementors when facing abnormalities. And there's TRACE/function -- which is handy in certain situations, even as a simple profiler. The trick with TRACE is turning it on ONLY around the smallest expression you want to debug. -jeff

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted