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

📄 mro.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
📖 第 1 页 / 共 2 页
字号:
methods from \f(CW\*(C`UNIVERSAL\*(C'\fR and its parents..ie n .Sh "mro::set_mro($classname, $type)".el .Sh "mro::set_mro($classname, \f(CW$type\fP)".IX Subsection "mro::set_mro($classname, $type)"Sets the \s-1MRO\s0 of the given class to the \f(CW$type\fR argument (either\&\f(CW\*(C`c3\*(C'\fR or \f(CW\*(C`dfs\*(C'\fR)..Sh "mro::get_mro($classname)".IX Subsection "mro::get_mro($classname)"Returns the \s-1MRO\s0 of the given class (either \f(CW\*(C`c3\*(C'\fR or \f(CW\*(C`dfs\*(C'\fR)..Sh "mro::get_isarev($classname)".IX Subsection "mro::get_isarev($classname)"Gets the \f(CW\*(C`mro_isarev\*(C'\fR for this class, returned as anarrayref of class names.  These are every class that \*(L"isa\*(R"the given class name, even if the isa relationship isindirect.  This is used internally by the \s-1MRO\s0 code tokeep track of method/MRO cache invalidations..PPCurrently, this list only grows, it never shrinks.  Thiswas a performance consideration (properly tracking anddeleting isarev entries when someone removes an entryfrom an \f(CW@ISA\fR is costly, and it doesn't happen oftenanyways).  The fact that a class which no longer truly\&\*(L"isa\*(R" this class at runtime remains on the list should beconsidered a quirky implementation detail which is subjectto future change.  It shouldn't be an issue as long asyou're looking at this list for the same reasons thecore code does: as a performance optimizationover having to search every class in existence..PPAs with \f(CW\*(C`mro::get_mro\*(C'\fR above, \f(CW\*(C`UNIVERSAL\*(C'\fR is special.\&\f(CW\*(C`UNIVERSAL\*(C'\fR (and parents') isarev lists do not includeevery class in existence, even though all classes areeffectively descendants for method inheritance purposes..Sh "mro::is_universal($classname)".IX Subsection "mro::is_universal($classname)"Returns a boolean status indicating whether or notthe given classname is either \f(CW\*(C`UNIVERSAL\*(C'\fR itself,or one of \f(CW\*(C`UNIVERSAL\*(C'\fR's parents by \f(CW@ISA\fR inheritance..PPAny class for which this function returns true is\&\*(L"universal\*(R" in the sense that all classes potentiallyinherit methods from it..PPFor similar reasons to \f(CW\*(C`isarev\*(C'\fR above, this flag ispermanent.  Once it is set, it does not go away, evenif the class in question really isn't universal anymore..Sh "\fImro::invalidate_all_method_caches()\fP".IX Subsection "mro::invalidate_all_method_caches()"Increments \f(CW\*(C`PL_sub_generation\*(C'\fR, which invalidates methodcaching in all packages..Sh "mro::method_changed_in($classname)".IX Subsection "mro::method_changed_in($classname)"Invalidates the method cache of any classes dependent on thegiven class.  This is not normally necessary.  The onlyknown case where pure perl code can confuse the methodcache is when you manually install a new constantsubroutine by using a readonly scalar value, like theinternals of constant do.  If you find another case,please report it so we can either fix it or documentthe exception here..Sh "mro::get_pkg_gen($classname)".IX Subsection "mro::get_pkg_gen($classname)"Returns an integer which is incremented every time areal local method in the package \f(CW$classname\fR changes,or the local \f(CW@ISA\fR of \f(CW$classname\fR is modified..PPThis is intended for authors of modules which do lotsof class introspection, as it allows them to very quicklycheck if anything important about the local propertiesof a given class have changed since the last time theylooked.  It does not increment on method/\f(CW@ISA\fRchanges in superclasses..PPIt's still up to you to seek out the actual changes,and there might not actually be any.  Perhaps allof the changes since you last checked cancelled eachother out and left the package in the state it was inbefore..PPThis integer normally starts off at a value of \f(CW1\fRwhen a package stash is instantiated.  Calling iton packages whose stashes do not exist at all willreturn \f(CW0\fR.  If a package stash is completelydeleted (not a normal occurence, but it can happenif someone does something like \f(CW\*(C`undef %PkgName::\*(C'\fR),the number will be reset to either \f(CW0\fR or \f(CW1\fR,depending on how completely package was wiped out..Sh "next::method".IX Subsection "next::method"This is somewhat like \f(CW\*(C`SUPER\*(C'\fR, but it uses the C3 methodresolution order to get better consistency in multipleinheritance situations.  Note that while inheritance ingeneral follows whichever \s-1MRO\s0 is in effect for thegiven class, \f(CW\*(C`next::method\*(C'\fR only uses the C3 \s-1MRO\s0..PPOne generally uses it like so:.PP.Vb 5\&  sub some_method {\&    my $self = shift;\&    my $superclass_answer = $self\->next::method(@_);\&    return $superclass_answer + 1;\&  }.Ve.PPNote that you don't (re\-)specify the method name.It forces you to always use the same method nameas the method you started in..PPIt can be called on an object or a class, of course..PPThe way it resolves which actual method to call is:.IP "1." 4First, it determines the linearized C3 \s-1MRO\s0 ofthe object or class it is being called on..IP "2." 4Then, it determines the class and method nameof the context it was invoked from..IP "3." 4Finally, it searches down the C3 \s-1MRO\s0 list untilit reaches the contextually enclosing class, thensearches further down the \s-1MRO\s0 list for the nextmethod with the same name as the contextuallyenclosing method..PPFailure to find a next method will result in anexception being thrown (see below for alternatives)..PPThis is substantially different than the behaviorof \f(CW\*(C`SUPER\*(C'\fR under complex multiple inheritance.(This becomes obvious when one realizes that thecommon superclasses in the C3 linearizations ofa given class and one of its parents will notalways be ordered the same for both.).PP\&\fBCaveat\fR: Calling \f(CW\*(C`next::method\*(C'\fR from methods defined outside the class:.PPThere is an edge case when using \f(CW\*(C`next::method\*(C'\fR from within a subroutinewhich was created in a different module than the one it is called from. Itsounds complicated, but it really isn't. Here is an example which will notwork correctly:.PP.Vb 1\&  *Foo::foo = sub { (shift)\->next::method(@_) };.Ve.PPThe problem exists because the anonymous subroutine being assigned to the\&\f(CW*Foo::foo\fR glob will show up in the call stack as being called\&\f(CW\*(C`_\|_ANON_\|_\*(C'\fR and not \f(CW\*(C`foo\*(C'\fR as you might expect. Since \f(CW\*(C`next::method\*(C'\fR uses\&\f(CW\*(C`caller\*(C'\fR to find the name of the method it was called in, it will fail inthis case..PPBut fear not, there's a simple solution. The module \f(CW\*(C`Sub::Name\*(C'\fR willreach into the perl internals and assign a name to an anonymous subroutinefor you. Simply do this:.PP.Vb 2\&  use Sub::Name \*(Aqsubname\*(Aq;\&  *Foo::foo = subname \*(AqFoo::foo\*(Aq => sub { (shift)\->next::method(@_) };.Ve.PPand things will Just Work..Sh "next::can".IX Subsection "next::can"This is similar to \f(CW\*(C`next::method\*(C'\fR, but just returns either a codereference or \f(CW\*(C`undef\*(C'\fR to indicate that no further methods of this nameexist..Sh "maybe::next::method".IX Subsection "maybe::next::method"In simple cases, it is equivalent to:.PP.Vb 1\&   $self\->next::method(@_) if $self\->next_can;.Ve.PPBut there are some cases where only this solutionworks (like \f(CW\*(C`goto &maybe::next::method\*(C'\fR);.SH "SEE ALSO".IX Header "SEE ALSO".Sh "The original Dylan paper".IX Subsection "The original Dylan paper".IP "<http://www.webcom.com/haahr/dylan/linearization\-oopsla96.html>" 4.IX Item "<http://www.webcom.com/haahr/dylan/linearization-oopsla96.html>".Sh "The prototype Perl 6 Object Model uses C3".IX Subsection "The prototype Perl 6 Object Model uses C3".PD 0.IP "<http://svn.openfoundry.org/pugs/perl5/Perl6\-MetaModel/>" 4.IX Item "<http://svn.openfoundry.org/pugs/perl5/Perl6-MetaModel/>".PD.Sh "Parrot now uses C3".IX Subsection "Parrot now uses C3".IP "<http://aspn.activestate.com/ASPN/Mail/Message/perl6\-internals/2746631>" 4.IX Item "<http://aspn.activestate.com/ASPN/Mail/Message/perl6-internals/2746631>".PD 0.IP "<http://use.perl.org/~autrijus/journal/25768>" 4.IX Item "<http://use.perl.org/~autrijus/journal/25768>".PD.Sh "Python 2.3 \s-1MRO\s0 related links".IX Subsection "Python 2.3 MRO related links".IP "<http://www.python.org/2.3/mro.html>" 4.IX Item "<http://www.python.org/2.3/mro.html>".PD 0.IP "<http://www.python.org/2.2.2/descrintro.html#mro>" 4.IX Item "<http://www.python.org/2.2.2/descrintro.html#mro>".PD.Sh "C3 for TinyCLOS".IX Subsection "C3 for TinyCLOS".IP "<http://www.call\-with\-current\-continuation.org/eggs/c3.html>" 4.IX Item "<http://www.call-with-current-continuation.org/eggs/c3.html>".Sh "Class::C3".IX Subsection "Class::C3".PD 0.IP "Class::C3" 4.IX Item "Class::C3".PD.SH "AUTHOR".IX Header "AUTHOR"Brandon L. Black, <blblack@gmail.com>.PPBased on Stevan Little's Class::C3

⌨️ 快捷键说明

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