Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Introspecting type informations?

by LanX (Cardinal)
on Aug 03, 2019 at 20:19 UTC ( #11103823=perlquestion: print w/replies, xml ) Need Help??

LanX has asked for the wisdom of the Perl Monks concerning the following question:

Please compare these outputs of B::Deparse and B::Concise

C:\>perl -MO=Deparse -e "my DB $x; print $x" my DB $x; # <-- DB print $x; -e syntax OK C:\>perl -MO=Concise -e "my DB $x; print $x" 8 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) v:{ ->3 3 <0> padsv[$x:1,2] vM/LVINTRO ->4 # <-- no DB 4 <;> nextstate(main 2 -e:1) v:{ ->5 7 <@> print vK ->8 5 <0> pushmark s ->6 6 <0> padsv[$x:1,2] s ->7 -e syntax OK

So where is the information hidden in the OP-tree, such that Deparse can see it but not Concise?

Please enlighten me! :)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

) for simplicity I just randomly picked a predefined package DB (debugger) as a dummy type.

update

Devel::Peek neither helps

C:\>perl -MDevel::Peek -e "my DB $x=10; Dump $x" SV = IV(0xee96a8) at 0xee96b8 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 10

Replies are listed 'Best First'.
Re: Introspecting type informations?
by choroba (Archbishop) on Aug 03, 2019 at 20:53 UTC
    There's no difference if you omit the type:
    diff <(perl -MO=Concise -e 'my DB $x; print $x') \ <(perl -MO=Concise -e 'my $x; print $x')
    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      Exactly, so where is the information?
Re: Introspecting type informations?
by Don Coyote (Friar) on Aug 04, 2019 at 12:03 UTC

    Hi LanX.

    I tried just adding -wMstrict and the DB line no longer continued to show when being deparsed.

    As you had not mentioned this in the OP I think that would be the first thing to consider.

    C:\Users\deutoronomy>perl -wMstrict -MO=Deparse -e "my DB $x" BEGIN { $^W = 1; } use strict 'refs'; my $x; #<-- no DB -e syntax OK

    Could Concise be introducing strict compliance at some point?

      Unlikely, I'd rather say your system is buggy.
      $ perl -wMstrict -MO=Deparse -e 'my DB $x' BEGIN { $^W = 1; } use strict; my DB $x; -e syntax OK $

      Thanks for the interesting observation! :)

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      update

      couldn't reproduce on win

      C:\>perl -wMstrict -MO=Deparse -e "my DB $x" BEGIN { $^W = 1; } use strict; my DB $x; -e syntax OK
Re: Introspecting type informations? HvNAME(SvSTASH(SvRV(ST(0))))
by Anonymous Monk on Aug 04, 2019 at 07:35 UTC
    HvNAME(SvSTASH(SvRV(ST(0))))

    B:: does have SvSTASH

    I tried with Inline::C but it keeps crashing with "my TYPE ... " but plain scalar returns "(null)"

      Thanks, probably you forgot to define TYPE.

      FYI you don't need inline C, B::Deparse is written in Perl and accessing all methods via the B:: backend.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

        Heh. Didnt forget diagnostics always reminds. Show the B code then.
Re: Introspecting type informations?
by Anonymous Monk on Aug 04, 2019 at 05:08 UTC

    Its where it belongs?

    $ perl -MO=Concise -e "my DouBloon $x; print $x" No such class DouBloon at -e line 1, near "my DouBloon" -e had compilation errors. 8 <@> leave[1 ref] KP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) :{ ->3 - <1> ex-rv2sv K/1 ->4 3 <#> gvsv[*x] ->4 4 <;> nextstate(main 1 -e:1) :{ ->5 7 <@> print K ->8 5 <0> pushmark ->6 - <1> ex-rv2sv K/1 ->7 6 <#> gvsv[*x] ->7 $ perl -MO=Concise,-src -e "my DouBloon $x; print $x" No such class DouBloon at -e line 1, near "my DouBloon" -e had compilation errors. 8 <@> leave[1 ref] KP/REFC ->(end) 1 <0> enter ->2 # 1: -src not supported for -e 2 <;> nextstate(main 1 -e:1) :{ ->3 - <1> ex-rv2sv K/1 ->4 3 <#> gvsv[*x] ->4 # 1: -src not supported for -e 4 <;> nextstate(main 1 -e:1) :{ ->5 7 <@> print K ->8 5 <0> pushmark ->6 - <1> ex-rv2sv K/1 ->7 6 <#> gvsv[*x] ->7
      As already mentioned, the type must be an already defined package. Hence your compilation errors.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

        Heh. Its not an opcode. The warning is parse/toke. Dont expect concise to talk about it.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11103823]
Approved by stevieb
Front-paged by haukex
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2020-10-21 08:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (212 votes). Check out past polls.

    Notices?