Skip Menu |

This queue is for tickets about the Devel-REPL CPAN distribution.

Report information
The Basics
Id: 62980
Status: open
Priority: 0/
Queue: Devel-REPL

People
Owner: Nobody in particular
Requestors: chm [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: REPL context not quite the same as script context
I just ran into a subtle difference between running in a perl script or in the REPL. Devel::REPL, by default, forces list context on the code being run, i.e.: sub checkcontext { if (wantarray) { print "list context\n"; } elsif (defined wantarray) { print "scalar context\n"; } else { print "void context\n"; } } sub tryit { checkcontext; return 1; } checkcontext(); tryit(); When run as a program outputs: void context void context But when cut an pasted into an re.pl session the result is: $ checkcontext(); list context 1 $ tryit(); void context 1 In addition, there is a problem with the DDS output if the line being executed has a void return, e.g.: sub tryit { checkcontext; return; } When run in re.pl yields this: $ tryit void context No arguments! at /home/chm/perl/lib/Devel/REPL/Plugin/DDS.pm line 17 Error! - Can't use string ("1") as an ARRAY ref while "strict refs" in use at /usr/lib/perl5/site_perl/5.10/i686-cygwin/Data/Dump/Streamer.pm line 1363. I'm not sure what the best fix would be. Documentation would help. It would be nice if the REPL context better matched the context from a perl program. The DDS display "noise" when there is a void return is a bug. I took a quick look and didn't go futher since the code was tricky and I did not wish to break anything.
Regarding the DDS display problem for a sub with void return, another cygwin system does not show that problem. This may have been fixed or it could be a problem with version skew. On Sun Nov 14 13:11:01 2010, CHM wrote: Show quoted text
> > In addition, there is a problem with the DDS > output if the line being executed has a void > return, e.g.: > > sub tryit { > checkcontext; > return; > } > > When run in re.pl yields this: > > $ tryit > void context > No arguments! at /home/chm/perl/lib/Devel/REPL/Plugin/DDS.pm line 17 > Error! - Can't use string ("1") as an ARRAY ref while "strict refs" in > use at /usr/lib/perl5/site_perl/5.10/i686-cygwin/Data/Dump/Streamer.pm > line 1363. > > The DDS display "noise" when there is a > void return is a bug. I took a quick look > and didn't go futher since the code was > tricky and I did not wish to break anything.