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

Re: The Law of Inconsistent Assumptions

by ihb (Deacon)
on Oct 20, 2004 at 15:30 UTC ( [id://400894]=note: print w/replies, xml ) Need Help??


in reply to The Law of Inconsistent Assumptions

The previous example correctly sends a warning based on the assumption that the name main::fee should appear at least twice in a single script.

That statement is a bit too vague and I'll explain why below.

The previous example sends a spurious warning message because the former assumption breaks down

It's only spurious if it is based on the assumption you say it's based on, but as I'll come to, it's not necessarily based on that assumption.

incomplete assumptions about what constitutes a "single script"

I neither agree or disagree, but I more disagree than I agree. I'd stretch as far as saying that you may have an incomplete assumption of what the warning means, and that's why you think it breaks down and you think a spurious warning is emitted. What the warning really means, but doesn't clearly say, is 'Name "main::fee" used (i.e. seen) once (at compile-time)'. It's got nothing to do with where the variable is seen, but when.

Your program is one thing during compile-time. Your program can be another during run-time and can change infinately many times during run-time. The warning is looking at what your program is during compile-time. If you put a BEGIN block around your require() the problem would've been solved and the warning goes away, as the variable is now seen more than once during compile-time. The problem is no different from doing eval '$main::fee = 0xfee'. Perl has no way of knowing that you use that you use $main::fee since the usage of $main::fee is not a part of your program yet.

ihb

See perltoc if you don't know which perldoc to read!
Read argumentation in its context!

Replies are listed 'Best First'.
Re^2: The Law of Inconsistent Assumptions
by dimar (Curate) on Oct 20, 2004 at 20:08 UTC

    Your point regarding the 'compile time' versus 'run time' distinction is a point well-taken.

    From a technical perspective, your point helps to identify and zero in on a key issue. From a communication perspective, it helps to demonstrate how "the law" (TLIA) can creep into even this very discussion.

    Perl has no way of knowing that you use ... $main::fee since the usage of $main::fee is not a part of your program yet.

    Although the whole "throwaway warnings" example is not my favorite, the point I hoped to illustrate was *precisely* that people can have "inconsistent assumptions" about what constitutes "part of your program yet."

    One person can take the (admittedly more complete) assumption that a program is "finished" only after it has compiled, run and terminated. Another person can take the (admittedly more simplistic ... and perhaps even deeply flawed) assumption that a program is "finished" once he or she has written all the source code and saved it to disk.

    Because of TLIA, I guess the point is, this kind of "disagreement" (aka divergence of assumptions) does not even get out into the open (what does the word "finished" mean) until: 1) someone proactively asserts "active listening"; or 2) something more "messy" like a contract dispute arises.

    I guess the other point is, TLIA is something I (and perhaps others) need to be more keenly aware of in general...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-25 06:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found