perl-Carp-Assert-0.21-4.1.noarch.rpm


Advertisement

Description

perl-Carp-Assert - executable comments

Property Value
Distribution openSUSE Leap 42.2
Repository openSUSE Oss all
Package name perl-Carp-Assert
Package version 0.21
Package release 4.1
Package architecture noarch
Package type rpm
Installed size 28.27 KB
Download size 21.94 KB
Official Mirror ftp.gwdg.de
"We are ready for any unforseen event that may or may not
occur."
- Dan Quayle
Carp::Assert is intended for a purpose like the ANSI C library
http://en.wikipedia.org/wiki/Assert.h. If you're already familiar with
assert.h, then you can probably skip this and go straight to the FUNCTIONS
section.
Assertions are the explicit expressions of your assumptions about the
reality your program is expected to deal with, and a declaration of those
which it is not. They are used to prevent your program from blissfully
processing garbage inputs (garbage in, garbage out becomes garbage in,
error out) and to tell you when you've produced garbage output. (If I was
going to be a cynic about Perl and the user nature, I'd say there are no
user inputs but garbage, and Perl produces nothing but...)
An assertion is used to prevent the impossible from being asked of your
code, or at least tell you when it does. For example:
sub my_sqrt {
my($num) = shift;
assert($num >= 0);
return sqrt $num;
}
The assertion will warn you if a negative number was handed to your
subroutine, a reality the routine has no intention of dealing with.
An assertion should also be used as something of a reality check, to make
sure what your code just did really did happen:
open(FILE, $filename) || die $!;
@stuff = <FILE>;
@stuff = do_something(@stuff);
assert(@stuff > 0);
The assertion makes sure you have some @stuff at the end. Maybe the file
was empty, maybe do_something() returned an empty list... either way, the
assert() will give you a clue as to where the problem lies, rather than 50
lines down at when you wonder why your program isn't printing anything.
Since assertions are designed for debugging and will remove themelves from
production code, your assertions should be carefully crafted so as to not
have any side-effects, change any variables, or otherwise have any effect
on your program. Here is an example of a bad assertation:
assert($error = 1 if $king ne 'Henry');  # Bad!
It sets an error flag which may then be used somewhere else in your
program. When you shut off your assertions with the $DEBUG flag, $error
will no longer be set.
Here's another example of *bad* use:
assert($next_pres ne 'Dan Quayle' or goto Canada);  # Bad!
This assertion has the side effect of moving to Canada should it fail. This
is a very bad assertion since error handling should not be placed in an
assertion, nor should it have side-effects.
In short, an assertion is an executable comment. For instance, instead of
writing this
$life = begin_life();
you'd replace the comment with an assertion which *enforces* the comment.
$life = begin_life();
assert( $life =~ /!$/ );

Alternatives

Package Version Architecture Repository
perl-Carp-Assert - - -

Requires

Name Value
perl(:MODULE_COMPAT_5.18.2) -
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsLzma) <= 4.4.6-1

Provides

Name Value
perl(Carp::Assert) = 0.21
perl-Carp-Assert = 0.21-4.1

Download

Type URL
Binary Package perl-Carp-Assert-0.21-4.1.noarch.rpm
Source Package perl-Carp-Assert-0.21-4.1.src.rpm

Install Howto

Install perl-Carp-Assert rpm package:

# zypper install perl-Carp-Assert

See Also

Package Description
perl-Carp-Assert-More-1.14-6.1.noarch.rpm Convenience wrappers around Carp::Assert
perl-Carp-Clan-6.04-26.2.noarch.rpm Carp::Clan Perl module
perl-Carton-1.0.28-1.1.noarch.rpm Perl module dependency manager (aka Bundler for Perl)
perl-Catalyst-Manual-5.9009-4.1.noarch.rpm The Catalyst developer's manual
perl-Chart-2.4.10-4.1.noarch.rpm Series of Charting Modules
perl-Class-Accessor-0.34-26.1.x86_64.rpm Automated accessor generation
perl-Class-Accessor-Chained-0.01-16.1.x86_64.rpm Make chained accessors
perl-Class-Accessor-Grouped-0.10012-3.1.noarch.rpm Lets you build groups of accessors
perl-Class-Accessor-Lite-0.08-4.1.noarch.rpm Minimalistic Variant of Class::Accessor
perl-Class-Adapter-1.08-13.1.noarch.rpm Perl implementation of the "Adapter" Design Pattern
perl-Class-Autouse-2.01-11.1.x86_64.rpm Run-time class loading on first method call
perl-Class-Base-0.06-4.1.noarch.rpm useful base class for deriving other modules
perl-Class-C3-0.31-1.1.noarch.rpm Pragma to Use the C3 Method Resolution Order Algorithm
perl-Class-C3-Adopt-NEXT-0.14-2.1.noarch.rpm Make Next Suck Less
perl-Class-C3-Componentised-1.001000-10.1.noarch.rpm Class::C3::Componentised Perl module
Advertisement
Advertisement