Beefy Boxes and Bandwidth Generously Provided by pair Networks kudra
"be consistent"
 
PerlMonks  

Re^8: can't import using exporter

by perl-diddler (Friar)
on Mar 15, 2012 at 08:29 UTC ( #959746=note: print w/ replies, xml ) Need Help??


in reply to Re^7: can't import using exporter
in thread can't import using exporter

The entire program was included for anyone who wanted to reproduce the problem. If no one could reproduce the problem, it is because they didn't try. Not because the source wasn't there.

Every workaround and suggestion to fix the problem didn't work. I'd say it wasn't a trivial problem.

In fact chromatic, a veteran perler admitted, that it'd be too ugly to do it the way you did it.

But thanks for proving the concept. It will useful on more than one level -- including on a reason why

'use module' should simply do it's import mechanics on packages already defined in the current file.

But believe me, I appreciate the example.


Comment on Re^8: can't import using exporter
Re^9: can't import using exporter
by Corion (Pope) on Mar 15, 2012 at 09:33 UTC

    I tried to hint at you that you should put in more effort into making it easy for other people to reproduce your problem. The easier it is for people to reproduce your problem and to inspect your code, the more likely it is that a solution or a workaround will be presented.

    Dumping the whole code, littered with stuff inconsequential to the problem, like Readonly and weird aliasing, is not what I call effort, and it also does not help in making the problem obvious. This is menial work that you should have done yourself instead of running around in circles and screaming that you are the only person in the world who has encountered this bug in 5.14.x. Whenever you feel that you are the only person to have found a fundamental bug in a language, or in a compiler, I recommend doubting your own understanding of the matter instead of running around and claiming you have found the bug and everybody ignores you. Also see I am great at communicating, but people are bad at listening. If you feel that nobody understands you, it is far more likely that your communication is bad, than that people are bad at listening.

    That you think that "use module" should do what you want is your prerogative. If you want to use Perl instead of your fantasy language though, it behooves you to read use to actually see what the use keyword does. Understanding that, and learning about how Perl exporting and symbol aliasing works will then also help you understand why your attempt fails as it does and why the BEGIN shehanigans are neccesary if you want to keep the rest of your program structure as is.

    Personally, I recommend splitting up the program into separate files and not relying on weird initialization dances like first initializing lexical variables, just to initialize global variables from them. Again, see App::fatpacker if you are hell-bent on producing a single file after developing your program.

      Um... there are a few things your example doesn't do nor solve, yet proves. (!?!?)

      you put 90% of the the program in BEGIN{}.

      You can't develop a program entirely in Begin.

      As soon as you start including parts not in begin, you'll run into the fact that you didn't duplicate all of the definitions -- the 2nd being outside of the begin, so that warnings/strict don't complain.

      Now you have 2 sets of defines -- those inside the begins, and those outside. You've doubled the development and maintenance.

      None of the standard ways to ways suggested worked. While you may have found a workaround that works for you, that is not proving there is not a flaw in perl 5.14.x -- and that standard methods others suggest don't work, neither about 2 dozen more than I tried before coming here.

      That's still fits the definition of broken usability, which still fits the definition of a bug.

      The problem with simplifying all those pesky aliases and RO var, is that oft' times the problem becomes induplicable.

      BTW, I have NEVER accused people of being bad at listening, I *SUCK* at communicating, ok? I know it. I'm stuck with it. I've taken courses, been to therapy, I'm defective -- unfortunately for me and the world. More times than not, I have it together enough to be understood without an interpreter, but have, on occasion, found that helpful!...

      I trebly hesitate to post anything for me running up into another wall or another hard place. It isn't usually worth the effort. I figured this time, I'd tried everything except rewriting the program all inside a BEGIN statement. The use Module(util). and it's usage was the last suggestion mentioned to me on 5.10, when this was brought up -- and worked then -- it doesn't anymore.

      The module suggested doesn't run on 5.14 without errors -- indicating that 5.14 has now broken it as well. Sure, it may be the modules fault, but if perl is breaking all these programs -- that is another bug -- it's not supposed to be breaking backwards compatibility without a "use feature"...

      Your program is a onerous, though proven, workaround, but it also gives ample fodder to any perl-hater out there about how broken a language perl is, because having to do that to have multiple classes in the same file is broken.

      But I honest still appreciate the work and effort you put into it, and have saved it... but that type of effort shouldn't be required for so little gain, nor should being required to write your code all one way.

      Perl was supposed to be about the freedom to do things 20-100 different ways, and now, it's all one way, or a straight-jacket (people go crazy that way, don'thcha know?)...

        Perl was supposed to be about the freedom to do things 20-100 different ways...

        If you throw a random mess of nonsense at the compiler and expect it to do what you think you mean, you're going to spend a lot of time surprised at the results.

        Um... there are a few things your example doesn't do nor solve, yet proves.

        Nonsense. What Corion wrote is correct.

        ... standard methods others suggest don't work...

        Utter nonsense. Code I wrote that's been run countless millions of times would not work if that were true, and millions of successful test reports from CPAN Testers alone demonstrates that that feature works as it has for years.

        ... Sorry. Breaking apart a 800 line perl prog that was a 185 line shell script , into a 10-15 file perl monster is messed up. ... The problem with simplifying all those pesky aliases and RO var, is that oft' times the problem becomes induplicable. ...

        This process is called debugging. If you are programming, you should familiarize yourself with it. If the problem becomes "induplicable", that means you have just eliminated one source of your problems. But it feels to me that you prefer others to put effort in solving your problems over cleaning your room first before asking for help.

        ... you put 90% of the the program in BEGIN{}. ... You can't develop a program entirely in Begin.

        My approach mechanically reproduces what use does. If that does not suit you, then you will have to restructure your code in a way that it does not rely on how use works. I'm not sure why you are hell-bent on doing things the way you do them, but I showed you where your approach fails and how you need to modify your approach to get to a result. Your impression that "standard methods" don't work is owed to the fact that you did not present the relevant code and did not show how you tried to rely on symbol exports happening at the right time. The "standard methods" rely on the programmer understanding Perl and understanding how and when symbols are exported from modules. I suggest that you learn more Perl.

        Also, it may surprise you, but you can easily develop a program entirely in BEGIN blocks, as long as you understand what BEGIN blocks are and what they do.

        The module suggested doesn't run on 5.14 without errors -- indicating that 5.14 has now broken it as well.

        Again, extraordinary claims require extraordinary evidence. The CPAN tester Matrix for Module::Util shows no breakage, and you have shown lots of broken code that you produce, and concepts that you misunderstand or ignore. In so far, I really, really recommend that you don't claim things that you do not have a program with less than 10 short lines for to reproduce them.

        Your program is a onerous, though proven, workaround, but it also gives ample fodder to any perl-hater out there about how broken a language perl is, because having to do that to have multiple classes in the same file is broken.

        No. You don't need to do any of that to have multiple classes in the same file. This only shows that you don't understand what you are doing. You are not declaring a single class in your code. As you claim to be educated by merlyn and brian d foy, it would amuse me if you found a section in their books or a statement by them where they claim that your shown approach is somehow object oriented and has entities where "class" would be an appropriate moniker. Especially the lack of the bless keyword is a certain indicator that you are not dealing with objects and classes in your code.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://959746]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2014-04-18 01:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (460 votes), past polls