Discussion:
[perl #54478] [RFE] trace should be a number that can be decremented and incremented
(too old to reply)
Stephane Payrard
2008-05-19 22:29:33 UTC
Permalink
# New Ticket Created by Stephane Payrard
# Please include the string: [perl #54478]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=54478 >


Request for enhancement:

At the PIR level, trace should be a number that can be decremented
and incremented with two new opcodes
inc_trace and dec_trace. trace mode would be active when the trace
variable is strictly positive. This is useful
for tracing recursive calls.

A :trace flag should be implemented for routine and methods to
prepend inc_trace and append dec_trace.

A the Perl6 level, this could be a trait 'is :pirtrace' and and
'is :pirtrace<rec>. for functions and methods.
:pirtrace would cause subcalls to be wrapped: trace 0; subcall(); trace 1.
:pirtrace would cause a whole method function PIR code wrapped by
inc_trace and dec_trace.
--
cognominal stef
Patrick R. Michaud
2008-05-19 22:40:15 UTC
Permalink
Post by Stephane Payrard
# New Ticket Created by Stephane Payrard
# Please include the string: [perl #54478]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=54478 >
[...]
A the Perl6 level, this could be a trait 'is :pirtrace' and and
'is :pirtrace<rec>. for functions and methods.
:pirtrace would cause subcalls to be wrapped: trace 0; subcall(); trace 1.
:pirtrace would cause a whole method function PIR code wrapped by
inc_trace and dec_trace.
Rakudo already offers a "trace" builtin that enables/disables
tracing in Parrot. I'm not sure it needs to be a trait.

One can implement the equivalent of inc_trace and dec_trace in rakudo
with something like:

our $tracevalue = 0;

sub inc_trace {
our $tracevalue;
$tracevalue++;
trace(1);
}

sub dec_trace {
our $tracevalue;
$tracevalue-- if $tracevalue > 0;
trace($tracevalue > 0);
}

Pm
Will Coleda via RT
2008-05-20 01:13:07 UTC
Permalink
Post by Stephane Payrard
At the PIR level, trace should be a number that can be decremented
and incremented with two new opcodes
inc_trace and dec_trace. trace mode would be active when the trace
variable is strictly positive. This is useful
for tracing recursive calls.
There are already multiple meanings for various positive trace levels; see, for example, 'trace
1' vs 'trace 4' vs. the and-itive 'trace 5'.
Post by Stephane Payrard
A :trace flag should be implemented for routine and methods to
prepend inc_trace and append dec_trace.
I would prefer to see a more generic mechanism that allowed us to add pre- and post- sub
execution hooks. (Tcl needs this to be feature complete anyway); You could then wrap up sub
invocation with this mechanism to get your desired effect.
Patrick R. Michaud
2009-02-06 02:06:42 UTC
Permalink
Allison, can you weigh in on this RFE?
Have there been any developments on the issues raised in this ticket?
Not really; I don't expect there to be any before 1.0. I vote
that we reject the ticket, and possibly create a new ticket in Trac for it.

Pm

Loading...