Perl Cd Bookshelf [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Perl Cd Bookshelf [Electronic resources] - نسخه متنی

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید










31.3. use base



use base qw(Mother Father);



This pragma lets a programmer conveniently declare a derived class
based upon the listed parent classes. The declaration above is
roughly equivalent to:


BEGIN {
require Mother;
require Father;
push @ISA, qw(Mother Father);
}


The use base pragma takes care of any require needed. When the
strict 'vars' pragma is in scope, use base lets you (in effect)
assign to @ISA without first having to declare our @ISA. (Since the
use base pragma happens at compile time, it's best to avoid diddling
@ISA on your own at run time.)

But beyond this, use base has another property. If any named base
class makes use of the fields facility described under use fields
later in this chapter, then the pragma initializes the package's
special field attributes from the base class. (Multiple inheritance of
field classes is not supported. The use base pragma raises an
exception if more than one named base class has fields.)

Any base class not yet loaded will be loaded automatically via
require. However, whether to require a base class package is
determined not by the customary inspection of %INC, but by the absence
of a global $VERSION in the base package. This hack keeps Perl from
repeatedly trying (and failing) to load a base class that isn't in its
own requirable file (because, for example, it's loaded as part of some
other module's file). If $VERSION is not detected after successfully
loading a file, use base will define $VERSION in the base package,
setting it to the string "-1, defined by base.pm".






/ 875