Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Perl Cross References

by PetaMem (Priest)
on Jun 04, 2002 at 15:11 UTC ( [id://171502]=perlquestion: print w/replies, xml ) Need Help??

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

Suffering comrades,

yes - I'm suffering - not just because perlcc never works. No - that's a different story. The problem seems to be, that the whole B::<mod> module hierarchy is nothing but experimental. Very bad. Consider this:

#> perl -MO=Xref elric

Can't locate object method "xref" via package "B::SPECIAL"
(perhaps you forgot to load "B::SPECIAL"?) at
/usr/lib/perl5/5.6.1/i586-linux/B.pm line 213.
CHECK failed--call queue aborted.
Oh great. So what? I don't know. No compiler, no cross-references and now maintain a large and growing Perl project. Attack of the bugs begun has.

Bye
 PetaMem

Replies are listed 'Best First'.
Re: Perl Cross References
by grinder (Bishop) on Jun 04, 2002 at 17:49 UTC
    The problem seems to be, that the whole B:: module hierarchy is nothing but experimental. Very bad.

    That's because the whole B:: module hierarchy is experimental!

    I can only wonder though, why you need cross-referencing to get a handle on your project. With a decent design using modern techniques of abstraction and encapsulation, you shouldn't even need it. I can't remember the last time I looked at one, but it must be something like 15 years ago. If I thought I needed one today, I'd be reviewing my design methodologies very carefully.

    If you're looking for tools to help dig you out of the mud, and in particular the B:: modules, I'd tend to say that it's already too late.


    print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'
      I can only wonder though, why you need cross-referencing to get a handle on your project. With a decent design using modern techniques of abstraction and encapsulation, you shouldn't even need it.

      Oh!

      Well - then probably the best we can do is to tell the B:xxx authors stop wasting their time implementing such useless tools. While it is almost exactly 13 years since I used (and needed) Cross Referencing on some projects of mine, I completedly disagree, that "modern techniques" and discipline and cleverness (I've added that) are enough to carve complex large prototypes flawlessly in perl.

      I had a dispute - long time ago - with a student about the need of some parser-generator for perl. (Was before Parse::RecDescent, perlyacc etc.). He said:

      "You don't need a parser-generator in perl, because you already have regexps. The rest is done in a while-loop."

      Your argument seems pretty same to me.

      Bye
       PetaMem

        Assuming that a bunch of regexps is equivalent to a parser generator is misguided and naïve, I think we both agree on that point.

        But I think you miss my point about cross referencing a Perl program. Cross referencing involves static analysis of source code. For some subset of Perl, this will be fine, but once you start to involve source filters, run-time evaluation of code, closures, ties, autoloading... the problem becomes impossible. Some of the code simply does not exist before the program runs. It is not written, the program writes as it goes along. How can you cross reference that? And the more complex a system becomes, the more likely the above techniques will be employed in order to get a handle on the complexity.

        I'd suggest looking at the Devel:: and Test:: hierarchies, for looking at tools to help you instrument a running program and get feedback on its behaviour, and ensuring its correctness (or at least that you haven't broken anything that used to work when you introduce new code). For instance, I have used chromatic's Devel::TraceMethods to understand a bug in an OO hieararchy that relied heavily on autoloading.

        Honestly, I didn't even know that there was such a thing as B::Xref. I think Malcolm Beattie wrote it more as a proof of concept, rather than expecting people to really use it. Cross referencing just seems so '80s to me.


        print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'
Re: Perl Cross References
by Courage (Parson) on Jun 04, 2002 at 17:05 UTC
    I'm 75% sure you have another B.pm somewhere in your @INC that clashes with one in perl distribution!

    (I had similar failings recently and that was a reason in my case)

    To check my idea, what perl -MO=Xref -we 1 outputs? If it is good. then my assumption is wrong. In that case there should be something special with your elric. If that is the case, could you post then a place in 'elric' that causes such behaviour?

    Courage, the Cowardly Dog.
    PS. Something fishy is going on there, or my name is Vadim Konovalov. And it's not.

      Hi,

      it's the 25% that bite us (both):

      rj@pollux:~/_ELRIC/implementation/src/examples> perl -MO=Xref -we 1 File -e Subroutine (definitions) Package UNIVERSAL &VERSION s0 &can s0 &isa s0 Package attributes &bootstrap s0 -e syntax OK
      and - btw. B::XRef works "good" for all smaller scripts I call it on as long as they aren't complicated and ~ 50 lines of code not more. Even then:
      Use of uninitialized value in string eq at /usr/lib/perl5/5.6.1/i586-l +inux/B/Xref.pm line 117. Use of uninitialized value in substitution (s///) at /usr/lib/perl5/5. +6.1/i586-linux/B/Xref.pm line 124. Use of uninitialized value in string eq at /usr/lib/perl5/5.6.1/i586-l +inux/B/Xref.pm line 117. Use of uninitialized value in substitution (s///) at /usr/lib/perl5/5. +6.1/i586-linux/B/Xref.pm line 124. Use of uninitialized value in concatenation (.) or string at /usr/lib/ +perl5/5.6.1/i586-linux/B/Xref.pm line 130. Use of uninitialized value in string eq at /usr/lib/perl5/5.6.1/i586-l +inux/B/Xref.pm line 117. etc. etc. (cut for node readability) Use of uninitialized value in substitution (s///) at /usr/lib/perl5/5. +6.1/i586-linux/B/Xref.pm line 124. Use of uninitialized value in concatenation (.) or string at /usr/lib/ +perl5/5.6.1/i586-linux/B/Xref.pm line 130. Use of uninitialized value in concatenation (.) or string at /usr/lib/ +perl5/5.6.1/i586-linux/B/Xref.pm line 130.
      Ugly isn't it? But after that the references spill out. So one must say: unusable for larger projects. Who needs cross references on small scripts???

      Update:

      I thought B::Xref spills out human readable output by default (no params).. :-) Is this considered human readable?

      Subroutine deflate Package (lexical) $$eref 51 $@$$eref 56 $@$@$$eref 60 $@$@$@$$eref 65 $@$@$@$@$$eref 70 $eref i50, 51 $i i55, 56, 59, 59, 55, 70, 71 $inner i60, 62, 63, 64, 55, 69 $j i59, 60, 65, 66, 67, 59 $key i49 $outer i56, 62, 63, 64, 55, 69 $size i51, 66, 59, 55, 71 @$$eref 51, 56 @$@$$eref 56, 60 @$@$@$$eref 60, 65 @$@$@$@$$eref 65, 70 @$@$@$@$@$$eref 70 Package main @_ 49, 50

      Bye
       PetaMem

      Edit by tye to change PRE tags to CODE tags

        You're right, things are worse than I thought. And yes, cross-referencing usage starts from large ammount of code.

        Anyway, did you tried latest perl (5.8.0-RC1)?
        Just curious.
        Also, thank you for your experience, with your help I will be careful when will be planning using any compiler stuff.

        Courage, the Cowardly Dog.
        PS. Something fishy is going on there, or my name is Vadim Konovalov. And it's not.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://171502]
Approved by talexb
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-03-19 05:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found