develooper Front page | perl.perl5.porters | Postings from April 2018

Re: [perl #133123] eval '__PACKAGE__' in debug mode do not returnright package

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
April 25, 2018 08:53
Subject:
Re: [perl #133123] eval '__PACKAGE__' in debug mode do not returnright package
Message ID:
20180425085300.GR597@iabyn.com
On Mon, Apr 23, 2018 at 07:14:08AM -0700, KES via RT wrote:
> >If I understand you correctly, you're wanting __LINE__etc to be changed from compile-time constants to run-time functions?
> 
> No. Maybe change the value it is compiled into when this is 'eval' in DB
> package

So, this:

    package DB {
        sub do_foo  { print __PACKAGE__, "\n" }
        sub do_eval { print eval '__PACKAGE__', "\n" }
    }
    do_foo();
    do_eval();

would output
    main
    DB

what about errors and warnings within the eval? Would they appear to come
from within the eval, or from the first non-DB caller.

> I mean next:
> eval EXPR, FRAMENUMBER

It's not possible to give eval an optional second argument. Eval used as
part of list is expected to consume 1 argument. So for example this is
valid perl which passes two arguments to f():

    f(eval $x, 1);

-- 
You live and learn (although usually you just live).

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About