FAQ

On Fri, Jul 11, 2014 at 6:02 AM, Dave Mitchell wrote:
On Thu, Jul 10, 2014 at 09:11:55AM -0500, Reini Urban wrote:
On Wed, Jul 9, 2014 at 9:40 AM, Dave Mitchell wrote:
Looking a bit further, it appears that the B::Util in Module-Info is a
fork of the CPAN B::Util module, and both define a B::OP::parent method,
which is a bit naughty of them.

Perhaps the best approach is for the B::Util author(s) to make their
B::OP::parent method available only if the same method doesn't already
exist in B, or if it exists but perl was'nt built with -DPERL_OP_PARENT
(in which case the builtin B::OP::parent always just returns NULL.)
Fixed with https://github.com/jbenjore/B-Utils/pull/10 Thanks.
Note that the builtin B::OP::parents deviates slightly from B::Utils
that it returns B::NULL instead of undef.
See https://github.com/rurban/B-Utils/commit/cf506c3a3fa40287fbd01bd24194770fe09d8700#diff-8036def766d91d6bd1d95741933c4a4dR59
I have no particular opinion on whether it's best to return undef or B::NULL;
if you have a preference for undef, I can easily change B.xs.
I've checked a bit. Returning B::NULL seems to be more consistent
across the board and is better.
E.g. an empty main_root is B::NULL and not undef, similar to other
ops. All the compilers and
walkers assume B::NULL

It would argue it's B::Utils fault here, even if undef is easier to
use in such loops.
However this typical B loop works fine, because $$kid will be 0:
        for (my $kid = $op->first; $$kid; $kid = $kid->sibling) {

DB<1> x $op->first->sibling
0 B::NULL=SCALAR(0x1e09658)
    -> 0

We (jjore and me) should note it in the B::Utils docs.
Josh?

PS: My
if ($] >= 5.021002 and $Config::Config{ccflags} =~ /-DPERL_OP_PARENT/) {
    is( ref $parent, 'B::NULL', "No parent for root " . $op->stringify );
check in my first patch is highly fragile, and we rather should check
for ok $$parent.
I'll come up with better patches.

Search Discussions

  • Dave Mitchell at Jul 13, 2014 at 1:44 pm

    On Sat, Jul 12, 2014 at 11:40:35AM -0500, Reini Urban wrote:
    PS: My
    if ($] >= 5.021002 and $Config::Config{ccflags} =~ /-DPERL_OP_PARENT/) {
    is( ref $parent, 'B::NULL', "No parent for root " . $op->stringify );
    check in my first patch is highly fragile, and we rather should check
    for ok $$parent.
    I'll come up with better patches.
    Thinking about this,

         $Config::Config{ccflags} =~ /-DPERL_OP_PARENT/

    probably isn't a good way of checking for this feature; eventually it
    should become the default and not appear in ccflags.

    Perhaps I should add a global var to B: $B::OP::does_parent, say, which is:

         undef on older perls
         0 on perls that have the parent() method but not -DPERL_OP_PARENT
         1 on perls that have the parent() method and -DPERL_OP_PARENT


    --
    Any [programming] language that doesn't occasionally surprise the
    novice will pay for it by continually surprising the expert.
        -- Larry Wall
  • Reini Urban at Jul 14, 2014 at 8:52 pm

    On Sun, Jul 13, 2014 at 8:44 AM, Dave Mitchell wrote:
    On Sat, Jul 12, 2014 at 11:40:35AM -0500, Reini Urban wrote:
    PS: My
    if ($] >= 5.021002 and $Config::Config{ccflags} =~ /-DPERL_OP_PARENT/) {
    is( ref $parent, 'B::NULL', "No parent for root " . $op->stringify );
    check in my first patch is highly fragile, and we rather should check
    for ok $$parent.
    I'll come up with better patches.
    Thinking about this,

    $Config::Config{ccflags} =~ /-DPERL_OP_PARENT/

    probably isn't a good way of checking for this feature; eventually it
    should become the default and not appear in ccflags.
    Yes. That was my concern.
    Perhaps I should add a global var to B: $B::OP::does_parent, say, which is:

    undef on older perls
    0 on perls that have the parent() method but not -DPERL_OP_PARENT
    1 on perls that have the parent() method and -DPERL_OP_PARENT
    Yes, something like this.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupperl5-porters @
categoriesperl
postedJul 12, '14 at 4:40p
activeJul 14, '14 at 8:52p
posts3
users2
websiteperl.org

2 users in discussion

Reini Urban: 2 posts Dave Mitchell: 1 post

People

Translate

site design / logo © 2021 Grokbase