leohan <> wrote:
> Tad McClellan ??:
>> leohan <> wrote:
>> > about Lint.pm perl module, which is kind of warning module.
^^^^^^^
^^^^^^^
>> I cannot find that module on CPAN.
>
> It is not yet finished, it now in progress,
I thought you said yours was named LintEX, I'm trying to find
the Lint module that you mention, there are a bunch of them:
B::Lint
Test::HTML::Lint
HTML::Lint
MARC::Lint
Apache::Lint
But there *are no* modules named simply "Lint"...
>> Did you instead mean the B::Lint module?
You must have meant the B::Lint module, as you've copied its
docs into your PDF.
>> Have you looked into using B::Lint:
luggable rather than
>> creating an entirely new module?
>
> I didn't heard about B::Lint:
luggable before,
You are developing a module named "Lint" but you didn't search
CPAN to see other modules named "Lint"?
That seems an inefficient development method...
>> > Here's a pdf slide file, which listed bug patterns.
>>
>> Why not just post the POD for your module?
>
> I did this presentation in my laboratory this morning, and I had no
> time to post it
> as POD.
You should have started with POD. You could probaby get "pod2pdf"
to generate your slides for you from the pod.
>> You use "Errors" in your title when precious few of the warnings
>> it produces actually are errors.
>
> then, should I change the "Errors" to "fault"?
I would use "warnings" instead of "errors".
The standard docs (eg. perldiag.pod) for Perl make this same distinction.
>> > open STDOUT, "foo.pl";
>>
>> 1) That is (intended to be) the standard idiom for redirecting STDOUT.
>>
>> You are saying that it is an "error" or "bug" to redirect STDOUT?
>>
>> Seems to me like a reasonable (ie. not buggy) thing to want to do...
You didn't comment on my comment there.
Let me restate my comment:
Your module should not warn about things that are reasonable
in error-free code.
It is reasonable to redirect STDOUT.
Otherwise, folks that want to do this reasonable thing will not
make use of your module.
(Personally, I think this idea is a bit of "The Boy Who Cried Wolf",
I doubt that I would ever use a module that spit out 20 warnings
when my response to 18 of them is "I _meant_ to do that" while
only 2 actually find something worth changing.
)
>> 2) Opening STDOUT only for *input* like that actually _is_ an "error".
>>
>> Does your module warn when you open STDOUT for input?
>
> no
It should. Shouldn't it?
>> 3) You should always, yes *always*, check the return value from open().
>>
>> Does your module warn when you do not test the return value from open?
>
> no, but do you mean some thing like following die expression?
>
> open IN, "file" or die "warning: no file";
Yes. Or something like:
unless ( open IN, "file" )
{ do something, maybe call die() }
or
return unless open IN, "file";
Basically, it should warn whenever open() is not in a "boolean context".
>> Does your module warn when you have a package variable in the
>> current package with the same name as a lexical variable that
>> is in scope?
>> our $x;
>> my $x;
>
> yes, my module is warn at this case.
Ack!
So if someone wants to use your module, and have it report nothing,
they must keep track of every variable name in their entire program
to ensure that they don't use a different variable with the same name?
Now I'm to the point that I doubt I would even bother to install
the module, let alone use it.
>> What does an "unassigned function" mean?
>> (I think you meant "undefined function"?)
>
> my God, that my stupid mistake. I'm not from English speaking country,
> so
> I made such mistake...
No problem.
> Thanks for your kindness to correct this.
You're welcome.
I have a good bit of experience decoding English-from-a-Korean-speaker,
because that is how my wife speaks.
>> > redefine variable
>>
>>
>> I am pretty sure that you mean "redeclare variable" there instead.
I'm not too sure that you understand the profound difference
between "declare" and "define". Please keep at it until you
see how they are very very different.
>> Using double quotes when single quotes would do.
>
> is it worthwhile? what is the problem?
the hard-to-read:
"C:\\Program Files\\Sell Your Soul"
becomes the less-hard-to-read:
'C:\Program Files\Sell Your Soul'
But the most important reason is that it an opportunity to
indicate your intent:
'the cost is $100'
where $100 is intended to be literal, while
"the cost is $100"
means you better have a pattern with at least 100 set of
parenthesis in your program.
When debugging:
Single quotes mean "no variable here, no need to pay close attention
to the contents of this string".
Double quotes mean "might be a variable in here, better look carefully"
so:
my $str = "this is a pretty long string. it takes a long time to read";
"tricks" the maintenance coder into spending more time on this
line of code than would be needed had the original programmer written:
my $str = 'this is a pretty long string. it takes a long time to read';
>> Using variables named $a or $b.
>
> do you mean my module should warn all these simple variable names?
No, I mean that it should warn only for those 2 exact names,
because they are "special variables" used by the sort() function.
>> Calling a subroutine using an ampersand.
>
> do you mean using subroutine like following should warn?
> &foo();
Yes.
> why?
perldoc -q "&"
What's the difference between calling a function as &foo and foo()?
> But do you really think that these kind of light weight analyzer useful
> in perl world?
No, in my opinion.
--
Tad McClellan SGML consulting
Perl programming
Fort Worth, Texas