⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 attributes.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
📖 第 1 页 / 共 2 页
字号:
explicitly taken with the \f(CW\*(C`lock\*(C'\fR operator immediately after thesubroutine is entered..IP "method" 4.IX Item "method"Indicates that the referenced subroutine is a method.This has a meaning when taken together with the \fBlocked\fR attribute,as described there.  It also means that a subroutine so markedwill not trigger the \*(L"Ambiguous call resolved as CORE::%s\*(R" warning..IP "lvalue" 4.IX Item "lvalue"Indicates that the referenced subroutine is a valid lvalue and canbe assigned to. The subroutine must return a modifiable value suchas a scalar variable, as described in perlsub..PPFor global variables there is \f(CW\*(C`unique\*(C'\fR attribute: see \*(L"our\*(R" in perlfunc..Sh "Available Subroutines".IX Subsection "Available Subroutines"The following subroutines are available for general use once this modulehas been loaded:.IP "get" 4.IX Item "get"This routine expects a single parameter\*(--a reference to asubroutine or variable.  It returns a list of attributes, which may beempty.  If passed invalid arguments, it uses \fIdie()\fR (via Carp::croak)to raise a fatal exception.  If it can find an appropriate package namefor a class method lookup, it will include the results from a\&\f(CW\*(C`FETCH_\f(CItype\f(CW_ATTRIBUTES\*(C'\fR call in its return list, as described in\&\*(L"Package-specific Attribute Handling\*(R" below.Otherwise, only built-in attributes will be returned..IP "reftype" 4.IX Item "reftype"This routine expects a single parameter\*(--a reference to a subroutine orvariable.  It returns the built-in type of the referenced variable,ignoring any package into which it might have been blessed.This can be useful for determining the \fItype\fR value which forms part ofthe method names described in \*(L"Package-specific Attribute Handling\*(R" below..PPNote that these routines are \fInot\fR exported by default..Sh "Package-specific Attribute Handling".IX Subsection "Package-specific Attribute Handling"\&\fB\s-1WARNING\s0\fR: the mechanisms described here are still experimental.  Do notrely on the current implementation.  In particular, there is no provisionfor applying package attributes to 'cloned' copies of subroutines used asclosures.  (See \*(L"Making References\*(R" in perlref for information on closures.)Package-specific attribute handling may change incompatibly in a futurerelease..PPWhen an attribute list is present in a declaration, a check is made to seewhether an attribute 'modify' handler is present in the appropriate package(or its \f(CW@ISA\fR inheritance tree).  Similarly, when \f(CW\*(C`attributes::get\*(C'\fR iscalled on a valid reference, a check is made for an appropriate attribute\&'fetch' handler.  See \*(L"\s-1EXAMPLES\s0\*(R" to see how the \*(L"appropriate package\*(R"determination works..PPThe handler names are based on the underlying type of the variable beingdeclared or of the reference passed.  Because these attributes areassociated with subroutine or variable declarations, this deliberatelyignores any possibility of being blessed into some package.  Thus, asubroutine declaration uses \*(L"\s-1CODE\s0\*(R" as its \fItype\fR, and even a blessedhash reference uses \*(L"\s-1HASH\s0\*(R" as its \fItype\fR..PPThe class methods invoked for modifying and fetching are these:.IP "\s-1FETCH_\s0\fItype\fR_ATTRIBUTES" 4.IX Item "FETCH_type_ATTRIBUTES"This method is called with two arguments:  the relevant package name,and a reference to a variable or subroutine for which package-definedattributes are desired.  The expected return value is a list ofassociated attributes.  This list may be empty..IP "\s-1MODIFY_\s0\fItype\fR_ATTRIBUTES" 4.IX Item "MODIFY_type_ATTRIBUTES"This method is called with two fixed arguments, followed by the list ofattributes from the relevant declaration.  The two fixed arguments arethe relevant package name and a reference to the declared subroutine orvariable.  The expected return value is a list of attributes which werenot recognized by this handler.  Note that this allows for a derived classto delegate a call to its base class, and then only examine the attributeswhich the base class didn't already handle for it..SpThe call to this method is currently made \fIduring\fR the processing of thedeclaration.  In particular, this means that a subroutine reference willprobably be for an undefined subroutine, even if this declaration isactually part of the definition..PPCalling \f(CW\*(C`attributes::get()\*(C'\fR from within the scope of a null packagedeclaration \f(CW\*(C`package ;\*(C'\fR for an unblessed variable reference willnot provide any starting package name for the 'fetch' method lookup.Thus, this circumstance will not result in a method call for package-definedattributes.  A named subroutine knows to which symbol table entry it belongs(or originally belonged), and it will use the corresponding package.An anonymous subroutine knows the package name into which it was compiled(unless it was also compiled with a null package declaration), and so itwill use that package name..Sh "Syntax of Attribute Lists".IX Subsection "Syntax of Attribute Lists"An attribute list is a sequence of attribute specifications, separated bywhitespace or a colon (with optional whitespace).Each attribute specification is a simplename, optionally followed by a parenthesised parameter list.If such a parameter list is present, it is scanned past as for the rulesfor the \f(CW\*(C`q()\*(C'\fR operator.  (See \*(L"Quote and Quote-like Operators\*(R" in perlop.)The parameter list is passed as it was found, however, and not as per \f(CW\*(C`q()\*(C'\fR..PPSome examples of syntactically valid attribute lists:.PP.Vb 4\&    switch(10,foo(7,3))  :  expensive\&    Ugly(\*(Aq\e(") :Bad\&    _5x5\&    locked method.Ve.PPSome examples of syntactically invalid attribute lists (with annotation):.PP.Vb 5\&    switch(10,foo()             # ()\-string not balanced\&    Ugly(\*(Aq(\*(Aq)                   # ()\-string not balanced\&    5x5                         # "5x5" not a valid identifier\&    Y2::north                   # "Y2::north" not a simple identifier\&    foo + bar                   # "+" neither a colon nor whitespace.Ve.SH "EXPORTS".IX Header "EXPORTS".Sh "Default exports".IX Subsection "Default exports"None..Sh "Available exports".IX Subsection "Available exports"The routines \f(CW\*(C`get\*(C'\fR and \f(CW\*(C`reftype\*(C'\fR are exportable..Sh "Export tags defined".IX Subsection "Export tags defined"The \f(CW\*(C`:ALL\*(C'\fR tag will get all of the above exports..SH "EXAMPLES".IX Header "EXAMPLES"Here are some samples of syntactically valid declarations, with annotationas to how they resolve internally into \f(CW\*(C`use attributes\*(C'\fR invocations byperl.  These examples are primarily useful to see how the \*(L"appropriatepackage\*(R" is found for the possible method lookups for package-definedattributes..IP "1." 4Code:.Sp.Vb 3\&    package Canine;\&    package Dog;\&    my Canine $spot : Watchful ;.Ve.SpEffect:.Sp.Vb 2\&    use attributes ();\&    attributes::\->import(Canine => \e$spot, "Watchful");.Ve.IP "2." 4Code:.Sp.Vb 2\&    package Felis;\&    my $cat : Nervous;.Ve.SpEffect:.Sp.Vb 2\&    use attributes ();\&    attributes::\->import(Felis => \e$cat, "Nervous");.Ve.IP "3." 4Code:.Sp.Vb 2\&    package X;\&    sub foo : locked ;.Ve.SpEffect:.Sp.Vb 1\&    use attributes X => \e&foo, "locked";.Ve.IP "4." 4Code:.Sp.Vb 2\&    package X;\&    sub Y::x : locked { 1 }.Ve.SpEffect:.Sp.Vb 1\&    use attributes Y => \e&Y::x, "locked";.Ve.IP "5." 4Code:.Sp.Vb 2\&    package X;\&    sub foo { 1 }\&\&    package Y;\&    BEGIN { *bar = \e&X::foo; }\&\&    package Z;\&    sub Y::bar : locked ;.Ve.SpEffect:.Sp.Vb 1\&    use attributes X => \e&X::foo, "locked";.Ve.PPThis last example is purely for purposes of completeness.  You should notbe trying to mess with the attributes of something in a package that'snot your own..SH "SEE ALSO".IX Header "SEE ALSO"\&\*(L"Private Variables via \fImy()\fR\*(R" in perlsub and\&\*(L"Subroutine Attributes\*(R" in perlsub for details on the basic declarations;attrs for the obsolescent form of subroutine attribute specificationwhich this module replaces;\&\*(L"use\*(R" in perlfunc for details on the normal invocation mechanism.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -