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

📄 overload.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
📖 第 1 页 / 共 4 页
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" Set up some character translations and predefined strings.  \*(-- will.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left.\" double quote, and \*(R" will give a right double quote.  \*(C+ will.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,.\" nothing in troff, for use with C<>..tr \(*W-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\.    ds -- \(*W-.    ds PI pi.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch.    ds L" "".    ds R" "".    ds C` "".    ds C' ""'br\}.el\{\.    ds -- \|\(em\|.    ds PI \(*p.    ds L" ``.    ds R" '''br\}.\".\" Escape single quotes in literal strings from groff's Unicode transform..ie \n(.g .ds Aq \(aq.el       .ds Aq '.\".\" If the F register is turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD.  Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\.    de IX.    tm Index:\\$1\t\\n%\t"\\$2"...    nr % 0.    rr F.\}.el \{\.    de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear.  Run.  Save yourself.  No user-serviceable parts..    \" fudge factors for nroff and troff.if n \{\.    ds #H 0.    ds #V .8m.    ds #F .3m.    ds #[ \f1.    ds #] \fP.\}.if t \{\.    ds #H ((1u-(\\\\n(.fu%2u))*.13m).    ds #V .6m.    ds #F 0.    ds #[ \&.    ds #] \&.\}.    \" simple accents for nroff and troff.if n \{\.    ds ' \&.    ds ` \&.    ds ^ \&.    ds , \&.    ds ~ ~.    ds /.\}.if t \{\.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u".    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}.    \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E.    \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'.    \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\.    ds : e.    ds 8 ss.    ds o a.    ds d- d\h'-1'\(ga.    ds D- D\h'-1'\(hy.    ds th \o'bp'.    ds Th \o'LP'.    ds ae ae.    ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "overload 3".TH overload 3 "2007-12-18" "perl v5.10.0" "Perl Programmers Reference Guide".\" For nroff, turn off justification.  Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..if n .ad l.nh.SH "NAME"overload \- Package for overloading Perl operations.SH "SYNOPSIS".IX Header "SYNOPSIS".Vb 1\&    package SomeThing;\&\&    use overload\&        \*(Aq+\*(Aq => \e&myadd,\&        \*(Aq\-\*(Aq => \e&mysub;\&        # etc\&    ...\&\&    package main;\&    $a = new SomeThing 57;\&    $b=5+$a;\&    ...\&    if (overload::Overloaded $b) {...}\&    ...\&    $strval = overload::StrVal $b;.Ve.SH "DESCRIPTION".IX Header "DESCRIPTION".Sh "Declaration of overloaded functions".IX Subsection "Declaration of overloaded functions"The compilation directive.PP.Vb 4\&    package Number;\&    use overload\&        "+" => \e&add,\&        "*=" => "muas";.Ve.PPdeclares function \fINumber::add()\fR for addition, and method \fImuas()\fR inthe \*(L"class\*(R" \f(CW\*(C`Number\*(C'\fR (or one of its base classes)for the assignment form \f(CW\*(C`*=\*(C'\fR of multiplication..PPArguments of this directive come in (key, value) pairs.  Legal valuesare values legal inside a \f(CW\*(C`&{ ... }\*(C'\fR call, so the name of asubroutine, a reference to a subroutine, or an anonymous subroutinewill all work.  Note that values specified as strings areinterpreted as methods, not subroutines.  Legal keys are listed below..PPThe subroutine \f(CW\*(C`add\*(C'\fR will be called to execute \f(CW\*(C`$a+$b\*(C'\fR if \f(CW$a\fRis a reference to an object blessed into the package \f(CW\*(C`Number\*(C'\fR, or if \f(CW$a\fR isnot an object from a package with defined mathemagic addition, but \f(CW$b\fR is areference to a \f(CW\*(C`Number\*(C'\fR.  It can also be called in other situations, like\&\f(CW\*(C`$a+=7\*(C'\fR, or \f(CW\*(C`$a++\*(C'\fR.  See \*(L"\s-1MAGIC\s0 \s-1AUTOGENERATION\s0\*(R".  (Mathemagicalmethods refer to methods triggered by an overloaded mathematicaloperator.).PPSince overloading respects inheritance via the \f(CW@ISA\fR hierarchy, theabove declaration would also trigger overloading of \f(CW\*(C`+\*(C'\fR and \f(CW\*(C`*=\*(C'\fR inall the packages which inherit from \f(CW\*(C`Number\*(C'\fR..Sh "Calling Conventions for Binary Operations".IX Subsection "Calling Conventions for Binary Operations"The functions specified in the \f(CW\*(C`use overload ...\*(C'\fR directive are calledwith three (in one particular case with four, see \*(L"Last Resort\*(R")arguments.  If the corresponding operation is binary, then the firsttwo arguments are the two arguments of the operation.  However, due togeneral object calling conventions, the first argument should always bean object in the package, so in the situation of \f(CW\*(C`7+$a\*(C'\fR, theorder of the arguments is interchanged.  It probably does not matterwhen implementing the addition method, but whether the argumentsare reversed is vital to the subtraction method.  The method canquery this information by examining the third argument, which can takethree different values:.IP "\s-1FALSE\s0" 7.IX Item "FALSE"the order of arguments is as in the current operation..IP "\s-1TRUE\s0" 7.IX Item "TRUE"the arguments are reversed..ie n .IP """undef""" 7.el .IP "\f(CWundef\fR" 7.IX Item "undef"the current operation is an assignment variant (as in\&\f(CW\*(C`$a+=7\*(C'\fR), but the usual function is called instead.  This additionalinformation can be used to generate some optimizations.  Compare\&\*(L"Calling Conventions for Mutators\*(R"..Sh "Calling Conventions for Unary Operations".IX Subsection "Calling Conventions for Unary Operations"Unary operation are considered binary operations with the secondargument being \f(CW\*(C`undef\*(C'\fR.  Thus the functions that overloads \f(CW\*(C`{"++"}\*(C'\fRis called with arguments \f(CW\*(C`($a,undef,\*(Aq\*(Aq)\*(C'\fR when \f(CW$a\fR++ is executed..Sh "Calling Conventions for Mutators".IX Subsection "Calling Conventions for Mutators"Two types of mutators have different calling conventions:.ie n .IP """++""\fR and \f(CW""\-\-""" 4.el .IP "\f(CW++\fR and \f(CW\-\-\fR" 4.IX Item "++ and --"The routines which implement these operators are expected to actually\&\fImutate\fR their arguments.  So, assuming that \f(CW$obj\fR is a reference to anumber,.Sp.Vb 1\&  sub incr { my $n = $ {$_[0]}; ++$n; $_[0] = bless \e$n}.Ve.Spis an appropriate implementation of overloaded \f(CW\*(C`++\*(C'\fR.  Note that.Sp.Vb 1\&  sub incr { ++$ {$_[0]} ; shift }.Ve.Spis \s-1OK\s0 if used with preincrement and with postincrement. (In the caseof postincrement a copying will be performed, see \*(L"Copy Constructor\*(R".).ie n .IP """x="" and other assignment versions" 4.el .IP "\f(CWx=\fR and other assignment versions" 4.IX Item "x= and other assignment versions"There is nothing special about these methods.  They may change thevalue of their arguments, and may leave it as is.  The result is goingto be assigned to the value in the left-hand-side if different fromthis value..SpThis allows for the same method to be used as overloaded \f(CW\*(C`+=\*(C'\fR and\&\f(CW\*(C`+\*(C'\fR.  Note that this is \fIallowed\fR, but not recommended, since by thesemantic of \*(L"Fallback\*(R" Perl will call the method for \f(CW\*(C`+\*(C'\fR anyway,if \f(CW\*(C`+=\*(C'\fR is not overloaded..PP\&\fBWarning.\fR  Due to the presence of assignment versions of operations,routines which may be called in assignment context may createself-referential structures.  Currently Perl will not free self-referentialstructures until cycles are \f(CW\*(C`explicitly\*(C'\fR broken.  You may get problemswhen traversing your structures too..PPSay,.PP.Vb 1\&  use overload \*(Aq+\*(Aq => sub { bless [ \e$_[0], \e$_[1] ] };.Ve.PPis asking for trouble, since for code \f(CW\*(C`$obj += $foo\*(C'\fR the subroutineis called as \f(CW\*(C`$obj = add($obj, $foo, undef)\*(C'\fR, or \f(CW\*(C`$obj = [\e$obj,\&\e$foo]\*(C'\fR.  If using such a subroutine is an important optimization, onecan overload \f(CW\*(C`+=\*(C'\fR explicitly by a non\-\*(L"optimized\*(R" version, or switchto non-optimized version if \f(CW\*(C`not defined $_[2]\*(C'\fR (see\&\*(L"Calling Conventions for Binary Operations\*(R")..PPEven if no \fIexplicit\fR assignment-variants of operators are present inthe script, they may be generated by the optimizer.  Say, \f(CW",$obj,"\fR or\&\f(CW\*(Aq,\*(Aq . $obj . \*(Aq,\*(Aq\fR may be both optimized to.PP.Vb 1\&  my $tmp = \*(Aq,\*(Aq . $obj;    $tmp .= \*(Aq,\*(Aq;.Ve.Sh "Overloadable Operations".IX Subsection "Overloadable Operations"The following symbols can be specified in \f(CW\*(C`use overload\*(C'\fR directive:.IP "\(bu" 5\&\fIArithmetic operations\fR.Sp.Vb 2\&    "+", "+=", "\-", "\-=", "*", "*=", "/", "/=", "%", "%=",\&    "**", "**=", "<<", "<<=", ">>", ">>=", "x", "x=", ".", ".=",.Ve.SpFor these operations a substituted non-assignment variant can be called ifthe assignment variant is not available.  Methods for operations \f(CW\*(C`+\*(C'\fR,\&\f(CW\*(C`\-\*(C'\fR, \f(CW\*(C`+=\*(C'\fR, and \f(CW\*(C`\-=\*(C'\fR can be called to automatically generateincrement and decrement methods.  The operation \f(CW\*(C`\-\*(C'\fR can be used toautogenerate missing methods for unary minus or \f(CW\*(C`abs\*(C'\fR..SpSee \*(L"\s-1MAGIC\s0 \s-1AUTOGENERATION\s0\*(R", \*(L"Calling Conventions for Mutators\*(R" and\&\*(L"Calling Conventions for Binary Operations\*(R") for details of thesesubstitutions..IP "\(bu" 5\&\fIComparison operations\fR.Sp.Vb 2\&    "<",  "<=", ">",  ">=", "==", "!=", "<=>",\&    "lt", "le", "gt", "ge", "eq", "ne", "cmp",.Ve.SpIf the corresponding \*(L"spaceship\*(R" variant is available, it can beused to substitute for the missing operation.  During \f(CW\*(C`sort\*(C'\fRingarrays, \f(CW\*(C`cmp\*(C'\fR is used to compare values subject to \f(CW\*(C`use overload\*(C'\fR..IP "\(bu" 5\&\fIBit operations\fR.Sp.Vb 1\&    "&", "&=", "^", "^=", "|", "|=", "neg", "!", "~",.Ve.Sp\&\f(CW\*(C`neg\*(C'\fR stands for unary minus.  If the method for \f(CW\*(C`neg\*(C'\fR is notspecified, it can be autogenerated using the method forsubtraction. If the method for \f(CW\*(C`!\*(C'\fR is not specified, it can beautogenerated using the methods for \f(CW\*(C`bool\*(C'\fR, or \f(CW""\fR, or \f(CW\*(C`0+\*(C'\fR..SpThe same remarks in \*(L"Arithmetic operations\*(R" aboutassignment-variants and autogeneration apply forbit operations \f(CW"&"\fR, \f(CW"^"\fR, and \f(CW"|"\fR as well..IP "\(bu" 5\&\fIIncrement and decrement\fR.Sp.Vb 1\&    "++", "\-\-",.Ve.SpIf undefined, addition and subtraction methods can beused instead.  These operations are called both in prefix andpostfix form..IP "\(bu" 5\&\fITranscendental functions\fR.Sp.Vb 1\&    "atan2", "cos", "sin", "exp", "abs", "log", "sqrt", "int".Ve.SpIf \f(CW\*(C`abs\*(C'\fR is unavailable, it can be autogenerated using methodsfor \*(L"<\*(R" or \*(L"<=>\*(R" combined with either unary minus or subtraction..SpNote that traditionally the Perl function int rounds to 0, thus forfloating-point-like types one should follow the same semantic.  If\&\f(CW\*(C`int\*(C'\fR is unavailable, it can be autogenerated using the overloading of\&\f(CW\*(C`0+\*(C'\fR..IP "\(bu" 5\&\fIBoolean, string and numeric conversion\fR.Sp.Vb 1\&    \*(Aqbool\*(Aq, \*(Aq""\*(Aq, \*(Aq0+\*(Aq,

⌨️ 快捷键说明

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